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

: core of a non-linear solution, using fixed-point method 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_nonlinear (FemModel *femmodel, bool conserve_loads)
 

Detailed Description

: core of a non-linear solution, using fixed-point method

Definition in file solutionsequence_nonlinear.cpp.

Function Documentation

◆ solutionsequence_nonlinear()

void solutionsequence_nonlinear ( FemModel femmodel,
bool  conserve_loads 
)

Definition at line 11 of file solutionsequence_nonlinear.cpp.

11  {
12 
13  /*intermediary: */
14  Matrix<IssmDouble>* Kff = NULL;
15  Matrix<IssmDouble>* Kfs = NULL;
16  Vector<IssmDouble>* ug = NULL;
17  Vector<IssmDouble>* uf = NULL;
18  Vector<IssmDouble>* old_uf = NULL;
19  Vector<IssmDouble>* pf = NULL;
20  Vector<IssmDouble>* df = NULL;
21  Vector<IssmDouble>* ys = NULL;
22 
23  Loads* savedloads=NULL;
24  bool converged;
25  int constraints_converged;
26  int num_unstable_constraints;
27  int count;
28 
29  /*parameters:*/
30  int min_mechanical_constraints;
31  int max_nonlinear_iterations;
32  int configuration_type;
33  IssmDouble eps_res,eps_rel,eps_abs;
34 
35  /*Recover parameters: */
37  femmodel->parameters->FindParam(&max_nonlinear_iterations,StressbalanceMaxiterEnum);
41  femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
43 
44  /*Were loads requested as output? : */
45  if(conserve_loads){
46  savedloads = static_cast<Loads*>(femmodel->loads->Copy());
47  }
48 
49  count=0;
50  converged=false;
51 
52  /*Start non-linear iteration using input velocity: */
55 
56  /*Update once again the solution to make sure that vx and vxold are similar (for next step in transient or steadystate)*/
59 
60  /*allocate the matrices once and reuse them per iteration*/
61  if(femmodel->loads->numrifts == 0){
62  AllocateSystemMatricesx(&Kff,&Kfs,&df,&pf,femmodel);
63  }
64 
65  for(;;){
66 
67  //save pointer to old velocity
68  delete old_uf;old_uf=uf;
69  delete ug;
70 
71  if(femmodel->loads->numrifts){
72  AllocateSystemMatricesx(&Kff,&Kfs,&df,&pf,femmodel);
73  }
74  SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel, true);
76  Reduceloadx(pf, Kfs, ys);
78  Solverx(&uf, Kff, pf, old_uf, df, femmodel->parameters);
80 
82 
83  convergence(&converged,Kff,pf,uf,old_uf,eps_res,eps_rel,eps_abs);
86 
87  /*Clean up if rifts*/
88  if(femmodel->loads->numrifts){
89  delete Kfs; delete Kff; delete pf; delete df;
90  }
91 
92  ConstraintsStatex(&constraints_converged,&num_unstable_constraints,femmodel);
93  if(VerboseConvergence()) _printf0_(" number of unstable constraints: " << num_unstable_constraints << "\n");
94 
95  //rift convergence
96  if (!constraints_converged) {
97  if (converged){
98  if (num_unstable_constraints <= min_mechanical_constraints) converged=true;
99  else converged=false;
100  }
101  }
102 
103  /*Increase count: */
104  count++;
105  if(converged==true){
107  break;
108  }
109  if(count>=max_nonlinear_iterations){
110  _printf0_(" maximum number of nonlinear iterations (" << max_nonlinear_iterations << ") exceeded\n");
111  converged=true;
115  break;
116  }
117 
118  /*Set the matrix entries to zero if we do an other iteration*/
119  if(femmodel->loads->numrifts==0){
120  Kff->SetZero();
121  Kfs->SetZero();
122  df->Set(0);
123  pf->Set(0);
124  }
125  }
126 
127  /*delete matrices after the iteration loop*/
128  if(femmodel->loads->numrifts==0){
129  delete Kff; delete pf; delete df; delete Kfs;
130  }
131 
132  if(VerboseConvergence()) _printf0_("\n total number of iterations: " << count << "\n");
133 
134  /*clean-up*/
135  if(conserve_loads){
136  delete femmodel->loads;
137  int index=femmodel->AnalysisIndex(configuration_type);
138  femmodel->loads_list[index]=savedloads;
139  femmodel->loads=savedloads;
140  }
141  delete uf;
142  delete ug;
143  delete old_uf;
144 }
DataSet::Size
int Size()
Definition: DataSet.cpp:399
Matrix< IssmDouble >
SOLVER
#define SOLVER
Definition: Profiler.h:16
FemModel::AnalysisIndex
int AnalysisIndex(int)
Definition: FemModel.cpp:220
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
_printf0_
#define _printf0_(StreamArgs)
Definition: Print.h:29
VerboseConvergence
bool VerboseConvergence(void)
Definition: Verbosity.cpp:26
FemModel::parameters
Parameters * parameters
Definition: FemModel.h:46
ConvergedEnum
@ ConvergedEnum
Definition: EnumDefinitions.h:514
FemModel::results
Results * results
Definition: FemModel.h:48
StressbalanceConvergenceNumStepsEnum
@ StressbalanceConvergenceNumStepsEnum
Definition: EnumDefinitions.h:1286
Solverx
void Solverx(Vector< IssmDouble > **puf, Matrix< IssmDouble > *Kff, Vector< IssmDouble > *pf, Vector< IssmDouble > *uf0, Vector< IssmDouble > *df, Parameters *parameters)
Definition: Solverx.cpp:15
AllocateSystemMatricesx
void AllocateSystemMatricesx(Matrix< IssmDouble > **pKff, Matrix< IssmDouble > **pKfs, Vector< IssmDouble > **pdf, Vector< IssmDouble > **ppf, FemModel *femmodel)
Definition: AllocateSystemMatricesx.cpp:9
StressbalanceRiftPenaltyThresholdEnum
@ StressbalanceRiftPenaltyThresholdEnum
Definition: EnumDefinitions.h:413
StressbalanceMaxiterEnum
@ StressbalanceMaxiterEnum
Definition: EnumDefinitions.h:407
Loads::Copy
Loads * Copy()
Definition: Loads.cpp:42
Matrix::SetZero
void SetZero(void)
Definition: Matrix.h:312
FemModel::UpdateConstraintsx
void UpdateConstraintsx(void)
Definition: FemModel.cpp:3027
FemModel::nodes
Nodes * nodes
Definition: FemModel.h:56
StressbalanceAbstolEnum
@ StressbalanceAbstolEnum
Definition: EnumDefinitions.h:404
StressbalanceReltolEnum
@ StressbalanceReltolEnum
Definition: EnumDefinitions.h:410
ConfigurationTypeEnum
@ ConfigurationTypeEnum
Definition: EnumDefinitions.h:101
Results::AddResult
int AddResult(ExternalResult *result)
Definition: Results.cpp:33
InputUpdateFromConstantx
void InputUpdateFromConstantx(FemModel *femmodel, bool constant, int name)
Definition: InputUpdateFromConstantx.cpp:10
FemModel::loads
Loads * loads
Definition: FemModel.h:54
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
Loads::numrifts
int numrifts
Definition: Loads.h:20
GenericExternalResult
Definition: GenericExternalResult.h:21
Loads
Declaration of Loads class.
Definition: Loads.h:16
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
StressbalanceRestolEnum
@ StressbalanceRestolEnum
Definition: EnumDefinitions.h:412
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
FemModel::loads_list
Loads ** loads_list
Definition: FemModel.h:55
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 >
Vector::Set
void Set(doubletype value)
Definition: Vector.h:245
femmodel
FemModel * femmodel
Definition: esmfbinders.cpp:16