https://mooseframework.inl.gov
WCNSFVScalarFluxBC.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 "WCNSFVScalarFluxBC.h"
11 #include "NS.h"
12 
13 registerMooseObject("NavierStokesApp", WCNSFVScalarFluxBC);
14 
17 {
19  params.addClassDescription("Flux boundary conditions for scalar quantity advection.");
20 
21  // Two different ways to input an advected scalar flux:
22  // 1) Postprocessor with the scalar flow rate directly
23  // 2) Postprocessors for inlet velocity and scalar concentration
24  params.addParam<PostprocessorName>("scalar_flux_pp",
25  "Postprocessor with the inlet scalar flow rate");
26  params.addParam<PostprocessorName>("scalar_value_pp",
27  "Postprocessor with the inlet scalar concentration");
28  params.addRequiredParam<MooseFunctorName>("passive_scalar", "passive scalar functor");
29  return params;
30 }
31 
33  : WCNSFVFluxBCBase(params),
34  _scalar_value_pp(isParamValid("scalar_value_pp") ? &getPostprocessorValue("scalar_value_pp")
35  : nullptr),
36  _scalar_flux_pp(isParamValid("scalar_flux_pp") ? &getPostprocessorValue("scalar_flux_pp")
37  : nullptr),
38  _passive_scalar(getFunctor<ADReal>("passive_scalar"))
39 {
40  // Density is often set as global parameters so it is not checked
43  "If setting the scalar flux directly, no need for inlet velocity, mass flow or scalar "
44  "concentration");
45 
46  // Need enough information if trying to use a mass flow rate postprocessor
47  if (!_scalar_flux_pp)
48  {
49  if (!_scalar_value_pp)
50  mooseError("If not providing the scalar flow rate, the inlet scalar concentration should be "
51  "provided");
52  if (!_velocity_pp && !_mdot_pp)
53  mooseError("If not providing the scalar flow rate, the inlet velocity or mass flow "
54  "should be provided");
55  if (_mdot_pp && !_area_pp)
56  mooseError("If providing the inlet mass flow rate, the inlet flow "
57  "area should be provided as well");
58  }
59  else if (!_area_pp)
60  paramError("scalar_flux_pp",
61  "If supplying the energy flow rate, the flow area should be provided as well");
62 }
63 
64 ADReal
66 {
67  const auto state = determineState();
68 
69  if (!isInflow())
70  return varVelocity(state) * _normal * _passive_scalar(singleSidedFaceArg(), state);
71  else if (_scalar_flux_pp)
73 
74  return -_scaling_factor * inflowSpeed(state) * (*_scalar_value_pp);
75 }
76 
77 bool
79 {
80  if (_mdot_pp)
81  return *_mdot_pp >= 0;
82  else if (_velocity_pp)
83  return *_velocity_pp >= 0;
84  else if (_scalar_flux_pp)
85  return *_scalar_flux_pp >= 0;
86 
87  mooseError(
88  "Either mdot_pp or velocity_pp or scalar_flux_pp need to be provided OR this function "
89  "must be overridden in derived classes if other input parameter combinations are valid. "
90  "Neither mdot_pp nor velocity_pp are provided.");
91  return true;
92 }
const PostprocessorValue *const _velocity_pp
Postprocessor with the inlet velocity.
const PostprocessorValue *const _mdot_pp
Postprocessor with the inlet mass flow rate.
ADReal computeQpResidual() override
ADRealVectorValue varVelocity(const Moose::StateArg &state) const
returns the velocity vector (vel_x, vel_y, vel_z)
const Moose::Functor< ADReal > & _passive_scalar
passive scalar functor
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
Moose::StateArg determineState() const
virtual bool isInflow() const override
override because energy_pp is not considered in base class
const PostprocessorValue *const _scalar_flux_pp
Postprocessor with the inlet scalar flow rate.
Base class for weakly compressible flux boundary conditions.
static InputParameters validParams()
const PostprocessorValue *const _scalar_value_pp
Postprocessor with the inlet scalar concentration.
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
DualNumber< Real, DNDerivativeType, true > ADReal
Flux boundary condition for the weakly compressible scalar advection equation.
void mooseWarning(Args &&... args) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
ADReal inflowSpeed(const Moose::StateArg &state) const
computes the inflow speed
static InputParameters validParams()
const PostprocessorValue *const _area_pp
Postprocessor with the inlet area.
ADRealVectorValue _normal
WCNSFVScalarFluxBC(const InputParameters &params)
void paramError(const std::string &param, Args... args) const
registerMooseObject("NavierStokesApp", WCNSFVScalarFluxBC)
const Real _scaling_factor
Scaling factor.
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)