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