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 cptr(ncomp_t component) 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 flat() const -> std::vector<tk::real>
void operator=(const std::vector<tk::real>& rhs)
void operator=(const std::array<std::vector<tk::real>, 3>& rhs)
auto extract_comp(ncomp_t component) 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 A, ncomp_t B, ncomp_t C, ncomp_t D) const -> std::array<tk::real, 4>
auto extract(ncomp_t component, const std::array<ncomp_t, 4>& N) const -> std::array<tk::real, 4>
auto extract(ncomp_t component, ncomp_t A, ncomp_t B, ncomp_t C) const -> std::array<tk::real, 3>
auto extract(ncomp_t component, const std::array<ncomp_t, 3>& N) const -> std::array<tk::real, 3>
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 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), 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>
const tk::real* tk::Data<Layout>::cptr(ncomp_t component) const

Parameters
component in Component index, i.e., position of a scalar within a system
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 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 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 ); and
  • const real* p = cptr( comp ); and const real& value = var( p, unk ); or real& value = var( p, unk ); Requirement: component < nprop, enforced with an assert in DEBUG mode, see also the constructor.

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 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 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 ); and
  • const real* p = cptr( comp ); 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>
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 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 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 ); and
  • const real* p = cptr( comp ); 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>::flat() const

Returns Flat vector of reals

Extract flat vector of all unknowns

template<uint8_t Layout>
void tk::Data<Layout>::operator=(const std::vector<tk::real>& rhs)

Parameters
rhs in Flat vector to assign from

Assign from flat vector

template<uint8_t Layout>
void tk::Data<Layout>::operator=(const std::array<std::vector<tk::real>, 3>& rhs)

Parameters
rhs in Array(3) of vectors to assign from

Assign from array(3) of vectors

template<uint8_t Layout>
std::vector<tk::real> tk::Data<Layout>::extract_comp(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>::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 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
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

Extract (a copy of) four values of unknowns

Requirement: 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, 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>
std::array<tk::real, 3> tk::Data<Layout>::extract(ncomp_t component, ncomp_t A, ncomp_t B, ncomp_t C) const

Parameters
component in Component index, i.e., position of a scalar within a system
in Index of 1st unknown
in Index of 2nd unknown
in Index of 3rd unknown
Returns Array of the four values of component

Extract (a copy of) three values of unknowns

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

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

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

Extract (a copy of) three 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>::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