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

Detailed Description

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

Definition at line 69 of file Function.cpp.

Public Types

using Expression = exprtk::expression<double>

Public Member Functions

 Implementation (int num_threads, 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< std::vector< Expression > > value_expressions
std::vector< std::vector< std::pair< Variable, std::vector< Expression > > > > dvalue_expressions
std::vector< VariableArrayvariable_arrays
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, VariableArray &variable_array)
std::vector< exprtk::symbol_table< double > > createSymbolTables (int num_threads, std::vector< std::string > const &variables, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)
 Create symbol tables for all threads.

Member Typedef Documentation

◆ Expression

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

Definition at line 72 of file Function.cpp.

Constructor & Destructor Documentation

◆ Implementation()

template<int D>
MaterialPropertyLib::Function::Implementation< D >::Implementation ( int num_threads,
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 225 of file Function.cpp.

234{
238
240
241 // value expressions per thread.
242 for (int thread_id = 0; thread_id < num_threads; ++thread_id)
243 {
246 }
247
248 // dValue expressions per thread.
249 for (int thread_id = 0; thread_id < num_threads; ++thread_id)
250 {
251 for (auto const& [variable_name, string_expressions] :
253 {
254 dvalue_expressions[thread_id].emplace_back(
258 }
259 }
260}
std::vector< VariableArray > variable_arrays
Definition Function.cpp:115
std::vector< exprtk::symbol_table< double > > createSymbolTables(int num_threads, std::vector< std::string > const &variables, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)
Create symbol tables for all threads.
Definition Function.cpp:206
std::vector< std::vector< std::pair< Variable, std::vector< Expression > > > > dvalue_expressions
Definition Function.cpp:111
std::vector< std::vector< Expression > > value_expressions
Definition Function.cpp:106
static std::vector< exprtk::expression< T > > compileExpressions(exprtk::symbol_table< T > &symbol_table, std::vector< std::string > const &string_expressions)
Definition Function.cpp:48
Variable convertStringToVariable(std::string const &string)

References MaterialPropertyLib::compileExpressions(), MaterialPropertyLib::convertStringToVariable(), createSymbolTables(), dvalue_expressions, value_expressions, and variable_arrays.

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,
VariableArray & variable_array )
private

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

Definition at line 123 of file Function.cpp.

129{
131 symbol_table.add_constants();
132
134 for (auto const& curve : curves)
135 {
136 curve_names.insert(curve.first);
137 }
138
140
141 symbol_table.create_variable("t");
142
143 for (auto const& v : variables)
144 {
145 if (v == "t")
146 {
147 continue;
148 }
149 else if (v == "x" || v == "y" || v == "z")
150 {
151 symbol_table.create_variable("x");
152 symbol_table.create_variable("y");
153 symbol_table.create_variable("z");
155 }
156 else if (curve_names.contains(v))
157 {
158 used_curves.insert(v);
159 }
160 else
161 {
162 auto add_scalar = [&v, &symbol_table](double& value)
163 { symbol_table.add_variable(v, value); };
164
165 auto add_vector =
166 [&v, &symbol_table](double* ptr, std::size_t const size)
167 { symbol_table.add_vector(v, ptr, size); };
168
171 { add_scalar(*address); },
173 {
174 auto constexpr size =
176 auto& result = address->template emplace<
178 add_vector(result.data(), size);
179 },
181 {
182 auto constexpr size = MathLib::VectorizedTensor::size(D);
183 auto& result = address->template emplace<
185 add_vector(result.data(), size);
186 }};
187
190 }
191 }
192
193 for (const auto& name : used_curves)
194 {
195 const auto& curve_ptr = curves.at(name);
197 }
198 for (auto& [name, wrapper] : _curve_wrappers)
199 {
200 symbol_table.add_function(name, wrapper);
201 }
202 return symbol_table;
203}
std::map< std::string, CurveWrapper > _curve_wrappers
Definition Function.cpp:117
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 _curve_wrappers, MaterialPropertyLib::convertStringToVariable(), MathLib::KelvinVector::kelvin_vector_dimensions(), MaterialPropertyLib::name, MathLib::VectorizedTensor::size(), spatial_position_is_required, MaterialPropertyLib::Function::value(), and MaterialPropertyLib::VariableArray::visitVariable().

Referenced by createSymbolTables().

◆ createSymbolTables()

template<int D>
std::vector< exprtk::symbol_table< double > > MaterialPropertyLib::Function::Implementation< D >::createSymbolTables ( int num_threads,
std::vector< std::string > const & variables,
std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const & curves )
private

Create symbol tables for all threads.

Definition at line 206 of file Function.cpp.

212{
214
215 for (int thread_id = 0; thread_id < num_threads; ++thread_id)
216 {
219 }
220
221 return symbol_tables;
222}
exprtk::symbol_table< double > createSymbolTable(std::vector< std::string > const &variables, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves, VariableArray &variable_array)
Definition Function.cpp:123

References createSymbolTable(), and variable_arrays.

Referenced by Implementation().

Member Data Documentation

◆ _curve_wrappers

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

Definition at line 117 of file Function.cpp.

Referenced by createSymbolTable().

◆ dvalue_expressions

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

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

Definition at line 111 of file Function.cpp.

Referenced by Implementation().

◆ spatial_position_is_required

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

Definition at line 119 of file Function.cpp.

Referenced by createSymbolTable().

◆ value_expressions

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

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

Definition at line 106 of file Function.cpp.

Referenced by Implementation().

◆ variable_arrays

template<int D>
std::vector<VariableArray> MaterialPropertyLib::Function::Implementation< D >::variable_arrays

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

Definition at line 115 of file Function.cpp.

Referenced by Implementation(), and createSymbolTables().


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