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

Detailed Description

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

Definition at line 63 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 66 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 219 of file Function.cpp.

228{
232
234
235 // value expressions per thread.
236 for (int thread_id = 0; thread_id < num_threads; ++thread_id)
237 {
240 }
241
242 // dValue expressions per thread.
243 for (int thread_id = 0; thread_id < num_threads; ++thread_id)
244 {
245 for (auto const& [variable_name, string_expressions] :
247 {
248 dvalue_expressions[thread_id].emplace_back(
252 }
253 }
254}
std::vector< VariableArray > variable_arrays
Definition Function.cpp:109
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:200
std::vector< std::vector< std::pair< Variable, std::vector< Expression > > > > dvalue_expressions
Definition Function.cpp:105
std::vector< std::vector< Expression > > value_expressions
Definition Function.cpp:100
static std::vector< exprtk::expression< T > > compileExpressions(exprtk::symbol_table< T > &symbol_table, std::vector< std::string > const &string_expressions)
Definition Function.cpp:42
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 117 of file Function.cpp.

123{
125 symbol_table.add_constants();
126
128 for (auto const& curve : curves)
129 {
130 curve_names.insert(curve.first);
131 }
132
134
135 symbol_table.create_variable("t");
136
137 for (auto const& v : variables)
138 {
139 if (v == "t")
140 {
141 continue;
142 }
143 else if (v == "x" || v == "y" || v == "z")
144 {
145 symbol_table.create_variable("x");
146 symbol_table.create_variable("y");
147 symbol_table.create_variable("z");
149 }
150 else if (curve_names.contains(v))
151 {
152 used_curves.insert(v);
153 }
154 else
155 {
156 auto add_scalar = [&v, &symbol_table](double& value)
157 { symbol_table.add_variable(v, value); };
158
159 auto add_vector =
160 [&v, &symbol_table](double* ptr, std::size_t const size)
161 { symbol_table.add_vector(v, ptr, size); };
162
165 { add_scalar(*address); },
167 {
168 auto constexpr size =
170 auto& result = address->template emplace<
172 add_vector(result.data(), size);
173 },
175 {
176 auto constexpr size = MathLib::VectorizedTensor::size(D);
177 auto& result = address->template emplace<
179 add_vector(result.data(), size);
180 }};
181
184 }
185 }
186
187 for (const auto& name : used_curves)
188 {
189 const auto& curve_ptr = curves.at(name);
191 }
192 for (auto& [name, wrapper] : _curve_wrappers)
193 {
194 symbol_table.add_function(name, wrapper);
195 }
196 return symbol_table;
197}
std::map< std::string, CurveWrapper > _curve_wrappers
Definition Function.cpp:111
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 200 of file Function.cpp.

206{
208
209 for (int thread_id = 0; thread_id < num_threads; ++thread_id)
210 {
213 }
214
215 return symbol_tables;
216}
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:117

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 111 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 105 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 113 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 100 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 109 of file Function.cpp.

Referenced by Implementation(), and createSymbolTables().


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