template<uint8_t Layout>
tk::Data class

Zero-runtime-cost data-layout wrappers with type-based compile-time dispatch.

Public static functions

static auto layout() -> std::string

Constructors, destructors, conversion operators

Data() explicit
Default constructor (required for Charm++ migration)
Data(ncomp_t nu, ncomp_t np) explicit

Public functions

auto operator()(ncomp_t unknown, ncomp_t component, ncomp_t offset) const -> const tk::real&
auto operator()(ncomp_t unknown, ncomp_t component, ncomp_t offset) -> tk::real&
auto cptr(ncomp_t component, ncomp_t offset) const -> const tk::real*
auto var(const tk::real* pt, ncomp_t unknown) const -> const tk::real&
auto var(const tk::real* pt, ncomp_t unknown) -> tk::real&
auto nunk() const -> ncomp_t noexcept
auto nprop() const -> ncomp_t noexcept
auto extract(ncomp_t component, ncomp_t offset) const -> std::vector<tk::real>
auto extract(ncomp_t unknown) const -> std::vector<tk::real>
auto operator[](ncomp_t unknown) const -> std::vector<tk::real>
auto extract(ncomp_t component, ncomp_t offset, ncomp_t A, ncomp_t B, ncomp_t C, ncomp_t D) const -> std::array<tk::real, 4>
auto extract(ncomp_t component, ncomp_t offset, const std::array<ncomp_t, 4>& N) const -> std::array<tk::real, 4>
auto data() const -> const std::vector<tk::real>&
auto data() -> std::vector<tk::real>&
auto operator-=(const Data<Layout>& rhs) -> Data<Layout>&
auto operator-(const Data<Layout>& rhs) const -> Data<Layout>
auto operator+=(const Data<Layout>& rhs) -> Data<Layout>&
auto operator+(const Data<Layout>& rhs) const -> Data<Layout>
auto operator*=(const Data<Layout>& rhs) -> Data<Layout>&
auto operator*(const Data<Layout>& rhs) const -> Data<Layout>
auto operator*=(tk::real rhs) -> Data<Layout>&
auto operator*(tk::real rhs) const -> Data<Layout>
auto operator/=(const Data<Layout>& rhs) -> Data<Layout>&
auto operator/(const Data<Layout>& rhs) const -> Data<Layout>
auto operator/=(tk::real rhs) -> Data<Layout>&
auto operator/(tk::real rhs) const -> Data<Layout>
void push_back(const std::vector<tk::real>& prop)
void resize(std::size_t count, tk::real value = 0.0)
void rm(const std::set<ncomp_t>& unknown)
void fill(ncomp_t component, ncomp_t offset, tk::real value)
void fill(tk::real value)

Pack/Unpack: Serialize Data object for Charm++

void pup(PUP::er& p)
Pack/Unpack serialize member function.
void operator|(PUP::er& p, Data& d)
Pack/Unpack serialize operator|.

Function documentation

template<uint8_t Layout>
static std::string tk::Data<Layout>::layout()

Returns The name of the data layout used

Layout name dispatch

template<uint8_t Layout>
tk::Data<Layout>::Data(ncomp_t nu, ncomp_t np) explicit

Parameters
nu in Number of unknowns to allocate memory for
np in Total number of properties, i.e., scalar variables or components, per unknown

Constructor

template<uint8_t Layout>
const tk::real& tk::Data<Layout>::operator()(ncomp_t unknown, ncomp_t component, ncomp_t offset) const

Parameters
unknown in Unknown index
component in Component index, i.e., position of a scalar within a system
offset in System offset specifying the position of the system of equations among other systems
Returns Const reference to data of type tk::real

Const data access dispatch

Public interface to const-ref data access to a single real value. Use it as Data(p,c,o), where p is the unknown index, c is the component index specifying the scalar equation within a system of equations, and o is the offset specifying the position at which the system resides among other systems. Requirement: offset + component < nprop, unknown < nunk, enforced with an assert in DEBUG mode, see also the constructor.

template<uint8_t Layout>
tk::real& tk::Data<Layout>::operator()(ncomp_t unknown, ncomp_t component, ncomp_t offset)

Parameters
unknown in Unknown index
component in Component index, i.e., position of a scalar within a system
offset in System offset specifying the position of the system of equations among other systems
Returns Non-const reference to data of type tk::real

Non-const data access dispatch

Public interface to non-const-ref data access to a single real value. Use it as Data(p,c,o), where p is the unknown index, c is the component index specifying the scalar equation within a system of equations, and o is the offset specifying the position at which the system resides among other systems. Requirement: offset + component < nprop, unknown < nunk, enforced with an assert in DEBUG mode, see also the constructor.

template<uint8_t Layout>
const tk::real* tk::Data<Layout>::cptr(ncomp_t component, ncomp_t offset) const

Parameters
component in Component index, i.e., position of a scalar within a system
offset in System offset specifying the position of the system of equations among other systems
Returns Pointer to data of type tk::real for use with var()

Const ptr to physical variable access dispatch

