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