23 params.
addClassDescription(
"Represents the matrix and right hand side contributions of the "
24 "stress and advection terms of the momentum equation.");
25 params.
addRequiredParam<SolverVariableName>(
"u",
"The velocity in the x direction.");
26 params.
addParam<SolverVariableName>(
"v",
"The velocity in the y direction.");
27 params.
addParam<SolverVariableName>(
"w",
"The velocity in the z direction.");
29 "rhie_chow_user_object",
30 "The rhie-chow user-object which is used to determine the face velocity.");
32 MooseEnum momentum_component(
"x=0 y=1 z=2");
36 "The component of the momentum equation that this kernel applies to.");
38 "use_nonorthogonal_correction",
40 "If the nonorthogonal correction should be used when computing the normal gradient.");
42 "use_deviatoric_terms",
false,
"If deviatoric terms in the stress terms need to be used.");
45 "advected_interp_method_name",
46 "Name of the FVInterpolationMethod to use for the advected velocity.");
53 _dim(_subproblem.
mesh().dimension()),
54 _mass_flux_provider(getUserObject<
RhieChowMassFlux>(
"rhie_chow_user_object")),
55 _mu(getFunctor<Real>(getParam<MooseFunctorName>(
NS::
mu))),
56 _use_nonorthogonal_correction(getParam<bool>(
"use_nonorthogonal_correction")),
57 _use_deviatoric_terms(getParam<bool>(
"use_deviatoric_terms")),
58 _adv_interp_method(getFVAdvectedInterpolationMethod(
59 getParam<InterpolationMethodName>(
"advected_interp_method_name"))),
61 _boundary_normal_factor(1.0),
62 _stress_matrix_contribution(0.0),
63 _stress_rhs_contribution(0.0),
64 _index(getParam<
MooseEnum>(
"momentum_component")),
65 _velocity_vars{nullptr, nullptr, nullptr},
66 _coord_type(getBlockCoordSystem()),
67 _rz_radial_coord(_fe_problem.
mesh().getAxisymmetricRadialCoord())
77 auto get_velocity_var = [&](
const std::string & param_name)
85 paramError(
"u",
"the u velocity must be a MooseLinearVariableFVReal.");
90 paramError(
"v",
"In two or more dimensions, the v velocity must be supplied.");
94 "In two or more dimensions, the v velocity must be supplied and it must be a "
95 "MooseLinearVariableFVReal.");
101 paramError(
"w",
"In three-dimensions, the w velocity must be supplied.");
105 "In three-dimensions, the w velocity must be supplied and it must be a "
106 "MooseLinearVariableFVReal.");
147 mooseAssert(adv_diff_bc,
"This should be a valid BC!");
157 mooseAssert(adv_diff_bc,
"This should be a valid BC!");
218 const auto interp_coeffs =
221 const auto correction_vector =
228 _mu(face_arg, state_arg) *
229 (interp_coeffs.first * grad_elem + interp_coeffs.second * grad_neighbor) *
238 const auto interp_coeffs =
241 RealGradient grad_elem[3];
242 RealGradient grad_neighbor[3];
244 Real trace_neighbor = 0;
245 RealVectorValue deviatoric_vector_elem;
246 RealVectorValue deviatoric_vector_neighbor;
249 for (
const auto dir : make_range(
_dim))
254 trace_elem += grad_elem[dir](dir);
255 trace_neighbor += grad_neighbor[dir](dir);
260 if (
_coord_type == Moose::CoordinateSystemType::COORD_RZ)
262 Real elem_value = 0.0;
263 Real neighbor_value = 0.0;
270 trace_elem += elem_value;
271 trace_neighbor += neighbor_value;
275 for (
const auto dir : make_range(
_dim))
277 grad_elem[dir](dir) -= 2. / 3 * trace_elem;
278 grad_neighbor[dir](dir) -= 2. / 3 * trace_neighbor;
280 deviatoric_vector_elem(dir) = grad_elem[dir](
_index);
281 deviatoric_vector_neighbor(dir) = grad_neighbor[dir](
_index);
285 (interp_coeffs.first * deviatoric_vector_elem +
286 interp_coeffs.second * deviatoric_vector_neighbor) *
335 const auto correction_vector =
339 grad_contrib +=
_mu(face_arg, state_arg) *
_var.
gradSln(*elem_info, state_arg) *
354 RealGradient grad_elem[3];
356 RealVectorValue deviatoric_vector_elem;
358 for (
const auto dir : make_range(
_dim))
361 trace_elem += grad_elem[dir](dir);
364 if (
_coord_type == Moose::CoordinateSystemType::COORD_RZ)
367 const Real elem_value =
368 radial_var.getElemValue(*elem_info, state_arg) / elem_info->centroid()(
_rz_radial_coord);
369 trace_elem += elem_value;
372 for (
const auto dir : make_range(
_dim))
374 grad_elem[dir](dir) -= 2. / 3 * trace_elem;
375 deviatoric_vector_elem(dir) = grad_elem[dir](
_index);
448 "Velocity variable for requested direction is not available.");
registerMooseObject("NavierStokesApp", LinearWCNSFVMomentumFlux)
const Point & centroid() const
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const override
virtual Moose::FV::GradientLimiterType gradientLimiter() const
virtual AdvectedSystemContribution advectedInterpolate(const FaceInfo &face, Real elem_value, Real neighbor_value, const VectorValue< Real > *elem_grad, const VectorValue< Real > *neighbor_grad, Real mass_flux) const=0
virtual bool needsGradients() const
Moose::FaceArg makeCDFace(const FaceInfo &fi, const bool correct_skewness=false) const
const Point & normal() const
const Point & eCN() const
const ElemInfo * elemInfo() const
const ElemInfo * neighborInfo() const
const Point & dCN() const
const Point & faceCentroid() const
virtual Real computeBoundaryValueMatrixContribution() const=0
virtual bool providesCompleteBoundaryFlux() const
virtual Real computeBoundaryValueRHSContribution() const=0
virtual Real computeBoundaryGradientMatrixContribution() const=0
virtual Real computeBoundaryGradientRHSContribution() const=0
virtual bool includesMaterialPropertyMultiplier() const
virtual bool needsBoundaryNonorthogonalCorrection() const
bool _cached_matrix_contribution
bool _cached_rhs_contribution
FaceInfo::VarFaceNeighbors _current_face_type
Moose::FaceArg singleSidedFaceArg(const FaceInfo *fi, Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false) const
virtual void setupFaceData(const FaceInfo *face_info)
const FaceInfo * _current_face_info
static InputParameters validParams()
MooseLinearVariableFV< Real > & _var
FEProblemBase & _fe_problem
Kernel that implements the stress tensor and advection terms for the momentum equation.
virtual void setupFaceData(const FaceInfo *face_info) override
Set the current FaceInfo object.
Real computeInternalStressMatrixContribution()
Computes the matrix contribution of the stress term on the current face when the face is an internal ...
virtual Real computeNeighborMatrixContribution() override
VectorValue< Real > _elem_grad_storage
Reusable gradient storage used when advected interpolation requires gradients.
const MooseLinearVariableFVReal & velocityVar(unsigned int dir) const
Helper to access the velocity variable for a given direction.
Real _face_mass_flux
Container for the mass flux on the face which will be reused in the advection term's matrix and right...
const unsigned int _rz_radial_coord
Axisymmetric radial coordinate index (only used when in RZ)
const FVAdvectedInterpolationMethod & _adv_interp_method
The interpolation method to use for the advected quantity.
Real computeInternalAdvectionElemMatrixContribution()
Computes the matrix contribution of the advective flux on the element side of current face when the f...
FVAdvectedInterpolationMethod::AdvectedSystemContribution _adv_interp_result
Current advected interpolation contribution on the face.
virtual Real computeNeighborRightHandSideContribution() override
const Moose::CoordinateSystemType _coord_type
Coordinate system of the blocks this kernel operates on.
virtual Real computeElemMatrixContribution() override
Real _stress_matrix_contribution
The cached matrix contribution.
const Moose::Functor< Real > & _mu
The functor for the dynamic viscosity.
virtual Real computeElemRightHandSideContribution() override
Real _boundary_normal_factor
Multiplier that ensures the normal of the boundary always points outwards, even in cases when the bou...
Real _stress_rhs_contribution
The cached right hand side contribution.
virtual Real computeBoundaryRHSContribution(const LinearFVBoundaryCondition &bc) override
const unsigned int _index
Index x|y|z, this is mainly to handle the deviatoric parts correctly in in the stress term.
Real computeAdvectionBoundaryMatrixContribution(const LinearFVAdvectionDiffusionBC *bc)
Computes the matrix contributions of the boundary conditions resulting from the advection term.
const bool _use_deviatoric_terms
Switch to enable/disable deviatoric parts in the stress term.
Real computeAdvectionBoundaryRHSContribution(const LinearFVAdvectionDiffusionBC *bc)
Computes the right hand side contributions of the boundary conditions resulting from the advection te...
Real computeInternalStressRHSContribution()
Computes the right hand side contribution of the stress term on the current face when the face is an ...
VectorValue< Real > _neighbor_grad_storage
Real computeInternalAdvectionNeighborMatrixContribution()
Computes the matrix contribution of the advective flux on the neighbor side of current face when the ...
std::array< const MooseLinearVariableFVReal *, 3 > _velocity_vars
Velocity variables for each coordinate direction.
const unsigned int _dim
The dimension of the mesh.
const bool _use_nonorthogonal_correction
Switch to enable/disable nonorthogonal correction in the stress term.
Real computeStressBoundaryMatrixContribution(const LinearFVAdvectionDiffusionBC *bc)
Computes the matrix contributions of the boundary conditions resulting from the stress tensor.
const RhieChowMassFlux & _mass_flux_provider
The Rhie-Chow user object that provides us with the face velocity.
Real computeStressBoundaryRHSContribution(const LinearFVAdvectionDiffusionBC *bc)
Computes the right hand side contributions of the boundary conditions resulting from the stress tenso...
static InputParameters validParams()
virtual Real computeBoundaryMatrixContribution(const LinearFVBoundaryCondition &bc) override
LinearWCNSFVMomentumFlux(const InputParameters ¶ms)
Class constructor.
void paramError(const std::string ¶m, Args... args) const
void computeCellGradients()
Real getElemValue(const ElemInfo &elem_info, const StateArg &state) const
VectorValue< Real > gradSln(const ElemInfo &elem_info, const StateArg &state) const
User object responsible for determining the face fluxes using the Rhie-Chow interpolation in a segreg...
Real getMassFlux(const FaceInfo &fi) const
Get the face velocity times density (used in advection terms)
Moose::StateArg determineState() const
static const std::string mu
std::pair< Real, Real > weights_matrix