00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _AMRSolver_H_
00030 #define _AMRSolver_H_
00031
00032 #include <cstdlib>
00033 #include <cmath>
00034 #include <iostream>
00035 #include <assert.h>
00036
00037 #include "REAL.H"
00038 #include "IntVect.H"
00039 #include "Box.H"
00040 #include "FArrayBox.H"
00041 #include "Vector.H"
00042 #include "IntVectSet.H"
00043 #include "DisjointBoxLayout.H"
00044 #include "LevelData.H"
00045 #include "AMRLevelMG.H"
00046 #include "LevelSolver.H"
00047 #include "ProblemDomain.H"
00048
00050
00057 class AMRSolver
00058 {
00059 public:
00060 friend class AMRLevelMG;
00062
00067 AMRSolver();
00068
00070
00074 AMRSolver(const Vector<DisjointBoxLayout>& a_gridsLevel,
00075 const Vector<Box>& a_domainLevel,
00076 const Vector<Real>& a_dxLevel,
00077 const Vector<int>& a_refRatio,
00078 int a_numLevels,
00079 int a_lBase,
00080 const LevelOp* const a_opin,
00081 int ncomp = 1);
00082
00083
00085
00089 AMRSolver(const Vector<DisjointBoxLayout>& a_gridsLevel,
00090 const Vector<ProblemDomain>& a_domainLevel,
00091 const Vector<Real>& a_dxLevel,
00092 const Vector<int>& a_refRatio,
00093 int a_numLevels,
00094 int a_lBase,
00095 const LevelOp* const a_opin,
00096 int ncomp = 1);
00097
00099
00133 void
00134 define(const Vector<DisjointBoxLayout>& a_gridsLevel,
00135 const Vector<Box>& a_domainLevel,
00136 const Vector<Real>& a_dxLevel,
00137 const Vector<int>& a_refRatio,
00138 int a_numLevels,
00139 int a_lBase,
00140 const LevelOp* const a_opin,
00141 int ncomp=1);
00142
00143
00145
00179 void
00180 define(const Vector<DisjointBoxLayout>& a_gridsLevel,
00181 const Vector<ProblemDomain>& a_domainLevel,
00182 const Vector<Real>& a_dxLevel,
00183 const Vector<int>& a_refRatio,
00184 int a_numLevels,
00185 int a_lBase,
00186 const LevelOp* const a_opin,
00187 int ncomp=1);
00188
00190 ~AMRSolver();
00191
00193
00196 bool isDefined() const;
00197
00199
00203 void setNumSmoothUp(int a_numSmoothUp);
00204
00206
00210 void setNumSmoothDown(int a_numSmoothDown);
00211
00213
00216 void setTolerance(Real a_tolerance);
00217
00218
00220
00226 void setOperatorTolerance(Real a_operatorTolerance);
00227
00229
00232 void setMaxIter(int a_maxIter);
00233
00235
00240
00241 void setMinIter(int a_minIter);
00242
00244
00249 void setNumVCyclesBottom(int a_numVCycleBottom);
00250
00252
00271 void solveAMR(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00272 const Vector<LevelData<FArrayBox> *>& a_rhsLevel);
00273
00275
00292 void AMRVCycleMG(Vector<LevelData<FArrayBox> *>& a_corrLevel,
00293 const Vector<LevelData<FArrayBox> *>& a_residLevel);
00294
00296
00300 Vector<Real> computeResidualNorm(
00301 Vector<LevelData<FArrayBox> *>& a_phiLevel,
00302 const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00303 int normNtype);
00304
00305
00307
00312 Vector<Real> computeResidualNorm(Vector<LevelData<FArrayBox> *>& a_residLevel,
00313 Vector<LevelData<FArrayBox> *>& a_phiLevel,
00314 const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00315 int normNtype);
00316
00318
00321 void computeAMRResidual(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00322 const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00323 LevelData<FArrayBox> & res,
00324 int ilev);
00325
00327
00331 void applyAMROperator(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00332 LevelData<FArrayBox>& a_LofPhi,
00333 int a_ilev);
00334
00335
00337
00342 void applyAMROperatorHphys(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00343 LevelData<FArrayBox>& a_LofPhi,
00344 int a_ilev);
00345
00347
00350 void setVerbose(bool a_verbose);
00351 protected:
00352
00353 void setDefaultValues();
00354
00355 void clear();
00356
00357
00358 Real m_errorTolerance;
00359
00360
00361 Real m_tolerance;
00362
00363
00364 Real m_operatorTolerance;
00365
00366
00367
00368 int m_numLevels;
00369
00370
00371 int m_finestLevel;
00372
00373
00374 Vector<int> m_refRatio;
00375
00376
00377 Vector<Real> m_dxLevel;
00378
00379
00380 Vector<DisjointBoxLayout> m_gridsLevel;
00381
00382
00383 Vector<ProblemDomain> m_domainLevel;
00384
00385
00386 int m_maxIter;
00387
00388
00389
00390 int m_minIter;
00391
00392
00393 int m_numSmoothUp;
00394
00395
00396 int m_numVCyclesBottom;
00397
00398
00399 int m_numSmoothDown;
00400
00401
00402 Vector<AMRLevelMG*> m_amrmgLevel;
00403
00404 bool m_isDefined;
00405
00406 LevelSolver m_levelSolver;
00407
00408 int m_lBase;
00409
00410 int m_ncomp;
00411
00412
00413 bool m_verbose;
00414
00415 private:
00416 AMRSolver(const AMRSolver&);
00417 AMRSolver& operator=(const AMRSolver&);
00418
00419
00420 };
00421 #endif
00422
00423