template<uint8_t Layout>
Data class
Zero-runtime-cost data-layout wrappers with type-based compile-time dispatch.
Contents
Public static functions
- static auto layout() -> std::string
Constructors, destructors, conversion operators
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 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(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 extract(ncomp_
t component, ncomp_ t offset, ncomp_ t A, ncomp_ t B, ncomp_ t C) const -> std::array<tk:: real, 3> -
auto extract(ncomp_
t component, ncomp_ t offset, 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, ncomp_ t offset, 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++
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>
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:: |
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:: |
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:: |
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):
- 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: offset + 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:: |
unknown in | Unknown index |
Returns | Const reference to data of type tk:: |
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>
tk:: real& tk:: Data<Layout>:: var(const tk:: real* pt,
ncomp_ t unknown)
Parameters | |
---|---|
pt in | Pointer to data of type tk:: |
unknown in | Unknown index |
Returns | Non-const reference to data of type tk:: |
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>
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 |
A in | Index of 1st unknown |
B in | Index of 2nd unknown |
C in | Index of 3rd unknown |
D 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 |
N 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>
std::array<tk:: real, 3> tk:: Data<Layout>:: extract(ncomp_ t component,
ncomp_ t offset,
ncomp_ t A,
ncomp_ t B,
ncomp_ t C) 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 |
A in | Index of 1st unknown |
B in | Index of 2nd unknown |
C in | Index of 3rd unknown |
Returns | Array of the four values of component at offset |
Extract (a copy of) three values of unknowns
Requirement: offset + 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,
ncomp_ t offset,
const std::array<ncomp_ t, 3>& 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 |
N in | Indices of the 3 unknowns |
Returns | Array of the three values of component at offset |
Extract (a copy of) three 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>
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)
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)
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/=(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/=(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>
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>:: pup(PUP::er& p)
Pack/Unpack serialize member function.
Parameters | |
---|---|
p in/out | Charm++'s PUP::er serializer object reference |