11 #ifndef _JFNKSOLVER_H_ 12 #define _JFNKSOLVER_H_ 17 #include "AMRMultiGrid.H" 19 #include "ViscousTensorOp.H" 24 #include "NamespaceHeader.H" 53 Vector<LevelData<FArrayBox>*> m_fu;
54 Vector<LevelData<FArrayBox>*> m_uplushv;
59 Real m_err, m_umin;
bool m_hAdaptive;
61 Real finiteh(
const Vector<LevelData<FArrayBox>*>& a_v);
72 static int m_bottom_solver_type;
75 static int m_MG_solver_depth;
77 Vector<DisjointBoxLayout> m_grids;
78 Vector<int> m_refRatio;
79 Vector<ProblemDomain> m_domains;
80 Vector<RealVect> m_dxs;
86 bool m_writeResiduals;
87 static int m_residualID;
90 (
const Vector<LevelData<FArrayBox> *>& a_u,
91 const Vector<LevelData<FArrayBox> *>& a_residual);
100 if (m_uPerturbed != NULL)
106 for (
int lev = 0; lev < m_fu.size(); ++lev)
108 if (m_fu[lev] != NULL)
111 for (
int lev = 0; lev < m_uplushv.size(); ++lev)
113 if (m_uplushv[lev] != NULL)
114 delete m_uplushv[lev];
118 Vector<LevelData<FArrayBox>*>& a_u,
119 Real a_h, Real m_err, Real m_umin,
bool m_hAdaptive,
120 Vector<DisjointBoxLayout>& a_grids,
121 Vector<int>& a_refRatio,
122 Vector<ProblemDomain>& a_domains,
123 Vector<RealVect>& a_dxs,
131 virtual void setU(Vector<LevelData<FArrayBox>*>& a_u);
135 virtual void applyOp(Vector<LevelData<FArrayBox>*>& a_lhs,
136 const Vector<LevelData<FArrayBox>*>& a_v,
137 bool a_homogeneous =
false);
141 virtual void residual(Vector<LevelData<FArrayBox>*>& a_lhs,
142 const Vector<LevelData<FArrayBox>*>& a_v,
143 const Vector<LevelData<FArrayBox>*>& a_rhs,
144 bool a_homogeneous =
false);
146 virtual void outerResidual(Vector<LevelData<FArrayBox>*>& a_lhs,
147 const Vector<LevelData<FArrayBox>*>& a_u,
148 const Vector<LevelData<FArrayBox>*>& a_rhs,
149 bool a_homogeneous =
false);
152 virtual void outerLHS(Vector<LevelData<FArrayBox>*>& a_lhs,
153 const Vector<LevelData<FArrayBox>*>& a_u,
154 bool a_homogeneous =
false)
157 m_mlOp.applyOp(a_lhs, a_u, a_homogeneous);
163 virtual void preCond(Vector<LevelData<FArrayBox>*>& a_cor,
164 const Vector<LevelData<FArrayBox>*>& a_residual);
167 virtual void create(Vector<LevelData<FArrayBox>*>& a_lhs,
168 const Vector<LevelData<FArrayBox>*>& a_rhs)
170 m_mlOp.create(a_lhs , a_rhs);
173 virtual void clear(Vector<LevelData<FArrayBox>*>& a_lhs)
181 for (
int lev=0; lev<a_lhs.size(); lev++)
183 if (a_lhs[lev] != NULL)
191 virtual void assign(Vector<LevelData<FArrayBox>*>& a_lhs,
192 const Vector<LevelData<FArrayBox>*>& a_rhs)
194 m_mlOp.assign(a_lhs, a_rhs);
198 virtual Real
dotProduct(
const Vector<LevelData<FArrayBox>*>& a_1,
199 const Vector<LevelData<FArrayBox>*>& a_2)
201 return m_mlOp.dotProduct(a_1,a_2);
204 virtual void incr(Vector<LevelData<FArrayBox>*>& a_lhs,
205 const Vector<LevelData<FArrayBox>*>& a_x,
208 m_mlOp.incr(a_lhs, a_x, a_scale);
212 virtual void axby(Vector<LevelData<FArrayBox>*>& a_lhs,
213 const Vector<LevelData<FArrayBox>*>& a_x,
214 const Vector<LevelData<FArrayBox>*>& a_y,
218 m_mlOp.axby(a_lhs, a_x, a_y, a_a, a_b);
221 virtual void scale(Vector<LevelData<FArrayBox>*>& a_lhs,
224 m_mlOp.scale(a_lhs , a_scale);
227 virtual Real
norm(
const Vector<LevelData<FArrayBox>*>& a_rhs,
230 return m_mlOp.norm(a_rhs, a_ord);
233 virtual void setToZero(Vector<LevelData<FArrayBox>*>& a_lhs)
235 m_mlOp.setToZero(a_lhs);
289 void parse(
const char* a_prefix =
"JFNKSolver");
386 m_config.
parse(a_prefix);
403 Vector<ProblemDomain> m_domains;
405 Vector<DisjointBoxLayout> m_grids;
407 Vector<RealVect> m_dxs;
409 Vector<int> m_refRatios;
424 LinearSolver<Vector<LevelData<FArrayBox>* > >* newLinearSolver(
LinearizedVTOp& a_op,
429 Real lineSearch(Vector<LevelData<FArrayBox>* >& a_u,
430 Vector<LevelData<FArrayBox>* >& a_residual,
431 const Vector<LevelData<FArrayBox>* >& a_rhs,
432 const Vector<LevelData<FArrayBox>* >& a_du,
440 Vector<LevelData<FArrayBox>* >& a_u,
441 const Vector<LevelData<FArrayBox>* >& a_rhs,
446 Vector<LevelData<FArrayBox>* >& a_calvedIce,
447 Vector<LevelData<FArrayBox>* >& a_addedIce,
448 Vector<LevelData<FArrayBox>* >& a_removedIce,
449 Vector<LevelData<FArrayBox>* >& a_rhs,
450 Vector<RefCountedPtr<LevelSigmaCS > >& a_coordSys,
454 Real m_convergenceMetric;
460 if (m_petscSolver)
delete m_petscSolver;
466 : m_petscSolver(NULL)
473 virtual void define(
const ProblemDomain& a_coarseDomain,
476 const Vector<DisjointBoxLayout>& a_vectGrids,
477 const Vector<int>& a_vectRefRatio,
478 const RealVect& a_dxCrse,
484 virtual int solve(Vector<LevelData<FArrayBox>* >& a_horizontalVel,
485 Vector<LevelData<FArrayBox>* >& a_calvedIce,
486 Vector<LevelData<FArrayBox>* >& a_addedIce,
487 Vector<LevelData<FArrayBox>* >& a_removedIce,
488 Real& a_initialResidualNorm, Real& a_finalResidualNorm,
489 const Real a_convergenceMetric,
490 const Vector<LevelData<FArrayBox>* >& a_rhs,
491 const Vector<LevelData<FArrayBox>* >& a_C,
492 const Vector<LevelData<FArrayBox>* >& a_C0,
493 const Vector<LevelData<FArrayBox>* >& a_A,
494 const Vector<LevelData<FArrayBox>* >& a_muCoef,
495 Vector<RefCountedPtr<LevelSigmaCS > >& a_coordSys,
497 int a_lbase,
int a_maxLevel) ;
509 virtual int solve(Vector<LevelData<FArrayBox>* >& a_horizontalVel,
510 Vector<LevelData<FArrayBox>* >& a_calvedIce,
511 Vector<LevelData<FArrayBox>* >& a_addedIce,
512 Vector<LevelData<FArrayBox>* >& a_removedIce,
513 Real& a_initialResidualNorm, Real& a_finalResidualNorm,
514 const Real a_convergenceMetric,
516 const Vector<LevelData<FArrayBox>* >& a_rhs,
517 const Vector<LevelData<FArrayBox>* >& a_C,
518 const Vector<LevelData<FArrayBox>* >& a_C0,
519 const Vector<LevelData<FArrayBox>* >& a_A,
520 const Vector<LevelData<FArrayBox>* >& a_muCoef,
521 Vector<RefCountedPtr<LevelSigmaCS > >& a_coordSys,
523 int a_lbase,
int a_maxLevel);
530 void imposeMaxAbs(Vector<LevelData<FArrayBox>*>& a_u,
541 #include "NamespaceFooter.H" Real m_err
parameters that appears in the adaptive calculation of h
Definition: JFNKSolver.H:334
Real m_relTol
relative tolerance for convergence test;
Definition: JFNKSolver.H:298
virtual void scale(Vector< LevelData< FArrayBox > *> &a_lhs, const Real &a_scale)
Definition: JFNKSolver.H:221
Real m_eliminateRemoteIceTol
how thin is thin ice?
Definition: JFNKSolver.H:358
Implement NonlinearViscousTensor for typical (velocity-depenendent) ice rheology. ...
Definition: NonlinearViscousTensor.H:105
int m_maxRelaxIter
maximum number of Relax iterations
Definition: JFNKSolver.H:314
virtual ~LinearizedVTOp()
Definition: JFNKSolver.H:97
Real m_vtopRelaxTol
relax tolerance for viscous tensor op
Definition: JFNKSolver.H:324
Real m_scale
Definition: JFNKSolver.H:368
bool m_writeResiduals
write out residual data frequently: useful for working out why solves fail
Definition: JFNKSolver.H:350
Real m_RelaxRelTol
Relax solver relative tolerance.
Definition: JFNKSolver.H:312
int m_vtopRelaxMinIter
minimum number of smnooths in viscous tensor op mg relax
Definition: JFNKSolver.H:326
virtual void setU(Vector< LevelData< FArrayBox > *> &a_u)
Definition: JFNKSolver.cpp:146
virtual Real norm(const Vector< LevelData< FArrayBox > *> &a_rhs, int a_ord)
Definition: JFNKSolver.H:227
Abstract class to manage the nonlinear solve for the ice-sheet momentum.
Definition: IceVelocitySolver.H:32
Real m_artificialDragPower
Definition: JFNKSolver.H:374
virtual void clearStorage(Vector< LevelData< FArrayBox > * > &a_lhs)
Definition: JFNKSolver.H:179
Abstract class around the englacial constitutive relations for ice.
Definition: ConstitutiveRelation.H:34
virtual ~JFNKSolver()
Definition: JFNKSolver.H:458
Real m_muMax
largest effective viscosity in ice-covered regions
Definition: JFNKSolver.H:364
bool m_hAdaptive
Use adaptive calculation of h?
Definition: JFNKSolver.H:338
Jacobian-Free Newton Krylov (JFNK) solver for the nonlinear ice-sheet/shelf momentum equations...
Definition: JFNKSolver.H:274
int m_maxGMRESIter
maximum number of GMRES iterations
Definition: JFNKSolver.H:310
LinearizedVTOp(NonlinearViscousTensor *a_currentState, Vector< LevelData< FArrayBox > *> &a_u, Real a_h, Real m_err, Real m_umin, bool m_hAdaptive, Vector< DisjointBoxLayout > &a_grids, Vector< int > &a_refRatio, Vector< ProblemDomain > &a_domains, Vector< RealVect > &a_dxs, int a_lBase, int a_numMGSmooth, int a_numMGIter, LinearizationMode a_mode)
Definition: JFNKSolver.cpp:54
int m_normType
type of norm to test convergence against
Definition: JFNKSolver.H:318
virtual void applyOp(Vector< LevelData< FArrayBox > *> &a_lhs, const Vector< LevelData< FArrayBox > *> &a_v, bool a_homogeneous=false)
Definition: JFNKSolver.cpp:184
Real m_BiCGStabRelTol
BiCGstab solver relative tolerance.
Definition: JFNKSolver.H:300
friend class JFNKSolver
Definition: JFNKSolver.H:45
Real m_vtopSafety
safety number for viscous tensor op
Definition: JFNKSolver.H:322
Physical/domain initial and boundary conditions for ice-sheet problems.
Definition: IceThicknessIBC.H:84
virtual void create(Vector< LevelData< FArrayBox > *> &a_lhs, const Vector< LevelData< FArrayBox > *> &a_rhs)
Definition: JFNKSolver.H:167
const Configuration & configuration()
allow read access to configuration entries
Definition: JFNKSolver.H:390
Real m_absTol
absolute tolerance for convergence test;
Definition: JFNKSolver.H:296
virtual void residual(Vector< LevelData< FArrayBox > *> &a_lhs, const Vector< LevelData< FArrayBox > *> &a_v, const Vector< LevelData< FArrayBox > *> &a_rhs, bool a_homogeneous=false)
Definition: JFNKSolver.cpp:127
Definition: JFNKSolver.H:43
void parse(const char *a_prefix="JFNKSolver")
Definition: JFNKSolver.cpp:358
Definition: JFNKSolver.H:27
void parseConfiguration(const char *a_prefix)
allows the usual configuration ("JFNKSolver.*") to be over-ridden
Definition: JFNKSolver.H:384
virtual void assign(Vector< LevelData< FArrayBox > *> &a_lhs, const Vector< LevelData< FArrayBox > *> &a_rhs)
Definition: JFNKSolver.H:191
Real m_muMin
smallest effective viscosity in ice-covered regions
Definition: JFNKSolver.H:362
virtual void axby(Vector< LevelData< FArrayBox > *> &a_lhs, const Vector< LevelData< FArrayBox > *> &a_x, const Vector< LevelData< FArrayBox > *> &a_y, Real a_a, Real a_b)
Definition: JFNKSolver.H:212
int m_numMGSmooth
(maximum) number of smooths in mg relax
Definition: JFNKSolver.H:328
NonlinearViscousTensor & current() const
Definition: JFNKSolver.H:95
bool m_eliminateFastIceEdgeOnly
throw away fast ice only ice/no ice boundaries
Definition: JFNKSolver.H:356
Definition: JFNKSolver.H:283
Real m_switchRate
rate at which to switch from Picard to JFNK mode
Definition: JFNKSolver.H:340
virtual Real dotProduct(const Vector< LevelData< FArrayBox > *> &a_1, const Vector< LevelData< FArrayBox > *> &a_2)
Definition: JFNKSolver.H:198
Definition: PetscAMRSolver.H:26
int m_verbosity
verbosity
Definition: JFNKSolver.H:320
Definition: JFNKSolver.H:27
Real m_eliminateFastIceSpeed
how fast is fast?
Definition: JFNKSolver.H:354
virtual void outerResidual(Vector< LevelData< FArrayBox > *> &a_lhs, const Vector< LevelData< FArrayBox > *> &a_u, const Vector< LevelData< FArrayBox > *> &a_rhs, bool a_homogeneous=false)
Definition: JFNKSolver.cpp:111
int eliminateFastIce(Vector< RefCountedPtr< LevelSigmaCS > > &a_coordSys, Vector< LevelData< FArrayBox > * > &a_vel, Vector< LevelData< FArrayBox > * > &a_calvedIce, Vector< LevelData< FArrayBox > * > &a_addedIce, Vector< LevelData< FArrayBox > * > &a_removedIce, const Vector< DisjointBoxLayout > &a_grids, const Vector< ProblemDomain > &a_domain, const Vector< int > &a_refRatio, Real a_crseDx, int a_finestLevel, int a_maxIter, Real a_thinIceTol, Real a_fastIceTol, bool a_edgeOnly, int a_verbosity=0)
Identify regions of fast ice and eliminate them. return the total number of cells eliminated...
Definition: IceUtility.cpp:776
LinearizationMode
Definition: JFNKSolver.H:27
Definition: JFNKSolver.H:27
Virtual base class for basal friction relations.
Definition: BasalFrictionRelation.H:27
bool m_eliminateFastIce
throw away fast ice at the end of each iteration?
Definition: JFNKSolver.H:352
Real m_eliminateRemoteIceMaxIter
limit the number of iterations in eliminate remote ice
Definition: JFNKSolver.H:360
virtual void setToZero(Vector< LevelData< FArrayBox > *> &a_lhs)
Definition: JFNKSolver.H:233
Definition: NonlinearViscousTensor.H:33
Real m_GMRESRelTol
GMRES solver relative tolerance.
Definition: JFNKSolver.H:308
Real m_RelaxHang
hang parameter for RelaxSolver;
Definition: JFNKSolver.H:316
int m_maxIter
maximum number of Newton steps;
Definition: JFNKSolver.H:294
LinearSolverType m_linearSolverType
type of linear solver
Definition: JFNKSolver.H:292
virtual void outerLHS(Vector< LevelData< FArrayBox > *> &a_lhs, const Vector< LevelData< FArrayBox > *> &a_u, bool a_homogeneous=false)
Definition: JFNKSolver.H:152
Real m_h
size of finite differenc
Definition: JFNKSolver.H:332
bool m_residualOnly
Definition: JFNKSolver.H:366
Definition: JFNKSolver.H:278
Real m_minStepFactor
smallest acceptable factor to try when reducing the newton step length
Definition: JFNKSolver.H:348
Real m_CGRelTol
CG solver relative tolerance.
Definition: JFNKSolver.H:304
Definition: MultilevelIceVelOp.H:38
virtual void clear(Vector< LevelData< FArrayBox > *> &a_lhs)
Definition: JFNKSolver.H:173
Configuration & get_evil_configuration()
allow write access to configuration entries
Definition: JFNKSolver.H:396
virtual void incr(Vector< LevelData< FArrayBox > *> &a_lhs, const Vector< LevelData< FArrayBox > *> &a_x, Real a_scale)
Definition: JFNKSolver.H:204
int m_numMGIter
number of MG v-cycles per BiCGStab iteration
Definition: JFNKSolver.H:330
LinearSolverType
Definition: JFNKSolver.H:283
virtual void preCond(Vector< LevelData< FArrayBox > *> &a_cor, const Vector< LevelData< FArrayBox > *> &a_residual)
Definition: JFNKSolver.cpp:283
int m_maxCGIter
maximum number of CG iterations
Definition: JFNKSolver.H:306
int m_maxBiCGStabIter
maximum number of BiCGStab iterations
Definition: JFNKSolver.H:302
int m_minPicardIter
minumum number of Picard Iterations before switching to JFNK
Definition: JFNKSolver.H:346
Real m_umin
parameter that appears in the adaptive calculation of h
Definition: JFNKSolver.H:336