https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ConstantMaterial.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
10#include "ConstantMaterial.h"
11
12registerMooseObject("ThermalHydraulicsApp", ConstantMaterial);
13
16{
18 params.addClassDescription("Defines a single constant material property, along with zero "
19 "derivative material properties for user-defined variables");
20 params.addParam<Real>("value", 0., "Constant value being assigned into the property");
21 params.addRequiredParam<std::string>("property_name", "The property name to declare");
22 params.addCoupledVar(
23 "derivative_vars",
24 "Names of variables for which to create (zero) material derivative properties");
25 params.set<MooseEnum>("constant_on") = "SUBDOMAIN";
26 return params;
27}
28
31 _value(getParam<Real>("value")),
32 _property_name(getParam<std::string>("property_name")),
33 _property(declareProperty<Real>(_property_name)),
34 _n_derivative_vars(coupledComponents("derivative_vars"))
35{
36 // get references to new material property derivatives
38 if (!isCoupledConstant("derivative_vars"))
39 for (unsigned int i = 0; i < _n_derivative_vars; ++i)
41 &declarePropertyDerivative<Real>(_property_name, coupledName("derivative_vars", i));
42}
43
44void
46{
47 _property[_qp] = _value;
48
49 for (unsigned int i = 0; i < _n_derivative_vars; ++i)
51 (*_derivative_properties[i])[_qp] = 0;
52}
registerMooseObject("ThermalHydraulicsApp", ConstantMaterial)
Constant material with zero-valued derivatives.
const unsigned int _n_derivative_vars
Number of variables for which to create zero-valued property derivatives.
const Real & _value
const MaterialPropertyName _property_name
ConstantMaterial(const InputParameters &parameters)
virtual void computeQpProperties()
std::vector< MaterialProperty< Real > * > _derivative_properties
Derivatives of material property with respect to each variable.
static InputParameters validParams()
MaterialProperty< Real > & _property
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
void addCoupledVar(const std::string &name, const std::string &doc_string)
static InputParameters validParams()