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 "WCNSFVSwitchableInletVelocityBC.h" 11 : #include "INSFVVelocityVariable.h" 12 : #include "NS.h" 13 : 14 : registerMooseObject("NavierStokesApp", WCNSFVSwitchableInletVelocityBC); 15 : 16 : InputParameters 17 82 : WCNSFVSwitchableInletVelocityBC::validParams() 18 : { 19 82 : InputParameters params = WCNSFVInletVelocityBC::validParams(); 20 : 21 82 : params.addClassDescription("Adds switchable inlet-velocity boundary condition" 22 : "for weakly compressible flows."); 23 : 24 246 : params.addParam<bool>( 25 164 : "switch_bc", true, "Switch on (true) / off (false) for boundary condition."); 26 164 : params.declareControllable("switch_bc"); 27 : 28 164 : params.addParam<Real>("face_limiter", 1.0, "Face flux limiter."); 29 164 : params.declareControllable("face_limiter"); 30 : 31 82 : return params; 32 0 : } 33 : 34 44 : WCNSFVSwitchableInletVelocityBC::WCNSFVSwitchableInletVelocityBC(const InputParameters & params) 35 : : WCNSFVInletVelocityBC(params), 36 44 : _switch_bc(getParam<bool>("switch_bc")), 37 132 : _face_limiter(getParam<Real>("face_limiter")) 38 : { 39 44 : } 40 : 41 : ADReal 42 193039 : WCNSFVSwitchableInletVelocityBC::boundaryValue(const FaceInfo & fi, 43 : const Moose::StateArg & state) const 44 : { 45 193039 : if (_switch_bc) 46 192714 : return WCNSFVInletVelocityBC::boundaryValue(fi, state) * _face_limiter; 47 : else 48 : { 49 : // if on an internal face (internal to the mesh, but an external boundary of the flow area), 50 : // we have to make sure to select the element on which the velocity is defined 51 : const auto elem_ptr = (fi.faceType(_var_sys_numbers_pair) == FaceInfo::VarFaceNeighbors::ELEM) 52 96682 : ? fi.elemPtr() 53 : : fi.neighborPtr(); 54 : // The two-term expansion = false piece is critical as it prevents infinite recursion that would 55 : // occur with a Green-Gauss gradient calculation which would call back to this "Dirichlet" 56 : // object 57 96682 : return _var.getExtrapolatedBoundaryFaceValue(fi, 58 : /*two_term_expansion=*/false, 59 : /*correct_skewness=*/false, 60 : elem_ptr, 61 : state) * 62 96682 : _face_limiter; 63 : } 64 : }