/** * @file multigrid.hpp * @author Julian Iseringhausen * @date Mon Apr 18 12:54:51 2011 * * @brief VMG::Multigrid * */ #ifndef MULTIGRID_HPP_ #define MULTIGRID_HPP_ #include #include "grid/grid_indexing.hpp" namespace VMG { class Comm; class Grid; class Index; class Interface; class Multigrid : public Object { public: Multigrid(Comm* comm, const Interface* interface); virtual ~Multigrid(); Grid& operator()() {return *grids[levelIndex];} Grid& operator()(const int& level) {return *grids[levelMax-level];} const Grid& operator()() const {return *grids[levelIndex];} const Grid& operator()(const int& level) const {return *grids[levelMax-level];} const int& Level() const {return levelCurrent;} ///< Current level int LevelIndex() const {return levelMax-levelCurrent;} ///< Index of current level const int& GlobalMaxLevel() const {return levelGlobalMax;} const int& MaxLevel() const {return levelMax;} ///< Maximum level const int& MinLevel() const {return levelMin;} ///< Minimum level const int& NumLevels() const {return numLevels;} ///< Number of levels void SetLevel(int level); void ToCoarserLevel(); ///< Switch to next coarser level if possible void ToFinerLevel(); ///< Switch to next finer level if possible void ClearAll(); ///< Overwrites all grid points with zeros void ClearAllCoarseLevels(); ///< Overwrites all grid points on all levels except the finest one with zeros void SetCoarserDirichletValues(); protected: std::vector grids; int levelGlobalMax, levelMin, levelMax; int levelIndex, levelCurrent; int numLevels; private: LocalIndices InitDirichlet(const GlobalIndices& global, const SpatialExtent& extent, const Index& pos, const Index& procs); LocalIndices InitPeriodic(const GlobalIndices& global, const SpatialExtent& extent, const Index& pos, const Index& procs); }; } #endif /* MULTIGRID_HPP_ */