https://mooseframework.inl.gov
THMParsedFunctionWrapper.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 "MooseError.h"
13 #include "MooseTypes.h"
14 #include "ControlData.h"
15 #include "libmesh/parsed_function.h"
16 #include <string>
17 #include <vector>
18 
19 class Simulation;
20 class FEProblemBase;
21 class Function;
22 
29 {
30 public:
40  FEProblemBase & feproblem,
41  const std::string & function_str,
42  const std::vector<std::string> & vars,
43  const std::vector<std::string> & vals,
44  const THREAD_ID tid = 0);
45 
49  Real evaluate(Real t, const Point & p);
50 
54  const std::vector<ControlData<Real> *> getRealControlData() { return _cd_real_vals; }
55 
59  const std::vector<ControlData<bool> *> getBoolControlData() { return _cd_bool_vals; }
60 
61 private:
64 
67 
69  const std::string & _function_str;
70 
72  const std::vector<std::string> & _vars;
73 
75  const std::vector<std::string> & _vals_input;
76 
78  std::vector<Real> _initial_vals;
79 
81  std::unique_ptr<libMesh::ParsedFunction<Real>> _function_ptr;
82 
84  std::vector<unsigned int> _cd_real_index;
85 
87  std::vector<ControlData<Real> *> _cd_real_vals;
88 
90  std::vector<unsigned int> _cd_bool_index;
91 
93  std::vector<ControlData<bool> *> _cd_bool_vals;
94 
96  std::vector<unsigned int> _scalar_index;
97 
99  std::vector<const VariableValue *> _scalar_vals;
100 
102  std::vector<unsigned int> _function_index;
103 
105  std::vector<const Function *> _functions;
106 
108  std::vector<Real *> _addr;
109 
112 
117  void initialize();
118 
122  void update();
123 
127  void updateFunctionValues(Real t, const Point & pt);
128 
133 };
std::unique_ptr< libMesh::ParsedFunction< Real > > _function_ptr
Pointer to the libMesh::ParsedFunction object.
std::vector< unsigned int > _scalar_index
Stores _addr variable indices for each scalar variable value.
const std::vector< ControlData< bool > * > getBoolControlData()
Get list of boolean-valued control data objects.
std::vector< ControlData< bool > * > _cd_bool_vals
Vector of pointers to bool control data values this parsed function is using.
std::vector< unsigned int > _cd_bool_index
Stores _addr variable indices for each ControlData<bool> value.
Main class for simulation (the driver of the simulation)
Definition: Simulation.h:29
Real evaluate(Real t, const Point &p)
Perform the evaluation of the libMesh::ParsedFunction.
const std::vector< std::string > & _vars
List of variables supplied from the user.
char ** vars
const THREAD_ID _tid
The thread id passed from owning object.
std::vector< const Function * > _functions
Vector of Functions this parsed function is using.
std::vector< Real > _initial_vals
Storage for the initial values of _vars variables used by the libMesh::ParsedFunction object...
void updateControlDataValues()
Updates control data values for use in the libMesh::ParsedFunction.
std::vector< const VariableValue * > _scalar_vals
Vector of pointers to scalar variables values.
A wrapper class for creating and evaluating parsed functions via the libMesh::ParsedFunction interfac...
std::vector< Real * > _addr
Pointers to the variables that store the values of _vars inside the libMesh::ParsedFunction object...
const std::vector< std::string > & _vals_input
List of the values for the variables supplied by the user.
void updateFunctionValues(Real t, const Point &pt)
Updates function values for use in the libMesh::ParsedFunction.
std::vector< unsigned int > _cd_real_index
Stores _addr variable indices for each ControlData<Real> value.
const std::string & _function_str
Reference to the string containing the function to evaluate.
std::vector< unsigned int > _function_index
Stores _addr variable indices for each Function.
FEProblemBase & _feproblem
Reference to the FEProblemBase object.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Simulation & _sim
Reference to the Simulation object.
THMParsedFunctionWrapper(Simulation &sim, 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.
void update()
Updates scalar values for use in the libMesh::ParsedFunction.
void initialize()
Initialization method that prepares the _vars and _initial_vals for use by the libMesh::ParsedFunctio...
const std::vector< ControlData< Real > * > getRealControlData()
Get list of Real-valued control data objects.
unsigned int THREAD_ID
std::vector< ControlData< Real > * > _cd_real_vals
Vector of pointers to Real control data values this parsed function is using.