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 _GENAMRSOLVER_H_
00030 #define _GENAMRSOLVER_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 "Vector.H"
00041 #include "IntVectSet.H"
00042 #include "DisjointBoxLayout.H"
00043 #include "ProblemDomain.H"
00044
00045 #include "GenAMRLevelMGOp.H"
00046
00047 template <class T> class GenAMRLevelMG;
00048
00050
00057 template <class T> class GenAMRSolver
00058 {
00059 public:
00060 friend class GenAMRLevelMG<T>;
00062
00067 GenAMRSolver();
00068
00070
00074 GenAMRSolver(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 GenAMRLevelMGOp<T>* const a_opin,
00081 int a_ncomp = 1);
00082
00084
00088 GenAMRSolver(const Vector<DisjointBoxLayout>& a_gridsLevel,
00089 const Vector<ProblemDomain>& a_domainLevel,
00090 const Vector<Real>& a_dxLevel,
00091 const Vector<int>& a_refRatio,
00092 int a_numLevels,
00093 int a_lBase,
00094 const GenAMRLevelMGOp<T>* const a_opin,
00095 int a_ncomp = 1);
00096
00098 ~GenAMRSolver();
00099
00101
00104 bool isDefined() const;
00105
00107
00139 void define(const Vector<DisjointBoxLayout>& a_gridsLevel,
00140 const Vector<Box>& a_domainLevel,
00141 const Vector<Real>& a_dxLevel,
00142 const Vector<int>& a_refRatio,
00143 int a_numLevels,
00144 int a_lBase,
00145 const GenAMRLevelMGOp<T>* const a_opin,
00146 int a_ncomp = 1);
00147
00149
00181 void define(const Vector<DisjointBoxLayout>& a_gridsLevel,
00182 const Vector<ProblemDomain>& a_domainLevel,
00183 const Vector<Real>& a_dxLevel,
00184 const Vector<int>& a_refRatio,
00185 int a_numLevels,
00186 int a_lBase,
00187 const GenAMRLevelMGOp<T>* const a_opin,
00188 int a_ncomp = 1);
00189
00191
00195 void setNumSmoothUp(int a_numSmoothUp);
00196
00198
00202 void setNumSmoothDown(int a_numSmoothDown);
00203
00205
00208 void setTolerance(Real a_tolerance);
00209
00211
00217 void setOperatorTolerance(Real a_operatorTolerance);
00218
00220
00223 void setMaxIter(int a_maxIter);
00224
00226
00231
00232 void setMinIter(int a_minIter);
00233
00235
00240 void setNumVCyclesBottom(int a_numVCycleBottom);
00241
00243
00262 void solveAMR(Vector<T *>& a_phiLevel,
00263 const Vector<T *>& a_rhsLevel);
00264
00266
00283 void AMRVCycleMG(Vector<T *>& a_corrLevel,
00284 const Vector<T *>& a_residLevel);
00285
00287
00291 Vector<Real> computeResidualNorm(Vector<T *>& a_phiLevel,
00292 const Vector<T *>& a_rhsLevel,
00293 int a_normType);
00294
00296
00301 Vector<Real> computeResidualNorm(Vector<T *>& a_residLevel,
00302 Vector<T *>& a_phiLevel,
00303 const Vector<T *>& a_rhsLevel,
00304 int a_normType);
00305
00307
00310 void computeAMRResidual(Vector<T *>& a_phiLevel,
00311 const Vector<T *>& a_rhsLevel,
00312 T& a_res,
00313 int a_ilev);
00314
00316
00320 void applyAMROperator(Vector<T *>& a_phiLevel,
00321 T& a_LOfPhi,
00322 int a_ilev);
00323
00325
00330 void applyAMROperatorHphys(Vector<T *>& a_phiLevel,
00331 T& a_LOfPhi,
00332 int a_ilev);
00333
00335
00338 void setVerbose(bool a_verbose);
00339
00340 protected:
00341
00342 void setDefaultValues();
00343
00344 void clear();
00345
00346
00347 Real m_errorTolerance;
00348
00349
00350 Real m_tolerance;
00351
00352
00353 Real m_operatorTolerance;
00354
00355
00356 int m_numLevels;
00357
00358
00359 int m_finestLevel;
00360
00361
00362 Vector<int> m_refRatio;
00363
00364
00365 Vector<Real> m_dxLevel;
00366
00367
00368 Vector<DisjointBoxLayout> m_gridsLevel;
00369
00370
00371 Vector<ProblemDomain> m_domainLevel;
00372
00373
00374 int m_maxIter;
00375
00376
00377
00378 int m_minIter;
00379
00380
00381 int m_numSmoothUp;
00382
00383
00384 int m_numVCyclesBottom;
00385
00386
00387 int m_numSmoothDown;
00388
00389
00390 Vector<GenAMRLevelMG<T> *> m_amrmgLevel;
00391
00392 bool m_isDefined;
00393
00394 GenLevelSolver<T> m_levelSolver;
00395
00396 int m_lBase;
00397
00398 int m_ncomp;
00399
00400
00401 bool m_verbose;
00402
00403 private:
00404 GenAMRSolver<T>(const GenAMRSolver<T>&) {};
00405 void operator= (const GenAMRSolver<T>&) {};
00406 };
00407
00408 #include "GenAMRSolverImplem.H"
00409
00410 #endif