Skip to content

Commit

Permalink
Adjust postprocessors. (idaholab#29582)
Browse files Browse the repository at this point in the history
  • Loading branch information
grmnptr committed Dec 19, 2024
1 parent 80e6a8e commit 5ba0e96
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "SideIntegralPostprocessor.h"
#include "MathFVUtils.h"

class RhieChowInterpolatorBase;
class RhieChowFaceFluxProvider;

/**
* This postprocessor computes the volumetric flow rate through a boundary, internal or external to
Expand Down Expand Up @@ -60,5 +60,5 @@ class VolumetricFlowRate : public SideIntegralPostprocessor
Moose::FV::InterpMethod _velocity_interp_method;

/// The Rhie-Chow interpolation user object
const RhieChowInterpolatorBase * const _rc_uo;
const RhieChowFaceFluxProvider * const _rc_uo;
};
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ MassFluxWeightedFlowRate::computeFaceInfoIntegral([[maybe_unused]] const FaceInf
const auto state = determineState();

// Get face value for velocity
const auto vel = MetaPhysicL::raw_value(_rc_uo->getVelocity(
const auto face_flux = MetaPhysicL::raw_value(_rc_uo->getVolumetricFaceFlux(
_velocity_interp_method, *fi, state, _tid, /*subtract_mesh_velocity=*/true));
const bool correct_skewness =
_advected_interp_method == Moose::FV::InterpMethod::SkewCorrectedAverage;
Expand All @@ -68,14 +68,14 @@ MassFluxWeightedFlowRate::computeFaceInfoIntegral([[maybe_unused]] const FaceInf
const auto face_arg =
Moose::FaceArg({fi,
Moose::FV::limiterType(_advected_interp_method),
MetaPhysicL::raw_value(vel) * fi->normal() > 0,
face_flux > 0,
correct_skewness,
_adv_quant->hasFaceSide(*fi, true) ? fi->elemPtr() : fi->neighborPtr(),
nullptr});
auto dens = _density(face_arg, state);
const auto adv_quant_face = MetaPhysicL::raw_value(dens * (*_adv_quant)(face_arg, state));
_mdot += fi->faceArea() * fi->faceCoord() * MetaPhysicL::raw_value(dens) * fi->normal() * vel;
return fi->normal() * adv_quant_face * vel;
_mdot += fi->faceArea() * fi->faceCoord() * MetaPhysicL::raw_value(dens) * face_flux;
return face_flux * adv_quant_face;
}

void
Expand Down
19 changes: 10 additions & 9 deletions modules/navier_stokes/src/postprocessors/VolumetricFlowRate.C
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "VolumetricFlowRate.h"
#include "MathFVUtils.h"
#include "INSFVRhieChowInterpolator.h"
#include "RhieChowInterpolatorBase.h"
#include "NSFVUtils.h"

#include <cmath>
Expand Down Expand Up @@ -53,7 +53,7 @@ VolumetricFlowRate::VolumetricFlowRate(const InputParameters & parameters)
_adv_quant(isParamValid("advected_quantity") ? &getFunctor<ADReal>("advected_quantity")
: nullptr),
_rc_uo(isParamValid("rhie_chow_user_object")
? &getUserObject<RhieChowInterpolatorBase>("rhie_chow_user_object")
? &getUserObject<RhieChowFaceFluxProvider>("rhie_chow_user_object")
: nullptr)
{
// Check that at most one advected quantity has been provided
Expand Down Expand Up @@ -89,13 +89,14 @@ VolumetricFlowRate::VolumetricFlowRate(const InputParameters & parameters)
void
VolumetricFlowRate::initialSetup()
{
if (_rc_uo && _rc_uo->velocityInterpolationMethod() == Moose::FV::InterpMethod::RhieChow &&
!_rc_uo->segregated())
const auto * rc_base = dynamic_cast<const RhieChowInterpolatorBase *>(_rc_uo);
if (_rc_uo && rc_base && rc_base->velocityInterpolationMethod() == Moose::FV::InterpMethod::RhieChow &&
!rc_base->segregated())
{
// We must make sure the A coefficients in the Rhie Chow interpolator are present on
// both sides of the boundaries so that interpolation coefficients may be computed
for (const auto bid : boundaryIDs())
const_cast<RhieChowInterpolatorBase *>(_rc_uo)->ghostADataOnBoundary(bid);
const_cast<RhieChowInterpolatorBase *>(rc_base)->ghostADataOnBoundary(bid);

// On INITIAL, we cannot compute Rhie Chow coefficients on internal surfaces because
// - the time integrator is not ready to compute time derivatives
Expand All @@ -104,7 +105,7 @@ VolumetricFlowRate::initialSetup()
if (getExecuteOnEnum().isValueSet(EXEC_INITIAL))
for (const auto bid : boundaryIDs())
{
if (!_mesh.isBoundaryFullyExternalToSubdomains(bid, _rc_uo->blockIDs()))
if (!_mesh.isBoundaryFullyExternalToSubdomains(bid, rc_base->blockIDs()))
paramError(
"execute_on",
"Boundary '",
Expand All @@ -131,7 +132,7 @@ VolumetricFlowRate::computeFaceInfoIntegral(const FaceInfo * fi)
const auto state = determineState();

// Get face value for velocity
const auto vel = MetaPhysicL::raw_value(_rc_uo->getVelocity(
const auto face_flux = MetaPhysicL::raw_value(_rc_uo->getVolumetricFaceFlux(
_velocity_interp_method, *fi, state, _tid, /*subtract_mesh_velocity=*/true));

const bool correct_skewness =
Expand All @@ -145,12 +146,12 @@ VolumetricFlowRate::computeFaceInfoIntegral(const FaceInfo * fi)
const auto adv_quant_face = MetaPhysicL::raw_value(
(*_adv_quant)(Moose::FaceArg({fi,
Moose::FV::limiterType(_advected_interp_method),
MetaPhysicL::raw_value(vel) * fi->normal() > 0,
face_flux > 0,
correct_skewness,
elem,
nullptr}),
state));
return fi->normal() * adv_quant_face * vel;
return face_flux * adv_quant_face;
}

Real
Expand Down

0 comments on commit 5ba0e96

Please sign in to comment.