Skip to content

Commit

Permalink
Address Peter's review
Browse files Browse the repository at this point in the history
- face velocity -> volumetric face flux due to A term

Co-authored-by: Peter German <[email protected]>

Apply suggestions from code review

Co-authored-by: Peter German <[email protected]>
  • Loading branch information
GiudGiud and grmnptr committed Dec 4, 2024
1 parent 9f5cafe commit 84790cf
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For FV, the integral of the advection term of scalar $C_i$ over a cell can be ex

where $C_{if}$ is the face value of the scalar concentration. An interpolation scheme (e.g. upwind) can be used to compute the face value. This kernel adds the face contribution for each face $f$ to the right hand side and matrix.

The face mass flux $(\vec{u}\cdot \vec{n})_{RC}$ is provided by the [RhieChowMassFlux.md] object which uses pressure
The volumetric face flux $(\vec{u}\cdot \vec{n})_{RC}$ is provided by the [RhieChowMassFlux.md] object which uses pressure
gradients and the discrete momentum equation to compute face velocities and mass fluxes.
For more information on the expression that is used, see [SIMPLE.md].

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ where:
- $\phi_i$ is the i-th scalar quantity
- \mathbf{v} is the advecting velocity
- $k_i$ the i-th scalar diffusivity
- $Q_i$ is the i-th precursor source
- $Q_i$ is the i-th scalar source
- $\lambda_i$ is a reaction coefficient. It should be negative for a loss term

The kernels created are:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class LinearFVScalarAdvection : public LinearFVFluxKernel

/// Container for the velocity on the face which will be reused in the advection term's
/// matrix and right hand side contribution
Real _face_velocity;
Real _volumetric_face_flux;

/// The interpolation method to use for the advected quantity
Moose::FV::InterpMethod _advected_interp_method;
Expand Down
4 changes: 2 additions & 2 deletions modules/navier_stokes/include/userobjects/RhieChowMassFlux.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class RhieChowMassFlux : public GeneralUserObject,

/// Get the face velocity times density (used in advection terms)
Real getMassFlux(const FaceInfo & fi) const;
/// Get the face velocity (used in advection terms)
Real getFaceVelocity(const FaceInfo & fi) const;
/// Get the volumetric face flux (used in advection terms)
Real getVolumetricFaceFlux(const FaceInfo & fi) const;

/// Initialize the container for face velocities
void initFaceMassFlux();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ LinearFVScalarAdvection::LinearFVScalarAdvection(const InputParameters & params)
: LinearFVFluxKernel(params),
_mass_flux_provider(getUserObject<RhieChowMassFlux>("rhie_chow_user_object")),
_advected_interp_coeffs(std::make_pair<Real, Real>(0, 0)),
_face_velocity(0.0)
_volumetric_face_flux(0.0)
{
Moose::FV::setInterpolationMethod(*this, _advected_interp_method, "advected_interp_method");
}

Real
LinearFVScalarAdvection::computeElemMatrixContribution()
{
return _advected_interp_coeffs.first * _face_velocity * _current_face_area;
return _advected_interp_coeffs.first * _volumetric_face_flux * _current_face_area;
}

Real
LinearFVScalarAdvection::computeNeighborMatrixContribution()
{
return _advected_interp_coeffs.second * _face_velocity * _current_face_area;
return _advected_interp_coeffs.second * _volumetric_face_flux * _current_face_area;
}

Real
Expand All @@ -71,7 +71,7 @@ LinearFVScalarAdvection::computeBoundaryMatrixContribution(const LinearFVBoundar
// We support internal boundaries too so we have to make sure the normal points always outward
const auto factor = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM) ? 1.0 : -1.0;

return boundary_value_matrix_contrib * factor * _face_velocity * _current_face_area;
return boundary_value_matrix_contrib * factor * _volumetric_face_flux * _current_face_area;
}

Real
Expand All @@ -84,7 +84,7 @@ LinearFVScalarAdvection::computeBoundaryRHSContribution(const LinearFVBoundaryCo
const auto factor = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM ? 1.0 : -1.0);

const auto boundary_value_rhs_contrib = adv_bc->computeBoundaryValueRHSContribution();
return -boundary_value_rhs_contrib * factor * _face_velocity * _current_face_area;
return -boundary_value_rhs_contrib * factor * _volumetric_face_flux * _current_face_area;
}

void
Expand All @@ -94,10 +94,10 @@ LinearFVScalarAdvection::setupFaceData(const FaceInfo * face_info)

// Caching the velocity on the face which will be reused in the advection term's matrix and right
// hand side contributions
_face_velocity = _mass_flux_provider.getFaceVelocity(*face_info);
_volumetric_face_flux = _mass_flux_provider.getVolumetricFaceFlux(*face_info);

// Caching the interpolation coefficients so they will be reused for the matrix and right hand
// side terms
_advected_interp_coeffs =
interpCoeffs(_advected_interp_method, *_current_face_info, true, _face_velocity);
interpCoeffs(_advected_interp_method, *_current_face_info, true, _volumetric_face_flux);
}
7 changes: 4 additions & 3 deletions modules/navier_stokes/src/userobjects/RhieChowMassFlux.C
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,16 @@ RhieChowMassFlux::getMassFlux(const FaceInfo & fi) const
}

Real
RhieChowMassFlux::getFaceVelocity(const FaceInfo & fi) const
RhieChowMassFlux::getVolumetricFaceFlux(const FaceInfo & fi) const
{
const Moose::FaceArg face_arg{&fi,
/*limiter_type=*/Moose::FV::LimiterType::CentralDifference,
/*elem_is_upwind=*/true,
/*correct_skewness=*/false,
&fi.elem()};
&fi.elem(),
/*state_limiter*/ nullptr};
const Real face_rho = _rho(face_arg, Moose::currentState());
return _face_mass_flux.evaluate(&fi) / face_rho;
return libmesh_map_find(_face_mass_flux, fi.id()) / face_rho;
}

void
Expand Down

0 comments on commit 84790cf

Please sign in to comment.