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.");
51 _dim(_subproblem.
mesh().dimension()),
52 _mass_flux_provider(getUserObject<
RhieChowMassFlux>(
"rhie_chow_user_object")),
53 _mu(getFunctor<
Real>(getParam<MooseFunctorName>(
NS::
mu))),
54 _use_nonorthogonal_correction(getParam<bool>(
"use_nonorthogonal_correction")),
55 _use_deviatoric_terms(getParam<bool>(
"use_deviatoric_terms")),
56 _advected_interp_coeffs(
std::make_pair<
Real,
Real>(0, 0)),
58 _boundary_normal_factor(1.0),
59 _stress_matrix_contribution(0.0),
60 _stress_rhs_contribution(0.0),
61 _index(getParam<
MooseEnum>(
"momentum_component")),
62 _velocity_vars{
nullptr,
nullptr,
nullptr},
63 _coord_type(getBlockCoordSystem()),
64 _rz_radial_coord(_fe_problem.mesh().getAxisymmetricRadialCoord())
68 if (_use_nonorthogonal_correction || _use_deviatoric_terms)
69 _var.computeCellGradients();
73 auto get_velocity_var = [&](
const std::string & param_name)
76 &_fe_problem.getVariable(_tid, getParam<SolverVariableName>(param_name)));
79 _velocity_vars[0] = get_velocity_var(
"u");
80 if (!_velocity_vars[0])
81 paramError(
"u",
"the u velocity must be a MooseLinearVariableFVReal.");
85 if (!params.isParamValid(
"v"))
86 paramError(
"v",
"In two or more dimensions, the v velocity must be supplied.");
87 _velocity_vars[1] = get_velocity_var(
"v");
88 if (!_velocity_vars[1])
90 "In two or more dimensions, the v velocity must be supplied and it must be a " 91 "MooseLinearVariableFVReal.");
96 if (!params.isParamValid(
"w"))
97 paramError(
"w",
"In three-dimensions, the w velocity must be supplied.");
98 _velocity_vars[2] = get_velocity_var(
"w");
99 if (!_velocity_vars[2])
101 "In three-dimensions, the w velocity must be supplied and it must be a " 102 "MooseLinearVariableFVReal.");
139 mooseAssert(adv_diff_bc,
"This should be a valid BC!");
149 mooseAssert(adv_diff_bc,
"This should be a valid BC!");
210 const auto interp_coeffs =
213 const auto correction_vector =
220 _mu(face_arg, state_arg) *
221 (interp_coeffs.first * grad_elem + interp_coeffs.second * grad_neighbor) *
230 const auto interp_coeffs =
236 Real trace_neighbor = 0;
246 trace_elem += grad_elem[dir](dir);
247 trace_neighbor += grad_neighbor[dir](dir);
252 if (
_coord_type == Moose::CoordinateSystemType::COORD_RZ)
254 Real elem_value = 0.0;
255 Real neighbor_value = 0.0;
262 trace_elem += elem_value;
263 trace_neighbor += neighbor_value;
269 grad_elem[dir](dir) -= 2. / 3 * trace_elem;
270 grad_neighbor[dir](dir) -= 2. / 3 * trace_neighbor;
272 deviatoric_vector_elem(dir) = grad_elem[dir](
_index);
273 deviatoric_vector_neighbor(dir) = grad_neighbor[dir](
_index);
277 (interp_coeffs.first * deviatoric_vector_elem +
278 interp_coeffs.second * deviatoric_vector_neighbor) *
327 const auto correction_vector =
331 grad_contrib +=
_mu(face_arg, state_arg) *
_var.
gradSln(*elem_info, state_arg) *
352 trace_elem += grad_elem[dir](dir);
355 if (
_coord_type == Moose::CoordinateSystemType::COORD_RZ)
358 const Real elem_value =
359 radial_var.getElemValue(*elem_info, state_arg) / elem_info->centroid()(
_rz_radial_coord);
360 trace_elem += elem_value;
365 grad_elem[dir](dir) -= 2. / 3 * trace_elem;
366 deviatoric_vector_elem(dir) = grad_elem[dir](
_index);
420 "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.
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 Moose::CoordinateSystemType _coord_type
Coordinate system of the blocks this kernel operates on.
FaceInfo::VarFaceNeighbors _current_face_type
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
static InputParameters validParams()
const FaceInfo * _current_face_info
InputParameters advectedInterpolationParameter()
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...
static const std::string mu
Kernel that implements the stress tensor and advection terms for the momentum equation.
std::pair< Real, Real > _advected_interp_coeffs
Container for the current advected interpolation coefficients on the face to make sure we don't compu...
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
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
IntRange< T > make_range(T beg, T end)
virtual Real computeBoundaryValueRHSContribution() const=0
Moose::FV::InterpMethod _advected_interp_method
The interpolation method to use for the advected quantity.
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 ...
bool setInterpolationMethod(const MooseObject &obj, Moose::FV::InterpMethod &interp_method, const std::string ¶m_name)
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