https://mooseframework.inl.gov
ParsedConvergence.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 "Convergence.h"
13 #include "FunctionParserUtils.h"
14 
15 class Function;
16 
20 class ParsedConvergence : public Convergence, public FunctionParserUtils<false>
21 {
22 public:
24 
26 
27  virtual MooseConvergenceStatus checkConvergence(unsigned int iter) override;
28 
29  virtual void initialSetup() override;
30 
31 protected:
33 
37  void initializeSymbols();
38  void initializePostprocessorSymbol(unsigned int i);
39  void initializeFunctionSymbol(unsigned int i);
40  void initializeConvergenceSymbol(unsigned int i);
41  void initializeConstantSymbol(unsigned int i);
42 
48  SymFunctionPtr makeParsedFunction(const std::string & expression);
49 
55  void updateSymbolValues(unsigned int iter);
58  void updateConvergenceSymbolValues(unsigned int iter);
59 
66  bool convertRealToBool(Real value, const std::string & param) const;
67 
69 
71  std::vector<std::string> _symbol_names;
73  std::vector<std::string> _symbol_values;
74 
76  const std::string _convergence_expression;
78  const std::string _divergence_expression;
79 
84 
86  std::vector<Real> _convergence_function_params;
88  std::vector<Real> _divergence_function_params;
89 
91  std::vector<const PostprocessorValue *> _pp_values;
92  std::vector<unsigned int> _pp_indices;
93 
95  std::vector<Function *> _functions;
96  std::vector<unsigned int> _function_indices;
97 
99  std::vector<Convergence *> _convergences;
100  std::vector<std::string> _convergence_symbol_names;
101  std::vector<unsigned int> _convergence_indices;
102 };
Base class for function objects.
Definition: Function.h:36
std::shared_ptr< SymFunction > SymFunctionPtr
Shorthand for an smart pointer to an autodiff function parser object.
std::vector< unsigned int > _function_indices
std::vector< std::string > _convergence_symbol_names
const std::string _convergence_expression
Expression to parse for convergence.
std::vector< Real > _convergence_function_params
Convergence function parameters.
static InputParameters validParams()
SymFunctionPtr _divergence_function
Parsed function for divergence.
void updateSymbolValues(unsigned int iter)
Updates non-constant symbol values.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Evaluates convergence from a parsed expression.
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
void updatePostprocessorSymbolValues()
bool convertRealToBool(Real value, const std::string &param) const
Converts a Real value to a bool.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
void initializeFunctionSymbol(unsigned int i)
void initializePostprocessorSymbol(unsigned int i)
std::vector< unsigned int > _pp_indices
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
Base class for convergence criteria.
Definition: Convergence.h:21
void updateConvergenceSymbolValues(unsigned int iter)
ParsedConvergence(const InputParameters &parameters)
std::vector< const PostprocessorValue * > _pp_values
Post-processor values in the provided symbols.
std::vector< unsigned int > _convergence_indices
usingFunctionParserUtilsMembers(false)
MooseConvergenceStatus
Status returned by calls to checkConvergence.
Definition: Convergence.h:33
std::vector< std::string > _symbol_values
Corresponding symbol values (Convergence, Function, Postprocessor, or constant)
std::vector< Convergence * > _convergences
Convergences in the provided symbols.
virtual MooseConvergenceStatus checkConvergence(unsigned int iter) override
Returns convergence status.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void initializeSymbols()
Initializes symbols used in the parsed expression.
SymFunctionPtr makeParsedFunction(const std::string &expression)
Makes a parsed function.
void initializeConstantSymbol(unsigned int i)
void initializeConvergenceSymbol(unsigned int i)
const InputParameters & parameters() const
Get the parameters of the object.
std::vector< Real > _divergence_function_params
Divergence function parameters.
FEProblemBase & _fe_problem
std::vector< Function * > _functions
Functions in the provided symbols.
SymFunctionPtr _convergence_function
Parsed function for convergence.
std::vector< std::string > _symbol_names
User-defined symbols to use in parsed expression.
const std::string _divergence_expression
Expression to parse for divergence.