Block-Structured AMR Software Framework
amrex::TableData< T, N, ORDER > Class Template Reference

Multi-dimensional array class. More...

#include <AMReX_TableData.H>

Inheritance diagram for amrex::TableData< T, N, ORDER >:
amrex::DataAllocator

Public Types

using value_type = T
 
using table_type = std::conditional_t< N==1, Table1D< T >, std::conditional_t< N==2, Table2D< T, ORDER >, std::conditional_t< N==3, Table3D< T, ORDER >, Table4D< T, ORDER > > > >
 
using const_table_type = std::conditional_t< N==1, Table1D< T const >, std::conditional_t< N==2, Table2D< T const, ORDER >, std::conditional_t< N==3, Table3D< T const, ORDER >, Table4D< T const, ORDER > > > >
 

Public Member Functions

 TableData () noexcept=default
 
 TableData (Arena *ar) noexcept
 
 TableData (Array< int, N > const &lo, Array< int, N > const &hi, Arena *ar=nullptr)
 
 TableData (TableData< T, N, ORDER > const &)=delete
 
TableData< T, N, ORDER > & operator= (TableData< T, N, ORDER > const &)=delete
 
 TableData (TableData< T, N, ORDER > &&rhs) noexcept
 
TableData< T, N, ORDER > & operator= (TableData< T, N, ORDER > &&rhs) noexcept
 
 ~TableData () noexcept
 
constexpr int dim () const noexcept
 
void resize (Array< int, N > const &lo, Array< int, N > const &hi, Arena *ar=nullptr)
 
Long size () const noexcept
 
Array< int, N > const & lo () const noexcept
 
Array< int, N > const & hi () const noexcept
 
void clear () noexcept
 
void copy (TableData< T, N, ORDER > const &rhs) noexcept
 
table_type table () noexcept
 
const_table_type table () const noexcept
 
const_table_type const_table () const noexcept
 
- Public Member Functions inherited from amrex::DataAllocator
 DataAllocator () noexcept=default
 
 DataAllocator (Arena *ar) noexcept
 
void * alloc (std::size_t sz) const noexcept
 
void free (void *pt) const noexcept
 
Arenaarena () const noexcept
 

Private Member Functions

void define ()
 

Private Attributes

T * m_dptr = nullptr
 
Array< int, N > m_lo
 
Array< int, N > m_hi
 
Long m_truesize = 0L
 
bool m_ptr_owner = false
 

Friends

template<class U , int M, Order O>
class TableData
 

Additional Inherited Members

- Public Attributes inherited from amrex::DataAllocator
Arenam_arena = nullptr
 

Detailed Description

template<typename T, int N, Order ORDER = Order::F>
class amrex::TableData< T, N, ORDER >

Multi-dimensional array class.

This class is somewhat similar to FArrayBox/BaseFab. The main difference is the dimension of the array in this class can be 1, 2, 3, or 4, whereas the dimension of FArrayBox/BaseFab is the spatial dimension (AMREX_SPACEDIM) plus a component dimension. Another difference is that this class supports both column-major order (i.e., Fortran order) and row-major order (i.e., C order), whereas FArrayBox/BaseFab is always column-major. Below is an example of using it to store a 3D table of data that is initialized on CPU and is read-only by all GPU threads on the device.

Array<int,3> tlo{0,0,0}; // lower bounds
Array<int,3> thi{100,100,100}; // upper bounds
TableData<Real,3> table_data(tlo, thi);
#ifdef AMREX_USE_GPU
TableData<Real,3> h_table_data(tlo, thi, The_Pinned_Arena());
auto const& h_table = h_table_data.table();
#else
auto const& h_table = table_data.table();
#endif
// Initialize data on the host
for (int k = tlo[0]; k <= thi[0]; ++k) {
for (int j = tlo[1]; j <= thi[1]; ++j) {
for (int i = tlo[2]; i <= thi[2]; ++i) {
h_table(i,j,k) = i + 1.e3*j + 1.e6*k;
}}}
#ifdef AMREX_USE_GPU
// Copy data to GPU memory
table_data.copy(h_table_data);
Gpu::streamSynchronize(); // not needed if the kernel using it is on the same stream
#endif
auto const& table = table_data.const_table(); // const makes it read only
// We can now use table in device lambda.
table_type table() noexcept
Definition: AMReX_TableData.H:604
void streamSynchronize() noexcept
Definition: AMReX_GpuDevice.H:237
Arena * The_Pinned_Arena()
Definition: AMReX_Arena.cpp:649

Member Typedef Documentation

◆ const_table_type

template<typename T , int N, Order ORDER = Order::F>
using amrex::TableData< T, N, ORDER >::const_table_type = std::conditional_t<N==1, Table1D<T const>, std::conditional_t<N==2, Table2D<T const, ORDER>, std::conditional_t<N==3, Table3D<T const, ORDER>, Table4D<T const, ORDER> > > >

◆ table_type

