https://mooseframework.inl.gov
Loading...
Searching...
No Matches
INSProjection.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 "INSProjection.h"
11#include "MooseMesh.h"
12#include "NS.h"
13
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
65Real
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
85Real
87{
88 // There will be a diagonal component from the time derivative term...
89 return 0.;
90}
91
92Real
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}
registerMooseObject("NavierStokesApp", INSProjection)
This class computes the "projection" part of the "split" method for solving incompressible Navier-Sto...
const VariableGradient & _grad_p
unsigned _component
unsigned _a3_var_number
virtual Real computeQpJacobian()
unsigned _a1_var_number
const MaterialProperty< Real > & _rho
const VariableValue & _a2
virtual Real computeQpOffDiagJacobian(unsigned jvar)
unsigned _a2_var_number
const VariableValue & _a3
INSProjection(const InputParameters &parameters)
unsigned _p_var_number
static InputParameters validParams()
const VariableValue & _a1
virtual Real computeQpResidual()
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
unsigned int _qp
unsigned int _j
unsigned int _i
const VariablePhiValue & _phi
const VariableTestValue & _test
static InputParameters validParams()
const VariablePhiGradient & _grad_phi
static const std::string pressure
Definition NS.h:57
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...