https://mooseframework.inl.gov
Loading...
Searching...
No Matches
INSMomentumBase.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 "INSMomentumBase.h"
11#include "Function.h"
12
15{
17
18 params.addRequiredParam<unsigned>("component", "The velocity component that this is applied to.");
19 params.addParam<bool>(
20 "integrate_p_by_parts", true, "Whether to integrate the pressure term by parts.");
21 params.addParam<bool>(
22 "supg", false, "Whether to perform SUPG stabilization of the momentum residuals");
23 params.addParam<FunctionName>("forcing_func", 0, "The mms forcing function.");
24 return params;
25}
26
28 : INSBase(parameters),
29 _component(getParam<unsigned>("component")),
30 _integrate_p_by_parts(getParam<bool>("integrate_p_by_parts")),
31 _supg(getParam<bool>("supg")),
32 _ffn(getFunction("forcing_func"))
33{
34 if (_supg && !_convective_term)
35 mooseError("It doesn't make sense to conduct SUPG stabilization without a convective term.");
36}
37
38Real
40{
41 Real r = 0;
42
43 // viscous term
45
46 // pressure term
49 else
51
52 // body force term
54
55 // convective term
58
59 if (_supg)
61
62 return r;
63}
64
65Real
67{
68 const auto U = relativeVelocity();
69
70 const auto convective_term = _convective_term ? convectiveTerm() : RealVectorValue(0, 0, 0);
71 const auto viscous_term = _laplace ? strongViscousTermLaplace() : strongViscousTermTraction();
72 const auto transient_term = _transient_term ? timeDerivativeTerm() : RealVectorValue(0, 0, 0);
73
74 return tau() * U * _grad_test[_i][_qp] *
75 ((convective_term + viscous_term + transient_term + strongPressureTerm() +
77
78 // For GLS as opposed to SUPG stabilization, one would need to modify the test function functional
79 // space to include second derivatives of the Galerkin test functions corresponding to the viscous
80 // term. This would look like:
81 // Real lap_test =
82 // _second_test[_i][_qp](0, 0) + _second_test[_i][_qp](1, 1) + _second_test[_i][_qp](2, 2);
83
84 // Real pg_viscous_r = -_mu[_qp] * lap_test * tau() *
85 // (convective_term + viscous_term + strongPressureTerm()(_component) +
86 // gravityTerm())(_component);
87}
88
89Real
91{
92 Real jac = 0;
93
94 // viscous term
96
97 // convective term
100
101 if (_supg)
103
104 return jac;
105}
106
107Real
109{
110 const auto U = relativeVelocity();
111 RealVectorValue d_U_d_U_comp(0, 0, 0);
112 d_U_d_U_comp(comp) = _phi[_j][_qp];
113
114 const Real convective_term = _convective_term ? convectiveTerm()(_component) : 0;
115 const Real d_convective_term_d_u_comp = _convective_term ? dConvecDUComp(comp)(_component) : 0;
116 const Real viscous_term =
118 const Real d_viscous_term_d_u_comp = _laplace ? dStrongViscDUCompLaplace(comp)(_component)
120 const Real transient_term = _transient_term ? timeDerivativeTerm()(_component) : 0;
121 const Real d_transient_term_d_u_comp =
123
124 return dTauDUComp(comp) * U * _grad_test[_i][_qp] *
125 (convective_term + viscous_term + strongPressureTerm()(_component) +
126 gravityTerm()(_component) + transient_term - _ffn.value(_t, _q_point[_qp])) +
127 tau() * d_U_d_U_comp * _grad_test[_i][_qp] *
128 (convective_term + viscous_term + strongPressureTerm()(_component) +
129 gravityTerm()(_component) + transient_term - _ffn.value(_t, _q_point[_qp])) +
130 tau() * U * _grad_test[_i][_qp] *
131 (d_convective_term_d_u_comp + d_viscous_term_d_u_comp + d_transient_term_d_u_comp);
132}
133
134Real
136{
137 Real jac = 0;
138 if (jvar == _u_vel_var_number)
139 {
140 Real convective_term = _convective_term ? _test[_i][_qp] * dConvecDUComp(0)(_component) : 0.;
141 Real viscous_term = computeQpOffDiagJacobianViscousPart(jvar);
142
143 jac += convective_term + viscous_term;
144
145 if (_supg)
146 jac += computeQpPGJacobian(0);
147
148 return jac;
149 }
150 else if (jvar == _v_vel_var_number)
151 {
152 Real convective_term = _convective_term ? _test[_i][_qp] * dConvecDUComp(1)(_component) : 0.;
153 Real viscous_term = computeQpOffDiagJacobianViscousPart(jvar);
154
155 jac += convective_term + viscous_term;
156
157 if (_supg)
158 jac += computeQpPGJacobian(1);
159
160 return jac;
161 }
162 else if (jvar == _w_vel_var_number)
163 {
164 Real convective_term = _convective_term ? _test[_i][_qp] * dConvecDUComp(2)(_component) : 0.;
165 Real viscous_term = computeQpOffDiagJacobianViscousPart(jvar);
166
167 jac += convective_term + viscous_term;
168
169 if (_supg)
170 jac += computeQpPGJacobian(2);
171
172 return jac;
173 }
174
175 else if (jvar == _p_var_number)
176 {
179 else
181
182 if (_supg)
183 {
184 const auto U = relativeVelocity();
186 }
187
188 return jac;
189 }
190
191 else
192 return 0;
193}
virtual Real value(Real t, const Point &p) const
This class computes strong and weak components of the INS governing equations.
Definition INSBase.h:19
virtual RealVectorValue gravityTerm()
Definition INSBase.C:289
virtual Real dWeakPressureDPressure()
Definition INSBase.C:283
virtual Real tau()
Definition INSBase.C:321
virtual RealVectorValue dStrongPressureDPressure()
Definition INSBase.C:277
virtual RealVectorValue dTimeDerivativeDUComp(unsigned comp)
Definition INSBase.C:301
virtual RealVectorValue timeDerivativeTerm()
Definition INSBase.C:295
virtual RealVectorValue strongPressureTerm()
Definition INSBase.C:265
unsigned _w_vel_var_number
Definition INSBase.h:127
static InputParameters validParams()
Definition INSBase.C:15
virtual RealVectorValue dStrongViscDUCompLaplace(unsigned comp)
Definition INSBase.C:185
bool _laplace
Definition INSBase.h:137
virtual RealVectorValue strongViscousTermTraction()
Definition INSBase.C:177
virtual RealVectorValue dStrongViscDUCompTraction(unsigned comp)
Definition INSBase.C:194
unsigned _p_var_number
Definition INSBase.h:128
virtual Real dTauDUComp(unsigned comp)
Definition INSBase.C:349
bool _transient_term
Definition INSBase.h:139
virtual Real weakPressureTerm()
Definition INSBase.C:271
bool _convective_term
Definition INSBase.h:138
virtual RealVectorValue dConvecDUComp(unsigned comp)
Definition INSBase.C:143
unsigned _v_vel_var_number
Definition INSBase.h:126
virtual RealVectorValue convectiveTerm()
Definition INSBase.C:132
virtual RealVectorValue strongViscousTermLaplace()
Definition INSBase.C:170
unsigned _u_vel_var_number
Definition INSBase.h:125
RealVectorValue relativeVelocity() const
Compute the velocity.
Definition INSBase.C:120
virtual Real computeQpOffDiagJacobianViscousPart(unsigned jvar)=0
virtual Real computeQpPGResidual()
virtual Real computeQpJacobian()
static InputParameters validParams()
INSMomentumBase(const InputParameters &parameters)
virtual Real computeQpResidual()
virtual Real computeQpPGJacobian(unsigned comp)
const Function & _ffn
virtual Real computeQpResidualViscousPart()=0
virtual Real computeQpJacobianViscousPart()=0
virtual Real computeQpOffDiagJacobian(unsigned jvar)
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)
unsigned int _qp
const MooseArray< Point > & _q_point
unsigned int _j
unsigned int _i
const VariablePhiValue & _phi
const VariableTestValue & _test
const VariableTestGradient & _grad_test
void mooseError(Args &&... args) const
Real & _t