Line data Source code
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 : 12 : registerMooseObject("ThermalHydraulicsApp", ConstantMaterial); 13 : 14 : InputParameters 15 9435 : ConstantMaterial::validParams() 16 : { 17 9435 : InputParameters params = Material::validParams(); 18 9435 : params.addClassDescription("Defines a single constant material property, along with zero " 19 : "derivative material properties for user-defined variables"); 20 18870 : params.addParam<Real>("value", 0., "Constant value being assigned into the property"); 21 18870 : params.addRequiredParam<std::string>("property_name", "The property name to declare"); 22 18870 : params.addCoupledVar( 23 : "derivative_vars", 24 : "Names of variables for which to create (zero) material derivative properties"); 25 18870 : params.set<MooseEnum>("constant_on") = "SUBDOMAIN"; 26 9435 : return params; 27 0 : } 28 : 29 7296 : ConstantMaterial::ConstantMaterial(const InputParameters & parameters) 30 : : DerivativeMaterialInterface<Material>(parameters), 31 7296 : _value(getParam<Real>("value")), 32 7296 : _property_name(getParam<std::string>("property_name")), 33 7296 : _property(declareProperty<Real>(_property_name)), 34 14592 : _n_derivative_vars(coupledComponents("derivative_vars")) 35 : { 36 : // get references to new material property derivatives 37 7296 : _derivative_properties.resize(_n_derivative_vars); 38 14592 : if (!isCoupledConstant("derivative_vars")) 39 28917 : for (unsigned int i = 0; i < _n_derivative_vars; ++i) 40 21621 : _derivative_properties[i] = 41 43242 : &declarePropertyDerivative<Real>(_property_name, coupledName("derivative_vars", i)); 42 7296 : } 43 : 44 : void 45 5435257 : ConstantMaterial::computeQpProperties() 46 : { 47 5435257 : _property[_qp] = _value; 48 : 49 21796306 : for (unsigned int i = 0; i < _n_derivative_vars; ++i) 50 16361049 : if (_derivative_properties[i]) 51 16361049 : (*_derivative_properties[i])[_qp] = 0; 52 5435257 : }