www.mooseframework.org
INSProjection.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 "INSProjection.h"
9 #include "MooseMesh.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<Kernel>();
16 
17  params.addClassDescription("This class computes the 'projection' part of the 'split' method for "
18  "solving incompressible Navier-Stokes.");
19  // Coupled variables
20  params.addRequiredCoupledVar("a1", "x-acceleration");
21  params.addCoupledVar("a2", "y-acceleration"); // only required in 2D and 3D
22  params.addCoupledVar("a3", "z-acceleration"); // 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 momentum equation");
29 
30  // Optional parameters
31  params.addParam<MaterialPropertyName>("rho_name", "rho", "density name");
32 
33  return params;
34 }
35 
36 INSProjection::INSProjection(const InputParameters & parameters)
37  : Kernel(parameters),
38 
39  // Coupled variables
40  _a1(coupledValue("a1")),
41  _a2(_mesh.dimension() >= 2 ? coupledValue("a2") : _zero),
42  _a3(_mesh.dimension() == 3 ? coupledValue("a3") : _zero),
43 
44  // Gradients
45  _grad_p(coupledGradient("p")),
46 
47  // Variable numberings
48  _a1_var_number(coupled("a1")),
49  _a2_var_number(_mesh.dimension() >= 2 ? coupled("a2") : libMesh::invalid_uint),
50  _a3_var_number(_mesh.dimension() == 3 ? coupled("a3") : 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 a
65  RealVectorValue a(_a1[_qp], _a2[_qp], _a3[_qp]);
66 
67  // Vector object for test function (only the component'th entry is non-zero)
68  RealVectorValue test;
69  test(_component) = _test[_i][_qp];
70 
71  // "Symmetric" part, -a.test
72  Real symmetric_part = -a(_component) * _test[_i][_qp];
73 
74  // The pressure part, (1/_rho[_qp]) * (grad(p).v)
75  Real pressure_part = (1. / _rho[_qp]) * (_grad_p[_qp] * test);
76 
77  // Return the result
78  return symmetric_part + pressure_part;
79 }
80 
81 Real
83 {
84  // There will be a diagonal component from the time derivative term...
85  return 0.;
86 }
87 
88 Real
90 {
91  if (((jvar == _a1_var_number) && (_component == 0)) ||
92  ((jvar == _a2_var_number) && (_component == 1)) ||
93  ((jvar == _a3_var_number) && (_component == 2)))
94  {
95  // The symmetric term's Jacobian is only non-zero when the
96  // component of 'a' being differentiated is the same as _component.
97  return -_phi[_j][_qp] * _test[_i][_qp];
98  }
99 
100  else if (jvar == _p_var_number)
101  {
102  return (1. / _rho[_qp]) * (_grad_phi[_j][_qp](_component) * _test[_i][_qp]);
103  }
104 
105  else
106  return 0;
107 }
INSProjection(const InputParameters &parameters)
Definition: INSProjection.C:36
const VariableValue & _a3
Definition: INSProjection.h:40
unsigned _p_var_number
Definition: INSProjection.h:49
const MaterialProperty< Real > & _rho
Definition: INSProjection.h:55
unsigned _a1_var_number
Definition: INSProjection.h:46
unsigned _a3_var_number
Definition: INSProjection.h:48
virtual Real computeQpOffDiagJacobian(unsigned jvar)
Definition: INSProjection.C:89
unsigned _component
Definition: INSProjection.h:52
const VariableGradient & _grad_p
Definition: INSProjection.h:43
const VariableValue & _a1
Definition: INSProjection.h:38
virtual Real computeQpJacobian()
Definition: INSProjection.C:82
InputParameters validParams< INSProjection >()
Definition: INSProjection.C:13
virtual Real computeQpResidual()
Definition: INSProjection.C:62
unsigned _a2_var_number
Definition: INSProjection.h:47
const VariableValue & _a2
Definition: INSProjection.h:39