26 params.
addClassDescription(
"Represents the matrix and right hand side contributions of the "
27 "stress and advection terms of the momentum equation.");
28 params.
addRequiredParam<SolverVariableName>(
"u",
"The velocity in the x direction.");
29 params.
addParam<SolverVariableName>(
"v",
"The velocity in the y direction.");
30 params.
addParam<SolverVariableName>(
"w",
"The velocity in the z direction.");
32 "rhie_chow_user_object",
33 "The rhie-chow user-object which is used to determine the face velocity.");
35 MooseEnum momentum_component(
"x=0 y=1 z=2");
39 "The component of the momentum equation that this kernel applies to.");
41 "use_nonorthogonal_correction",
43 "If the nonorthogonal correction should be used when computing the normal gradient.");
45 "use_deviatoric_terms",
false,
"If deviatoric terms in the stress terms need to be used.");
48 "advected_interp_method_name",
49 "Name of the FVInterpolationMethod to use for the advected velocity.");
56 _dim(_subproblem.
mesh().dimension()),
57 _mass_flux_provider(getUserObject<
RhieChowMassFlux>(
"rhie_chow_user_object")),
58 _mu(getFunctor<Real>(getParam<MooseFunctorName>(
NS::
mu))),
59 _use_nonorthogonal_correction(getParam<bool>(
"use_nonorthogonal_correction")),
60 _use_deviatoric_terms(getParam<bool>(
"use_deviatoric_terms")),
61 _adv_interp_method(getFVAdvectedInterpolationMethod(
62 getParam<InterpolationMethodName>(
"advected_interp_method_name"))),
63 _advected_gradient_field(
64 _adv_interp_method.needsGradients()
65 ? &_var.requestCellGradients(_adv_interp_method.gradientMethodName())
68 _boundary_normal_factor(1.0),
69 _stress_matrix_contribution(0.0),
70 _stress_rhs_contribution(0.0),
71 _index(getParam<
MooseEnum>(
"momentum_component")),
72 _velocity_vars{nullptr, nullptr, nullptr},
73 _gradient_field(_use_nonorthogonal_correction || _use_deviatoric_terms
74 ? &_var.requestCellGradients()
76 _velocity_gradient_fields{nullptr, nullptr, nullptr},
77 _coord_type(getBlockCoordSystem()),
78 _rz_radial_coord(_fe_problem.
mesh().getAxisymmetricRadialCoord())
85 "Must match the block restriction of variable '",
89 "). This kernel's blocks are ",
93 auto get_velocity_var = [&](
const std::string & param_name)
99 std::array<MooseLinearVariableFVReal *, 3> velocity_vars{
nullptr,
nullptr,
nullptr};
101 velocity_vars[0] = get_velocity_var(
"u");
102 if (!velocity_vars[0])
103 paramError(
"u",
"the u velocity must be a MooseLinearVariableFVReal.");
108 paramError(
"v",
"In two or more dimensions, the v velocity must be supplied.");
109 velocity_vars[1] = get_velocity_var(
"v");
110 if (!velocity_vars[1])
112 "In two or more dimensions, the v velocity must be supplied and it must be a "
113 "MooseLinearVariableFVReal.");
119 paramError(
"w",
"In three-dimensions, the w velocity must be supplied.");
120 velocity_vars[2] = get_velocity_var(
"w");
121 if (!velocity_vars[2])
123 "In three-dimensions, the w velocity must be supplied and it must be a "
124 "MooseLinearVariableFVReal.");
127 for (
const auto dir : make_range(
_dim))
131 for (
const auto dir : make_range(
_dim))
170 const auto *
const adv_diff_bc = cast_ptr<const LinearFVAdvectionDiffusionBC *>(&bc);
172 mooseAssert(adv_diff_bc,
"This should be a valid BC!");
181 const auto *
const adv_diff_bc = cast_ptr<const LinearFVAdvectionDiffusionBC *>(&bc);
182 mooseAssert(adv_diff_bc,
"This should be a valid BC!");
249 RealVectorValue correction_vector;
256 const auto interp_coeffs =
258 const Real elem_correction =
260 const Real neighbor_correction =
265 (interp_coeffs.first * elem_correction + interp_coeffs.second * neighbor_correction);
270 const ElemInfo & cell_info,
const RealVectorValue & nonorthogonal_correction_vector)
const
272 Real correction = 0.0;
276 mooseAssert(
_gradient_field,
"Gradient field should be registered when gradients are needed.");
284 std::array<RealGradient, 3> gradients;
286 RealVectorValue deviatoric_vector;
289 for (
const auto dir : make_range(
_dim))
292 trace += gradients[dir](dir);
295 if (
_coord_type == Moose::CoordinateSystemType::COORD_RZ)
300 for (
const auto dir : make_range(
_dim))
302 gradients[dir](dir) -= 2.0 / 3.0 * trace;
303 deviatoric_vector(dir) = gradients[dir](
_index);
352 const auto correction_vector =
356 mooseAssert(
_gradient_field,
"Gradient field should be registered when gradients are needed.");
421 "Gradient field should be registered when gradients are needed.");
443 "Velocity variable for requested direction is not available.");
451 "Velocity gradient field for requested direction is not available.");
registerMooseObject("NavierStokesApp", LinearWCNSFVMomentumFlux)
virtual const std::set< SubdomainID > & blockIDs() const
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.
Real computeInternalStressExplicitCorrection() const
Computes the explicit internal-face stress correction.
Real computeInternalStressTransmissibility() const
Computes the implicit internal-face stress transmissibility.
Real computeCellStressExplicitCorrection(const ElemInfo &cell_info, const RealVectorValue &nonorthogonal_correction_vector) const
Compute the explicit stress correction reconstructed from one adjacent cell.
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.
virtual 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.
virtual 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.
const std::string & name() const
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
std::string stringify(const T &t)
static const std::string mu
std::pair< Real, Real > weights_matrix