https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
FunctionParserUtils< is_ad > Class Template Reference

#include <FunctionParserUtils.h>

Public Types

typedef GenericSymFunction< is_ad > SymFunction
 Shorthand for an autodiff function parser object.
 
typedef std::shared_ptr< SymFunctionSymFunctionPtr
 Shorthand for an smart pointer to an autodiff function parser object.
 

Public Member Functions

 FunctionParserUtils (const InputParameters &parameters)
 
void setParserFeatureFlags (SymFunctionPtr &) const
 apply input parameters to internal feature flags of the parser object
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Types

enum class  FailureMethod { nan , nan_warning , error , exception }
 Enum for failure method. More...
 

Protected Member Functions

GenericReal< is_ad > evaluate (SymFunctionPtr &, const std::string &object_name="")
 Evaluate FParser object and check EvalError.
 
GenericReal< is_ad > evaluate (SymFunctionPtr &, const std::vector< GenericReal< is_ad > > &, const std::string &object_name="")
 Evaluate FParser object and check EvalError.
 
void addFParserConstants (SymFunctionPtr &parser, const std::vector< std::string > &constant_names, const std::vector< std::string > &constant_expressions) const
 add constants (which can be complex expressions) to the parser object
 
virtual void functionsOptimize (SymFunctionPtr &parsed_function)
 run FPOptimizer on the parsed function
 
void parsedFunctionSetup (SymFunctionPtr &function, const std::string &expression, const std::string &variables, const std::vector< std::string > &constant_names, const std::vector< std::string > &constant_expressions, const libMesh::Parallel::Communicator &comm) const
 Performs setup steps on a SymFunction.
 
void functionsOptimize (SymFunctionPtr &parsed_function)
 
void functionsOptimize (SymFunctionPtr &parsed_function)
 

Protected Attributes

enum FunctionParserUtils::FailureMethod _evalerror_behavior
 
const Real _quiet_nan
 appropriate not a number value to return
 
std::vector< GenericReal< is_ad > > _func_params
 Array to stage the parameters passed to the functions when calling Eval.
 
const Real _epsilon
 fuzzy comparison tolerance
 
bool _enable_jit
 feature flags
 
bool _enable_ad_cache
 
bool _disable_fpoptimizer
 
bool _enable_auto_optimize
 

Static Protected Attributes

static const char * _eval_error_msg []
 table of FParser eval error codes
 

Detailed Description

template<bool is_ad = false>
class FunctionParserUtils< is_ad >

Definition at line 54 of file FunctionParserUtils.h.

Member Typedef Documentation

◆ SymFunction

template<bool is_ad = false>
typedef GenericSymFunction<is_ad> FunctionParserUtils< is_ad >::SymFunction

Shorthand for an autodiff function parser object.

Definition at line 62 of file FunctionParserUtils.h.

◆ SymFunctionPtr

template<bool is_ad = false>
typedef std::shared_ptr<SymFunction> FunctionParserUtils< is_ad >::SymFunctionPtr

Shorthand for an smart pointer to an autodiff function parser object.

Definition at line 65 of file FunctionParserUtils.h.

Member Enumeration Documentation

◆ FailureMethod

template<bool is_ad = false>
enum class FunctionParserUtils::FailureMethod
strongprotected

Enum for failure method.

Enumerator
nan 
nan_warning 
error 
exception 

Definition at line 116 of file FunctionParserUtils.h.

Constructor & Destructor Documentation

◆ FunctionParserUtils()

template<bool is_ad = false>
FunctionParserUtils< is_ad >::FunctionParserUtils ( const InputParameters parameters)

Member Function Documentation

◆ addFParserConstants()

template<bool is_ad = false>
void FunctionParserUtils< is_ad >::addFParserConstants ( SymFunctionPtr parser,
const std::vector< std::string > &  constant_names,
const std::vector< std::string > &  constant_expressions 
) const
protected

add constants (which can be complex expressions) to the parser object

◆ evaluate() [1/2]

template<bool is_ad = false>
GenericReal< is_ad > FunctionParserUtils< is_ad >::evaluate ( SymFunctionPtr ,
const std::string &  object_name = "" 
)
protected

Evaluate FParser object and check EvalError.

◆ evaluate() [2/2]

template<bool is_ad = false>
GenericReal< is_ad > FunctionParserUtils< is_ad >::evaluate ( SymFunctionPtr ,
const std::vector< GenericReal< is_ad > > &  ,
const std::string &  object_name = "" 
)
protected

