OGS
MaterialPropertyLib::ScalarCopyOp Struct Reference

Detailed Description

Scalar copy operation: transfers one double from a VariableArray into the per-thread symbol table using a precomputed byte offset. The variable field is carried only for error messages.

Definition at line 30 of file Function.cpp.

Public Member Functions

 ScalarCopyOp (VariableArray const &base, VariableArray::Scalar *dst, Variable var)
void apply (VariableArray const &src) const

Public Attributes

std::ptrdiff_t src_offset
 byte offset from VariableArray start
double * dst_ptr
 pointer into this thread's symbol table
Variable variable
 for error messages

Constructor & Destructor Documentation

◆ ScalarCopyOp()

MaterialPropertyLib::ScalarCopyOp::ScalarCopyOp ( VariableArray const & base,
VariableArray::Scalar * dst,
Variable var )
inline

Definition at line 36 of file Function.cpp.

39 : src_offset{reinterpret_cast<char const*>(dst) -
40 reinterpret_cast<char const*>(&base)},
41 dst_ptr{dst},
42 variable{var}
43 {
44 }
Variable variable
for error messages
Definition Function.cpp:34
std::ptrdiff_t src_offset
byte offset from VariableArray start
Definition Function.cpp:32
double * dst_ptr
pointer into this thread's symbol table
Definition Function.cpp:33

References dst_ptr, src_offset, and variable.

Member Function Documentation

◆ apply()

void MaterialPropertyLib::ScalarCopyOp::apply ( VariableArray const & src) const
inline

Definition at line 46 of file Function.cpp.

47 {
48 double const val = *reinterpret_cast<double const*>(
49 reinterpret_cast<char const*>(&src) + src_offset);
50 if (std::isnan(val))
51 {
53 "Function property: Scalar variable '{:s}' is not "
54 "initialized.",
55 variable_enum_to_string[static_cast<int>(variable)]);
56 }
57 *dst_ptr = val;
58 }
#define OGS_FATAL(...)
Definition Error.h:10
static const std::array< std::string, static_cast< int >(Variable::number_of_variables)> variable_enum_to_string

References dst_ptr, OGS_FATAL, src_offset, variable, and MaterialPropertyLib::variable_enum_to_string.

Member Data Documentation

◆ dst_ptr

double* MaterialPropertyLib::ScalarCopyOp::dst_ptr

pointer into this thread's symbol table

Definition at line 33 of file Function.cpp.

Referenced by ScalarCopyOp(), and apply().

◆ src_offset

std::ptrdiff_t MaterialPropertyLib::ScalarCopyOp::src_offset

byte offset from VariableArray start

Definition at line 32 of file Function.cpp.

Referenced by ScalarCopyOp(), and apply().

◆ variable

Variable MaterialPropertyLib::ScalarCopyOp::variable

for error messages

Definition at line 34 of file Function.cpp.

Referenced by ScalarCopyOp(), and apply().


The documentation for this struct was generated from the following file: