00001 #ifndef _MULTIGRID_H_
00002 #define _MULTIGRID_H_
00003
00004 #include <memory>
00005
00006 #include "RectMDArray.H"
00007 #include "LevelData.H"
00008 #include "BLIterator.H"
00009 #include "CH_Timer.H"
00010 #include "Stencil.H"
00011 #include "MultigridStencils.H"
00012
00013
00014 class Multigrid
00015 {
00016 public:
00017
00018 Multigrid();
00019
00020 Multigrid(
00021 const BoxLayout& a_bl,
00022 double a_dx,
00023 int a_level
00024 );
00025 void define(
00026 const BoxLayout& a_bl,
00027 double a_dx,
00028 int a_level
00029 );
00030
00031 ~Multigrid();
00032
00033 void residual(
00034 LevelData<double >& a_res,
00035 LevelData<double >& a_phi,
00036 const LevelData<double >& a_rhs
00037 );
00038
00039 double resnorm(
00040 LevelData<double >& a_phi,
00041 const LevelData<double >& a_rhs
00042 );
00043
00044 void pointRelax(
00045 LevelData<double >& a_phi,
00046 const LevelData<double >& a_rhs,
00047 int a_numIter
00048 );
00049
00050 void avgDown(
00051 LevelData<double >& a_resc,
00052 const LevelData<double >& a_res
00053 );
00054
00055 void fineInterp(
00056 LevelData<double >& a_phiFine,
00057 const LevelData<double >& a_deltaCoarse
00058 );
00059
00060 void vCycle(
00061 LevelData<double >& a_phi,
00062 const LevelData<double >& a_rhs
00063 );
00064 private:
00065 LevelData<double > m_res;
00066 LevelData<double > m_rescReAligned;
00067 LevelData<double > m_deltaReAligned;
00068 LevelData<double > m_resc;
00069 LevelData<double > m_delta;
00070 BoxLayout m_bl;
00071 Multigrid* m_coarsePtr;
00072 double m_dx;
00073 int m_level;
00074 int m_preRelax = 2*DIM;
00075 int m_postRelax = 2*DIM;
00076 int m_bottomRelax = 20;
00077 long long m_flops = 0;
00078 bool m_isAligned;
00079 };
00080 #endif