Public interface to the first half of a physical variable access. cptr() and var() are two member functions intended to be used together in case when component and offset would be expensive to compute for data access via the function call operator, i.e., cptr() can be used to pre-compute part of the address, which returns a pointer and var() can be used to finish the data access using the pointer returned by cptr(). In other words, cptr() returns part of the address known based on component and offset and intended to be used in a setup phase. Then var() takes this partial address and finishes the address calculation given the unknown id. Thus the following two data accesses are equivalent (modulo constness):

template<uint8_t Layout>
const tk::real& tk::Data<Layout>::var(const tk::real* pt, ncomp_t unknown) const

Parameters
pt in Pointer to data of type tk::real as returned from cptr()
unknown in Unknown index
Returns Const reference to data of type tk::real

Const-ref data-access dispatch

Public interface to the second half of a physical variable access. cptr() and var() are two member functions intended to be used together in case when component and offset would be expensive to compute for data access via the function call operator, i.e., cptr() can be used to pre-compute part of the address, which returns a pointer and var() can be used to finish the data access using the pointer returned by cptr(). In other words, cptr() returns part of the address known based on component and offset and intended to be used in a setup phase. Then var() takes this partial address and finishes the address calculation given the unknown id. Thus the following two data accesses are equivalent (modulo constness):

template<uint8_t Layout>
tk::real& tk::Data<Layout>::var(const tk::real* pt, ncomp_t unknown)

Parameters
pt in Pointer to data of type tk::real as returned from cptr()
unknown in Unknown index
Returns Non-const reference to data of type tk::real

Non-const-ref data-access dispatch

Public interface to the second half of a physical variable access. cptr() and var() are two member functions intended to be used together in case when component and offset would be expensive to compute for data access via the function call operator, i.e., cptr() can be used to pre-compute part of the address, which returns a pointer and var() can be used to finish the data access using the pointer returned by cptr(). In other words, cptr() returns part of the address known based on component and offset and intended to be used in a setup phase. Then var() takes this partial address and finishes the address calculation given the unknown id. Thus the following two data accesses are equivalent (modulo constness):

  • real& value = operator()( unk, comp, offs ); and
  • const real* p = cptr( comp, offs ); and const real& value = var( p, unk ); or real& value = var( p, unk ); Requirement: unknown < nunk, enforced with an assert in DEBUG mode, see also the constructor.

template<uint8_t Layout>
ncomp_t tk::Data<Layout>::nunk() const noexcept

Returns Number of unknowns

Access to number of unknowns

template<uint8_t Layout>
ncomp_t tk::Data<Layout>::nprop() const noexcept

Returns Number of propertes/unknown

Access to number of properties

This is the total number of scalar components per unknown

template<uint8_t Layout>
std::vector<tk::real> tk::Data<Layout>::extract(ncomp_t component, ncomp_t offset) const

Parameters
component in Component index, i.e., position of a scalar within a system
offset in System offset specifying the position of the system of equations among other systems
Returns A vector of unknowns given by component at offset (length: nunk(), i.e., the first constructor argument)

Extract vector of unknowns given component and offset

Requirement: offset + component < nprop, enforced with an assert in DEBUG mode, see also the constructor.

template<uint8_t Layout>
std::vector<tk::real> tk::Data<Layout>::extract(ncomp_t unknown) const

Parameters
unknown in Index of unknown
Returns A vector of components for a single unknown (length: nprop, i.e., the second constructor argument)

Extract (a copy of) all components for an unknown

Requirement: unknown < nunk, enforced with an assert in DEBUG mode, see also the constructor.

template<uint8_t Layout>
std::vector<tk::real> tk::Data<Layout>::operator[](ncomp_t unknown) const

Parameters
unknown in Index of unknown
Returns A vector of components for a single unknown (length: nprop, i.e., the second constructor argument)

Extract all components for unknown

Requirement: unknown < nunk, enforced with an assert in DEBUG mode, see also the constructor.

template<uint8_t Layout>
std::array<tk::real, 4> tk::Data<Layout>::extract(ncomp_t component, ncomp_t offset, ncomp_t A, ncomp_t B, ncomp_t C, ncomp_t D) const

Parameters
component in Component index, i.e., position of a scalar within a system
offset in System offset specifying the position of the system of equations among other systems
in Index of 1st unknown
in Index of 2nd unknown
in Index of 3rd unknown
in Index of 4th unknown
Returns Array of the four values of component at offset

Extract (a copy of) four values of unknowns

Requirement: offset + component < nprop, [A,B,C,D] < nunk, enforced with an assert in DEBUG mode, see also the constructor.

template<uint8_t Layout>
std::array<tk::real, 4> tk::Data<Layout>::extract(ncomp_t component, ncomp_t offset, const std::array<ncomp_t, 4>& N) const

Parameters
component in Component index, i.e., position of a scalar within a system
offset in System offset specifying the position of the system of equations among other systems
in Indices of the 4 unknowns
Returns Array of the four values of component at offset

Extract (a copy of) four values of unknowns

Requirement: offset + component < nprop, for all N[i] < nunk, enforced with an assert in DEBUG mode, see also the constructor.

