File BaseState.H

Functions

template<typename T> AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BaseStateArray< T > makeBaseStateArray (T *dptr, const int num_levs=1, const int length=1, const int ncomp=1) noexcept

create a BaseStateArray

template<class T>
BaseState<T> operator+(const T val, const BaseState<T> &p)
template<class T>
BaseState<T> operator+(const BaseState<T> &lhs, const BaseState<T> &rhs)
template<class T>
BaseState<T> operator-(const T val, const BaseState<T> &p)
template<class T>
BaseState<T> operator-(const BaseState<T> &lhs, const BaseState<T> &rhs)
template<class T>
BaseState<T> operator*(const T val, const BaseState<T> &p)
template<class T>
BaseState<T> operator*(const BaseState<T> &lhs, const BaseState<T> &rhs)
template<class T>
BaseState<T> operator/(const T val, const BaseState<T> &p)
template<class T>
BaseState<T> operator/(const BaseState<T> &lhs, const BaseState<T> &rhs)
template<class T>
bool operator==(const BaseState<T> &lhs, const BaseState<T> &rhs)
template<class T>
bool operator!=(const BaseState<T> &lhs, const BaseState<T> &rhs)
template<typename T>
struct BaseStateArray
#include <BaseState.H>

Public Functions

inline constexpr AMREX_GPU_HOST_DEVICE BaseStateArray() noexcept

default constructor

inline constexpr AMREX_GPU_HOST_DEVICE BaseStateArray(BaseStateArray<T> const &rhs) noexcept

copy constructor

AMREX_GPU_HOST_DEVICE ~BaseStateArray() = default

destructor

AMREX_GPU_HOST_DEVICE BaseStateArray & operator= (const BaseStateArray< T > &other)=delete
AMREX_GPU_HOST_DEVICE BaseStateArray(BaseStateArray<T> &&other) = delete
AMREX_GPU_HOST_DEVICE BaseStateArray & operator= (BaseStateArray< T > &&other)=delete
inline constexpr AMREX_GPU_HOST_DEVICE BaseStateArray(T *ptr, const int num_levs = 1, const int length = 1, const int ncomp = 1) noexcept

initialize from pointer

inline AMREX_GPU_HOST_DEVICE void init (T *ptr, const int num_levs=1, const int length=1, const int ncomp=1) noexcept
inline void init(BaseState<T> &base_state) noexcept
inline explicit AMREX_GPU_HOST_DEVICE operator bool() const noexcept
inline AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T & operator() (const int lev, const int i, const int n=0) const noexcept

access elements. If only 2 arguments are passed in, component is set to 0

inline AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T & operator() (const int i) const noexcept

if access using only one index, then this ignores the underlying data structure. Useful for e.g. applying the same operation to all data.

inline AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T & operator[] (int i) noexcept
inline AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const T & operator[] (const int i) const noexcept
inline AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T * ptr (int lev, int i=0, int n=0) const noexcept
inline AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T * dataPtr () noexcept
inline AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nLevels () const noexcept

number of levels in base

inline AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int length () const noexcept

number of cells in base

inline AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nComp () const noexcept

number of components

Public Members

T *AMREX_RESTRICT dptr
int nlev
int len
int nvar
template<class T>
class BaseState
#include <BaseState.H>

Public Functions

inline BaseState() noexcept
explicit BaseState(const int num_levs, const int length = 1, const int ncomp = 1, const T val = T())
BaseState(const amrex::Gpu::ManagedVector<T> &src, const int num_levs, const int length = 1, const int ncomp = 1)

create a BaseState object from an existing Fortran-friendly base state

BaseState(const amrex::Vector<T> &src, const int num_levs, const int length = 1, const int ncomp = 1)
BaseState(const BaseState<T> &src)

copy constructor. This makes a deep copy of the src.

~BaseState() = default
BaseState &operator=(const BaseState<T> &src) = delete
BaseState(BaseState<T> &&src) = default
BaseState &operator=(BaseState<T> &&src) = delete
inline AMREX_FORCE_INLINE BaseStateArray< T const  > array () const noexcept

return a BaseStateArray object to allow for accessing the underlying data

inline AMREX_FORCE_INLINE BaseStateArray< T > array () noexcept

return a BaseStateArray object to allow for accessing the underlying data

inline AMREX_FORCE_INLINE BaseStateArray< const T > const_array () const noexcept
inline AMREX_FORCE_INLINE T array (const int i) noexcept

return ith element of underlying data array

void define(const int num_levs, const int length = 1, const int ncomp = 1, const T val = T())

allocate memory for the BaseState

void resize(const int num_levs, const int length = 1, const int ncomp = 1, const T val = T())
void setVal(const T &val)

set to some scalar value

void setVal(const int comp, const T &val)

set the comp’th component to some scalar value

inline AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nLevels () const noexcept

number of levels in base

inline AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int length () const noexcept

number of cells in base

inline AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nComp () const noexcept

number of components

void copy(const BaseState<T> &src)

deep copy

void copy(const BaseStateArray<T> src)
void copy(const amrex::Gpu::ManagedVector<T> &src)
void copy(const amrex::Vector<T> &src)
void toVector(amrex::Vector<T> &vec) const
void toVector(amrex::Gpu::ManagedVector<T> &vec) const
void swap(BaseState<T> &src) noexcept

swap the data with src

inline T *dataPtr() noexcept
inline AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T * dataPtr () const noexcept
BaseState<T> &operator+=(const T val)
BaseState<T> &operator+=(const BaseState<T> &rhs)
BaseState<T> &operator-=(const T val)
BaseState<T> &operator-=(const BaseState<T> &rhs)
BaseState<T> &operator*=(const T val)
BaseState<T> &operator*=(const BaseState<T> &rhs)
BaseState<T> operator/(const T val)
BaseState<T> &operator/=(const T val)
BaseState<T> operator/(const T val) const noexcept
BaseState<T> &operator/=(const BaseState<T> &rhs)
BaseState(const int, const int, const int, const bool) = delete

make sure that this class is never instantiated with bool

Protected Attributes

amrex::Gpu::ManagedVector<T> base_data
int nlev
int len
int nvar

Friends

template<class U>
friend BaseState<U> operator+(const U val, const BaseState<U> &p)

scalar addition to the whole base state

template<class U>
friend BaseState<U> operator+(const BaseState<U> &lhs, const BaseState<U> &rhs)

element-wise addition

template<class U>
friend BaseState<U> operator-(const U val, const BaseState<U> &p)

scalar subtraction from the whole base state

template<class U>
friend BaseState<U> operator-(const BaseState<U> &lhs, const BaseState<U> &rhs)

element-wise subtraction

template<class U>
friend BaseState<U> operator*(const U val, const BaseState<U> &p)

scalar multiplication of the whole base state

template<class U>
friend BaseState<U> operator*(const BaseState<U> &lhs, const BaseState<U> &rhs)

element-wise multiplication

template<class U>
friend BaseState<U> operator/(const U val, const BaseState<U> &p)

scalar division of the whole base state

template<class U>
friend BaseState<U> operator/(const BaseState<U> &lhs, const BaseState<U> &rhs)

element-wise division

template<class U>
friend bool operator==(const BaseState<U> &lhs, const BaseState<U> &rhs)

comparison operator

template<class U>
friend bool operator!=(const BaseState<U> &lhs, const BaseState<U> &rhs)

comparison operator