https://mooseframework.inl.gov
ParsedAux.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 "AuxKernel.h"
13 #include "FunctionParserUtils.h"
14 
18 class ParsedAux : public AuxKernel, public FunctionParserUtils<false>
19 {
20 public:
22 
24 
25 protected:
26  virtual Real computeValue() override;
27 
30 
32  void validateFunctorNames();
33 
40  template <typename T>
41  void validateGenericVectorNames(const std::vector<T> & names_vec, const std::string & param_name);
42 
44  std::string _function;
45 
47  const unsigned int _nargs;
48  const std::vector<const VariableValue *> _args;
49 
51  const std::vector<MaterialPropertyName> & _matprop_names;
52  const std::vector<MaterialPropertyName> & _ad_matprop_names;
53  const unsigned int _n_matprops;
54  const unsigned int _n_ad_matprops;
55  std::vector<const MaterialProperty<Real> *> _matprops;
56  std::vector<const ADMaterialProperty<Real> *> _ad_matprops;
57 
59  const bool _use_xyzt;
60 
62  const std::vector<std::string> _xyzt;
63 
66 
68 
70  const std::vector<MooseFunctorName> & _functor_names;
71 
73  const unsigned int _n_functors;
74 
76  const std::vector<std::string> _functor_symbols;
77 
79  std::vector<const Moose::Functor<Real> *> _functors;
80 
82  std::vector<std::string> _coupled_variable_names;
83 };
84 
85 template <typename T>
86 void
87 ParsedAux::validateGenericVectorNames(const std::vector<T> & names_vec,
88  const std::string & param_name)
89 {
90  for (const auto & name : names_vec)
91  {
92  // Make sure symbol is not x, y, z, or t
93  if (_use_xyzt && (std::find(_xyzt.begin(), _xyzt.end(), name) != _xyzt.end()))
94  paramError(
95  param_name,
96  "x, y, z, and t cannot be used in '" + param_name + "' when use_xyzt=true." +
97  (param_name == "functor_names" ? " Use 'functor_symbols' to disambiguate." : ""));
98  // Make sure symbol is not a coupled variable name
99  if (_coupled_variable_names.size() &&
100  (std::find(_coupled_variable_names.begin(), _coupled_variable_names.end(), name) !=
102  paramError(
103  param_name,
104  "Values in '" + param_name + "' cannot overlap with coupled variable names." +
105  (param_name == "functor_names" ? " Use 'functor_symbols' to disambiguate." : ""));
106  }
107 }
void validateFunctorNames()
Function to validate the names in _functor_names.
Definition: ParsedAux.C:183
const std::vector< std::string > _xyzt
coordinate and time variable names
Definition: ParsedAux.h:62
std::shared_ptr< SymFunction > SymFunctionPtr
Shorthand for an smart pointer to an autodiff function parser object.
const unsigned int _nargs
coupled variables
Definition: ParsedAux.h:47
std::vector< const Moose::Functor< Real > * > _functors
Vector of pointers to functors.
Definition: ParsedAux.h:79
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const std::vector< MaterialPropertyName > & _matprop_names
material properties
Definition: ParsedAux.h:51
const bool _use_xyzt
import coordinates and time
Definition: ParsedAux.h:59
std::vector< std::string > _coupled_variable_names
Vector of coupled variable names.
Definition: ParsedAux.h:82
const std::vector< MooseFunctorName > & _functor_names
Functors to use in the parsed expression.
Definition: ParsedAux.h:70
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
std::vector< const ADMaterialProperty< Real > * > _ad_matprops
Definition: ParsedAux.h:56
AuxKernel that evaluates a parsed function expression.
Definition: ParsedAux.h:18
SymFunctionPtr _func_F
function parser object to compute the local value of the aux-variable
Definition: ParsedAux.h:65
usingFunctionParserUtilsMembers(false)
const std::vector< std::string > _functor_symbols
Symbolic name to use for each functor.
Definition: ParsedAux.h:76
std::string _function
function expression
Definition: ParsedAux.h:44
const unsigned int _n_matprops
Definition: ParsedAux.h:53
const unsigned int _n_functors
Number of functors.
Definition: ParsedAux.h:73
const std::vector< MaterialPropertyName > & _ad_matprop_names
Definition: ParsedAux.h:52
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
std::vector< const MaterialProperty< Real > * > _matprops
Definition: ParsedAux.h:55
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::vector< const VariableValue * > _args
Definition: ParsedAux.h:48
const InputParameters & parameters() const
Get the parameters of the object.
static InputParameters validParams()
Definition: ParsedAux.C:15
void validateGenericVectorNames(const std::vector< T > &names_vec, const std::string &param_name)
Function to ensure vector entries (names) do not overlap with xyzt or coupled variable names...
Definition: ParsedAux.h:87
const unsigned int _n_ad_matprops
Definition: ParsedAux.h:54
ParsedAux(const InputParameters &parameters)
Definition: ParsedAux.C:56
virtual Real computeValue() override
Compute and return the value of the aux variable.
Definition: ParsedAux.C:136
void validateFunctorSymbols()
Function to validate the symbols in _functor_symbols.
Definition: ParsedAux.C:177