Go to the documentation of this file.
21 #ifndef THUNDEREGG_PATCHARRAY_H
22 #define THUNDEREGG_PATCHARRAY_H
39 std::vector<double> vector;
55 PatchArray(
const std::array<int, D>& lengths,
int num_components,
int num_ghost_cells)
57 std::array<int, D + 1> view_lengths;
58 for (
int i = 0; i < D; i++) {
59 view_lengths[i] = lengths[i];
61 view_lengths[D] = num_components;
62 std::array<int, D + 1> strides;
64 for (
int i = 1; i < D + 1; i++) {
65 strides[i] = strides[i - 1] * (lengths[i - 1] + 2 * num_ghost_cells);
67 int size = strides[D] * num_components;
78 : vector(other.vector)
96 vector = other.vector;
118 return view.template getSliceOn<M>(f, offset);
132 const std::array<int, D - M>& offset)
const
148 const std::array<size_t, D - M>& offset)
const
150 return view.template getGhostSliceOn<M>(f, offset);
153 inline const double& operator[](
const std::array<int, D + 1>& coord)
const {
return view[coord]; }
154 template<
class... Types>
155 inline const double& operator()(Types... args)
const
157 return view(args...);
159 inline void set(
const std::array<int, D + 1>& coord,
double value)
const
161 view.
set(coord, value);
163 inline double& operator[](
const std::array<int, D + 1>& coord) {
return view[coord]; }
164 template<
class... Types>
165 inline double& operator()(Types... args)
167 return view(args...);
169 inline void set(
const std::array<int, D + 1>& coord,
double value) { view.
set(coord, value); }
182 inline const std::array<int, D + 1>&
getEnd()
const {
return view.
getEnd(); }
198 extern template class PatchArray<1>;
199 extern template class PatchArray<2>;
200 extern template class PatchArray<3>;
Array for acessing data of a patch. It supports variable striding.
Definition: View.h:40
View< double, M+1 > getGhostSliceOn(Face< D, M > f, const std::array< size_t, D - M > &offset) const
Get the gosts slice on a given face.
Definition: PatchArray.h:147
const std::array< int, D > & getStrides() const
Get the strides of the patch in each direction.
Definition: View.h:203
const std::array< int, D+1 > & getStrides() const
Get the strides of the patch in each direction.
Definition: PatchArray.h:174
const std::array< int, D > & getGhostStart() const
Get the coordinate of the first ghost cell element.
Definition: View.h:215
View< double, M+1 > getSliceOn(Face< D, M > f, const std::array< int, D - M > &offset)
Get the slice on a given face.
Definition: PatchArray.h:116
const std::array< int, D+1 > & getGhostStart() const
Get the coordinate of the first ghost cell element.
Definition: PatchArray.h:186
const PatchView< double, D > & getView()
Get the View for the array.
Definition: PatchArray.h:196
The ThunderEgg namespace.
Definition: BiLinearGhostFiller.h:31
const std::array< int, D > & getEnd() const
Get the coordinate of the last element.
Definition: View.h:211
Array for acessing data of a patch. It supports variable striding.
Definition: PatchArray.h:36
const std::array< int, D+1 > & getEnd() const
Get the coordinate of the last element.
Definition: PatchArray.h:182
PatchArray(const std::array< int, D > &lengths, int num_components, int num_ghost_cells)
Construct a new PatchArray object.
Definition: PatchArray.h:55
void set(const std::array< int, D > &coord, T value) const
Set the value at a coordinate to the specified value.
Definition: View.h:174
PatchArray(const PatchArray< D > &other)
Copy constructor.
Definition: PatchArray.h:77
PatchArray()=default
Construct a new PatchArray object of size zero.
const std::array< int, D+1 > & getGhostEnd() const
Get the coordinate of the last ghost cell element.
Definition: PatchArray.h:190
PatchArray< D > & operator=(const PatchArray< D > &other)
Copy assignment.
Definition: PatchArray.h:94
View< const double, M+1 > getSliceOn(Face< D, M > f, const std::array< int, D - M > &offset) const
Get the slice on a given face.
Definition: PatchArray.h:131
Enum-style class for the faces of an n-dimensional cube.
Definition: Face.h:41
const std::array< int, D+1 > & getStart() const
Get the coordinate of the first element.
Definition: PatchArray.h:178
const std::array< int, D > & getGhostEnd() const
Get the coordinate of the last ghost cell element.
Definition: View.h:219
const std::array< int, D > & getStart() const
Get the coordinate of the first element.
Definition: View.h:207