www.mooseframework.org
GenericFunctionMaterial.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 #include "Function.h"
17 
18 template <>
21 {
23  params.addParam<std::vector<std::string>>("prop_names",
24  "The names of the properties this material will have");
25  params.addParam<std::vector<FunctionName>>("prop_values",
26  "The corresponding names of the "
27  "functions that are going to provide "
28  "the values for the variables");
29  params.addDeprecatedParam<bool>("enable_stateful",
30  false,
31  "Enable the declaration of old and older values",
32  "all properties can implicitly become stateful");
33  return params;
34 }
35 
37  : Material(parameters),
38  _prop_names(getParam<std::vector<std::string>>("prop_names")),
39  _prop_values(getParam<std::vector<FunctionName>>("prop_values")),
40  _enable_stateful(getParam<bool>("enable_stateful"))
41 {
42  unsigned int num_names = _prop_names.size();
43  unsigned int num_values = _prop_values.size();
44 
45  if (num_names != num_values)
46  mooseError(
47  "Number of prop_names much match the number of prop_values for a GenericFunctionMaterial!");
48 
49  _num_props = num_names;
50 
51  _properties.resize(num_names);
52 
53  if (_enable_stateful)
54  {
55  _properties_old.resize(num_names);
56  _properties_older.resize(num_names);
57  }
58 
59  _functions.resize(num_names);
60 
61  for (unsigned int i = 0; i < _num_props; i++)
62  {
63  _properties[i] = &declareProperty<Real>(_prop_names[i]);
65  }
66 }
67 
68 void
70 {
72 }
73 
74 void
76 {
78 }
79 
80 void
82 {
83  for (unsigned int i = 0; i < _num_props; i++)
84  (*_properties[i])[_qp] = (*_functions[i]).value(_t, _q_point[_qp]);
85 }
const MooseArray< Point > & _q_point
Definition: Material.h:225
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
std::vector< MaterialProperty< Real > * > _properties_old
void computeQpFunctions()
A helper method for evaluating the functions.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::vector< FunctionName > _prop_values
unsigned int _qp
Definition: Material.h:220
InputParameters validParams< GenericFunctionMaterial >()
std::vector< std::string > _prop_names
std::vector< MaterialProperty< Real > * > _properties
std::vector< Function * > _functions
virtual void initQpStatefulProperties() override
Initialize stateful properties at quadrature points.
GenericFunctionMaterial(const InputParameters &parameters)
Materials compute MaterialProperties.
Definition: Material.h:53
bool _enable_stateful
Flag for calling declareProperyOld/Older.
Function & getFunctionByName(const FunctionName &name)
Get a function with a given name.
virtual void computeQpProperties() override
Users must override this method.
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
InputParameters validParams< Material >()
Definition: Material.C:27
std::vector< MaterialProperty< Real > * > _properties_older