Changeset 23963


Ignore:
Timestamp:
05/30/19 14:53:00 (6 years ago)
Author:
Mathieu Morlighem
Message:

CHG: working on channels

File:
1 edited

Legend:

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

    r23962 r23963  
    1414#include "../classes.h"
    1515/*}}}*/
     16
     17/*Macros*/
    1618#define NUMNODES    2
    1719#define NUMVERTICES 2
     20
     21#define C_W         4.22e3   /*specific heat capacity of water (J/kg/K)*/
     22#define ALPHA_C     5./4.
     23#define BETA_C      3./2.
     24/*Make sure these are the same as in HydrologyGlaDSAnalysis::CreateKMatrix*/
     25#define ALPHA_S     5./4.
     26#define BETA_S      3./2.
    1827
    1928/*Channel constructors and destructor*/
     
    338347
    339348        /*Intermediaries */
    340         IssmDouble  Jdet,v1;
    341         IssmDouble  A,B,n,phi_old,phi,phi_0;
    342         IssmDouble  H,h,b;
     349        IssmDouble  Jdet,v1,qc,fFactor;
     350        IssmDouble  A,B,n,phi_old,phi,phi_0,dPw;
     351        IssmDouble  H,h,b,dphi[2],dphids,dphimds,db[2],dbds;
    343352        IssmDouble  xyz_list[NUMVERTICES][3];
    344353        IssmDouble  xyz_list_tria[3][3];
     
    354363        GetVerticesCoordinates(&xyz_list[0][0]     ,this->vertices,NUMVERTICES);
    355364        GetVerticesCoordinates(&xyz_list_tria[0][0],tria->vertices,3);
     365
    356366        IssmDouble L         = element->FindParam(MaterialsLatentheatEnum);
    357367        IssmDouble rho_ice   = element->FindParam(MaterialsRhoIceEnum);
     
    359369        IssmDouble dt        = element->FindParam(TimesteppingTimeStepEnum);
    360370        IssmDouble g         = element->FindParam(ConstantsGEnum);
     371        IssmDouble kc        = element->FindParam(HydrologyChannelConductivityEnum);
     372        IssmDouble ks        = element->FindParam(HydrologySheetConductivityEnum);
     373        IssmDouble lc        = element->FindParam(HydrologyChannelSheetWidthEnum);
     374        IssmDouble c_t       = element->FindParam(HydrologyPressureMeltCoefficientEnum);
     375
    361376        Input* h_input      = element->GetInput(HydrologySheetThicknessEnum);_assert_(h_input);
    362377        Input* H_input      = element->GetInput(ThicknessEnum); _assert_(H_input);
     
    381396                tria->GetSegmentNodalFunctions(&basis[0],gauss,index1,index2,tria->FiniteElement());
    382397                tria->GetSegmentNodalFunctionsDerivatives(&dbasisdx[0],&xyz_list_tria[0][0],gauss,index1,index2,tria->FiniteElement());
     398                dbasisds[0] = dbasisdx[0*2+0]*tx + dbasisdx[0*2+1]*ty;
     399                dbasisds[1] = dbasisdx[1*2+0]*tx + dbasisdx[1*2+1]*ty;
    383400
    384401                /*Get input values at gauss points*/
     402                phi_input->GetInputValue(&phi,gauss);
     403                phi_input->GetInputDerivativeValue(&dphi[0],&xyz_list_tria[0][0],gauss);
    385404                h_input->GetInputValue(&h,gauss);
    386405                B_input->GetInputValue(&B,gauss);
    387406                n_input->GetInputValue(&n,gauss);
    388                 phi_input->GetInputValue(&phi,gauss);
    389407                b_input->GetInputValue(&b,gauss);
     408                b_input->GetInputDerivativeValue(&db[0],&xyz_list_tria[0][0],gauss);
    390409                H_input->GetInputValue(&H,gauss);
    391410
     411                /*Get values for a few potentials*/
     412                phi_0   = rho_water*g*b + rho_ice*g*H;
     413                dphids  = dphi[0]*tx + dphi[1]*ty;
     414                dphimds = rho_water*g*(db[0]*tx + db[1]*ty);
     415
     416                /*Compute the effective conductivity Kc = k h^alpha |grad Phi|^{beta-2} (same for sheet)*/
     417                IssmDouble Kc = kc * pow(this->S,ALPHA_C) * pow(fabs(dphids),BETA_C-2.);
     418                IssmDouble Ks = ks * pow(h      ,ALPHA_S) * pow(fabs(dphids),BETA_S-2.);
     419
     420                /*Approx. discharge in the sheet flowing folwing in the direction of the channel ofver a width lc*/
     421                qc = - Ks * dphids;
     422
     423                /*d(phi - phi_m)/ds*/
     424                dPw = dphids - dphimds;
     425
     426                /*Compute f factor*/
     427                fFactor = 0.;
     428                if(this->S>0. || qc*dPw>0.){
     429                        fFactor = lc * qc;
     430                }
     431
     432                /*Diffusive term*/
     433                for(int i=0;i<numnodes;i++){
     434                        for(int j=0;j<numnodes;j++){
     435                                Ke->values[i*numnodes+j] += gauss->weight*Jdet*(
     436                                                        +Kc*dbasisds[i]*dbasisds[j] /*GlaDSCoupledSolver.F90 line 1659*/
     437                                                        );
     438                        }
     439                }
     440
    392441                /*Closing rate term, see Gagliardini and Werder 2018 eq. A2 (v = v1*phi_i + v2(phi_{i+1}))*/
    393                 phi_0 = rho_water*g*b + rho_ice*g*H;
    394442                A=pow(B,-n);
    395443                v1 = 2./pow(n,n)*A*S*(pow(fabs(phi_0 - phi),n-1.)*( - n));
Note: See TracChangeset for help on using the changeset viewer.