www.mooseframework.org
INSMass.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "INSMass.h"
11 #include "Function.h"
12 
13 registerMooseObject("NavierStokesApp", INSMass);
14 
17 {
19 
20  params.addClassDescription("This class computes the mass equation residual and Jacobian "
21  "contributions for the incompressible Navier-Stokes momentum "
22  "equation.");
23  params.addParam<bool>(
24  "pspg", false, "Whether to perform PSPG stabilization of the mass equation");
25  params.addParam<FunctionName>("x_vel_forcing_func", 0, "The x-velocity mms forcing function.");
26  params.addParam<FunctionName>("y_vel_forcing_func", 0, "The y-velocity mms forcing function.");
27  params.addParam<FunctionName>("z_vel_forcing_func", 0, "The z-velocity mms forcing function.");
28  return params;
29 }
30 
31 INSMass::INSMass(const InputParameters & parameters)
32  : INSBase(parameters),
33  _pspg(getParam<bool>("pspg")),
34  _x_ffn(getFunction("x_vel_forcing_func")),
35  _y_ffn(getFunction("y_vel_forcing_func")),
36  _z_ffn(getFunction("z_vel_forcing_func"))
37 
38 {
39 }
40 
41 Real
43 {
44  // (div u) * q
45  // Note: we (arbitrarily) multiply this term by -1 so that it matches the -p(div v)
46  // term in the momentum equation. Not sure if that is really important?
47  Real r = -(_grad_u_vel[_qp](0) + _grad_v_vel[_qp](1) + _grad_w_vel[_qp](2)) * _test[_i][_qp];
48 
49  if (_pspg)
50  r += computeQpPGResidual();
51 
52  return r;
53 }
54 
55 Real
57 {
58  RealVectorValue viscous_term =
60  RealVectorValue transient_term =
62  RealVectorValue convective_term = _convective_term ? convectiveTerm() : RealVectorValue(0, 0, 0);
63  Real r = -1. / _rho[_qp] * tau() * _grad_test[_i][_qp] *
64  (strongPressureTerm() + gravityTerm() + viscous_term + convective_term + transient_term -
67  _z_ffn.value(_t, _q_point[_qp])));
68 
69  return r;
70 }
71 
72 Real
74 {
75  // Derivative wrt to p is zero
76  Real r = 0;
77 
78  // Unless we are doing PSPG stabilization
79  if (_pspg)
80  r += computeQpPGJacobian();
81 
82  return r;
83 }
84 
85 Real
87 {
88  return -1. / _rho[_qp] * tau() * _grad_test[_i][_qp] * dStrongPressureDPressure();
89 }
90 
91 Real
92 INSMass::computeQpOffDiagJacobian(const unsigned int jvar)
93 {
94  if (jvar == _u_vel_var_number)
95  {
96  Real jac = -_grad_phi[_j][_qp](0) * _test[_i][_qp];
97  if (_pspg)
99  return jac;
100  }
101 
102  else if (jvar == _v_vel_var_number)
103  {
104  Real jac = -_grad_phi[_j][_qp](1) * _test[_i][_qp];
105  if (_pspg)
106  jac += computeQpPGOffDiagJacobian(1);
107  return jac;
108  }
109 
110  else if (jvar == _w_vel_var_number)
111  {
112  Real jac = -_grad_phi[_j][_qp](2) * _test[_i][_qp];
113  if (_pspg)
114  jac += computeQpPGOffDiagJacobian(2);
115  return jac;
116  }
117 
118  else
119  return 0.0;
120 }
121 
122 Real
123 INSMass::computeQpPGOffDiagJacobian(const unsigned int comp)
124 {
125  RealVectorValue convective_term = _convective_term ? convectiveTerm() : RealVectorValue(0, 0, 0);
126  RealVectorValue d_convective_term_d_u_comp =
128  RealVectorValue viscous_term =
130  RealVectorValue d_viscous_term_d_u_comp =
132  RealVectorValue transient_term =
134  RealVectorValue d_transient_term_d_u_comp =
136 
137  return -1. / _rho[_qp] * tau() * _grad_test[_i][_qp] *
138  (d_convective_term_d_u_comp + d_viscous_term_d_u_comp + d_transient_term_d_u_comp) -
139  1. / _rho[_qp] * dTauDUComp(comp) * _grad_test[_i][_qp] *
140  (convective_term + viscous_term + transient_term + strongPressureTerm() +
141  gravityTerm() -
144  _z_ffn.value(_t, _q_point[_qp])));
145 }
virtual RealVectorValue strongViscousTermLaplace()
Definition: INSBase.C:170
virtual RealVectorValue dStrongViscDUCompTraction(unsigned comp)
Definition: INSBase.C:194
virtual Real tau()
Definition: INSBase.C:321
virtual Real computeQpOffDiagJacobian(unsigned jvar)
Definition: INSMass.C:92
const MaterialProperty< Real > & _rho
Definition: INSBase.h:134
This class computes strong and weak components of the INS governing equations.
Definition: INSBase.h:18
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
virtual Real computeQpJacobian()
Definition: INSMass.C:73
static InputParameters validParams()
Definition: INSBase.C:15
const VariablePhiGradient & _grad_phi
virtual Real dTauDUComp(unsigned comp)
Definition: INSBase.C:349
const VariableGradient & _grad_v_vel
Definition: INSBase.h:105
This class computes the mass equation residual and Jacobian contributions for the incompressible Navi...
Definition: INSMass.h:21
const Function & _z_ffn
Definition: INSMass.h:42
static InputParameters validParams()
Definition: INSMass.C:16
virtual Real computeQpPGResidual()
Definition: INSMass.C:56
const Function & _y_ffn
Definition: INSMass.h:41
unsigned _w_vel_var_number
Definition: INSBase.h:127
virtual RealVectorValue dStrongPressureDPressure()
Definition: INSBase.C:277
bool _pspg
Definition: INSMass.h:39
const VariableTestValue & _test
virtual RealVectorValue timeDerivativeTerm()
Definition: INSBase.C:295
virtual Real computeQpPGJacobian()
Definition: INSMass.C:86
virtual RealVectorValue convectiveTerm()
Definition: INSBase.C:132
Real & _t
bool _convective_term
Definition: INSBase.h:138
const VariableGradient & _grad_u_vel
Definition: INSBase.h:104
INSMass(const InputParameters &parameters)
Definition: INSMass.C:31
unsigned int _i
virtual RealVectorValue strongPressureTerm()
Definition: INSBase.C:265
bool _transient_term
Definition: INSBase.h:139
virtual RealVectorValue dConvecDUComp(unsigned comp)
Definition: INSBase.C:143
unsigned int _j
unsigned _u_vel_var_number
Definition: INSBase.h:125
virtual RealVectorValue dStrongViscDUCompLaplace(unsigned comp)
Definition: INSBase.C:185
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const VariableGradient & _grad_w_vel
Definition: INSBase.h:106
registerMooseObject("NavierStokesApp", INSMass)
const VariableTestGradient & _grad_test
bool _laplace
Definition: INSBase.h:137
const Function & _x_ffn
Definition: INSMass.h:40
virtual RealVectorValue gravityTerm()
Definition: INSBase.C:289
virtual RealVectorValue strongViscousTermTraction()
Definition: INSBase.C:177
void addClassDescription(const std::string &doc_string)
unsigned _v_vel_var_number
Definition: INSBase.h:126
virtual Real computeQpResidual()
Definition: INSMass.C:42
virtual Real value(Real t, const Point &p) const
virtual Real computeQpPGOffDiagJacobian(unsigned comp)
Definition: INSMass.C:123
const MooseArray< Point > & _q_point
unsigned int _qp
virtual RealVectorValue dTimeDerivativeDUComp(unsigned comp)
Definition: INSBase.C:301