Ice Sheet System Model  4.18
Code documentation
Functions
solutionsequence_newton.cpp File Reference
#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_newton (FemModel *femmodel)
 

Function Documentation

◆ solutionsequence_newton()

void solutionsequence_newton ( FemModel femmodel)

Definition at line 11 of file solutionsequence_newton.cpp.

11  {
12 
13  /*intermediary: */
14  bool converged;
15  int count,newton;
16  IssmDouble kmax;
17  Matrix<IssmDouble>* Kff = NULL;
18  Matrix<IssmDouble>* Kfs = NULL;
19  Matrix<IssmDouble>* Jff = NULL;
20  Vector<IssmDouble>* ug = NULL;
21  Vector<IssmDouble>* old_ug = NULL;
22  Vector<IssmDouble>* uf = NULL;
23  Vector<IssmDouble>* old_uf = NULL;
24  Vector<IssmDouble>* duf = NULL;
25  Vector<IssmDouble>* pf = NULL;
26  Vector<IssmDouble>* pJf = NULL;
27  Vector<IssmDouble>* df = NULL;
28  Vector<IssmDouble>* ys = NULL;
29 
30  /*parameters:*/
31  int max_nonlinear_iterations;
32  IssmDouble eps_res,eps_rel,eps_abs;
33 
34  /*Recover parameters: */
35  femmodel->parameters->FindParam(&max_nonlinear_iterations,StressbalanceMaxiterEnum);
41 
42  count=1;
43  converged=false;
44 
45  /*Start non-linear iteration using input velocity: */
48 
49  //Update once again the solution to make sure that vx and vxold are similar (for next step in transient or steadystate)
52 
53  for(;;){
54 
55  delete old_ug;old_ug=ug;
56  delete old_uf;old_uf=uf;
57 
58  /*Solver forward model*/
59  if(count==1 || newton==2){
60  SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel);
62  Reduceloadx(pf,Kfs,ys);delete Kfs;
64  Solverx(&uf,Kff,pf,old_uf,df,femmodel->parameters);delete df; delete Kff; delete pf;
68  delete old_ug;old_ug=ug;
69  delete old_uf;old_uf=uf;
70  }
71  uf=old_uf->Duplicate(); old_uf->Copy(uf);
72 
73  /*Prepare next iteration using Newton's method*/
74  SystemMatricesx(&Kff,&Kfs,&pf,&df,&kmax,femmodel);delete df;
76  Reduceloadx(pf,Kfs,ys);delete Kfs;
77 
78  pJf=pf->Duplicate();
79  Kff->MatMult(uf,pJf);
80  pJf->Scale(-1.0); pJf->AXPY(pf,+1.0);
81 
84  Solverx(&duf,Jff,pJf,NULL,NULL,femmodel->parameters); delete Jff; delete pJf;
86  uf->AXPY(duf, 1.0); delete duf;
89 
90  /*Check convergence*/
91  convergence(&converged,Kff,pf,uf,old_uf,eps_res,eps_rel,eps_abs);
92  delete Kff; delete pf;
93  if(converged==true){
94  break;
95  }
96  if(count>=max_nonlinear_iterations){
97  _printf0_(" maximum number of Newton iterations (" << max_nonlinear_iterations << ") exceeded\n");
98  break;
99  }
100 
101  count++;
102  }
103 
104  if(VerboseConvergence()) _printf0_("\n total number of iterations: " << count-1 << "\n");
105 
106  /*clean-up*/
107  delete uf;
108  delete ug;
109  delete old_ug;
110  delete old_uf;
111 }
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
_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
Solverx
void Solverx(Vector< IssmDouble > **puf, Matrix< IssmDouble > *Kff, Vector< IssmDouble > *pf, Vector< IssmDouble > *uf0, Vector< IssmDouble > *df, Parameters *parameters)
Definition: Solverx.cpp:15
Vector::Duplicate
Vector< doubletype > * Duplicate(void)
Definition: Vector.h:230
Matrix::MatMult
void MatMult(Vector< doubletype > *X, Vector< doubletype > *AX)
Definition: Matrix.h:239
StressbalanceMaxiterEnum
@ StressbalanceMaxiterEnum
Definition: EnumDefinitions.h:407
Vector::Scale
void Scale(doubletype scale_factor)
Definition: Vector.h:355
StressbalanceIsnewtonEnum
@ StressbalanceIsnewtonEnum
Definition: EnumDefinitions.h:406
Vector::AXPY
void AXPY(Vector *X, doubletype a)
Definition: Vector.h:256
FemModel::UpdateConstraintsx
void UpdateConstraintsx(void)
Definition: FemModel.cpp:3027
FemModel::nodes
Nodes * nodes
Definition: FemModel.h:56
StressbalanceAbstolEnum
@ StressbalanceAbstolEnum
Definition: EnumDefinitions.h:404
CreateJacobianMatrixx
void CreateJacobianMatrixx(Matrix< IssmDouble > **pJff, FemModel *femmodel, IssmDouble kmax)
Definition: CreateJacobianMatrixx.cpp:10
StressbalanceReltolEnum
@ StressbalanceReltolEnum
Definition: EnumDefinitions.h:410
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
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
Vector::Copy
void Copy(Vector *to)
Definition: Vector.h:319
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 >
femmodel
FemModel * femmodel
Definition: esmfbinders.cpp:16