www.mooseframework.org
INSMomentumBase.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 "INSMomentumBase.h"
8 #include "Function.h"
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<INSBase>();
15 
16  params.addRequiredParam<unsigned>("component", "The velocity component that this is applied to.");
17  params.addParam<bool>(
18  "integrate_p_by_parts", true, "Whether to integrate the pressure term by parts.");
19  params.addParam<bool>(
20  "supg", false, "Whether to perform SUPG stabilization of the momentum residuals");
21  params.addParam<FunctionName>("forcing_func", 0, "The mms forcing function.");
22  return params;
23 }
24 
25 INSMomentumBase::INSMomentumBase(const InputParameters & parameters)
26  : INSBase(parameters),
27  _component(getParam<unsigned>("component")),
28  _integrate_p_by_parts(getParam<bool>("integrate_p_by_parts")),
29  _supg(getParam<bool>("supg")),
30  _ffn(getFunction("forcing_func"))
31 {
32  if (_supg && !_convective_term)
33  mooseError("It doesn't make sense to conduct SUPG stabilization without a convective term.");
34 }
35 
36 Real
38 {
39  Real r = 0;
40 
41  // viscous term
43 
44  // pressure term
46  r += _grad_test[_i][_qp](_component) * weakPressureTerm();
47  else
48  r += _test[_i][_qp] * strongPressureTerm()(_component);
49 
50  // body force term
51  r += _test[_i][_qp] * (gravityTerm()(_component) - _ffn.value(_t, _q_point[_qp]));
52 
53  // convective term
54  if (_convective_term)
55  r += _test[_i][_qp] * convectiveTerm()(_component);
56 
57  if (_supg)
58  r += computeQpPGResidual();
59 
60  return r;
61 }
62 
63 Real
65 {
66  RealVectorValue U(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
67 
68  RealVectorValue convective_term = _convective_term ? convectiveTerm() : RealVectorValue(0, 0, 0);
69  RealVectorValue viscous_term =
71  RealVectorValue transient_term =
72  _transient_term ? timeDerivativeTerm() : RealVectorValue(0, 0, 0);
73 
74  return tau() * U * _grad_test[_i][_qp] *
75  ((convective_term + viscous_term + transient_term + strongPressureTerm() +
76  gravityTerm())(_component)-_ffn.value(_t, _q_point[_qp]));
77 
78  // For GLS as opposed to SUPG stabilization, one would need to modify the test function functional
79  // space to include second derivatives of the Galerkin test functions corresponding to the viscous
80  // term. This would look like:
81  // Real lap_test =
82  // _second_test[_i][_qp](0, 0) + _second_test[_i][_qp](1, 1) + _second_test[_i][_qp](2, 2);
83 
84  // Real pg_viscous_r = -_mu[_qp] * lap_test * tau() *
85  // (convective_term + viscous_term + strongPressureTerm()(_component) +
86  // gravityTerm())(_component);
87 }
88 
89 Real
91 {
92  Real jac = 0;
93 
94  // viscous term
96 
97  // convective term
98  if (_convective_term)
99  jac += _test[_i][_qp] * dConvecDUComp(_component)(_component);
100 
101  if (_supg)
103 
104  return jac;
105 }
106 
107 Real
109 {
110  RealVectorValue U(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
111  RealVectorValue d_U_d_U_comp(0, 0, 0);
112  d_U_d_U_comp(comp) = _phi[_j][_qp];
113 
114  Real convective_term = _convective_term ? convectiveTerm()(_component) : 0;
115  Real d_convective_term_d_u_comp = _convective_term ? dConvecDUComp(comp)(_component) : 0;
116  Real viscous_term =
118  Real d_viscous_term_d_u_comp = _laplace ? dStrongViscDUCompLaplace(comp)(_component)
120  Real transient_term = _transient_term ? timeDerivativeTerm()(_component) : 0;
121  Real d_transient_term_d_u_comp = _transient_term ? dTimeDerivativeDUComp(comp)(_component) : 0;
122 
123  return dTauDUComp(comp) * U * _grad_test[_i][_qp] *
124  (convective_term + viscous_term + strongPressureTerm()(_component) +
125  gravityTerm()(_component) + transient_term - _ffn.value(_t, _q_point[_qp])) +
126  tau() * d_U_d_U_comp * _grad_test[_i][_qp] *
127  (convective_term + viscous_term + strongPressureTerm()(_component) +
128  gravityTerm()(_component) + transient_term - _ffn.value(_t, _q_point[_qp])) +
129  tau() * U * _grad_test[_i][_qp] *
130  (d_convective_term_d_u_comp + d_viscous_term_d_u_comp + d_transient_term_d_u_comp);
131 }
132 
133 Real
135 {
136  Real jac = 0;
137  if (jvar == _u_vel_var_number)
138  {
139  Real convective_term = _convective_term ? _test[_i][_qp] * dConvecDUComp(0)(_component) : 0.;
140  Real viscous_term = computeQpOffDiagJacobianViscousPart(jvar);
141 
142  jac += convective_term + viscous_term;
143 
144  if (_supg)
145  jac += computeQpPGJacobian(0);
146 
147  return jac;
148  }
149  else if (jvar == _v_vel_var_number)
150  {
151  Real convective_term = _convective_term ? _test[_i][_qp] * dConvecDUComp(1)(_component) : 0.;
152  Real viscous_term = computeQpOffDiagJacobianViscousPart(jvar);
153 
154  jac += convective_term + viscous_term;
155 
156  if (_supg)
157  jac += computeQpPGJacobian(1);
158 
159  return jac;
160  }
161  else if (jvar == _w_vel_var_number)
162  {
163  Real convective_term = _convective_term ? _test[_i][_qp] * dConvecDUComp(2)(_component) : 0.;
164  Real viscous_term = computeQpOffDiagJacobianViscousPart(jvar);
165 
166  jac += convective_term + viscous_term;
167 
168  if (_supg)
169  jac += computeQpPGJacobian(2);
170 
171  return jac;
172  }
173 
174  else if (jvar == _p_var_number)
175  {
177  jac += _grad_test[_i][_qp](_component) * dWeakPressureDPressure();
178  else
179  jac += _test[_i][_qp] * dStrongPressureDPressure()(_component);
180 
181  if (_supg)
182  {
183  RealVectorValue U(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
184  jac += tau() * U * _grad_test[_i][_qp] * dStrongPressureDPressure()(_component);
185  }
186 
187  return jac;
188  }
189 
190  else
191  return 0;
192 }
virtual RealVectorValue strongViscousTermLaplace()
Definition: INSBase.C:117
virtual RealVectorValue dStrongViscDUCompTraction(unsigned comp)
Definition: INSBase.C:141
virtual Real computeQpResidualViscousPart()=0
virtual Real tau()
Definition: INSBase.C:268
This class computes strong and weak components of the INS governing equations.
Definition: INSBase.h:22
const VariableValue & _u_vel
Definition: INSBase.h:67
virtual Real computeQpPGResidual()
virtual Real dTauDUComp(unsigned comp)
Definition: INSBase.C:296
virtual Real computeQpResidual()
virtual Real computeQpJacobianViscousPart()=0
InputParameters validParams< INSMomentumBase >()
const VariableValue & _w_vel
Definition: INSBase.h:69
virtual Real computeQpOffDiagJacobianViscousPart(unsigned jvar)=0
virtual Real computeQpJacobian()
unsigned _w_vel_var_number
Definition: INSBase.h:96
virtual RealVectorValue dStrongPressureDPressure()
Definition: INSBase.C:224
virtual RealVectorValue timeDerivativeTerm()
Definition: INSBase.C:242
virtual Real computeQpOffDiagJacobian(unsigned jvar)
virtual RealVectorValue convectiveTerm()
Definition: INSBase.C:94
virtual Real computeQpPGJacobian(unsigned comp)
bool _convective_term
Definition: INSBase.h:107
virtual RealVectorValue strongPressureTerm()
Definition: INSBase.C:212
virtual Real dWeakPressureDPressure()
Definition: INSBase.C:230
bool _transient_term
Definition: INSBase.h:108
INSMomentumBase(const InputParameters &parameters)
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
bool _laplace
Definition: INSBase.h:106
virtual RealVectorValue gravityTerm()
Definition: INSBase.C:236
virtual RealVectorValue strongViscousTermTraction()
Definition: INSBase.C:124
const VariableValue & _v_vel
Definition: INSBase.h:68
unsigned _v_vel_var_number
Definition: INSBase.h:95
unsigned _p_var_number
Definition: INSBase.h:97
virtual Real weakPressureTerm()
Definition: INSBase.C:218
virtual RealVectorValue dTimeDerivativeDUComp(unsigned comp)
Definition: INSBase.C:248