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) const -> const tk::real&
auto operator()(ncomp_t unknown, ncomp_t component) -> tk::real&
auto nunk() const -> ncomp_t noexcept
auto nprop() const -> ncomp_t noexcept
auto extract(ncomp_t component) const -> std::vector<tk::real>
auto operator[](ncomp_t unknown) const -> std::vector<tk::real>
auto extract(ncomp_t component, const std::array<ncomp_t, 4>& N) const -> std::array<tk::real, 4>
auto vec() const -> const std::vector<tk::real>&
auto vec() -> 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 resize(std::size_t nu, std::size_t np)
void rm(const std::set<ncomp_t>& unknown)
void fill(ncomp_t component, tk::real value)
void fill(tk::real value)
auto empty() const -> bool noexcept
Check if vector of unknowns is empty.

Pack/Unpack: Serialize Data object for Charm++

std::vector<tk::real> m_vec
Data pointer.
ncomp_t m_nunk
Number of unknowns.
ncomp_t m_nprop
Number of properties/unknown.
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) const

Parameters
unknown in Unknown index
component in Component index, i.e., position of a scalar within a system
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), where p is the unknown index, and c is the component index specifying the scalar equation within a system of equations. Requirement: 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)

Parameters
unknown in Unknown index
component in Component index, i.e., position of a scalar within a system
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, and c is the component index specifying the scalar equation within a system of equations. Requirement: component < nprop, 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) const

Parameters
component in Component index, i.e., position of a scalar within a system
Returns A vector of unknowns given by component (length: nunk(), i.e., the first constructor argument)

Extract vector of unknowns given component

Requirement: component < nprop, 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, const std::array<ncomp_t, 4>& N) const

Parameters
component in Component index, i.e., position of a scalar within a system
in Indices of the 4 unknowns
Returns Array of the four values of component

Extract (a copy of) four values of unknowns

Requirement: 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>::vec() const

Returns Constant reference to underlying raw data

Const-ref accessor to underlying raw data as a std::vector

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

Returns Non-constant reference to underlying raw data

Non-const-ref accessor to underlying raw data as a std::vector

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 * nprop 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>::resize(std::size_t nu, std::size_t np)

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

Resize data given number of unknowns and number of properties

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, tk::real value)

Parameters
component in Component index, i.e., position of a scalar within a system
value in Value to fill vector of unknowns with

Fill vector of unknowns with the same value

Requirement: 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