template<uint8_t Layout>
const std::vector<tk::real>& tk::Data<Layout>::data() const

Returns Constant reference to underlying raw data

Const-ref accessor to underlying raw data

template<uint8_t Layout>
std::vector<tk::real>& tk::Data<Layout>::data()

Returns Non-constant reference to underlying raw data

Non-const-ref accessor to underlying raw data

template<uint8_t Layout>
Data<Layout>& tk::Data<Layout>::operator-=(const Data<Layout>& rhs)

Parameters
rhs in Data object to subtract
Returns Reference to ourselves after subtraction

Compound operator-=

template<uint8_t Layout>
Data<Layout> tk::Data<Layout>::operator-(const Data<Layout>& rhs) const

Parameters
rhs in Data object to subtract
Returns Copy of Data object after rhs has been subtracted

Operator - Implemented in terms of compound operator-=

template<uint8_t Layout>
Data<Layout>& tk::Data<Layout>::operator+=(const Data<Layout>& rhs)

Parameters
rhs in Data object to add
Returns Reference to ourselves after addition

Compound operator+=

template<uint8_t Layout>
Data<Layout> tk::Data<Layout>::operator+(const Data<Layout>& rhs) const

Parameters
rhs in Data object to add
Returns Copy of Data object after rhs has been multiplied with

Operator + Implemented in terms of compound operator+=

template<uint8_t Layout>
Data<Layout>& tk::Data<Layout>::operator*=(const Data<Layout>& rhs)

Parameters
rhs in Data object to multiply with
Returns Reference to ourselves after multiplication

Compound operator*= multiplying by another Data object item by item

template<uint8_t Layout>
Data<Layout> tk::Data<Layout>::operator*(const Data<Layout>& rhs) const

Parameters
rhs in Data object to multiply with
Returns Copy of Data object after rhs has been multiplied with

Operator * multiplying by another Data object item by item Implemented in terms of compound operator*=

template<uint8_t Layout>
Data<Layout>& tk::Data<Layout>::operator*=(tk::real rhs)

Parameters
rhs in Scalar to multiply with
Returns Reference to ourselves after multiplication

Compound operator*= multiplying all items by a scalar

template<uint8_t Layout>
Data<Layout> tk::Data<Layout>::operator*(tk::real rhs) const

Parameters
rhs in Scalar to multiply with
Returns Copy of Data object after rhs has been multiplied with

Operator * multiplying all items by a scalar Implemented in terms of compound operator*=

template<uint8_t Layout>
Data<Layout>& tk::Data<Layout>::operator/=(const Data<Layout>& rhs)

Parameters
rhs in Data object to divide by
Returns Reference to ourselves after division

Compound operator/=

template<uint8_t Layout>
Data<Layout> tk::Data<Layout>::operator/(const Data<Layout>& rhs) const

Parameters
rhs in Data object to divide by
Returns Copy of Data object after rhs has been divided by

Operator / Implemented in terms of compound operator/=

template<uint8_t Layout>
Data<Layout>& tk::Data<Layout>::operator/=(tk::real rhs)

Parameters
rhs in Scalar to divide with
Returns Reference to ourselves after division

Compound operator/= dividing all items by a scalar

template<uint8_t Layout>
Data<Layout> tk::Data<Layout>::operator/(tk::real rhs) const

Parameters
rhs in Scalar to divide with
Returns Copy of Data object after rhs has been divided by

Operator / dividing all items by a scalar Implemented in terms of compound operator/=

template<uint8_t Layout>
void tk::Data<Layout>::push_back(const std::vector<tk::real>& prop)

Parameters
prop in Vector of properties to initialize the new unknown with

Add new unknown at the end of the container

template<uint8_t Layout>
void tk::Data<Layout>::resize(std::size_t count, tk::real value = 0.0)

Parameters
count in Resize store to contain 'count' elements
value in Value to initialize new data with (default: 0.0)

Resize data store to contain 'count' elements

template<uint8_t Layout>
void tk::Data<Layout>::rm(const std::set<ncomp_t>& unknown)

Parameters
unknown in Set of indices of unknowns to remove

Remove a number of unknowns

template<uint8_t Layout>
void tk::Data<Layout>::fill(ncomp_t component, ncomp_t offset, tk::real value)

Parameters
component in Component index, i.e., position of a scalar within a system
offset in System offset specifying the position of the system of equations among other systems
value in Value to fill vector of unknowns with

Fill vector of unknowns with the same value

Requirement: offset + component < nprop, enforced with an assert in DEBUG mode, see also the constructor.

template<uint8_t Layout>
void tk::Data<Layout>::fill(tk::real value)

Parameters
value in Value to fill data with

Fill full data storage with value

template<uint8_t Layout>
void tk::Data<Layout>::pup(PUP::er& p)

Pack/Unpack serialize member function.

Parameters
in/out Charm++'s PUP::er serializer object reference

template<uint8_t Layout>
void tk::Data<Layout>::operator|(PUP::er& p, Data& d)

Pack/Unpack serialize operator|.

Parameters
in/out Charm++'s PUP::er serializer object reference
in/out DataLyaout object reference