| 1 | /**
|
|---|
| 2 | * @file grid_index_translations.hpp
|
|---|
| 3 | * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
|
|---|
| 4 | * @date Tue May 17 11:46:37 2011
|
|---|
| 5 | *
|
|---|
| 6 | * @brief Class to convert different representations of grid
|
|---|
| 7 | * indices.
|
|---|
| 8 | *
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | #ifndef GRID_INDEX_TRANSLATIONS_HPP_
|
|---|
| 12 | #define GRID_INDEX_TRANSLATIONS_HPP_
|
|---|
| 13 |
|
|---|
| 14 | #include "base/defs.hpp"
|
|---|
| 15 | #include "base/index.hpp"
|
|---|
| 16 |
|
|---|
| 17 | namespace VMG
|
|---|
| 18 | {
|
|---|
| 19 |
|
|---|
| 20 | class Comm;
|
|---|
| 21 | class Grid;
|
|---|
| 22 |
|
|---|
| 23 | class GridIndexTranslations
|
|---|
| 24 | {
|
|---|
| 25 | public:
|
|---|
| 26 | GridIndexTranslations(const Grid* father_) :
|
|---|
| 27 | father(father_)
|
|---|
| 28 | {}
|
|---|
| 29 |
|
|---|
| 30 | Index GlobalToLocal(const Index& index_global) const;
|
|---|
| 31 | static Index GlobalToFiner(const Index& index_global);
|
|---|
| 32 | static Index GlobalToCoarser(const Index& index_global);
|
|---|
| 33 |
|
|---|
| 34 | static Index GlobalToFiner(const Index& index_global, const int& num_levels);
|
|---|
| 35 | static Index GlobalToCoarser(const Index& index_global, const int& num_levels);
|
|---|
| 36 |
|
|---|
| 37 | Index LocalToGlobal(const Index& index_local) const;
|
|---|
| 38 | Index LocalToFiner(const Index& index_local) const;
|
|---|
| 39 | Index LocalToCoarser(const Index& index_local) const;
|
|---|
| 40 |
|
|---|
| 41 | Index FinestGlobalToLocal(const Index& index_finest) const;
|
|---|
| 42 | Index FinestGlobalToGlobal(const Index& index_finest) const;
|
|---|
| 43 |
|
|---|
| 44 | static void FineToCoarse(Index& begin, Index& end);
|
|---|
| 45 | static void CoarseToFine(Index& begin, Index& end, const Index& size_global);
|
|---|
| 46 |
|
|---|
| 47 | static Index EndOffset(const Boundary& boundary)
|
|---|
| 48 | {
|
|---|
| 49 | Index offset;
|
|---|
| 50 |
|
|---|
| 51 | for (int i=0; i<3; ++i)
|
|---|
| 52 | offset[i] = (boundary[i] == Open || boundary[i] == Dirichlet ? 1 : 0);
|
|---|
| 53 |
|
|---|
| 54 | return offset;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | protected:
|
|---|
| 58 | const Grid* Father() const {return father;}
|
|---|
| 59 |
|
|---|
| 60 | private:
|
|---|
| 61 | const Grid* father;
|
|---|
| 62 | };
|
|---|
| 63 |
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | #endif /* GRID_INDEX_TRANSLATIONS_HPP_ */
|
|---|