https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GenericConstantVectorMaterial.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{
19
21 params.addClassDescription("Declares material properties based on names and vector values "
22 "prescribed by input parameters.");
23 params.addRequiredParam<std::vector<std::string>>(
24 "prop_names", "The names of the properties this material will have");
25 params.addRequiredParam<std::vector<Real>>("prop_values",
26 "The values associated with the named properties. "
27 "The vector lengths must be the same.");
28 params.declareControllable("prop_values");
29 params.set<MooseEnum>("constant_on") = "SUBDOMAIN";
30 return params;
31}
32
33template <bool is_ad>
35 const InputParameters & parameters)
36 : Material(parameters),
37 _prop_names(getParam<std::vector<std::string>>("prop_names")),
38 _prop_values(getParam<std::vector<Real>>("prop_values"))
39{
40 unsigned int num_names = _prop_names.size();
41 unsigned int num_values = _prop_values.size();
42
43 if (num_values != num_names * LIBMESH_DIM)
44 mooseError("prop_values must be a equal to dim * number of prop_names for a "
45 "GenericConstantVectorMaterial.");
46
47 _num_props = num_names;
48 _properties.resize(num_names);
49
50 for (unsigned int i = 0; i < _num_props; i++)
51 _properties[i] = &declareGenericProperty<RealVectorValue, is_ad>(_prop_names[i]);
52}
53
54template <bool is_ad>
55void
60
61template <bool is_ad>
62void
64{
65 for (unsigned int i = 0; i < _num_props; i++)
66 for (const auto j : make_range(Moose::dim))
67 (*_properties[i])[_qp](j) = _prop_values[i * LIBMESH_DIM + j];
68}
69
registerMooseObject("MooseApp", GenericConstantVectorMaterial)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
virtual void computeQpProperties() override
Users must override this method.
std::vector< std::string > _prop_names
The names of the constant vector material properties.
const std::vector< Real > & _prop_values
The vector values of each vector material property.
virtual void initQpStatefulProperties() override
Initialize stateful properties at quadrature points.
unsigned int _num_props
The number of constant vector material properties defined.
GenericConstantVectorMaterialTempl(const InputParameters &parameters)
std::vector< GenericMaterialProperty< RealVectorValue, is_ad > * > _properties
A vector of pointer to the material properties.
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
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition Moose.h:165