www.mooseframework.org
FunctionParserUtils.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "Moose.h"
13 
14 #include "libmesh/fparser_ad.hh"
15 
16 // C++ includes
17 #include <memory>
18 
19 // Forward declartions
21 class InputParameters;
22 
23 template <typename T>
25 
26 template <>
28 
30 {
31 public:
32  FunctionParserUtils(const InputParameters & parameters);
33 
35  typedef FunctionParserADBase<Real> ADFunction;
36 
38  typedef std::shared_ptr<ADFunction> ADFunctionPtr;
39 
42 
43 protected:
45  Real evaluate(ADFunctionPtr &);
46 
48  void addFParserConstants(ADFunctionPtr & parser,
49  const std::vector<std::string> & constant_names,
50  const std::vector<std::string> & constant_expressions);
51 
59 
61  const Real _nan;
62 
64  static const char * _eval_error_msg[];
65 
67  std::vector<Real> _func_params;
68 };
69 
static const char * _eval_error_msg[]
table of FParser eval error codes
Real evaluate(ADFunctionPtr &)
Evaluate FParser object and check EvalError.
void addFParserConstants(ADFunctionPtr &parser, const std::vector< std::string > &constant_names, const std::vector< std::string > &constant_expressions)
add constants (which can be complex expressions) to the parser object
FunctionParserADBase< Real > ADFunction
Shorthand for an autodiff function parser object.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::shared_ptr< ADFunction > ADFunctionPtr
Shorthand for an smart pointer to an autodiff function parser object.
InputParameters validParams()
This is the templated validParams() function that every MooseObject-derived class is required to spec...
FunctionParserUtils(const InputParameters &parameters)
const Real _nan
appropriate not a number value to return
InputParameters validParams< FunctionParserUtils >()
std::vector< Real > _func_params
Array to stage the parameters passed to the functions when calling Eval.
void setParserFeatureFlags(ADFunctionPtr &)
apply input paramters to internal feature flags of the parser object