Changeset 27470


Ignore:
Timestamp:
12/21/22 10:31:54 (2 years ago)
Author:
Mathieu Morlighem
Message:

NEW: moving friction io to Friction.cpp and preparing linearization as an option

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

Legend:

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

    r27102 r27470  
    102102
    103103        bool dakota_analysis,ismovingfront,isenthalpy;
    104         int frictionlaw,basalforcing_model,materialstype;
    105         int FrictionCoupling;
     104        int  basalforcing_model,materialstype;
    106105
    107106        /*Now, is the model 3d? otherwise, do nothing: */
     
    131130        iomodel->FindConstant(&dakota_analysis,"md.qmu.isdakota");
    132131        iomodel->FindConstant(&ismovingfront,"md.transient.ismovingfront");
    133         iomodel->FindConstant(&frictionlaw,"md.friction.law");
    134132        iomodel->FindConstant(&materialstype,"md.materials.type");
    135133
     
    191189        }
    192190
    193         /*Friction law variables*/
    194         switch(frictionlaw){
    195                 case 1:
    196                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    197                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    198                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    199                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    200                         if (FrictionCoupling==3){
    201                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    202                         else if(FrictionCoupling==4){
    203                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    204                         }
    205                         break;
    206                 case 2:
    207                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    208                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    209                         break;
    210                 case 3:
    211                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    212                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    213                         iomodel->FetchDataToInput(inputs,elements,"md.friction.As",FrictionAsEnum);
    214                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    215                         if (FrictionCoupling==3){
    216                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    217                         else if(FrictionCoupling==4){
    218                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    219                         }
    220                         break;
    221                 case 4:
    222                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    223                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    224                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    225                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.pressure",PressureEnum);
    226                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.temperature",TemperatureEnum);
    227                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    228                         break;
    229                 case 5:
    230                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    231                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    232                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    233                         iomodel->FetchDataToInput(inputs,elements,"md.friction.water_layer",FrictionWaterLayerEnum);
    234                         break;
    235                 case 6:
    236                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    237                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    238                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.pressure",PressureEnum);
    239                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.temperature",TemperatureEnum);
    240                         break;
    241                 case 7:
    242                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    243                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    244                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficientcoulomb",FrictionCoefficientcoulombEnum);
    245                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    246                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    247                         if (FrictionCoupling==3){
    248                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    249                         else if(FrictionCoupling==4){
    250                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    251                         }
    252                         break;
    253                 case 9:
    254                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    255                         iomodel->FetchDataToInput(inputs,elements,"md.friction.pressure_adjusted_temperature",FrictionPressureAdjustedTemperatureEnum);
    256                         InputUpdateFromConstantx(inputs,elements,1.,FrictionPEnum);
    257                         InputUpdateFromConstantx(inputs,elements,1.,FrictionQEnum);
    258                         break;
    259                 default:
    260                         _error_("friction law not supported");
    261         }
     191        /*Friction*/
     192        FrictionUpdateInputs(elements, inputs, iomodel);
    262193
    263194        /*Free data: */
     
    277208        parameters->AddObject(iomodel->CopyConstantObject("md.thermal.isdrainicecolumn",ThermalIsdrainicecolumnEnum));
    278209        parameters->AddObject(iomodel->CopyConstantObject("md.thermal.watercolumn_upperlimit",ThermalWatercolumnUpperlimitEnum));
    279         parameters->AddObject(iomodel->CopyConstantObject("md.friction.law",FrictionLawEnum));
    280210
    281211        iomodel->FindConstant(&requestedoutputs,&numoutputs,"md.thermal.requested_outputs");
     
    284214        iomodel->DeleteData(&requestedoutputs,numoutputs,"md.thermal.requested_outputs");
    285215
    286         /*Deal with friction parameters*/
    287         int frictionlaw;
    288         iomodel->FindConstant(&frictionlaw,"md.friction.law");
    289         if(frictionlaw==6){
    290                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
    291         }
    292         if(frictionlaw==4){
    293                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
    294                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    295                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    296         }
    297         if(frictionlaw==1 || frictionlaw==3 || frictionlaw==7){
    298                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    299                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    300         }
    301         if(frictionlaw==9){
    302                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
    303                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    304                 parameters->AddObject(new IntParam(FrictionCouplingEnum,0));
    305         }
     216        /*Friction*/
     217        FrictionUpdateParameters(parameters, iomodel);
    306218}/*}}}*/
    307219
  • issm/trunk-jpl/src/c/analyses/HydrologyGlaDSAnalysis.cpp

    r27413 r27470  
    111111
    112112        /*Fetch data needed: */
    113         int    hydrology_model,frictionlaw;
     113        int    hydrology_model;
    114114        iomodel->FindConstant(&hydrology_model,"md.hydrology.model");
    115115
     
    151151                iomodel->FetchDataToInput(inputs,elements,"md.initialization.vx",VxBaseEnum);
    152152                iomodel->FetchDataToInput(inputs,elements,"md.initialization.vy",VyBaseEnum);
    153                 iomodel->FindConstant(&frictionlaw,"md.friction.law");
    154153        }
    155154        else{
    156155                iomodel->FetchDataToInput(inputs,elements,"md.initialization.vx",VxEnum);
    157156                iomodel->FetchDataToInput(inputs,elements,"md.initialization.vy",VyEnum);
    158                 iomodel->FindConstant(&frictionlaw,"md.friction.law");
    159         }
    160 
    161         /*Friction law variables*/
    162         int FrictionCoupling;
    163         switch(frictionlaw){
    164                 case 1:
    165                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    166                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    167                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    168                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    169                         if(FrictionCoupling==3){
    170                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    171                         else if(FrictionCoupling==4){
    172                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    173                         }
    174                         break;
    175                 case 2:
    176                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    177                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    178                         break;
    179                 case 3:
    180                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    181                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    182                         iomodel->FetchDataToInput(inputs,elements,"md.friction.As",FrictionAsEnum);
    183                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    184                         if(FrictionCoupling==3){
    185                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    186                         else if(FrictionCoupling==4){
    187                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    188                         }
    189                         break;
    190                 case 4:
    191                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    192                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    193                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    194                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.pressure",PressureEnum);
    195                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.temperature",TemperatureEnum);
    196                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    197                         break;
    198                 case 5:
    199                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    200                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    201                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    202                         iomodel->FetchDataToInput(inputs,elements,"md.friction.water_layer",FrictionWaterLayerEnum);
    203                         break;
    204                 case 6:
    205                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    206                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    207                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.pressure",PressureEnum);
    208                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.temperature",TemperatureEnum);
    209                         break;
    210                 case 7:
    211                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    212                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    213                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficientcoulomb",FrictionCoefficientcoulombEnum);
    214                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    215                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    216                         if(FrictionCoupling==3){
    217                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    218                         else if(FrictionCoupling==4){
    219                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    220 
    221                         }
    222                         break;
    223                 case 9:
    224                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.temperature",TemperatureEnum);
    225                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    226                         iomodel->FetchDataToInput(inputs,elements,"md.friction.pressure_adjusted_temperature",FrictionPressureAdjustedTemperatureEnum);
    227                         InputUpdateFromConstantx(inputs,elements,1.,FrictionPEnum);
    228                         InputUpdateFromConstantx(inputs,elements,1.,FrictionQEnum);
    229                         break;
    230                 case 10:
    231                         iomodel->FetchDataToInput(inputs,elements,"md.friction.till_friction_angle",FrictionTillFrictionAngleEnum);
    232                         iomodel->FetchDataToInput(inputs,elements,"md.friction.sediment_compressibility_coefficient",FrictionSedimentCompressibilityCoefficientEnum);
    233                         iomodel->FetchDataToInput(inputs,elements,"md.hydrology.watercolumn_max",HydrologyWatercolumnMaxEnum);
    234                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.watercolumn",WatercolumnEnum,0.);
    235                         break;
    236                 case 11:
    237                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    238                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    239                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    240                         iomodel->FetchDataToInput(inputs,elements,"md.friction.Cmax",FrictionCmaxEnum);
    241                         if(FrictionCoupling==3){
    242                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    243                         else if(FrictionCoupling==4){
    244                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    245                         }
    246                         break;
    247                 case 12:
    248                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    249                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    250                         iomodel->FetchDataToInput(inputs,elements,"md.friction.f",FrictionfEnum);
    251                         break;
    252                 case 13:
    253                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    254                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    255                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    256                         if(FrictionCoupling==3){
    257                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    258                         else if(FrictionCoupling==4){
    259                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    260                         }
    261                         break;
    262                 default:
    263                         _error_("friction law "<< frictionlaw <<" not supported");
    264         }
     157        }
     158
     159        /*Friction*/
     160        FrictionUpdateInputs(elements, inputs, iomodel);
     161
    265162}/*}}}*/
    266163void HydrologyGlaDSAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/
     
    276173
    277174        parameters->AddObject(new IntParam(HydrologyModelEnum,hydrology_model));
    278         parameters->AddObject(iomodel->CopyConstantObject("md.friction.law",FrictionLawEnum));
    279175        parameters->AddObject(iomodel->CopyConstantObject("md.hydrology.pressure_melt_coefficient",HydrologyPressureMeltCoefficientEnum));
    280176        parameters->AddObject(iomodel->CopyConstantObject("md.hydrology.cavity_spacing",HydrologyCavitySpacingEnum));
     
    284180        parameters->AddObject(iomodel->CopyConstantObject("md.hydrology.englacial_void_ratio",HydrologyEnglacialVoidRatioEnum));
    285181
    286         /*Deal with friction parameters*/
    287         int frictionlaw;
    288         iomodel->FindConstant(&frictionlaw,"md.friction.law");
    289         switch(frictionlaw){
    290                 case 1:
    291                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    292                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    293                         break;
    294                 case 2:
    295                         break;
    296                 case 3:
    297                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    298                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    299                         break;
    300                 case 4:
    301                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
    302                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    303                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    304                         break;
    305                 case 5:
    306                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.f",FrictionFEnum));
    307                         break;
    308                 case 6:
    309                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
    310                         break;
    311                 case 7:
    312                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    313                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    314                         break;
    315                 case 8:
    316                         break;
    317                 case 9:
    318                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
    319                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    320                         parameters->AddObject(new IntParam(FrictionCouplingEnum,0));
    321                         break;
    322                 case 10:
    323                         parameters->AddObject(new IntParam(FrictionCouplingEnum,2)); /*comment this line to use effective pressure from Beuler and Pelt (2015)*/
    324                         parameters->AddObject(new DoubleParam(FrictionEffectivePressureLimitEnum,0.));
    325                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.pseudoplasticity_exponent",FrictionPseudoplasticityExponentEnum));
    326                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.threshold_speed",FrictionThresholdSpeedEnum));
    327                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.delta",FrictionDeltaEnum));
    328                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.void_ratio",FrictionVoidRatioEnum));
    329                         break;
    330                 case 11:
    331                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    332                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    333                         break;
    334                 case 12:
    335                         parameters->AddObject(new IntParam(FrictionCouplingEnum,2));
    336                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    337                         break;
    338                 case 13:
    339                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    340                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    341                         break;
    342                 default: _error_("Friction law "<<frictionlaw<<" not implemented yet");
    343         }
     182        /*Friction*/
     183        FrictionUpdateParameters(parameters, iomodel);
    344184
    345185        /*Requested outputs*/
  • issm/trunk-jpl/src/c/analyses/HydrologyShaktiAnalysis.cpp

    r27413 r27470  
    124124                iomodel->FetchDataToInput(inputs,elements,"md.initialization.vy",VyBaseEnum);
    125125        }
    126         iomodel->FindConstant(&frictionlaw,"md.friction.law");
    127 
    128         /*Friction law variables*/
    129         switch(frictionlaw){
    130                 case 1:
    131                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    132                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    133                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    134                         break;
    135                 case 8:
    136                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    137                         break;
    138                 default:
    139                         _error_("Friction law "<< frictionlaw <<" not supported");
    140         }
     126
     127        /*Friction*/
     128        FrictionUpdateInputs(elements, inputs, iomodel);
    141129}/*}}}*/
    142130void HydrologyShaktiAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/
     
    152140
    153141        parameters->AddObject(new IntParam(HydrologyModelEnum,hydrology_model));
    154         parameters->AddObject(iomodel->CopyConstantObject("md.friction.law",FrictionLawEnum));
    155142   parameters->AddObject(iomodel->CopyConstantObject("md.hydrology.relaxation",HydrologyRelaxationEnum));
    156143        parameters->AddObject(iomodel->CopyConstantObject("md.hydrology.storage",HydrologyStorageEnum));
    157 
    158         /*Deal with friction parameters*/
    159         int frictionlaw;
    160         iomodel->FindConstant(&frictionlaw,"md.friction.law");
    161         if(frictionlaw==6){
    162                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
    163         }
    164         if(frictionlaw==4){
    165                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
    166                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    167                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    168         }
    169         if(frictionlaw==1 || frictionlaw==3 || frictionlaw==7){
    170                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    171                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    172         }
    173         if(frictionlaw==9){
    174                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
    175                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    176                 parameters->AddObject(new IntParam(FrictionCouplingEnum,0));
    177         }
    178144
    179145  /*Requested outputs*/
     
    182148  if(numoutputs)parameters->AddObject(new StringArrayParam(HydrologyRequestedOutputsEnum,requestedoutputs,numoutputs));
    183149  iomodel->DeleteData(&requestedoutputs,numoutputs,"md.hydrology.requested_outputs");
     150
     151        /*Friction*/
     152        FrictionUpdateParameters(parameters, iomodel);
    184153}/*}}}*/
    185154
  • issm/trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp

    r27284 r27470  
    692692        /*Intermediaries*/
    693693        int    materials_type,finiteelement,fe_FS;
    694         int    approximation,frictionlaw;
    695         int    FrictionCoupling;
     694        int    approximation;
    696695        int*   finiteelement_list=NULL;
    697696        bool   isSSA,isL1L2,isMOLHO,isHO,isFS,iscoupling;
     
    710709        iomodel->FindConstant(&materials_type,"md.materials.type");
    711710        iomodel->FindConstant(&ismovingfront,"md.transient.ismovingfront");
    712         iomodel->FindConstant(&frictionlaw,"md.friction.law");
    713711
    714712        /*return if no processing required*/
     
    876874        }
    877875
    878         /*Friction law variables*/
    879         switch(frictionlaw){
    880                 case 1:
    881                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    882                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    883                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    884                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    885                         if(FrictionCoupling==3){
    886                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    887                         else if(FrictionCoupling==4){
    888                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    889                         }
    890                         break;
    891                 case 2:
    892                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    893                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    894                         break;
    895                 case 3:
    896                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    897                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    898                         iomodel->FetchDataToInput(inputs,elements,"md.friction.As",FrictionAsEnum);
    899                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    900                         if(FrictionCoupling==3){
    901                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    902                         else if(FrictionCoupling==4){
    903                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    904                         }
    905                         break;
    906                 case 4:
    907                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    908                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    909                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    910                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.pressure",PressureEnum);
    911                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.temperature",TemperatureEnum);
    912                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    913                         break;
    914                 case 5:
    915                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    916                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    917                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    918                         iomodel->FetchDataToInput(inputs,elements,"md.friction.water_layer",FrictionWaterLayerEnum);
    919                         break;
    920                 case 6:
    921                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    922                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    923                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.pressure",PressureEnum);
    924                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.temperature",TemperatureEnum);
    925                         break;
    926                 case 7:
    927                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    928                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    929                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficientcoulomb",FrictionCoefficientcoulombEnum);
    930                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    931                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    932                         if(FrictionCoupling==3){
    933                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    934                         else if(FrictionCoupling==4){
    935                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    936 
    937                         }
    938                         break;
    939                 case 9:
    940                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.temperature",TemperatureEnum);
    941                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    942                         iomodel->FetchDataToInput(inputs,elements,"md.friction.pressure_adjusted_temperature",FrictionPressureAdjustedTemperatureEnum);
    943                         InputUpdateFromConstantx(inputs,elements,1.,FrictionPEnum);
    944                         InputUpdateFromConstantx(inputs,elements,1.,FrictionQEnum);
    945                         break;
    946                 case 10:
    947                         iomodel->FetchDataToInput(inputs,elements,"md.friction.till_friction_angle",FrictionTillFrictionAngleEnum);
    948                         iomodel->FetchDataToInput(inputs,elements,"md.friction.sediment_compressibility_coefficient",FrictionSedimentCompressibilityCoefficientEnum);
    949                         iomodel->FetchDataToInput(inputs,elements,"md.hydrology.watercolumn_max",HydrologyWatercolumnMaxEnum);
    950                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.watercolumn",WatercolumnEnum,0.);
    951                         break;
    952                 case 11:
    953                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    954                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    955                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    956                         iomodel->FetchDataToInput(inputs,elements,"md.friction.Cmax",FrictionCmaxEnum);
    957                         if(FrictionCoupling==3){
    958                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    959                         else if(FrictionCoupling==4){
    960                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    961                         }
    962                         break;
    963                 case 12:
    964                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    965                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    966                         iomodel->FetchDataToInput(inputs,elements,"md.friction.f",FrictionfEnum);
    967                         break;
    968                 case 13:
    969                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    970                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    971                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    972                         if(FrictionCoupling==3){
    973                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    974                         else if(FrictionCoupling==4){
    975                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    976                         }
    977                         break;
    978                 default:
    979                         _error_("friction law "<< frictionlaw <<" not supported");
    980         }
    981 
    982 #ifdef _HAVE_ANDROID_
    983         inputs->DuplicateInput(FrictionCoefficientEnum,AndroidFrictionCoefficientEnum);
    984 #endif
     876        /*Friction*/
     877        FrictionUpdateInputs(elements, inputs, iomodel);
    985878
    986879        /*Free data: */
     
    1014907        parameters->AddObject(iomodel->CopyConstantObject("md.stressbalance.FSreconditioning",StressbalanceFSreconditioningEnum));
    1015908        parameters->AddObject(iomodel->CopyConstantObject("md.stressbalance.shelf_dampening",StressbalanceShelfDampeningEnum));
    1016         parameters->AddObject(iomodel->CopyConstantObject("md.friction.law",FrictionLawEnum));
    1017909
    1018910        /*XTH LATH parameters*/
     
    1037929        iomodel->DeleteData(&requestedoutputs,numoutputs,"md.stressbalance.requested_outputs");
    1038930
    1039         /*Deal with friction parameters*/
    1040         int frictionlaw;
    1041         iomodel->FindConstant(&frictionlaw,"md.friction.law");
    1042         switch(frictionlaw){
    1043                 case 1:
    1044                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    1045                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    1046                         break;
    1047                 case 2:
    1048                         break;
    1049                 case 3:
    1050                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    1051                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    1052                         break;
    1053                 case 4:
    1054                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
    1055                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    1056                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    1057                         break;
    1058                 case 5:
    1059                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.f",FrictionFEnum));
    1060                         break;
    1061                 case 6:
    1062                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
    1063                         break;
    1064                 case 7:
    1065                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    1066                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    1067                         break;
    1068                 case 8:
    1069                         break;
    1070                 case 9:
    1071                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
    1072                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    1073                         parameters->AddObject(new IntParam(FrictionCouplingEnum,0));
    1074                         break;
    1075                 case 10:
    1076                         parameters->AddObject(new IntParam(FrictionCouplingEnum,2)); /*comment this line to use effective pressure from Beuler and Pelt (2015)*/
    1077                         parameters->AddObject(new DoubleParam(FrictionEffectivePressureLimitEnum,0.));
    1078                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.pseudoplasticity_exponent",FrictionPseudoplasticityExponentEnum));
    1079                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.threshold_speed",FrictionThresholdSpeedEnum));
    1080                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.delta",FrictionDeltaEnum));
    1081                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.void_ratio",FrictionVoidRatioEnum));
    1082                         break;
    1083                 case 11:
    1084                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    1085                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    1086                         break;
    1087                 case 12:
    1088                         parameters->AddObject(new IntParam(FrictionCouplingEnum,2));
    1089                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    1090                         break;
    1091                 case 13:
    1092                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    1093                         parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    1094                         break;
    1095                 default: _error_("Friction law "<<frictionlaw<<" not implemented yet");
    1096         }
     931        /*Friction*/
     932        FrictionUpdateParameters(parameters, iomodel);
    1097933
    1098934}/*}}}*/
  • issm/trunk-jpl/src/c/analyses/StressbalanceSIAAnalysis.cpp

    r27102 r27470  
    113113        bool   isSIA;
    114114        bool   ismovingfront;
    115         int    frictionlaw;
    116115        iomodel->FindConstant(&isSIA,"md.flowequation.isSIA");
    117116        iomodel->FindConstant(&ismovingfront,"md.transient.ismovingfront");
    118         iomodel->FindConstant(&frictionlaw,"md.friction.law");
    119117
    120118        /*Now, is the flag SIA on? otherwise, do nothing: */
     
    140138        iomodel->DeleteData(1,"md.flowequation.element_equation");
    141139
    142         /*Friction law variables*/
    143         switch(frictionlaw){
    144                 case 1:
    145                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    146                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    147                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    148                         break;
    149                 case 2:
    150                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    151                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    152                         break;
    153                 case 6:
    154                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    155                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    156                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.pressure",PressureEnum);
    157                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.temperature",TemperatureEnum);
    158                         break;
    159                 default:
    160                         _error_("not supported");
    161         }
    162 
    163140        iomodel->FetchDataToInput(inputs,elements,"md.geometry.thickness",ThicknessEnum);
    164141        iomodel->FetchDataToInput(inputs,elements,"md.mask.ocean_levelset",MaskOceanLevelsetEnum);
     
    168145        }
    169146
     147        /*Friction*/
     148        FrictionUpdateInputs(elements, inputs, iomodel);
     149
    170150}/*}}}*/
    171151void StressbalanceSIAAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/
    172152
    173         /*No specific parameters*/
     153        /*Friction*/
     154        FrictionUpdateParameters(parameters, iomodel);
    174155
    175156}/*}}}*/
  • issm/trunk-jpl/src/c/analyses/ThermalAnalysis.cpp

    r27102 r27470  
    106106void ThermalAnalysis::UpdateElements(Elements* elements,Inputs* inputs,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/
    107107
    108         int frictionlaw,basalforcing_model,materialstype;
    109         int FrictionCoupling;
     108        int basalforcing_model,materialstype;
     109
    110110        /*Now, is the model 3d? otherwise, do nothing: */
    111111        if(iomodel->domaintype==Domain2DhorizontalEnum)return;
     
    127127        iomodel->FindConstant(&dakota_analysis,"md.qmu.isdakota");
    128128        iomodel->FindConstant(&ismovingfront,"md.transient.ismovingfront");
    129         iomodel->FindConstant(&frictionlaw,"md.friction.law");
    130129        iomodel->FindConstant(&materialstype,"md.materials.type");
    131130
     
    183182                        break;
    184183        }
    185         /*Friction law variables*/
    186         switch(frictionlaw){
    187                 case 1:
    188                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    189                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    190                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    191                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    192                         if (FrictionCoupling==3){
    193                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    194                         else if(FrictionCoupling==4){
    195                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    196                         }
    197                         break;
    198                 case 2:
    199                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    200                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    201                         break;
    202                 case 3:
    203                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    204                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    205                         iomodel->FetchDataToInput(inputs,elements,"md.friction.As",FrictionAsEnum);
    206                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    207                         if (FrictionCoupling==3){
    208                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    209                         else if(FrictionCoupling==4){
    210                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    211                         }
    212                         break;
    213                 case 4:
    214                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    215                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    216                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    217                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.pressure",PressureEnum);
    218                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.temperature",TemperatureEnum);
    219                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    220                         break;
    221                 case 5:
    222                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    223                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    224                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    225                         iomodel->FetchDataToInput(inputs,elements,"md.friction.water_layer",FrictionWaterLayerEnum);
    226                         break;
    227                 case 6:
    228                         iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
    229                         iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
    230                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.pressure",PressureEnum);
    231                         iomodel->FetchDataToInput(inputs,elements,"md.initialization.temperature",TemperatureEnum);
    232                         break;
    233                 case 7:
    234                         iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling");
    235                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    236                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficientcoulomb",FrictionCoefficientcoulombEnum);
    237                         iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
    238                         iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
    239                         if (FrictionCoupling==3){
    240                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
    241                         else if(FrictionCoupling==4){
    242                                 iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
    243                         }
    244                         break;
    245                 case 9:
    246                         iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
    247                         iomodel->FetchDataToInput(inputs,elements,"md.friction.pressure_adjusted_temperature",FrictionPressureAdjustedTemperatureEnum);
    248                         InputUpdateFromConstantx(inputs,elements,1.,FrictionPEnum);
    249                         InputUpdateFromConstantx(inputs,elements,1.,FrictionQEnum);
    250                         break;
    251                 default:
    252                         _error_("friction law not supported");
    253         }
     184
     185        /*Friction*/
     186        FrictionUpdateInputs(elements, inputs, iomodel);
    254187}/*}}}*/
    255188void ThermalAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/
     
    265198        parameters->AddObject(iomodel->CopyConstantObject("md.thermal.isenthalpy",ThermalIsenthalpyEnum));
    266199        parameters->AddObject(iomodel->CopyConstantObject("md.thermal.isdynamicbasalspc",ThermalIsdynamicbasalspcEnum));
    267         parameters->AddObject(iomodel->CopyConstantObject("md.friction.law",FrictionLawEnum));
    268200
    269201        iomodel->FindConstant(&requestedoutputs,&numoutputs,"md.thermal.requested_outputs");
     
    272204        iomodel->DeleteData(&requestedoutputs,numoutputs,"md.thermal.requested_outputs");
    273205
    274         /*Deal with friction parameters*/
    275         int frictionlaw;
    276         iomodel->FindConstant(&frictionlaw,"md.friction.law");
    277         if(frictionlaw==6){
    278                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
    279         }
    280         if(frictionlaw==4){
    281                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
    282                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    283                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    284         }
    285         if(frictionlaw==1 || frictionlaw==3 || frictionlaw==7){
    286                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
    287                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    288         }
    289         if(frictionlaw==9){
    290                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
    291                 parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
    292                 parameters->AddObject(new IntParam(FrictionCouplingEnum,0));
    293         }
    294 
     206        /*Friction*/
     207        FrictionUpdateParameters(parameters, iomodel);
    295208}/*}}}*/
    296209
  • issm/trunk-jpl/src/c/classes/Loads/Friction.cpp

    r27462 r27470  
    1313#include "../classes.h"
    1414#include "shared/shared.h"
     15#include "../../modules/InputUpdateFromConstantx/InputUpdateFromConstantx.h"
    1516/*}}}*/
    1617
     
    1920        this->element=NULL;
    2021        this->law=0;
     22        this->linearize=false;
    2123        this->apply_dim = 1.;
    2224        this->domaintype=-1;
     
    2426        this->vy_input=NULL;
    2527        this->vz_input=NULL;
     28        this->alpha2_list=NULL;
     29        this->alpha2_complement_list=NULL;
    2630}
    2731/*}}}*/
     
    3943                case Domain2DhorizontalEnum:
    4044                        this->apply_dim = 2.;
    41                         this->vx_input = element_in->GetInput(VxBaseEnum);                      _assert_(this->vx_input);
    42                         this->vy_input = element_in->GetInput(VyBaseEnum);                      _assert_(this->vy_input);
     45                        this->vx_input = element_in->GetInput(VxBaseEnum);      _assert_(this->vx_input);
     46                        this->vy_input = element_in->GetInput(VyBaseEnum);      _assert_(this->vy_input);
    4347                        this->vz_input = NULL;
    4448                        break;
    4549      case Domain2DverticalEnum:
    4650                        this->apply_dim = 2.;
    47                         this->vx_input = element_in->GetInput(VxEnum);                          _assert_(this->vx_input);
    48                         this->vy_input = element_in->GetInput(VyEnum);                          _assert_(this->vy_input);
     51                        this->vx_input = element_in->GetInput(VxEnum);  _assert_(this->vx_input);
     52                        this->vy_input = element_in->GetInput(VyEnum);  _assert_(this->vy_input);
    4953                        this->vz_input = NULL;
    5054                        break;
    5155      case Domain3DEnum:           
    5256                        this->apply_dim = 3.;
    53                         this->vx_input = element_in->GetInput(VxEnum);                          _assert_(this->vx_input);
    54                         this->vy_input = element_in->GetInput(VyEnum);                          _assert_(this->vy_input);
    55                         this->vz_input = element_in->GetInput(VzEnum);                          _assert_(this->vz_input);
     57                        this->vx_input = element_in->GetInput(VxEnum);  _assert_(this->vx_input);
     58                        this->vy_input = element_in->GetInput(VyEnum);  _assert_(this->vy_input);
     59                        this->vz_input = element_in->GetInput(VzEnum);  _assert_(this->vz_input);
    5660                        break;
    5761      default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet");
     62        }
     63
     64        if(this->law==1){
     65                element_in->FindParam(&this->linearize,FrictionLinearizeEnum);
     66                if(this->linearize){
     67                        this->linearize = false; /*Change to make sure we do the calculation once*/
     68                        int numvertices = this->element->GetNumberOfVertices();
     69                        this->alpha2_list            = xNew<IssmDouble>(numvertices);
     70                        this->alpha2_complement_list = xNew<IssmDouble>(numvertices);
     71                        Gauss* gauss=this->element->NewGauss();
     72                        for(int iv=0;iv<numvertices;iv++){
     73                                gauss->GaussVertex(iv);
     74                                this->GetAlpha2(&this->alpha2_list[iv], gauss);
     75                                IssmDouble temp = 0.;
     76                                this->GetAlpha2(&temp, gauss);
     77                                this->GetAlphaComplement(&this->alpha2_complement_list[iv], gauss);
     78                        }
     79                        this->linearize = true ; /*Change back, we are now all set!*/
     80                }
    5881        }
    5982}
     
    6891/*}}}*/
    6992Friction::~Friction(){/*{{{*/
     93        if(this->linearize){
     94                xDelete<IssmDouble>(this->alpha2_list);
     95                xDelete<IssmDouble>(this->alpha2_complement_list);
     96        }
    7097}
    7198/*}}}*/
    72 
    7399
    74100/*methods: */
     
    270296        switch(this->law){
    271297                case 1:
    272                         GetAlpha2Viscous(palpha2,gauss);
     298                        if(this->linearize){
     299                                this->element->ValueP1OnGauss(palpha2, this->alpha2_list, gauss);
     300                        }
     301                        else{
     302                                GetAlpha2Viscous(palpha2,gauss);
     303                        }
    273304                        break;
    274305                case 2:
     
    10461077        _assert_(!xIsInf<IssmDouble>(*pvz));
    10471078}/*}}}*/
     1079
     1080/*IO*/
     1081void FrictionUpdateInputs(Elements* elements,Inputs* inputs,IoModel* iomodel){/*{{{*/
     1082
     1083        /*Intermediaries*/
     1084        int    frictionlaw;
     1085        int    frictioncoupling;
     1086
     1087        /*Friction law variables*/
     1088        iomodel->FindConstant(&frictionlaw,"md.friction.law");
     1089        switch(frictionlaw){
     1090                case 1:
     1091                        iomodel->FindConstant(&frictioncoupling,"md.friction.coupling");
     1092                        iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
     1093                        iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
     1094                        iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
     1095                        if(frictioncoupling==3){
     1096                                iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
     1097                        else if(frictioncoupling==4){
     1098                                iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
     1099                        }
     1100                        break;
     1101                case 2:
     1102                        iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
     1103                        iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
     1104                        break;
     1105                case 3:
     1106                        iomodel->FindConstant(&frictioncoupling,"md.friction.coupling");
     1107                        iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
     1108                        iomodel->FetchDataToInput(inputs,elements,"md.friction.As",FrictionAsEnum);
     1109                        iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
     1110                        if(frictioncoupling==3){
     1111                                iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
     1112                        else if(frictioncoupling==4){
     1113                                iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
     1114                        }
     1115                        break;
     1116                case 4:
     1117                        iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
     1118                        iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
     1119                        iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
     1120                        iomodel->FetchDataToInput(inputs,elements,"md.initialization.pressure",PressureEnum);
     1121                        iomodel->FetchDataToInput(inputs,elements,"md.initialization.temperature",TemperatureEnum);
     1122                        iomodel->FindConstant(&frictioncoupling,"md.friction.coupling");
     1123                        break;
     1124                case 5:
     1125                        iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
     1126                        iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
     1127                        iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
     1128                        iomodel->FetchDataToInput(inputs,elements,"md.friction.water_layer",FrictionWaterLayerEnum);
     1129                        break;
     1130                case 6:
     1131                        iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
     1132                        iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
     1133                        iomodel->FetchDataToInput(inputs,elements,"md.initialization.pressure",PressureEnum);
     1134                        iomodel->FetchDataToInput(inputs,elements,"md.initialization.temperature",TemperatureEnum);
     1135                        break;
     1136                case 7:
     1137                        iomodel->FindConstant(&frictioncoupling,"md.friction.coupling");
     1138                        iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
     1139                        iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficientcoulomb",FrictionCoefficientcoulombEnum);
     1140                        iomodel->FetchDataToInput(inputs,elements,"md.friction.p",FrictionPEnum);
     1141                        iomodel->FetchDataToInput(inputs,elements,"md.friction.q",FrictionQEnum);
     1142                        if(frictioncoupling==3){
     1143                                iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
     1144                        else if(frictioncoupling==4){
     1145                                iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
     1146
     1147                        }
     1148                        break;
     1149                case 9:
     1150                        iomodel->FetchDataToInput(inputs,elements,"md.initialization.temperature",TemperatureEnum);
     1151                        iomodel->FetchDataToInput(inputs,elements,"md.friction.coefficient",FrictionCoefficientEnum);
     1152                        iomodel->FetchDataToInput(inputs,elements,"md.friction.pressure_adjusted_temperature",FrictionPressureAdjustedTemperatureEnum);
     1153                        InputUpdateFromConstantx(inputs,elements,1.,FrictionPEnum);
     1154                        InputUpdateFromConstantx(inputs,elements,1.,FrictionQEnum);
     1155                        break;
     1156                case 10:
     1157                        iomodel->FetchDataToInput(inputs,elements,"md.friction.till_friction_angle",FrictionTillFrictionAngleEnum);
     1158                        iomodel->FetchDataToInput(inputs,elements,"md.friction.sediment_compressibility_coefficient",FrictionSedimentCompressibilityCoefficientEnum);
     1159                        iomodel->FetchDataToInput(inputs,elements,"md.hydrology.watercolumn_max",HydrologyWatercolumnMaxEnum);
     1160                        iomodel->FetchDataToInput(inputs,elements,"md.initialization.watercolumn",WatercolumnEnum,0.);
     1161                        break;
     1162                case 11:
     1163                        iomodel->FindConstant(&frictioncoupling,"md.friction.coupling");
     1164                        iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
     1165                        iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
     1166                        iomodel->FetchDataToInput(inputs,elements,"md.friction.Cmax",FrictionCmaxEnum);
     1167                        if(frictioncoupling==3){
     1168                                iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
     1169                        else if(frictioncoupling==4){
     1170                                iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
     1171                        }
     1172                        break;
     1173                case 12:
     1174                        iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
     1175                        iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
     1176                        iomodel->FetchDataToInput(inputs,elements,"md.friction.f",FrictionfEnum);
     1177                        break;
     1178                case 13:
     1179                        iomodel->FindConstant(&frictioncoupling,"md.friction.coupling");
     1180                        iomodel->FetchDataToInput(inputs,elements,"md.friction.C",FrictionCEnum);
     1181                        iomodel->FetchDataToInput(inputs,elements,"md.friction.m",FrictionMEnum);
     1182                        if(frictioncoupling==3){
     1183                                iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
     1184                        else if(frictioncoupling==4){
     1185                                iomodel->FetchDataToInput(inputs,elements,"md.friction.effective_pressure",EffectivePressureEnum);
     1186                        }
     1187                        break;
     1188                default:
     1189                        _error_("friction law "<< frictionlaw <<" not supported");
     1190        }
     1191
     1192#ifdef _HAVE_ANDROID_
     1193        inputs->DuplicateInput(FrictionCoefficientEnum,AndroidFrictionCoefficientEnum);
     1194#endif
     1195
     1196}/*}}}*/
     1197void FrictionUpdateParameters(Parameters* parameters,IoModel* iomodel){/*{{{*/
     1198
     1199        parameters->AddObject(iomodel->CopyConstantObject("md.friction.law",FrictionLawEnum));
     1200
     1201        /*Set default linearize parameter to 0 for now*/
     1202        parameters->AddObject(new IntParam(FrictionLinearizeEnum,0));
     1203
     1204        int frictionlaw;
     1205        iomodel->FindConstant(&frictionlaw,"md.friction.law");
     1206        switch(frictionlaw){
     1207                case 1:
     1208                        //parameters->AddObject(iomodel->CopyConstantObject("md.friction.linearize",FrictionLinearizeEnum));
     1209                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
     1210                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
     1211                        break;
     1212                case 2:
     1213                        break;
     1214                case 3:
     1215                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
     1216                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
     1217                        break;
     1218                case 4:
     1219                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
     1220                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
     1221                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
     1222                        break;
     1223                case 5:
     1224                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.f",FrictionFEnum));
     1225                        break;
     1226                case 6:
     1227                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
     1228                        break;
     1229                case 7:
     1230                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
     1231                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
     1232                        break;
     1233                case 8:
     1234                        break;
     1235                case 9:
     1236                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum));
     1237                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
     1238                        parameters->AddObject(new IntParam(FrictionCouplingEnum,0));
     1239                        break;
     1240                case 10:
     1241                        parameters->AddObject(new IntParam(FrictionCouplingEnum,2)); /*comment this line to use effective pressure from Beuler and Pelt (2015)*/
     1242                        parameters->AddObject(new DoubleParam(FrictionEffectivePressureLimitEnum,0.));
     1243                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.pseudoplasticity_exponent",FrictionPseudoplasticityExponentEnum));
     1244                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.threshold_speed",FrictionThresholdSpeedEnum));
     1245                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.delta",FrictionDeltaEnum));
     1246                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.void_ratio",FrictionVoidRatioEnum));
     1247                        break;
     1248                case 11:
     1249                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
     1250                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
     1251                        break;
     1252                case 12:
     1253                        parameters->AddObject(new IntParam(FrictionCouplingEnum,2));
     1254                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
     1255                        break;
     1256                case 13:
     1257                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum));
     1258                        parameters->AddObject(iomodel->CopyConstantObject("md.friction.effective_pressure_limit",FrictionEffectivePressureLimitEnum));
     1259                        break;
     1260                default: _error_("Friction law "<<frictionlaw<<" not implemented yet");
     1261        }
     1262
     1263}/*}}}*/
  • issm/trunk-jpl/src/c/classes/Loads/Friction.h

    r26676 r27470  
    88/*Headers:*/
    99class Inputs;
     10class Elements;
     11class Parameters;
     12class IoModel;
    1013class GaussPenta;
    1114class GaussTria;
     
    2124                Input      *vy_input;
    2225                Input      *vz_input;
     26                bool        linearize;
     27                IssmDouble *alpha2_list;
     28                IssmDouble *alpha2_complement_list;
    2329
    2430                /*methods: */
     
    6066};
    6167
     68/*Friction related IO*/
     69void FrictionUpdateParameters(Parameters* parameters,IoModel* iomodel);
     70void FrictionUpdateInputs(Elements* elements,Inputs* inputs,IoModel* iomodel);
     71
    6272#endif  /* _FRICTION_H_ */
Note: See TracChangeset for help on using the changeset viewer.