https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GenericFunctorTimeDerivativeMaterial.C
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
11
14
15template <bool is_ad>
18{
20 params.set<ExecFlagEnum>("execute_on") = {EXEC_ALWAYS};
22 "FunctorMaterial object for declaring properties that are populated by evaluation of "
23 "time derivatives of Functors objects. (such as variables, constants, postprocessors). "
24 "The time derivative is only returned if the 'dot' functor routine is implemented.");
25 params.addParam<std::vector<std::string>>("prop_names",
26 "The names of the properties this material will have");
27
28 params.addParam<std::vector<MooseFunctorName>>("prop_values",
29 "The corresponding names of the "
30 "functors which gradient are going to provide "
31 "the values for the variables");
32 return params;
33}
34
35template <bool is_ad>
37 const InputParameters & parameters)
38 : FunctorMaterial(parameters),
39 _prop_names(getParam<std::vector<std::string>>("prop_names")),
40 _prop_values(getParam<std::vector<MooseFunctorName>>("prop_values")),
41 _num_props(_prop_names.size())
42{
43 unsigned int num_values = _prop_values.size();
44
45 if (_num_props != num_values)
46 mooseError("Number of prop_names must match the number of prop_values for a "
47 "GenericFunctorTimeDerivativeMaterial!");
48
49 // Check that there is no name conflict, a common mistake with this object
50 for (const auto i : make_range(_num_props))
51 for (const auto j : make_range(num_values))
52 if (_prop_names[i] == _prop_values[j])
53 paramError("prop_names",
54 "prop_names should not be the same as any of the prop_values. They"
55 " can both be functors, and functors may not have the same name.");
56
57 _functors.resize(_num_props);
58
59 for (const auto i : make_range(_num_props))
60 {
62 paramError("prop_names", "Postprocessors should not be used in this functor material");
63 _functors[i] = &getFunctor<GenericReal<is_ad>>(_prop_values[i]);
64 }
65
66 const std::set<ExecFlagType> clearance_schedule(_execute_enum.begin(), _execute_enum.end());
67 for (const auto i : make_range(_num_props))
69 _prop_names[i],
70 [this, i](const auto & r, const auto & t) -> GenericReal<is_ad>
71 { return (*_functors[i]).dot(r, t); },
72 clearance_schedule);
73}
74
registerMooseObject("MooseApp", GenericFunctorTimeDerivativeMaterial)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
Moose::GenericType< Real, is_ad > GenericReal
Definition MooseTypes.h:698
const ExecFlagType EXEC_ALWAYS
Definition Moose.C:53
A MultiMooseEnum object to hold "execute_on" flags.
bool hasPostprocessor(const std::string &name) const
Deprecated.
FunctorMaterials compute functor material properties.
const Moose::FunctorBase< T > & addFunctorProperty(const std::string &name, PolymorphicLambda my_lammy, const std::set< ExecFlagType > &clearance_schedule={EXEC_ALWAYS})
Declare a functor material property.
static InputParameters validParams()
This material automatically declares as functor material properties whatever is passed to it through ...
std::vector< const Moose::Functor< GenericReal< is_ad > > * > _functors
Vector of the functors.
std::vector< MooseFunctorName > _prop_values
Names of the functors to evaluate for those properties.
GenericFunctorTimeDerivativeMaterialTempl(const InputParameters &parameters)
std::vector< std::string > _prop_names
Names of the functor material properties to define.
const unsigned int _num_props
Number of properties to define.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
FEProblemBase & _fe_problem
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
MooseEnumIterator end() const
MooseEnumIterator begin() const
Returns a begin/end iterator to all of the set values in the enum.
const ExecFlagEnum & _execute_enum
Execute settings for this object.