Cabana 0.8.0-dev
 
Loading...
Searching...
No Matches
Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType > Class Template Reference

Sparse array of field data on the local sparse mesh; Array data is stored in AoSoA manner, with each tile being the SoA element. More...

#include <Cabana_Grid_SparseArray.hpp>

Public Types

using sparse_array_type
 self type
 
using memory_space = typename MemorySpace::memory_space
 Memory space.
 
using execution_space = typename memory_space::execution_space
 Default execution space.
 
using size_type = typename memory_space::size_type
 Memory space size type.
 
using entity_type = EntityType
 Array entity type (node, cell, face, edge).
 
using mesh_type = MeshType
 Mesh type.
 
using sparse_map_type = SparseMapType
 Sparse map type.
 
using member_types = DataTypes
 DataTypes Data types (Cabana::MemberTypes).
 
using aosoa_type = Cabana::AoSoA<member_types, memory_space, vector_length>
 AosoA type.
 
using soa_type = Cabana::SoA<member_types, vector_length>
 SoA Type.
 
using tuple_type = Cabana::Tuple<member_types>
 AoSoA tuple type.
 
using array_layout
 Sparse array layout type.
 

Public Member Functions

 SparseArray (const std::string label, array_layout layout)
 (Host) Constructor
 
aosoa_typeaosoa ()
 Get AoSoA reference.
 
std::string label () const
 Get array label (description)
 
array_layoutlayout ()
 Get reference to the array layout (device accessible)
 
const array_layoutlayout () const
 Get const reference to the array layout (device accessible)
 
void resize (const size_type n)
 Resize the AoSoA array according to the input.
 
void resize ()
 Reserve the AoSoA array according to the sparse map info in layout.
 
void reserve (const size_type n)
 Reserve the AoSoA array according to the input.
 
void reserveFromMap (const double factor=1.2)
 Reserve the AoSoA array according to the sparse map info in layout.
 
void shrinkToFit ()
 Shrink allocation to fit the valid size.
 
void clear ()
 
KOKKOS_FUNCTION size_type capacity ()
 Get AoSoA capacity.
 
KOKKOS_FUNCTION size_type size () const
 Get AoSoA size (valid number of elements)
 
KOKKOS_FUNCTION bool empty () const
 Test if the AoSoA array is empty.
 
KOKKOS_FORCEINLINE_FUNCTION size_type numSoA () const
 Get the number of SoA inside an AoSoA structure.
 
KOKKOS_FORCEINLINE_FUNCTION size_type arraySize (const size_type s) const
 Get data array size at a given struct member index.
 
template<class PositionSliceType>
void registerSparseGrid (PositionSliceType &positions, int particle_num, const int p2g_radius=1)
 Register valid grids in sparse map according to input particle positions.
 
KOKKOS_FORCEINLINE_FUNCTION soa_typeaccessTile (const int tile_i, const int tile_j, const int tile_k) const
 (Device) Access tile SoA from tile-related information
 
template<typename Value>
KOKKOS_FORCEINLINE_FUNCTION soa_typeaccessTile (const Value tile_id) const
 (Device) Access tile SoA from tile-related information
 
KOKKOS_FORCEINLINE_FUNCTION soa_typeaccessTileFromCell (const int cell_i, const int cell_j, const int cell_k) const
 (Device) Access tile SoA from cell-related information
 
template<typename Key>
KOKKOS_FORCEINLINE_FUNCTION tuple_type getTuple (const Key tile_key, const int cell_local_id) const
 Access AoSoA tuple from tile key and local cell id.
 
template<std::size_t M, typename... Indices>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > get (const Kokkos::Array< int, 3 > cell_ijk, Indices &&... ids) const
 Access element from cell IJK, access corresponding element's channels with extra indices.
 
template<std::size_t M>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > get (const Kokkos::Array< int, 3 > cell_ijk) const
 Access element from cell IJK.
 
template<std::size_t M, typename... Indices>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > get (const Kokkos::Array< int, 3 > tile_ijk, const Kokkos::Array< int, 3 > local_cell_ijk, Indices &&... ids) const
 Access element in a hierarchical manner, from tile IJK and then local cell IJK, access corresponding element's channels with extra indices.
 
template<std::size_t M>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > get (const Kokkos::Array< int, 3 > tile_ijk, const Kokkos::Array< int, 3 > local_cell_ijk) const
 Access element in a hierarchical manner, from tile IJK and then local cell IJK.
 
