https://mooseframework.inl.gov
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
Moose::Kokkos::ParsedObjectBase Class Reference

#include <KokkosParsedObjectBase.h>

Inheritance diagram for Moose::Kokkos::ParsedObjectBase:
[legend]

Public Member Functions

 ParsedObjectBase (const MooseObject *object)
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Member Functions

template<typename T >
void checkDuplicateSymbols (const std::vector< T > &symbols, const std::string &param)
 Check if duplicate symbols were added. More...
 
void addConstant (const std::string &name, const Real constant)
 Add a constant. More...
 
void addScalar (const std::string &name, const Real &scalar)
 Add a scalar variable. More...
 
void addField (const std::string &name, const VariableValue &field)
 Add a field variable. More...
 
void addProperty (const std::string &name, const MaterialProperty< Real > &property)
 Add a material property. More...
 
void addFunction (const std::string &name, const Function &function)
 Add a function. More...
 
template<typename T >
void initParsed (T *obj, const std::vector< VariableName > &variable_names)
 Initialize symbols from parsed parameters. More...
 

Protected Attributes

const std::string & _expression
 Parsed expression. More...
 
std::shared_ptr< RPNBuilder_builder
 Parsed function builder. More...
 
RPNEvaluator _evaluator
 Parsed function evaluator. More...
 
std::unordered_map< std::string, Real_constants
 Constants used in the parsed expression. More...
 
std::unordered_map< std::string, std::reference_wrapper< const Real > > _scalars
 Scalar variables used in the parsed expression. More...
 
std::unordered_map< std::string, VariableValue_fields
 Field variables used in the parsed expression. More...
 
std::unordered_map< std::string, MaterialProperty< Real > > _properties
 Material properties used in the parsed expression. More...
 
std::unordered_map< std::string, Function_functions
 Functions used in the parsed expression. More...
 

Private Member Functions

void finalize ()
 Finalize parsed function. More...
 

Private Attributes

const MooseObject_parsed_object
 Parsed object. More...
 
std::unordered_set< std::string > _all_symbols
 All symbols added to the parsed function. More...
 

Detailed Description

Definition at line 19 of file KokkosParsedObjectBase.h.

Constructor & Destructor Documentation

◆ ParsedObjectBase()

Moose::Kokkos::ParsedObjectBase::ParsedObjectBase ( const MooseObject object)

Member Function Documentation

◆ addConstant()

void Moose::Kokkos::ParsedObjectBase::addConstant ( const std::string &  name,
const Real  constant 
)
protected

Add a constant.

Parameters
nameThe variable name
constantThe constant value

Referenced by initParsed().

◆ addField()

void Moose::Kokkos::ParsedObjectBase::addField ( const std::string &  name,
const VariableValue field 
)
protected

Add a field variable.

Parameters
nameThe variable name
fieldThe coupled field variable

Referenced by initParsed().

◆ addFunction()

void Moose::Kokkos::ParsedObjectBase::addFunction ( const std::string &  name,
const Function function 
)
protected

Add a function.

Parameters
nameThe variable name
functionThe function

Referenced by initParsed().

◆ addProperty()

void Moose::Kokkos::ParsedObjectBase::addProperty ( const std::string &  name,
const MaterialProperty< Real > &  property 
)
protected

Add a material property.

Parameters
nameThe variable name
propertyThe material property

Referenced by initParsed().

◆ addScalar()

void Moose::Kokkos::ParsedObjectBase::addScalar ( const std::string &  name,
const Real scalar 
)
protected

Add a scalar variable.

Parameters
nameThe variable name
scalarThe pointer to the scalar variable

Referenced by initParsed().

◆ checkDuplicateSymbols()

template<typename T >
void Moose::Kokkos::ParsedObjectBase::checkDuplicateSymbols ( const std::vector< T > &  symbols,
const std::string &  param 
)
protected

Check if duplicate symbols were added.

Parameters
symbolsThe list of symbols
paramThe parameter name containing symbols

Definition at line 124 of file KokkosParsedObjectBase.h.

125 {
126  for (const auto & symbol : symbols)
127  {
128  if (_all_symbols.count(symbol))
129  _parsed_object->paramError(param, "Symbol '", symbol, "' was added multiple times.");
130 
131  _all_symbols.insert(symbol);
132  }
133 }
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition: MooseBase.h:467
const MooseObject * _parsed_object
Parsed object.
std::unordered_set< std::string > _all_symbols
All symbols added to the parsed function.

◆ finalize()

void Moose::Kokkos::ParsedObjectBase::finalize ( )
private

Finalize parsed function.

Referenced by initParsed().

