https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
18class ParsedAux : public AuxKernel, public FunctionParserUtils<false>
19{
20public:
22
24
25protected:
26 virtual Real computeValue() override;
27
30
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
83
85 std::vector<std::string> _coupled_variable_names;
86};
87
88template <typename T>
89void
90ParsedAux::validateGenericVectorNames(const std::vector<T> & names_vec,
91 const std::string & param_name)
92{
93 for (const auto & name : names_vec)
94 {
95 // Make sure symbol is not x, y, z, or t
96 if (_use_xyzt && (std::find(_xyzt.begin(), _xyzt.end(), name) != _xyzt.end()))
98 param_name,
99 "x, y, z, and t cannot be used in '" + param_name + "' when use_xyzt=true." +
100 (param_name == "functor_names" ? " Use 'functor_symbols' to disambiguate." : ""));
101 // Make sure symbol is not a coupled variable name
102 if (_coupled_variable_names.size() &&
103 (std::find(_coupled_variable_names.begin(), _coupled_variable_names.end(), name) !=
106 param_name,
107 "Values in '" + param_name + "' cannot overlap with coupled variable names." +
108 (param_name == "functor_names" ? " Use 'functor_symbols' to disambiguate." : ""));
109 }
110}
std::shared_ptr< SymFunction > SymFunctionPtr
Shorthand for an smart pointer to an autodiff function parser object.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
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 ...
Definition MooseBase.h:457
AuxKernel that evaluates a parsed function expression.
Definition ParsedAux.h:19
std::vector< const MaterialProperty< Real > * > _matprops
Definition ParsedAux.h:55
const std::vector< MaterialPropertyName > & _matprop_names
material properties
Definition ParsedAux.h:51
const bool _use_qp_functor_arguments
Whether to use qp-functor arguments.
Definition ParsedAux.h:82
std::string _function
function expression
Definition ParsedAux.h:44
const unsigned int _n_ad_matprops
Definition ParsedAux.h:54
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:90
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:85
static InputParameters validParams()
Definition ParsedAux.C:15
const std::vector< MooseFunctorName > & _functor_names
Functors to use in the parsed expression.
Definition ParsedAux.h:70
void validateFunctorSymbols()
Function to validate the symbols in _functor_symbols.
Definition ParsedAux.C:211
const unsigned int _nargs
coupled variables
Definition ParsedAux.h:47
const unsigned int _n_matprops
Definition ParsedAux.h:53
const std::vector< MaterialPropertyName > & _ad_matprop_names
Definition ParsedAux.h:52
const std::vector< std::string > _functor_symbols
Symbolic name to use for each functor.
Definition ParsedAux.h:76
void validateFunctorNames()
Function to validate the names in _functor_names.
Definition ParsedAux.C:217
std::vector< const ADMaterialProperty< Real > * > _ad_matprops
Definition ParsedAux.h:56
const std::vector< std::string > _xyzt
coordinate and time variable names
Definition ParsedAux.h:62
const unsigned int _n_functors
Number of functors.
Definition ParsedAux.h:73
virtual Real computeValue() override
Compute and return the value of the aux variable.
Definition ParsedAux.C:146
usingFunctionParserUtilsMembers(false)
std::vector< const Moose::Functor< Real > * > _functors
Vector of pointers to functors.
Definition ParsedAux.h:79
const std::vector< const VariableValue * > _args
Definition ParsedAux.h:48
SymFunctionPtr _func_F
function parser object to compute the local value of the aux-variable
Definition ParsedAux.h:65