BISICLES AMR ice sheet model  0.9
PetscIceSolver.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3 * _______ __
4 * / ___/ / ___ __ _ / / ___
5 * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6 * \___/_//_/\___/_/_/_/_.__/\___/
7 * Please refer to Copyright.txt, in Chombo's root directory.
8 */
9 #endif
10 
11 #ifndef _PETSCICESOLVER_H_
12 #define _PETSCICESOLVER_H_
13 
14 #include "IceVelocitySolver.H"
15 #include "ViscousTensorOp.H"
16 #ifdef CH_USE_PETSC
17 #include "PetscSolver.H"
18 #endif
19 #include "Copier.H"
20 
21 
22 #include "NamespaceHeader.H"
23 
26 
30 {
31 
32 public:
33 
34  PetscIceSolver();
35 
36  virtual ~PetscIceSolver();
37 
38  virtual void define(const ProblemDomain& a_coarseDomain,
39  ConstitutiveRelation* a_constRel,
40  BasalFrictionRelation* a_basalFrictionRel,
41  const Vector<DisjointBoxLayout>& a_vectGrids,
42  const Vector<int>& a_vectRefRatio,
43  const RealVect& a_dxCrse,
44  IceThicknessIBC* a_bc,
45  int a_numLevels);
46 
47  void setSolverType(int a_solver_type)
48  {
49  pout() << "PetscIceSolver::setSolverType=" << a_solver_type << endl;
50  }
51 
52  void setTolerance(Real a_tolerance) {
53  m_rtol = a_tolerance;
54  }
55 
56  // set "absolute tolerance"
61  void setAbsoluteTolerance(Real a_tolerance){ m_atol = a_tolerance; }
62 
63  // sets maximum number of iterations
64  void setMaxIterations(int a_max_iter) { m_max_its = a_max_iter; }
65 
66  void setVerbosity(int a_verbosity) {m_verbosity = a_verbosity;}
67 
68  void computeAMRResidual( Vector<RefCountedPtr<LevelData<FArrayBox> > >& a_resid,
69  const Vector<LevelData<FArrayBox>* >& a_horizontalVel,
70  const Vector<LevelData<FArrayBox>* >& a_rhs,
71  int a_lbase, int a_maxLevel
72  );
73  void computeAMRResidualLevel( Vector<RefCountedPtr<LevelData<FArrayBox> > >& a_resid,
74  const Vector<LevelData<FArrayBox>* >& a_horizontalVel,
75  const Vector<LevelData<FArrayBox>* >& a_rhs,
76  int a_lbase, int a_maxLevel, int a_ilev
77  );
78 
79  // solve for isothermal ice -- returns 0 if converged, 1 if not
80  virtual int solve( Vector<LevelData<FArrayBox>* >& a_horizontalVel,
81  Vector<LevelData<FArrayBox>* >& a_calvedIce,
82  Vector<LevelData<FArrayBox>* >& a_addedIce,
83  Vector<LevelData<FArrayBox>* >& a_removedIce,
84  Real& a_initialResidualNorm, Real& a_finalResidualNorm,
85  const Real a_convergenceMetric,
86  const Vector<LevelData<FArrayBox>* >& a_rhs,
87  const Vector<LevelData<FArrayBox>* >& a_C,
88  const Vector<LevelData<FArrayBox>* >& a_C0,
89  const Vector<LevelData<FArrayBox>* >& a_A,
90  const Vector<LevelData<FArrayBox>* >& a_muCoef,
91  Vector<RefCountedPtr<LevelSigmaCS > >& a_coordSys,
92  Real a_time,
93  int a_lbase, int a_maxLevel);
94 
95  void picardSolve_private( int a_ilev,
96  LevelData<FArrayBox> &a_horizontalVel,
97  const LevelData<FArrayBox> &a_rhs,
98  Real a_norm0, Real &a_norm, int a_numIts, int &a_it );
99 
100  void jfnkSolve_private( int a_ilev,
101  LevelData<FArrayBox> &a_horizontalVel,
102  const LevelData<FArrayBox> &a_rhs,
103  Real a_norm0, int a_numIts, int &a_it );
104 
105  Vector<ProblemDomain> m_domains;
106  RefCountedPtr<ViscousTensorOpFactory> m_opFactoryPtr;
107  Vector<RefCountedPtr<ViscousTensorOp> > m_op;
108 protected:
111  Vector<DisjointBoxLayout> m_grids;
116 
118 
120  Real m_rtol;
121  Real m_atol;
125 
126  Vector<int> m_refRatios;
127 
128 protected:
129  // materials
130  Vector<RefCountedPtr<LevelData<FluxBox> > > m_Mu;
131  Vector<RefCountedPtr<LevelData<FluxBox> > > m_Lambda;
132  // beta is used to scale C below
133  Vector<const LevelData<FArrayBox> *> m_Beta;
134  Vector<const LevelData<FArrayBox> *> m_Beta0;
135  // C here is the sliding coefficient -- the "acoeff" in terms of the viscousTensorOp
136  Vector<RefCountedPtr<LevelData<FArrayBox> > > m_C;
137 
138  Real m_constThetaVal; // not used?
139 
141  void defineOpFactory(RealVect,const ProblemDomain &,int);
142 
144 
145  void getOperatorScaleFactors( Real& a_alpha, Real& a_beta ) const;
146 public:
147  // compute face-centered coefficients for tensor solver (really
148  // winds up being H*mu) -- non-isothermal version...
149  void computeMu( LevelData<FArrayBox> &a_horizontalVel,
150  const LevelData<FluxBox> &a_A,
151  const LevelData<FluxBox> &a_muCoef,
152  const RefCountedPtr<LevelSigmaCS> &a_coordSys,
153  LevelData<FArrayBox>* crseVelPtr,
154  LevelData<FArrayBox>* fineVelPtr,
155  int a_ilev,
156  Real a_time);
157  // abstract methods for (PETSc) nonlinear solvers
158  virtual void updateCoefs(LevelData<FArrayBox> &a_horizontalVel, int);
159 
160  // cache
161  RefCountedPtr<LevelData<FArrayBox> >m_twork1; // work vectors
162  RefCountedPtr<LevelData<FArrayBox> >m_twork2;
163  RefCountedPtr<LevelData<FluxBox> > m_tfaceA;
164  LevelData<FArrayBox>* m_tcrseVel;
165  LevelData<FArrayBox> *m_tphi0;
166  RefCountedPtr<LevelData<FluxBox> > m_tmuCoef;
167  RefCountedPtr<LevelSigmaCS> m_tcoordSys;
168  Real m_ttime;
169  // prolongation stuff
170  Vector<RefCountedPtr<LevelData<FArrayBox> > >m_fineCover;
171  Vector<Copier> m_restCopier;
172  Vector<Copier> m_projCopier;
173  void AMRProlong( LevelData<FArrayBox>& a_fineU,
174  const LevelData<FArrayBox>& a_CrsU,
175  LevelData<FArrayBox>& a_CrsCover,
176  Copier a_copier,
177  int a_refRatio );
178 
179 };
180 #include "NamespaceFooter.H"
181 #endif
int m_verbosity
Definition: PetscIceSolver.H:113
void setAbsoluteTolerance(Real a_tolerance)
Definition: PetscIceSolver.H:61
PetscIceSolver()
Definition: PetscIceSolver.cpp:31
virtual int solve(Vector< LevelData< FArrayBox > * > &a_horizontalVel, Vector< LevelData< FArrayBox > * > &a_calvedIce, Vector< LevelData< FArrayBox > * > &a_addedIce, Vector< LevelData< FArrayBox > * > &a_removedIce, Real &a_initialResidualNorm, Real &a_finalResidualNorm, const Real a_convergenceMetric, const Vector< LevelData< FArrayBox > * > &a_rhs, const Vector< LevelData< FArrayBox > * > &a_C, const Vector< LevelData< FArrayBox > * > &a_C0, const Vector< LevelData< FArrayBox > * > &a_A, const Vector< LevelData< FArrayBox > * > &a_muCoef, Vector< RefCountedPtr< LevelSigmaCS > > &a_coordSys, Real a_time, int a_lbase, int a_maxLevel)
solve for isothermal ice
Definition: PetscIceSolver.cpp:464
void setMaxIterations(int a_max_iter)
if relevant, set max number of solver iterations
Definition: PetscIceSolver.H:64
Vector< const LevelData< FArrayBox > * > m_Beta0
Definition: PetscIceSolver.H:134
void setSolverType(int a_solver_type)
Definition: PetscIceSolver.H:47
Abstract class to manage the nonlinear solve for the ice-sheet momentum.
Definition: IceVelocitySolver.H:32
Abstract class around the englacial constitutive relations for ice.
Definition: ConstitutiveRelation.H:34
Vector< Copier > m_restCopier
Definition: PetscIceSolver.H:171
void getOperatorScaleFactors(Real &a_alpha, Real &a_beta) const
get ViscousTensorOp scaling factors (alpha and beta)
Definition: PetscIceSolver.cpp:908
Vector< int > m_refRatios
Definition: PetscIceSolver.H:126
bool m_plotResidual
Definition: PetscIceSolver.H:124
Physical/domain initial and boundary conditions for ice-sheet problems.
Definition: IceThicknessIBC.H:84
virtual void define(const ProblemDomain &a_coarseDomain, ConstitutiveRelation *a_constRel, BasalFrictionRelation *a_basalFrictionRel, const Vector< DisjointBoxLayout > &a_vectGrids, const Vector< int > &a_vectRefRatio, const RealVect &a_dxCrse, IceThicknessIBC *a_bc, int a_numLevels)
(Re-)define IceVelocitySolver object for a given mesh and set of physics rules
Definition: PetscIceSolver.cpp:219
virtual ~PetscIceSolver()
Definition: PetscIceSolver.cpp:83
void setVerbosity(int a_verbosity)
Definition: PetscIceSolver.H:66
RefCountedPtr< LevelData< FArrayBox > > m_twork2
Definition: PetscIceSolver.H:162
IceThicknessIBC * m_bc
Definition: PetscIceSolver.H:117
Real m_atol
Definition: PetscIceSolver.H:121
virtual void updateCoefs(LevelData< FArrayBox > &a_horizontalVel, int)
Definition: PetscIceSolver.cpp:918
Vector< const LevelData< FArrayBox > * > m_Beta
Definition: PetscIceSolver.H:133
void picardSolve_private(int a_ilev, LevelData< FArrayBox > &a_horizontalVel, const LevelData< FArrayBox > &a_rhs, Real a_norm0, Real &a_norm, int a_numIts, int &a_it)
Definition: PetscIceSolver.cpp:387
bool m_isSolverDefined
Definition: PetscIceSolver.H:115
void defineOpFactory(RealVect, const ProblemDomain &, int)
define operator factory. In 2D, this is a ViscousTensorOp.
Definition: PetscIceSolver.cpp:862
BasalFrictionRelation * m_basalFrictionRelPtr
Definition: PetscIceSolver.H:110
void AMRProlong(LevelData< FArrayBox > &a_fineU, const LevelData< FArrayBox > &a_CrsU, LevelData< FArrayBox > &a_CrsCover, Copier a_copier, int a_refRatio)
Definition: PetscIceSolver.cpp:359
Vector< RefCountedPtr< LevelData< FluxBox > > > m_Lambda
Definition: PetscIceSolver.H:131
void computeAMRResidualLevel(Vector< RefCountedPtr< LevelData< FArrayBox > > > &a_resid, const Vector< LevelData< FArrayBox > * > &a_horizontalVel, const Vector< LevelData< FArrayBox > * > &a_rhs, int a_lbase, int a_maxLevel, int a_ilev)
Definition: PetscIceSolver.cpp:318
Vector< RefCountedPtr< LevelData< FArrayBox > > > m_C
Definition: PetscIceSolver.H:136
RefCountedPtr< ViscousTensorOpFactory > m_opFactoryPtr
Definition: PetscIceSolver.H:106
Real m_rtol
Definition: PetscIceSolver.H:120
Vector< RefCountedPtr< LevelData< FArrayBox > > > m_fineCover
Definition: PetscIceSolver.H:170
LevelData< FArrayBox > * m_tphi0
Definition: PetscIceSolver.H:165
Real m_constThetaVal
Definition: PetscIceSolver.H:138
Definition: PetscIceSolver.H:29
bool m_isOpDefined
Definition: PetscIceSolver.H:114
void computeAMRResidual(Vector< RefCountedPtr< LevelData< FArrayBox > > > &a_resid, const Vector< LevelData< FArrayBox > * > &a_horizontalVel, const Vector< LevelData< FArrayBox > * > &a_rhs, int a_lbase, int a_maxLevel)
Definition: PetscIceSolver.cpp:304
RefCountedPtr< LevelData< FluxBox > > m_tmuCoef
Definition: PetscIceSolver.H:166
Virtual base class for basal friction relations.
Definition: BasalFrictionRelation.H:27
RefCountedPtr< LevelSigmaCS > m_tcoordSys
Definition: PetscIceSolver.H:167
Real m_vtopSafety
Definition: PetscIceSolver.H:112
void jfnkSolve_private(int a_ilev, LevelData< FArrayBox > &a_horizontalVel, const LevelData< FArrayBox > &a_rhs, Real a_norm0, int a_numIts, int &a_it)
Definition: PetscIceSolver.cpp:430
void setTolerance(Real a_tolerance)
if relevant, set solver tolerance
Definition: PetscIceSolver.H:52
RefCountedPtr< LevelData< FluxBox > > m_tfaceA
Definition: PetscIceSolver.H:163
Vector< RefCountedPtr< LevelData< FluxBox > > > m_Mu
Definition: PetscIceSolver.H:130
Vector< DisjointBoxLayout > m_grids
Definition: PetscIceSolver.H:111
Real m_ttime
Definition: PetscIceSolver.H:168
Vector< RefCountedPtr< ViscousTensorOp > > m_op
Definition: PetscIceSolver.H:107
int m_amr_max_level
Definition: PetscIceSolver.H:123
void computeMu(LevelData< FArrayBox > &a_horizontalVel, const LevelData< FluxBox > &a_A, const LevelData< FluxBox > &a_muCoef, const RefCountedPtr< LevelSigmaCS > &a_coordSys, LevelData< FArrayBox > *crseVelPtr, LevelData< FArrayBox > *fineVelPtr, int a_ilev, Real a_time)
Definition: PetscIceSolver.cpp:937
Vector< Copier > m_projCopier
Definition: PetscIceSolver.H:172
RefCountedPtr< LevelData< FArrayBox > > m_twork1
Definition: PetscIceSolver.H:161
int m_minPicardIterations
Definition: PetscIceSolver.H:122
ConstitutiveRelation * m_constRelPtr
Definition: PetscIceSolver.H:109
int m_max_its
Definition: PetscIceSolver.H:119
LevelData< FArrayBox > * m_tcrseVel
Definition: PetscIceSolver.H:164
Vector< ProblemDomain > m_domains
Definition: PetscIceSolver.H:105