https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GenericFunctionMaterial.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#include "Function.h"
12
15
16template <bool is_ad>
19{
21 params.addClassDescription("Material object for declaring properties that are populated by "
22 "evaluation of Function object.");
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 return params;
30}
31
32template <bool is_ad>
34 const InputParameters & parameters)
35 : Material(parameters),
36 _prop_names(getParam<std::vector<std::string>>("prop_names")),
37 _prop_values(getParam<std::vector<FunctionName>>("prop_values"))
38{
39 unsigned int num_names = _prop_names.size();
40 unsigned int num_values = _prop_values.size();
41
42 if (num_names != num_values)
44 "Number of prop_names must match the number of prop_values for a GenericFunctionMaterial!");
45
46 _num_props = num_names;
47
48 _properties.resize(num_names);
49 _functions.resize(num_names);
50
51 for (unsigned int i = 0; i < _num_props; i++)
52 {
53 _properties[i] = &declareGenericProperty<Real, is_ad>(_prop_names[i]);
55 }
56}
57
58template <bool is_ad>
59void
64
65template <bool is_ad>
66void
71
72template <bool is_ad>
73void
75{
76 for (unsigned int i = 0; i < _num_props; i++)
77 (*_properties[i])[_qp] = (*_functions[i]).value(_t, _q_point[_qp]);
78}
79
registerMooseObject("MooseApp", GenericFunctionMaterial)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const Function & getFunctionByName(const FunctionName &name) const
Get a function with a given name.
This material automatically declares as material properties whatever is passed to it through the para...
std::vector< FunctionName > _prop_values
The functions to use for each property.
void computeQpFunctions()
A helper method for evaluating the functions.
static InputParameters validParams()
std::vector< const Function * > _functions
Vector of pointers to the functions, stored here after retrieval using their name.
virtual void initQpStatefulProperties() override
Initialize stateful properties at quadrature points.
unsigned int _num_props
Number of properties that will be defined.
std::vector< std::string > _prop_names
Names of the material properties to define.
virtual void computeQpProperties() override
Users must override this method.
GenericFunctionMaterialTempl(const InputParameters &parameters)
std::vector< GenericMaterialProperty< Real, is_ad > * > _properties
Vector of all the properties.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
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.
Materials compute MaterialProperties.
Definition Material.h:36
static InputParameters validParams()
Definition Material.C:14