Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::CellData< T > Class Template Reference

Lightweight accessor for data associated with a single cell. More...

#include <AMReX_Array4.H>

Public Member Functions

__host__ __device__ constexpr CellData (T *a_p, Long a_stride, int a_ncomp)
 Construct a CellData.
 
template<class U = T, std::enable_if_t< std::is_const_v< U >, int > = 0>
__host__ __device__ constexpr CellData (CellData< std::remove_const_t< T > > const &rhs) noexcept
 Construct a const CellData from a non-const CellData.
 
__host__ __device__ operator bool () const noexcept
 Check whether the accessor refers to valid data.
 
__host__ __device__ int nComp () const noexcept
 Return the number of components.
 
template<class U = T, std::enable_if_t<!std::is_void_v< U >, int > = 0>
__host__ __device__ U & operator[] (int n) const noexcept
 Access the n-th component of the cell.
 

Detailed Description

template<typename T>
class amrex::CellData< T >

Lightweight accessor for data associated with a single cell.

Template Parameters
TData type. May be const-qualified.

CellData provides a non-owning view of data associated with a single cell in an Array4. It's typically created by the Array4::cellData member function.

Constructor & Destructor Documentation

◆ CellData() [1/2]

template<typename T >
__host__ __device__ constexpr amrex::CellData< T >::CellData ( T *  a_p,
Long  a_stride,
int  a_ncomp 
)
inlineconstexpr

Construct a CellData.

Parameters
a_pdata Pointer pointing to component 0 of the cell data
a_strideComponent stride, i.e., the distance (in number of elements, not bytes) between successive components (i,j,k,n) and (i,j,k,n+1) of Array4.
a_ncompnumber of components.

◆ CellData() [2/2]

template<typename T >
template<class U = T, std::enable_if_t< std::is_const_v< U >, int > = 0>
__host__ __device__ constexpr amrex::CellData< T >::CellData ( CellData< std::remove_const_t< T > > const &  rhs)
inlineconstexprnoexcept

Construct a const CellData from a non-const CellData.

This enables implicit conversion from CellData<T> to CellData<const T>.

Parameters
rhsSource CellData object.

Member Function Documentation

◆ nComp()

template<typename T >
__host__ __device__ int amrex::CellData< T >::nComp ( ) const
inlinenoexcept

Return the number of components.

◆ operator bool()

template<typename T >
__host__ __device__ amrex::CellData< T >::operator bool ( ) const
inlineexplicitnoexcept

Check whether the accessor refers to valid data.

Returns
true if the internal pointer is non-null, otherwise false.

◆ operator[]()

template<typename T >
template<class U = T, std::enable_if_t<!std::is_void_v< U >, int > = 0>
__host__ __device__ U & amrex::CellData< T >::operator[] ( int  n) const
inlinenoexcept

Access the n-th component of the cell.

Parameters
nComponent index.
Returns
Reference to component n.
Warning
No bounds checking is performed, unless either AMREX_DEBUG or AMREX_BOUND_CHECK is defined. The caller is responsible for ensuring that n is in the range [0, ncomp).

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