template<std::size_t M, typename... Indices>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > get (const int tile_id, const Kokkos::Array< int, 3 > local_cell_ijk, Indices &&... ids) const
 Access element in a hierarchical manner, from 1D tile ID and then local cell IJK, access corresponding element's channels with extra indices.
 
template<std::size_t M>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > get (const int tile_id, const Kokkos::Array< int, 3 > local_cell_ijk) const
 Access element in a hierarchical manner, from 1D tile ID and then local cell IJK.
 
template<std::size_t M, typename... Indices>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > get (const int tile_id, const int cell_id, Indices &&... ids) const
 Access element in a hierarchical manner, from 1D tile ID and then 1D local cell ID, access corresponding element's channels with extra indices.
 
template<std::size_t M>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > get (const int tile_id, const int cell_id) const
 Access element in a hierarchical manner, from 1D tile ID and then 1D local cell ID.
 

Static Public Attributes

static constexpr std::size_t num_space_dim = mesh_type::num_space_dim
 Dimension number.
 
static constexpr unsigned long long cell_bits_per_tile
 Least bits required to represent all cells inside a tile.
 
static constexpr unsigned long long cell_mask_per_tile
 Cell ID mask inside a tile.
 
static constexpr int vector_length = sparse_map_type::cell_num_per_tile
 AoSoA vector length = cell number in each tile.
 

Detailed Description

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
class Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >

Sparse array of field data on the local sparse mesh; Array data is stored in AoSoA manner, with each tile being the SoA element.

Template Parameters
DataTypesData types (Cabana::MemberTypes).
MemorySpaceKokkos memory space.
EntityTypeArray entity type (node, cell, face, edge).
MeshTypeMesh type (sparse mesh).
SparseMapTypeSparse map type.

Member Typedef Documentation

◆ array_layout

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
using Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::array_layout
Initial value:
Entity layout for sparse array data on the local sparse mesh.
Definition Cabana_Grid_SparseArray.hpp:54
SparseMapType sparse_map_type
Sparse map type.
Definition Cabana_Grid_SparseArray.hpp:340
EntityType entity_type
Array entity type (node, cell, face, edge).
Definition Cabana_Grid_SparseArray.hpp:336
MeshType mesh_type
Mesh type.
Definition Cabana_Grid_SparseArray.hpp:338
DataTypes member_types
DataTypes Data types (Cabana::MemberTypes).
Definition Cabana_Grid_SparseArray.hpp:352

Sparse array layout type.

◆ sparse_array_type

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
using Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::sparse_array_type
Initial value:
SparseArray<DataTypes, MemorySpace, EntityType,
MeshType, SparseMapType>
SparseArray(const std::string label, array_layout layout)
(Host) Constructor
Definition Cabana_Grid_SparseArray.hpp:370

self type

Constructor & Destructor Documentation

◆ SparseArray()

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::SparseArray ( const std::string label,
array_layout layout )
inline

(Host) Constructor

Parameters
labelarray description
layoutsparse array layout

Member Function Documentation

◆ accessTile() [1/2]

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
KOKKOS_FORCEINLINE_FUNCTION soa_type & Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::accessTile ( const int tile_i,
const int tile_j,
const int tile_k ) const
inline

(Device) Access tile SoA from tile-related information

Parameters
tile_i,tile_j,tile_kTile index in each dimension

◆ accessTile() [2/2]

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
template<typename Value>
KOKKOS_FORCEINLINE_FUNCTION soa_type & Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::accessTile ( const Value tile_id) const
inline

(Device) Access tile SoA from tile-related information

Parameters
tile_id1D Tile ID (registered ID in sparse map, which is also the real allocation Id inside the AoS)

◆ accessTileFromCell()

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
KOKKOS_FORCEINLINE_FUNCTION soa_type & Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::accessTileFromCell ( const int cell_i,
const int cell_j,
const int cell_k ) const
inline

(Device) Access tile SoA from cell-related information

Parameters
cell_i,cell_j,cell_kCell index in each dimension

◆ clear()

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
void Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::clear ( )
inline

Clear sparse array, including resize valid AoSoA size to 0 and clear sparse layout

◆ get() [1/8]

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
template<std::size_t M>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::get ( const int tile_id,
const int cell_id ) const
inline

Access element in a hierarchical manner, from 1D tile ID and then 1D local cell ID.

Parameters
tile_idthe 1D Tile ID
cell_idthe 1D Local Cell ID

◆ get() [2/8]

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
template<std::size_t M, typename... Indices>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::get ( const int tile_id,
const int cell_id,
Indices &&... ids ) const
inline

Access element in a hierarchical manner, from 1D tile ID and then 1D local cell ID, access corresponding element's channels with extra indices.

