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 <cassert>
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;
00061
00063
00067 AMRSolver();
00068
00070
00073 AMRSolver(const Vector<DisjointBoxLayout>& a_gridsLevel,
00074 const Vector<Box>& a_domainLevel,
00075 const Vector<Real>& a_dxLevel,
00076 const Vector<int>& a_refRatio,
00077 int a_numLevels,
00078 int a_lBase,
00079 const LevelOp* const a_opin,
00080 int a_ncomp = 1,
00081 bool a_limitCoarsening = false);
00082
00084
00087 AMRSolver(const Vector<DisjointBoxLayout>& a_gridsLevel,
00088 const Vector<ProblemDomain>& a_domainLevel,
00089 const Vector<Real>& a_dxLevel,
00090 const Vector<int>& a_refRatio,
00091 int a_numLevels,
00092 int a_lBase,
00093 const LevelOp* const a_opin,
00094 int a_ncomp = 1,
00095 bool a_limitCoarsening = false);
00096
00098
00126 void define(const Vector<DisjointBoxLayout>& a_gridsLevel,
00127 const Vector<Box>& a_domainLevel,
00128 const Vector<Real>& a_dxLevel,
00129 const Vector<int>& a_refRatio,
00130 int a_numLevels,
00131 int a_lBase,
00132 const LevelOp* const a_opin,
00133 int a_ncomp=1,
00134 bool a_limitCoarsening = false);
00135
00137
00165 void
00166 define(const Vector<DisjointBoxLayout>& a_gridsLevel,
00167 const Vector<ProblemDomain>& a_domainLevel,
00168 const Vector<Real>& a_dxLevel,
00169 const Vector<int>& a_refRatio,
00170 int a_numLevels,
00171 int a_lBase,
00172 const LevelOp* const a_opin,
00173 int a_ncomp=1,
00174 bool a_limitCoarsening = false);
00175
00177 ~AMRSolver();
00178
00180 bool isDefined() const;
00181
00183 void setNumSmoothUp(int a_numSmoothUp);
00184
00186 void setNumSmoothDown(int a_numSmoothDown);
00187
00189 void setTolerance(Real a_tolerance);
00190
00192
00196 void setOperatorTolerance(Real a_operatorTolerance);
00197
00199 void setMaxIter(int a_maxIter);
00200
00202
00207
00208 void setMinIter(int a_minIter);
00209
00211
00216 void setNumVCyclesBottom(int a_numVCycleBottom);
00217
00219
00224 void setConvergenceMetric(Real a_metric, int a_comp);
00225
00226
00228
00247 void solveAMR(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00248 const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00249 bool a_initializePhiToZero = true);
00250
00252
00267 void AMRVCycleMG(Vector<LevelData<FArrayBox> *>& a_corrLevel,
00268 const Vector<LevelData<FArrayBox> *>& a_residLevel);
00269
00271
00274 Vector<Real> computeResidualNorm(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00275 const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00276 int a_normType);
00277
00279
00283 Vector<Real> computeResidualNorm(Vector<LevelData<FArrayBox> *>& a_residLevel,
00284 Vector<LevelData<FArrayBox> *>& a_phiLevel,
00285 const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00286 int a_normType);
00287
00289 void computeAMRResidual(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00290 const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00291 LevelData<FArrayBox>& a_res,
00292 int a_ilev);
00293
00295
00299 void applyAMROperator(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00300 LevelData<FArrayBox>& a_LofPhi,
00301 int a_ilev);
00302
00304
00309 void applyAMROperatorHphys(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00310 LevelData<FArrayBox>& a_LofPhi,
00311 int a_ilev);
00312
00314 void setVerbose(bool a_verbose);
00315
00316 protected:
00320 void setDefaultValues();
00321
00325 void clear();
00326
00332 Vector<Real> computeNorm(const Vector<LevelData<FArrayBox>* >& a_phiVect,
00333 int a_normType);
00334
00338 Real m_errorTolerance;
00339
00343 Real m_tolerance;
00344
00348 Vector<Real> m_convergenceMetrics;
00349
00350
00354 Real m_operatorTolerance;
00355
00359 int m_numLevels;
00360
00364 int m_finestLevel;
00365
00369 Vector<int> m_refRatio;
00370
00374 Vector<Real> m_dxLevel;
00375
00379 Vector<DisjointBoxLayout> m_gridsLevel;
00380
00384 Vector<ProblemDomain> m_domainLevel;
00385
00389 int m_maxIter;
00390
00395 int m_minIter;
00396
00400 int m_numSmoothUp;
00401
00405 int m_numVCyclesBottom;
00406
00410 int m_numSmoothDown;
00411
00415 Vector<AMRLevelMG*> m_amrmgLevel;
00416
00420 bool m_isDefined;
00421
00424 LevelSolver m_levelSolver;
00425
00428 int m_lBase;
00429
00432 int m_ncomp;
00433
00437 bool m_verbose;
00438
00439 private:
00440 AMRSolver(const AMRSolver&);
00441 AMRSolver& operator=(const AMRSolver&);
00442 };
00443
00444 #endif