https://mooseframework.inl.gov
WCNSFVInletVelocityBC.C
Go to the documentation of this file.
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 
18 {
20  params += INSFVFlowBC::validParams();
21 
22  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  params.addParam<PostprocessorName>("velocity_pp", "Postprocessor with the inlet velocity");
27 
28  // 2) Postprocessors with an inlet mass flow rate
29  params.addParam<PostprocessorName>("mdot_pp", "Postprocessor with the inlet mass flow rate");
30  params.addParam<MooseFunctorName>(NS::density, "Density functor");
31  params.addParam<PostprocessorName>("area_pp", "Inlet area as a postprocessor");
32 
33  return params;
34 }
35 
37  : FVDirichletBCBase(params),
38  INSFVFlowBC(params),
39  _scaling_factor(getParam<Real>("scaling_factor")),
40  _velocity_pp(isParamValid("velocity_pp") ? &getPostprocessorValue("velocity_pp") : nullptr),
41  _mdot_pp(isParamValid("mdot_pp") ? &getPostprocessorValue("mdot_pp") : nullptr),
42  _area_pp(isParamValid("area_pp") ? &getPostprocessorValue("area_pp") : nullptr),
43  _rho(isParamValid(NS::density) ? &getFunctor<ADReal>(NS::density) : nullptr)
44 {
45  if (!dynamic_cast<INSFVVelocityVariable *>(&_var))
46  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  if (_velocity_pp && (_mdot_pp || _area_pp))
52  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  if (!_velocity_pp && (!_mdot_pp || !_area_pp || !_rho))
56  mooseError("Mass flow rate, area and density should be provided if velocity is not");
57 }
58 
59 ADReal
61 {
62  if (_area_pp)
64  mooseError("Surface area is 0");
65 
66  if (_velocity_pp)
67  return _scaling_factor * (*_velocity_pp);
68  else
69  {
70  ADReal rho = (*_rho)(singleSidedFaceArg(&fi), state);
71 
72  return _scaling_factor * (*_mdot_pp) / (*_area_pp * rho);
73  }
74 }
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const Moose::Functor< ADReal > *const _rho
Fluid density functor.
static const std::string density
Definition: NS.h:33
Moose::FaceArg singleSidedFaceArg(const FaceInfo *fi=nullptr, Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false, const Moose::StateArg *state_limiter=nullptr) const
MooseVariableFV< Real > & _var
Dirichlet boundary conditions for the velocity, set from either a velocity postprocessor or a mass fl...
DualNumber< Real, DNDerivativeType, true > ADReal
void mooseWarning(Args &&... args) const
ADReal boundaryValue(const FaceInfo &fi, const Moose::StateArg &state) const override
static InputParameters validParams()
const Real _scaling_factor
Scaling factor.
const PostprocessorValue *const _mdot_pp
Postprocessor with the inlet mass flow rate.
void paramError(const std::string &param, Args... args) const
const PostprocessorValue *const _area_pp
Postprocessor with the inlet area.
WCNSFVInletVelocityBC(const InputParameters &params)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
registerMooseObject("NavierStokesApp", WCNSFVInletVelocityBC)
const PostprocessorValue *const _velocity_pp
Postprocessor with the inlet velocity.
void mooseError(Args &&... args) const
static InputParameters validParams()
A parent class for INSFV flow boundary conditions.
Definition: INSFVFlowBC.h:17
static InputParameters validParams()
Definition: INSFVFlowBC.C:14