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 "FlowModel1PhaseFunctorMaterial.h" 11 : 12 : registerMooseObject("ThermalHydraulicsApp", FlowModel1PhaseFunctorMaterial); 13 : 14 : InputParameters 15 8918 : FlowModel1PhaseFunctorMaterial::validParams() 16 : { 17 8918 : InputParameters params = FunctorMaterial::validParams(); 18 : 19 8918 : params.addClassDescription("Computes several quantities for FlowModel1Phase."); 20 : 21 17836 : params.addRequiredParam<UserObjectName>("fluid_properties", 22 : "The SinglePhaseFluidProperties object for the fluid"); 23 : 24 8918 : return params; 25 0 : } 26 : 27 4870 : FlowModel1PhaseFunctorMaterial::FlowModel1PhaseFunctorMaterial(const InputParameters & parameters) 28 : : FunctorMaterial(parameters), 29 4870 : _rhoA(getFunctor<ADReal>(THM::RHOA)), 30 4870 : _rhouA(getFunctor<ADReal>(THM::RHOUA)), 31 4870 : _rhoEA(getFunctor<ADReal>(THM::RHOEA)), 32 4870 : _A(getFunctor<Real>(THM::AREA)), 33 9740 : _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties")) 34 : { 35 : // pressure 36 4870 : addPressureFunctorProperty<false>(); 37 : 38 : // temperature 39 4870 : addTemperatureFunctorProperty<false>(); 40 : 41 : // velocity 42 4870 : addVelocityFunctorProperty<false>(); 43 4870 : } 44 : 45 : template <bool is_ad> 46 : void 47 4870 : FlowModel1PhaseFunctorMaterial::addPressureFunctorProperty() 48 : { 49 14610 : addFunctorProperty<GenericReal<is_ad>>( 50 : THM::functorMaterialPropertyName<is_ad>(THM::PRESSURE), 51 6306024 : [this](const auto & r, const auto & t) -> GenericReal<is_ad> 52 : { 53 6306024 : const auto rhoA = Moose::ADRealToGenericReal<is_ad>(_rhoA(r, t)); 54 6306024 : const auto rhouA = Moose::ADRealToGenericReal<is_ad>(_rhouA(r, t)); 55 6306024 : const auto rhoEA = Moose::ADRealToGenericReal<is_ad>(_rhoEA(r, t)); 56 6306024 : const auto A = _A(r, t); 57 6306024 : const auto v = A / rhoA; 58 6306024 : const auto e = (rhoEA - 0.5 * rhouA * rhouA / rhoA) / rhoA; 59 6306024 : return _fp.p_from_v_e(v, e); 60 : }); 61 9740 : } 62 : 63 : template <bool is_ad> 64 : void 65 4870 : FlowModel1PhaseFunctorMaterial::addTemperatureFunctorProperty() 66 : { 67 14610 : addFunctorProperty<GenericReal<is_ad>>( 68 : THM::functorMaterialPropertyName<is_ad>(THM::TEMPERATURE), 69 6306024 : [this](const auto & r, const auto & t) -> GenericReal<is_ad> 70 : { 71 6306024 : const auto rhoA = Moose::ADRealToGenericReal<is_ad>(_rhoA(r, t)); 72 6306024 : const auto rhouA = Moose::ADRealToGenericReal<is_ad>(_rhouA(r, t)); 73 6306024 : const auto rhoEA = Moose::ADRealToGenericReal<is_ad>(_rhoEA(r, t)); 74 6306024 : const auto A = _A(r, t); 75 6306024 : const auto v = A / rhoA; 76 6306024 : const auto e = (rhoEA - 0.5 * rhouA * rhouA / rhoA) / rhoA; 77 6306024 : return _fp.T_from_v_e(v, e); 78 : }); 79 9740 : } 80 : 81 : template <bool is_ad> 82 : void 83 4870 : FlowModel1PhaseFunctorMaterial::addVelocityFunctorProperty() 84 : { 85 14610 : addFunctorProperty<GenericReal<is_ad>>( 86 : THM::functorMaterialPropertyName<is_ad>(THM::VELOCITY), 87 6306024 : [this](const auto & r, const auto & t) -> GenericReal<is_ad> 88 : { 89 6306024 : const auto rhoA = Moose::ADRealToGenericReal<is_ad>(_rhoA(r, t)); 90 6306024 : const auto rhouA = Moose::ADRealToGenericReal<is_ad>(_rhouA(r, t)); 91 6306024 : return rhouA / rhoA; 92 : }); 93 9740 : }