| 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_finer_begin(0), global_finer_end(0), global_finer_size(0),
|
|---|
| 44 | local_finer_begin(0), local_finer_end(0), local_finer_size(0),
|
|---|
| 45 | finest_abs_begin(0), finest_abs_end(0), finest_abs_size(0),
|
|---|
| 46 | global_size(0),
|
|---|
| 47 | boundary(EmptyGrid)
|
|---|
| 48 | {}
|
|---|
| 49 |
|
|---|
| 50 | GlobalIndices(const GlobalIndices& other) :
|
|---|
| 51 | local_begin(other.local_begin), local_end(other.local_end), local_size(other.local_size),
|
|---|
| 52 | global_finer_begin(other.global_finer_begin), global_finer_end(other.global_finer_end), global_finer_size(other.global_finer_size),
|
|---|
| 53 | local_finer_begin(other.local_finer_begin), local_finer_end(other.local_finer_end), local_finer_size(other.local_finer_size),
|
|---|
| 54 | finest_abs_begin(other.finest_abs_begin), finest_abs_end(other.finest_abs_end), finest_abs_size(other.finest_abs_size),
|
|---|
| 55 | global_size(other.global_size),
|
|---|
| 56 | boundary(other.boundary)
|
|---|
| 57 | {}
|
|---|
| 58 |
|
|---|
| 59 | Index& LocalBegin() {return local_begin;}
|
|---|
| 60 | Index& LocalEnd() {return local_end;}
|
|---|
| 61 | Index& LocalSize() {return local_size;}
|
|---|
| 62 |
|
|---|
| 63 | const Index& LocalBegin() const {return local_begin;}
|
|---|
| 64 | const Index& LocalEnd() const {return local_end;}
|
|---|
| 65 | const Index& LocalSize() const {return local_size;}
|
|---|
| 66 |
|
|---|
| 67 | Index& GlobalFinerBegin() {return global_finer_begin;}
|
|---|
| 68 | Index& GlobalFinerEnd() {return global_finer_end;}
|
|---|
| 69 | Index& GlobalFinerSize() {return global_finer_size;}
|
|---|
| 70 |
|
|---|
| 71 | const Index& GlobalFinerBegin() const {return global_finer_begin;}
|
|---|
| 72 | const Index& GlobalFinerEnd() const {return global_finer_end;}
|
|---|
| 73 | const Index& GlobalFinerSize() const {return global_finer_size;}
|
|---|
| 74 |
|
|---|
| 75 | Index& LocalFinerBegin() {return local_finer_begin;}
|
|---|
| 76 | Index& LocalFinerEnd() {return local_finer_end;}
|
|---|
| 77 | Index& LocalFinerSize() {return local_finer_size;}
|
|---|
| 78 |
|
|---|
| 79 | const Index& LocalFinerBegin() const {return local_finer_begin;}
|
|---|
| 80 | const Index& LocalFinerEnd() const {return local_finer_end;}
|
|---|
| 81 | const Index& LocalFinerSize() const {return local_finer_size;}
|
|---|
| 82 |
|
|---|
| 83 | Index& FinestAbsBegin() {return finest_abs_begin;}
|
|---|
| 84 | Index& FinestAbsEnd() {return finest_abs_end;}
|
|---|
| 85 | Index& FinestAbsSize() {return finest_abs_size;}
|
|---|
| 86 |
|
|---|
| 87 | const Index& FinestAbsBegin() const {return finest_abs_begin;}
|
|---|
| 88 | const Index& FinestAbsEnd() const {return finest_abs_end;}
|
|---|
| 89 | const Index& FinestAbsSize() const {return finest_abs_size;}
|
|---|
| 90 |
|
|---|
| 91 | Index& GlobalSize() {return global_size;}
|
|---|
| 92 | const Index& GlobalSize() const {return global_size;}
|
|---|
| 93 |
|
|---|
| 94 | BT& BoundaryType() {return boundary;}
|
|---|
| 95 | const BT& BoundaryType() const {return boundary;}
|
|---|
| 96 |
|
|---|
| 97 | private:
|
|---|
| 98 | Index local_begin, local_end, local_size;
|
|---|
| 99 | Index global_finer_begin, global_finer_end, global_finer_size;
|
|---|
| 100 | Index local_finer_begin, local_finer_end, local_finer_size;
|
|---|
| 101 | Index finest_abs_begin, finest_abs_end, finest_abs_size;
|
|---|
| 102 | Index global_size;
|
|---|
| 103 | BT boundary;
|
|---|
| 104 | };
|
|---|
| 105 |
|
|---|
| 106 | class LocalIndices
|
|---|
| 107 | {
|
|---|
| 108 | public:
|
|---|
| 109 | LocalIndices() :
|
|---|
| 110 | begin(0), end(0), size(0), size_total(0),
|
|---|
| 111 | halo_begin_1(0), halo_end_1(0), halo_size_1(0),
|
|---|
| 112 | halo_begin_2(0), halo_end_2(0), halo_size_2(0),
|
|---|
| 113 | boundary_begin_1(0), boundary_end_1(0), boundary_size_1(0),
|
|---|
| 114 | boundary_begin_2(0), boundary_end_2(0), boundary_size_2(0),
|
|---|
| 115 | finer_begin(0), finer_end(0), finer_size(0)
|
|---|
| 116 | {}
|
|---|
| 117 |
|
|---|
| 118 | LocalIndices(const LocalIndices& other) :
|
|---|
| 119 | begin(other.begin), end(other.end), size(other.size), size_total(other.size_total),
|
|---|
| 120 | halo_begin_1(other.halo_begin_1), halo_end_1(other.halo_end_1), halo_size_1(other.halo_size_1),
|
|---|
| 121 | halo_begin_2(other.halo_begin_2), halo_end_2(other.halo_end_2), halo_size_2(other.halo_size_2),
|
|---|
| 122 | boundary_begin_1(other.boundary_begin_1), boundary_end_1(other.boundary_end_1), boundary_size_1(other.boundary_size_1),
|
|---|
| 123 | boundary_begin_2(other.boundary_begin_2), boundary_end_2(other.boundary_end_2), boundary_size_2(other.boundary_size_2),
|
|---|
| 124 | finer_begin(other.finer_begin), finer_end(other.finer_end), finer_size(other.finer_size)
|
|---|
| 125 | {}
|
|---|
| 126 |
|
|---|
| 127 | Index& Begin() {return begin;} ///< Index of first local grid point
|
|---|
| 128 | Index& End() {return end;} ///< Index of first non-local grid point
|
|---|
| 129 | Index& Size() {return size;} ///< Local grid size excluding halo
|
|---|
| 130 | Index& SizeTotal() {return size_total;} ///< Local grid size including halo and boundary
|
|---|
| 131 |
|
|---|
| 132 | const Index& Begin() const {return begin;} ///< Index of first local grid point
|
|---|
| 133 | const Index& End() const {return end;} ///< Index of first non-local grid point
|
|---|
| 134 | const Index& Size() const {return size;} ///< Local grid size excluding halo
|
|---|
| 135 | const Index& SizeTotal() const {return size_total;} ///< Local grid size including halo and boundary
|
|---|
| 136 |
|
|---|
| 137 | Index& HaloBegin1() {return halo_begin_1;} ///< Index of first halo point
|
|---|
| 138 | Index& HaloEnd1() {return halo_end_1;} ///< Index of first non-halo point
|
|---|
| 139 | Index& HaloSize1() {return halo_size_1;} ///< Size of halo
|
|---|
| 140 |
|
|---|
| 141 | Index& HaloBegin2() {return halo_begin_2;} ///< Index of first halo point
|
|---|
| 142 | Index& HaloEnd2() {return halo_end_2;} ///< Index of first non-halo point
|
|---|
| 143 | Index& HaloSize2() {return halo_size_2;} ///< Size of halo
|
|---|
| 144 |
|
|---|
| 145 | const Index& HaloBegin1() const {return halo_begin_1;} ///< Index of first halo point
|
|---|
| 146 | const Index& HaloEnd1() const {return halo_end_1;} ///< Index of first non-halo point
|
|---|
| 147 | const Index& HaloSize1() const {return halo_size_1;} ///< Size of halo
|
|---|
| 148 |
|
|---|
| 149 | const Index& HaloBegin2() const {return halo_begin_2;} ///< Index of first halo point
|
|---|
| 150 | const Index& HaloEnd2() const {return halo_end_2;} ///< Index of first non-halo point
|
|---|
| 151 | const Index& HaloSize2() const {return halo_size_2;} ///< Size of halo
|
|---|
| 152 |
|
|---|
| 153 | Index& BoundaryBegin1() {return boundary_begin_1;} ///< Index of first boundary point
|
|---|
| 154 | Index& BoundaryEnd1() {return boundary_end_1;} ///< Index of first non-boundary point
|
|---|
| 155 | Index& BoundarySize1() {return boundary_size_1;} ///< Size of boundary
|
|---|
| 156 |
|
|---|
| 157 | Index& BoundaryBegin2() {return boundary_begin_2;} ///< Index of first boundary point
|
|---|
| 158 | Index& BoundaryEnd2() {return boundary_end_2;} ///< Index of first non-boundary point
|
|---|
| 159 | Index& BoundarySize2() {return boundary_size_2;} ///< Size of boundary
|
|---|
| 160 |
|
|---|
| 161 | const Index& BoundaryBegin1() const {return boundary_begin_1;} ///< Index of first boundary point
|
|---|
| 162 | const Index& BoundaryEnd1() const {return boundary_end_1;} ///< Index of first non-boundary point
|
|---|
| 163 | const Index& BoundarySize1() const {return boundary_size_1;} ///< Size of boundary
|
|---|
| 164 |
|
|---|
| 165 | const Index& BoundaryBegin2() const {return boundary_begin_2;} ///< Index of first boundary point
|
|---|
| 166 | const Index& BoundaryEnd2() const {return boundary_end_2;} ///< Index of first non-boundary point
|
|---|
| 167 | const Index& BoundarySize2() const {return boundary_size_2;} ///< Size of boundary
|
|---|
| 168 |
|
|---|
| 169 | Index& FinerBegin() {return finer_begin;}
|
|---|
| 170 | Index& FinerEnd() {return finer_end;}
|
|---|
| 171 | Index& FinerSize() {return finer_size;}
|
|---|
| 172 |
|
|---|
| 173 | const Index& FinerBegin() const {return finer_begin;}
|
|---|
| 174 | const Index& FinerEnd() const {return finer_end;}
|
|---|
| 175 | const Index& FinerSize() const {return finer_size;}
|
|---|
| 176 |
|
|---|
| 177 | bool HasFinerGrid() const {return static_cast<bool>(finer_size.Product());}
|
|---|
| 178 |
|
|---|
| 179 | private:
|
|---|
| 180 | Index begin, end, size, size_total;
|
|---|
| 181 | Index halo_begin_1, halo_end_1, halo_size_1;
|
|---|
| 182 | Index halo_begin_2, halo_end_2, halo_size_2;
|
|---|
| 183 | Index boundary_begin_1, boundary_end_1, boundary_size_1;
|
|---|
| 184 | Index boundary_begin_2, boundary_end_2, boundary_size_2;
|
|---|
| 185 | Index finer_begin, finer_end, finer_size;
|
|---|
| 186 | };
|
|---|
| 187 |
|
|---|
| 188 | class SpatialExtent
|
|---|
| 189 | {
|
|---|
| 190 | public:
|
|---|
| 191 | SpatialExtent() :
|
|---|
| 192 | begin(0.0),
|
|---|
| 193 | end(0.0),
|
|---|
| 194 | size(0.0),
|
|---|
| 195 | mesh_width(0.0)
|
|---|
| 196 | {}
|
|---|
| 197 |
|
|---|
| 198 | SpatialExtent(const SpatialExtent& other) :
|
|---|
| 199 | begin(other.begin),
|
|---|
| 200 | end(other.end),
|
|---|
| 201 | size(other.size),
|
|---|
| 202 | mesh_width(other.mesh_width)
|
|---|
| 203 | {}
|
|---|
| 204 |
|
|---|
| 205 | Vector& Begin() {return begin;}
|
|---|
| 206 | const Vector& Begin() const {return begin;}
|
|---|
| 207 |
|
|---|
| 208 | Vector& End() {return end;}
|
|---|
| 209 | const Vector& End() const {return end;}
|
|---|
| 210 |
|
|---|
| 211 | Vector& Size() {return size;}
|
|---|
| 212 | const Vector& Size() const {return size;}
|
|---|
| 213 |
|
|---|
| 214 | Vector& MeshWidth() {return mesh_width;}
|
|---|
| 215 | const Vector& MeshWidth() const {return mesh_width;}
|
|---|
| 216 |
|
|---|
| 217 | private:
|
|---|
| 218 | Vector begin, end, size;
|
|---|
| 219 | Vector mesh_width;
|
|---|
| 220 | };
|
|---|
| 221 |
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | #endif /* GRID_PROPERTIES_HPP_ */
|
|---|