www.mooseframework.org
MooseParsedFunctionWrapper.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #ifndef MOOSEPARSEDFUNCTIONWRAPPER_H
16 #define MOOSEPARSEDFUNCTIONWRAPPER_H
17 
18 // MOOSE includes
19 #include "MooseError.h"
20 #include "MooseTypes.h"
21 
22 #include "libmesh/parsed_function.h"
23 
24 // C++ includes
25 #include <string>
26 #include <vector>
27 
28 // Forward declarations
29 class FEProblemBase;
30 
39 {
40 public:
49  const std::string & function_str,
50  const std::vector<std::string> & vars,
51  const std::vector<std::string> & vals,
52  const THREAD_ID tid = 0);
53 
60 
66  template <typename T>
67  T evaluate(Real t, const Point & p);
68 
73  RealGradient evaluateGradient(Real t, const Point & p);
74 
79  Real evaluateDot(Real t, const Point & p);
80 
81 private:
84 
86  const std::string & _function_str;
87 
89  const std::vector<std::string> & _vars;
90 
92  const std::vector<std::string> & _vals_input;
93 
95  std::vector<Real> _vals;
96 
98  std::unique_ptr<ParsedFunction<Real>> _function_ptr;
99 
101  std::vector<unsigned int> _pp_index;
102 
104  std::vector<const Real *> _pp_vals;
105 
107  std::vector<unsigned int> _scalar_index;
108 
110  std::vector<Real *> _scalar_vals;
111 
113  std::vector<Real *> _addr;
114 
117 
122  void initialize();
123 
127  void update();
128 
129  // moose_unit needs access
130  friend class ParsedFunctionTest;
131 };
132 
136 template <typename T>
137 T
138 evaluate(Real /*t*/, const Point & /*p*/)
139 {
140  mooseError("The evaluate method is not defined for this type.");
141 }
142 
143 #endif // MOOOSEPARSEDFUNCTIONWRAPPER_H
RealVectorValue RealGradient
Definition: Assembly.h:43
const THREAD_ID _tid
The thread id passed from owning Function object.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
Real evaluateDot(Real t, const Point &p)
Evaluate the time derivative of the function which libMesh provides through automatic differentiation...
const std::vector< std::string > & _vals_input
List of the values for the variables supplied by the user.
const std::vector< std::string > & _vars
List of variables supplied from the user.
RealGradient evaluateGradient(Real t, const Point &p)
Evaluate the gradient of the function which libMesh provides through automatic differentiation.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
MooseParsedFunctionWrapper(FEProblemBase &feproblem, const std::string &function_str, const std::vector< std::string > &vars, const std::vector< std::string > &vals, const THREAD_ID tid=0)
Class constructor.
const std::string & _function_str
Reference to the string containing the function to evaluate.
std::vector< Real * > _scalar_vals
Vector of pointers to PP values.
void update()
Updates postprocessor values for use in the libMesh::ParsedFunction.
virtual ~MooseParsedFunctionWrapper()
Class destruction Deletes the pointer to the dynamically allocated instance of the underlying libMesh...
std::vector< Real * > _addr
Vector of pointers to the variables in libMesh::ParsedFunction.
std::vector< unsigned int > _pp_index
Stores the relative location of variables (in _vars) that are connected to Postprocessors.
FEProblemBase & _feproblem
Reference to the FEProblemBase object.
std::unique_ptr< ParsedFunction< Real > > _function_ptr
Pointer to the libMesh::ParsedFunction object.
std::vector< unsigned int > _scalar_index
Stores the relative location of variables (in _vars) that are connected to Scalar Variables...
T evaluate(Real t, const Point &p)
A template method for performing the evaluation of the libMesh::ParsedFunction Within the source two ...
void initialize()
Initialization method that prepares the vars and vals for use by the libMesh::ParsedFunction object a...
std::vector< Real > _vals
Storage for the values.
std::vector< const Real * > _pp_vals
Vector of pointers to PP values.
A wrapper class for creating and evaluating parsed functions via the libMesh::ParsedFunction interfac...
unsigned int THREAD_ID
Definition: MooseTypes.h:79