Evaluate FParser object and check EvalError.

This version uses a supplied vector of function parameters, which is useful if an object uses more than one parsed function, which may have different function parameter values.

◆ functionsOptimize() [1/3]

template<bool is_ad = false>
virtual void FunctionParserUtils< is_ad >::functionsOptimize ( SymFunctionPtr parsed_function)
protectedvirtual

run FPOptimizer on the parsed function

◆ functionsOptimize() [2/3]

void FunctionParserUtils< true >::functionsOptimize ( SymFunctionPtr parsed_function)
protected

◆ functionsOptimize() [3/3]

void FunctionParserUtils< true >::functionsOptimize ( SymFunctionPtr parsed_function)
protected

Definition at line 211 of file FunctionParserUtils.C.

212{
213 // set desired epsilon for optimization!
214 auto tmp_eps = parsed_function->epsilon();
215 parsed_function->setEpsilon(_epsilon);
216
217 // base function
219 parsed_function->Optimize();
220 if (!_enable_jit || !parsed_function->JITCompile())
221 mooseError("AD parsed objects require JIT compilation to be enabled and working.");
222
223 parsed_function->setEpsilon(tmp_eps);
224}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const Real _epsilon
fuzzy comparison tolerance
bool _enable_jit
feature flags

◆ parsedFunctionSetup()

template<bool is_ad = false>
void FunctionParserUtils< is_ad >::parsedFunctionSetup ( SymFunctionPtr function,
const std::string &  expression,
const std::string &  variables,
const std::vector< std::string > &  constant_names,
const std::vector< std::string > &  constant_expressions,
const libMesh::Parallel::Communicator comm 
) const
protected

Performs setup steps on a SymFunction.

Parameters
functionreference to pointer to the function to set up
expressionexpression to parse
variablescomma separated string holding all the variables of the expression
constant_namesvector of names (symbols) of constants in the expression
constant_expressionsvectors of expressions (=values) of constants in the expression
commcommunicator used to stagger JIT file creations

◆ setParserFeatureFlags()

template<bool is_ad = false>
void FunctionParserUtils< is_ad >::setParserFeatureFlags ( SymFunctionPtr ) const

apply input parameters to internal feature flags of the parser object

◆ validParams()

template<bool is_ad = false>
static InputParameters FunctionParserUtils< is_ad >::validParams ( )
static

Member Data Documentation

◆ _disable_fpoptimizer

template<bool is_ad = false>
bool FunctionParserUtils< is_ad >::_disable_fpoptimizer
protected

Definition at line 111 of file FunctionParserUtils.h.

◆ _enable_ad_cache

template<bool is_ad = false>
bool FunctionParserUtils< is_ad >::_enable_ad_cache
protected

Definition at line 110 of file FunctionParserUtils.h.

◆ _enable_auto_optimize

template<bool is_ad = false>
bool FunctionParserUtils< is_ad >::_enable_auto_optimize
protected

Definition at line 112 of file FunctionParserUtils.h.

◆ _enable_jit

template<bool is_ad = false>
bool FunctionParserUtils< is_ad >::_enable_jit
protected

feature flags

Definition at line 109 of file FunctionParserUtils.h.

◆ _epsilon

template<bool is_ad = false>
const Real FunctionParserUtils< is_ad >::_epsilon
protected

fuzzy comparison tolerance

Definition at line 128 of file FunctionParserUtils.h.

◆ _eval_error_msg

template<bool is_ad = false>
const char* FunctionParserUtils< is_ad >::_eval_error_msg[]
staticprotected

table of FParser eval error codes

Definition at line 122 of file FunctionParserUtils.h.

◆ _evalerror_behavior

template<bool is_ad = false>
enum FunctionParserUtils::FailureMethod FunctionParserUtils< is_ad >::_evalerror_behavior
protected

◆ _func_params

template<bool is_ad = false>
std::vector<GenericReal<is_ad> > FunctionParserUtils< is_ad >::_func_params
protected

Array to stage the parameters passed to the functions when calling Eval.

Definition at line 125 of file FunctionParserUtils.h.

◆ _quiet_nan

template<bool is_ad = false>
const Real FunctionParserUtils< is_ad >::_quiet_nan
protected

appropriate not a number value to return

Definition at line 119 of file FunctionParserUtils.h.


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