Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
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 
15 template <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 
33 template <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 
54 template <bool is_ad>
55 void
57 {
58  computeQpProperties();
59 }
60 
61 template <bool is_ad>
62 void
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 
std::vector< GenericMaterialProperty< RealVectorValue, is_ad > * > _properties
A vector of pointer to the material properties.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:148
const std::vector< Real > & _prop_values
The vector values of each vector material property.
registerMooseObject("MooseApp", GenericConstantVectorMaterial)
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...
virtual void initQpStatefulProperties() override
Initialize stateful properties at quadrature points.
virtual void computeQpProperties() override
Users must override this method.
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:33
Materials compute MaterialProperties.
Definition: Material.h:34
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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...
std::vector< std::string > _prop_names
The names of the constant vector material properties.
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
GenericConstantVectorMaterialTempl(const InputParameters &parameters)
unsigned int _num_props
The number of constant vector material properties defined.