Changeset 25473


Ignore:
Timestamp:
08/25/20 15:11:38 (5 years ago)
Author:
Mathieu Morlighem
Message:

CHG: moving transient stuff around to make it more consistent

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/cores/transient_core.cpp

    r25472 r25473  
    2424        /*parameters: */
    2525        IssmDouble finaltime,dt,yts;
    26         bool       isoceancoupling,iscontrol,isautodiff,isgroundingline,isslr;
    27         bool       save_results,dakota_analysis;
     26        bool       isoceancoupling,iscontrol,isautodiff,isslr;
    2827        int        timestepping;
    29         int        output_frequency;
    30         int        sb_coupling_frequency;
    31         int        recording_frequency;
    32         int        groundingline_migration,smb_model,amr_frequency,amr_restart;
    33         int        numoutputs;
     28        int        output_frequency,recording_frequency;
     29        int        amr_frequency,amr_restart;
    3430        char     **requested_outputs = NULL;
    3531
     
    4743        femmodel->parameters->FindParam(&finaltime,TimesteppingFinalTimeEnum);
    4844        femmodel->parameters->FindParam(&yts,ConstantsYtsEnum);
    49         femmodel->parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum);
    5045        femmodel->parameters->FindParam(&output_frequency,SettingsOutputFrequencyEnum);
    51         femmodel->parameters->FindParam(&sb_coupling_frequency,SettingsSbCouplingFrequencyEnum);
    5246        femmodel->parameters->FindParam(&timestepping,TimesteppingTypeEnum);
    5347        femmodel->parameters->FindParam(&isslr,TransientIsslrEnum);
    54         femmodel->parameters->FindParam(&isgroundingline,TransientIsgroundinglineEnum);
    5548        femmodel->parameters->FindParam(&isoceancoupling,TransientIsoceancouplingEnum);
    5649        femmodel->parameters->FindParam(&amr_frequency,TransientAmrFrequencyEnum);
    5750        femmodel->parameters->FindParam(&iscontrol,InversionIscontrolEnum);
    5851        femmodel->parameters->FindParam(&isautodiff,AutodiffIsautodiffEnum);
    59         if(isgroundingline) femmodel->parameters->FindParam(&groundingline_migration,GroundinglineMigrationEnum);
    60         femmodel->parameters->FindParam(&numoutputs,TransientNumRequestedOutputsEnum);
    61         if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,TransientRequestedOutputsEnum);
    6252
    6353        #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD_)
     
    9989                femmodel->parameters->SetParam(step,StepEnum);
    10090
    101                 if(VerboseSolution()) _printf0_("iteration " << step << "/" << ceil((finaltime-time)/dt)+step << "  time [yr]: " << setprecision(4) << time/yts << " (time step: " << dt/yts << ")\n");
    102                 if(step%output_frequency==0 || (time >= finaltime - (yts*DBL_EPSILON)) || step==1)
    103                  save_results=true;
    104                 else
    105                  save_results=false;
     91                if(VerboseSolution()){
     92                        _printf0_("iteration " << step << "/" << ceil((finaltime-time)/dt)+step << \
     93                                                "  time [yr]: " << setprecision(4) << time/yts << " (time step: " << dt/yts << ")\n");
     94                }
     95                bool save_results=false;
     96                if(step%output_frequency==0 || (time >= finaltime - (yts*DBL_EPSILON)) || step==1) save_results=true;
    10697                femmodel->parameters->SetParam(save_results,SaveResultsEnum);
    10798
     
    110101
    111102                /*unload results*/
    112                 if(VerboseSolution()) _printf0_("   computing requested outputs\n");
    113                 femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs,save_results);
    114                 if(isgroundingline && (groundingline_migration==AggressiveMigrationEnum || groundingline_migration==ContactEnum)){
    115                         int outputs[1] = {MaskOceanLevelsetEnum};
    116                         femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],1,save_results);
    117                 }
    118 
    119103                if(save_results){
    120104                        if(VerboseSolution()) _printf0_("   saving temporary results\n");
     
    156140        if(iscontrol && isautodiff) femmodel->parameters->SetParam(dependent_objects,AutodiffDependentObjectsEnum);
    157141
    158         /*Free ressources:*/
    159         if(numoutputs){for(int i=0;i<numoutputs;i++){xDelete<char>(requested_outputs[i]);} xDelete<char*>(requested_outputs);}
    160 
    161142}/*}}}*/
    162143void transient_step(FemModel* femmodel){/*{{{*/
     
    164145        /*parameters: */
    165146        bool isstressbalance,ismasstransport,issmb,isthermal,isgroundingline,isgia,isesa;
    166         bool isslr,ismovingfront,isdamageevolution,ishydrology,isoceancoupling;
    167         bool save_results;
     147        bool isslr,ismovingfront,isdamageevolution,ishydrology,isoceancoupling,save_results;
    168148        int  step,sb_coupling_frequency;
    169         int  domaintype,smb_model;
     149        int  domaintype,numoutputs;
    170150
    171151        /*then recover parameters common to all solutions*/
    172152        femmodel->parameters->FindParam(&domaintype,DomainTypeEnum);
     153        femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
    173154        femmodel->parameters->FindParam(&step,StepEnum);
    174155        femmodel->parameters->FindParam(&sb_coupling_frequency,SettingsSbCouplingFrequencyEnum);
     
    185166        femmodel->parameters->FindParam(&isdamageevolution,TransientIsdamageevolutionEnum);
    186167        femmodel->parameters->FindParam(&ishydrology,TransientIshydrologyEnum);
     168        femmodel->parameters->FindParam(&numoutputs,TransientNumRequestedOutputsEnum);
    187169
    188170        #if defined(_HAVE_OCEAN_ )
     
    193175                if(issmb){
    194176                        bool isenthalpy;
     177                        int  smb_model;
    195178                        femmodel->parameters->FindParam(&isenthalpy,ThermalIsenthalpyEnum);
    196179                        femmodel->parameters->FindParam(&smb_model,SmbEnum);
     
    272255        }
    273256
     257        /*Any requested output that needs to be saved?*/
     258        if(numoutputs){
     259                char **requested_outputs = NULL;
     260                femmodel->parameters->FindParam(&requested_outputs,&numoutputs,TransientRequestedOutputsEnum);
     261
     262                if(VerboseSolution()) _printf0_("   computing transient requested outputs\n");
     263                femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs,save_results);
     264
     265                /*Free ressources:*/
     266                for(int i=0;i<numoutputs;i++){xDelete<char>(requested_outputs[i]);} xDelete<char*>(requested_outputs);
     267        }
    274268}/*}}}*/
    275269
     
    279273        /*parameters: */
    280274        IssmDouble finaltime,dt,yts;
    281         bool       isoceancoupling,iscontrol,isautodiff,isgroundingline,isslr;
    282         bool       save_results,dakota_analysis;
     275        bool       isoceancoupling,iscontrol,isautodiff,isslr;
    283276        int        timestepping;
    284277        int        output_frequency;
    285         int        sb_coupling_frequency;
    286278        int        recording_frequency;
    287         int        groundingline_migration,smb_model,amr_frequency,amr_restart;
    288         int        numoutputs;
    289         char     **requested_outputs = NULL;
     279        int        amr_frequency,amr_restart;
    290280
    291281        /*intermediary: */
     
    302292        femmodel->parameters->FindParam(&finaltime,TimesteppingFinalTimeEnum);
    303293        femmodel->parameters->FindParam(&yts,ConstantsYtsEnum);
    304         femmodel->parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum);
    305294        femmodel->parameters->FindParam(&output_frequency,SettingsOutputFrequencyEnum);
    306         femmodel->parameters->FindParam(&sb_coupling_frequency,SettingsSbCouplingFrequencyEnum);
    307295        femmodel->parameters->FindParam(&timestepping,TimesteppingTypeEnum);
    308296        femmodel->parameters->FindParam(&isslr,TransientIsslrEnum);
    309         femmodel->parameters->FindParam(&isgroundingline,TransientIsgroundinglineEnum);
    310297        femmodel->parameters->FindParam(&amr_frequency,TransientAmrFrequencyEnum);
    311298        femmodel->parameters->FindParam(&iscontrol,InversionIscontrolEnum);
    312299        femmodel->parameters->FindParam(&isautodiff,AutodiffIsautodiffEnum);
    313         femmodel->parameters->FindParam(&numoutputs,TransientNumRequestedOutputsEnum);
    314         if(isgroundingline) femmodel->parameters->FindParam(&groundingline_migration,GroundinglineMigrationEnum);
    315         if(numoutputs)      femmodel->parameters->FindParam(&requested_outputs,&numoutputs,TransientRequestedOutputsEnum);
    316 
    317         DataSet*    dependent_objects=NULL;
     300
     301        DataSet* dependent_objects=NULL;
    318302        if(iscontrol){
    319303                femmodel->parameters->FindParam(&dependent_objects,AutodiffDependentObjectsEnum);
     
    346330                transient_step(femmodel);
    347331
    348                 /*unload results*/
    349                 if(VerboseSolution()) _printf0_("   computing requested outputs\n");
    350                 femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs,false);
    351 
    352332                if(recording_frequency && (step%recording_frequency==0)){
    353333                        if(VerboseSolution()) _printf0_("   checkpointing model \n");
     
    366346        if(!iscontrol) femmodel->RequestedDependentsx();
    367347        if(iscontrol) femmodel->parameters->SetParam(dependent_objects,AutodiffDependentObjectsEnum);
    368 
    369         /*Free ressources:*/
    370         if(numoutputs){for(int i=0;i<numoutputs;i++){xDelete<char>(requested_outputs[i]);} xDelete<char*>(requested_outputs);}
    371 
    372348}/*}}}*/
    373349#endif
Note: See TracChangeset for help on using the changeset viewer.