pEqn.H
Go to the documentation of this file.
1 PtrList<surfaceScalarField> alphafs(phases.size());
2 PtrList<volScalarField> rAUs(phases.size());
3 PtrList<surfaceScalarField> alpharAUfs(phases.size());
4 
6 {
7  phaseModel& phase = phases[phasei];
8  const volScalarField& alpha = phase;
9 
10  alphafs.set(phasei, fvc::interpolate(alpha).ptr());
11  alphafs[phasei].rename("pEqn" + alphafs[phasei].name());
12 
13  rAUs.set
14  (
15  phasei,
16  new volScalarField
17  (
18  IOobject::groupName("rAU", phase.name()),
19  1.0
20  /(
21  UEqns[phasei].A()
22  + max(phase.residualAlpha() - alpha, scalar(0))
23  *phase.rho()/runTime.deltaT()
24  )
25  )
26  );
27 
28  alpharAUfs.set
29  (
30  phasei,
31  (
32  fvc::interpolate(max(alpha, phase.residualAlpha())*rAUs[phasei])
33  ).ptr()
34  );
35 }
36 
37 // Lift, wall-lubrication and turbulent diffusion fluxes
38 PtrList<surfaceScalarField> phiFs(phases.size());
39 {
40  autoPtr<PtrList<volVectorField> > Fs = fluid.Fs();
41 
43  {
44  phaseModel& phase = phases[phasei];
45 
46  if (Fs().set(phasei))
47  {
48  phiFs.set
49  (
50  phasei,
52  (
53  IOobject::groupName("phiF", phase.name()),
54  (fvc::interpolate(rAUs[phasei]*Fs()[phasei]) & mesh.Sf())
55  )
56  );
57  }
58  }
59 }
60 {
61  autoPtr<PtrList<surfaceScalarField> > phiDs = fluid.phiDs(rAUs);
62 
64  {
65  phaseModel& phase = phases[phasei];
66 
67  if (phiDs().set(phasei))
68  {
69  if (phiFs.set(phasei))
70  {
71  phiFs[phasei] += phiDs()[phasei];
72  }
73  else
74  {
75  phiFs.set
76  (
77  phasei,
79  (
80  IOobject::groupName("phiF", phase.name()),
81  phiDs()[phasei]
82  )
83  );
84  }
85  }
86  }
87 }
88 
89 // --- Pressure corrector loop
90 while (pimple.correct())
91 {
92  // Update continuity errors due to temperature changes
93  fluid.correct();
94 
95  volScalarField rho("rho", fluid.rho());
96 
97  // Correct p_rgh for consistency with p and the updated densities
98  p_rgh = p - rho*gh;
99 
100  PtrList<volVectorField> HbyAs(phases.size());
101 
103  {
104  phaseModel& phase = phases[phasei];
105  const volScalarField& alpha = phase;
106 
107  // Correct fixed-flux BCs to be consistent with the velocity BCs
108  MRF.correctBoundaryFlux(phase.U(), phase.phi());
109 
110  HbyAs.set
111  (
112  phasei,
113  new volVectorField
114  (
115  IOobject::groupName("HbyA", phase.name()),
116  phase.U()
117  )
118  );
119 
120  HbyAs[phasei] =
121  rAUs[phasei]
122  *(
123  UEqns[phasei].H()
124  + max(phase.residualAlpha() - alpha, scalar(0))
125  *phase.rho()*phase.U().oldTime()/runTime.deltaT()
126  );
127  }
128 
130  (
131  "ghSnGradRho",
132  ghf*fvc::snGrad(rho)*mesh.magSf()
133  );
134 
135  PtrList<surfaceScalarField> phigFs(phases.size());
137  {
138  phaseModel& phase = phases[phasei];
139 
140  phigFs.set
141  (
142  phasei,
143  (
145  *(
147  - (fvc::interpolate(phase.rho() - rho))*(g & mesh.Sf())
148  - fluid.surfaceTension(phase)*mesh.magSf()
149  )
150  ).ptr()
151  );
152 
153  if (phiFs.set(phasei))
154  {
155  phigFs[phasei] += phiFs[phasei];
156  }
157  }
158 
159  PtrList<surfaceScalarField> phiHbyAs(phases.size());
160 
162  (
163  IOobject
164  (
165  "phiHbyA",
166  runTime.timeName(),
167  mesh,
168  IOobject::NO_READ,
169  IOobject::AUTO_WRITE
170  ),
171  mesh,
172  dimensionedScalar("phiHbyA", dimArea*dimVelocity, 0)
173  );
174 
176  {
177  phaseModel& phase = phases[phasei];
178  const volScalarField& alpha = phase;
179 
180  // ddtPhiCorr filter -- only apply in pure(ish) phases
181  surfaceScalarField alphafBar
182  (
184  );
185  surfaceScalarField phiCorrCoeff(pos(alphafBar - 0.99));
186 
187  forAll(mesh.boundary(), patchi)
188  {
189  // Set ddtPhiCorr to 0 on non-coupled boundaries
190  if
191  (
192  !mesh.boundary()[patchi].coupled()
193  || isA<cyclicAMIFvPatch>(mesh.boundary()[patchi])
194  )
195  {
196  phiCorrCoeff.boundaryField()[patchi] = 0;
197  }
198  }
199 
200  phiHbyAs.set
201  (
202  phasei,
204  (
205  IOobject::groupName("phiHbyA", phase.name()),
206  (fvc::interpolate(HbyAs[phasei]) & mesh.Sf())
207  + phiCorrCoeff
209  (
210  alpha.oldTime()*phase.rho()().oldTime()*rAUs[phasei]
211  )
212  *(
213  MRF.absolute(phase.phi().oldTime())
214  - (fvc::interpolate(phase.U().oldTime()) & mesh.Sf())
215  )/runTime.deltaT()
216  - phigFs[phasei]
217  )
218  );
219 
221  (
222  phaseSystem::KdTable,
223  fluid.Kds(),
224  KdIter
225  )
226  {
227  const volScalarField& K(*KdIter());
228 
229  const phasePair& pair(fluid.phasePairs()[KdIter.key()]);
230 
231  const phaseModel* phase1 = &pair.phase1();
232  const phaseModel* phase2 = &pair.phase2();
233 
234  forAllConstIter(phasePair, pair, iter)
235  {
236  if (phase1 == &phase)
237  {
238  phiHbyAs[phasei] +=
239  fvc::interpolate(rAUs[phasei]*K)
240  *MRF.absolute(phase2->phi());
241 
242  HbyAs[phasei] += rAUs[phasei]*K*phase2->U();
243  }
244 
245  Swap(phase1, phase2);
246  }
247  }
248 
250  }
251 
252  MRF.makeRelative(phiHbyA);
253 
254  // Construct pressure "diffusivity"
256  (
257  IOobject
258  (
259  "rAUf",
260  runTime.timeName(),
261  mesh
262  ),
263  mesh,
264  dimensionedScalar("rAUf", dimensionSet(-1, 3, 1, 0, 0), 0)
265  );
266 
268  {
269  rAUf += alphafs[phasei]*alpharAUfs[phasei];
270  }
271  rAUf = mag(rAUf);
272 
273 
274  // Update the fixedFluxPressure BCs to ensure flux consistency
275  {
276  surfaceScalarField::GeometricBoundaryField phib(phi.boundaryField());
277  phib = 0;
279  {
280  phaseModel& phase = phases[phasei];
281  phib += alphafs[phasei].boundaryField()*phase.phi().boundaryField();
282  }
283 
285  (
286  p_rgh.boundaryField(),
287  (
288  phiHbyA.boundaryField() - phib
289  )/(mesh.magSf().boundaryField()*rAUf.boundaryField())
290  );
291  }
292 
293  PtrList<fvScalarMatrix> pEqnComps(phases.size());
295  {
296  phaseModel& phase = phases[phasei];
297 
298  if (phase.compressible())
299  {
300  const volScalarField& alpha = phase;
301  const volScalarField& rho = phase.rho();
302 
303  if (pimple.transonic())
304  {
306  (
307  IOobject::groupName("phid", phase.name()),
308  fvc::interpolate(phase.thermo().psi())*phase.phi()
309  );
310 
311  pEqnComps.set
312  (
313  phasei,
314  (
315  (
316  phase.continuityError()
317  - fvc::Sp
318  (
319  fvc::ddt(alpha) + fvc::div(phase.alphaPhi()),
320  rho
321  )
322  )/rho
323  + (alpha/rho)*correction
324  (
325  phase.thermo().psi()*fvm::ddt(p_rgh)
326  + fvm::div(phid, p_rgh)
327  - fvm::Sp(fvc::div(phid), p_rgh)
328  )
329  ).ptr()
330  );
331 
333  (
334  pEqnComps[phasei].faceFluxCorrectionPtr()
335  );
336  pEqnComps[phasei].relax();
337  }
338  else
339  {
340  pEqnComps.set
341  (
342  phasei,
343  (
344  (
345  phase.continuityError()
346  - fvc::Sp
347  (
348  (fvc::ddt(alpha) + fvc::div(phase.alphaPhi())),
349  rho
350  )
351  )/rho
352  + (alpha*phase.thermo().psi()/rho)
353  *correction(fvm::ddt(p_rgh))
354  ).ptr()
355  );
356  }
357 
358  if (fluid.transfersMass(phase))
359  {
360  if (pEqnComps.set(phasei))
361  {
362  pEqnComps[phasei] -= fluid.dmdt(phase)/rho;
363  }
364  else
365  {
366  pEqnComps.set
367  (
368  phasei,
369  fvm::Su(-fluid.dmdt(phase)/rho, p_rgh)
370  );
371  }
372  }
373  }
374  }
375 
376  // Cache p prior to solve for density update
377  volScalarField p_rgh_0(p_rgh);
378 
379  // Iterate over the pressure equation to correct for non-orthogonality
380  while (pimple.correctNonOrthogonal())
381  {
382  // Construct the transport part of the pressure equation
383  fvScalarMatrix pEqnIncomp
384  (
386  - fvm::laplacian(rAUf, p_rgh)
387  );
388 
389  {
390  fvScalarMatrix pEqn(pEqnIncomp);
391 
393  {
394  if (pEqnComps.set(phasei))
395  {
396  pEqn += pEqnComps[phasei];
397  }
398  }
399 
400  solve
401  (
402  pEqn,
403  mesh.solver(p_rgh.select(pimple.finalInnerIter()))
404  );
405  }
406 
407  // Correct fluxes and velocities on last non-orthogonal iteration
408  if (pimple.finalNonOrthogonalIter())
409  {
410  phi = phiHbyA + pEqnIncomp.flux();
411 
412  surfaceScalarField mSfGradp("mSfGradp", pEqnIncomp.flux()/rAUf);
413 
415  {
416  phaseModel& phase = phases[phasei];
417 
418  phase.phi() = phiHbyAs[phasei] + alpharAUfs[phasei]*mSfGradp;
419 
420  // Set the phase dilatation rates
421  if (phase.compressible())
422  {
423  phase.divU(-pEqnComps[phasei] & p_rgh);
424  }
425  }
426 
427  // Optionally relax pressure for velocity correction
428  p_rgh.relax();
429 
430  mSfGradp = pEqnIncomp.flux()/rAUf;
431 
433  {
434  phaseModel& phase = phases[phasei];
435 
436  phase.U() =
437  HbyAs[phasei]
439  (
440  alpharAUfs[phasei]*mSfGradp
441  - phigFs[phasei]
442  );
443  phase.U().correctBoundaryConditions();
444  fvOptions.correct(phase.U());
445  }
446  }
447  }
448 
449  // Update and limit the static pressure
450  p = max(p_rgh + rho*gh, pMin);
451 
452  // Limit p_rgh
453  p_rgh = p - rho*gh;
454 
455  // Update densities from change in p_rgh
457  {
458  phaseModel& phase = phases[phasei];
459  phase.rho()() += phase.thermo().psi()*(p_rgh - p_rgh_0);
460  }
461 
462  // Correct p_rgh for consistency with p and the updated densities
463  rho = fluid.rho();
464  p_rgh = p - rho*gh;
465  p_rgh.correctBoundaryConditions();
466 }
phaseModel & phase1
Definition: createFields.H:12
PtrList< fvVectorMatrix > UEqns(fluid.phases().size())
phaseModel & phase2
Definition: createFields.H:13
PtrList< surfaceScalarField > phiHbyAs(fluid.phases().size())
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix.
multiphaseSystem & fluid
Definition: createFields.H:10
phi
Definition: pEqn.H:20
dimensioned< scalar > mag(const dimensioned< Type > &)
label phasei
Definition: pEqn.H:37
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
setSnGrad< fixedFluxPressureFvPatchScalarField >(p_rgh.boundaryField(),( phiHbyA.boundaryField() -MRF.relative(mesh.Sf().boundaryField()&U.boundaryField()) *rho.boundaryField() )/(mesh.magSf().boundaryField()*rhorAUf.boundaryField()))
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU))
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> reconstruct(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
void deleteDemandDrivenData(DataPtr &dataPtr)
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
tmp< GeometricField< Type, fvPatchField, volMesh > > Sp(const volScalarField &sp, const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvcSup.C:67
tmp< GeometricField< Type, fvPatchField, volMesh > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcLaplacian.C:45
volScalarField & p_rgh
tmp< surfaceScalarField > interpolate(const RhoType &rho)
tmp< GeometricField< Type, fvPatchField, volMesh > > ddt(const dimensioned< Type > dt, const fvMesh &mesh)
Definition: fvcDdt.C:45
dynamicFvMesh & mesh
const dictionary & pimple
p
Definition: pEqn.H:59
tmp< GeometricField< Type, fvPatchField, volMesh > > Su(const GeometricField< Type, fvPatchField, volMesh > &su, const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvcSup.C:44
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
rhoEqn solve()
fv::IOoptionList & fvOptions
fvMatrix< scalar > fvScalarMatrix
Definition: fvMatricesFwd.H:42
surfaceScalarField ghSnGradRho(ghf *fvc::snGrad(rho)*mesh.magSf())
IOMRFZoneList & MRF
surfaceScalarField phid("phid", fvc::interpolate(psi)*( (mesh.Sf()&fvc::interpolate(HbyA)) +rhorAUf *fvc::ddtCorr(rho, U, phi)/fvc::interpolate(rho) ))
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
forAll(phases, phasei)
Definition: pEqn.H:5
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
PtrList< surfaceScalarField > alpharAUfs(phases.size())
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
PtrList< volVectorField > HbyAs(fluid.phases().size())
label patchi
volScalarField p_rgh_0(p_rgh)
phiHbyA
Definition: pEqn.H:21
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > snGrad(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcSnGrad.C:45
rho oldTime()
PtrList< surfaceScalarField > phiFs(phases.size())
void Swap(T &a, T &b)
Definition: Swap.H:43
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:55
const dimensionedVector & g
tmp< GeometricField< Type, fvPatchField, volMesh > > average(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Area-weighted average a surfaceField creating a volField.
Definition: fvcAverage.C:46
PtrList< volScalarField > rAUs(fluid.phases().size())
multiphaseSystem::phaseModelList & phases
Definition: createFields.H:11
K
Definition: pEqn.H:85
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:47
dimensionedScalar pos(const dimensionedScalar &ds)
rho
Definition: pEqn.H:1
const dimensionSet dimVelocity
dimensionedScalar pMin("pMin", dimPressure, fluid)
PtrList< surfaceScalarField > alphafs(phases.size())
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const surfaceScalarField & ghf
const volScalarField & gh
phib
Definition: pEqn.H:191