www.mooseframework.org
GenericFunctionMaterial.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 #include "Function.h"
12 
14 
15 template <>
18 {
20  params.addParam<std::vector<std::string>>("prop_names",
21  "The names of the properties this material will have");
22  params.addParam<std::vector<FunctionName>>("prop_values",
23  "The corresponding names of the "
24  "functions that are going to provide "
25  "the values for the variables");
26  params.addDeprecatedParam<bool>("enable_stateful",
27  false,
28  "Enable the declaration of old and older values",
29  "all properties can implicitly become stateful");
30  return params;
31 }
32 
34  : Material(parameters),
35  _prop_names(getParam<std::vector<std::string>>("prop_names")),
36  _prop_values(getParam<std::vector<FunctionName>>("prop_values")),
37  _enable_stateful(getParam<bool>("enable_stateful"))
38 {
39  unsigned int num_names = _prop_names.size();
40  unsigned int num_values = _prop_values.size();
41 
42  if (num_names != num_values)
43  mooseError(
44  "Number of prop_names much match the number of prop_values for a GenericFunctionMaterial!");
45 
46  _num_props = num_names;
47 
48  _properties.resize(num_names);
49 
50  if (_enable_stateful)
51  {
52  _properties_old.resize(num_names);
53  _properties_older.resize(num_names);
54  }
55 
56  _functions.resize(num_names);
57 
58  for (unsigned int i = 0; i < _num_props; i++)
59  {
60  _properties[i] = &declareProperty<Real>(_prop_names[i]);
62  }
63 }
64 
65 void
67 {
69 }
70 
71 void
73 {
75 }
76 
77 void
79 {
80  for (unsigned int i = 0; i < _num_props; i++)
81  (*_properties[i])[_qp] = (*_functions[i]).value(_t, _q_point[_qp]);
82 }
const MooseArray< Point > & _q_point
Definition: Material.h:227
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
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
std::vector< const MaterialProperty< Real > * > _properties_older
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
unsigned int _qp
Definition: Material.h:222
InputParameters validParams< GenericFunctionMaterial >()
std::vector< std::string > _prop_names
This material automatically declares as material properties whatever is passed to it through the para...
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:46
bool _enable_stateful
Flag for calling declareProperyOld/Older.
Function & getFunctionByName(const FunctionName &name)
Get a function with a given name.
std::vector< const MaterialProperty< Real > * > _properties_old
virtual void computeQpProperties() override
Users must override this method.
registerMooseObject("MooseApp", GenericFunctionMaterial)
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...
InputParameters validParams< Material >()
Definition: Material.C:22