https://mooseframework.inl.gov
PressureGradient.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 "PressureGradient.h"
11 #include "NS.h"
12 
13 registerMooseObject("NavierStokesApp", PressureGradient);
14 
17 {
19  params.addRequiredCoupledVar(NS::pressure, "pressure");
20  params.addRequiredParam<unsigned int>("component", "number of component (0 = x, 1 = y, 2 = z)");
21  params.addClassDescription(
22  "Implements the pressure gradient term for one of the Navier Stokes momentum equations.");
23  params.addParam<bool>(
24  "integrate_p_by_parts", true, "Whether to integrate the pressure term by parts");
25 
26  return params;
27 }
28 
30  : Kernel(parameters),
31  _integrate_p_by_parts(getParam<bool>("integrate_p_by_parts")),
32  _component(getParam<unsigned int>("component")),
33  _pressure(coupledValue(NS::pressure)),
34  _grad_pressure(coupledGradient(NS::pressure)),
35  _pressure_id(coupled(NS::pressure)),
36  _coord_sys(_assembly.coordSystem()),
37  _rz_radial_coord(_mesh.getAxisymmetricRadialCoord())
38 {
39 }
40 
41 Real
43 {
45  {
46  auto residual = -_pressure[_qp] * _grad_test[_i][_qp](_component);
48  residual -= _pressure[_qp] / _q_point[_qp](_rz_radial_coord) * _test[_i][_qp];
49  return residual;
50  }
51  else
52  return _test[_i][_qp] * _grad_pressure[_qp](_component);
53 }
54 
55 Real
57 {
58  return 0.;
59 }
60 
61 Real
63 {
64  if (jvar == _pressure_id)
65  {
67  {
68  auto residual = -_phi[_j][_qp] * _grad_test[_i][_qp](_component);
70  residual -= _phi[_j][_qp] / _q_point[_qp](_rz_radial_coord) * _test[_i][_qp];
71  return residual;
72  }
73  else
74  return _test[_i][_qp] * _grad_phi[_j][_qp](_component);
75  }
76  else
77  return 0;
78 }
const bool _integrate_p_by_parts
Whether to integrate the pressure term by parts.
static InputParameters validParams()
const unsigned int _rz_radial_coord
The radial coordinate index for RZ coordinate systems.
registerMooseObject("NavierStokesApp", PressureGradient)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
PressureGradient(const InputParameters &parameters)
const VariablePhiGradient & _grad_phi
const VariableValue & _pressure
The pressure value.
static InputParameters validParams()
const unsigned int _pressure_id
The number of the pressure variable.
void addRequiredParam(const std::string &name, const std::string &doc_string)
virtual Real computeQpResidual() override
const VariableTestValue & _test
unsigned int _i
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
virtual Real computeQpJacobian() override
unsigned int _j
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Adds the pressure gradient term to the Navier-Stokes momentum equation.
const VariableTestGradient & _grad_test
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
static const std::string pressure
Definition: NS.h:56
void addClassDescription(const std::string &doc_string)
const VariablePhiValue & _phi
const VariableGradient & _grad_pressure
The pressure gradient.
void ErrorVector unsigned int
unsigned int _component
The velocity component this object is adding a residual for.
const MooseArray< Point > & _q_point
const Moose::CoordinateSystemType & _coord_sys
The coordinate system.
unsigned int _qp