| 1 | /**
|
|---|
| 2 | * @file multigrid.hpp
|
|---|
| 3 | * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
|
|---|
| 4 | * @date Mon Apr 18 12:54:51 2011
|
|---|
| 5 | *
|
|---|
| 6 | * @brief VMG::Multigrid
|
|---|
| 7 | *
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | #ifndef MULTIGRID_HPP_
|
|---|
| 11 | #define MULTIGRID_HPP_
|
|---|
| 12 |
|
|---|
| 13 | #include <vector>
|
|---|
| 14 |
|
|---|
| 15 | #include "grid/grid_indexing.hpp"
|
|---|
| 16 |
|
|---|
| 17 | namespace VMG
|
|---|
| 18 | {
|
|---|
| 19 |
|
|---|
| 20 | class Comm;
|
|---|
| 21 | class Grid;
|
|---|
| 22 | class Index;
|
|---|
| 23 | class Interface;
|
|---|
| 24 |
|
|---|
| 25 | class Multigrid : public Object
|
|---|
| 26 | {
|
|---|
| 27 | public:
|
|---|
| 28 | Multigrid(Comm* comm, const Interface* interface);
|
|---|
| 29 |
|
|---|
| 30 | virtual ~Multigrid();
|
|---|
| 31 |
|
|---|
| 32 | Grid& operator()() {return *grids[levelIndex];}
|
|---|
| 33 | Grid& operator()(const int& level) {return *grids[levelMax-level];}
|
|---|
| 34 |
|
|---|
| 35 | const Grid& operator()() const {return *grids[levelIndex];}
|
|---|
| 36 | const Grid& operator()(const int& level) const {return *grids[levelMax-level];}
|
|---|
| 37 |
|
|---|
| 38 | const int& Level() const {return levelCurrent;} ///< Current level
|
|---|
| 39 | int LevelIndex() const {return levelMax-levelCurrent;} ///< Index of current level
|
|---|
| 40 |
|
|---|
| 41 | const int& GlobalMaxLevel() const {return levelGlobalMax;}
|
|---|
| 42 | const int& MaxLevel() const {return levelMax;} ///< Maximum level
|
|---|
| 43 | const int& MinLevel() const {return levelMin;} ///< Minimum level
|
|---|
| 44 | const int& NumLevels() const {return numLevels;} ///< Number of levels
|
|---|
| 45 |
|
|---|
| 46 | void SetLevel(int level);
|
|---|
| 47 |
|
|---|
| 48 | void ToCoarserLevel(); ///< Switch to next coarser level if possible
|
|---|
| 49 | void ToFinerLevel(); ///< Switch to next finer level if possible
|
|---|
| 50 |
|
|---|
| 51 | void ClearAll(); ///< Overwrites all grid points with zeros
|
|---|
| 52 | void ClearAllCoarseLevels(); ///< Overwrites all grid points on all levels except the finest one with zeros
|
|---|
| 53 |
|
|---|
| 54 | void SetCoarserDirichletValues();
|
|---|
| 55 |
|
|---|
| 56 | protected:
|
|---|
| 57 |
|
|---|
| 58 | std::vector<Grid*> grids;
|
|---|
| 59 |
|
|---|
| 60 | int levelGlobalMax, levelMin, levelMax;
|
|---|
| 61 | int levelIndex, levelCurrent;
|
|---|
| 62 | int numLevels;
|
|---|
| 63 |
|
|---|
| 64 | private:
|
|---|
| 65 | LocalIndices InitDirichlet(const GlobalIndices& global,
|
|---|
| 66 | const SpatialExtent& extent,
|
|---|
| 67 | const Index& pos,
|
|---|
| 68 | const Index& procs);
|
|---|
| 69 |
|
|---|
| 70 | LocalIndices InitPeriodic(const GlobalIndices& global,
|
|---|
| 71 | const SpatialExtent& extent,
|
|---|
| 72 | const Index& pos,
|
|---|
| 73 | const Index& procs);
|
|---|
| 74 | };
|
|---|
| 75 |
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | #endif /* MULTIGRID_HPP_ */
|
|---|