https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
12#include "NS.h"
13
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))
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
61{
62 if (_area_pp)
63 if (MooseUtils::absoluteFuzzyEqual(*_area_pp, 0))
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}
DualNumber< Real, DNDerivativeType, true > ADReal
const double rho
registerMooseObject("NavierStokesApp", WCNSFVInletVelocityBC)
MooseVariableFV< Real > & _var
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
static InputParameters validParams()
A parent class for INSFV flow boundary conditions.
Definition INSFVFlowBC.h:18
static InputParameters validParams()
Definition INSFVFlowBC.C:14
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
void mooseWarning(Args &&... args) const
Dirichlet boundary conditions for the velocity, set from either a velocity postprocessor or a mass fl...
static InputParameters validParams()
WCNSFVInletVelocityBC(const InputParameters &params)
ADReal boundaryValue(const FaceInfo &fi, const Moose::StateArg &state) const override
const PostprocessorValue *const _mdot_pp
Postprocessor with the inlet mass flow rate.
const PostprocessorValue *const _area_pp
Postprocessor with the inlet area.
const PostprocessorValue *const _velocity_pp
Postprocessor with the inlet velocity.
const Moose::Functor< ADReal > *const _rho
Fluid density functor.
const Real _scaling_factor
Scaling factor.
static const std::string density
Definition NS.h:34