Parameters
tile_idthe 1D Tile ID
cell_idthe 1D Local Cell ID
idsIds to access channels inside a data member/element

◆ get() [3/8]

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
template<std::size_t M>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::get ( const int tile_id,
const Kokkos::Array< int, 3 > local_cell_ijk ) const
inline

Access element in a hierarchical manner, from 1D tile ID and then local cell IJK.

Parameters
tile_idthe 1D Tile ID
local_cell_ijkLocal Cell ID in each dimension

◆ get() [4/8]

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
template<std::size_t M, typename... Indices>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::get ( const int tile_id,
const Kokkos::Array< int, 3 > local_cell_ijk,
Indices &&... ids ) const
inline

Access element in a hierarchical manner, from 1D tile ID and then local cell IJK, access corresponding element's channels with extra indices.

Parameters
tile_idthe 1D Tile ID
local_cell_ijkLocal Cell ID in each dimension
idsIds to access channels inside a data member/element

◆ get() [5/8]

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
template<std::size_t M>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::get ( const Kokkos::Array< int, 3 > cell_ijk) const
inline

Access element from cell IJK.

Parameters
cell_ijkCell ID in each dimension

◆ get() [6/8]

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
template<std::size_t M, typename... Indices>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::get ( const Kokkos::Array< int, 3 > cell_ijk,
Indices &&... ids ) const
inline

Access element from cell IJK, access corresponding element's channels with extra indices.

Parameters
cell_ijkCell ID in each dimension
idsIds to access channels inside a data member/element

◆ get() [7/8]

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
template<std::size_t M>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::get ( const Kokkos::Array< int, 3 > tile_ijk,
const Kokkos::Array< int, 3 > local_cell_ijk ) const
inline

Access element in a hierarchical manner, from tile IJK and then local cell IJK.

Parameters
tile_ijkTile ID in each dimension
local_cell_ijkLocal Cell ID in each dimension

◆ get() [8/8]

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
template<std::size_t M, typename... Indices>
KOKKOS_FORCEINLINE_FUNCTION soa_type::template member_reference_type< M > Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::get ( const Kokkos::Array< int, 3 > tile_ijk,
const Kokkos::Array< int, 3 > local_cell_ijk,
Indices &&... ids ) const
inline

Access element in a hierarchical manner, from tile IJK and then local cell IJK, access corresponding element's channels with extra indices.

Parameters
tile_ijkTile ID in each dimension
local_cell_ijkLocal Cell ID in each dimension
idsIds to access channels inside a data member/element

◆ getTuple()

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
template<typename Key>
KOKKOS_FORCEINLINE_FUNCTION tuple_type Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::getTuple ( const Key tile_key,
const int cell_local_id ) const
inline

Access AoSoA tuple from tile key and local cell id.

Parameters
tile_keyTile Key inside sparse map
cell_local_idlocal Cell ID inside the tile

◆ label()

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
std::string Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::label ( ) const
inline

Get array label (description)

Returns
Array label (description)

◆ registerSparseGrid()

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
template<class PositionSliceType>
void Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::registerSparseGrid ( PositionSliceType & positions,
int particle_num,
const int p2g_radius = 1 )
inline

Register valid grids in sparse map according to input particle positions.

Parameters
positionsInput particle positions.
particle_numNumber of valid particles inside positions
p2g_radiusThe half range of grids that will be influenced by each particle, depending on the interpolation kernel

◆ reserve()

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
void Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::reserve ( const size_type n)
inline

Reserve the AoSoA array according to the input.

Parameters
nTarget reserved size.

◆ reserveFromMap()

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
void Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::reserveFromMap ( const double factor = 1.2)
inline

Reserve the AoSoA array according to the sparse map info in layout.

Parameters
factorscale up the real size as reserved space

◆ resize()

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
void Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::resize ( const size_type n)
inline

Resize the AoSoA array according to the input.

Parameters
nTarget size.

Member Data Documentation

◆ cell_bits_per_tile

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
unsigned long long Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::cell_bits_per_tile
staticconstexpr
Initial value:
=
sparse_map_type::cell_bits_per_tile

Least bits required to represent all cells inside a tile.

◆ cell_mask_per_tile

template<class DataTypes, class MemorySpace, class EntityType, class MeshType, class SparseMapType>
unsigned long long Cabana::Grid::Experimental::SparseArray< DataTypes, MemorySpace, EntityType, MeshType, SparseMapType >::cell_mask_per_tile
staticconstexpr
Initial value:
=
sparse_map_type::cell_mask_per_tile

Cell ID mask inside a tile.


The documentation for this class was generated from the following file: