pEqn.H
Go to the documentation of this file.
2 surfaceScalarField alphaf2("alphaf2", scalar(1) - alphaf1);
3 
5 (
6  IOobject::groupName("rAU", phase1.name()),
7  1.0
8  /(
9  U1Eqn.A()
10  + byDt(max(phase1.residualAlpha() - alpha1, scalar(0))*rho1)
11  )
12 );
14 (
15  IOobject::groupName("rAU", phase2.name()),
16  1.0
17  /(
18  U2Eqn.A()
19  + byDt(max(phase2.residualAlpha() - alpha2, scalar(0))*rho2)
20  )
21 );
22 
24 (
25  fvc::interpolate(max(alpha1, phase1.residualAlpha())*rAU1)
26 );
28 (
29  fvc::interpolate(max(alpha2, phase2.residualAlpha())*rAU2)
30 );
31 
32 volScalarField Kd(fluid.Kd());
33 
34 // Turbulent diffusion, particle-pressure, lift and wall-lubrication fluxes
35 tmp<surfaceScalarField> phiF1;
36 tmp<surfaceScalarField> phiF2;
37 {
38  // Turbulent-dispersion diffusivity
39  volScalarField D(fluid.D());
40 
41  // Phase-1 turbulent dispersion and particle-pressure flux
42  tmp<surfaceScalarField> DbyA1
43  (
45  (
46  rAU1*(D + phase1.turbulence().pPrime())
47  )
48  );
49 
50  // Phase-2 turbulent dispersion and particle-pressure flux
51  tmp<surfaceScalarField> DbyA2
52  (
54  (
55  rAU2*(D + phase2.turbulence().pPrime())
56  )
57  );
58 
59  // Lift and wall-lubrication forces
60  volVectorField F(fluid.F());
61 
62  // Phase-fraction face-gradient
64 
65  // Phase-1 dispersion, lift and wall-lubrication flux
66  phiF1 = DbyA1()*snGradAlpha1 + fvc::flux(rAU1*F);
67 
68  // Phase-2 dispersion, lift and wall-lubrication flux
69  phiF2 = - DbyA2()*snGradAlpha1 - fvc::flux(rAU2*F);
70 
71  // Cache the phase diffusivities for implicit treatment in the
72  // phase-fraction equation
73  if (implicitPhasePressure)
74  {
75  phase1.DbyA(DbyA1);
76  phase2.DbyA(DbyA2);
77  }
78 }
79 
80 
81 // --- Pressure corrector loop
82 while (pimple.correct())
83 {
84  volScalarField rho("rho", fluid.rho());
85 
86  // Correct p_rgh for consistency with p and the updated densities
87  p_rgh = p - rho*gh;
88 
89  // Correct fixed-flux BCs to be consistent with the velocity BCs
90  MRF.correctBoundaryFlux(U1, phi1);
91  MRF.correctBoundaryFlux(U2, phi2);
92 
93  volVectorField HbyA1
94  (
95  IOobject::groupName("HbyA", phase1.name()),
96  U1
97  );
98  HbyA1 =
99  rAU1
100  *(
101  U1Eqn.H()
102  + byDt(max(phase1.residualAlpha() - alpha1, scalar(0))*rho1)
103  *U1.oldTime()
104  );
105 
106  volVectorField HbyA2
107  (
108  IOobject::groupName("HbyA", phase2.name()),
109  U2
110  );
111  HbyA2 =
112  rAU2
113  *(
114  U2Eqn.H()
115  + byDt(max(phase2.residualAlpha() - alpha2, scalar(0))*rho2)
116  *U2.oldTime()
117  );
118 
120  (
121  "ghSnGradRho",
122  ghf*fvc::snGrad(rho)*mesh.magSf()
123  );
124 
125  surfaceScalarField phig1
126  (
127  alpharAUf1
128  *(
130  - alphaf2*fvc::interpolate(rho1 - rho2)*(g & mesh.Sf())
131  )
132  );
133 
134  surfaceScalarField phig2
135  (
136  alpharAUf2
137  *(
139  - alphaf1*fvc::interpolate(rho2 - rho1)*(g & mesh.Sf())
140  )
141  );
142 
143 
144  // ddtPhiCorr filter -- only apply in pure(ish) phases
146  surfaceScalarField phiCorrCoeff1(pos0(alphaf1Bar - 0.99));
147  surfaceScalarField phiCorrCoeff2(pos0(0.01 - alphaf1Bar));
148 
149  {
150  surfaceScalarField::Boundary& phiCorrCoeff1Bf =
151  phiCorrCoeff1.boundaryFieldRef();
152 
153  surfaceScalarField::Boundary& phiCorrCoeff2Bf =
154  phiCorrCoeff2.boundaryFieldRef();
155 
156  forAll(mesh.boundary(), patchi)
157  {
158  // Set ddtPhiCorr to 0 on non-coupled boundaries
159  if
160  (
161  !mesh.boundary()[patchi].coupled()
162  || isA<cyclicAMIFvPatch>(mesh.boundary()[patchi])
163  )
164  {
165  phiCorrCoeff1Bf[patchi] = 0;
166  phiCorrCoeff2Bf[patchi] = 0;
167  }
168  }
169  }
170 
171  // Phase-1 predicted flux
172  surfaceScalarField phiHbyA1
173  (
174  IOobject::groupName("phiHbyA", phase1.name()),
175  fvc::flux(HbyA1)
176  + phiCorrCoeff1
177  *fvc::interpolate(byDt(alpha1.oldTime()*rho1.oldTime()*rAU1))
178  *(MRF.absolute(phi1.oldTime()) - fvc::flux(U1.oldTime()))
179  - phiF1()
180  - phig1
181  );
182 
183  // Phase-2 predicted flux
184  surfaceScalarField phiHbyA2
185  (
186  IOobject::groupName("phiHbyA", phase2.name()),
187  fvc::flux(HbyA2)
188  + phiCorrCoeff2
189  *fvc::interpolate(byDt(alpha2.oldTime()*rho2.oldTime()*rAU2))
190  *(MRF.absolute(phi2.oldTime()) - fvc::flux(U2.oldTime()))
191  - phiF2()
192  - phig2
193  );
194 
195  // Face-drag coefficients
198 
199  // Construct the mean predicted flux
200  // including explicit drag contributions based on absolute fluxes
202  (
203  "phiHbyA",
204  alphaf1*(phiHbyA1 + rAUKd1*MRF.absolute(phi2))
205  + alphaf2*(phiHbyA2 + rAUKd2*MRF.absolute(phi1))
206  );
207  MRF.makeRelative(phiHbyA);
208 
209  // Construct pressure "diffusivity"
211  (
212  "rAUf",
214  );
215 
216  // Update the fixedFluxPressure BCs to ensure flux consistency
218  (
219  p_rgh.boundaryFieldRef(),
220  (
221  phiHbyA.boundaryField()
222  - (
223  alphaf1.boundaryField()*phi1.boundaryField()
224  + alphaf2.boundaryField()*phi2.boundaryField()
225  )
226  )/(mesh.magSf().boundaryField()*rAUf.boundaryField())
227  );
228 
229  tmp<fvScalarMatrix> pEqnComp1;
230  tmp<fvScalarMatrix> pEqnComp2;
231 
232  // Construct the compressibility parts of the pressure equation
233 
234  if (phase1.compressible())
235  {
236  if (pimple.transonic())
237  {
238  surfaceScalarField phid1
239  (
240  IOobject::groupName("phid", phase1.name()),
242  );
243 
244  pEqnComp1 =
245  (
246  phase1.continuityError()
248  )/rho1
249  + correction
250  (
251  (alpha1/rho1)*
252  (
253  psi1*fvm::ddt(p_rgh)
254  + fvm::div(phid1, p_rgh) - fvm::Sp(fvc::div(phid1), p_rgh)
255  )
256  );
257 
258  deleteDemandDrivenData(pEqnComp1.ref().faceFluxCorrectionPtr());
259  pEqnComp1.ref().relax();
260  }
261  else
262  {
263  pEqnComp1 =
264  (
265  phase1.continuityError()
267  )/rho1
268  + (alpha1*psi1/rho1)*correction(fvm::ddt(p_rgh));
269  }
270  }
271  else
272  {
273  pEqnComp1 = fvm::Su(-(fvOptions(alpha1, rho1)&rho1)/rho1, p_rgh);
274  }
275 
276  if (phase2.compressible())
277  {
278  if (pimple.transonic())
279  {
280  surfaceScalarField phid2
281  (
282  IOobject::groupName("phid", phase2.name()),
284  );
285 
286  pEqnComp2 =
287  (
288  phase2.continuityError()
290  )/rho2
291  + correction
292  (
293  (alpha2/rho2)*
294  (
295  psi2*fvm::ddt(p_rgh)
296  + fvm::div(phid2, p_rgh) - fvm::Sp(fvc::div(phid2), p_rgh)
297  )
298  );
299 
300  deleteDemandDrivenData(pEqnComp2.ref().faceFluxCorrectionPtr());
301  pEqnComp2.ref().relax();
302  }
303  else
304  {
305  pEqnComp2 =
306  (
307  phase2.continuityError()
309  )/rho2
310  + (alpha2*psi2/rho2)*correction(fvm::ddt(p_rgh));
311  }
312  }
313  else
314  {
315  pEqnComp2 = fvm::Su(-(fvOptions(alpha2, rho2)&rho2)/rho2, p_rgh);
316  }
317 
318  if (fluid.transfersMass())
319  {
320  if (pEqnComp1.valid())
321  {
322  pEqnComp1.ref() -= fluid.dmdt()/rho1;
323  }
324  else
325  {
326  pEqnComp1 = fvm::Su(-fluid.dmdt()/rho1, p_rgh);
327  }
328 
329  if (pEqnComp2.valid())
330  {
331  pEqnComp2.ref() += fluid.dmdt()/rho2;
332  }
333  else
334  {
335  pEqnComp2 = fvm::Su(fluid.dmdt()/rho2, p_rgh);
336  }
337  }
338 
339  // Cache p prior to solve for density update
340  volScalarField p_rgh_0(p_rgh);
341 
342  // Iterate over the pressure equation to correct for non-orthogonality
343  while (pimple.correctNonOrthogonal())
344  {
345  // Construct the transport part of the pressure equation
346  fvScalarMatrix pEqnIncomp
347  (
348  fvc::div(phiHbyA)
349  - fvm::laplacian(rAUf, p_rgh)
350  );
351 
352  {
353  fvScalarMatrix pEqn(pEqnIncomp);
354 
355  if (pEqnComp1.valid())
356  {
357  pEqn += pEqnComp1();
358  }
359 
360  if (pEqnComp2.valid())
361  {
362  pEqn += pEqnComp2();
363  }
364 
365  solve
366  (
367  pEqn,
368  mesh.solver(p_rgh.select(pimple.finalInnerIter()))
369  );
370  }
371 
372  // Correct fluxes and velocities on last non-orthogonal iteration
373  if (pimple.finalNonOrthogonalIter())
374  {
375  phi = phiHbyA + pEqnIncomp.flux();
376 
377  surfaceScalarField mSfGradp("mSfGradp", pEqnIncomp.flux()/rAUf);
378 
379  // Partial-elimination phase-flux corrector
380  {
381  surfaceScalarField phi1s
382  (
383  phiHbyA1 + alpharAUf1*mSfGradp
384  );
385 
386  surfaceScalarField phi2s
387  (
388  phiHbyA2 + alpharAUf2*mSfGradp
389  );
390 
392  (
393  ((phi1s + rAUKd1*phi2s) - (phi2s + rAUKd2*phi1s))
394  /(1 - rAUKd1*rAUKd2)
395  );
396 
397  phi1 = phi + alphaf2*phir;
398  phi2 = phi - alphaf1*phir;
399  }
400 
401  // Set the phase dilatation rates
402  if (pEqnComp1.valid())
403  {
404  phase1.divU(-pEqnComp1 & p_rgh);
405  }
406  if (pEqnComp2.valid())
407  {
408  phase2.divU(-pEqnComp2 & p_rgh);
409  }
410 
411  // Optionally relax pressure for velocity correction
412  p_rgh.relax();
413 
414  mSfGradp = pEqnIncomp.flux()/rAUf;
415 
416  // Partial-elimination phase-velocity corrector
417  {
418  volVectorField Us1
419  (
420  HbyA1
421  + fvc::reconstruct(alpharAUf1*mSfGradp - phiF1() - phig1)
422  );
423 
424  volVectorField Us2
425  (
426  HbyA2
427  + fvc::reconstruct(alpharAUf2*mSfGradp - phiF2() - phig2)
428  );
429 
430  volScalarField D1(rAU1*Kd);
431  volScalarField D2(rAU2*Kd);
432 
433  volVectorField U(alpha1*(Us1 + D1*U2) + alpha2*(Us2 + D2*U1));
434  volVectorField Ur(((1 - D2)*Us1 - (1 - D1)*Us2)/(1 - D1*D2));
435 
436  U1 = U + alpha2*Ur;
437  U1.correctBoundaryConditions();
438  fvOptions.correct(U1);
439 
440  U2 = U - alpha1*Ur;
441  U2.correctBoundaryConditions();
442  fvOptions.correct(U2);
443  }
444  }
445  }
446 
447  // Update and limit the static pressure
448  p = max(p_rgh + rho*gh, pMin);
449 
450  // Limit p_rgh
451  p_rgh = p - rho*gh;
452 
453  // Update densities from change in p_rgh
454  rho1 += psi1*(p_rgh - p_rgh_0);
455  rho2 += psi2*(p_rgh - p_rgh_0);
456 
457  // Correct p_rgh for consistency with p and the updated densities
458  rho = fluid.rho();
459  p_rgh = p - rho*gh;
460  p_rgh.correctBoundaryConditions();
461 }
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix.
psi2
Definition: TEqns.H:35
fvMatrix< scalar > fvScalarMatrix
Definition: fvMatricesFwd.H:42
tmp< surfaceScalarField > phiF2
Definition: pEqn.H:36
U
Definition: pEqn.H:83
volVectorField F(fluid.F())
surfaceScalarField alphaf1("alphaf1", fvc::interpolate(alpha1))
surfaceScalarField alpharAUf2(fvc::interpolate(max(alpha2, phase2.residualAlpha()) *rAU2))
zeroField Su
Definition: alphaSuSp.H:1
surfaceScalarField & phi2
volScalarField rAU2(IOobject::groupName("rAU", phase2.name()), 1.0/(U2Eqn.A()+byDt(max(phase2.residualAlpha() - alpha2, scalar(0)) *rho2)))
multiphaseSystem & fluid
Definition: createFields.H:11
p
Definition: pEqn.H:50
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
phiHbyA
Definition: pEqn.H:20
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:47
surfaceScalarField & alphaPhi2
const dictionary & pimple
const surfaceScalarField & alphaPhi1
surfaceScalarField & phi1
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:55
tmp< GeometricField< Type, fvPatchField, volMesh > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcLaplacian.C:45
forAll(phases, phasei)
Definition: pEqn.H:5
fv::options & fvOptions
const surfaceScalarField & ghf
tmp< GeometricField< Type, fvPatchField, volMesh > > ddt(const dimensioned< Type > dt, const fvMesh &mesh)
Definition: fvcDdt.C:45
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
tmp< surfaceScalarField > DbyA1(fvc::interpolate(rAU1 *(D+phase1.turbulence().pPrime())))
dynamicFvMesh & mesh
volScalarField Kd(fluid.Kd())
IOMRFZoneList & MRF
surfaceScalarField snGradAlpha1(fvc::snGrad(alpha1) *mesh.magSf())
surfaceScalarField phir(fvc::flux(UdmModel.Udm()))
rhoEqn solve()
volVectorField & U1
alpha2
Definition: alphaEqn.H:112
phaseModel & phase1
p_rgh
Definition: pEqn.H:134
dimensionedScalar pos0(const dimensionedScalar &ds)
const dimensionedVector & g
volScalarField & alpha1
dimensionedScalar pMin("pMin", dimPressure, fluid)
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU))
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> reconstruct(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
label patchi
tmp< surfaceScalarField > phiF1
Definition: pEqn.H:35
psi1
Definition: TEqns.H:34
surfaceScalarField ghSnGradRho(ghf *fvc::snGrad(rho) *mesh.magSf())
surfaceScalarField alpharAUf1(fvc::interpolate(max(alpha1, phase1.residualAlpha()) *rAU1))
setSnGrad< fixedFluxPressureFvPatchScalarField >(p_rgh.boundaryFieldRef(),(phiHbyA.boundaryField() - MRF.relative(phib))/(mesh.magSf().boundaryField() *rAUf.boundaryField()))
volVectorField & U2
const volScalarField & gh
volScalarField p_rgh_0(p_rgh)
tmp< surfaceScalarField > DbyA2(fvc::interpolate(rAU2 *(D+phase2.turbulence().pPrime())))
tmp< GeometricField< Type, fvPatchField, volMesh > > average(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Area-weighted average a surfaceField creating a volField.
Definition: fvcAverage.C:46
dimensioned< scalar > mag(const dimensioned< Type > &)
const dimensionedScalar & rho2
Definition: createFields.H:40
phi
Definition: pEqn.H:18
volScalarField rAU1(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1)))
phaseModel & phase2
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Return the face-flux field obtained from the given volVectorField.
Definition: fvcFlux.C:32
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
surfaceScalarField alphaf2("alphaf2", scalar(1) - alphaf1)
const dimensionedScalar & rho1
Definition: createFields.H:39
rho
Definition: pEqn.H:1
void deleteDemandDrivenData(DataPtr &dataPtr)
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > snGrad(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcSnGrad.C:45
zeroField Sp
Definition: alphaSuSp.H:2