https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ThermalSolidPropertiesFunctorMaterial.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
13
15
18{
20 params.addRequiredParam<MooseFunctorName>("temperature", "Temperature");
21 params.addRequiredParam<UserObjectName>("sp", "The name of the user object for solid properties");
22 params.addParam<bool>("use_constant_density", false, "Use constant density evaluated at 'T_ref'");
23 params.addParam<Real>(
24 "T_ref",
25 "Temperature at which to evaluate density if 'use_constant_density' is set to 'true'");
28 "Name to be used for the isobaric specific heat");
31 "Name to be used for the thermal conductivity");
32 params.addParam<std::string>(SolidPropertiesNames::density,
34 "Name to be used for the density");
37 "Name to be used for the specific internal energy");
38 params.addClassDescription("Computes solid thermal properties as a function of temperature");
39 return params;
40}
41
43 const InputParameters & parameters)
44 : FunctorMaterial(parameters),
45 _temperature(getFunctor<ADReal>("temperature")),
46 _sp(getUserObject<ThermalSolidProperties>("sp"))
47{
48 if (getParam<bool>("use_constant_density"))
49 {
50 if (isParamValid("T_ref"))
51 {
52 const Real T_ref = getParam<Real>("T_ref");
53 addFunctorProperty<ADReal>(getParam<std::string>(SolidPropertiesNames::density),
54 [this, T_ref](const auto & /*r*/, const auto & /*t*/) -> ADReal
55 { return _sp.rho_from_T(T_ref); });
56 }
57 else
58 paramError("T_ref",
59 "The parameter 'T_ref' is required if 'use_constant_density' is set to 'true'.");
60 }
61 else
62 {
63 if (isParamValid("T_ref"))
64 paramError("T_ref",
65 "The parameter 'T_ref' may not be specified if 'use_constant_density' is set to "
66 "'false'.");
67 else
68 addFunctorProperty<ADReal>(getParam<std::string>(SolidPropertiesNames::density),
69 [this](const auto & r, const auto & t) -> ADReal
70 { return _sp.rho_from_T(_temperature(r, t)); });
71 }
72
73 addFunctorProperty<ADReal>(getParam<std::string>(SolidPropertiesNames::specific_heat),
74 [this](const auto & r, const auto & t) -> ADReal
75 { return _sp.cp_from_T(_temperature(r, t)); });
76 addFunctorProperty<ADReal>(getParam<std::string>(SolidPropertiesNames::thermal_conductivity),
77 [this](const auto & r, const auto & t) -> ADReal
78 { return _sp.k_from_T(_temperature(r, t)); });
79 addFunctorProperty<ADReal>(getParam<std::string>(SolidPropertiesNames::specific_internal_energy),
80 [this](const auto & r, const auto & t) -> ADReal
81 { return _sp.e_from_T(_temperature(r, t)); });
82}
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("SolidPropertiesApp", ThermalSolidPropertiesFunctorMaterial)
static InputParameters validParams()
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)
void paramError(const std::string &param, Args... args) const
bool isParamValid(const std::string &name) const
Computes solid thermal properties as a function of temperature.
ThermalSolidPropertiesFunctorMaterial(const InputParameters &parameters)
const ThermalSolidProperties & _sp
Solid properties.
const Moose::Functor< ADReal > & _temperature
Temperature.
Common class for solid properties that are a function of temperature.
Real e_from_T(const Real &T) const
static const std::string thermal_conductivity
static const std::string specific_heat
static const std::string specific_internal_energy
static const std::string density