https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GenericConstantMaterial.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{
21 "Declares material properties based on names and values prescribed by input parameters.");
22 params.addRequiredParam<std::vector<std::string>>(
23 "prop_names", "The names of the properties this material will have");
24 params.addRequiredParam<std::vector<Real>>("prop_values",
25 "The values associated with the named properties");
26 params.set<MooseEnum>("constant_on") = "SUBDOMAIN";
27 params.declareControllable("prop_values");
28 return params;
29}
30
31template <bool is_ad>
33 const InputParameters & parameters)
34 : Material(parameters),
35 _prop_names(getParam<std::vector<std::string>>("prop_names")),
36 _prop_values(getParam<std::vector<Real>>("prop_values"))
37{
38 unsigned int num_names = _prop_names.size();
39 unsigned int num_values = _prop_values.size();
40
41 if (num_names != num_values)
43 "Number of prop_names must match the number of prop_values for a GenericConstantMaterial!");
44
45 _num_props = num_names;
46
47 _properties.resize(num_names);
48
49 for (unsigned int i = 0; i < _num_props; i++)
50 _properties[i] = &declareGenericProperty<Real, is_ad>(_prop_names[i]);
51}
52
53template <bool is_ad>
54void
59
60template <bool is_ad>
61void
63{
64 for (unsigned int i = 0; i < _num_props; i++)
65 (*_properties[i])[_qp] = _prop_values[i];
66}
67
registerMooseObject("MooseApp", GenericConstantMaterial)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
This material automatically declares as material properties whatever is passed to it through the para...
static InputParameters validParams()
const std::vector< Real > & _prop_values
const std::vector< std::string > & _prop_names
std::vector< GenericMaterialProperty< Real, is_ad > * > _properties
GenericConstantMaterialTempl(const InputParameters &parameters)
virtual void computeQpProperties() override
Users must override this method.
virtual void initQpStatefulProperties() override
Initialize stateful properties at quadrature points.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
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.
Materials compute MaterialProperties.
Definition Material.h:36
static InputParameters validParams()
Definition Material.C:14
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55