https://mooseframework.inl.gov
MassFluxWeightedFlowRate.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 
11 #include "MathFVUtils.h"
13 #include "NSFVUtils.h"
14 #include "NS.h"
16 
17 #include <math.h>
18 
20 
23 {
25  params.addRequiredParam<MooseFunctorName>("density",
26  "Provide a functor that returns the density.");
27  params.addClassDescription("Computes the mass flux weighted average of the quantity "
28  "provided by advected_quantity over a boundary.");
29  return params;
30 }
31 
33  : VolumetricFlowRate(parameters), _density(getFunctor<ADReal>("density")), _mdot(0)
34 {
35  if (_qp_integration)
36  mooseError("This object only works only with finite volume.");
37 
38  checkFunctorSupportsSideIntegration<ADReal>("density", _qp_integration);
39 }
40 
41 void
43 {
45  _mdot = 0;
46 }
47 
48 Real
50 {
51  mooseAssert(fi, "We should have a face info in " + name());
52  mooseAssert(_adv_quant, "We should have an advected quantity in " + name());
53  const auto state = determineState();
54 
55  // Get face value for velocity
56  const auto face_flux = MetaPhysicL::raw_value(_rc_uo->getVolumetricFaceFlux(
57  _velocity_interp_method, *fi, state, _tid, /*subtract_mesh_velocity=*/true));
58  const bool correct_skewness =
60 
61  mooseAssert(_adv_quant->hasFaceSide(*fi, true) || _adv_quant->hasFaceSide(*fi, true),
62  "Advected quantity must be defined on one of the sides of the face!");
63  mooseAssert((_adv_quant->hasFaceSide(*fi, true) == _density.hasFaceSide(*fi, true)) ||
64  (_adv_quant->hasFaceSide(*fi, false) == _density.hasFaceSide(*fi, false)),
65  "Density must be defined at least on one of the sides where the advected quantity is "
66  "defined!");
67 
68  const auto face_arg =
69  Moose::FaceArg({fi,
71  face_flux > 0,
72  correct_skewness,
73  _adv_quant->hasFaceSide(*fi, true) ? fi->elemPtr() : fi->neighborPtr(),
74  nullptr});
75  auto dens = _density(face_arg, state);
76  const auto adv_quant_face = MetaPhysicL::raw_value(dens * (*_adv_quant)(face_arg, state));
77  _mdot += fi->faceArea() * fi->faceCoord() * MetaPhysicL::raw_value(dens) * face_flux;
78  return face_flux * adv_quant_face;
79 }
80 
81 void
83 {
85  const auto & pps = static_cast<const MassFluxWeightedFlowRate &>(y);
86  _mdot += pps._mdot;
87 }
88 
89 Real
91 {
92  return _integral_value / _mdot;
93 }
94 
95 void
97 {
100 }
Moose::FV::InterpMethod _advected_interp_method
The interpolation method to use for the advected quantity.
virtual Real computeFaceInfoIntegral(const FaceInfo *fi) override
registerMooseObject("NavierStokesApp", MassFluxWeightedFlowRate)
const Moose::Functor< ADReal > & _density
density provided as functor
Moose::StateArg determineState() const
auto raw_value(const Eigen::Map< T > &in)
virtual void threadJoin(const UserObject &y) override
const std::vector< double > y
virtual const std::string & name() const
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
virtual void initialize() override
LimiterType limiterType(InterpMethod interp_method)
void gatherSum(T &value)
static InputParameters validParams()
virtual void finalize() override
const RhieChowFaceFluxProvider *const _rc_uo
The Rhie-Chow interpolation user object.
This postprocessor computes the mass-flux weighted average of a flow quantity over a boundary...
const Moose::Functor< ADReal > *const _adv_quant
The functor representing the advected quantity for finite volume.
virtual void finalize() override
This postprocessor computes the volumetric flow rate through a boundary, internal or external to the ...
virtual Real getValue() const override
virtual void threadJoin(const UserObject &y) override
virtual void initialize() override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Moose::FV::InterpMethod _velocity_interp_method
The interpolation method to use for the velocity.
Real _mdot
the mass flow rate over the face computed by this object
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
MassFluxWeightedFlowRate(const InputParameters &parameters)
virtual Real getVolumetricFaceFlux(const Moose::FV::InterpMethod m, const FaceInfo &fi, const Moose::StateArg &time, const THREAD_ID tid, bool subtract_mesh_velocity) const =0
Retrieve the volumetric face flux, will not include derivatives.