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
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #ifndef _AMRSOLVER_H_
00055 #define _AMRSOLVER_H_
00056
00057 #include <cstdlib>
00058 #include <cmath>
00059 #include <iostream>
00060 #include "SPACE.H"
00061
00062 #include "REAL.H"
00063 #include "IntVect.H"
00064 #include "Box.H"
00065 #include "FArrayBox.H"
00066 #include "Vector.H"
00067 #include "IntVectSet.H"
00068 #include "DisjointBoxLayout.H"
00069 #include "LevelData.H"
00070 #include "AMRLevelMG.H"
00071 #include "LevelSolver.H"
00072 #include "ProblemDomain.H"
00073
00075
00082 class AMRSolver
00083 {
00084 public:
00085 friend class AMRLevelMG;
00086
00088
00092 AMRSolver();
00093
00095
00098 AMRSolver(const Vector<DisjointBoxLayout>& a_gridsLevel,
00099 const Vector<Box>& a_domainLevel,
00100 const Vector<Real>& a_dxLevel,
00101 const Vector<int>& a_refRatio,
00102 int a_numLevels,
00103 int a_lBase,
00104 const LevelOp* const a_opin,
00105 int a_ncomp = 1,
00106 bool a_limitCoarsening = false);
00107
00109
00112 AMRSolver(const Vector<DisjointBoxLayout>& a_gridsLevel,
00113 const Vector<ProblemDomain>& a_domainLevel,
00114 const Vector<Real>& a_dxLevel,
00115 const Vector<int>& a_refRatio,
00116 int a_numLevels,
00117 int a_lBase,
00118 const LevelOp* const a_opin,
00119 int a_ncomp = 1,
00120 bool a_limitCoarsening = false);
00121
00123
00151 virtual void define(const Vector<DisjointBoxLayout>& a_gridsLevel,
00152 const Vector<Box>& a_domainLevel,
00153 const Vector<Real>& a_dxLevel,
00154 const Vector<int>& a_refRatio,
00155 int a_numLevels,
00156 int a_lBase,
00157 const LevelOp* const a_opin,
00158 int a_ncomp=1,
00159 bool a_limitCoarsening = false);
00160
00162
00190 virtual void
00191 define(const Vector<DisjointBoxLayout>& a_gridsLevel,
00192 const Vector<ProblemDomain>& a_domainLevel,
00193 const Vector<Real>& a_dxLevel,
00194 const Vector<int>& a_refRatio,
00195 int a_numLevels,
00196 int a_lBase,
00197 const LevelOp* const a_opin,
00198 int a_ncomp=1,
00199 bool a_limitCoarsening = false);
00200
00202 virtual ~AMRSolver();
00203
00205 bool isDefined() const;
00206
00208 void setNumSmoothUp(int a_numSmoothUp);
00209
00211 void setNumSmoothDown(int a_numSmoothDown);
00212
00214 void setTolerance(Real a_tolerance);
00215
00217
00221 void setOperatorTolerance(Real a_operatorTolerance);
00222
00224 void setMaxIter(int a_maxIter);
00225
00227
00232
00233 void setMinIter(int a_minIter);
00234
00236
00241 void setNumVCyclesBottom(int a_numVCycleBottom);
00242
00244
00249 void setConvergenceMetric(Real a_metric, int a_comp);
00250
00252 void setNormType(int a_normType);
00253
00255
00274 void solveAMR(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00275 const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00276 bool a_initializePhiToZero = true);
00277
00279
00294 virtual void AMRVCycleMG(Vector<LevelData<FArrayBox> *>& a_corrLevel,
00295 const Vector<LevelData<FArrayBox> *>& a_residLevel);
00296
00298
00301 Vector<Real> computeResidualNorm(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00302 const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00303 int a_normType);
00304
00306
00310 Vector<Real> computeResidualNorm(Vector<LevelData<FArrayBox> *>& a_residLevel,
00311 Vector<LevelData<FArrayBox> *>& a_phiLevel,
00312 const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00313 int a_normType);
00314
00316 void computeAMRResidual(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00317 const Vector<LevelData<FArrayBox> *>& a_rhsLevel,
00318 LevelData<FArrayBox>& a_res,
00319 int a_ilev);
00320
00322
00326 void applyAMROperator(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00327 LevelData<FArrayBox>& a_LofPhi,
00328 int a_ilev);
00329
00331
00336 void applyAMROperatorHphys(Vector<LevelData<FArrayBox> *>& a_phiLevel,
00337 LevelData<FArrayBox>& a_LofPhi,
00338 int a_ilev);
00339
00341 void setVerbose(bool a_verbose);
00342
00343 protected:
00347 virtual void setDefaultValues();
00348
00352 virtual void clear();
00353
00359 Vector<Real> computeNorm(const Vector<LevelData<FArrayBox>* >& a_phiVect,
00360 int a_normType);
00361
00362
00363 LevelData<FArrayBox>& getResid(int a_level);
00364
00365
00366 LevelData<FArrayBox>& getCorr(int a_level);
00367
00371 Real m_errorTolerance;
00372
00376 Real m_tolerance;
00377
00381 Vector<Real> m_convergenceMetrics;
00382
00386 Real m_operatorTolerance;
00387
00391 int m_numLevels;
00392
00396 int m_finestLevel;
00397
00401 Vector<int> m_refRatio;
00402
00406 Vector<Real> m_dxLevel;
00407
00411 Vector<DisjointBoxLayout> m_gridsLevel;
00412
00416 Vector<ProblemDomain> m_domainLevel;
00417
00421 int m_maxIter;
00422
00427 int m_minIter;
00428
00432 int m_numSmoothUp;
00433
00437 int m_numVCyclesBottom;
00438
00442 int m_numSmoothDown;
00443
00447 int m_normType;
00448
00452 Vector<AMRLevelMG*> m_amrmgLevel;
00453
00457 bool m_isDefined;
00458
00461 LevelSolver m_levelSolver;
00462
00465 int m_lBase;
00466
00469 int m_ncomp;
00470
00474 bool m_verbose;
00475
00476 private:
00477 AMRSolver(const AMRSolver&);
00478 AMRSolver& operator=(const AMRSolver&);
00479 };
00480
00481 #endif