| [fcf7f6] | 1 | /*
|
|---|
| 2 | * vmg - a versatile multigrid solver
|
|---|
| 3 | * Copyright (C) 2012 Institute for Numerical Simulation, University of Bonn
|
|---|
| 4 | *
|
|---|
| 5 | * vmg is free software: you can redistribute it and/or modify
|
|---|
| 6 | * it under the terms of the GNU General Public License as published by
|
|---|
| 7 | * the Free Software Foundation, either version 3 of the License, or
|
|---|
| 8 | * (at your option) any later version.
|
|---|
| 9 | *
|
|---|
| 10 | * vmg is distributed in the hope that it will be useful,
|
|---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 13 | * GNU General Public License for more details.
|
|---|
| 14 | *
|
|---|
| 15 | * You should have received a copy of the GNU General Public License
|
|---|
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| [dfed1c] | 19 | /**
|
|---|
| 20 | * @file grid_index_translations.hpp
|
|---|
| 21 | * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
|
|---|
| 22 | * @date Tue May 17 11:46:37 2011
|
|---|
| 23 | *
|
|---|
| 24 | * @brief Class to convert different representations of grid
|
|---|
| 25 | * indices.
|
|---|
| 26 | *
|
|---|
| 27 | */
|
|---|
| 28 |
|
|---|
| 29 | #ifndef GRID_INDEX_TRANSLATIONS_HPP_
|
|---|
| 30 | #define GRID_INDEX_TRANSLATIONS_HPP_
|
|---|
| 31 |
|
|---|
| 32 | #include "base/defs.hpp"
|
|---|
| 33 | #include "base/index.hpp"
|
|---|
| 34 |
|
|---|
| 35 | namespace VMG
|
|---|
| 36 | {
|
|---|
| 37 |
|
|---|
| 38 | class Comm;
|
|---|
| 39 | class Grid;
|
|---|
| 40 |
|
|---|
| 41 | class GridIndexTranslations
|
|---|
| 42 | {
|
|---|
| 43 | public:
|
|---|
| 44 | GridIndexTranslations(const Grid* father_) :
|
|---|
| 45 | father(father_)
|
|---|
| 46 | {}
|
|---|
| 47 |
|
|---|
| 48 | Index GlobalToLocal(const Index& index_global) const;
|
|---|
| 49 | static Index GlobalToFiner(const Index& index_global);
|
|---|
| 50 | static Index GlobalToCoarser(const Index& index_global);
|
|---|
| 51 |
|
|---|
| 52 | static Index GlobalToFiner(const Index& index_global, const int& num_levels);
|
|---|
| 53 | static Index GlobalToCoarser(const Index& index_global, const int& num_levels);
|
|---|
| 54 |
|
|---|
| 55 | Index LocalToGlobal(const Index& index_local) const;
|
|---|
| 56 | Index LocalToFiner(const Index& index_local) const;
|
|---|
| 57 | Index LocalToCoarser(const Index& index_local) const;
|
|---|
| 58 |
|
|---|
| 59 | Index FinestGlobalToLocal(const Index& index_finest) const;
|
|---|
| 60 | Index FinestGlobalToGlobal(const Index& index_finest) const;
|
|---|
| 61 |
|
|---|
| 62 | static void FineToCoarse(Index& begin, Index& end);
|
|---|
| 63 | static void CoarseToFine(Index& begin, Index& end, const Index& size_global);
|
|---|
| 64 |
|
|---|
| 65 | static Index EndOffset(const Boundary& boundary)
|
|---|
| 66 | {
|
|---|
| 67 | Index offset;
|
|---|
| 68 |
|
|---|
| 69 | for (int i=0; i<3; ++i)
|
|---|
| 70 | offset[i] = (boundary[i] == Open || boundary[i] == Dirichlet ? 1 : 0);
|
|---|
| 71 |
|
|---|
| 72 | return offset;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | protected:
|
|---|
| 76 | const Grid* Father() const {return father;}
|
|---|
| 77 |
|
|---|
| 78 | private:
|
|---|
| 79 | const Grid* father;
|
|---|
| 80 | };
|
|---|
| 81 |
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 | #endif /* GRID_INDEX_TRANSLATIONS_HPP_ */
|
|---|