source: issm/oecreview/Archive/23390-24306/ISSM-23964-23965.diff

Last change on this file was 24307, checked in by Mathieu Morlighem, 5 years ago

NEW: adding Archive/23390-24306

File size: 8.5 KB
  • ../trunk-jpl/src/c/analyses/HydrologyGlaDSAnalysis.cpp

     
    371371}/*}}}*/
    372372void           HydrologyGlaDSAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/
    373373        element->InputUpdateFromSolutionOneDof(solution,HydraulicPotentialEnum);
    374         this->UpdateEffectivePressure(element);
    375374}/*}}}*/
    376375void           HydrologyGlaDSAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/
    377376        /*Default, do nothing*/
     
    509508        delete gauss;
    510509        xDelete<IssmDouble>(N);
    511510}/*}}}*/
     511void HydrologyGlaDSAnalysis::UpdateChannelCrossSection(FemModel* femmodel){/*{{{*/
     512
     513        bool ischannels;
     514        femmodel->parameters->FindParam(&ischannels,HydrologyIschannelsEnum);
     515        if(!ischannels) return;
     516
     517        for(int i=0;i<femmodel->loads->Size();i++){
     518                if(femmodel->loads->GetEnum(i)==ChannelEnum){
     519                        Channel* channel=(Channel*)femmodel->loads->GetObjectByOffset(i);
     520                        channel->UpdateChannelCrossSection();
     521                }
     522        }
     523
     524}/*}}}*/
  • ../trunk-jpl/src/c/analyses/HydrologyGlaDSAnalysis.h

     
    3333                /*Specific to GlaDS*/
    3434                void UpdateSheetThickness(FemModel* femmodel);
    3535                void UpdateSheetThickness(Element*  element);
     36                void UpdateChannelCrossSection(FemModel* femmodel);
    3637                void UpdateEffectivePressure(FemModel* femmodel);
    37                 void UpdateEffectivePressure(Element*  element);
     38                void UpdateEffectivePressure(Element* element);
    3839};
    3940#endif
  • ../trunk-jpl/src/c/cores/hydrology_core.cpp

     
    197197                InputDuplicatex(femmodel,HydraulicPotentialEnum,HydraulicPotentialOldEnum);
    198198                analysis->UpdateEffectivePressure(femmodel);
    199199                solutionsequence_shakti_nonlinear(femmodel);
    200                 if(VerboseSolution()) _printf0_("   updating sheet thickness\n");
     200
     201                if(VerboseSolution()) _printf0_("   updating effective pressure\n");
     202                analysis->UpdateEffectivePressure(femmodel);
     203                if(VerboseSolution()) _printf0_("   updating sheet thickness\n"); /*Uses N, so needs to come after*/
    201204                analysis->UpdateSheetThickness(femmodel);
     205                if(VerboseSolution()) _printf0_("   updating channels cross section\n");
     206                analysis->UpdateChannelCrossSection(femmodel);
    202207                delete analysis;
    203208        }
    204209
  • ../trunk-jpl/src/c/classes/Loads/Channel.cpp

     
    571571        return pe;
    572572}
    573573/*}}}*/
     574void           Channel::UpdateChannelCrossSection(void){/*{{{*/
     575
     576        /*Initialize Element matrix and return if necessary*/
     577        Tria*  tria=(Tria*)element;
     578        if(!tria->IsIceInElement()){
     579                this->S = 0.;
     580                return;
     581        }
     582        _assert_(tria->FiniteElement()==P1Enum);
     583        int index1=tria->GetNodeIndex(nodes[0]);
     584        int index2=tria->GetNodeIndex(nodes[1]);
     585
     586        /*Intermediaries */
     587        IssmDouble  Jdet,v1,qc,fFactor,Afactor,Bfactor,Xifactor;
     588        IssmDouble  A,B,n,phi_old,phi,phi_0,dPw;
     589        IssmDouble  H,h,b,dphi[2],dphids,dphimds,db[2],dbds;
     590        IssmDouble  xyz_list[NUMVERTICES][3];
     591        IssmDouble  xyz_list_tria[3][3];
     592        const int   numnodes = NUMNODES;
     593
     594        /*Initialize Element vector and other vectors*/
     595        ElementMatrix* Ke=new ElementMatrix(this->nodes,NUMNODES,this->parameters);
     596        IssmDouble     basis[NUMNODES];
     597        IssmDouble     dbasisdx[2*NUMNODES];
     598        IssmDouble     dbasisds[NUMNODES];
     599
     600        /*Retrieve all inputs and parameters*/
     601        GetVerticesCoordinates(&xyz_list[0][0]     ,this->vertices,NUMVERTICES);
     602        GetVerticesCoordinates(&xyz_list_tria[0][0],tria->vertices,3);
     603
     604        IssmDouble L         = element->FindParam(MaterialsLatentheatEnum);
     605        IssmDouble rho_ice   = element->FindParam(MaterialsRhoIceEnum);
     606        IssmDouble rho_water = element->FindParam(MaterialsRhoFreshwaterEnum);
     607        IssmDouble g         = element->FindParam(ConstantsGEnum);
     608        IssmDouble kc        = element->FindParam(HydrologyChannelConductivityEnum);
     609        IssmDouble ks        = element->FindParam(HydrologySheetConductivityEnum);
     610        IssmDouble lc        = element->FindParam(HydrologyChannelSheetWidthEnum);
     611        IssmDouble c_t       = element->FindParam(HydrologyPressureMeltCoefficientEnum);
     612
     613        Input* h_input      = element->GetInput(HydrologySheetThicknessEnum);_assert_(h_input);
     614        Input* H_input      = element->GetInput(ThicknessEnum); _assert_(H_input);
     615        Input* b_input      = element->GetInput(BedEnum); _assert_(b_input);
     616        Input* B_input      = element->GetInput(MaterialsRheologyBEnum);         _assert_(B_input);
     617        Input* n_input      = element->GetInput(MaterialsRheologyNEnum);         _assert_(n_input);
     618        Input* phiold_input = element->GetInput(HydraulicPotentialOldEnum);      _assert_(phiold_input);
     619        Input* phi_input    = element->GetInput(HydraulicPotentialEnum);         _assert_(phi_input);
     620
     621        /*Get tangent vector*/
     622        IssmDouble tx = xyz_list_tria[index2][0] - xyz_list_tria[index1][0];
     623        IssmDouble ty = xyz_list_tria[index2][1] - xyz_list_tria[index1][1];
     624        tx = tx/sqrt(tx*tx+ty*ty);
     625        ty = ty/sqrt(tx*tx+ty*ty);
     626
     627        /*Evaluate fields on center of edge*/
     628        GaussTria* gauss=new GaussTria();
     629        gauss->GaussEdgeCenter(index1,index2);
     630
     631        tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss);
     632        tria->GetSegmentNodalFunctions(&basis[0],gauss,index1,index2,tria->FiniteElement());
     633        tria->GetSegmentNodalFunctionsDerivatives(&dbasisdx[0],&xyz_list_tria[0][0],gauss,index1,index2,tria->FiniteElement());
     634        dbasisds[0] = dbasisdx[0*2+0]*tx + dbasisdx[0*2+1]*ty;
     635        dbasisds[1] = dbasisdx[1*2+0]*tx + dbasisdx[1*2+1]*ty;
     636
     637        /*Get input values at gauss points*/
     638        phi_input->GetInputValue(&phi,gauss);
     639        phi_input->GetInputDerivativeValue(&dphi[0],&xyz_list_tria[0][0],gauss);
     640        h_input->GetInputValue(&h,gauss);
     641        B_input->GetInputValue(&B,gauss);
     642        n_input->GetInputValue(&n,gauss);
     643        b_input->GetInputValue(&b,gauss);
     644        b_input->GetInputDerivativeValue(&db[0],&xyz_list_tria[0][0],gauss);
     645        H_input->GetInputValue(&H,gauss);
     646
     647        /*Get values for a few potentials*/
     648        phi_0   = rho_water*g*b + rho_ice*g*H;
     649        dphids  = dphi[0]*tx + dphi[1]*ty;
     650        dphimds = rho_water*g*(db[0]*tx + db[1]*ty);
     651
     652        /*Compute the effective conductivity Kc = k h^alpha |grad Phi|^{beta-2} (same for sheet)*/
     653        IssmDouble Kc = kc * pow(this->S,ALPHA_C) * pow(fabs(dphids),BETA_C-2.);
     654        IssmDouble Ks = ks * pow(h      ,ALPHA_S) * pow(fabs(dphids),BETA_S-2.);
     655
     656        /*Approx. discharge in the sheet flowing folwing in the direction of the channel ofver a width lc*/
     657        qc = - Ks * dphids;
     658
     659        /*d(phi - phi_m)/ds*/
     660        dPw = dphids - dphimds;
     661
     662        /*Compute f factor*/
     663        fFactor = 0.;
     664        if(this->S>0. || qc*dPw>0.){
     665                fFactor = lc * qc;
     666        }
     667
     668        /*Compute Afactor and Bfactor*/
     669        Afactor = C_W*c_t*rho_water;
     670        Bfactor = 1./L * (1./rho_ice - 1./rho_water);
     671        if(dphids>0){
     672                Xifactor = + Bfactor * (fabs(-Kc*dphids) + fabs(lc*qc));
     673        }
     674        else{
     675                Xifactor = - Bfactor * (fabs(-Kc*dphids) + fabs(lc*qc));
     676        }
     677
     678        _error_("STOP");
     679
     680        /*Diffusive term*/
     681        for(int i=0;i<numnodes;i++){
     682                for(int j=0;j<numnodes;j++){
     683                        /*GlaDSCoupledSolver.F90 line 1659*/
     684                        Ke->values[i*numnodes+j] += gauss->weight*Jdet*(
     685                                                +Kc*dbasisds[i]*dbasisds[j]                               /*Diffusion term*/
     686                                                - Afactor * Bfactor* Kc * dPw * basis[i] * dbasisds[j]    /*First part of Pi*/
     687                                                + Afactor * fFactor * Bfactor * basis[i] * dbasisds[j]    /*Second part of Pi*/
     688                                                + Xifactor* basis[i] * dbasisds[j]                        /*Xi term*/
     689                                                );
     690                }
     691        }
     692
     693        /*Clean up and return*/
     694        delete gauss;
     695}
     696/*}}}*/
  • ../trunk-jpl/src/c/classes/Loads/Channel.h

     
    7373                void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum);
    7474                /*}}}*/
    7575                /*Channel management:{{{*/
    76                 void           GetNormal(IssmDouble* normal,IssmDouble xyz_list[4][3]);
     76                void           UpdateChannelCrossSection(void);
    7777                ElementVector* CreatePVectorHydrologyGlaDS(void);
    7878                ElementMatrix* CreateKMatrixHydrologyGlaDS(void);
    7979                /*}}}*/
Note: See TracBrowser for help on using the repository browser.