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 "NSFVOutflowTemperatureBC.h" 11 : #include "SystemBase.h" 12 : #include "NS.h" 13 : 14 : registerMooseObject("NavierStokesApp", NSFVOutflowTemperatureBC); 15 : 16 : InputParameters 17 82 : NSFVOutflowTemperatureBC::validParams() 18 : { 19 82 : InputParameters params = FVFluxBC::validParams(); 20 82 : params.addClassDescription("Outflow velocity temperature advection boundary conditions for " 21 : "finite volume method allowing for thermal backflow."); 22 82 : params.addRequiredParam<MooseFunctorName>(NS::density, "The name of the density"); 23 82 : params.addRequiredParam<MooseFunctorName>(NS::cp, "The name of the specific heat"); 24 164 : params.addRequiredParam<MooseFunctorName>("u", "The velocity in the x direction."); 25 164 : params.addParam<MooseFunctorName>("v", "The velocity in the y direction."); 26 164 : params.addParam<MooseFunctorName>("w", "The velocity in the z direction."); 27 164 : params.addRequiredParam<MooseFunctorName>("backflow_T", 28 : "The backflow temperature entering the domain."); 29 82 : return params; 30 0 : } 31 : 32 44 : NSFVOutflowTemperatureBC::NSFVOutflowTemperatureBC(const InputParameters & parameters) 33 : : FVFluxBC(parameters), 34 44 : _rho(getFunctor<ADReal>(NS::density)), 35 44 : _cp(getFunctor<ADReal>(NS::cp)), 36 88 : _u(getFunctor<ADReal>("u")), 37 176 : _v(isParamValid("v") ? &getFunctor<ADReal>("v") : nullptr), 38 88 : _w(isParamValid("w") ? &getFunctor<ADReal>("w") : nullptr), 39 88 : _backflow_T(getFunctor<ADReal>("backflow_T")), 40 88 : _dim(_subproblem.mesh().dimension()) 41 : { 42 44 : if (_dim >= 2 && !_v) 43 0 : mooseError( 44 : "In two or more dimensions, the v velocity must be supplied using the 'v' parameter"); 45 44 : if (_dim >= 3 && !_w) 46 0 : mooseError("In threedimensions, the w velocity must be supplied using the 'w' parameter"); 47 44 : } 48 : 49 : ADReal 50 31425 : NSFVOutflowTemperatureBC::computeQpResidual() 51 : { 52 31425 : const auto boundary_face = singleSidedFaceArg(); 53 31425 : const auto state = determineState(); 54 : 55 62850 : ADRealVectorValue v(_u(boundary_face, state)); 56 31425 : if (_v) 57 31425 : v(1) = (*_v)(boundary_face, state); 58 31425 : if (_w) 59 0 : v(2) = (*_w)(boundary_face, state); 60 : 61 31425 : const auto vol_flux = v * _normal; 62 62850 : const auto rho_cp_face = _rho(boundary_face, state) * _cp(boundary_face, state); 63 : 64 31425 : if (vol_flux > 0) 65 24892 : return rho_cp_face * _var(boundary_face, state) * vol_flux; 66 : else 67 : { 68 18979 : auto backflow_T = _backflow_T(boundary_face, state); 69 18979 : return rho_cp_face * backflow_T * vol_flux; 70 : } 71 : }