| 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 | 
 | 
|---|
| 19 | /**
 | 
|---|
| 20 |  * @file   grid_properties.hpp
 | 
|---|
| 21 |  * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
 | 
|---|
| 22 |  * @date   Mon Apr 18 12:54:05 2011
 | 
|---|
| 23 |  *
 | 
|---|
| 24 |  * @brief  VMG::GlobalIndices, VMG::LocalIndices and VMG::SpatialExtent
 | 
|---|
| 25 |  *
 | 
|---|
| 26 |  */
 | 
|---|
| 27 | 
 | 
|---|
| 28 | #ifndef GRID_PROPERTIES_HPP_
 | 
|---|
| 29 | #define GRID_PROPERTIES_HPP_
 | 
|---|
| 30 | 
 | 
|---|
| 31 | #include "base/defs.hpp"
 | 
|---|
| 32 | #include "base/index.hpp"
 | 
|---|
| 33 | #include "base/vector.hpp"
 | 
|---|
| 34 | 
 | 
|---|
| 35 | namespace VMG
 | 
|---|
| 36 | {
 | 
|---|
| 37 | 
 | 
|---|
| 38 | class GlobalIndices
 | 
|---|
| 39 | {
 | 
|---|
| 40 | public:
 | 
|---|
| 41 |   GlobalIndices() :
 | 
|---|
| 42 |     local_begin(0), local_end(0), local_size(0),
 | 
|---|
| 43 |     global_begin(0), global_end(0), global_size(0),
 | 
|---|
| 44 |     global_begin_finest(0), global_end_finest(0), global_size_finest(0),
 | 
|---|
| 45 |     boundary(EmptyGrid)
 | 
|---|
| 46 |   {}
 | 
|---|
| 47 | 
 | 
|---|
| 48 |   GlobalIndices(const GlobalIndices& other) :
 | 
|---|
| 49 |     local_begin(other.local_begin), local_end(other.local_end), local_size(other.local_size),
 | 
|---|
| 50 |     global_begin(other.global_begin), global_end(other.global_end), global_size(other.global_size),
 | 
|---|
| 51 |     global_begin_finest(other.global_begin_finest), global_end_finest(other.global_end_finest), global_size_finest(other.global_size_finest),
 | 
|---|
| 52 |     boundary(other.boundary)
 | 
|---|
| 53 |   {}
 | 
|---|
| 54 | 
 | 
|---|
| 55 |   Index& LocalBegin() {return local_begin;}
 | 
|---|
| 56 |   Index& LocalEnd() {return local_end;}
 | 
|---|
| 57 |   Index& LocalSize() {return local_size;}
 | 
|---|
| 58 | 
 | 
|---|
| 59 |   const Index& LocalBegin() const {return local_begin;}
 | 
|---|
| 60 |   const Index& LocalEnd() const {return local_end;}
 | 
|---|
| 61 |   const Index& LocalSize() const {return local_size;}
 | 
|---|
| 62 | 
 | 
|---|
| 63 |   Index& GlobalBegin() {return global_begin;}
 | 
|---|
| 64 |   Index& GlobalEnd() {return global_end;}
 | 
|---|
| 65 |   Index& GlobalSize() {return global_size;}
 | 
|---|
| 66 | 
 | 
|---|
| 67 |   const Index& GlobalBegin() const {return global_begin;}
 | 
|---|
| 68 |   const Index& GlobalEnd() const {return global_end;}
 | 
|---|
| 69 |   const Index& GlobalSize() const {return global_size;}
 | 
|---|
| 70 | 
 | 
|---|
| 71 |   Index& GlobalBeginFinest() {return global_begin_finest;}
 | 
|---|
| 72 |   Index& GlobalEndFinest() {return global_end_finest;}
 | 
|---|
| 73 |   Index& GlobalSizeFinest() {return global_size_finest;}
 | 
|---|
| 74 | 
 | 
|---|
| 75 |   const Index& GlobalBeginFinest() const {return global_begin_finest;}
 | 
|---|
| 76 |   const Index& GlobalEndFinest() const {return global_end_finest;}
 | 
|---|
| 77 |   const Index& GlobalSizeFinest() const {return global_size_finest;}
 | 
|---|
| 78 | 
 | 
|---|
| 79 |   BT& BoundaryType() {return boundary;}
 | 
|---|
| 80 |   const BT& BoundaryType() const {return boundary;}
 | 
|---|
| 81 | 
 | 
|---|
| 82 | private:
 | 
|---|
| 83 |   Index local_begin, local_end, local_size;
 | 
|---|
| 84 |   Index global_begin, global_end, global_size;
 | 
|---|
| 85 |   Index global_begin_finest, global_end_finest, global_size_finest;
 | 
|---|
| 86 |   BT boundary;
 | 
|---|
| 87 | };
 | 
|---|
| 88 | 
 | 
|---|
| 89 | class LocalIndices
 | 
|---|
| 90 | {
 | 
|---|
| 91 | public:
 | 
|---|
| 92 |   LocalIndices() :
 | 
|---|
| 93 |     begin(0), end(0), size(0), size_total(0),
 | 
|---|
| 94 |     halo_begin_1(0), halo_end_1(0), halo_size_1(0),
 | 
|---|
| 95 |     halo_begin_2(0), halo_end_2(0), halo_size_2(0),
 | 
|---|
| 96 |     boundary_begin_1(0), boundary_end_1(0), boundary_size_1(0),
 | 
|---|
| 97 |     boundary_begin_2(0), boundary_end_2(0), boundary_size_2(0)
 | 
|---|
| 98 |   {}
 | 
|---|
| 99 | 
 | 
|---|
| 100 |   LocalIndices(const LocalIndices& other) :
 | 
|---|
| 101 |     begin(other.begin), end(other.end), size(other.size), size_total(other.size_total),
 | 
|---|
| 102 |     halo_begin_1(other.halo_begin_1), halo_end_1(other.halo_end_1), halo_size_1(other.halo_size_1),
 | 
|---|
| 103 |     halo_begin_2(other.halo_begin_2), halo_end_2(other.halo_end_2), halo_size_2(other.halo_size_2),
 | 
|---|
| 104 |     boundary_begin_1(other.boundary_begin_1), boundary_end_1(other.boundary_end_1), boundary_size_1(other.boundary_size_1),
 | 
|---|
| 105 |     boundary_begin_2(other.boundary_begin_2), boundary_end_2(other.boundary_end_2), boundary_size_2(other.boundary_size_2)
 | 
|---|
| 106 |   {}
 | 
|---|
| 107 | 
 | 
|---|
| 108 |   Index& Begin() {return begin;}                         ///< Index of first local grid point
 | 
|---|
| 109 |   Index& End() {return end;}                             ///< Index of first non-local grid point
 | 
|---|
| 110 |   Index& Size() {return size;}                           ///< Local grid size excluding halo
 | 
|---|
| 111 |   Index& SizeTotal() {return size_total;}                ///< Local grid size including halo and boundary
 | 
|---|
| 112 | 
 | 
|---|
| 113 |   const Index& Begin() const {return begin;}             ///< Index of first local grid point
 | 
|---|
| 114 |   const Index& End() const {return end;}                 ///< Index of first non-local grid point
 | 
|---|
| 115 |   const Index& Size() const {return size;}               ///< Local grid size excluding halo
 | 
|---|
| 116 |   const Index& SizeTotal() const {return size_total;}    ///< Local grid size including halo and boundary
 | 
|---|
| 117 | 
 | 
|---|
| 118 |   Index& HaloBegin1() {return halo_begin_1;}             ///< Index of first halo point
 | 
|---|
| 119 |   Index& HaloEnd1() {return halo_end_1;}                 ///< Index of first non-halo point
 | 
|---|
| 120 |   Index& HaloSize1() {return halo_size_1;}               ///< Size of halo
 | 
|---|
| 121 | 
 | 
|---|
| 122 |   Index& HaloBegin2() {return halo_begin_2;}             ///< Index of first halo point
 | 
|---|
| 123 |   Index& HaloEnd2() {return halo_end_2;}                 ///< Index of first non-halo point
 | 
|---|
| 124 |   Index& HaloSize2() {return halo_size_2;}               ///< Size of halo
 | 
|---|
| 125 | 
 | 
|---|
| 126 |   const Index& HaloBegin1() const {return halo_begin_1;} ///< Index of first halo point
 | 
|---|
| 127 |   const Index& HaloEnd1() const {return halo_end_1;}     ///< Index of first non-halo point
 | 
|---|
| 128 |   const Index& HaloSize1() const {return halo_size_1;}   ///< Size of halo
 | 
|---|
| 129 | 
 | 
|---|
| 130 |   const Index& HaloBegin2() const {return halo_begin_2;} ///< Index of first halo point
 | 
|---|
| 131 |   const Index& HaloEnd2() const {return halo_end_2;}     ///< Index of first non-halo point
 | 
|---|
| 132 |   const Index& HaloSize2() const {return halo_size_2;}   ///< Size of halo
 | 
|---|
| 133 | 
 | 
|---|
| 134 |   Index& BoundaryBegin1() {return boundary_begin_1;}     ///< Index of first boundary point
 | 
|---|
| 135 |   Index& BoundaryEnd1() {return boundary_end_1;}         ///< Index of first non-boundary point
 | 
|---|
| 136 |   Index& BoundarySize1() {return boundary_size_1;}       ///< Size of boundary
 | 
|---|
| 137 | 
 | 
|---|
| 138 |   Index& BoundaryBegin2() {return boundary_begin_2;}     ///< Index of first boundary point
 | 
|---|
| 139 |   Index& BoundaryEnd2() {return boundary_end_2;}         ///< Index of first non-boundary point
 | 
|---|
| 140 |   Index& BoundarySize2() {return boundary_size_2;}       ///< Size of boundary
 | 
|---|
| 141 | 
 | 
|---|
| 142 |   const Index& BoundaryBegin1() const {return boundary_begin_1;} ///< Index of first boundary point
 | 
|---|
| 143 |   const Index& BoundaryEnd1() const {return boundary_end_1;}     ///< Index of first non-boundary point
 | 
|---|
| 144 |   const Index& BoundarySize1() const {return boundary_size_1;}   ///< Size of boundary
 | 
|---|
| 145 | 
 | 
|---|
| 146 |   const Index& BoundaryBegin2() const {return boundary_begin_2;} ///< Index of first boundary point
 | 
|---|
| 147 |   const Index& BoundaryEnd2() const {return boundary_end_2;}     ///< Index of first non-boundary point
 | 
|---|
| 148 |   const Index& BoundarySize2() const {return boundary_size_2;}   ///< Size of boundary
 | 
|---|
| 149 | 
 | 
|---|
| 150 | private:
 | 
|---|
| 151 |   Index begin, end, size, size_total;
 | 
|---|
| 152 |   Index halo_begin_1, halo_end_1, halo_size_1;
 | 
|---|
| 153 |   Index halo_begin_2, halo_end_2, halo_size_2;
 | 
|---|
| 154 |   Index boundary_begin_1, boundary_end_1, boundary_size_1;
 | 
|---|
| 155 |   Index boundary_begin_2, boundary_end_2, boundary_size_2;
 | 
|---|
| 156 | };
 | 
|---|
| 157 | 
 | 
|---|
| 158 | class SpatialExtent
 | 
|---|
| 159 | {
 | 
|---|
| 160 | public:
 | 
|---|
| 161 |   SpatialExtent() :
 | 
|---|
| 162 |     begin(0.0),
 | 
|---|
| 163 |     end(0.0),
 | 
|---|
| 164 |     size(0.0),
 | 
|---|
| 165 |     mesh_width(0.0)
 | 
|---|
| 166 |   {}
 | 
|---|
| 167 | 
 | 
|---|
| 168 |   SpatialExtent(const SpatialExtent& other) :
 | 
|---|
| 169 |     begin(other.begin),
 | 
|---|
| 170 |     end(other.end),
 | 
|---|
| 171 |     size(other.size),
 | 
|---|
| 172 |     mesh_width(other.mesh_width)
 | 
|---|
| 173 |   {}
 | 
|---|
| 174 | 
 | 
|---|
| 175 |   Vector& Begin() {return begin;}
 | 
|---|
| 176 |   const Vector& Begin() const {return begin;}
 | 
|---|
| 177 | 
 | 
|---|
| 178 |   Vector& End() {return end;}
 | 
|---|
| 179 |   const Vector& End() const {return end;}
 | 
|---|
| 180 | 
 | 
|---|
| 181 |   Vector& Size() {return size;}
 | 
|---|
| 182 |   const Vector& Size() const {return size;}
 | 
|---|
| 183 | 
 | 
|---|
| 184 |   Vector& MeshWidth() {return mesh_width;}
 | 
|---|
| 185 |   const Vector& MeshWidth() const {return mesh_width;}
 | 
|---|
| 186 | 
 | 
|---|
| 187 | private:
 | 
|---|
| 188 |   Vector begin, end, size;
 | 
|---|
| 189 |   Vector mesh_width;
 | 
|---|
| 190 | };
 | 
|---|
| 191 | 
 | 
|---|
| 192 | }
 | 
|---|
| 193 | 
 | 
|---|
| 194 | #endif /* GRID_PROPERTIES_HPP_ */
 | 
|---|