ThunderEgg  1.0.0
ThunderEgg::View< T, D > Class Template Reference

Array for acessing data of a patch. It supports variable striding. More...

#include <View.h>

Inheritance diagram for ThunderEgg::View< T, D >:

Public Types

using T_ptr = typename std::add_pointer< T >::type
 

Public Member Functions

 View ()
 Constructs a view of size 0.
 
 View (T_ptr data, const std::array< int, D > &strides, const std::array< int, D > &ghost_start, const std::array< int, D > &start, const std::array< int, D > &end, const std::array< int, D > &ghost_end)
 Construct a new View object. More...
 
T & operator[] (const std::array< int, D > &coord) const
 Get a reference to the element at the specified coordinate. More...
 
template<class... Types>
T & operator() (Types... args) const
 Get a reference to the element at the specified coordinate. More...
 
void set (const std::array< int, D > &coord, T value) const
 Set the value at a coordinate to the specified value. More...
 
const std::array< int, D > & getStrides () const
 Get the strides of the patch in each direction.
 
const std::array< int, D > & getStart () const
 Get the coordinate of the first element.
 
const std::array< int, D > & getEnd () const
 Get the coordinate of the last element.
 
const std::array< int, D > & getGhostStart () const
 Get the coordinate of the first ghost cell element.
 
const std::array< int, D > & getGhostEnd () const
 Get the coordinate of the last ghost cell element.
 
 operator View< std::add_const_t< T >, D > () const
 

Protected Member Functions

int getIndex (const std::array< int, D > &coord) const
 
T_ptr getData () const
 

Detailed Description

template<typename T, int D>
class ThunderEgg::View< T, D >

Array for acessing data of a patch. It supports variable striding.

Template Parameters
Dnumber of cartesian dimensions

Constructor & Destructor Documentation

◆ View()

template<typename T , int D>
ThunderEgg::View< T, D >::View ( T_ptr  data,
const std::array< int, D > &  strides,
const std::array< int, D > &  ghost_start,
const std::array< int, D > &  start,
const std::array< int, D > &  end,
const std::array< int, D > &  ghost_end 
)
inline

Construct a new View object.

Parameters
datapointer to the first element in the patch (non-ghost cell element)
stridesthe strides in each direction
lengthsthe lengths in each direction
num_ghost_cellsthe number of ghost cells on each side of the patch
ldmthe local data manager for the data

Member Function Documentation

◆ operator()()

template<typename T , int D>
template<class... Types>
T& ThunderEgg::View< T, D >::operator() ( Types...  args) const
inline

Get a reference to the element at the specified coordinate.

for example uasage in 3d is view(ix,iy,iz)

Template Parameters
Typesthe types
Parameters
argsthe coordnate in x,y,z form
Returns
const double& the value

◆ operator[]()

template<typename T , int D>
T& ThunderEgg::View< T, D >::operator[] ( const std::array< int, D > &  coord) const
inline

Get a reference to the element at the specified coordinate.

Parameters
coordthe coordinate
Returns
double& the element

◆ set()

template<typename T , int D>
void ThunderEgg::View< T, D >::set ( const std::array< int, D > &  coord,
value 
) const
inline

Set the value at a coordinate to the specified value.

Parameters
coordthe coordinate
valuethe value

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