www.mooseframework.org
INSChorinCorrector.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 
8 #include "INSChorinCorrector.h"
9 #include "MooseMesh.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<Kernel>();
16 
17  params.addClassDescription("This class computes the 'Chorin' Corrector equation in "
18  "fully-discrete (both time and space) form.");
19  // Coupled variables
20  params.addRequiredCoupledVar("u_star", "star x-velocity");
21  params.addCoupledVar("v_star", "star y-velocity"); // only required in 2D and 3D
22  params.addCoupledVar("w_star", "star z-velocity"); // only required in 3D
23  params.addRequiredCoupledVar("p", "pressure");
24 
25  // Required parameters
26  params.addRequiredParam<unsigned>(
27  "component",
28  "0,1,2 depending on if we are solving the x,y,z component of the Corrector equation");
29 
30  // Optional parameters
31  params.addParam<MaterialPropertyName>("rho_name", "rho", "density name");
32 
33  return params;
34 }
35 
36 INSChorinCorrector::INSChorinCorrector(const InputParameters & parameters)
37  : Kernel(parameters),
38 
39  // Current velocities
40  _u_vel_star(coupledValue("u_star")),
41  _v_vel_star(_mesh.dimension() >= 2 ? coupledValue("v_star") : _zero),
42  _w_vel_star(_mesh.dimension() == 3 ? coupledValue("w_star") : _zero),
43 
44  // Pressure gradient
45  _grad_p(coupledGradient("p")),
46 
47  // Variable numberings
48  _u_vel_star_var_number(coupled("u_star")),
49  _v_vel_star_var_number(_mesh.dimension() >= 2 ? coupled("v_star") : libMesh::invalid_uint),
50  _w_vel_star_var_number(_mesh.dimension() == 3 ? coupled("w_star") : libMesh::invalid_uint),
51  _p_var_number(coupled("p")),
52 
53  // Required parameters
54  _component(getParam<unsigned>("component")),
55 
56  // Material properties
57  _rho(getMaterialProperty<Real>("rho_name"))
58 {
59 }
60 
61 Real
63 {
64  // Vector object for U_star
65  RealVectorValue U_star(_u_vel_star[_qp], _v_vel_star[_qp], _w_vel_star[_qp]);
66 
67  // The symmetric part
68  Real symmetric_part = (_u[_qp] - U_star(_component)) * _test[_i][_qp];
69 
70  // The pressure part, don't forget to multiply by dt!
71  Real pressure_part = (_dt / _rho[_qp]) * _grad_p[_qp](_component) * _test[_i][_qp];
72 
73  return symmetric_part + pressure_part;
74 }
75 
76 Real
78 {
79  // The on-diagonal Jacobian contribution is just the mass matrix entry.
80  return _phi[_j][_qp] * _test[_i][_qp];
81 }
82 
83 Real
85 {
86  if (((jvar == _u_vel_star_var_number) && (_component == 0)) ||
87  ((jvar == _v_vel_star_var_number) && (_component == 1)) ||
88  ((jvar == _w_vel_star_var_number) && (_component == 2)))
89  {
90  // The symmetric term's Jacobian is only non-zero when the
91  // component of 'u_star' being differentiated is the same as _component.
92  return -_phi[_j][_qp] * _test[_i][_qp];
93  }
94 
95  else if (jvar == _p_var_number)
96  return (_dt / _rho[_qp]) * _grad_phi[_j][_qp](_component) * _test[_i][_qp];
97 
98  else
99  return 0;
100 }
const VariableValue & _v_vel_star
const VariableGradient & _grad_p
InputParameters validParams< INSChorinCorrector >()
virtual Real computeQpOffDiagJacobian(unsigned jvar)
INSChorinCorrector(const InputParameters &parameters)
virtual Real computeQpJacobian()
const VariableValue & _w_vel_star
virtual Real computeQpResidual()
const VariableValue & _u_vel_star
const MaterialProperty< Real > & _rho