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
00243 void setNumVCyclesBottom(int a_numVCycleBottom);
00244
00246
00265 void solveAMR(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00266 const Vector<LevelData<FArrayBox> *>& a_rhsLevel);
00267
00269
00286 void AMRVCycleMG(Vector<LevelData<FArrayBox> *>& a_corrLevel,
00287 const Vector<LevelData<FArrayBox> *>& a_residLevel);
00288
00290
00294 Vector<Real> computeResidualNorm(
00295 Vector<LevelData<FArrayBox> *>& a_phiLevel,
00296 const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00297 int normNtype);
00298
00299
00301
00306 Vector<Real> computeResidualNorm(Vector<LevelData<FArrayBox> *>& a_residLevel,
00307 Vector<LevelData<FArrayBox> *>& a_phiLevel,
00308 const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00309 int normNtype);
00310
00312
00315 void computeAMRResidual(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00316 const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00317 LevelData<FArrayBox> & res,
00318 int ilev);
00319
00321
00325 void applyAMROperator(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00326 LevelData<FArrayBox>& a_LofPhi,
00327 int a_ilev);
00328
00329
00331
00336 void applyAMROperatorHphys(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00337 LevelData<FArrayBox>& a_LofPhi,
00338 int a_ilev);
00339
00341
00344 void setVerbose(bool a_verbose);
00345 protected:
00346
00347 void setDefaultValues();
00348
00349 void clear();
00350
00351
00352 Real m_errorTolerance;
00353
00354
00355 Real m_tolerance;
00356
00357
00358 Real m_operatorTolerance;
00359
00360
00361
00362 int m_numLevels;
00363
00364
00365 int m_finestLevel;
00366
00367
00368 Vector<int> m_refRatio;
00369
00370
00371 Vector<Real> m_dxLevel;
00372
00373
00374 Vector<DisjointBoxLayout> m_gridsLevel;
00375
00376
00377 Vector<ProblemDomain> m_domainLevel;
00378
00379
00380 int m_maxIter;
00381
00382
00383
00384 int m_minIter;
00385
00386
00387 int m_numSmoothUp;
00388
00389
00390 int m_numVCyclesBottom;
00391
00392
00393 int m_numSmoothDown;
00394
00395
00396 Vector<AMRLevelMG*> m_amrmgLevel;
00397
00398 bool m_isDefined;
00399
00400 LevelSolver m_levelSolver;
00401
00402 int m_lBase;
00403
00404 int m_ncomp;
00405
00406
00407 bool m_verbose;
00408
00409 private:
00410 AMRSolver(const AMRSolver&);
00411 AMRSolver& operator=(const AMRSolver&);
00412
00413
00414 };
00415 #endif
00416
00417