https://mooseframework.inl.gov
INSFEFluidMomentumKernel.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 
13 registerMooseObjectRenamed("NavierStokesApp",
14  MDFluidMomentumKernel,
15  "02/01/2024 00:00",
17 
20 {
22  params.addClassDescription("Adds advection, viscous, pressure, friction, and gravity terms to "
23  "the Navier-Stokes momentum equation, potentially with stabilization");
24  params.addParam<bool>("conservative_form", false, "Whether conservative form is used");
25  params.addParam<bool>(
26  "p_int_by_parts", false, "Whether integration by parts is applied to the pressure term");
27  params.addRequiredParam<unsigned>("component", "0,1,or 2 for x-, y-, or z- direction");
28  return params;
29 }
30 
32  : INSFEFluidKernelStabilization(parameters),
33  _grad_eps(coupledGradient("porosity")),
34  _conservative_form(getParam<bool>("conservative_form")),
35  _p_int_by_parts(getParam<bool>("p_int_by_parts")),
36  _component(getParam<unsigned>("component"))
37 {
38 }
39 
40 Real
42 {
45 
46  // Weak form residual of the momentum equation
47  Real convection_part = _conservative_form
48  ? -_rho[_qp] / porosity * _u[_qp] * vec_vel * _grad_test[_i][_qp]
49  : _rho[_qp] / porosity * vec_vel * _grad_u[_qp] * _test[_i][_qp];
50  Real gravity_part = -porosity * _rho[_qp] * _vec_g(_component) * _test[_i][_qp];
51  Real pressure_part = _p_int_by_parts
55 
56  Real viscous_part = 0;
57  Real friction = 0;
58  Real friction_part = 0;
59  if (porosity > 0.99)
60  {
61  RealVectorValue viscous_stress_vec(_viscous_stress_tensor[_qp](_component, 0),
64  viscous_part = viscous_stress_vec * _grad_test[_i][_qp];
65  }
66  else
67  {
68  Real velmag = std::sqrt(_u_vel[_qp] * _u_vel[_qp] + _v_vel[_qp] * _v_vel[_qp] +
69  _w_vel[_qp] * _w_vel[_qp]);
70  Real pm_inertial_part =
72  Real pm_viscous_part =
74  friction = pm_inertial_part + pm_viscous_part;
75  friction_part = friction * _test[_i][_qp];
76  }
77 
78  // Assemble weak form terms
79  Real normal_part = convection_part + pressure_part + gravity_part + viscous_part + friction_part;
80 
81  // SUPG contributions
82  Real psi_supg = _taum[_qp] * _vel_elem * _grad_test[_i][_qp];
83 
84  Real transient_supg = _bTransient ? _rho[_qp] * velocityDot()(_component) : 0;
85  Real convection_supg = _rho[_qp] / porosity * vec_vel * _grad_u[_qp];
86  Real pressure_supg = porosity * _grad_pressure[_qp](_component);
87  Real gravity_supg = -porosity * _rho[_qp] * _vec_g(_component);
88  Real viscous_supg = 0;
89  Real friction_supg = friction;
90  if (porosity > 0.99)
91  viscous_supg = -(_dynamic_viscosity[_qp] + _turbulence_viscosity[_qp]) * _second_u[_qp].tr();
92 
93  // Assemble SUPG terms
94  Real supg_part = psi_supg * (transient_supg + convection_supg + pressure_supg + viscous_supg +
95  friction_supg + gravity_supg);
96 
97  // Assemble weak form and SUPG contributions
98  Real res = normal_part + supg_part;
99  if (_p_int_by_parts && (_component == 0) &&
101  res -= porosity * _pressure[_qp] / _q_point[_qp](0) * _test[_i][_qp];
102 
103  return res;
104 }
105 
106 Real
108 {
110  RealVectorValue vec_vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
111 
112  // supg parts (some terms can be reused in the weak form)
113  Real psi_supg = _taum[_qp] * _vel_elem * _grad_test[_i][_qp];
114  Real transient_supg = _bTransient ? _rho[_qp] * _du_dot_du[_qp] * _phi[_j][_qp] : 0;
115  Real convection_supg = _rho[_qp] / porosity *
116  (_phi[_j][_qp] * _grad_u[_qp](_component) + _grad_phi[_j][_qp] * vec_vel);
117 
118  // Weak form parts
119  Real convection_part = 0;
120  if (_conservative_form)
121  convection_part = -_rho[_qp] / porosity * _phi[_j][_qp] *
122  (vec_vel * _grad_test[_i][_qp] + _u[_qp] * _grad_test[_i][_qp](_component));
123  else
124  convection_part = convection_supg * _test[_i][_qp];
125 
126  Real viscous_part = 0;
127  Real friction_part = 0;
128  Real friction_supg = 0;
129  if (porosity > 0.99)
130  viscous_part = (_dynamic_viscosity[_qp] + _turbulence_viscosity[_qp]) *
132  else
133  {
134  Real velmag = std::sqrt(_u_vel[_qp] * _u_vel[_qp] + _v_vel[_qp] * _v_vel[_qp] +
135  _w_vel[_qp] * _w_vel[_qp]);
136 
137  Real pm_inertial_part = 0;
138  if (velmag > 1e-3)
139  pm_inertial_part = _inertia_resistance_coeff[_qp](_component, _component) * _phi[_j][_qp] *
140  (velmag + vec_vel(_component) * vec_vel(_component) / velmag);
142 
143  friction_part = (pm_inertial_part + pm_viscous_part) * _test[_i][_qp];
144  friction_supg = (pm_inertial_part + pm_viscous_part) * psi_supg;
145  }
146 
147  // Assemble weak form and SUPG contributions
148  Real normal_part = convection_part + viscous_part + friction_part;
149  Real supg_part = psi_supg * (transient_supg + convection_supg) + friction_supg;
150 
151  return normal_part + supg_part;
152 }
153 
154 Real
156 {
157  unsigned m = this->mapVarNumber(jvar);
159  RealVectorValue vec_vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
160 
161  Real psi_supg = _taum[_qp] * _vel_elem * _grad_test[_i][_qp];
162 
163  Real jac = 0.;
164  switch (m)
165  {
166  case 0:
170  if (_p_int_by_parts && (_component == 0) &&
172  jac -= porosity * _phi[_j][_qp] / _q_point[_qp](0) * _test[_i][_qp];
173  break;
174  case 1:
175  case 2:
176  case 3:
177  if (m != (_component + 1))
178  {
179  // convection term weak form
180  if (_conservative_form)
181  jac = -_rho[_qp] / porosity * _phi[_j][_qp] * _u[_qp] * _grad_test[_i][_qp](m - 1);
182  else
183  jac = _rho[_qp] / porosity * _phi[_j][_qp] * _grad_u[_qp](m - 1) * _test[_i][_qp];
184  // convection SUPG term
185  jac += _rho[_qp] / porosity * _phi[_j][_qp] * _grad_u[_qp](m - 1) * psi_supg;
186  // pm friction
187  if (porosity <= 0.99)
188  {
189  Real velmag = std::sqrt(_u_vel[_qp] * _u_vel[_qp] + _v_vel[_qp] * _v_vel[_qp] +
190  _w_vel[_qp] * _w_vel[_qp]);
191  if (velmag > 1e-3)
192  {
193  // inertia_resistance, both normal and supg parts
195  vec_vel(_component) * vec_vel(m - 1) / velmag * (_test[_i][_qp] + psi_supg);
196  }
197  }
198  }
199  break;
200 
201  case 4:
202  default:
203  jac = 0.;
204  }
205  return jac;
206 }
registerMooseObject("NavierStokesApp", INSFEFluidMomentumKernel)
const VariableSecond & _second_u
const VariableGradient & _grad_u
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const VariableValue & _w_vel
const VariablePhiGradient & _grad_phi
virtual Real computeQpResidual() override
RealVectorValue velocityDot() const
void addRequiredParam(const std::string &name, const std::string &doc_string)
static const std::string porosity
Definition: NS.h:104
const VariableTestValue & _test
const VariableGradient & _grad_pressure
const MaterialProperty< Real > & _dynamic_viscosity
const VariableValue & _pressure
const MaterialProperty< RealTensorValue > & _inertia_resistance_coeff
FEProblemBase & _fe_problem
unsigned int _i
const VariableValue & _porosity
const MaterialProperty< Real > & _turbulence_viscosity
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
const unsigned _component
The component (x=0, y=1, z=2) of the momentum equation this kernel is applied.
const bool _conservative_form
Whether conservative form to be used for the convection term.
Base class for stabilization kernels.
const VariableValue & _u_vel
const VariableGradient & _grad_eps
Gradient of porosity.
virtual Real computeQpJacobian() override
unsigned int _j
The spatial part of the 3D momentum conservation for fluid flow.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const VariableTestGradient & _grad_test
const MaterialProperty< RealTensorValue > & _viscous_resistance_coeff
registerMooseObjectRenamed("NavierStokesApp", MDFluidMomentumKernel, "02/01/2024 00:00", INSFEFluidMomentumKernel)
void addClassDescription(const std::string &doc_string)
const MaterialProperty< Real > & _rho
Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const
const bool _p_int_by_parts
Whether integration by parts to be used for the pressure gradient term.
const Elem *const & _current_elem
unsigned int mapVarNumber(unsigned int var) const
Helper function for mapping Moose variable numberings into the "canonical" numbering for the porous m...
INSFEFluidMomentumKernel(const InputParameters &parameters)
const VariableValue & _v_vel
const VariablePhiValue & _phi
const MaterialProperty< RealTensorValue > & _viscous_stress_tensor
const MaterialProperty< Real > & _taum
const MooseArray< Point > & _q_point
const VariableValue & _u
unsigned int _qp