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 #include "NS.h"
13 
14 registerMooseObject("NavierStokesApp", INSProjection);
15 
18 {
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(NS::pressure, "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 
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(NS::pressure)),
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(NS::pressure)),
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
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(const InputParameters &parameters)
Definition: INSProjection.C:40
const VariableValue & _a3
Definition: INSProjection.h:40
registerMooseObject("NavierStokesApp", INSProjection)
static InputParameters validParams()
const unsigned int invalid_uint
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const VariablePhiGradient & _grad_phi
unsigned _p_var_number
Definition: INSProjection.h:49
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
const MaterialProperty< Real > & _rho
Definition: INSProjection.h:55
void addRequiredParam(const std::string &name, const std::string &doc_string)
unsigned _a1_var_number
Definition: INSProjection.h:46
const VariableTestValue & _test
unsigned _a3_var_number
Definition: INSProjection.h:48
virtual Real computeQpOffDiagJacobian(unsigned jvar)
Definition: INSProjection.C:93
unsigned _component
Definition: INSProjection.h:52
unsigned int _i
const VariableGradient & _grad_p
Definition: INSProjection.h:43
void addCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
unsigned int _j
const VariableValue & _a1
Definition: INSProjection.h:38
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string pressure
Definition: NS.h:56
virtual Real computeQpJacobian()
Definition: INSProjection.C:86
This class computes the "projection" part of the "split" method for solving incompressible Navier-Sto...
Definition: INSProjection.h:23
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
Definition: INSProjection.C:17
const VariablePhiValue & _phi
virtual Real computeQpResidual()
Definition: INSProjection.C:66
unsigned _a2_var_number
Definition: INSProjection.h:47
unsigned int _qp
const VariableValue & _a2
Definition: INSProjection.h:39