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 "WCNSFVInletVelocityBC.h" 11 : #include "INSFVVelocityVariable.h" 12 : #include "NS.h" 13 : 14 : registerMooseObject("NavierStokesApp", WCNSFVInletVelocityBC); 15 : 16 : InputParameters 17 268 : WCNSFVInletVelocityBC::validParams() 18 : { 19 268 : InputParameters params = FVDirichletBCBase::validParams(); 20 268 : params += INSFVFlowBC::validParams(); 21 : 22 536 : params.addParam<Real>("scaling_factor", 1, "To scale the velocity"); 23 : 24 : // Two different ways to input velocity 25 : // 1) Postprocessor with the velocity value directly 26 536 : params.addParam<PostprocessorName>("velocity_pp", "Postprocessor with the inlet velocity"); 27 : 28 : // 2) Postprocessors with an inlet mass flow rate 29 536 : params.addParam<PostprocessorName>("mdot_pp", "Postprocessor with the inlet mass flow rate"); 30 268 : params.addParam<MooseFunctorName>(NS::density, "Density functor"); 31 536 : params.addParam<PostprocessorName>("area_pp", "Inlet area as a postprocessor"); 32 : 33 268 : return params; 34 0 : } 35 : 36 151 : WCNSFVInletVelocityBC::WCNSFVInletVelocityBC(const InputParameters & params) 37 : : FVDirichletBCBase(params), 38 : INSFVFlowBC(params), 39 151 : _scaling_factor(getParam<Real>("scaling_factor")), 40 334 : _velocity_pp(isParamValid("velocity_pp") ? &getPostprocessorValue("velocity_pp") : nullptr), 41 423 : _mdot_pp(isParamValid("mdot_pp") ? &getPostprocessorValue("mdot_pp") : nullptr), 42 419 : _area_pp(isParamValid("area_pp") ? &getPostprocessorValue("area_pp") : nullptr), 43 302 : _rho(isParamValid(NS::density) ? &getFunctor<ADReal>(NS::density) : nullptr) 44 : { 45 151 : if (!dynamic_cast<INSFVVelocityVariable *>(&_var)) 46 0 : paramError( 47 : "variable", 48 : "The variable argument to WCNSFVInletVelocityBC must be of type INSFVVelocityVariable"); 49 : 50 : // Density is often set as global parameters so it is not checked 51 151 : if (_velocity_pp && (_mdot_pp || _area_pp)) 52 2 : mooseWarning("If setting the velocity directly, no need for inlet mass flow rate or area"); 53 : 54 : // Need enough information if trying to use a mass flow rate postprocessor 55 149 : if (!_velocity_pp && (!_mdot_pp || !_area_pp || !_rho)) 56 2 : mooseError("Mass flow rate, area and density should be provided if velocity is not"); 57 147 : } 58 : 59 : ADReal 60 240441 : WCNSFVInletVelocityBC::boundaryValue(const FaceInfo & fi, const Moose::StateArg & state) const 61 : { 62 240441 : if (_area_pp) 63 214473 : if (MooseUtils::absoluteFuzzyEqual(*_area_pp, 0)) 64 0 : mooseError("Surface area is 0"); 65 : 66 240441 : if (_velocity_pp) 67 25968 : return _scaling_factor * (*_velocity_pp); 68 : else 69 : { 70 214473 : ADReal rho = (*_rho)(singleSidedFaceArg(&fi), state); 71 : 72 643419 : return _scaling_factor * (*_mdot_pp) / (*_area_pp * rho); 73 : } 74 : }