template<typename T , int N, Order ORDER = Order::F>
using amrex::TableData< T, N, ORDER >::table_type = std::conditional_t<N==1, Table1D<T>, std::conditional_t<N==2, Table2D<T, ORDER>, std::conditional_t<N==3, Table3D<T, ORDER>, Table4D<T, ORDER> > > >

◆ value_type

template<typename T , int N, Order ORDER = Order::F>
using amrex::TableData< T, N, ORDER >::value_type = T

Constructor & Destructor Documentation

◆ TableData() [1/5]

template<typename T , int N, Order ORDER = Order::F>
amrex::TableData< T, N, ORDER >::TableData ( )
defaultnoexcept

◆ TableData() [2/5]

template<typename T , int N, Order ORDER = Order::F>
amrex::TableData< T, N, ORDER >::TableData ( Arena ar)
explicitnoexcept

◆ TableData() [3/5]

template<typename T , int N, Order ORDER>
amrex::TableData< T, N, ORDER >::TableData ( Array< int, N > const &  lo,
Array< int, N > const &  hi,
Arena ar = nullptr 
)

◆ TableData() [4/5]

template<typename T , int N, Order ORDER = Order::F>
amrex::TableData< T, N, ORDER >::TableData ( TableData< T, N, ORDER > const &  )
delete

◆ TableData() [5/5]

template<typename T , int N, Order ORDER>
amrex::TableData< T, N, ORDER >::TableData ( TableData< T, N, ORDER > &&  rhs)
noexcept

◆ ~TableData()

template<typename T , int N, Order ORDER>
amrex::TableData< T, N, ORDER >::~TableData
noexcept

Member Function Documentation

◆ clear()

template<typename T , int N, Order ORDER>
void amrex::TableData< T, N, ORDER >::clear
noexcept

◆ const_table()

template<typename T , int N, Order ORDER>
TableData< T, N, ORDER >::const_table_type amrex::TableData< T, N, ORDER >::const_table
noexcept

◆ copy()

template<typename T , int N, Order ORDER>
void amrex::TableData< T, N, ORDER >::copy ( TableData< T, N, ORDER > const &  rhs)
noexcept

◆ define()

template<typename T , int N, Order ORDER>
void amrex::TableData< T, N, ORDER >::define
private

◆ dim()

template<typename T , int N, Order ORDER = Order::F>
constexpr int amrex::TableData< T, N, ORDER >::dim ( ) const
inlineconstexprnoexcept

◆ hi()

template<typename T , int N, Order ORDER = Order::F>
Array<int,N> const& amrex::TableData< T, N, ORDER >::hi ( ) const
inlinenoexcept

◆ lo()

template<typename T , int N, Order ORDER = Order::F>
Array<int,N> const& amrex::TableData< T, N, ORDER >::lo ( ) const
inlinenoexcept

◆ operator=() [1/2]

template<typename T , int N, Order ORDER>
TableData< T, N, ORDER > & amrex::TableData< T, N, ORDER >::operator= ( TableData< T, N, ORDER > &&  rhs)
noexcept

◆ operator=() [2/2]

template<typename T , int N, Order ORDER = Order::F>
TableData<T,N,ORDER>& amrex::TableData< T, N, ORDER >::operator= ( TableData< T, N, ORDER > const &  )
delete

◆ resize()

template<typename T , int N, Order ORDER>
void amrex::TableData< T, N, ORDER >::resize ( Array< int, N > const &  lo,
Array< int, N > const &  hi,
Arena ar = nullptr 
)

◆ size()

template<typename T , int N, Order ORDER>
Long amrex::TableData< T, N, ORDER >::size
noexcept

◆ table() [1/2]

template<typename T , int N, Order ORDER>
TableData< T, N, ORDER >::const_table_type amrex::TableData< T, N, ORDER >::table
noexcept

◆ table() [2/2]

template<typename T , int N, Order ORDER>
TableData< T, N, ORDER >::table_type amrex::TableData< T, N, ORDER >::table
noexcept

Friends And Related Function Documentation

◆ TableData

template<typename T , int N, Order ORDER = Order::F>
template<class U , int M, Order O>
friend class TableData
friend

Member Data Documentation

◆ m_dptr

template<typename T , int N, Order ORDER = Order::F>
T* amrex::TableData< T, N, ORDER >::m_dptr = nullptr
private

◆ m_hi

template<typename T , int N, Order ORDER = Order::F>
Array<int,N> amrex::TableData< T, N, ORDER >::m_hi
private

◆ m_lo

template<typename T , int N, Order ORDER = Order::F>
Array<int,N> amrex::TableData< T, N, ORDER >::m_lo
private

◆ m_ptr_owner

template<typename T , int N, Order ORDER = Order::F>
bool amrex::TableData< T, N, ORDER >::m_ptr_owner = false
private

◆ m_truesize

template<typename T , int N, Order ORDER = Order::F>
Long amrex::TableData< T, N, ORDER >::m_truesize = 0L
private

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