https://mooseframework.inl.gov
INSFEFluidMassKernel.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 
10 #include "INSFEFluidMassKernel.h"
11 #include "MooseMesh.h"
12 
13 registerMooseObject("NavierStokesApp", INSFEFluidMassKernel);
14 registerMooseObjectRenamed("NavierStokesApp",
15  MDFluidMassKernel,
16  "02/01/2024 00:00",
18 
21 {
23  params.addClassDescription("Adds advective term of mass conservation equation along with "
24  "pressure-stabilized Petrov-Galerkin terms");
25  return params;
26 }
27 
29  : INSFEFluidKernelStabilization(parameters),
30  _u_vel_second(_u_var.secondSln()),
31  _v_vel_second(_v_var.secondSln()),
32  _w_vel_second(_mesh.dimension() == 3 ? _w_var.secondSln() : _second_zero)
33 {
34 }
35 
36 Real
38 {
40  Real masseq_part = -_rho[_qp] * vec_vel * _grad_test[_i][_qp];
41 
42  // Compute PSPG term due to momentum equation residual vector
44  RealVectorValue convection_vec(
45  vec_vel * _grad_u_vel[_qp], vec_vel * _grad_v_vel[_qp], vec_vel * _grad_w_vel[_qp]);
46  RealVectorValue psi_pspg = _tauc[_qp] * _grad_test[_i][_qp];
47 
48  Real transient_pspg = _bTransient ? _rho[_qp] * velocityDot() * psi_pspg : 0;
49  Real convection_pspg = _rho[_qp] / porosity * convection_vec * psi_pspg;
50  Real pressure_pspg = porosity * _grad_u[_qp] * psi_pspg;
51  Real gravity_pspg = -porosity * _rho[_qp] * _vec_g * psi_pspg;
52 
53  Real viscous_pspg = 0;
54  Real pm_friction_pspg = 0;
55  if (porosity > 0.99)
56  {
57  RealVectorValue vec_vel_second(
58  _u_vel_second[_qp].tr(), _v_vel_second[_qp].tr(), _w_vel_second[_qp].tr());
59  viscous_pspg =
60  -(_dynamic_viscosity[_qp] + _turbulence_viscosity[_qp]) * vec_vel_second * psi_pspg;
61  }
62  else
63  {
64  Real velmag = std::sqrt(_u_vel[_qp] * _u_vel[_qp] + _v_vel[_qp] * _v_vel[_qp] +
65  _w_vel[_qp] * _w_vel[_qp]);
66 
67  pm_friction_pspg += _inertia_resistance_coeff[_qp] * vec_vel * velmag * psi_pspg;
68  pm_friction_pspg += _viscous_resistance_coeff[_qp] * vec_vel * psi_pspg;
69  }
70 
71  // Assemble PSPG terms
72  Real momeq_part = transient_pspg + convection_pspg + pressure_pspg + viscous_pspg + gravity_pspg +
73  pm_friction_pspg;
74 
75  // Assemble final residual
76  return masseq_part + momeq_part;
77 }
78 
79 Real
81 {
83  return porosity * _tauc[_qp] * _grad_test[_i][_qp] * _grad_phi[_j][_qp];
84 }
85 
86 Real
88 {
89  // Convert the Moose numbering to internal porous medium model variable numbering.
90  unsigned m = this->mapVarNumber(jvar);
91 
92  switch (m)
93  {
94  case 1:
95  case 2:
96  case 3:
97  {
99  Real velmag = std::sqrt(_u_vel[_qp] * _u_vel[_qp] + _v_vel[_qp] * _v_vel[_qp] +
100  _w_vel[_qp] * _w_vel[_qp]);
101 
102  Real mass_eqn_part = -_rho[_qp] * _phi[_j][_qp] * _grad_test[_i][_qp](m - 1);
103 
104  Real pm_inertial_pspg = 0;
105  Real pm_viscous_pspg = 0;
106  if (velmag < 1e-3)
107  pm_inertial_pspg = 0.;
108  else
109  pm_inertial_pspg = _inertia_resistance_coeff[_qp](m - 1, m - 1) *
110  (velmag + vec_vel(m - 1) * vec_vel(m - 1) / velmag) * _phi[_j][_qp] *
111  _tauc[_qp] * _grad_test[_i][_qp](m - 1);
112  pm_viscous_pspg = _viscous_resistance_coeff[_qp](m - 1, m - 1) * _phi[_j][_qp] * _tauc[_qp] *
113  _grad_test[_i][_qp](m - 1);
114 
115  return mass_eqn_part + pm_inertial_pspg + pm_viscous_pspg;
116  }
117 
118  default:
119  return 0;
120  }
121 }
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
registerMooseObject("NavierStokesApp", INSFEFluidMassKernel)
const VariableGradient & _grad_u
const VariableValue & _w_vel
const VariableSecond & _u_vel_second
const VariablePhiGradient & _grad_phi
const VariableSecond & _v_vel_second
const VariableGradient & _grad_w_vel
RealVectorValue velocityDot() const
static const std::string porosity
Definition: NS.h:104
virtual Real computeQpResidual() override
const MaterialProperty< Real > & _tauc
const MaterialProperty< Real > & _dynamic_viscosity
const MaterialProperty< RealTensorValue > & _inertia_resistance_coeff
The spatial part of the 3D mass conservation for fluid flow.
unsigned int _i
const VariableValue & _porosity
const MaterialProperty< Real > & _turbulence_viscosity
Base class for stabilization kernels.
virtual Real computeQpJacobian() override
const VariableValue & _u_vel
unsigned int _j
const VariableSecond & _w_vel_second
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const VariableTestGradient & _grad_test
const MaterialProperty< RealTensorValue > & _viscous_resistance_coeff
INSFEFluidMassKernel(const InputParameters &parameters)
registerMooseObjectRenamed("NavierStokesApp", MDFluidMassKernel, "02/01/2024 00:00", INSFEFluidMassKernel)
void addClassDescription(const std::string &doc_string)
const MaterialProperty< Real > & _rho
static InputParameters validParams()
unsigned int mapVarNumber(unsigned int var) const
Helper function for mapping Moose variable numberings into the "canonical" numbering for the porous m...
const VariableValue & _v_vel
const VariablePhiValue & _phi
const VariableGradient & _grad_u_vel
const VariableGradient & _grad_v_vel
unsigned int _qp