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 "LinearFVEnthalpyFunctorMaterial.h" 11 : #include "NS.h" // Variable Term Names 12 : #include "NavierStokesMethods.h" 13 : #include "SinglePhaseFluidProperties.h" 14 : 15 : registerMooseObject("NavierStokesApp", LinearFVEnthalpyFunctorMaterial); 16 : 17 : InputParameters 18 152 : LinearFVEnthalpyFunctorMaterial::validParams() 19 : { 20 152 : auto params = FunctorMaterial::validParams(); 21 152 : params.addClassDescription( 22 : "Creates functors for conversions between specific enthalpy and temperature"); 23 : 24 152 : params.addRequiredParam<MooseFunctorName>(NS::pressure, "Pressure"); 25 152 : params.addRequiredParam<MooseFunctorName>(NS::T_fluid, "Fluid temperature"); 26 152 : params.addRequiredParam<MooseFunctorName>(NS::specific_enthalpy, "Specific Enthalpy"); 27 : 28 : // Please choose between providing a fluid properties 29 152 : params.addParam<UserObjectName>(NS::fluid, "Fluid properties userobject"); 30 : // or the h_from_p_T and T_from_p_h functors. 31 304 : params.addParam<MooseFunctorName>("h_from_p_T_functor", 32 : "User specified enthalpy from temperature functor"); 33 304 : params.addParam<MooseFunctorName>("T_from_p_h_functor", 34 : "User specified temperature from enthalpy functor"); 35 : 36 152 : return params; 37 0 : } 38 : 39 76 : LinearFVEnthalpyFunctorMaterial::LinearFVEnthalpyFunctorMaterial(const InputParameters & params) 40 : : FunctorMaterial(params), 41 76 : _pressure(getFunctor<Real>(NS::pressure)), 42 76 : _T_fluid(getFunctor<Real>(NS::T_fluid)), 43 76 : _h(getFunctor<Real>(NS::specific_enthalpy)), 44 76 : _fluid(params.isParamValid(NS::fluid) 45 76 : ? &UserObjectInterface::getUserObject<SinglePhaseFluidProperties>(NS::fluid) 46 : : nullptr), 47 76 : _h_from_p_T_functor(params.isParamValid("h_from_p_T_functor") 48 114 : ? &getFunctor<Real>("h_from_p_T_functor") 49 : : nullptr), 50 76 : _T_from_p_h_functor(params.isParamValid("T_from_p_h_functor") 51 114 : ? &getFunctor<Real>("T_from_p_h_functor") 52 76 : : nullptr) 53 : { 54 : // Check parameters 55 76 : if (!((_fluid && !_h_from_p_T_functor && !_T_from_p_h_functor) || 56 19 : (!_fluid && _h_from_p_T_functor && _T_from_p_h_functor))) 57 : { 58 0 : mooseError("An unsupported combination of input parameters was given. Current " 59 : "supported combinations are either\ni) `fp` and neither `h_from_p_T_functor` nor " 60 : "`T_from_p_h_functor`, or\nii) " 61 : "no `fp` and both `h_from_p_T_functor` and `T_from_p_h_functor` are provided."); 62 : } 63 : 64 : // 65 : // Set material property functors 66 : // 67 76 : if (_fluid) 68 : { 69 171 : addFunctorProperty<Real>("h_from_p_T", 70 2425050 : [this](const auto & r, const auto & t) -> Real 71 2425050 : { return _fluid->h_from_p_T(_pressure(r, t), _T_fluid(r, t)); }); 72 171 : addFunctorProperty<Real>("T_from_p_h", 73 5330250 : [this](const auto & r, const auto & t) -> Real 74 5330250 : { return _fluid->T_from_p_h(_pressure(r, t), _h(r, t)); }); 75 : } 76 : else 77 : { 78 57 : addFunctorProperty<Real>("h_from_p_T", 79 : [this](const auto & r, const auto & t) -> Real 80 2160900 : { return (*_h_from_p_T_functor)(r, t); }); 81 57 : addFunctorProperty<Real>("T_from_p_h", 82 : [this](const auto & r, const auto & t) -> Real 83 2160000 : { return (*_T_from_p_h_functor)(r, t); }); 84 : } 85 228 : }