Changeset 17349


Ignore:
Timestamp:
02/25/14 17:45:51 (11 years ago)
Author:
bdef
Message:

CHG:Now computing the transfer between layer in an implicit way

Location:
issm/trunk-jpl/src/c
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/analyses/HydrologyDCEfficientAnalysis.cpp

    r17212 r17349  
    5555        iomodel->FetchDataToInput(elements,MeshElementonbedEnum);
    5656        iomodel->FetchDataToInput(elements,MeshElementonsurfaceEnum);
    57         iomodel->FetchDataToInput(elements,BasalforcingsMeltingRateEnum);
    5857        iomodel->FetchDataToInput(elements,EplHeadEnum);
     58        iomodel->FetchDataToInput(elements,SedimentHeadEnum);
    5959        iomodel->FetchDataToInput(elements,HydrologydcEplInitialThicknessEnum);
     60        iomodel->FetchDataToInput(elements,HydrologydcSedimentTransmitivityEnum);
    6061
    6162        //      iomodel->FetchDataToInput(elements,HydrologydcMaskEplactiveNodeEnum);
     
    140141        IssmDouble  D_scalar,Jdet,dt;
    141142        IssmDouble  epl_thickness;
     143        IssmDouble  transfer;
    142144        IssmDouble *xyz_list = NULL;
    143145
     
    154156        basalelement->GetVerticesCoordinates(&xyz_list);
    155157        basalelement->FindParam(&dt,TimesteppingTimeStepEnum);
    156         Input* thickness_input=basalelement->GetInput(HydrologydcEplThicknessEnum); _assert_(thickness_input);
    157         IssmDouble epl_specificstoring = EplSpecificStoring(basalelement);
    158         IssmDouble epl_conductivity    = basalelement->GetMaterialParameter(HydrologydcEplConductivityEnum);
     158        Input* thickness_input = basalelement->GetInput(HydrologydcEplThicknessEnum);          _assert_(thickness_input);
     159        IssmDouble epl_specificstoring   = EplSpecificStoring(basalelement);
     160        IssmDouble epl_conductivity      = basalelement->GetMaterialParameter(HydrologydcEplConductivityEnum);
    159161
    160162        /* Start  looping on the number of gaussian points: */
    161163        Gauss* gauss=basalelement->NewGauss(2);
    162164        for(int ig=gauss->begin();ig<gauss->end();ig++){
    163                 gauss->GaussPoint(ig);
    164 
    165                 basalelement->JacobianDeterminant(&Jdet,xyz_list,gauss);
    166                 thickness_input->GetInputValue(&epl_thickness,gauss);
     165                gauss           ->GaussPoint(ig);
     166                basalelement    ->JacobianDeterminant(&Jdet,xyz_list,gauss);
     167                thickness_input ->GetInputValue(&epl_thickness,gauss);
    167168
    168169                /*Diffusivity*/
     
    179180                /*Transient*/
    180181                if(dt!=0.){
    181                         basalelement->NodalFunctions(basis,gauss);
     182                        basalelement->NodalFunctions(&basis[0],gauss);
    182183                        D_scalar=epl_specificstoring*epl_thickness*gauss->weight*Jdet;
    183184                        TripleMultiply(basis,numnodes,1,0,
     
    185186                                                basis,1,numnodes,0,
    186187                                                &Ke->values[0],1);
    187                 }
    188         }
    189 
     188                       
     189                        /*Transfer EPL part*/
     190                        transfer=GetHydrologyKMatrixTransfer(basalelement,gauss);
     191                        basalelement->NodalFunctions(&basis[0],gauss);
     192                        D_scalar=transfer*gauss->weight*Jdet*dt;
     193                        TripleMultiply(basis,numnodes,1,0,
     194                                                                                 &D_scalar,1,1,0,
     195                                                                                 basis,1,numnodes,0,
     196                                                                                 &Ke->values[0],1);
     197                }
     198        }
    190199        /*Clean up and return*/
    191200        xDelete<IssmDouble>(xyz_list);
     
    224233        }
    225234        /*Intermediaries */
    226         IssmDouble dt,scalar,water_head,connectivity;
    227         IssmDouble transfer,residual,epl_thickness;
     235        IssmDouble dt,scalar,water_head;
     236        IssmDouble transfer;
     237        IssmDouble epl_thickness;
    228238        IssmDouble Jdet;
     239        IssmDouble residual,connectivity;
     240
    229241        IssmDouble *xyz_list     = NULL;
    230242        Input*      old_wh_input = NULL;
     
    240252        /*Retrieve all inputs and parameters*/
    241253        basalelement->GetVerticesCoordinates(&xyz_list);
     254        basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 
     255
     256        Input* residual_input  = basalelement->GetInput(SedimentHeadResidualEnum);    _assert_(residual_input);
     257        Input* thickness_input = basalelement->GetInput(HydrologydcEplThicknessEnum); _assert_(thickness_input);
     258        if(dt!= 0.){old_wh_input = basalelement->GetInput(EplHeadOldEnum);            _assert_(old_wh_input);}
     259
    242260        IssmDouble epl_specificstoring = EplSpecificStoring(basalelement);
    243         basalelement->FindParam(&dt,TimesteppingTimeStepEnum);
    244         Input* residual_input    = basalelement->GetInput(SedimentHeadResidualEnum);    _assert_(residual_input);
    245         Input* transfer_input    = basalelement->GetInput(WaterTransferEnum);           _assert_(transfer_input);
    246         Input* thickness_input   = basalelement->GetInput(HydrologydcEplThicknessEnum); _assert_(thickness_input);
    247         if(dt!= 0.){old_wh_input = basalelement->GetInput(EplHeadOldEnum);              _assert_(old_wh_input);}
    248261
    249262        /* Start  looping on the number of gaussian points: */
     
    252265                gauss->GaussPoint(ig);
    253266
    254                 basalelement->JacobianDeterminant(&Jdet,xyz_list,gauss);
    255                 basalelement->NodalFunctions(basis,gauss);
    256 
    257                 /*Loading term*/
    258                 transfer_input->GetInputValue(&transfer,gauss);
    259                 scalar = Jdet*gauss->weight*(-transfer);
    260                 if(dt!=0.) scalar = scalar*dt;
    261                
    262                 for(int i=0;i<numnodes;i++)pe->values[i]+=scalar*basis[i];
    263                
    264                 /*Transient term*/
     267                basalelement ->JacobianDeterminant(&Jdet,xyz_list,gauss);
     268                basalelement ->NodalFunctions(basis,gauss);
     269
     270                /*Transient and transfer terms*/
    265271                if(dt!=0.){
    266                         thickness_input->GetInputValue(&epl_thickness,gauss);
    267                         old_wh_input->GetInputValue(&water_head,gauss);
    268                         scalar = Jdet*gauss->weight*water_head*epl_specificstoring*epl_thickness;
     272                        old_wh_input    ->GetInputValue(&water_head,gauss);
     273                        thickness_input ->GetInputValue(&epl_thickness,gauss);
    269274                       
     275                        /*Dealing with the sediment part of the transfer term*/
     276                        transfer=GetHydrologyPVectorTransfer(basalelement,gauss);
     277                        scalar = Jdet*gauss->weight*((water_head*epl_specificstoring*epl_thickness)+(transfer*dt));
    270278                        for(int i=0;i<numnodes;i++)pe->values[i]+=scalar*basis[i];
    271279                }
     
    281289                residual_input->GetInputValue(&residual,gauss);
    282290                pe->values[iv]+=residual/connectivity;
     291
    283292        }
    284293
     
    318327       
    319328        IssmDouble* eplHeads    = xNew<IssmDouble>(numnodes);
    320         /* IssmDouble* relaxed    = xNew<IssmDouble>(numnodes); */
    321         /* IssmDouble* eplOldHeads    = xNew<IssmDouble>(numnodes); */
    322         IssmDouble  Stepping;
    323 
     329        IssmDouble* eplOldHeads    = xNew<IssmDouble>(numnodes);
    324330
    325331        /*Get previous water head*/
    326         //basalelement->GetInputListOnNodes(&eplOldHeads[0],EplHeadEnum);
     332        basalelement->GetInputListOnNodes(&eplOldHeads[0],EplHeadEnum);
    327333
    328334        /*Use the dof list to index into the solution vector: */
     
    330336                eplHeads[i]=solution[doflist[i]];
    331337                if(xIsNan<IssmDouble>(eplHeads[i])) _error_("NaN found in solution vector");
    332         }
    333        
    334         /* for(i=0;i<numnodes;i++) { */
    335         /*      relaxed[i] = eplOldHeads[i]+0.8*(eplHeads[i]-eplOldHeads[i]); */
    336         /* } */
     338
     339        }
    337340        /*Add input to the element: */
    338341        element->AddBasalInput(EplHeadEnum,eplHeads,P1Enum);
     
    358361        return rho_freshwater*g*epl_porosity*(water_compressibility+(epl_compressibility/epl_porosity));                 
    359362}/*}}}*/
     363IssmDouble HydrologyDCEfficientAnalysis::SedimentStoring(Element* element){/*{{{*/
     364        IssmDouble rho_freshwater           = element->GetMaterialParameter(MaterialsRhoFreshwaterEnum);
     365        IssmDouble g                        = element->GetMaterialParameter(ConstantsGEnum);
     366        IssmDouble sediment_porosity        = element->GetMaterialParameter(HydrologydcSedimentPorosityEnum);
     367        IssmDouble sediment_thickness       = element->GetMaterialParameter(HydrologydcSedimentThicknessEnum);
     368        IssmDouble sediment_compressibility = element->GetMaterialParameter(HydrologydcSedimentCompressibilityEnum);
     369        IssmDouble water_compressibility    = element->GetMaterialParameter(HydrologydcWaterCompressibilityEnum);
     370        return rho_freshwater*g*sediment_porosity*sediment_thickness*(water_compressibility+(sediment_compressibility/sediment_porosity));               
     371}/*}}}*/
     372IssmDouble HydrologyDCEfficientAnalysis::GetHydrologyDCInefficientHmax(Element* element, Gauss* gauss){/*{{{*/
     373        int        hmax_flag;
     374        IssmDouble h_max;
     375        IssmDouble rho_ice,rho_water;
     376        IssmDouble thickness,bed;
     377        /*Get the flag to the limitation method*/
     378        element->FindParam(&hmax_flag,HydrologydcSedimentlimitFlagEnum);
     379       
     380        /*Switch between the different cases*/
     381        switch(hmax_flag){
     382        case 0:
     383                h_max=1.0e+10;
     384                break;
     385        case 1:
     386                element->FindParam(&h_max,HydrologydcSedimentlimitEnum);
     387                break;
     388        case 2:
     389                rho_water= element->GetMaterialParameter(MaterialsRhoFreshwaterEnum);
     390                rho_ice= element->GetMaterialParameter(MaterialsRhoIceEnum);
     391                element->GetInputValue(&thickness,gauss,ThicknessEnum);
     392                element->GetInputValue(&bed,gauss,BedEnum);
     393                h_max=((rho_ice*thickness)/rho_water)+bed;
     394                break;
     395        case 3:
     396                _error_("Using normal stress  not supported yet");
     397                break;
     398        default:
     399                _error_("no case higher than 3 for SedimentlimitFlag");
     400        }
     401        return h_max;
     402}/*}}}*/
     403IssmDouble HydrologyDCEfficientAnalysis::GetHydrologyKMatrixTransfer(Element* element, Gauss* gauss){/*{{{*/
     404       
     405        int transfermethod;
     406        IssmDouble epl_thickness;
     407        IssmDouble epl_head,sed_head;
     408        IssmDouble sediment_transmitivity;
     409        IssmDouble leakage,residual,transfer;
     410
     411        IssmDouble sediment_thickness  = element->GetMaterialParameter(HydrologydcSedimentThicknessEnum);
     412        IssmDouble sediment_storing    = SedimentStoring(element);
     413        IssmDouble epl_specificstoring = EplSpecificStoring(element);           
     414
     415        element->FindParam(&transfermethod,HydrologydcTransferFlagEnum);
     416        /*Switch between the different transfer methods cases*/
     417        switch(transfermethod){
     418        case 0:
     419                /*Just keepping the transfer to zero, should be OK with the initial value of transfer*/
     420                break;
     421        case 1:
     422
     423                element->GetInputValue(&epl_thickness,gauss,HydrologydcEplThicknessEnum);
     424                element->GetInputValue(&sed_head,gauss,SedimentHeadEnum);
     425                element->GetInputValue(&epl_head,gauss,EplHeadEnum);
     426                element->GetInputValue(&sediment_transmitivity,gauss,HydrologydcSedimentTransmitivityEnum);
     427                element->GetInputValue(&residual,gauss,SedimentHeadResidualEnum);
     428                element->FindParam(&leakage,HydrologydcLeakageFactorEnum);
     429
     430                if(epl_head>sed_head){
     431                        if(residual>0.0){       
     432                                transfer=0.0;
     433                        }
     434                        else{
     435                                transfer=(epl_specificstoring*epl_thickness*sediment_transmitivity)/(sediment_thickness*leakage);
     436                        }
     437                }
     438                else{
     439                        transfer=(sediment_storing*sediment_transmitivity)/(sediment_thickness*leakage);
     440                }
     441                break;
     442        default:
     443                _error_("no case higher than 1 for the Transfer method");
     444        }
     445       
     446        return transfer;
     447}/*}}}*/
     448
     449IssmDouble HydrologyDCEfficientAnalysis::GetHydrologyPVectorTransfer(Element* element, Gauss* gauss){/*{{{*/
     450
     451        int transfermethod;
     452        IssmDouble epl_thickness;
     453        IssmDouble epl_head,sediment_head;
     454        IssmDouble sediment_transmitivity;
     455        IssmDouble leakage,residual,transfer;
     456
     457        IssmDouble sediment_thickness = element->GetMaterialParameter(HydrologydcSedimentThicknessEnum);
     458        IssmDouble sediment_storing   = SedimentStoring(element);
     459        IssmDouble epl_specificstoring = EplSpecificStoring(element);           
     460
     461        element->FindParam(&transfermethod,HydrologydcTransferFlagEnum);
     462        /*Switch between the different transfer methods cases*/
     463        switch(transfermethod){
     464        case 0:
     465                /*Just keepping the transfer to zero, should be OK with the initial value of transfer*/
     466                break;
     467        case 1:
     468
     469                element->GetInputValue(&epl_thickness,gauss,HydrologydcEplThicknessEnum);
     470                element->GetInputValue(&sediment_head,gauss,SedimentHeadEnum);
     471                element->GetInputValue(&epl_head,gauss,EplHeadEnum);
     472                element->GetInputValue(&sediment_transmitivity,gauss,HydrologydcSedimentTransmitivityEnum);
     473                element->GetInputValue(&residual,gauss,SedimentHeadResidualEnum);
     474                element->FindParam(&leakage,HydrologydcLeakageFactorEnum);
     475               
     476                if(epl_head>sediment_head){
     477                        if(residual>0.0){       
     478                                transfer=0.0;
     479                        }
     480                        else{
     481                                transfer=(epl_specificstoring*epl_thickness*sediment_transmitivity*sediment_head)/(sediment_thickness*leakage);
     482                        }
     483                }
     484                else{
     485                        transfer=(sediment_storing*sediment_transmitivity*sediment_head)/(sediment_thickness*leakage);
     486                }
     487                break;
     488        default:
     489                _error_("no case higher than 1 for the Transfer method");
     490        }
     491        return transfer;
     492}/*}}}*/
     493
    360494void HydrologyDCEfficientAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    361495        /*Compute B  matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2.
  • issm/trunk-jpl/src/c/analyses/HydrologyDCEfficientAnalysis.h

    r17212 r17349  
    3333                void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss);
    3434                IssmDouble EplSpecificStoring(Element* element);
     35                IssmDouble SedimentStoring(Element* element);
     36                IssmDouble GetHydrologyDCInefficientHmax(Element* element, Gauss* gauss);
     37                IssmDouble GetHydrologyKMatrixTransfer(Element* element, Gauss* gauss);
     38                IssmDouble GetHydrologyPVectorTransfer(Element* element, Gauss* gauss);
    3539};
    3640#endif
  • issm/trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.cpp

    r17212 r17349  
    8989        iomodel->FetchDataToInput(elements,SedimentHeadEnum);
    9090        iomodel->FetchDataToInput(elements,HydrologydcSedimentTransmitivityEnum);
     91
    9192
    9293        if(isefficientlayer)iomodel->FetchDataToInput(elements,HydrologydcMaskEplactiveNodeEnum);
     
    172173
    173174        /*Intermediaries */
     175        bool        active_element,isefficientlayer;
    174176        IssmDouble  D_scalar,Jdet,dt;
    175177        IssmDouble  sediment_transmitivity;
     178        IssmDouble  transfer;
    176179        IssmDouble *xyz_list  = NULL;
     180
     181        /*Define transfer related variables*/
     182        Input* active_element_input =NULL;
    177183
    178184        /*Fetch number of nodes and dof for this finite element*/
     
    186192
    187193        /*Retrieve all inputs and parameters*/
    188         basalelement                       ->GetVerticesCoordinates(&xyz_list);
    189         IssmDouble sediment_storing        = SedimentStoring(basalelement);
    190         Input* SedTrans_input=basalelement ->GetInput(HydrologydcSedimentTransmitivityEnum); _assert_(SedTrans_input);
    191         basalelement                       ->FindParam(&dt,TimesteppingTimeStepEnum);
    192 
     194        basalelement ->GetVerticesCoordinates(&xyz_list);
     195        basalelement ->FindParam(&dt,TimesteppingTimeStepEnum);
     196        basalelement ->FindParam(&isefficientlayer,HydrologydcIsefficientlayerEnum);
     197
     198        Input* SedTrans_input       = basalelement->GetInput(HydrologydcSedimentTransmitivityEnum); _assert_(SedTrans_input);
     199        IssmDouble sediment_storing = SedimentStoring(basalelement);
     200        /*Transfer related Inputs*/
     201        if(isefficientlayer){
     202                active_element_input = basalelement->GetInput(HydrologydcMaskEplactiveEltEnum); _assert_(active_element_input);
     203        }
     204       
    193205        /* Start  looping on the number of gaussian points: */
    194206        Gauss* gauss=basalelement->NewGauss(2);
     
    197209                basalelement   -> JacobianDeterminant(&Jdet,xyz_list,gauss);
    198210                SedTrans_input -> GetInputValue(&sediment_transmitivity,gauss);
    199 
     211               
    200212                /*Diffusivity*/
    201213                D_scalar=sediment_transmitivity*gauss->weight*Jdet;
     
    205217                GetB(B,basalelement,xyz_list,gauss);
    206218                TripleMultiply(B,2,numnodes,1,
    207                                         &D[0][0],2,2,0,
    208                                         B,2,numnodes,0,
    209                                         &Ke->values[0],1);
     219                                                                         &D[0][0],2,2,0,
     220                                                                         B,2,numnodes,0,
     221                                                                         &Ke->values[0],1);
    210222
    211223                /*Transient*/
     
    214226                        D_scalar=sediment_storing*gauss->weight*Jdet;
    215227                        TripleMultiply(basis,numnodes,1,0,
    216                                                 &D_scalar,1,1,0,
    217                                                 basis,1,numnodes,0,
    218                                                 &Ke->values[0],1);
    219                 }
    220         }
    221 
     228                                                                                 &D_scalar,1,1,0,
     229                                                                                 basis,1,numnodes,0,
     230                                                                                 &Ke->values[0],1);
     231                       
     232                        /*Transfer EPL part*/
     233                        if(isefficientlayer){
     234                                active_element_input->GetInputValue(&active_element);
     235                                if(active_element){
     236                                        transfer=GetHydrologyKMatrixTransfer(basalelement,gauss);
     237                                       
     238                                        basalelement->NodalFunctions(&basis[0],gauss);
     239                                        D_scalar=transfer*gauss->weight*Jdet*dt;
     240                                        TripleMultiply(basis,numnodes,1,0,
     241                                                                                                 &D_scalar,1,1,0,
     242                                                                                                 basis,1,numnodes,0,
     243                                                                                                 &Ke->values[0],1);
     244                                }
     245                        }
     246                }
     247        }
    222248        /*Clean up and return*/
    223249        xDelete<IssmDouble>(xyz_list);
     
    248274
    249275        /*Intermediaries */
     276        bool       active_element,isefficientlayer;
    250277        IssmDouble dt,scalar,water_head;
    251278        IssmDouble water_load,transfer;
    252279        IssmDouble Jdet;
    253         IssmDouble *xyz_list  = NULL;
    254         Input*      old_wh_input      = NULL;
     280
     281        IssmDouble *xyz_list             = NULL;
     282        Input*      old_wh_input         = NULL;
     283        Input*      active_element_input = NULL;
    255284
    256285        /*Fetch number of nodes and dof for this finite element*/
     
    263292        /*Retrieve all inputs and parameters*/
    264293        basalelement->GetVerticesCoordinates(&xyz_list);
    265         IssmDouble sediment_storing = SedimentStoring(basalelement);
    266294        basalelement->FindParam(&dt,TimesteppingTimeStepEnum);
     295        basalelement->FindParam(&isefficientlayer,HydrologydcIsefficientlayerEnum);
     296
    267297        Input* water_input       = basalelement->GetInput(BasalforcingsMeltingRateEnum); _assert_(water_input);
    268         Input* transfer_input    = basalelement->GetInput(WaterTransferEnum);            _assert_(transfer_input);
    269298        if(dt!= 0.){old_wh_input = basalelement->GetInput(SedimentHeadOldEnum);          _assert_(old_wh_input);}
     299
     300        IssmDouble sediment_storing    = SedimentStoring(basalelement);
     301
     302        /*Transfer related Inputs*/
     303        if(isefficientlayer){
     304                active_element_input = basalelement->GetInput(HydrologydcMaskEplactiveEltEnum); _assert_(active_element_input);
     305        }
    270306
    271307        /* Start  looping on the number of gaussian points: */
     
    273309        for(int ig=gauss->begin();ig<gauss->end();ig++){
    274310                gauss->GaussPoint(ig);
    275 
     311       
    276312                basalelement->JacobianDeterminant(&Jdet,xyz_list,gauss);
    277313                basalelement->NodalFunctions(basis,gauss);
     
    279315                /*Loading term*/
    280316                water_input->GetInputValue(&water_load,gauss);
    281                 transfer_input->GetInputValue(&transfer,gauss);
    282                 scalar = Jdet*gauss->weight*(water_load+transfer);
     317       
     318                scalar = Jdet*gauss->weight*(water_load);
    283319                if(dt!=0.) scalar = scalar*dt;
    284                 for(int i=0;i<numnodes;i++) pe->values[i]+=scalar*basis[i];
    285 
    286                 /*Transient term*/
     320                for(int i=0;i<numnodes;i++){
     321                        pe->values[i]+=scalar*basis[i];
     322                }
     323                       
     324                /*Transient and transfer terms*/
    287325                if(dt!=0.){
    288                         old_wh_input->GetInputValue(&water_head,gauss);
    289                         scalar = Jdet*gauss->weight*water_head*sediment_storing;
    290                         for(int i=0;i<numnodes;i++) pe->values[i]+=scalar*basis[i];
    291                 }
    292         }
    293 
     326                        old_wh_input    ->GetInputValue(&water_head,gauss);
     327                        if(isefficientlayer){
     328                                /*Dealing with the sediment part of the transfer term*/
     329                                active_element_input->GetInputValue(&active_element);
     330                                if(active_element){
     331                                        transfer=GetHydrologyPVectorTransfer(basalelement,gauss);
     332                                }
     333                                else{
     334                                        transfer=0.0;
     335                                }
     336                                scalar = Jdet*gauss->weight*((water_head*sediment_storing)+(dt*transfer));
     337                                for(int i=0;i<numnodes;i++)pe->values[i]+=scalar*basis[i];
     338                        }
     339                        else{
     340                                scalar = Jdet*gauss->weight*(water_head*sediment_storing);
     341                                for(int i=0;i<numnodes;i++)pe->values[i]+=scalar*basis[i];
     342                        }
     343                }
     344        }
    294345        /*Clean up and return*/
    295346        xDelete<IssmDouble>(xyz_list);
     
    371422
    372423                for(int i=0;i<numnodes;i++){
    373                         basalelement->GetHydrologyDCInefficientHmax(&h_max,i);
     424                        basalelement->GetHydrologyDCInefficientHmax(&h_max,basalelement->GetNode(i));
    374425                        if(values[i]>h_max) residual[i] = kappa*(values[i]-h_max);
    375426                        else                residual[i] = 0.;
     
    402453        return rho_freshwater*g*sediment_porosity*sediment_thickness*(water_compressibility+(sediment_compressibility/sediment_porosity));               
    403454}/*}}}*/
     455
     456IssmDouble HydrologyDCInefficientAnalysis::EplSpecificStoring(Element* element){/*{{{*/
     457        IssmDouble rho_freshwater        = element->GetMaterialParameter(MaterialsRhoFreshwaterEnum);
     458        IssmDouble g                     = element->GetMaterialParameter(ConstantsGEnum);
     459        IssmDouble epl_porosity          = element->GetMaterialParameter(HydrologydcEplPorosityEnum);
     460        IssmDouble epl_compressibility   = element->GetMaterialParameter(HydrologydcEplCompressibilityEnum);
     461        IssmDouble water_compressibility = element->GetMaterialParameter(HydrologydcWaterCompressibilityEnum);
     462        return rho_freshwater*g*epl_porosity*(water_compressibility+(epl_compressibility/epl_porosity));                 
     463}/*}}}*/
     464
     465IssmDouble HydrologyDCInefficientAnalysis::GetHydrologyDCInefficientHmax(Element* element, Gauss* gauss){/*{{{*/
     466        int        hmax_flag;
     467        IssmDouble h_max;
     468        IssmDouble rho_ice,rho_water;
     469        IssmDouble thickness,bed;
     470        /*Get the flag to the limitation method*/
     471        element->FindParam(&hmax_flag,HydrologydcSedimentlimitFlagEnum);
     472       
     473        /*Switch between the different cases*/
     474        switch(hmax_flag){
     475        case 0:
     476                h_max=1.0e+10;
     477                break;
     478        case 1:
     479                element->FindParam(&h_max,HydrologydcSedimentlimitEnum);
     480                break;
     481        case 2:
     482       
     483                rho_water = element->GetMaterialParameter(MaterialsRhoFreshwaterEnum);
     484                rho_ice   = element->GetMaterialParameter(MaterialsRhoIceEnum);
     485
     486                /*Compute max*/
     487                /* thick_input->GetInputValue(&thickness,gauss); */
     488                /* bed_input->GetInputValue(&bed,gauss); */
     489                element->GetInputValue(&thickness,gauss,ThicknessEnum);
     490                element->GetInputValue(&bed,gauss,BedEnum);
     491                h_max=((rho_ice*thickness)/rho_water)+bed;
     492                break;
     493        case 3:
     494                _error_("Using normal stress  not supported yet");
     495                break;
     496        default:
     497                _error_("no case higher than 3 for SedimentlimitFlag");
     498        }
     499        return h_max;
     500}/*}}}*/
     501
     502IssmDouble HydrologyDCInefficientAnalysis::GetHydrologyKMatrixTransfer(Element* element, Gauss* gauss){/*{{{*/
     503
     504        int transfermethod;
     505        IssmDouble epl_thickness;
     506        IssmDouble epl_head,sed_head;
     507        IssmDouble sediment_transmitivity;
     508        IssmDouble leakage,h_max,transfer;
     509
     510        IssmDouble sediment_thickness  = element->GetMaterialParameter(HydrologydcSedimentThicknessEnum);
     511        IssmDouble sediment_storing    = SedimentStoring(element);
     512        IssmDouble epl_specificstoring = EplSpecificStoring(element);           
     513
     514        element->FindParam(&transfermethod,HydrologydcTransferFlagEnum);
     515        /*Switch between the different transfer methods cases*/
     516        switch(transfermethod){
     517        case 0:
     518                /*Just keepping the transfer to zero, should be OK with the initial value of transfer*/
     519                break;
     520        case 1:
     521
     522                element->GetInputValue(&epl_thickness,gauss,HydrologydcEplThicknessEnum);
     523                element->GetInputValue(&sed_head,gauss,SedimentHeadEnum);
     524                element->GetInputValue(&epl_head,gauss,EplHeadEnum);
     525                element->GetInputValue(&sediment_transmitivity,gauss,HydrologydcSedimentTransmitivityEnum);
     526               
     527                element->FindParam(&leakage,HydrologydcLeakageFactorEnum);
     528       
     529                if(epl_head>sed_head){
     530                        h_max=GetHydrologyDCInefficientHmax(element,gauss);
     531                        if(sed_head>=h_max){
     532                                transfer=0.0;
     533                        }
     534                        else{
     535                                transfer=(epl_specificstoring*epl_thickness*sediment_transmitivity)/(sediment_thickness*leakage);
     536                        }
     537                }
     538                else{
     539                        transfer=(sediment_storing*sediment_transmitivity)/(sediment_thickness*leakage);
     540                }
     541                break;
     542        default:
     543                _error_("no case higher than 1 for the Transfer method");
     544        }
     545       
     546        return transfer;
     547}/*}}}*/
     548
     549IssmDouble HydrologyDCInefficientAnalysis::GetHydrologyPVectorTransfer(Element* element, Gauss* gauss){/*{{{*/
     550
     551        int transfermethod;
     552        IssmDouble epl_thickness;
     553        IssmDouble epl_head,sediment_head;
     554        IssmDouble sediment_transmitivity;
     555        IssmDouble leakage,h_max,transfer;
     556
     557        IssmDouble sediment_thickness = element->GetMaterialParameter(HydrologydcSedimentThicknessEnum);
     558        IssmDouble sediment_storing   = SedimentStoring(element);
     559        IssmDouble epl_specificstoring = EplSpecificStoring(element);           
     560
     561        element->FindParam(&transfermethod,HydrologydcTransferFlagEnum);
     562        /*Switch between the different transfer methods cases*/
     563        switch(transfermethod){
     564        case 0:
     565                /*Just keepping the transfer to zero, should be OK with the initial value of transfer*/
     566                break;
     567        case 1:
     568
     569                element->GetInputValue(&epl_thickness,gauss,HydrologydcEplThicknessEnum);
     570                element->GetInputValue(&sediment_head,gauss,SedimentHeadEnum);
     571                element->GetInputValue(&epl_head,gauss,EplHeadEnum);
     572                element->GetInputValue(&sediment_transmitivity,gauss,HydrologydcSedimentTransmitivityEnum);
     573               
     574                element->FindParam(&leakage,HydrologydcLeakageFactorEnum);
     575                if(epl_head>sediment_head){
     576                        h_max=GetHydrologyDCInefficientHmax(element,gauss);
     577                        if(sediment_head>=h_max){
     578                                transfer=0.0;
     579                        }
     580                        else{
     581                                transfer=(epl_specificstoring*epl_thickness*sediment_transmitivity*epl_head)/(sediment_thickness*leakage);
     582                        }
     583                }
     584                else{
     585                        transfer=(sediment_storing*sediment_transmitivity*epl_head)/(sediment_thickness*leakage);
     586                }
     587                break;
     588        default:
     589                _error_("no case higher than 1 for the Transfer method");
     590        }
     591        return transfer;
     592}/*}}}*/
     593
    404594void HydrologyDCInefficientAnalysis::ElementizeEplMask(FemModel* femmodel){/*{{{*/
    405595
  • issm/trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.h

    r17212 r17349  
    3333                void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss);
    3434                IssmDouble SedimentStoring(Element* element);
     35                IssmDouble EplSpecificStoring(Element* element);
     36                IssmDouble GetHydrologyDCInefficientHmax(Element* element, Gauss* gauss);
     37                IssmDouble GetHydrologyKMatrixTransfer(Element* element, Gauss* gauss);
     38                IssmDouble GetHydrologyPVectorTransfer(Element* element, Gauss* gauss);
    3539                void ElementizeEplMask(FemModel* femmodel);
    3640};
  • issm/trunk-jpl/src/c/classes/Elements/Element.h

    r17338 r17349  
    283283                virtual void UpdateConstraintsExtrudeFromTop(void)=0;
    284284
    285                 virtual void GetHydrologyDCInefficientHmax(IssmDouble* ph_max,int index)=0;
     285                //              virtual void GetHydrologyDCInefficientHmax(IssmDouble* ph_max,int index)=0;
    286286                virtual void GetHydrologyDCInefficientHmax(IssmDouble* ph_max, Node* innode)=0;
    287287                virtual void GetHydrologyTransfer(Vector<IssmDouble>* transfer)=0;
  • issm/trunk-jpl/src/c/classes/Elements/Penta.h

    r17338 r17349  
    243243                ElementMatrix* CreateEPLDomainMassMatrix(void);
    244244                void           GetHydrologyDCInefficientHmax(IssmDouble* ph_max, Node* innode);
    245                 void           GetHydrologyDCInefficientHmax(IssmDouble* ph_max,int index){_error_("not implemented yet");};
     245                //              void           GetHydrologyDCInefficientHmax(IssmDouble* ph_max,int index){_error_("not implemented yet");};
    246246                void           GetHydrologyTransfer(Vector<IssmDouble>* transfer);
    247247                void           HydrologyEPLGetActive(Vector<IssmDouble>* active_vec);
  • issm/trunk-jpl/src/c/classes/Elements/Seg.h

    r17338 r17349  
    151151
    152152                void    GetHydrologyDCInefficientHmax(IssmDouble* ph_max, Node* innode){_error_("not implemented yet");};
    153                 void    GetHydrologyDCInefficientHmax(IssmDouble* ph_max,int index){_error_("not implemented yet");};
     153                //              void    GetHydrologyDCInefficientHmax(IssmDouble* ph_max,int index){_error_("not implemented yet");};
    154154                void    GetHydrologyTransfer(Vector<IssmDouble>* transfer){_error_("not implemented yet");};
    155155                void    HydrologyEPLGetActive(Vector<IssmDouble>* active_vec){_error_("not implemented yet");};
  • issm/trunk-jpl/src/c/classes/Elements/Tria.cpp

    r17338 r17349  
    44654465/*}}}*/
    44664466/*FUNCTION Tria::GetHydrologyDCInefficientHmax{{{*/
    4467 void  Tria::GetHydrologyDCInefficientHmax(IssmDouble* ph_max,int index){
    4468        
    4469         int        hmax_flag;
    4470         IssmDouble h_max;
    4471         IssmDouble rho_ice,rho_water;
    4472         IssmDouble thickness,bed;
    4473         /*Get the flag to the limitation method*/
    4474         this->parameters->FindParam(&hmax_flag,HydrologydcSedimentlimitFlagEnum);
    4475        
    4476         /*Switch between the different cases*/
    4477         switch(hmax_flag){
    4478         case 0:
    4479                 h_max=1.0e+10;
    4480                 break;
    4481         case 1:
    4482                 parameters->FindParam(&h_max,HydrologydcSedimentlimitEnum);
    4483                 break;
    4484         case 2:
    4485                 rho_ice=matpar->GetRhoIce();
    4486                 rho_water=matpar->GetRhoFreshwater();
    4487                 this->GetInputValue(&thickness,this->nodes[index],ThicknessEnum);
    4488                 this->GetInputValue(&bed,this->nodes[index],BedEnum);
    4489                 h_max=((rho_ice*thickness)/rho_water)+bed;
    4490                 break;
    4491         case 3:
    4492                 _error_("Using normal stress  not supported yet");
    4493                 break;
    4494         default:
    4495                 _error_("no case higher than 3 for SedimentlimitFlag");
    4496         }
    4497         /*Assign output pointer*/
    4498         *ph_max=h_max;
    4499 }
    4500 /*}}}*/
    4501 /*FUNCTION Tria::GetHydrologyDCInefficientHmax{{{*/
    45024467void  Tria::GetHydrologyDCInefficientHmax(IssmDouble* ph_max, Node* innode){
    45034468       
     
    45354500/*}}}*/
    45364501/*FUNCTION Tria::GetHydrologyTransfer{{{*/
    4537 void  Tria::GetHydrologyTransfer(Vector<IssmDouble>* transfer){
    4538 
    4539         const int  numdof   = NDOF1 *NUMVERTICES;
    4540         int        *doflist = NULL;
    4541         int        analysis_type;
    4542         bool       isefficientlayer;
    4543         bool       active_element;
    4544         int        transfermethod;
    4545         IssmDouble leakage,h_max;
    4546         IssmDouble wh_trans,sed_thick;
    4547         IssmDouble epl_specificstoring,sedstoring;
    4548         IssmDouble activeEpl[numdof],epl_thickness[numdof],old_epl_thickness[numdof];
    4549         IssmDouble epl_head[numdof],sed_head[numdof];
    4550         IssmDouble preceding_transfer[numdof],sed_trans[numdof];
    4551 
    4552         Input* active_element_input=NULL;
    4553 
    4554         parameters->FindParam(&analysis_type,AnalysisTypeEnum);
     4502/*This thing should be useless and deleted soon*/
     4503
     4504/* void  Tria::GetHydrologyTransfer(Vector<IssmDouble>* transfer){ */
     4505
     4506/*      const int  numdof   = NDOF1 *NUMVERTICES; */
     4507/*      int        *doflist = NULL; */
     4508/*      int        analysis_type; */
     4509/*      bool       isefficientlayer; */
     4510/*      bool       active_element; */
     4511/*      int        transfermethod; */
     4512/*      IssmDouble leakage,h_max,dt,test; */
     4513/*      IssmDouble wh_trans,sed_thick,relaxed; */
     4514/*      IssmDouble epl_specificstoring,sedstoring; */
     4515/*      IssmDouble activeEpl[numdof],epl_thickness[numdof],old_epl_thickness[numdof]; */
     4516/*      IssmDouble epl_head[numdof],sed_head[numdof]; */
     4517/*      IssmDouble epl_head_old[numdof],sed_head_old[numdof]; */
     4518/*      IssmDouble preceding_transfer[numdof],sed_trans[numdof]; */
     4519
     4520/*      Input* active_element_input=NULL; */
     4521
     4522
     4523/*      parameters->FindParam(&analysis_type,AnalysisTypeEnum); */
    45554524               
    4556         GetDofList(&doflist,NoneApproximationEnum,GsetEnum);
    4557 
    4558         /*Get the flag to know if the efficient layer is present*/
    4559         this->parameters->FindParam(&isefficientlayer,HydrologydcIsefficientlayerEnum);
    4560 
    4561         if(isefficientlayer){
    4562                 /*Also get the flag to the transfer method*/
    4563                 this->parameters->FindParam(&transfermethod,HydrologydcTransferFlagEnum);
    4564                
    4565                 /*Switch between the different transfer methods cases*/
    4566                 switch(transfermethod){
    4567                 case 0:
    4568                         /*Just keepping the transfer to zero, should be OK with the initial value of transfer*/
    4569                         break;
    4570                 case 1:
     4525/*      GetDofList(&doflist,NoneApproximationEnum,GsetEnum); */
     4526
     4527/*      /\*Get the flag to know if the efficient layer is present*\/ */
     4528/*      this->parameters->FindParam(&isefficientlayer,HydrologydcIsefficientlayerEnum); */
     4529
     4530/*      if(isefficientlayer){ */
     4531/*              /\*Also get the flag to the transfer method*\/ */
     4532/*              this->parameters->FindParam(&transfermethod,HydrologydcTransferFlagEnum); */
     4533/*              this->parameters->FindParam(&dt,TimesteppingTimeStepEnum);               */
     4534/*              /\*Switch between the different transfer methods cases*\/ */
     4535/*              switch(transfermethod){ */
     4536/*              case 0: */
     4537/*                      /\*Just keepping the transfer to zero, should be OK with the initial value of transfer*\/ */
     4538/*                      break; */
     4539/*              case 1: */
    45714540       
    4572                         active_element_input=inputs->GetInput(HydrologydcMaskEplactiveEltEnum); _assert_(active_element_input);
    4573                         active_element_input->GetInputValue(&active_element);
    4574 
    4575                         GetInputListOnVertices(&sed_head[0],SedimentHeadEnum);
    4576                         GetInputListOnVertices(&sed_trans[0],HydrologydcSedimentTransmitivityEnum);
    4577                         GetInputListOnVertices(&epl_head[0],EplHeadEnum);
    4578                         GetInputListOnVertices(&epl_thickness[0],HydrologydcEplThicknessEnum);                 
    4579 
    4580                         this->parameters->FindParam(&leakage,HydrologydcLeakageFactorEnum);
    4581 
    4582                         sed_thick = matpar->GetSedimentThickness();
    4583 
    4584                         if(!active_element){
    4585                                 /*No transfer if the EPL is not active*/
    4586                         }
    4587                         else{
    4588                                 GetInputListOnVertices(&preceding_transfer[0],WaterTransferEnum);
    4589                                 sedstoring=matpar->GetSedimentStoring();
    4590                                 epl_specificstoring=matpar->GetEplSpecificStoring();
     4541/*                      active_element_input=inputs->GetInput(HydrologydcMaskEplactiveEltEnum); _assert_(active_element_input); */
     4542/*                      active_element_input->GetInputValue(&active_element); */
     4543
     4544/*                      GetInputListOnVertices(&sed_head[0],SedimentHeadEnum); */
     4545/*                      GetInputListOnVertices(&sed_head_old[0],SedimentHeadOldEnum); */
     4546/*                      GetInputListOnVertices(&sed_trans[0],HydrologydcSedimentTransmitivityEnum); */
     4547/*                      GetInputListOnVertices(&epl_head[0],EplHeadEnum); */
     4548/*                      GetInputListOnVertices(&epl_head_old[0],EplHeadOldEnum); */
     4549/*                      GetInputListOnVertices(&epl_thickness[0],HydrologydcEplThicknessEnum);                   */
     4550
     4551/*                      this->parameters->FindParam(&leakage,HydrologydcLeakageFactorEnum); */
     4552
     4553/*                      sed_thick = matpar->GetSedimentThickness(); */
     4554
     4555/*                      if(!active_element){ */
     4556
     4557                                               
     4558/*                              /\*No transfer if the EPL is not active*\/ */
     4559/*                      } */
     4560/*                      else{ */
     4561/*                              GetInputListOnVertices(&preceding_transfer[0],WaterTransferEnum); */
     4562/*                              sedstoring=matpar->GetSedimentStoring(); */
     4563/*                              epl_specificstoring=matpar->GetEplSpecificStoring(); */
    45914564                                       
    4592                                 for(int i=0;i<numdof;i++){
    4593                                         this->GetHydrologyDCInefficientHmax(&h_max,i);
    4594                        
    4595                                         /*EPL head higher than sediment head, transfer from the epl to the sediment*/
    4596                                         if(epl_head[i]>sed_head[i]){
    4597                                                 wh_trans=epl_specificstoring*epl_thickness[i]*sed_trans[i]*(epl_head[i]-sed_head[i])/(leakage*sed_thick);
    4598                                                
    4599                                                 /*No transfer if the sediment head is allready at the maximum*/
    4600                                                 if(sed_head[i]>=h_max){
    4601                                                         wh_trans=0.0;
    4602                                                 }
    4603                                         }
    4604                                         /* EPL head lower than sediment head, transfer from the sediment to the epl */
    4605                                         else if(epl_head[i]<=sed_head[i]){
    4606                                                 wh_trans=sedstoring*sed_trans[i]*(epl_head[i]-sed_head[i])/(leakage*sed_thick);
    4607                                         }
     4565/*                              for(int i=0;i<numdof;i++){ */
     4566/*                                      this->GetHydrologyDCInefficientHmax(&h_max,this->nodes[i]); */
     4567/*                                      /\*EPL head higher than sediment head, transfer from the epl to the sediment*\/ */
     4568/*                                      if(epl_head[i]>sed_head[i]){ */
     4569/*                                              if(sed_head[i]>=h_max){ */
     4570/*                                                      wh_trans=0.0; */
     4571/*                                              } */
     4572/*                                              else{ */
     4573/*                                                      wh_trans=epl_specificstoring*epl_thickness[i]*sed_trans[i]*(epl_head[i]-sed_head[i])/(leakage*sed_thick); */
     4574/*                                              }                                                */
     4575/*                                      } */
     4576/*                                      /\* EPL head lower than sediment head, transfer from the sediment to the epl *\/ */
     4577/*                                      else if(epl_head[i]<=sed_head[i]){ */
     4578/*                                              wh_trans=sedstoring*sed_trans[i]*(epl_head[i]-sed_head[i])/(leakage*sed_thick); */
     4579/*                                      }  */
    46084580                                       
    4609                                         /*Relaxation stuff*/
    4610                                         wh_trans=preceding_transfer[i]+0.8*(wh_trans-preceding_transfer[i]);
    4611                                        
    4612                                         /*Assign output pointer*/
    4613                                         transfer->SetValue(doflist[i],wh_trans,INS_VAL);
    4614                                 }
    4615                         }
    4616                         break;
    4617                 default:
    4618                         _error_("no case higher than 1 for the Transfer method");
    4619                 }
    4620         }
    4621         /*Free ressources:*/
    4622         xDelete<int>(doflist);
    4623 }
     4581/*                                      /\*Assign output pointer*\/ */
     4582/*                                      transfer->SetValue(doflist[i],wh_trans,INS_VAL); */
     4583/*                              } */
     4584/*                      } */
     4585/*                      break; */
     4586/*              default: */
     4587/*                      _error_("no case higher than 1 for the Transfer method"); */
     4588/*              } */
     4589/*      } */
     4590/*      /\*Free ressources:*\/ */
     4591/*      xDelete<int>(doflist); */
     4592/* } */
    46244593/*}}}*/
    46254594/*FUNCTION Tria::HydrologyEPLGetActive {{{*/
     
    46904659                        if(epl_thickness[i]<0.001*init_thick){
    46914660                                vec_mask->SetValue(nodes[i]->Sid(),0.,INS_VAL);
     4661                                epl_thickness[i]=init_thick;
    46924662                        }
    46934663                }
    46944664                /*Increase of the efficient system is needed if the epl head reach the maximum value (sediment max value for now)*/
    4695                 this->GetHydrologyDCInefficientHmax(&h_max,i);
     4665                this->GetHydrologyDCInefficientHmax(&h_max,this->nodes[i]);
    46964666                if(eplhead[i]>=h_max && active_element){
    46974667                        for(j=0;j<numdof;j++){
     
    47724742                                thickness[i] = old_thickness[i]*(1+((rho_water*gravity*dt)/(rho_ice*latentheat))*epl_conductivity*EPLgrad2-2.0*(A*dt/(pow(n,n)))*(pow(EPL_N,n)));
    47734743                                       
    4774                                 /*Relaxation stuff*/
    4775                                 if(thickness[i]<10.0*init_thick){
    4776                                         thickness[i] = preceding_thickness[i]+0.8*(thickness[i]-preceding_thickness[i]);
    4777                                 }
    4778                                 else{
     4744                                /*Take care of otherthikening*/
     4745                                if(thickness[i]>10.0*init_thick){
    47794746                                        thickness[i] = 10.0*init_thick;
    47804747                                }
  • issm/trunk-jpl/src/c/classes/Elements/Tria.h

    r17338 r17349  
    254254                ElementMatrix* CreateEPLDomainMassMatrix(void);
    255255                void           CreateHydrologyWaterVelocityInput(void);
    256                 void           GetHydrologyDCInefficientHmax(IssmDouble* ph_max,int index);
     256                //              void           GetHydrologyDCInefficientHmax(IssmDouble* ph_max,int index);
    257257                void           GetHydrologyDCInefficientHmax(IssmDouble* ph_max, Node* innode);
    258258                void           GetHydrologyTransfer(Vector<IssmDouble>* transfer);
  • issm/trunk-jpl/src/c/solutionsequences/solutionsequence_hydro_nonlinear.cpp

    r17271 r17349  
    4444        IssmDouble ndu_sed,nu_sed;
    4545        IssmDouble ndu_epl,nu_epl;
    46         IssmDouble SedConv,EplConv;
     46        IssmDouble EplConv;
    4747
    4848        /*Recover parameters: */
     
    7676        /*The real computation starts here, outermost loop is on the two layer system*/
    7777        for(;;){
     78
     79                EplConv=1.0;
    7880                sedcount=1;
    7981                eplcount=1;
    80                 SedConv=1.0;
    81                 EplConv=1.0;
    8282
    8383                /*If there is two layers we need an outer loop value to compute convergence*/
     
    9797                /*Reset constraint on the ZigZag Lock, this thing doesn't work, it have to disapear*/
    9898                ResetConstraintsx(femmodel);
    99                 sedconverged=false;
     99
    100100                /* {{{ *//*Treating the sediment*/
    101101                for(;;){
     102                        sedconverged=false;
    102103                        uf_sed_sub_iter=uf_sed->Duplicate();_assert_(uf_sed_sub_iter);
    103104                        uf_sed->Copy(uf_sed_sub_iter);
     
    105106                        for(;;){
    106107                                /* {{{ *//*Core of the computation*/
     108                                if(VerboseSolution()) _printf0_("Building Sediment Matrix...\n");
    107109                                SystemMatricesx(&Kff,&Kfs,&pf,&df,&sediment_kmax,femmodel);
    108110                                CreateNodalConstraintsx(&ys,femmodel->nodes,HydrologyDCInefficientAnalysisEnum);
     
    127129                                if(sedconverged)break;
    128130                        }
     131               
    129132                        /* }}} *//*End of the sediment penalization loop*/
     133                        /*Update EPL mask*/
     134                        if(isefficientlayer){
     135                                HydrologyDCInefficientAnalysis* analysis = new HydrologyDCInefficientAnalysis();
     136                                analysis->ElementizeEplMask(femmodel);
     137                                delete analysis;
     138                        }
     139                       
    130140                        sedconverged=false;
    131                         /*Update Elemental Mask and compute transfer*/
    132                         if(isefficientlayer){
    133                                 if(SedConv<0.3){
    134                                         HydrologyDCInefficientAnalysis* analysis = new HydrologyDCInefficientAnalysis();
    135                                         analysis->ElementizeEplMask(femmodel);
    136                                         delete analysis;
    137                                         femmodel->HydrologyTransferx();
    138                                         transfered=true;
    139                                 }
    140                                 else{
    141                                         transfered=false;
    142                                 }
    143                         }
    144                         else{
    145                                 transfered=true;
    146                         }
     141                       
    147142                        /*Checking convegence on the value of the sediment head*/
    148143                        duf=uf_sed_sub_iter->Duplicate();_assert_(duf);
     
    154149                        if (xIsNan<IssmDouble>(ndu_sed) || xIsNan<IssmDouble>(nu_sed)) _error_("convergence criterion is NaN!");
    155150                        if (ndu_sed==0.0 && nu_sed==0.0) nu_sed=1.0e-6; /*Hacking the case where the layer is empty*/
    156                         if(VerboseConvergence()) _printf0_(setw(50) << left << "   Inner Sediment Convergence criterion:" << ndu_sed/nu_sed*100 << " aiming lower than " << eps_hyd*100 << " %\n");
    157                         SedConv = ndu_sed/nu_sed*100;
    158                         if((ndu_sed/nu_sed)<eps_hyd){
     151                        if(VerboseConvergence()) _printf0_(setw(50) << left << "   Inner Sediment Convergence criterion:" << ndu_sed/nu_sed*100 << "%, aiming lower than " << eps_hyd*10*100 << " %\n");
     152                        if((ndu_sed/nu_sed)<eps_hyd*10.){
    159153                                if(VerboseConvergence()) _printf0_("   # Inner sediment convergence achieve \n");
    160154                                sedconverged=true;
    161155                        }
    162156                        delete uf_sed_sub_iter;
    163                         if(sedconverged && transfered){
     157                        if(sedconverged){
    164158                                femmodel->parameters->SetParam(sediment_kmax,HydrologySedimentKmaxEnum);
    165159                                InputUpdateFromConstantx(femmodel,sedconverged,ConvergedEnum);
     
    179173                        InputUpdateFromConstantx(femmodel,false,ConvergedEnum);
    180174                        femmodel->parameters->SetParam(HydrologyEfficientEnum,HydrologyLayerEnum);
    181                
    182                         eplconverged=false;
     175                        EplConv=1.0;
    183176
    184177                        for(;;){
    185 
     178                                eplconverged=false;
    186179                                ug_epl_sub_iter=ug_epl->Duplicate();_assert_(ug_epl_sub_iter);
    187180                                ug_epl->Copy(ug_epl_sub_iter);
    188181
    189                                 if(EplConv<0.3){
    190                                         /* {{{ *//*Retriev the EPL head slopes and compute EPL Thickness*/
     182                                /* {{{ *//*Retriev the EPL head slopes and compute EPL Thickness*/
    191183                                        if(VerboseSolution()) _printf0_("computing EPL Head slope...\n");
    192184                                        femmodel->SetCurrentConfiguration(L2ProjectionEPLAnalysisEnum);
     
    201193                                        //updating mask after the computation of the epl thickness (Allow to close too thin EPL)
    202194                                        femmodel->HydrologyEPLupdateDomainx();
    203                                         /* }}} */
    204                                
    205                                         /*Update Elemental Mask and compute transfer*/
     195
    206196                                        HydrologyDCInefficientAnalysis* analysis = new HydrologyDCInefficientAnalysis();
    207197                                        analysis->ElementizeEplMask(femmodel);
    208198                                        delete analysis;
    209                                         femmodel->HydrologyTransferx();
    210                                         transfered=true;
    211                                 }
    212                                 else{
    213                                         transfered=false;
    214                                 }
    215                                
     199                                        /* }}} */
     200                                       
     201                                if(VerboseSolution()) _printf0_("Building EPL Matrix...\n");
    216202                                SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel);
    217203                                CreateNodalConstraintsx(&ys,femmodel->nodes,HydrologyDCEfficientAnalysisEnum);
     
    236222                                if (xIsNan<IssmDouble>(ndu_epl) || xIsNan<IssmDouble>(nu_epl)) _error_("convergence criterion is NaN!");
    237223                                if (ndu_epl==0.0 && nu_epl==0.0) nu_epl=1.0e-6; /*Hacking the case where the EPL is used but empty*/
    238                                 if(VerboseConvergence()) _printf0_(setw(50) << left << "   Inner EPL Convergence criterion:" << ndu_epl/nu_epl*100 << " aiming lower than " << eps_hyd*100 << " %\n");
    239                                 EplConv=ndu_epl/nu_epl*100;
    240                                 if((ndu_epl/nu_epl)<eps_hyd) eplconverged=true;
     224                                if(VerboseConvergence()) _printf0_(setw(50) << left << "   Inner EPL Convergence criterion:" << ndu_epl/nu_epl*100 << "%, aiming lower than " << eps_hyd*10*100 << " %\n");
     225                                EplConv=ndu_epl/nu_epl;
     226                                if((ndu_epl/nu_epl)<eps_hyd*10.) eplconverged=true;
    241227                                if (eplcount>=hydro_maxiter){
    242228                                        _error_("   maximum number of EPL iterations (" << hydro_maxiter << ") exceeded");
     
    246232                               
    247233                                delete ug_epl_sub_iter;
    248                                 if(eplconverged && transfered){
     234                                if(eplconverged){
    249235                                        if(VerboseSolution()) _printf0_("eplconverged...\n");
    250236                                        InputUpdateFromConstantx(femmodel,eplconverged,ConvergedEnum);
     
    283269                                }
    284270                                else{
    285                                         if(VerboseConvergence()) _printf0_(setw(50) << left << "   Sediment Convergence criterion:" << ndu_sed/nu_sed*100 << " aiming lower than " << eps_hyd*100 << " %\n");
    286                                         if(VerboseConvergence()) _printf0_(setw(50) << left << "   EPL Convergence criterion:" << ndu_epl/nu_epl*100 << " aiming lower than " << eps_hyd*100 << " %\n");
     271                                        if(VerboseConvergence()) _printf0_(setw(50) << left << "   Sediment Convergence criterion:" << ndu_sed/nu_sed*100 << "%, aiming lower than " << eps_hyd*100 << " %\n");
     272                                        if(VerboseConvergence()) _printf0_(setw(50) << left << "   EPL Convergence criterion:" << ndu_epl/nu_epl*100 << "%, aiming lower than " << eps_hyd*100 << " %\n");
    287273                                        hydroconverged=false;
    288274                                }
Note: See TracChangeset for help on using the changeset viewer.