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())
71 if (_use_nonorthogonal_correction || _use_deviatoric_terms)
72 _var.computeCellGradients();
74 if (_adv_interp_method.needsGradients())
75 _var.computeCellGradients(_adv_interp_method.gradientLimiter());
77 auto get_velocity_var = [&](
const std::string & param_name)
80 &_fe_problem.getVariable(_tid, getParam<SolverVariableName>(param_name)));
83 _velocity_vars[0] = get_velocity_var(
"u");
84 if (!_velocity_vars[0])
85 paramError(
"u",
"the u velocity must be a MooseLinearVariableFVReal.");
89 if (!params.isParamValid(
"v"))
90 paramError(
"v",
"In two or more dimensions, the v velocity must be supplied.");
91 _velocity_vars[1] = get_velocity_var(
"v");
92 if (!_velocity_vars[1])
94 "In two or more dimensions, the v velocity must be supplied and it must be a " 95 "MooseLinearVariableFVReal.");
100 if (!params.isParamValid(
"w"))
101 paramError(
"w",
"In three-dimensions, the w velocity must be supplied.");
102 _velocity_vars[2] = get_velocity_var(
"w");
103 if (!_velocity_vars[2])
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 =
244 Real trace_neighbor = 0;
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;
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) *
360 trace_elem += grad_elem[dir](dir);
363 if (
_coord_type == Moose::CoordinateSystemType::COORD_RZ)
366 const Real elem_value =
367 radial_var.getElemValue(*elem_info, state_arg) / elem_info->centroid()(
_rz_radial_coord);
368 trace_elem += elem_value;
373 grad_elem[dir](dir) -= 2. / 3 * trace_elem;
374 deviatoric_vector_elem(dir) = grad_elem[dir](
_index);
447 "Velocity variable for requested direction is not available.");
virtual Real computeBoundaryMatrixContribution(const LinearFVBoundaryCondition &bc) override
Real computeInternalAdvectionNeighborMatrixContribution()
Computes the matrix contribution of the advective flux on the neighbor side of current face when the ...
const unsigned int _index
Index x|y|z, this is mainly to handle the deviatoric parts correctly in in the stress term...
User object responsible for determining the face fluxes using the Rhie-Chow interpolation in a segreg...
virtual Real computeBoundaryGradientRHSContribution() const=0
Real computeInternalAdvectionElemMatrixContribution()
Computes the matrix contribution of the advective flux on the element side of current face when the f...
virtual Real computeNeighborRightHandSideContribution() override
std::pair< Real, Real > interpCoeffs(const InterpMethod m, const FaceInfo &fi, const bool one_is_elem, const T &face_flux=0.0)
Real getMassFlux(const FaceInfo &fi) const
Get the face velocity times density (used in advection terms)
Real computeStressBoundaryRHSContribution(const LinearFVAdvectionDiffusionBC *bc)
Computes the right hand side contributions of the boundary conditions resulting from the stress tenso...
Moose::FaceArg singleSidedFaceArg(const FaceInfo *fi, Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false) const
Moose::StateArg determineState() const
const ElemInfo * neighborInfo() const
const Point & faceCentroid() const
Real computeInternalStressMatrixContribution()
Computes the matrix contribution of the stress term on the current face when the face is an internal ...
MooseLinearVariableFV< Real > & _var
virtual void setupFaceData(const FaceInfo *face_info)
virtual Real computeBoundaryGradientMatrixContribution() const=0
const bool _use_nonorthogonal_correction
Switch to enable/disable nonorthogonal correction in the stress term.
const ElemInfo * elemInfo() const
const RhieChowMassFlux & _mass_flux_provider
The Rhie-Chow user object that provides us with the face velocity.
virtual Moose::FV::GradientLimiterType gradientLimiter() const
registerMooseObject("NavierStokesApp", LinearWCNSFVMomentumFlux)
std::array< const MooseLinearVariableFVReal *, 3 > _velocity_vars
Velocity variables for each coordinate direction.
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.
const Moose::CoordinateSystemType _coord_type
Coordinate system of the blocks this kernel operates on.
FaceInfo::VarFaceNeighbors _current_face_type
std::pair< Real, Real > weights_matrix
VectorValue< Real > _neighbor_grad_storage
Real _boundary_normal_factor
Multiplier that ensures the normal of the boundary always points outwards, even in cases when the bou...
const Moose::Functor< Real > & _mu
The functor for the dynamic viscosity.
VectorValue< Real > gradSln(const ElemInfo &elem_info, const StateArg &state) const
virtual bool useBoundaryGradientExtrapolation() const
static InputParameters validParams()
const MooseLinearVariableFVReal & velocityVar(unsigned int dir) const
Helper to access the velocity variable for a given direction.
const Point & centroid() const
FVAdvectedInterpolationMethod::AdvectedSystemContribution _adv_interp_result
Current advected interpolation contribution on the face.
static InputParameters validParams()
const FaceInfo * _current_face_info
virtual void setupFaceData(const FaceInfo *face_info) override
Set the current FaceInfo object.
Real computeAdvectionBoundaryMatrixContribution(const LinearFVAdvectionDiffusionBC *bc)
Computes the matrix contributions of the boundary conditions resulting from the advection term...
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
static const std::string mu
Kernel that implements the stress tensor and advection terms for the momentum equation.
Real computeAdvectionBoundaryRHSContribution(const LinearFVAdvectionDiffusionBC *bc)
Computes the right hand side contributions of the boundary conditions resulting from the advection te...
Real _stress_rhs_contribution
The cached right hand side contribution.
const Point & normal() const
virtual Real computeElemRightHandSideContribution() override
virtual bool includesMaterialPropertyMultiplier() const
const unsigned int _dim
The dimension of the mesh.
bool _cached_rhs_contribution
Real _stress_matrix_contribution
The cached matrix contribution.
Real computeStressBoundaryMatrixContribution(const LinearFVAdvectionDiffusionBC *bc)
Computes the matrix contributions of the boundary conditions resulting from the stress tensor...
virtual Real computeBoundaryValueMatrixContribution() const=0
virtual Real computeNeighborMatrixContribution() override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual bool needsGradients() const
const Point & eCN() const
Real _face_mass_flux
Container for the mass flux on the face which will be reused in the advection term's matrix and right...
virtual Real computeElemMatrixContribution() override
Real getElemValue(const ElemInfo &elem_info, const StateArg &state) const
IntRange< T > make_range(T beg, T end)
virtual Real computeBoundaryValueRHSContribution() const=0
bool _cached_matrix_contribution
LinearWCNSFVMomentumFlux(const InputParameters ¶ms)
Class constructor.
Moose::FaceArg makeCDFace(const FaceInfo &fi, const bool correct_skewness=false) const
Real computeInternalStressRHSContribution()
Computes the right hand side contribution of the stress term on the current face when the face is an ...
VectorValue< Real > _elem_grad_storage
Reusable gradient storage used when advected interpolation requires gradients.
const Point & dCN() const
const bool _use_deviatoric_terms
Switch to enable/disable deviatoric parts in the stress term.
virtual Real computeBoundaryRHSContribution(const LinearFVBoundaryCondition &bc) override