www.mooseframework.org
INSChorinCorrector.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 "INSChorinCorrector.h"
11 #include "MooseMesh.h"
12 #include "NS.h"
13 
14 registerMooseObject("NavierStokesApp", INSChorinCorrector);
15 
18 {
20 
21  params.addClassDescription("This class computes the 'Chorin' Corrector equation in "
22  "fully-discrete (both time and space) form.");
23  // Coupled variables
24  params.addRequiredCoupledVar("u_star", "star x-velocity");
25  params.addCoupledVar("v_star", "star y-velocity"); // only required in 2D and 3D
26  params.addCoupledVar("w_star", "star z-velocity"); // 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 Corrector 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  // Current velocities
44  _u_vel_star(coupledValue("u_star")),
45  _v_vel_star(_mesh.dimension() >= 2 ? coupledValue("v_star") : _zero),
46  _w_vel_star(_mesh.dimension() == 3 ? coupledValue("w_star") : _zero),
47 
48  // Pressure gradient
49  _grad_p(coupledGradient(NS::pressure)),
50 
51  // Variable numberings
52  _u_vel_star_var_number(coupled("u_star")),
53  _v_vel_star_var_number(_mesh.dimension() >= 2 ? coupled("v_star") : libMesh::invalid_uint),
54  _w_vel_star_var_number(_mesh.dimension() == 3 ? coupled("w_star") : 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 U_star
70 
71  // The symmetric part
72  Real symmetric_part = (_u[_qp] - U_star(_component)) * _test[_i][_qp];
73 
74  // The pressure part, don't forget to multiply by dt!
75  Real pressure_part = (_dt / _rho[_qp]) * _grad_p[_qp](_component) * _test[_i][_qp];
76 
77  return symmetric_part + pressure_part;
78 }
79 
80 Real
82 {
83  // The on-diagonal Jacobian contribution is just the mass matrix entry.
84  return _phi[_j][_qp] * _test[_i][_qp];
85 }
86 
87 Real
89 {
90  if (((jvar == _u_vel_star_var_number) && (_component == 0)) ||
91  ((jvar == _v_vel_star_var_number) && (_component == 1)) ||
92  ((jvar == _w_vel_star_var_number) && (_component == 2)))
93  {
94  // The symmetric term's Jacobian is only non-zero when the
95  // component of 'u_star' being differentiated is the same as _component.
96  return -_phi[_j][_qp] * _test[_i][_qp];
97  }
98 
99  else if (jvar == _p_var_number)
100  return (_dt / _rho[_qp]) * _grad_phi[_j][_qp](_component) * _test[_i][_qp];
101 
102  else
103  return 0;
104 }
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 VariableValue & _v_vel_star
const VariablePhiGradient & _grad_phi
const VariableGradient & _grad_p
Real & _dt
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
void addRequiredParam(const std::string &name, const std::string &doc_string)
registerMooseObject("NavierStokesApp", INSChorinCorrector)
virtual Real computeQpOffDiagJacobian(unsigned jvar)
const VariableTestValue & _test
INSChorinCorrector(const InputParameters &parameters)
unsigned int _i
void addCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This class computes the "Chorin" Corrector equation in fully-discrete (both time and space) form...
unsigned int _j
virtual Real computeQpJacobian()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const VariableValue & _w_vel_star
virtual Real computeQpResidual()
static const std::string pressure
Definition: NS.h:56
const VariableValue & _u_vel_star
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
const VariablePhiValue & _phi
const VariableValue & _u
unsigned int _qp
const MaterialProperty< Real > & _rho