OGS
MaterialPropertyLib::Function::Implementation< D > Class Template Reference

Detailed Description

template<int D>
class MaterialPropertyLib::Function::Implementation< D >

Definition at line 49 of file Function.h.

Collaboration diagram for MaterialPropertyLib::Function::Implementation< D >:
[legend]

Public Types

using Expression = exprtk::expression<double>
 

Public Member Functions

 Implementation (std::vector< std::string > const &variables, std::vector< std::string > const &value_string_expressions, std::vector< std::pair< std::string, std::vector< std::string > > > const &dvalue_string_expressions)
 

Public Attributes

std::vector< Expressionvalue_expressions
 
std::vector< std::pair< Variable, std::vector< Expression > > > dvalue_expressions
 
VariableArray variable_array
 

Private Member Functions

exprtk::symbol_table< double > createSymbolTable (std::vector< std::string > const &variables)
 

Member Typedef Documentation

◆ Expression

template<int D>
using MaterialPropertyLib::Function::Implementation< D >::Expression = exprtk::expression<double>

Definition at line 51 of file Function.cpp.

Constructor & Destructor Documentation

◆ Implementation()

template<int D>
MaterialPropertyLib::Function::Implementation< D >::Implementation ( std::vector< std::string > const & variables,
std::vector< std::string > const & value_string_expressions,
std::vector< std::pair< std::string, std::vector< std::string > > > const & dvalue_string_expressions )

Definition at line 122 of file Function.cpp.

127{
128 auto symbol_table = createSymbolTable(variables);
129
130 // value expressions.
132 compileExpressions(symbol_table, value_string_expressions);
133
134 // dValue expressions.
135 for (auto const& [variable_name, string_expressions] :
136 dvalue_string_expressions)
137 {
138 dvalue_expressions.emplace_back(
139 convertStringToVariable(variable_name),
140 compileExpressions(symbol_table, string_expressions));
141 }
142}
std::vector< Expression > value_expressions
Definition Function.cpp:69
exprtk::symbol_table< double > createSymbolTable(std::vector< std::string > const &variables)
Definition Function.cpp:82
std::vector< std::pair< Variable, std::vector< Expression > > > dvalue_expressions
Definition Function.cpp:74
static std::vector< exprtk::expression< T > > compileExpressions(exprtk::symbol_table< T > &symbol_table, std::vector< std::string > const &string_expressions)
Definition Function.cpp:27
Variable convertStringToVariable(std::string const &string)

References MaterialPropertyLib::compileExpressions(), and MaterialPropertyLib::convertStringToVariable().

Member Function Documentation

◆ createSymbolTable()

template<int D>
exprtk::symbol_table< double > MaterialPropertyLib::Function::Implementation< D >::createSymbolTable ( std::vector< std::string > const & variables)
private

Create symbol table for given variables and populates the variable_array as needed.

Definition at line 82 of file Function.cpp.

84{
85 exprtk::symbol_table<double> symbol_table;
86
87 for (auto const& v : variables)
88 {
89 auto add_scalar = [&v, &symbol_table](double& value)
90 { symbol_table.add_variable(v, value); };
91
92 auto add_vector =
93 [&v, &symbol_table](double* ptr, std::size_t const size)
94 { symbol_table.add_vector(v, ptr, size); };
95
96 auto add_any_variable = BaseLib::Overloaded{
97 [&add_scalar](VariableArray::Scalar* address)
98 { add_scalar(*address); },
99 [&add_vector](VariableArray::KelvinVector* address)
100 {
101 auto constexpr size =
103 auto& result =
104 address->template emplace<Eigen::Matrix<double, size, 1>>();
105 add_vector(result.data(), size);
106 },
107 [&add_vector](VariableArray::DeformationGradient* address)
108 {
109 auto constexpr size = MathLib::VectorizedTensor::size(D);
110 auto& result =
111 address->template emplace<Eigen::Matrix<double, size, 1>>();
112 add_vector(result.data(), size);
113 }};
114
115 Variable const variable = convertStringToVariable(v);
116 variable_array.visitVariable(add_any_variable, variable);
117 }
118 return symbol_table;
119}
virtual PropertyDataType value() const
Definition Property.cpp:76
std::variant< std::monostate, Eigen::Vector< double, 5 >, Eigen::Vector< double, 9 > > DeformationGradient
std::variant< std::monostate, Eigen::Vector< double, 4 >, Eigen::Vector< double, 6 > > KelvinVector
auto visitVariable(Visitor &&visitor, Variable const variable)
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
constexpr int size(int const displacement_dim)
Vectorized tensor size for given displacement dimension.

References MaterialPropertyLib::convertStringToVariable(), MathLib::KelvinVector::kelvin_vector_dimensions(), and MathLib::VectorizedTensor::size().

Member Data Documentation

◆ dvalue_expressions

template<int D>
std::vector<std::pair<Variable, std::vector<Expression> > > MaterialPropertyLib::Function::Implementation< D >::dvalue_expressions

Derivative expressions with respect to the variable. Multiple expressions are representing vector-valued functions.

Definition at line 74 of file Function.cpp.

◆ value_expressions

template<int D>
std::vector<Expression> MaterialPropertyLib::Function::Implementation< D >::value_expressions

Value expressions. Multiple expressions are representing vector-valued functions.

Definition at line 69 of file Function.cpp.

◆ variable_array

template<int D>
VariableArray MaterialPropertyLib::Function::Implementation< D >::variable_array
mutable

Stores values for evaluation of vectorial quantities. Needed for constant pointers for exprtk.

Definition at line 78 of file Function.cpp.


The documentation for this class was generated from the following files: