18#include "libmesh/nonlinear_solver.h"
27 params.addRequiredParam<MooseFunctorName>(
NS::mu,
"The viscosity");
28 params.addClassDescription(
29 "Implements the Laplace form of the viscous stress in the Navier-Stokes equation.");
31 MooseEnum coeff_interp_method(
"average harmonic",
"harmonic");
32 params.addParam<
MooseEnum>(
"mu_interp_method",
34 "Switch that can select face interpolation method for the viscosity.");
35 params.set<
unsigned short>(
"ghost_layers") = 2;
39 params.addRelationshipManager(
40 "ElementSideNeighborLayers",
41 Moose::RelationshipManagerType::GEOMETRIC | Moose::RelationshipManagerType::ALGEBRAIC |
42 Moose::RelationshipManagerType::COUPLING,
46 params.addParam<
bool>(
49 "Boolean parameter to use complete momentum expansion is the diffusion term.");
50 params.addParam<
bool>(
"include_isotropic_viscous_stress",
52 "Add the -(2/3) mu div(u) I term (requires specifying the velocity "
53 "components via 'u', 'v', 'w'). Only meaningful for "
54 "weakly-compressible formulations.");
55 params.addParam<MooseFunctorName>(
"u",
"The velocity in the x direction.");
56 params.addParam<MooseFunctorName>(
"v",
"The velocity in the y direction.");
57 params.addParam<MooseFunctorName>(
"w",
"The velocity in the z direction.");
58 params.addParam<
bool>(
59 "limit_interpolation",
false,
"Flag to limit interpolation to positive values.");
60 params.addParam<
bool>(
"newton_solve",
false,
"Whether a Newton nonlinear solve is being used");
61 params.addParamNamesToGroup(
"newton_solve",
"Advanced");
70 Moose::FV::selectInterpolationMethod(getParam<
MooseEnum>(
"mu_interp_method"))),
71 _u_var(params.isParamValid(
"u") ? &getFunctor<
ADReal>(
"u") : nullptr),
72 _v_var(params.isParamValid(
"v") ? &getFunctor<
ADReal>(
"v") : nullptr),
73 _w_var(params.isParamValid(
"w") ? &getFunctor<
ADReal>(
"w") : nullptr),
74 _complete_expansion(getParam<bool>(
"complete_expansion")),
75 _include_isotropic_viscous_stress(getParam<bool>(
"include_isotropic_viscous_stress")),
76 _limit_interpolation(getParam<bool>(
"limit_interpolation")),
77 _dim(_subproblem.
mesh().dimension()),
78 _newton_solve(getParam<bool>(
"newton_solve"))
81 paramError(
"u",
"The u velocity must be defined when 'complete_expansion=true'.");
85 "The v velocity must be defined when 'complete_expansion=true'"
86 "and problem dimension is larger or equal to 2.");
90 "The w velocity must be defined when 'complete_expansion=true'"
91 "and problem dimension is larger or equal to three.");
97 "Complete expansion needs to be enabled to use the isotropic viscous stress!");
100 paramError(
"include_isotropic_viscous_stress",
101 "Velocity components must be provided to use the "
102 "'include_isotropic_viscous_stress' option.");
104 paramError(
"include_isotropic_viscous_stress",
105 "Velocity components must be provided to use the "
106 "'include_isotropic_viscous_stress' option in dimensions >= 2.");
108 paramError(
"include_isotropic_viscous_stress",
109 "Velocity components must be provided to use the "
110 "'include_isotropic_viscous_stress' option in 3D.");
138 "Negative face viscosity has been encountered. Value ",
142 " limiting it to 0!\nFurther warnings for this issue will be silenced, but the "
143 "occurrences will be recorded through the solution invalidity interface."));
144 flagInvalidSolution(
"Negative face dynamic viscosity has been encountered.");
147 face_mu = 0 * face_mu;
150 if (populate_a_coeffs)
152 if (
_face_type == FaceInfo::VarFaceNeighbors::ELEM ||
153 _face_type == FaceInfo::VarFaceNeighbors::BOTH)
158 _ae = dudn.derivatives()[dof_number];
161 if (
_face_type == FaceInfo::VarFaceNeighbors::NEIGHBOR ||
162 _face_type == FaceInfo::VarFaceNeighbors::BOTH)
165 _an = dudn.derivatives()[dof_number];
170 ADReal dudn_transpose = 0.0;
171 ADReal divergence_term = 0.0;
186 const auto & grad_u =
_u_var->gradient(face, state);
191 const auto & grad_u =
_u_var->gradient(face, state);
192 const auto & grad_v =
_v_var->gradient(face, state);
197 const auto & grad_u =
_u_var->gradient(face, state);
198 const auto & grad_v =
_v_var->gradient(face, state);
199 const auto & grad_w =
_w_var->gradient(face, state);
204 const auto gradient_transpose =
gradient.transpose();
211 velocity(0) =
_u_var ? (*_u_var)(face, state) :
ADReal(0);
212 velocity(1) =
_v_var ? (*_v_var)(face, state) :
ADReal(0);
213 velocity(2) =
_w_var ? (*_w_var)(face, state) :
ADReal(0);
216 unsigned int rz_radial_coord =
223 ADReal residual = -face_mu * (dudn + dudn_transpose);
242 if (
_face_type == FaceInfo::VarFaceNeighbors::ELEM ||
243 _face_type == FaceInfo::VarFaceNeighbors::BOTH)
245 if (
_face_type == FaceInfo::VarFaceNeighbors::NEIGHBOR ||
246 _face_type == FaceInfo::VarFaceNeighbors::BOTH)
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("NavierStokesApp", INSFVMomentumDiffusion)
const bool _correct_skewness
static InputParameters validParams()
Moose::ElemArg neighborArg(bool correct_skewness=false) const
Moose::ElemArg elemArg(bool correct_skewness=false) const
virtual bool skipForBoundary(const FaceInfo &fi) const
bool onBoundary(const FaceInfo &fi) const
MooseVariableFV< Real > & _var
Moose::FaceArg singleSidedFaceArg(const FaceInfo *fi=nullptr, Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false, const Moose::StateArg *state_limiter=nullptr) const
virtual ADReal gradUDotNormal(const Moose::StateArg &time, const bool correct_skewness) const
const FaceInfo * _face_info
FaceInfo::VarFaceNeighbors _face_type
static void setRMParamsDiffusion(const InputParameters &obj_params, InputParameters &rm_params, const unsigned short conditional_extended_layers)
Moose::FaceArg makeCDFace(const FaceInfo &fi, const bool correct_skewness=false) const
const Point & normal() const
VarFaceNeighbors faceType(const std::pair< unsigned int, unsigned int > &var_sys) const
const Elem & elem() const
const Elem * neighborPtr() const
const Point & faceCentroid() const
const Elem & neighbor() const
A flux kernel that momentum residual objects that add non-advection flux terms, or more specifically ...
static InputParameters validParams()
void addResidualAndJacobian(const ADReal &residual)
Process into either the system residual or Jacobian.
ADReal _ae
The a coefficient for the element.
ADReal _an
The a coefficient for the neighbor.
const bool _include_isotropic_viscous_stress
Whether to add the -(2/3) mu div(u) I contribution.
const Moose::Functor< ADReal > *const _v_var
y-velocity
INSFVMomentumDiffusion(const InputParameters ¶ms)
const unsigned int _dim
dimension
const Moose::Functor< ADReal > *const _w_var
z-velocity
const Moose::FV::InterpMethod _mu_interp_method
The face interpolation method for the viscosity.
const Moose::Functor< ADReal > *const _u_var
x-velocity
virtual ADReal computeStrongResidual(const bool populate_a_coeffs)
Routine to compute this object's strong residual (e.g.
static InputParameters validParams()
const bool _limit_interpolation
Boolean parameter to limit interpolation.
virtual ADReal computeSegregatedContribution() override
Compute the contribution which goes into the residual of the segregated system.
const Moose::Functor< ADReal > & _mu
The dynamic viscosity.
void gatherRCData(const FaceInfo &fi) override final
Should be a non-empty implementation if the residual object is a FVFluxKernel and introduces residual...
const bool _complete_expansion
Boolean parameter to include the complete momentum expansion.
const unsigned int _index
index x|y|z
RhieChowInterpolatorBase & _rc_uo
The Rhie Chow user object that is responsible for generating face velocities for advection terms.
void paramError(const std::string ¶m, Args... args) const
void mooseWarning(Args &&... args) const
unsigned int number() const
virtual const OutputTools< T >::VariableGradient & gradient()
virtual void addToA(const libMesh::Elem *elem, unsigned int component, const ADReal &value)=0
API for momentum residual objects that have on-diagonals for velocity call.
unsigned int getAxisymmetricRadialCoord() const
Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const
unsigned int number() const
Moose::StateArg determineState() const
void interpolate(InterpMethod m, T &result, const T2 &value1, const T3 &value2, const FaceInfo &fi, const bool one_is_elem)
T divergence(const TensorValue< T > &gradient, const VectorType &value, const PointType &point, const Moose::CoordinateSystemType &coord_sys, const unsigned int rz_radial_coord)
Compute the divergence of a vector given its matrix of derivatives.
static const std::string mu