◆ initParsed()

template<typename T >
void Moose::Kokkos::ParsedObjectBase::initParsed ( T *  obj,
const std::vector< VariableName > &  variable_names 
)
protected

Initialize symbols from parsed parameters.

variable_names must be supplied by the caller because Coupleable::coupledNames() is protected.

Definition at line 137 of file KokkosParsedObjectBase.h.

138 {
139  const auto & constant_names = obj->template getParam<std::vector<std::string>>("constant_names");
140  const auto & postprocessor_names =
141  obj->template getParam<std::vector<PostprocessorName>>("postprocessor_names");
142  const auto & property_names =
143  obj->template getParam<std::vector<MaterialPropertyName>>("material_property_names");
144  const auto & function_names = obj->template getParam<std::vector<FunctionName>>("function_names");
145  const auto & constant_expressions =
146  obj->template getParam<std::vector<Real>>("constant_expressions");
147 
148  for (const auto i : make_range(constant_names.size()))
149  addConstant(constant_names[i], constant_expressions[i]);
150 
151  for (const auto & pp : postprocessor_names)
152  addScalar(pp, obj->getPostprocessorValueByName(pp));
153 
154  for (const auto i : make_range(variable_names.size()))
155  addField(variable_names[i], obj->kokkosCoupledValue("coupled_variables", i));
156 
157  for (const auto & prop : property_names)
158  addProperty(prop, obj->template getKokkosMaterialPropertyByName<Real>(prop));
159 
160  for (const auto & func : function_names)
161  addFunction(func, obj->getKokkosFunctionByName(func));
162 
163  finalize();
164 }
void addField(const std::string &name, const VariableValue &field)
Add a field variable.
void addProperty(const std::string &name, const MaterialProperty< Real > &property)
Add a material property.
void addConstant(const std::string &name, const Real constant)
Add a constant.
void addScalar(const std::string &name, const Real &scalar)
Add a scalar variable.
void addFunction(const std::string &name, const Function &function)
Add a function.
IntRange< T > make_range(T beg, T end)
void finalize()
Finalize parsed function.

◆ validParams()

static InputParameters Moose::Kokkos::ParsedObjectBase::validParams ( )
static

Member Data Documentation

◆ _all_symbols

std::unordered_set<std::string> Moose::Kokkos::ParsedObjectBase::_all_symbols
private

All symbols added to the parsed function.

Definition at line 119 of file KokkosParsedObjectBase.h.

Referenced by checkDuplicateSymbols().

◆ _builder

std::shared_ptr<RPNBuilder> Moose::Kokkos::ParsedObjectBase::_builder
protected

Parsed function builder.

Definition at line 80 of file KokkosParsedObjectBase.h.

◆ _constants

std::unordered_map<std::string, Real> Moose::Kokkos::ParsedObjectBase::_constants
protected

Constants used in the parsed expression.

Definition at line 88 of file KokkosParsedObjectBase.h.

◆ _evaluator

RPNEvaluator Moose::Kokkos::ParsedObjectBase::_evaluator
protected

Parsed function evaluator.

Definition at line 84 of file KokkosParsedObjectBase.h.

Referenced by KokkosParsedMaterial::computeQpProperties(), and KokkosParsedAux::computeValue().

◆ _expression

const std::string& Moose::Kokkos::ParsedObjectBase::_expression
protected

Parsed expression.

Definition at line 76 of file KokkosParsedObjectBase.h.

◆ _fields

std::unordered_map<std::string, VariableValue> Moose::Kokkos::ParsedObjectBase::_fields
protected

Field variables used in the parsed expression.

Definition at line 96 of file KokkosParsedObjectBase.h.

◆ _functions

std::unordered_map<std::string, Function> Moose::Kokkos::ParsedObjectBase::_functions
protected

Functions used in the parsed expression.

Definition at line 104 of file KokkosParsedObjectBase.h.

◆ _parsed_object

const MooseObject* Moose::Kokkos::ParsedObjectBase::_parsed_object
private

Parsed object.

Definition at line 115 of file KokkosParsedObjectBase.h.

Referenced by checkDuplicateSymbols().

◆ _properties

std::unordered_map<std::string, MaterialProperty<Real> > Moose::Kokkos::ParsedObjectBase::_properties
protected

Material properties used in the parsed expression.

Definition at line 100 of file KokkosParsedObjectBase.h.

◆ _scalars

std::unordered_map<std::string, std::reference_wrapper<const Real> > Moose::Kokkos::ParsedObjectBase::_scalars
protected

Scalar variables used in the parsed expression.

Definition at line 92 of file KokkosParsedObjectBase.h.


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