Loading [MathJax]/extensions/tex2jax.js
OGS
MaterialPropertyLib::Function::Implementation< D > Class Template Reference

Detailed Description

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

Definition at line 57 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, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)
 

Public Attributes

std::vector< Expressionvalue_expressions
 
std::vector< std::pair< Variable, std::vector< Expression > > > dvalue_expressions
 
VariableArray variable_array
 
std::map< std::string, CurveWrapper_curve_wrappers
 
bool spatial_position_is_required = false
 

Private Member Functions

exprtk::symbol_table< double > createSymbolTable (std::vector< std::string > const &variables, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)
 

Member Typedef Documentation

◆ Expression

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

Definition at line 67 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,
std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const & curves )

Definition at line 190 of file Function.cpp.

198{
199 auto symbol_table = createSymbolTable(variables, curves);
200
201 // value expressions.
203 compileExpressions(symbol_table, value_string_expressions);
204
205 // dValue expressions.
206 for (auto const& [variable_name, string_expressions] :
207 dvalue_string_expressions)
208 {
209 dvalue_expressions.emplace_back(
210 convertStringToVariable(variable_name),
211 compileExpressions(symbol_table, string_expressions));
212 }
213}
exprtk::symbol_table< double > createSymbolTable(std::vector< std::string > const &variables, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)
Definition Function.cpp:108
std::vector< Expression > value_expressions
Definition Function.cpp:91
std::vector< std::pair< Variable, std::vector< Expression > > > dvalue_expressions
Definition Function.cpp:96
static std::vector< exprtk::expression< T > > compileExpressions(exprtk::symbol_table< T > &symbol_table, std::vector< std::string > const &string_expressions)
Definition Function.cpp:43
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,
std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const & curves )
private

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

Definition at line 108 of file Function.cpp.

113{
114 exprtk::symbol_table<double> symbol_table;
115 symbol_table.add_constants();
116
117 std::unordered_set<std::string> curve_names;
118 for (auto const& curve : curves)
119 {
120 curve_names.insert(curve.first);
121 }
122
123 std::unordered_set<std::string> used_curves;
124
125 symbol_table.create_variable("t");
126
127 for (auto const& v : variables)
128 {
129 if (v == "t")
130 {
131 continue;
132 }
133 else if (v == "x" || v == "y" || v == "z")
134 {
135 symbol_table.create_variable("x");
136 symbol_table.create_variable("y");
137 symbol_table.create_variable("z");
139 }
140 else if (curve_names.contains(v))
141 {
142 used_curves.insert(v);
143 }
144 else
145 {
146 auto add_scalar = [&v, &symbol_table](double& value)
147 { symbol_table.add_variable(v, value); };
148
149 auto add_vector =
150 [&v, &symbol_table](double* ptr, std::size_t const size)
151 { symbol_table.add_vector(v, ptr, size); };
152
153 auto add_any_variable = BaseLib::Overloaded{
154 [&add_scalar](VariableArray::Scalar* address)
155 { add_scalar(*address); },
156 [&add_vector](VariableArray::KelvinVector* address)
157 {
158 auto constexpr size =
160 auto& result = address->template emplace<
161 Eigen::Matrix<double, size, 1>>();
162 add_vector(result.data(), size);
163 },
164 [&add_vector](VariableArray::DeformationGradient* address)
165 {
166 auto constexpr size = MathLib::VectorizedTensor::size(D);
167 auto& result = address->template emplace<
168 Eigen::Matrix<double, size, 1>>();
169 add_vector(result.data(), size);
170 }};
171
172 Variable const variable = convertStringToVariable(v);
173 variable_array.visitVariable(add_any_variable, variable);
174 }
175 }
176
177 for (const auto& name : used_curves)
178 {
179 const auto& curve_ptr = curves.at(name);
180 _curve_wrappers.emplace(name, CurveWrapper(*curve_ptr));
181 }
182 for (auto& [name, wrapper] : _curve_wrappers)
183 {
184 symbol_table.add_function(name, wrapper);
185 }
186 return symbol_table;
187}
std::map< std::string, CurveWrapper > _curve_wrappers
Definition Function.cpp:102
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(), MaterialPropertyLib::name, and MathLib::VectorizedTensor::size().

Member Data Documentation

◆ _curve_wrappers

template<int D>
std::map<std::string, CurveWrapper> MaterialPropertyLib::Function::Implementation< D >::_curve_wrappers

Definition at line 102 of file Function.cpp.

◆ 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 96 of file Function.cpp.

◆ spatial_position_is_required

template<int D>
bool MaterialPropertyLib::Function::Implementation< D >::spatial_position_is_required = false

Definition at line 104 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 91 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 100 of file Function.cpp.


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