pEqn.H
Go to the documentation of this file.
1surfaceScalarField alphaf1("alphaf1", fvc::interpolate(alpha1));
2surfaceScalarField alphaf2("alphaf2", scalar(1) - alphaf1);
3
4surfaceScalarField alphaRhof10
5(
6 "alphaRhof10",
7 fvc::interpolate
8 (
9 max(alpha1.oldTime(), phase1.residualAlpha())
10 *rho1.oldTime()
11 )
12);
13
14surfaceScalarField alphaRhof20
15(
16 "alphaRhof20",
17 fvc::interpolate
18 (
19 max(alpha2.oldTime(), phase2.residualAlpha())
20 *rho2.oldTime()
21 )
22);
23
24// Drag coefficient
25const surfaceScalarField Kdf("Kdf", fluid.Kdf());
26
27// Diagonal coefficients
28PtrList<surfaceScalarField> AFfs(fluid.AFfs());
29
30PtrList<surfaceScalarField> rAUfs;
31rAUfs.append
32(
33 new surfaceScalarField
34 (
35 IOobject::groupName("rAUf", phase1.name()),
36 1.0
37 /(
38 byDt(alphaRhof10)
39 + fvc::interpolate(U1Eqn.A())
40 + AFfs[0]
41 )
42 )
43);
44rAUfs.append
45(
46 new surfaceScalarField
47 (
48 IOobject::groupName("rAUf", phase2.name()),
49 1.0
50 /(
51 byDt(alphaRhof20)
52 + fvc::interpolate(U2Eqn.A())
53 + AFfs[0]
54 )
55 )
56);
57const surfaceScalarField& rAUf1 = rAUfs[0];
58const surfaceScalarField& rAUf2 = rAUfs[1];
59
60AFfs.clear();
61
62// Explicit force fluxes
63PtrList<surfaceScalarField> phiFfs(fluid.phiFfs(rAUfs));
64const surfaceScalarField& phiFf1 = phiFfs[0];
65const surfaceScalarField& phiFf2 = phiFfs[1];
66
67
68while (pimple.correct())
69{
70 volScalarField rho("rho", fluid.rho());
71
72 // Correct p_rgh for consistency with p and the updated densities
73 p_rgh = p - rho*gh;
74
75 surfaceScalarField rhof1(fvc::interpolate(rho1));
76 surfaceScalarField rhof2(fvc::interpolate(rho2));
77
78 // Correct fixed-flux BCs to be consistent with the velocity BCs
79 MRF.correctBoundaryFlux(U1, phi1);
80 MRF.correctBoundaryFlux(U2, phi2);
81
82 const surfaceScalarField alpharAUf1
83 (
84 IOobject::groupName("alpharAUf", phase1.name()),
85 max(alphaf1, phase1.residualAlpha())*rAUf1
86 );
87
88 const surfaceScalarField alpharAUf2
89 (
90 IOobject::groupName("alpharAUf", phase2.name()),
91 max(alphaf2, phase2.residualAlpha())*rAUf2
92 );
93
94 // Combined buoyancy and force fluxes
95 const surfaceScalarField ghSnGradRho
96 (
97 "ghSnGradRho",
98 ghf*fvc::snGrad(rho)*mesh.magSf()
99 );
100
101 const surfaceScalarField phigF1
102 (
104 *(
106 - alphaf2*(rhof1 - rhof2)*(g & mesh.Sf())
107 )
108 + phiFf1
109 );
110
111 const surfaceScalarField phigF2
112 (
114 *(
116 - alphaf1*(rhof2 - rhof1)*(g & mesh.Sf())
117 )
118 + phiFf2
119 );
120
121
122 // Predicted fluxes
123 surfaceScalarField phiHbyA1
124 (
125 IOobject::groupName("phiHbyA", phase1.name()),
126 phi1
127 );
128
129 phiHbyA1 =
130 rAUf1
131 *(
132 alphaRhof10*byDt(MRF.absolute(phi1.oldTime()))
133 + fvc::flux(U1Eqn.H())
134 )
135 - phigF1;
136
137 surfaceScalarField phiHbyA2
138 (
139 IOobject::groupName("phiHbyA", phase2.name()),
140 phi2
141 );
142
143 phiHbyA2 =
144 rAUf2
145 *(
146 alphaRhof20*byDt(MRF.absolute(phi2.oldTime()))
147 + fvc::flux(U2Eqn.H())
148 )
149 - phigF2;
150
151 // Drag fluxes
152 PtrList<surfaceScalarField> phiKdPhifs(fluid.phiKdPhifs(rAUfs));
153 const surfaceScalarField& phiKdPhif1 = phiKdPhifs[0];
154 const surfaceScalarField& phiKdPhif2 = phiKdPhifs[1];
155
156 // Total predicted flux
157 surfaceScalarField phiHbyA
158 (
159 "phiHbyA",
160 alphaf1*(phiHbyA1 - phiKdPhif1) + alphaf2*(phiHbyA2 - phiKdPhif2)
161 );
162 MRF.makeRelative(phiHbyA);
163
164 phiKdPhifs.clear();
165
166 // Construct pressure "diffusivity"
167 const surfaceScalarField rAUf
168 (
169 "rAUf",
171 );
172
173
174 // Update the fixedFluxPressure BCs to ensure flux consistency
176 (
177 p_rgh.boundaryFieldRef(),
178 (
179 phiHbyA.boundaryField()
180 - (
181 alphaf1.boundaryField()*phi1.boundaryField()
182 + alphaf2.boundaryField()*phi2.boundaryField()
183 )
184 )/(mesh.magSf().boundaryField()*rAUf.boundaryField())
185 );
186
187 // Construct the compressibility parts of the pressure equation
188 tmp<fvScalarMatrix> pEqnComp1, pEqnComp2;
189
190 if (phase1.compressible())
191 {
192 if (pimple.transonic())
193 {
194 surfaceScalarField phid1
195 (
196 IOobject::groupName("phid", phase1.name()),
197 fvc::interpolate(psi1)*phi1
198 );
199
200 pEqnComp1 =
201 (
202 fvc::ddt(alpha1, rho1) + fvc::div(phase1.alphaRhoPhi())
203 - fvc::Sp(fvc::ddt(alpha1) + fvc::div(alphaPhi1), rho1)
204 )/rho1
205 + correction
206 (
207 (alpha1/rho1)*
208 (
209 psi1*fvm::ddt(p_rgh)
210 + fvm::div(phid1, p_rgh) - fvm::Sp(fvc::div(phid1), p_rgh)
211 )
212 );
213
214 pEqnComp1.ref().relax();
215 }
216 else
217 {
218 pEqnComp1 =
219 (
220 fvc::ddt(alpha1, rho1) + fvc::div(phase1.alphaRhoPhi())
221 - fvc::Sp(fvc::ddt(alpha1) + fvc::div(alphaPhi1), rho1)
222 )/rho1
223 + (alpha1*psi1/rho1)*correction(fvm::ddt(p_rgh));
224 }
225 }
226
227 if (phase2.compressible())
228 {
229 if (pimple.transonic())
230 {
231 surfaceScalarField phid2
232 (
233 IOobject::groupName("phid", phase2.name()),
234 fvc::interpolate(psi2)*phi2
235 );
236
237 pEqnComp2 =
238 (
239 fvc::ddt(alpha2, rho2) + fvc::div(phase2.alphaRhoPhi())
240 - fvc::Sp(fvc::ddt(alpha2) + fvc::div(alphaPhi2), rho2)
241 )/rho2
242 + correction
243 (
244 (alpha2/rho2)*
245 (
246 psi2*fvm::ddt(p_rgh)
247 + fvm::div(phid2, p_rgh) - fvm::Sp(fvc::div(phid2), p_rgh)
248 )
249 );
250
251 pEqnComp2.ref().relax();
252 }
253 else
254 {
255 pEqnComp2 =
256 (
257 fvc::ddt(alpha2, rho2) + fvc::div(phase2.alphaRhoPhi())
258 - fvc::Sp(fvc::ddt(alpha2) + fvc::div(alphaPhi2), rho2)
259 )/rho2
260 + (alpha2*psi2/rho2)*correction(fvm::ddt(p_rgh));
261 }
262 }
263
264 // Add option sources
265 {
266 if (fvOptions.appliesToField(rho1.name()))
267 {
268 tmp<fvScalarMatrix> optEqn1 = fvOptions(alpha1, rho1);
269 if (pEqnComp1.valid())
270 {
271 pEqnComp1.ref() -= (optEqn1 & rho1)/rho1;
272 }
273 else
274 {
275 pEqnComp1 = fvm::Su(- (optEqn1 & rho1)/rho1, p_rgh);
276 }
277 }
278 if (fvOptions.appliesToField(rho2.name()))
279 {
280 tmp<fvScalarMatrix> optEqn2 = fvOptions(alpha2, rho2);
281 if (pEqnComp2.valid())
282 {
283 pEqnComp2.ref() -= (optEqn2 & rho2)/rho2;
284 }
285 else
286 {
287 pEqnComp2 = fvm::Su(- (optEqn2 & rho2)/rho2, p_rgh);
288 }
289 }
290 }
291
292
293 // Add mass transfer
294 {
295 PtrList<volScalarField> dmdts(fluid.dmdts());
296 if (dmdts.set(0))
297 {
298 if (pEqnComp1.valid())
299 {
300 pEqnComp1.ref() -= dmdts[0]/rho1;
301 }
302 else
303 {
304 pEqnComp1 = fvm::Su(- dmdts[0]/rho1, p_rgh);
305 }
306 }
307 if (dmdts.set(1))
308 {
309 if (pEqnComp2.valid())
310 {
311 pEqnComp2.ref() -= dmdts[1]/rho2;
312 }
313 else
314 {
315 pEqnComp2 = fvm::Su(- dmdts[1]/rho2, p_rgh);
316 }
317 }
318 }
319
320 // Cache p prior to solve for density update
321 volScalarField p_rgh_0("p_rgh_0", p_rgh);
322
323 while (pimple.correctNonOrthogonal())
324 {
325 fvScalarMatrix pEqnIncomp
326 (
327 fvc::div(phiHbyA)
328 - fvm::laplacian(rAUf, p_rgh)
329 );
330
331 {
332 fvScalarMatrix pEqn(pEqnIncomp);
333
334 if (pEqnComp1.valid())
335 {
336 pEqn += pEqnComp1();
337 }
338
339 if (pEqnComp2.valid())
340 {
341 pEqn += pEqnComp2();
342 }
343
344 solve
345 (
346 pEqn,
347 mesh.solver(p_rgh.select(pimple.finalInnerIter()))
348 );
349 }
350
351 if (pimple.finalNonOrthogonalIter())
352 {
353 surfaceScalarField mSfGradp("mSfGradp", pEqnIncomp.flux()/rAUf);
354
355 phi = phiHbyA + pEqnIncomp.flux();
356
357 const surfaceScalarField phi1s
358 (
359 phiHbyA1 + alpharAUf1*mSfGradp
360 );
361
362 const surfaceScalarField phi2s
363 (
364 phiHbyA2 + alpharAUf2*mSfGradp
365 );
366
367 surfaceScalarField phir
368 (
369 ((phi2s + rAUf2*Kdf*phi1s) - (phi1s + rAUf1*Kdf*phi2s))
370 /(1.0 - rAUf1*rAUf2*sqr(Kdf))
371 );
372
373 phi1 = phi - alphaf2*phir;
374 phi2 = phi + alphaf1*phir;
375
376 U1 = fvc::reconstruct(MRF.absolute(phi1));
377 U1.correctBoundaryConditions();
378 fvOptions.correct(U1);
379
380 U2 = fvc::reconstruct(MRF.absolute(phi2));
381 U2.correctBoundaryConditions();
382 fvOptions.correct(U2);
383
384 // Set the phase dilatation rates
385 if (pEqnComp1.valid())
386 {
387 phase1.divU(-pEqnComp1 & p_rgh);
388 }
389 if (pEqnComp2.valid())
390 {
391 phase2.divU(-pEqnComp2 & p_rgh);
392 }
393 }
394 }
395
396 // Update and limit the static pressure
397 p = max(p_rgh + rho*gh, pMin);
398
399 // Limit p_rgh
400 p_rgh = p - rho*gh;
401
402 // Update densities from change in p_rgh
403 rho1 += psi1*(p_rgh - p_rgh_0);
404 rho2 += psi2*(p_rgh - p_rgh_0);
405
406 // Correct p_rgh for consistency with p and the updated densities
407 rho = fluid.rho();
408 p_rgh = p - rho*gh;
409 p_rgh.correctBoundaryConditions();
410}
Y[inertIndex] max(0.0)
const uniformDimensionedVectorField & g
volScalarField & p_rgh
fv::options & fvOptions
surfaceScalarField & phi
const surfaceScalarField & ghf
IOMRFZoneList & MRF
const volScalarField & gh
pimpleControl & pimple
const volScalarField & alpha1
const volScalarField & psi2
surfaceScalarField & phi2
twoPhaseSystem & fluid
phaseModel & phase1
volScalarField & rho2
const volScalarField & alpha2
const surfaceScalarField & alphaPhi1
surfaceScalarField & phi1
phaseModel & phase2
const volScalarField & psi1
volVectorField & U1
const dimensionedScalar & pMin
volScalarField & rho1
volVectorField & U2
const surfaceScalarField & alphaPhi2
volScalarField & p
phiHbyA
Definition: pcEqn.H:73
dynamicFvMesh & mesh
surfaceScalarField phir(fvc::flux(UdmModel.Udm()))
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU))
volScalarField p_rgh_0(p_rgh)
surfaceScalarField ghSnGradRho(ghf *fvc::snGrad(rho) *mesh.magSf())
setSnGrad< fixedFluxPressureFvPatchScalarField >(p_rgh.boundaryFieldRef(),(phiHbyA.boundaryField() - MRF.relative(phib))/(mesh.magSf().boundaryField() *rAUf.boundaryField()))
PtrList< surfaceScalarField > phiFfs(fluid.phiFfs(rAUfs))
const surfaceScalarField alphaf2("alphaf2", scalar(1) - alphaf1)
const surfaceScalarField alpharAUf1(fvc::interpolate(max(alpha1, phase1.residualAlpha()) *rAU1))
const surfaceScalarField alpharAUf2(fvc::interpolate(max(alpha2, phase2.residualAlpha()) *rAU2))
const surfaceScalarField alphaf1("alphaf1", fvc::interpolate(alpha1))
const surfaceScalarField & rAUf1
Definition: pEqn.H:57
const surfaceScalarField & rAUf2
Definition: pEqn.H:58
surfaceScalarField alphaRhof20("alphaRhof20", fvc::interpolate(max(alpha2.oldTime(), phase2.residualAlpha()) *rho2.oldTime()))
surfaceScalarField alphaRhof10("alphaRhof10", fvc::interpolate(max(alpha1.oldTime(), phase1.residualAlpha()) *rho1.oldTime()))
const surfaceScalarField Kdf("Kdf", fluid.Kdf())
const surfaceScalarField & phiFf2
Definition: pEqn.H:65
PtrList< surfaceScalarField > rAUfs
Definition: pEqn.H:30
const surfaceScalarField & phiFf1
Definition: pEqn.H:64
PtrList< surfaceScalarField > AFfs(fluid.AFfs())
CEqn solve()