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 "MassFluxWeightedFlowRate.h" 11 : #include "MathFVUtils.h" 12 : #include "INSFVRhieChowInterpolator.h" 13 : #include "NSFVUtils.h" 14 : #include "NS.h" 15 : #include "SinglePhaseFluidProperties.h" 16 : 17 : #include <math.h> 18 : 19 : registerMooseObject("NavierStokesApp", MassFluxWeightedFlowRate); 20 : 21 : InputParameters 22 82 : MassFluxWeightedFlowRate::validParams() 23 : { 24 82 : InputParameters params = VolumetricFlowRate::validParams(); 25 164 : params.addRequiredParam<MooseFunctorName>("density", 26 : "Provide a functor that returns the density."); 27 82 : params.addClassDescription("Computes the mass flux weighted average of the quantity " 28 : "provided by advected_quantity over a boundary."); 29 82 : return params; 30 0 : } 31 : 32 44 : MassFluxWeightedFlowRate::MassFluxWeightedFlowRate(const InputParameters & parameters) 33 88 : : VolumetricFlowRate(parameters), _density(getFunctor<ADReal>("density")), _mdot(0) 34 : { 35 44 : if (_qp_integration) 36 0 : mooseError("This object only works only with finite volume."); 37 : 38 44 : checkFunctorSupportsSideIntegration<ADReal>("density", _qp_integration); 39 44 : } 40 : 41 : void 42 172 : MassFluxWeightedFlowRate::initialize() 43 : { 44 172 : VolumetricFlowRate::initialize(); 45 172 : _mdot = 0; 46 172 : } 47 : 48 : Real 49 368 : MassFluxWeightedFlowRate::computeFaceInfoIntegral([[maybe_unused]] const FaceInfo * fi) 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 368 : const auto state = determineState(); 54 : 55 : // Get face value for velocity 56 368 : const auto face_flux = MetaPhysicL::raw_value(_rc_uo->getVolumetricFaceFlux( 57 368 : _velocity_interp_method, *fi, state, _tid, /*subtract_mesh_velocity=*/true)); 58 368 : const bool correct_skewness = 59 368 : _advected_interp_method == Moose::FV::InterpMethod::SkewCorrectedAverage; 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 368 : const auto face_arg = 69 : Moose::FaceArg({fi, 70 368 : Moose::FV::limiterType(_advected_interp_method), 71 368 : face_flux > 0, 72 : correct_skewness, 73 368 : _adv_quant->hasFaceSide(*fi, true) ? fi->elemPtr() : fi->neighborPtr(), 74 368 : nullptr}); 75 368 : auto dens = _density(face_arg, state); 76 368 : const auto adv_quant_face = MetaPhysicL::raw_value(dens * (*_adv_quant)(face_arg, state)); 77 368 : _mdot += fi->faceArea() * fi->faceCoord() * MetaPhysicL::raw_value(dens) * face_flux; 78 368 : return face_flux * adv_quant_face; 79 : } 80 : 81 : void 82 30 : MassFluxWeightedFlowRate::threadJoin(const UserObject & y) 83 : { 84 30 : VolumetricFlowRate::threadJoin(y); 85 : const auto & pps = static_cast<const MassFluxWeightedFlowRate &>(y); 86 30 : _mdot += pps._mdot; 87 30 : } 88 : 89 : Real 90 142 : MassFluxWeightedFlowRate::getValue() const 91 : { 92 142 : return _integral_value / _mdot; 93 : } 94 : 95 : void 96 142 : MassFluxWeightedFlowRate::finalize() 97 : { 98 142 : VolumetricFlowRate::finalize(); 99 142 : gatherSum(_mdot); 100 142 : }