www.mooseframework.org
INSMass.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 #include "INSMass.h"
8 #include "Function.h"
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<INSBase>();
15 
16  params.addClassDescription("This class computes the mass equation residual and Jacobian "
17  "contributions for the incompressible Navier-Stokes momentum "
18  "equation.");
19  params.addParam<bool>(
20  "pspg", false, "Whether to perform PSPG stabilization of the mass equation");
21  params.addParam<FunctionName>("x_vel_forcing_func", 0, "The x-velocity mms forcing function.");
22  params.addParam<FunctionName>("y_vel_forcing_func", 0, "The y-velocity mms forcing function.");
23  params.addParam<FunctionName>("z_vel_forcing_func", 0, "The z-velocity mms forcing function.");
24  return params;
25 }
26 
27 INSMass::INSMass(const InputParameters & parameters)
28  : INSBase(parameters),
29  _pspg(getParam<bool>("pspg")),
30  _x_ffn(getFunction("x_vel_forcing_func")),
31  _y_ffn(getFunction("y_vel_forcing_func")),
32  _z_ffn(getFunction("z_vel_forcing_func"))
33 
34 {
35 }
36 
37 Real
39 {
40  // (div u) * q
41  // Note: we (arbitrarily) multiply this term by -1 so that it matches the -p(div v)
42  // term in the momentum equation. Not sure if that is really important?
43  Real r = -(_grad_u_vel[_qp](0) + _grad_v_vel[_qp](1) + _grad_w_vel[_qp](2)) * _test[_i][_qp];
44 
45  if (_pspg)
46  r += computeQpPGResidual();
47 
48  return r;
49 }
50 
51 Real
53 {
54  RealVectorValue viscous_term =
56  RealVectorValue transient_term =
57  _transient_term ? timeDerivativeTerm() : RealVectorValue(0, 0, 0);
58  RealVectorValue convective_term = _convective_term ? convectiveTerm() : RealVectorValue(0, 0, 0);
59  Real r = -1. / _rho[_qp] * tau() * _grad_test[_i][_qp] *
60  (strongPressureTerm() + gravityTerm() + viscous_term + convective_term + transient_term -
61  RealVectorValue(_x_ffn.value(_t, _q_point[_qp]),
62  _y_ffn.value(_t, _q_point[_qp]),
63  _z_ffn.value(_t, _q_point[_qp])));
64 
65  return r;
66 }
67 
68 Real
70 {
71  // Derivative wrt to p is zero
72  Real r = 0;
73 
74  // Unless we are doing GLS stabilization
75  if (_pspg)
76  r += computeQpPGJacobian();
77 
78  return r;
79 }
80 
81 Real
83 {
84  return -1. / _rho[_qp] * tau() * _grad_test[_i][_qp] * dStrongPressureDPressure();
85 }
86 
87 Real
89 {
90  if (jvar == _u_vel_var_number)
91  {
92  Real jac = -_grad_phi[_j][_qp](0) * _test[_i][_qp];
93  if (_pspg)
95  return jac;
96  }
97 
98  else if (jvar == _v_vel_var_number)
99  {
100  Real jac = -_grad_phi[_j][_qp](1) * _test[_i][_qp];
101  if (_pspg)
102  jac += computeQpPGOffDiagJacobian(1);
103  return jac;
104  }
105 
106  else if (jvar == _w_vel_var_number)
107  {
108  Real jac = -_grad_phi[_j][_qp](2) * _test[_i][_qp];
109  if (_pspg)
110  jac += computeQpPGOffDiagJacobian(2);
111  return jac;
112  }
113 
114  else
115  return 0.0;
116 }
117 
118 Real
120 {
121  RealVectorValue convective_term = _convective_term ? convectiveTerm() : RealVectorValue(0, 0, 0);
122  RealVectorValue d_convective_term_d_u_comp =
123  _convective_term ? dConvecDUComp(comp) : RealVectorValue(0, 0, 0);
124  RealVectorValue viscous_term =
126  RealVectorValue d_viscous_term_d_u_comp =
128  RealVectorValue transient_term =
129  _transient_term ? timeDerivativeTerm() : RealVectorValue(0, 0, 0);
130  RealVectorValue d_transient_term_d_u_comp =
131  _transient_term ? dTimeDerivativeDUComp(comp) : RealVectorValue(0, 0, 0);
132 
133  return -1. / _rho[_qp] * tau() * _grad_test[_i][_qp] *
134  (d_convective_term_d_u_comp + d_viscous_term_d_u_comp + d_transient_term_d_u_comp) -
135  1. / _rho[_qp] * dTauDUComp(comp) * _grad_test[_i][_qp] *
136  (convective_term + viscous_term + transient_term + strongPressureTerm() +
137  gravityTerm() - RealVectorValue(_x_ffn.value(_t, _q_point[_qp]),
138  _y_ffn.value(_t, _q_point[_qp]),
139  _z_ffn.value(_t, _q_point[_qp])));
140 }
virtual RealVectorValue strongViscousTermLaplace()
Definition: INSBase.C:117
InputParameters validParams< INSMass >()
Definition: INSMass.C:12
virtual RealVectorValue dStrongViscDUCompTraction(unsigned comp)
Definition: INSBase.C:141
virtual Real tau()
Definition: INSBase.C:268
virtual Real computeQpOffDiagJacobian(unsigned jvar)
Definition: INSMass.C:88
const MaterialProperty< Real > & _rho
Definition: INSBase.h:103
This class computes strong and weak components of the INS governing equations.
Definition: INSBase.h:22
virtual Real computeQpJacobian()
Definition: INSMass.C:69
virtual Real dTauDUComp(unsigned comp)
Definition: INSBase.C:296
const VariableGradient & _grad_v_vel
Definition: INSBase.h:74
virtual Real computeQpPGResidual()
Definition: INSMass.C:52
unsigned _w_vel_var_number
Definition: INSBase.h:96
virtual RealVectorValue dStrongPressureDPressure()
Definition: INSBase.C:224
bool _pspg
Definition: INSMass.h:39
virtual RealVectorValue timeDerivativeTerm()
Definition: INSBase.C:242
virtual Real computeQpPGJacobian()
Definition: INSMass.C:82
virtual RealVectorValue convectiveTerm()
Definition: INSBase.C:94
bool _convective_term
Definition: INSBase.h:107
const VariableGradient & _grad_u_vel
Definition: INSBase.h:73
INSMass(const InputParameters &parameters)
Definition: INSMass.C:27
virtual RealVectorValue strongPressureTerm()
Definition: INSBase.C:212
bool _transient_term
Definition: INSBase.h:108
Function & _z_ffn
Definition: INSMass.h:42
virtual RealVectorValue dConvecDUComp(unsigned comp)
Definition: INSBase.C:102
InputParameters validParams< INSBase >()
Definition: INSBase.C:13
unsigned _u_vel_var_number
Definition: INSBase.h:94
virtual RealVectorValue dStrongViscDUCompLaplace(unsigned comp)
Definition: INSBase.C:132
const VariableGradient & _grad_w_vel
Definition: INSBase.h:75
bool _laplace
Definition: INSBase.h:106
virtual RealVectorValue gravityTerm()
Definition: INSBase.C:236
virtual RealVectorValue strongViscousTermTraction()
Definition: INSBase.C:124
Function & _x_ffn
Definition: INSMass.h:40
unsigned _v_vel_var_number
Definition: INSBase.h:95
virtual Real computeQpResidual()
Definition: INSMass.C:38
Function & _y_ffn
Definition: INSMass.h:41
virtual Real computeQpPGOffDiagJacobian(unsigned comp)
Definition: INSMass.C:119
virtual RealVectorValue dTimeDerivativeDUComp(unsigned comp)
Definition: INSBase.C:248