www.mooseframework.org
GenericConstantMaterial.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
16 
17 #include "libmesh/quadrature.h"
18 
19 template <>
22 {
24  params.addParam<std::vector<std::string>>("prop_names",
25  "The names of the properties this material will have");
26  params.addParam<std::vector<Real>>("prop_values",
27  "The values associated with the named properties");
28  return params;
29 }
30 
32  : Material(parameters),
33  _prop_names(getParam<std::vector<std::string>>("prop_names")),
34  _prop_values(getParam<std::vector<Real>>("prop_values"))
35 {
36  unsigned int num_names = _prop_names.size();
37  unsigned int num_values = _prop_values.size();
38 
39  if (num_names != num_values)
40  mooseError(
41  "Number of prop_names must match the number of prop_values for a GenericConstantMaterial!");
42 
43  _num_props = num_names;
44 
45  _properties.resize(num_names);
46 
47  for (unsigned int i = 0; i < _num_props; i++)
48  _properties[i] = &declareProperty<Real>(_prop_names[i]);
49 }
50 
51 void
53 {
55 }
56 
57 void
59 {
60  for (unsigned int i = 0; i < _num_props; i++)
61  (*_properties[i])[_qp] = _prop_values[i];
62 }
virtual void computeQpProperties() override
Users must override this method.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::vector< Real > _prop_values
unsigned int _qp
Definition: Material.h:220
std::vector< MaterialProperty< Real > * > _properties
GenericConstantMaterial(const InputParameters &parameters)
std::vector< std::string > _prop_names
Materials compute MaterialProperties.
Definition: Material.h:53
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...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
virtual void initQpStatefulProperties() override
Initialize stateful properties at quadrature points.
InputParameters validParams< Material >()
Definition: Material.C:27
InputParameters validParams< GenericConstantMaterial >()