Ice Sheet System Model  4.18
Code documentation
Functions
solutionsequence_thermal_nonlinear.cpp File Reference

: core of the thermal solution More...

#include "./solutionsequences.h"
#include "../toolkits/toolkits.h"
#include "../classes/classes.h"
#include "../shared/shared.h"
#include "../modules/modules.h"

Go to the source code of this file.

Functions

void solutionsequence_thermal_nonlinear (FemModel *femmodel)
 

Detailed Description

: core of the thermal solution

Definition in file solutionsequence_thermal_nonlinear.cpp.

Function Documentation

◆ solutionsequence_thermal_nonlinear()

void solutionsequence_thermal_nonlinear ( FemModel femmodel)

Definition at line 11 of file solutionsequence_thermal_nonlinear.cpp.

11  {
12 
13  /*solution : */
14  Vector<IssmDouble>* tg=NULL;
15  Vector<IssmDouble>* tf=NULL;
16  Vector<IssmDouble>* tf_old=NULL;
17  Vector<IssmDouble>* ys=NULL;
18  IssmDouble melting_offset;
19 
20  /*intermediary: */
21  Matrix<IssmDouble>* Kff=NULL;
22  Matrix<IssmDouble>* Kfs=NULL;
23  Vector<IssmDouble>* pf=NULL;
24  Vector<IssmDouble>* df=NULL;
25 
26  bool converged;
27  bool isenthalpy, isdynamicbasalspc;
28  int constraints_converged;
29  int num_unstable_constraints;
30  int count;
31  int thermal_penalty_threshold;
32  int thermal_maxiter;
33 
34  /*parameters:*/
35  IssmDouble eps_rel;
36 
37  /*Recover parameters: */
39  femmodel->parameters->FindParam(&thermal_maxiter,ThermalMaxiterEnum);
40 
41  converged=false;
43 
44  if(isenthalpy){
48 
49  //Update the solution to make sure that tf and tf_old are similar (for next step in transient or steadystate)
53  }
54  else{
55  femmodel->parameters->FindParam(&thermal_penalty_threshold,ThermalPenaltyThresholdEnum);
58  }
59 
60  count=1;
61 
62  for(;;){
63  delete tf_old;tf_old=tf;
64 
65  if(isenthalpy){
66  SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel);
67  /*Update old solution, such that sizes of tf_old and tf are comparable*/
68  if(isdynamicbasalspc){
69  delete tf_old;
71  }
72  }
73  else SystemMatricesx(&Kff, &Kfs, &pf,&df, &melting_offset,femmodel);
74  delete tg;
76  Reduceloadx(pf, Kfs, ys); delete Kfs;
78  Solverx(&tf, Kff, pf, tf_old, df, femmodel->parameters);
80  Mergesolutionfromftogx(&tg, tf,ys,femmodel->nodes,femmodel->parameters); delete ys;
81  if(isenthalpy){
82  convergence(&converged,Kff,pf,tf,tf_old,0.05,eps_rel,NAN);
84  }
85  delete Kff; delete pf; delete df;
87  ConstraintsStatex(&constraints_converged,&num_unstable_constraints,femmodel);
88  if(VerboseConvergence()) _printf0_(" number of unstable constraints: " << num_unstable_constraints << "\n");
89 
90  if(isenthalpy){ // enthalpy method
91  IssmDouble dt;
93 
94  count++;
95  bool max_iteration_state=false;
96  if(count>=thermal_maxiter){
97  _printf0_(" maximum number of nonlinear iterations (" << thermal_maxiter << ") exceeded\n");
98  converged=true;
101  max_iteration_state=true;
102  }
103  if(converged==true){
104  break;
105  }
106  else if(dt==0.){
109  }
110  }
111  else{ // dry ice method
112  if(!converged){
113  if(num_unstable_constraints<=thermal_penalty_threshold) converged=true;
114  if(count>=thermal_maxiter){
115  converged=true;
116  _printf0_(" maximum number of iterations (" << thermal_maxiter << ") exceeded\n");
117  }
118  }
119  count++;
121  if(converged)break;
122  }
123  }
124 
125  if(isenthalpy){
126  if(VerboseConvergence()) _printf0_("\n total number of iterations: " << count-1 << "\n");
127  }
128  else{
130  femmodel->parameters->SetParam(melting_offset,MeltingOffsetEnum);
131  }
132 
133  /*Free ressources: */
134  delete tg;
135  delete tf;
136  delete tf_old;
137 }
Matrix< IssmDouble >
SOLVER
#define SOLVER
Definition: Profiler.h:16
Mergesolutionfromftogx
void Mergesolutionfromftogx(Vector< IssmDouble > **pug, Vector< IssmDouble > *uf, Vector< IssmDouble > *ys, Nodes *nodes, Parameters *parameters, bool flag_ys0)
Definition: Mergesolutionfromftogx.cpp:8
IssmDouble
double IssmDouble
Definition: types.h:37
ConstraintsStatex
void ConstraintsStatex(int *pconverged, int *pnum_unstable_constraints, FemModel *femmodel)
Definition: ConstraintsStatex.cpp:10
EnthalpyAnalysis::UpdateBasalConstraints
static void UpdateBasalConstraints(FemModel *femmodel)
Definition: EnthalpyAnalysis.cpp:1670
_printf0_
#define _printf0_(StreamArgs)
Definition: Print.h:29
VerboseConvergence
bool VerboseConvergence(void)
Definition: Verbosity.cpp:26
ResetZigzagCounterx
void ResetZigzagCounterx(FemModel *femmodel)
Definition: ResetConstraintsx.cpp:39
FemModel::parameters
Parameters * parameters
Definition: FemModel.h:46
TimesteppingTimeStepEnum
@ TimesteppingTimeStepEnum
Definition: EnumDefinitions.h:433
ConvergedEnum
@ ConvergedEnum
Definition: EnumDefinitions.h:514
ThermalIsdynamicbasalspcEnum
@ ThermalIsdynamicbasalspcEnum
Definition: EnumDefinitions.h:416
EnthalpyAnalysis::ComputeBasalMeltingrate
static void ComputeBasalMeltingrate(FemModel *femmodel)
Definition: EnthalpyAnalysis.cpp:355
Solverx
void Solverx(Vector< IssmDouble > **puf, Matrix< IssmDouble > *Kff, Vector< IssmDouble > *pf, Vector< IssmDouble > *uf0, Vector< IssmDouble > *df, Parameters *parameters)
Definition: Solverx.cpp:15
ThermalPenaltyThresholdEnum
@ ThermalPenaltyThresholdEnum
Definition: EnumDefinitions.h:422
Parameters::SetParam
void SetParam(bool boolean, int enum_type)
Definition: Parameters.cpp:441
FemModel::UpdateConstraintsx
void UpdateConstraintsx(void)
Definition: FemModel.cpp:3027
FemModel::nodes
Nodes * nodes
Definition: FemModel.h:56
ThermalReltolEnum
@ ThermalReltolEnum
Definition: EnumDefinitions.h:423
ThermalIsenthalpyEnum
@ ThermalIsenthalpyEnum
Definition: EnumDefinitions.h:417
InputUpdateFromConstantx
void InputUpdateFromConstantx(FemModel *femmodel, bool constant, int name)
Definition: InputUpdateFromConstantx.cpp:10
Profiler::Stop
void Stop(int tagenum, bool dontmpisync=true)
Definition: Profiler.cpp:179
Reducevectorgtofx
void Reducevectorgtofx(Vector< IssmDouble > **puf, Vector< IssmDouble > *ug, Nodes *nodes, Parameters *parameters)
Definition: Reducevectorgtofx.cpp:8
Reduceloadx
void Reduceloadx(Vector< IssmDouble > *pf, Matrix< IssmDouble > *Kfs, Vector< IssmDouble > *y_s, bool flag_ys0)
Definition: Reduceloadx.cpp:14
Profiler::Start
void Start(int tagenum, bool dontmpisync=true)
Definition: Profiler.cpp:139
InputUpdateFromSolutionx
void InputUpdateFromSolutionx(FemModel *femmodel, Vector< IssmDouble > *solution)
Definition: InputUpdateFromSolutionx.cpp:9
GetSolutionFromInputsx
void GetSolutionFromInputsx(Vector< IssmDouble > **psolution, FemModel *femmodel)
Definition: GetSolutionFromInputsx.cpp:9
Parameters::FindParam
void FindParam(bool *pinteger, int enum_type)
Definition: Parameters.cpp:262
ThermalMaxiterEnum
@ ThermalMaxiterEnum
Definition: EnumDefinitions.h:418
CreateNodalConstraintsx
void CreateNodalConstraintsx(Vector< IssmDouble > **pys, Nodes *nodes)
Definition: CreateNodalConstraintsx.cpp:10
SystemMatricesx
void SystemMatricesx(Matrix< IssmDouble > **pKff, Matrix< IssmDouble > **pKfs, Vector< IssmDouble > **ppf, Vector< IssmDouble > **pdf, IssmDouble *pkmax, FemModel *femmodel, bool isAllocated)
Definition: SystemMatricesx.cpp:10
convergence
void convergence(bool *pconverged, Matrix< IssmDouble > *Kff, Vector< IssmDouble > *pf, Vector< IssmDouble > *uf, Vector< IssmDouble > *old_uf, IssmDouble eps_res, IssmDouble eps_rel, IssmDouble eps_abs)
Definition: convergence.cpp:9
FemModel::profiler
Profiler * profiler
Definition: FemModel.h:42
Vector< IssmDouble >
MeltingOffsetEnum
@ MeltingOffsetEnum
Definition: EnumDefinitions.h:269
femmodel
FemModel * femmodel
Definition: esmfbinders.cpp:16