https://mooseframework.inl.gov
Loading...
Searching...
No Matches
INSChorinCorrector.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 "INSChorinCorrector.h"
11#include "MooseMesh.h"
12#include "NS.h"
13
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
65Real
67{
68 // Vector object for U_star
69 RealVectorValue U_star(_u_vel_star[_qp], _v_vel_star[_qp], _w_vel_star[_qp]);
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
80Real
82{
83 // The on-diagonal Jacobian contribution is just the mass matrix entry.
84 return _phi[_j][_qp] * _test[_i][_qp];
85}
86
87Real
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}
registerMooseObject("NavierStokesApp", INSChorinCorrector)
This class computes the "Chorin" Corrector equation in fully-discrete (both time and space) form.
const VariableGradient & _grad_p
virtual Real computeQpResidual()
const MaterialProperty< Real > & _rho
const VariableValue & _u_vel_star
const VariableValue & _w_vel_star
virtual Real computeQpJacobian()
static InputParameters validParams()
virtual Real computeQpOffDiagJacobian(unsigned jvar)
const VariableValue & _v_vel_star
INSChorinCorrector(const InputParameters &parameters)
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
const VariableValue & _u
Real & _dt
static const std::string pressure
Definition NS.h:57
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...