-
Notifications
You must be signed in to change notification settings - Fork 588
/
pEqn.H
174 lines (137 loc) · 3.78 KB
/
pEqn.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
rho = thermo.rho();
rho.relax();
// Thermodynamic density needs to be updated by psi*d(p) after the
// pressure solution
const volScalarField psip0(psi*p);
const volScalarField rAU("rAU", 1.0/UEqn.A());
const surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_rgh));
if (pimple.nCorrPiso() <= 1)
{
tUEqn.clear();
}
surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::interpolate(rho)*fvc::flux(HbyA)
+ MRF.zeroFilter(rhorAUf*fvc::ddtCorr(rho, U, phi, rhoUf))
);
MRF.makeRelative(fvc::interpolate(rho), phiHbyA);
bool adjustMass = mesh.schemes().steady() && adjustPhi(phiHbyA, U, p_rgh);
const surfaceScalarField phig(-rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf());
phiHbyA += phig;
// Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, rho, U, phiHbyA, rhorAUf, MRF);
fvc::makeRelative(phiHbyA, rho, U);
fvScalarMatrix p_rghEqn(p_rgh, dimMass/dimTime);
if (pimple.transonic())
{
const surfaceScalarField phid
(
"phid",
(fvc::interpolate(psi)/fvc::interpolate(rho))*phiHbyA
);
const fvScalarMatrix divPhidp(fvm::div(phid, p));
phiHbyA -= divPhidp.flux();
fvScalarMatrix p_rghDDtEqn
(
fvc::ddt(rho) + psi*correction(fvm::ddt(p_rgh))
+ fvc::div(phiHbyA) + divPhidp
==
fvModels.source(psi, p_rgh, rho.name())
);
while (pimple.correctNonOrthogonal())
{
p_rghEqn = p_rghDDtEqn - fvm::laplacian(rhorAUf, p_rgh);
// Relax the pressure equation to ensure diagonal-dominance
p_rghEqn.relax();
p_rghEqn.setReference
(
pressureReference.refCell(),
pressureReference.refValue()
);
p_rghEqn.solve();
}
}
else
{
fvScalarMatrix p_rghDDtEqn
(
fvc::ddt(rho) + psi*correction(fvm::ddt(p_rgh))
+ fvc::div(phiHbyA)
==
fvModels.source(psi, p_rgh, rho.name())
);
while (pimple.correctNonOrthogonal())
{
p_rghEqn = p_rghDDtEqn - fvm::laplacian(rhorAUf, p_rgh);
p_rghEqn.setReference
(
pressureReference.refCell(),
pressureReference.refValue()
);
p_rghEqn.solve();
}
}
phi = phiHbyA + p_rghEqn.flux();
if (mesh.schemes().steady())
{
#include "incompressible/continuityErrs.H"
}
else
{
p = p_rgh + rho*gh + pRef;
const bool constrained = fvConstraints.constrain(p);
// Thermodynamic density update
thermo.correctRho(psi*p - psip0);
if (constrained)
{
rho = thermo.rho();
}
#include "rhoEqn.H"
#include "compressibleContinuityErrs.H"
}
// Explicitly relax pressure for momentum corrector
p_rgh.relax();
p = p_rgh + rho*gh + pRef;
// Correct the momentum source with the pressure gradient flux
// calculated from the relaxed pressure
U = HbyA + rAU*fvc::reconstruct((phig + p_rghEqn.flux())/rhorAUf);
U.correctBoundaryConditions();
fvConstraints.constrain(U);
K = 0.5*magSqr(U);
if (mesh.schemes().steady())
{
if (fvConstraints.constrain(p))
{
p_rgh = p - rho*gh - pRef;
p_rgh.correctBoundaryConditions();
}
}
// For steady closed-volume compressible cases adjust the pressure level
// to obey overall mass continuity
if (adjustMass && !thermo.incompressible())
{
p += (initialMass - fvc::domainIntegrate(thermo.rho()))
/fvc::domainIntegrate(psi);
p_rgh = p - rho*gh - pRef;
p_rgh.correctBoundaryConditions();
}
if (mesh.schemes().steady() || pimple.simpleRho() || adjustMass)
{
rho = thermo.rho();
}
if (mesh.schemes().steady() || pimple.simpleRho())
{
rho.relax();
}
// Correct rhoUf if the mesh is moving
fvc::correctRhoUf(rhoUf, rho, U, phi);
if (thermo.dpdt())
{
dpdt = fvc::ddt(p);
if (mesh.moving())
{
dpdt -= fvc::div(fvc::meshPhi(rho, U), p);
}
}