4#include "../kokkos/kokkos_wrapper.hpp"
14template <
typename ScalarType >
17template <
typename ScalarType >
20template <
typename ScalarType >
23template <
typename ScalarType >
26template <
typename ScalarType >
29template <
typename ScalarType >
32template <
typename ScalarType,
int VecDim >
35template <
typename ScalarType,
int VecDim >
38template <
typename ScalarType,
int VecDim >
41template <
typename ScalarType,
int VecDim >
49template <
typename ScalarType,
int VecDim >
55 static constexpr int rank = 5;
63 for (
int d = 0; d < VecDim; ++d )
65 label +
"_d" + std::to_string( d ), s0, s1, s2, s3 );
68 KOKKOS_INLINE_FUNCTION
69 ScalarType&
operator()(
int i0,
int i1,
int i2,
int i3,
int d )
const
71 return comp_[d]( i0, i1, i2, i3 );
74 KOKKOS_INLINE_FUNCTION
78 return comp_[0].extent( i );
79 return static_cast< decltype(
comp_[0].
extent( 0 ) )
>( VecDim );
85 std::string l =
comp_[0].label();
86 auto pos = l.rfind(
"_d0" );
87 return ( pos != std::string::npos ) ? l.substr( 0, pos ) : l;
96 ScalarType&
operator()(
int i0,
int i1,
int i2,
int i3,
int d )
98 return comp_[d]( i0, i1, i2, i3 );
101 const ScalarType&
operator()(
int i0,
int i1,
int i2,
int i3,
int d )
const
103 return comp_[d]( i0, i1, i2, i3 );
110 return static_cast< decltype(
comp_[0].
extent( 0 ) )
>( VecDim );
116template <
typename ScalarType,
int VecDim >
117typename Grid4DDataVec< ScalarType, VecDim >::HostMirror
121 for (
int d = 0; d < VecDim; ++d )
122 result.
comp_[d] = Kokkos::create_mirror( space, src.
comp_[d] );
127template <
typename ScalarType >
128typename Grid4DDataScalar< ScalarType >::HostMirror
131 return Kokkos::create_mirror( space, src );
135template <
typename ScalarType,
int VecDim >
140 for (
int d = 0; d < VecDim; ++d )
141 Kokkos::deep_copy( dst.
comp_[d], src.
comp_[d] );
145template <
typename ScalarType,
int VecDim >
150 for (
int d = 0; d < VecDim; ++d )
151 Kokkos::deep_copy( dst.
comp_[d], src.
comp_[d] );
155template <
typename ScalarType >
160 Kokkos::deep_copy( dst, src );
164template <
typename ScalarType >
169 Kokkos::deep_copy( dst, src );
172template <
typename ScalarType,
int Rows,
int Cols,
int NumMatrices >
175template <
typename Gr
idDataType >
179 std::is_same_v< GridDataType, Grid0DDataScalar< typename GridDataType::value_type > > ||
180 std::is_same_v< GridDataType, Grid1DDataScalar< typename GridDataType::value_type > > ||
181 std::is_same_v< GridDataType, Grid2DDataScalar< typename GridDataType::value_type > > ||
182 std::is_same_v< GridDataType, Grid3DDataScalar< typename GridDataType::value_type > > ||
183 std::is_same_v< GridDataType, Grid4DDataScalar< typename GridDataType::value_type > > )
189 std::is_same_v< GridDataType, Grid0DDataVec< typename GridDataType::value_type, 1 > > ||
190 std::is_same_v< GridDataType, Grid1DDataVec< typename GridDataType::value_type, 1 > > ||
191 std::is_same_v< GridDataType, Grid2DDataVec< typename GridDataType::value_type, 1 > > ||
192 std::is_same_v< GridDataType, Grid3DDataVec< typename GridDataType::value_type, 1 > > ||
193 std::is_same_v< GridDataType, Grid4DDataVec< typename GridDataType::value_type, 1 > > )
199 std::is_same_v< GridDataType, Grid0DDataVec< typename GridDataType::value_type, 2 > > ||
200 std::is_same_v< GridDataType, Grid1DDataVec< typename GridDataType::value_type, 2 > > ||
201 std::is_same_v< GridDataType, Grid2DDataVec< typename GridDataType::value_type, 2 > > ||
202 std::is_same_v< GridDataType, Grid3DDataVec< typename GridDataType::value_type, 2 > > ||
203 std::is_same_v< GridDataType, Grid4DDataVec< typename GridDataType::value_type, 2 > > )
209 std::is_same_v< GridDataType, Grid0DDataVec< typename GridDataType::value_type, 3 > > ||
210 std::is_same_v< GridDataType, Grid1DDataVec< typename GridDataType::value_type, 3 > > ||
211 std::is_same_v< GridDataType, Grid2DDataVec< typename GridDataType::value_type, 3 > > ||
212 std::is_same_v< GridDataType, Grid3DDataVec< typename GridDataType::value_type, 3 > > ||
213 std::is_same_v< GridDataType, Grid4DDataVec< typename GridDataType::value_type, 3 > > )
236 return (
static_cast< int >( x ) << 4 ) | (
static_cast< int >( y ) << 2 ) | (
static_cast< int >( r ) << 0 );
316template <
typename BoundaryType >
320 std::is_same_v< BoundaryType, BoundaryVertex > || std::is_same_v< BoundaryType, BoundaryEdge > ||
321 std::is_same_v< BoundaryType, BoundaryFace > );
323 return static_cast< BoundaryPosition >( (
static_cast< int >( boundary_type ) & 0b110000 ) >> 4 );
326template <
typename BoundaryType >
330 std::is_same_v< BoundaryType, BoundaryVertex > || std::is_same_v< BoundaryType, BoundaryEdge > ||
331 std::is_same_v< BoundaryType, BoundaryFace > );
333 return static_cast< BoundaryPosition >( (
static_cast< int >( boundary_type ) & 0b001100 ) >> 2 );
336template <
typename BoundaryType >
340 std::is_same_v< BoundaryType, BoundaryVertex > || std::is_same_v< BoundaryType, BoundaryEdge > ||
341 std::is_same_v< BoundaryType, BoundaryFace > );
343 return static_cast< BoundaryPosition >( (
static_cast< int >( boundary_type ) & 0b000011 ) >> 0 );
424 return "<unknown LocalBoundaryVertex>";
457 return "<unknown LocalBoundaryEdge>";
478 return "<unknown LocalBoundaryFace>";
Definition bit_masks.hpp:8
Kokkos::View< ScalarType, Layout > Grid0DDataScalar
Definition grid_types.hpp:15
Kokkos::View< ScalarType *****, Layout > Grid5DDataScalar
Definition grid_types.hpp:30
Grid4DDataVec< ScalarType, VecDim >::HostMirror create_mirror(Kokkos::HostSpace space, const Grid4DDataVec< ScalarType, VecDim > &src)
Create a host mirror for Grid4DDataVec.
Definition grid_types.hpp:118
constexpr bool is_edge_boundary_radial(const BoundaryEdge id)
Definition grid_types.hpp:346
Kokkos::View< dense::Mat< ScalarType, Rows, Cols > ****[NumMatrices], Layout > Grid4DDataMatrices
Definition grid_types.hpp:173
Kokkos::View< ScalarType ***[VecDim], Layout > Grid3DDataVec
Definition grid_types.hpp:42
BoundaryPosition
Enum for encoding the boundary type tuples (in BoundaryVertex, BoundaryEdge, BoundaryFace).
Definition grid_types.hpp:223
Kokkos::View< ScalarType ***, Layout > Grid3DDataScalar
Definition grid_types.hpp:24
BoundaryVertex
Enum for identification of the 8 boundary vertices of a subdomain.
Definition grid_types.hpp:248
constexpr std::array all_boundary_faces
Definition grid_types.hpp:393
BoundaryDirection
Enum for the iteration direction at a boundary.
Definition grid_types.hpp:311
constexpr std::array all_boundary_vertices
Definition grid_types.hpp:366
std::ostream & operator<<(std::ostream &os, BoundaryVertex v)
Definition grid_types.hpp:482
constexpr std::array all_boundary_edges
Definition grid_types.hpp:376
Kokkos::LayoutRight Layout
Definition grid_types.hpp:12
Kokkos::View< ScalarType **[VecDim], Layout > Grid2DDataVec
Definition grid_types.hpp:39
constexpr int grid_data_vec_dim()
Definition grid_types.hpp:176
Kokkos::View< ScalarType *[VecDim], Layout > Grid1DDataVec
Definition grid_types.hpp:36
constexpr int boundary_position_encoding(const BoundaryPosition x, const BoundaryPosition y, const BoundaryPosition r)
Definition grid_types.hpp:234
constexpr BoundaryPosition boundary_position_from_boundary_type_y(const BoundaryType &boundary_type)
Definition grid_types.hpp:327
constexpr bool is_face_boundary_normal_to_radial_direction(const BoundaryFace id)
Definition grid_types.hpp:352
std::string to_string(BoundaryVertex v)
Definition grid_types.hpp:403
constexpr BoundaryPosition boundary_position_from_boundary_type_r(const BoundaryType &boundary_type)
Definition grid_types.hpp:337
Kokkos::View< ScalarType[VecDim], Layout > Grid0DDataVec
Definition grid_types.hpp:33
constexpr BoundaryVertex other_side_r(BoundaryVertex boundary_vertex)
Definition grid_types.hpp:357
BoundaryFace
Enum for identification of the 6 boundary faces of a subdomain.
Definition grid_types.hpp:297
Kokkos::View< ScalarType ****, Layout > Grid4DDataScalar
Definition grid_types.hpp:27
constexpr BoundaryPosition boundary_position_from_boundary_type_x(const BoundaryType &boundary_type)
Definition grid_types.hpp:317
void deep_copy(typename Grid4DDataVec< ScalarType, VecDim >::HostMirror &dst, const Grid4DDataVec< ScalarType, VecDim > &src)
Deep copy from device Grid4DDataVec to host mirror.
Definition grid_types.hpp:136
Kokkos::View< ScalarType *, Layout > Grid1DDataScalar
Definition grid_types.hpp:18
Kokkos::View< ScalarType **, Layout > Grid2DDataScalar
Definition grid_types.hpp:21
BoundaryEdge
Enum for identification of the 12 boundary edges of a subdomain.
Definition grid_types.hpp:269
Host mirror type for I/O.
Definition grid_types.hpp:92
Grid4DDataScalar< ScalarType >::HostMirror comp_[VecDim]
Definition grid_types.hpp:94
const ScalarType & operator()(int i0, int i1, int i2, int i3, int d) const
Definition grid_types.hpp:101
ScalarType & operator()(int i0, int i1, int i2, int i3, int d)
Definition grid_types.hpp:96
ScalarType value_type
Definition grid_types.hpp:93
auto extent(int i) const
Definition grid_types.hpp:106
SoA (Structure-of-Arrays) 4D vector grid data.
Definition grid_types.hpp:51
Grid4DDataScalar< ScalarType > comp_[VecDim]
Definition grid_types.hpp:57
auto extent(int i) const
Definition grid_types.hpp:75
typename Grid4DDataScalar< ScalarType >::memory_space memory_space
Definition grid_types.hpp:53
static constexpr int rank
Definition grid_types.hpp:55
static constexpr int vec_dim
Definition grid_types.hpp:54
ScalarType value_type
Definition grid_types.hpp:52
ScalarType & operator()(int i0, int i1, int i2, int i3, int d) const
Definition grid_types.hpp:69
Grid4DDataVec(const std::string &label, int s0, int s1, int s2, int s3)
Definition grid_types.hpp:61
std::string label() const
Get the label (derived from first component by stripping "_d0" suffix).
Definition grid_types.hpp:83