Alsvinn  0.5.3
The fast FVM simulator with UQ support
Grid.hpp
Go to the documentation of this file.
1 /* Copyright (c) 2018 ETH Zurich, Kjetil Olsen Lye
2  * This program is free software: you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 #pragma once
17 
18 #include "alsfvm/types.hpp"
19 #include "alsfvm/boundary/Type.hpp"
20 
21 namespace alsfvm {
22 namespace grid {
27 class Grid {
28 public:
29 
45 
47  Grid(rvec3 origin, rvec3 top, ivec3 dimensions,
48  const std::array<boundary::Type, 6>& boundaryConditions =
50  );
51 
70  Grid(rvec3 origin, rvec3 top, ivec3 dimensions,
71  const std::array<boundary::Type, 6>& boundaryConditions,
72  const ivec3& globalPosition,
73  const ivec3& globalSize);
74 
75 
104  Grid(rvec3 origin, rvec3 top, ivec3 dimensions,
105  const std::array<boundary::Type, 6>& boundaryConditions,
106  const ivec3& globalPosition,
107  const ivec3& globalSize,
108  const rvec3& cellLengths);
109 
140  Grid(rvec3 origin, rvec3 top, ivec3 dimensions,
141  const std::array<boundary::Type, 6>& boundaryConditions,
142  const ivec3& globalPosition,
143  const ivec3& globalSize,
144  const rvec3& cellLengths,
145  const std::vector<rvec3>& cellMidpoints);
146 
151  rvec3 getOrigin() const;
152 
157  rvec3 getTop() const;
158 
163  ivec3 getDimensions() const;
164 
169  size_t getActiveDimension() const;
170 
174  rvec3 getCellLengths() const;
175 
183  const std::vector<rvec3>& getCellMidpoints() const;
184 
185 
197  boundary::Type getBoundaryCondition(int side) const;
198 
210  std::array<boundary::Type, 6> getBoundaryConditions() const;
211 
224  std::vector<boundary::Type> getActiveBoundaryConditions() const;
225 
230  ivec3 getGlobalPosition() const;
231 
233  ivec3 getGlobalSize() const;
234 private:
235  rvec3 origin;
236  rvec3 top;
237  ivec3 dimensions;
238  rvec3 cellLengths;
239 
240  // A vector containing all cell midpoints
241  mutable std::vector<rvec3> cellMidpoints;
242 
243  // For each side, states the boundary condition.
244  std::array<boundary::Type, 6> boundaryConditions;
245 
246  // the global position (in case of using MPI)
247  ivec3 globalPosition;
248 
249  // the global size
250  ivec3 globalSize;
251 };
252 }
253 }
ivec3 getDimensions() const
Definition: Grid.cpp:127
Definition: Grid.hpp:27
rvec3 getTop() const
Definition: Grid.cpp:119
const std::vector< rvec3 > & getCellMidpoints() const
Definition: Grid.cpp:148
Type
Definition: Type.hpp:22
rvec3 getOrigin() const
Definition: Grid.cpp:111
const grid::Grid & grid
Definition: NumericalFluxFactory.cpp:104
rvec3 getCellLengths() const
Definition: Grid.cpp:144
ivec3 getGlobalSize() const
Get the total size (in number of cells) of the larger grid.
Definition: Grid.cpp:195
size_t getActiveDimension() const
Definition: Grid.cpp:131
std::vector< boundary::Type > getActiveBoundaryConditions() const
Definition: Grid.cpp:181
boundary::Type getBoundaryCondition(int side) const
Definition: Grid.cpp:173
Various utility functions to implement the tecno flux.
Definition: types.hpp:30
std::array< Type, 6 > allPeriodic()
Definition: Type.hpp:35
std::array< boundary::Type, 6 > getBoundaryConditions() const
Definition: Grid.cpp:177
ivec3 getGlobalPosition() const
Definition: Grid.cpp:191
Grid(rvec3 origin, rvec3 top, ivec3 dimensions, const std::array< boundary::Type, 6 > &boundaryConditions=boundary::allPeriodic())
Definition: Grid.cpp:44