www.mooseframework.org
GenericConstantMaterial.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
12 #include "libmesh/quadrature.h"
13 
15 
16 template <>
19 {
21  params.addParam<std::vector<std::string>>("prop_names",
22  "The names of the properties this material will have");
23  params.addParam<std::vector<Real>>("prop_values",
24  "The values associated with the named properties");
25  params.declareControllable("prop_values");
26  return params;
27 }
28 
30  : Material(parameters),
31  _prop_names(getParam<std::vector<std::string>>("prop_names")),
32  _prop_values(getParam<std::vector<Real>>("prop_values"))
33 {
34  unsigned int num_names = _prop_names.size();
35  unsigned int num_values = _prop_values.size();
36 
37  if (num_names != num_values)
38  mooseError(
39  "Number of prop_names must match the number of prop_values for a GenericConstantMaterial!");
40 
41  _num_props = num_names;
42 
43  _properties.resize(num_names);
44 
45  for (unsigned int i = 0; i < _num_props; i++)
46  _properties[i] = &declareProperty<Real>(_prop_names[i]);
47 }
48 
49 void
51 {
53 }
54 
55 void
57 {
58  for (unsigned int i = 0; i < _num_props; i++)
59  (*_properties[i])[_qp] = _prop_values[i];
60 }
const std::vector< Real > & _prop_values
virtual void computeQpProperties() override
Users must override this method.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
registerMooseObject("MooseApp", GenericConstantMaterial)
unsigned int _qp
Definition: Material.h:222
This material automatically declares as material properties whatever is passed to it through the para...
std::vector< MaterialProperty< Real > * > _properties
GenericConstantMaterial(const InputParameters &parameters)
std::vector< std::string > _prop_names
Materials compute MaterialProperties.
Definition: Material.h:46
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
virtual void initQpStatefulProperties() override
Initialize stateful properties at quadrature points.
InputParameters validParams< Material >()
Definition: Material.C:22
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
InputParameters validParams< GenericConstantMaterial >()