18 params.addClassDescription(
"This is the material class used to compute some of the strong "
19 "residuals for the INS equations.");
20 params.addRequiredCoupledVar(
"velocity",
"The velocity");
21 params.addRequiredCoupledVar(
"pressure",
"The pressure");
22 params.addParam<MaterialPropertyName>(
"mu_name",
"mu",
"The name of the dynamic viscosity");
23 params.addParam<MaterialPropertyName>(
"rho_name",
"rho",
"The name of the density");
24 params.addParam<
bool>(
"transient_term",
26 "Whether there should be a transient term in the momentum residuals.");
27 params.addParam<
bool>(
"integrate_p_by_parts",
29 "Whether to integrate the pressure by parts");
30 params.addParam<
bool>(
"include_viscous_term_in_strong_form",
32 "Whether to include the strong form of the viscous term in the momentum "
33 "equation strong residual. The method is more consistent if set to true, "
34 "but it incurs quite a bit more computational expense");
35 params.addParam<RealVectorValue>(
"gravity",
"Direction of the gravity vector");
36 params.addParam<FunctionName>(
"function_x", 0,
"The x-velocity mms forcing function.");
37 params.addParam<FunctionName>(
"function_y", 0,
"The y-velocity mms forcing function.");
38 params.addParam<FunctionName>(
"function_z", 0,
"The z-velocity mms forcing function."););
40 template <ComputeStage compute_stage>
42 : ADMaterial<compute_stage>(parameters),
43 _velocity(adCoupledVectorValue(
"velocity")),
44 _grad_velocity(adCoupledVectorGradient(
"velocity")),
45 _grad_p(adCoupledGradient(
"pressure")),
46 _mu(getADMaterialProperty<Real>(
"mu_name")),
47 _rho(getADMaterialProperty<Real>(
"rho_name")),
48 _transient_term(getParam<bool>(
"transient_term")),
49 _velocity_dot(_transient_term ? &adCoupledVectorDot(
"velocity") : nullptr),
50 _integrate_p_by_parts(getParam<bool>(
"integrate_p_by_parts")),
51 _include_viscous_term_in_strong_form(getParam<bool>(
"include_viscous_term_in_strong_form")),
52 _mass_strong_residual(declareADProperty<Real>(
"mass_strong_residual")),
53 _convective_strong_residual(declareADProperty<RealVectorValue>(
"convective_strong_residual")),
54 _td_strong_residual(declareADProperty<RealVectorValue>(
"td_strong_residual")),
55 _gravity_strong_residual(declareADProperty<RealVectorValue>(
"gravity_strong_residual")),
56 _mms_function_strong_residual(declareProperty<RealVectorValue>(
"mms_function_strong_residual")),
57 _momentum_strong_residual(declareADProperty<RealVectorValue>(
"momentum_strong_residual")),
58 _x_vel_fn(getFunction(
"function_x")),
59 _y_vel_fn(getFunction(
"function_y")),
60 _z_vel_fn(getFunction(
"function_z"))
62 if (parameters.isParamSetByUser(
"gravity"))
65 _gravity = getParam<RealVectorValue>(
"gravity");
69 if (getParam<bool>(
"include_viscous_term_in_strong_form"))
70 mooseError(
"Sorry no TypeNTensor operations are currently implemented, so we cannot add the "
71 "strong form contribution of the viscous term. Note that for linear elements, this "
72 "introduces no error, and in general for bi-linear elements, the error is small");
75 template <ComputeStage compute_stage>
79 _mass_strong_residual[_qp] = -_grad_velocity[_qp].tr();
80 _convective_strong_residual[_qp] = _rho[_qp] * _grad_velocity[_qp] * _velocity[_qp];
81 _td_strong_residual[_qp] =
82 _transient_term ? _rho[_qp] * (*_velocity_dot)[_qp] : ADRealVectorValue(0);
83 _gravity_strong_residual[_qp] = _gravity_set ? -_rho[_qp] * _gravity : ADRealVectorValue(0);
84 _mms_function_strong_residual[_qp] = -RealVectorValue(_x_vel_fn.value(_t, _q_point[_qp]),
85 _y_vel_fn.value(_t, _q_point[_qp]),
86 _z_vel_fn.value(_t, _q_point[_qp]));
87 _momentum_strong_residual[_qp] =
88 _gravity_strong_residual[_qp] + _mms_function_strong_residual[_qp] +
89 _convective_strong_residual[_qp] + _td_strong_residual[_qp] + _grad_p[_qp];