[25834] | 1 | Index: ../trunk-jpl/src/c/cores/transient_core.cpp
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/c/cores/transient_core.cpp (revision 25465)
|
---|
| 4 | +++ ../trunk-jpl/src/c/cores/transient_core.cpp (revision 25466)
|
---|
| 5 | @@ -72,20 +72,10 @@
|
---|
| 6 | if(isoceancoupling) OceanExchangeDatax(femmodel,true);
|
---|
| 7 | #endif
|
---|
| 8 |
|
---|
| 9 | - IssmDouble output_value;
|
---|
| 10 | - int num_dependents;
|
---|
| 11 | - IssmPDouble *dependents;
|
---|
| 12 | - DataSet* dependent_objects=NULL;
|
---|
| 13 | - IssmDouble J=0.;
|
---|
| 14 | -
|
---|
| 15 | + DataSet* dependent_objects=NULL;
|
---|
| 16 | if(iscontrol && isautodiff){
|
---|
| 17 | -
|
---|
| 18 | - femmodel->parameters->SetParam(starttime,TimeEnum);
|
---|
| 19 | - femmodel->parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum);
|
---|
| 20 | + femmodel->parameters->SetParam(starttime,TimeEnum); /*FIXME: DO WE REALLY NEED THIS?*/
|
---|
| 21 | femmodel->parameters->FindParam(&dependent_objects,AutodiffDependentObjectsEnum);
|
---|
| 22 | -
|
---|
| 23 | - /*Go through our dependent variables, and compute the response:*/
|
---|
| 24 | - dependents=xNew<IssmPDouble>(num_dependents);
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | if(isslr) sealevelrise_core_geometry(femmodel);
|
---|
| 28 | @@ -157,10 +147,11 @@
|
---|
| 29 | /*Go through our dependent variables, and compute the response:*/
|
---|
| 30 | for(int i=0;i<dependent_objects->Size();i++){
|
---|
| 31 | DependentObject* dep=(DependentObject*)dependent_objects->GetObjectByOffset(i);
|
---|
| 32 | - dep->Responsex(&output_value,femmodel);
|
---|
| 33 | - dep->AddValue(output_value);
|
---|
| 34 | - }
|
---|
| 35 | + IssmDouble output_value;
|
---|
| 36 | + dep->Responsex(&output_value,femmodel);
|
---|
| 37 | + dep->AddValue(output_value);
|
---|
| 38 | }
|
---|
| 39 | + }
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | if(!iscontrol || !isautodiff) femmodel->RequestedDependentsx();
|
---|
| 43 | @@ -283,3 +274,104 @@
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | }/*}}}*/
|
---|
| 47 | +
|
---|
| 48 | +#ifdef _HAVE_CODIPACK_
|
---|
| 49 | +void transient_ad(FemModel* femmodel){/*{{{*/
|
---|
| 50 | +
|
---|
| 51 | + /*parameters: */
|
---|
| 52 | + IssmDouble finaltime,dt,yts,starttime;
|
---|
| 53 | + bool isoceancoupling,iscontrol,isautodiff,isgroundingline,isslr;
|
---|
| 54 | + bool save_results,dakota_analysis;
|
---|
| 55 | + int timestepping;
|
---|
| 56 | + int output_frequency;
|
---|
| 57 | + int sb_coupling_frequency;
|
---|
| 58 | + int recording_frequency;
|
---|
| 59 | + int groundingline_migration,smb_model,amr_frequency,amr_restart;
|
---|
| 60 | + int numoutputs;
|
---|
| 61 | + char **requested_outputs = NULL;
|
---|
| 62 | +
|
---|
| 63 | + /*intermediary: */
|
---|
| 64 | + int step;
|
---|
| 65 | + IssmDouble time;
|
---|
| 66 | +
|
---|
| 67 | + /*first, figure out if there was a check point, if so, do a reset of the FemModel* femmodel structure. */
|
---|
| 68 | + femmodel->parameters->FindParam(&recording_frequency,SettingsRecordingFrequencyEnum);
|
---|
| 69 | + if(recording_frequency) femmodel->Restart();
|
---|
| 70 | +
|
---|
| 71 | + /*then recover parameters common to all solutions*/
|
---|
| 72 | + femmodel->parameters->FindParam(&step,StepEnum);
|
---|
| 73 | + femmodel->parameters->FindParam(&time,TimeEnum);
|
---|
| 74 | + femmodel->parameters->FindParam(&finaltime,TimesteppingFinalTimeEnum);
|
---|
| 75 | + femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum);
|
---|
| 76 | + femmodel->parameters->FindParam(&yts,ConstantsYtsEnum);
|
---|
| 77 | + femmodel->parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum);
|
---|
| 78 | + femmodel->parameters->FindParam(&output_frequency,SettingsOutputFrequencyEnum);
|
---|
| 79 | + femmodel->parameters->FindParam(&sb_coupling_frequency,SettingsSbCouplingFrequencyEnum);
|
---|
| 80 | + femmodel->parameters->FindParam(×tepping,TimesteppingTypeEnum);
|
---|
| 81 | + femmodel->parameters->FindParam(&isslr,TransientIsslrEnum);
|
---|
| 82 | + femmodel->parameters->FindParam(&isgroundingline,TransientIsgroundinglineEnum);
|
---|
| 83 | + femmodel->parameters->FindParam(&amr_frequency,TransientAmrFrequencyEnum);
|
---|
| 84 | + femmodel->parameters->FindParam(&iscontrol,InversionIscontrolEnum);
|
---|
| 85 | + femmodel->parameters->FindParam(&isautodiff,AutodiffIsautodiffEnum);
|
---|
| 86 | + femmodel->parameters->FindParam(&numoutputs,TransientNumRequestedOutputsEnum);
|
---|
| 87 | + if(isgroundingline) femmodel->parameters->FindParam(&groundingline_migration,GroundinglineMigrationEnum);
|
---|
| 88 | + if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,TransientRequestedOutputsEnum);
|
---|
| 89 | +
|
---|
| 90 | + DataSet* dependent_objects=NULL;
|
---|
| 91 | + if(iscontrol){
|
---|
| 92 | + femmodel->parameters->SetParam(starttime,TimeEnum);
|
---|
| 93 | + femmodel->parameters->FindParam(&dependent_objects,AutodiffDependentObjectsEnum);
|
---|
| 94 | + }
|
---|
| 95 | +
|
---|
| 96 | + if(isslr) sealevelrise_core_geometry(femmodel);
|
---|
| 97 | +
|
---|
| 98 | + while(time < finaltime - (yts*DBL_EPSILON)){ //make sure we run up to finaltime.
|
---|
| 99 | +
|
---|
| 100 | + /*Time Increment*/
|
---|
| 101 | + switch(timestepping){
|
---|
| 102 | + case AdaptiveTimesteppingEnum:
|
---|
| 103 | + femmodel->TimeAdaptx(&dt);
|
---|
| 104 | + if(time+dt>finaltime) dt=finaltime-time;
|
---|
| 105 | + femmodel->parameters->SetParam(dt,TimesteppingTimeStepEnum);
|
---|
| 106 | + break;
|
---|
| 107 | + case FixedTimesteppingEnum:
|
---|
| 108 | + femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
| 109 | + break;
|
---|
| 110 | + default:
|
---|
| 111 | + _error_("Time stepping \""<<EnumToStringx(timestepping)<<"\" not supported yet");
|
---|
| 112 | + }
|
---|
| 113 | + step+=1;
|
---|
| 114 | + time+=dt;
|
---|
| 115 | + femmodel->parameters->SetParam(time,TimeEnum);
|
---|
| 116 | + femmodel->parameters->SetParam(step,StepEnum);
|
---|
| 117 | + femmodel->parameters->SetParam(false,SaveResultsEnum);
|
---|
| 118 | +
|
---|
| 119 | + /*Run transient step!*/
|
---|
| 120 | + transient_step(femmodel);
|
---|
| 121 | +
|
---|
| 122 | + /*unload results*/
|
---|
| 123 | + if(VerboseSolution()) _printf0_(" computing requested outputs\n");
|
---|
| 124 | + femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs,false);
|
---|
| 125 | +
|
---|
| 126 | + if(recording_frequency && (step%recording_frequency==0)){
|
---|
| 127 | + if(VerboseSolution()) _printf0_(" checkpointing model \n");
|
---|
| 128 | + femmodel->CheckPoint();
|
---|
| 129 | + }
|
---|
| 130 | +
|
---|
| 131 | + /*Go through our dependent variables, and compute the response:*/
|
---|
| 132 | + for(int i=0;i<dependent_objects->Size();i++){
|
---|
| 133 | + DependentObject* dep=(DependentObject*)dependent_objects->GetObjectByOffset(i);
|
---|
| 134 | + IssmDouble output_value;
|
---|
| 135 | + dep->Responsex(&output_value,femmodel);
|
---|
| 136 | + dep->AddValue(output_value);
|
---|
| 137 | + }
|
---|
| 138 | + }
|
---|
| 139 | +
|
---|
| 140 | + if(!iscontrol) femmodel->RequestedDependentsx();
|
---|
| 141 | + if(iscontrol) femmodel->parameters->SetParam(dependent_objects,AutodiffDependentObjectsEnum);
|
---|
| 142 | +
|
---|
| 143 | + /*Free ressources:*/
|
---|
| 144 | + if(numoutputs){for(int i=0;i<numoutputs;i++){xDelete<char>(requested_outputs[i]);} xDelete<char*>(requested_outputs);}
|
---|
| 145 | +
|
---|
| 146 | +}/*}}}*/
|
---|
| 147 | +#endif
|
---|