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 126 : LinearFVEnthalpyFunctorMaterial::validParams() 19 : { 20 126 : auto params = FunctorMaterial::validParams(); 21 126 : params.addClassDescription( 22 : "Creates functors for conversions between specific enthalpy and temperature"); 23 : 24 126 : params.addRequiredParam<MooseFunctorName>(NS::pressure, "Pressure"); 25 126 : params.addRequiredParam<MooseFunctorName>(NS::T_fluid, "Fluid temperature"); 26 126 : params.addRequiredParam<MooseFunctorName>(NS::specific_enthalpy, "Specific Enthalpy"); 27 : 28 : // Please choose between providing a fluid properties 29 126 : params.addParam<UserObjectName>(NS::fluid, "Fluid properties userobject"); 30 : // or the h_from_p_T and T_from_p_h functors. 31 252 : params.addParam<MooseFunctorName>("h_from_p_T_functor", 32 : "User specified enthalpy from temperature functor"); 33 252 : params.addParam<MooseFunctorName>("T_from_p_h_functor", 34 : "User specified temperature from enthalpy functor"); 35 : 36 126 : return params; 37 0 : } 38 : 39 38 : LinearFVEnthalpyFunctorMaterial::LinearFVEnthalpyFunctorMaterial(const InputParameters & params) 40 : : FunctorMaterial(params), 41 38 : _pressure(getFunctor<Real>(NS::pressure)), 42 38 : _T_fluid(getFunctor<Real>(NS::T_fluid)), 43 38 : _h(getFunctor<Real>(NS::specific_enthalpy)), 44 38 : _fluid(params.isParamValid(NS::fluid) 45 38 : ? &UserObjectInterface::getUserObject<SinglePhaseFluidProperties>(NS::fluid) 46 : : nullptr), 47 38 : _h_from_p_T_functor(params.isParamValid("h_from_p_T_functor") 48 66 : ? &getFunctor<Real>("h_from_p_T_functor") 49 : : nullptr), 50 38 : _T_from_p_h_functor(params.isParamValid("T_from_p_h_functor") 51 66 : ? &getFunctor<Real>("T_from_p_h_functor") 52 38 : : nullptr) 53 : { 54 : // Check parameters 55 38 : if (!((_fluid && !_h_from_p_T_functor && !_T_from_p_h_functor) || 56 14 : (!_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 38 : if (_fluid) 68 : { 69 72 : addFunctorProperty<Real>("h_from_p_T", 70 1347350 : [this](const auto & r, const auto & t) -> Real 71 1347350 : { return _fluid->h_from_p_T(_pressure(r, t), _T_fluid(r, t)); }); 72 72 : addFunctorProperty<Real>("T_from_p_h", 73 2961750 : [this](const auto & r, const auto & t) -> Real 74 2961750 : { return _fluid->T_from_p_h(_pressure(r, t), _h(r, t)); }); 75 : } 76 : else 77 : { 78 42 : addFunctorProperty<Real>("h_from_p_T", 79 : [this](const auto & r, const auto & t) -> Real 80 1232468 : { return (*_h_from_p_T_functor)(r, t); }); 81 42 : addFunctorProperty<Real>("T_from_p_h", 82 : [this](const auto & r, const auto & t) -> Real 83 1498368 : { return (*_T_from_p_h_functor)(r, t); }); 84 : } 85 114 : }