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 "INSFVMassAdvectionOutflowBC.h" 11 : #include "INSFVVelocityVariable.h" 12 : #include "SubProblem.h" 13 : #include "MooseMesh.h" 14 : #include "NS.h" 15 : 16 : registerADMooseObject("NavierStokesApp", INSFVMassAdvectionOutflowBC); 17 : 18 : InputParameters 19 164 : INSFVMassAdvectionOutflowBC::validParams() 20 : { 21 164 : InputParameters params = FVFluxBC::validParams(); 22 164 : params += INSFVFullyDevelopedFlowBC::validParams(); 23 164 : params.addClassDescription("Outflow boundary condition for advecting mass."); 24 328 : params.addRequiredParam<MooseFunctorName>(NS::density, "The functor for the density"); 25 328 : params.declareControllable("rho"); 26 328 : params.addRequiredParam<MooseFunctorName>("u", "The velocity in the x direction."); 27 328 : params.addParam<MooseFunctorName>("v", "The velocity in the y direction."); 28 328 : params.addParam<MooseFunctorName>("w", "The velocity in the z direction."); 29 164 : return params; 30 0 : } 31 : 32 88 : INSFVMassAdvectionOutflowBC::INSFVMassAdvectionOutflowBC(const InputParameters & params) 33 : : FVFluxBC(params), 34 : INSFVFullyDevelopedFlowBC(params), 35 176 : _rho(getFunctor<ADReal>(NS::density)), 36 176 : _u(getFunctor<ADReal>("u")), 37 352 : _v(isParamValid("v") ? &getFunctor<ADReal>("v") : nullptr), 38 176 : _w(isParamValid("w") ? &getFunctor<ADReal>("w") : nullptr), 39 176 : _dim(_subproblem.mesh().dimension()) 40 : { 41 88 : if (_dim >= 2 && !_v) 42 0 : mooseError( 43 : "In two or more dimensions, the v velocity must be supplied using the 'v' parameter"); 44 88 : if (_dim >= 3 && !_w) 45 0 : mooseError("In threedimensions, the w velocity must be supplied using the 'w' parameter"); 46 88 : } 47 : 48 : ADReal 49 3528 : INSFVMassAdvectionOutflowBC::computeQpResidual() 50 : { 51 3528 : const auto boundary_face = singleSidedFaceArg(); 52 3528 : const auto state = determineState(); 53 : 54 7056 : ADRealVectorValue v(_u(boundary_face, state)); 55 3528 : if (_v) 56 3528 : v(1) = (*_v)(boundary_face, state); 57 3528 : if (_w) 58 0 : v(2) = (*_w)(boundary_face, state); 59 : 60 3528 : return _normal * v * _rho(boundary_face, state); 61 : }