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 "CNSFVHLLCStagnationInletBC.h" 11 : #include "IdealGasFluidProperties.h" 12 : #include "NS.h" 13 : 14 : InputParameters 15 164 : CNSFVHLLCStagnationInletBC::validParams() 16 : { 17 164 : InputParameters params = CNSFVHLLCBC::validParams(); 18 328 : params.addRequiredParam<PostprocessorName>("stagnation_temperature", 19 : "Specified inlet stagnation temperature."); 20 328 : params.addRequiredParam<PostprocessorName>("stagnation_pressure", 21 : "Specified inlet stagnation pressure."); 22 164 : return params; 23 0 : } 24 : 25 88 : CNSFVHLLCStagnationInletBC::CNSFVHLLCStagnationInletBC(const InputParameters & parameters) 26 : : CNSFVHLLCBC(parameters), 27 88 : _stagnation_temperature(this->getPostprocessorValue("stagnation_temperature")), 28 88 : _stagnation_pressure(this->getPostprocessorValue("stagnation_pressure")), 29 88 : _cp(getADMaterialProperty<Real>(NS::cp)), 30 176 : _cv(getADMaterialProperty<Real>(NS::cv)) 31 : { 32 : // we need to distinguish between ideal gas and non-ideal gas 33 : const IdealGasFluidProperties * fluid_ideal_gas = 34 88 : dynamic_cast<const IdealGasFluidProperties *>(&_fluid); 35 88 : if (!fluid_ideal_gas) 36 0 : paramError( 37 : NS::fluid, 38 : "Navier-Stokes module supports stagnation inlet BCs only for IdealGasFluidProperties. " 39 : "Non-ideal " 40 : "fluid " 41 : "properties do not implement the necessary interfaces to support isentropic processes."); 42 88 : } 43 : 44 : void 45 2832 : CNSFVHLLCStagnationInletBC::preComputeWaveSpeed() 46 : { 47 2832 : _normal_speed_boundary = _normal_speed_elem; 48 2832 : _vel_boundary = _vel_elem[_qp]; 49 : 50 : // for convenience compute the square of the speed 51 2832 : ADReal speed_sq = _speed_elem[_qp] * _speed_elem[_qp]; 52 : 53 : // Compute inlet temperature 54 5664 : ADReal T_inlet = _stagnation_temperature - 0.5 * speed_sq / _cp[_qp]; 55 : 56 : // Compute inlet pressure using isentropic relation 57 2832 : ADReal gamma = _cp[_qp] / _cv[_qp]; 58 : _p_boundary = 59 11328 : _stagnation_pressure * std::pow(_stagnation_temperature / T_inlet, -gamma / (gamma - 1.)); 60 : 61 : // Compute total energy from stagnation values. 62 8496 : _specific_internal_energy_boundary = _cv[_qp] * T_inlet + 0.5 * speed_sq; 63 : 64 2832 : _rho_boundary = _fluid.rho_from_p_T(_p_boundary, T_inlet); 65 2832 : _ht_boundary = _specific_internal_energy_boundary + _p_boundary / _rho_boundary; 66 2832 : }