Changeset 23964


Ignore:
Timestamp:
05/30/19 15:30:59 (6 years ago)
Author:
Mathieu Morlighem
Message:

CHG: finished RHS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/Loads/Channel.cpp

    r23963 r23964  
    347347
    348348        /*Intermediaries */
    349         IssmDouble  Jdet,v1,qc,fFactor;
     349        IssmDouble  Jdet,v1,qc,fFactor,Afactor,Bfactor,Xifactor;
    350350        IssmDouble  A,B,n,phi_old,phi,phi_0,dPw;
    351351        IssmDouble  H,h,b,dphi[2],dphids,dphimds,db[2],dbds;
     
    367367        IssmDouble rho_ice   = element->FindParam(MaterialsRhoIceEnum);
    368368        IssmDouble rho_water = element->FindParam(MaterialsRhoFreshwaterEnum);
    369         IssmDouble dt        = element->FindParam(TimesteppingTimeStepEnum);
    370369        IssmDouble g         = element->FindParam(ConstantsGEnum);
    371370        IssmDouble kc        = element->FindParam(HydrologyChannelConductivityEnum);
     
    430429                }
    431430
     431                /*Compute Afactor and Bfactor*/
     432                Afactor = C_W*c_t*rho_water;
     433                Bfactor = 1./L * (1./rho_ice - 1./rho_water);
     434                if(dphids>0){
     435                        Xifactor = + Bfactor * (fabs(-Kc*dphids) + fabs(lc*qc));
     436                }
     437                else{
     438                        Xifactor = - Bfactor * (fabs(-Kc*dphids) + fabs(lc*qc));
     439                }
     440
    432441                /*Diffusive term*/
    433442                for(int i=0;i<numnodes;i++){
    434443                        for(int j=0;j<numnodes;j++){
     444                                /*GlaDSCoupledSolver.F90 line 1659*/
    435445                                Ke->values[i*numnodes+j] += gauss->weight*Jdet*(
    436                                                         +Kc*dbasisds[i]*dbasisds[j] /*GlaDSCoupledSolver.F90 line 1659*/
     446                                                        +Kc*dbasisds[i]*dbasisds[j]                               /*Diffusion term*/
     447                                                        - Afactor * Bfactor* Kc * dPw * basis[i] * dbasisds[j]    /*First part of Pi*/
     448                                                        + Afactor * fFactor * Bfactor * basis[i] * dbasisds[j]    /*Second part of Pi*/
     449                                                        + Xifactor* basis[i] * dbasisds[j]                        /*Xi term*/
    437450                                                        );
    438451                        }
     
    447460                        }
    448461                }
    449 
    450                 /*Transient term if dt>0*/
    451                 if(dt>0.){
    452                 }
    453462        }
    454463
     
    468477
    469478        /*Intermediaries */
    470         IssmDouble  Jdet,v2;
    471         IssmDouble  A,B,n,phi_old,phi,phi_0;
    472         IssmDouble  H,h,b;
     479        IssmDouble  Jdet,v2,Afactor,Bfactor,fFactor;
     480        IssmDouble  A,B,n,phi_old,phi,phi_0,dphimds;
     481        IssmDouble  H,h,b,db[2],dphids,qc,dPw;
    473482        IssmDouble  xyz_list[NUMVERTICES][3];
     483        IssmDouble  xyz_list_tria[3][3];
    474484        const int   numnodes = NUMNODES;
    475485
     
    480490        /*Retrieve all inputs and parameters*/
    481491        GetVerticesCoordinates(&xyz_list[0][0],this->vertices,NUMVERTICES);
     492        GetVerticesCoordinates(&xyz_list_tria[0][0],tria->vertices,3);
     493
    482494        IssmDouble L         = element->FindParam(MaterialsLatentheatEnum);
    483495        IssmDouble rho_ice   = element->FindParam(MaterialsRhoIceEnum);
    484496        IssmDouble rho_water = element->FindParam(MaterialsRhoFreshwaterEnum);
    485         IssmDouble dt        = element->FindParam(TimesteppingTimeStepEnum);
     497        IssmDouble kc        = element->FindParam(HydrologyChannelConductivityEnum);
     498        IssmDouble ks        = element->FindParam(HydrologySheetConductivityEnum);
    486499        IssmDouble g         = element->FindParam(ConstantsGEnum);
     500        IssmDouble lc        = element->FindParam(HydrologyChannelSheetWidthEnum);
     501        IssmDouble c_t       = element->FindParam(HydrologyPressureMeltCoefficientEnum);
     502
    487503        Input* h_input      = element->GetInput(HydrologySheetThicknessEnum);_assert_(h_input);
    488504        Input* H_input      = element->GetInput(ThicknessEnum); _assert_(H_input);
     
    493509        Input* phi_input    = element->GetInput(HydraulicPotentialEnum);         _assert_(phi_input);
    494510
     511        /*Get tangent vector*/
     512        IssmDouble tx = xyz_list_tria[index2][0] - xyz_list_tria[index1][0];
     513        IssmDouble ty = xyz_list_tria[index2][1] - xyz_list_tria[index1][1];
     514        tx = tx/sqrt(tx*tx+ty*ty);
     515        ty = ty/sqrt(tx*tx+ty*ty);
     516
    495517        /* Start  looping on the number of gaussian points: */
    496518        Gauss* gauss=new GaussTria(index1,index2,2);
     
    502524
    503525                /*Get input values at gauss points*/
     526                b_input->GetInputDerivativeValue(&db[0],&xyz_list_tria[0][0],gauss);
    504527                h_input->GetInputValue(&h,gauss);
    505528                B_input->GetInputValue(&B,gauss);
     
    509532                H_input->GetInputValue(&H,gauss);
    510533
     534                /*Get values for a few potentials*/
     535                dphimds = rho_water*g*(db[0]*tx + db[1]*ty);
     536
     537                /*Compute the effective conductivity Kc = k h^alpha |grad Phi|^{beta-2} (same for sheet)*/
     538                IssmDouble Kc = kc * pow(this->S,ALPHA_C) * pow(fabs(dphids),BETA_C-2.);
     539                IssmDouble Ks = ks * pow(h      ,ALPHA_S) * pow(fabs(dphids),BETA_S-2.);
     540
     541                /*Approx. discharge in the sheet flowing folwing in the direction of the channel ofver a width lc*/
     542                qc = - Ks * dphids;
     543
     544                /*d(phi - phi_m)/ds*/
     545                dPw = dphids - dphimds;
     546
     547                /*Compute f factor*/
     548                fFactor = 0.;
     549                if(this->S>0. || qc*dPw>0.){
     550                        fFactor = lc * qc;
     551                }
     552
     553                /*Compute Afactor and Bfactor*/
     554                Afactor = C_W*c_t*rho_water;
     555                Bfactor = 1./L * (1./rho_ice - 1./rho_water);
     556
    511557                /*Compute closing rate*/
    512558                /*See Gagliardini and Werder 2018 eq. A2 (v = v2(phi_i) + v1*phi_{i+1})*/
     
    515561                v2 = 2./pow(n,n)*A*this->S*(pow(fabs(phi_0 - phi),n-1.)*(phi_0 +(n-1.)*phi));
    516562
    517                 for(int i=0;i<numnodes;i++) pe->values[i]+= - Jdet*gauss->weight*(-v2)*basis[i];
    518 
    519                 /*Transient term if dt>0*/
    520                 if(dt>0.){
    521                         //phiold_input->GetInputValue(&phi_old,gauss);
    522                         //for(int i=0;i<numnodes;i++) pe->values[i] += gauss->weight*Jdet*e_v/(rho_water*g*dt)*phi_old*basis[i];
     563                for(int i=0;i<numnodes;i++){
     564                        pe->values[i]+= - Jdet*gauss->weight*(-v2)*basis[i];
     565                        pe->values[i]+= + Jdet*gauss->weight*Afactor*Bfactor*fFactor*dphimds*basis[i];
    523566                }
    524567        }
Note: See TracChangeset for help on using the changeset viewer.