24 params.
addClassDescription(
"Represents the matrix and right hand side contributions of the "
25 "stress and advection terms of the momentum equation.");
26 params.
addRequiredParam<SolverVariableName>(
"u",
"The velocity in the x direction.");
27 params.
addParam<SolverVariableName>(
"v",
"The velocity in the y direction.");
28 params.
addParam<SolverVariableName>(
"w",
"The velocity in the z direction.");
30 "rhie_chow_user_object",
31 "The rhie-chow user-object which is used to determine the face velocity.");
33 MooseEnum momentum_component(
"x=0 y=1 z=2");
37 "The component of the momentum equation that this kernel applies to.");
39 "use_nonorthogonal_correction",
41 "If the nonorthogonal correction should be used when computing the normal gradient.");
43 "use_deviatoric_terms",
false,
"If deviatoric terms in the stress terms need to be used.");
46 "advected_interp_method_name",
47 "Name of the FVInterpolationMethod to use for the advected velocity.");
54 _dim(_subproblem.
mesh().dimension()),
55 _mass_flux_provider(getUserObject<
RhieChowMassFlux>(
"rhie_chow_user_object")),
56 _mu(getFunctor<Real>(getParam<MooseFunctorName>(
NS::
mu))),
57 _use_nonorthogonal_correction(getParam<bool>(
"use_nonorthogonal_correction")),
58 _use_deviatoric_terms(getParam<bool>(
"use_deviatoric_terms")),
59 _adv_interp_method(getFVAdvectedInterpolationMethod(
60 getParam<InterpolationMethodName>(
"advected_interp_method_name"))),
61 _advected_gradient_field(
62 _adv_interp_method.needsGradients()
63 ? &_var.requestCellGradients(_adv_interp_method.gradientMethodName())
66 _boundary_normal_factor(1.0),
67 _stress_matrix_contribution(0.0),
68 _stress_rhs_contribution(0.0),
69 _index(getParam<
MooseEnum>(
"momentum_component")),
70 _velocity_vars{nullptr, nullptr, nullptr},
71 _gradient_field(_use_nonorthogonal_correction || _use_deviatoric_terms
72 ? &_var.requestCellGradients()
74 _velocity_gradient_fields{nullptr, nullptr, nullptr},
75 _coord_type(getBlockCoordSystem()),
76 _rz_radial_coord(_fe_problem.
mesh().getAxisymmetricRadialCoord())
78 auto get_velocity_var = [&](
const std::string & param_name)
84 std::array<MooseLinearVariableFVReal *, 3> velocity_vars{
nullptr,
nullptr,
nullptr};
86 velocity_vars[0] = get_velocity_var(
"u");
87 if (!velocity_vars[0])
88 paramError(
"u",
"the u velocity must be a MooseLinearVariableFVReal.");
93 paramError(
"v",
"In two or more dimensions, the v velocity must be supplied.");
94 velocity_vars[1] = get_velocity_var(
"v");
95 if (!velocity_vars[1])
97 "In two or more dimensions, the v velocity must be supplied and it must be a "
98 "MooseLinearVariableFVReal.");
104 paramError(
"w",
"In three-dimensions, the w velocity must be supplied.");
105 velocity_vars[2] = get_velocity_var(
"w");
106 if (!velocity_vars[2])
108 "In three-dimensions, the w velocity must be supplied and it must be a "
109 "MooseLinearVariableFVReal.");
112 for (
const auto dir : make_range(
_dim))
116 for (
const auto dir : make_range(
_dim))
155 const auto *
const adv_diff_bc = cast_ptr<const LinearFVAdvectionDiffusionBC *>(&bc);
157 mooseAssert(adv_diff_bc,
"This should be a valid BC!");
166 const auto *
const adv_diff_bc = cast_ptr<const LinearFVAdvectionDiffusionBC *>(&bc);
167 mooseAssert(adv_diff_bc,
"This should be a valid BC!");
223 "Gradient field should be registered when gradients are needed.");
230 const auto interp_coeffs =
233 const auto correction_vector =
240 _mu(face_arg, state_arg) *
241 (interp_coeffs.first * grad_elem + interp_coeffs.second * grad_neighbor) *
250 const auto interp_coeffs =
253 RealGradient grad_elem[3];
254 RealGradient grad_neighbor[3];
256 Real trace_neighbor = 0;
257 RealVectorValue deviatoric_vector_elem;
258 RealVectorValue deviatoric_vector_neighbor;
261 for (
const auto dir : make_range(
_dim))
266 trace_elem += grad_elem[dir](dir);
267 trace_neighbor += grad_neighbor[dir](dir);
272 if (
_coord_type == Moose::CoordinateSystemType::COORD_RZ)
274 Real elem_value = 0.0;
275 Real neighbor_value = 0.0;
282 trace_elem += elem_value;
283 trace_neighbor += neighbor_value;
287 for (
const auto dir : make_range(
_dim))
289 grad_elem[dir](dir) -= 2. / 3 * trace_elem;
290 grad_neighbor[dir](dir) -= 2. / 3 * trace_neighbor;
292 deviatoric_vector_elem(dir) = grad_elem[dir](
_index);
293 deviatoric_vector_neighbor(dir) = grad_neighbor[dir](
_index);
297 (interp_coeffs.first * deviatoric_vector_elem +
298 interp_coeffs.second * deviatoric_vector_neighbor) *
347 const auto correction_vector =
351 mooseAssert(
_gradient_field,
"Gradient field should be registered when gradients are needed.");
367 RealGradient grad_elem[3];
369 RealVectorValue deviatoric_vector_elem;
371 for (
const auto dir : make_range(
_dim))
374 trace_elem += grad_elem[dir](dir);
377 if (
_coord_type == Moose::CoordinateSystemType::COORD_RZ)
380 const Real elem_value =
381 radial_var.getElemValue(*elem_info, state_arg) / elem_info->centroid()(
_rz_radial_coord);
382 trace_elem += elem_value;
385 for (
const auto dir : make_range(
_dim))
387 grad_elem[dir](dir) -= 2. / 3 * trace_elem;
388 deviatoric_vector_elem(dir) = grad_elem[dir](
_index);
440 "Gradient field should be registered when gradients are needed.");
462 "Velocity variable for requested direction is not available.");
470 "Velocity gradient field 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 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()
RealVectorValue gradient(const ElemInfo &elem_info) const
MooseLinearVariableFV< Real > & _var
FEProblemBase & _fe_problem
Kernel that implements the stress tensor and advection terms for the momentum equation.
const LinearFVGradientReader *const _advected_gradient_field
Gradient field used by advected interpolations that require gradients.
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.
const LinearFVGradientReader & velocityGradientField(unsigned int dir) const
Helper to access the velocity gradient field for a given direction.
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
std::array< const LinearFVGradientReader *, 3 > _velocity_gradient_fields
Gradient fields used for velocity variables in deviatoric stress terms.
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.
const LinearFVGradientReader * _gradient_field
Gradient field used for the kernel variable nonorthogonal correction.
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
Real getElemValue(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