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  PtrList<volVectorField> HbyAs(phases.size());
96 
98  {
99  phaseModel& phase = phases[phasei];
100  const volScalarField& alpha = phase;
101 
102  // Correct fixed-flux BCs to be consistent with the velocity BCs
103  MRF.correctBoundaryFlux(phase.U(), phase.phi());
104 
105  HbyAs.set
106  (
107  phasei,
108  new volVectorField
109  (
110  IOobject::groupName("HbyA", phase.name()),
111  phase.U()
112  )
113  );
114 
115  HbyAs[phasei] =
116  rAUs[phasei]
117  *(
118  UEqns[phasei].H()
119  + max(phase.residualAlpha() - alpha, scalar(0))
120  *phase.rho()*phase.U().oldTime()/runTime.deltaT()
121  );
122  }
123 
124  // Mean density for buoyancy force and p_rgh -> p
125  volScalarField rho("rho", fluid.rho());
126 
128  (
129  "ghSnGradRho",
130  ghf*fvc::snGrad(rho)*mesh.magSf()
131  );
132 
133  PtrList<surfaceScalarField> phigFs(phases.size());
135  {
136  phaseModel& phase = phases[phasei];
137 
138  phigFs.set
139  (
140  phasei,
141  (
143  *(
145  - (fvc::interpolate(phase.rho() - rho))*(g & mesh.Sf())
146  - fluid.surfaceTension(phase)*mesh.magSf()
147  )
148  ).ptr()
149  );
150 
151  if (phiFs.set(phasei))
152  {
153  phigFs[phasei] += phiFs[phasei];
154  }
155  }
156 
157  PtrList<surfaceScalarField> phiHbyAs(phases.size());
158 
160  (
161  IOobject
162  (
163  "phiHbyA",
164  runTime.timeName(),
165  mesh,
166  IOobject::NO_READ,
167  IOobject::AUTO_WRITE
168  ),
169  mesh,
170  dimensionedScalar("phiHbyA", dimArea*dimVelocity, 0)
171  );
172 
174  {
175  phaseModel& phase = phases[phasei];
176  const volScalarField& alpha = phase;
177 
178  // ddtPhiCorr filter -- only apply in pure(ish) phases
179  surfaceScalarField alphafBar
180  (
182  );
183  surfaceScalarField phiCorrCoeff(pos(alphafBar - 0.99));
184 
185  forAll(mesh.boundary(), patchi)
186  {
187  // Set ddtPhiCorr to 0 on non-coupled boundaries
188  if
189  (
190  !mesh.boundary()[patchi].coupled()
191  || isA<cyclicAMIFvPatch>(mesh.boundary()[patchi])
192  )
193  {
194  phiCorrCoeff.boundaryField()[patchi] = 0;
195  }
196  }
197 
198  phiHbyAs.set
199  (
200  phasei,
202  (
203  IOobject::groupName("phiHbyA", phase.name()),
204  (fvc::interpolate(HbyAs[phasei]) & mesh.Sf())
205  + phiCorrCoeff
207  (
208  alpha.oldTime()*phase.rho()().oldTime()*rAUs[phasei]
209  )
210  *(
211  MRF.absolute(phase.phi().oldTime())
212  - (fvc::interpolate(phase.U().oldTime()) & mesh.Sf())
213  )/runTime.deltaT()
214  - phigFs[phasei]
215  )
216  );
217 
219  (
220  phaseSystem::KdTable,
221  fluid.Kds(),
222  KdIter
223  )
224  {
225  const volScalarField& K(*KdIter());
226 
227  const phasePair& pair(fluid.phasePairs()[KdIter.key()]);
228 
229  const phaseModel* phase1 = &pair.phase1();
230  const phaseModel* phase2 = &pair.phase2();
231 
232  forAllConstIter(phasePair, pair, iter)
233  {
234  if (phase1 == &phase)
235  {
236  phiHbyAs[phasei] +=
238  *MRF.absolute(phase2->phi());
239 
240  HbyAs[phasei] += rAUs[phasei]*K*phase2->U();
241  }
242 
243  Swap(phase1, phase2);
244  }
245  }
246 
248  }
249 
250  MRF.makeRelative(phiHbyA);
251 
252  // Construct pressure "diffusivity"
254  (
255  IOobject
256  (
257  "rAUf",
258  runTime.timeName(),
259  mesh
260  ),
261  mesh,
262  dimensionedScalar("rAUf", dimensionSet(-1, 3, 1, 0, 0), 0)
263  );
264 
266  {
268  }
269  rAUf = mag(rAUf);
270 
271 
272  // Update the fixedFluxPressure BCs to ensure flux consistency
273  {
274  surfaceScalarField::GeometricBoundaryField phib(phi.boundaryField());
275  phib = 0;
277  {
278  phaseModel& phase = phases[phasei];
279  phib += alphafs[phasei].boundaryField()*phase.phi().boundaryField();
280  }
281 
283  (
284  p_rgh.boundaryField(),
285  (
286  phiHbyA.boundaryField() - phib
287  )/(mesh.magSf().boundaryField()*rAUf.boundaryField())
288  );
289  }
290 
291  PtrList<fvScalarMatrix> pEqnComps(phases.size());
293  {
294  phaseModel& phase = phases[phasei];
295 
296  if (phase.compressible())
297  {
298  const volScalarField& alpha = phase;
299  const volScalarField& rho = phase.rho();
300 
301  if (pimple.transonic())
302  {
304  (
305  IOobject::groupName("phid", phase.name()),
306  fvc::interpolate(phase.thermo().psi())*phase.phi()
307  );
308 
309  pEqnComps.set
310  (
311  phasei,
312  (
313  (
314  phase.continuityError()
315  - fvc::Sp
316  (
317  fvc::ddt(alpha) + fvc::div(phase.alphaPhi()),
318  rho
319  )
320  )/rho
321  + (alpha/rho)*correction
322  (
323  phase.thermo().psi()*fvm::ddt(p_rgh)
324  + fvm::div(phid, p_rgh)
326  )
327  ).ptr()
328  );
329 
331  (
332  pEqnComps[phasei].faceFluxCorrectionPtr()
333  );
334  pEqnComps[phasei].relax();
335  }
336  else
337  {
338  pEqnComps.set
339  (
340  phasei,
341  (
342  (
343  phase.continuityError()
344  - fvc::Sp
345  (
346  (fvc::ddt(alpha) + fvc::div(phase.alphaPhi())),
347  rho
348  )
349  )/rho
350  + (alpha*phase.thermo().psi()/rho)
352  ).ptr()
353  );
354  }
355 
356  if (fluid.transfersMass(phase))
357  {
358  if (pEqnComps.set(phasei))
359  {
360  pEqnComps[phasei] -= fluid.dmdt(phase)/rho;
361  }
362  else
363  {
364  pEqnComps.set
365  (
366  phasei,
367  fvm::Su(-fluid.dmdt(phase)/rho, p_rgh)
368  );
369  }
370  }
371  }
372  }
373 
374  // Cache p prior to solve for density update
376 
377  // Iterate over the pressure equation to correct for non-orthogonality
378  while (pimple.correctNonOrthogonal())
379  {
380  // Construct the transport part of the pressure equation
381  fvScalarMatrix pEqnIncomp
382  (
385  );
386 
387  {
388  fvScalarMatrix pEqn(pEqnIncomp);
389 
391  {
392  if (pEqnComps.set(phasei))
393  {
394  pEqn += pEqnComps[phasei];
395  }
396  }
397 
398  solve
399  (
400  pEqn,
401  mesh.solver(p_rgh.select(pimple.finalInnerIter()))
402  );
403  }
404 
405  // Correct fluxes and velocities on last non-orthogonal iteration
406  if (pimple.finalNonOrthogonalIter())
407  {
408  phi = phiHbyA + pEqnIncomp.flux();
409 
410  surfaceScalarField mSfGradp("mSfGradp", pEqnIncomp.flux()/rAUf);
411 
413  {
414  phaseModel& phase = phases[phasei];
415 
416  phase.phi() = phiHbyAs[phasei] + alpharAUfs[phasei]*mSfGradp;
417 
418  // Set the phase dilatation rates
419  if (phase.compressible())
420  {
421  phase.divU(-pEqnComps[phasei] & p_rgh);
422  }
423  }
424 
425  // Optionally relax pressure for velocity correction
426  p_rgh.relax();
427 
428  mSfGradp = pEqnIncomp.flux()/rAUf;
429 
431  {
432  phaseModel& phase = phases[phasei];
433 
434  phase.U() =
435  HbyAs[phasei]
437  (
438  alpharAUfs[phasei]*mSfGradp
439  - phigFs[phasei]
440  );
441  phase.U().correctBoundaryConditions();
442  fvOptions.correct(phase.U());
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
455  {
456  phaseModel& phase = phases[phasei];
457  phase.rho()() += phase.thermo().psi()*(p_rgh - p_rgh_0);
458  }
459 
460  // Correct p_rgh for consistency with p and the updated densities
461  rho = fluid.rho();
462  p_rgh = p - rho*gh;
463  p_rgh.correctBoundaryConditions();
464 }
Foam::fvc::reconstruct
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> reconstruct(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcReconstruct.C:54
Foam::fvc::snGrad
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > snGrad(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcSnGrad.C:45
p
p
Definition: pEqn.H:62
phid
surfaceScalarField phid("phid", fvc::interpolate(psi) *((mesh.Sf() &fvc::interpolate(HbyA))+rhorAUf *fvc::ddtCorr(rho, U, phi)/fvc::interpolate(rho)))
ghf
const surfaceScalarField & ghf
Definition: setRegionFluidFields.H:35
Foam::dimVelocity
const dimensionSet dimVelocity
fluid
multiphaseSystem & fluid
Definition: createFields.H:10
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:216
forAll
forAll(phases, phasei)
Definition: pEqn.H:5
pMin
dimensionedScalar pMin("pMin", dimPressure, fluid)
Foam::MULES::interpolate
tmp< surfaceScalarField > interpolate(const RhoType &rho)
Definition: IMULESTemplates.C:40
Foam::fvc::div
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:47
g
const dimensionedVector & g
Definition: setRegionFluidFields.H:33
setSnGrad< fixedFluxPressureFvPatchScalarField >
setSnGrad< fixedFluxPressureFvPatchScalarField >(p_rgh.boundaryField(),(phiHbyA.boundaryField() - MRF.relative(mesh.Sf().boundaryField() &U.boundaryField()))/(mesh.magSf().boundaryField() *rAUf.boundaryField()))
Foam::correction
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix.
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::fvc::average
tmp< GeometricField< Type, fvPatchField, volMesh > > average(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Area-weighted average a surfaceField creating a volField.
Definition: fvcAverage.C:46
phi
phi
Definition: pEqn.H:20
forAllConstIter
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
K
CGAL::Exact_predicates_exact_constructions_kernel K
Definition: CGALTriangulation3DKernel.H:56
Foam::fvc::laplacian
tmp< GeometricField< Type, fvPatchField, volMesh > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcLaplacian.C:45
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:40
solve
rhoEqn solve()
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
Foam::fvScalarMatrix
fvMatrix< scalar > fvScalarMatrix
Definition: fvMatricesFwd.H:42
Foam::fvc::Su
tmp< GeometricField< Type, fvPatchField, volMesh > > Su(const GeometricField< Type, fvPatchField, volMesh > &su, const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvcSup.C:44
HbyAs
PtrList< volVectorField > HbyAs(fluid.phases().size())
UEqns
PtrList< fvVectorMatrix > UEqns(fluid.phases().size())
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
phiHbyAs
PtrList< surfaceScalarField > phiHbyAs(fluid.phases().size())
MRF
IOMRFZoneList & MRF
Definition: setRegionFluidFields.H:15
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
gh
const volScalarField & gh
Definition: setRegionFluidFields.H:34
p_rgh_0
volScalarField p_rgh_0(p_rgh)
rho
rho
Definition: pEqn.H:3
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:55
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
phasei
label phasei
Definition: pEqn.H:37
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:52
phiFs
PtrList< surfaceScalarField > phiFs(phases.size())
phib
phib
Definition: pEqn.H:191
phases
multiphaseSystem::phaseModelList & phases
Definition: createFields.H:11
patchi
label patchi
Definition: getPatchFieldScalar.H:1
alpharAUfs
PtrList< surfaceScalarField > alpharAUfs(phases.size())
alphafs
PtrList< surfaceScalarField > alphafs(phases.size())
ghSnGradRho
surfaceScalarField ghSnGradRho(ghf *fvc::snGrad(rho) *mesh.magSf())
phase2
phaseModel & phase2
Definition: createFields.H:13
K
K
Definition: pEqn.H:85
pimple
const dictionary & pimple
Definition: readFluidMultiRegionPIMPLEControls.H:1
phiHbyA
phiHbyA
Definition: pEqn.H:21
Foam::fvc::ddt
tmp< GeometricField< Type, fvPatchField, volMesh > > ddt(const dimensioned< Type > dt, const fvMesh &mesh)
Definition: fvcDdt.C:45
rAUs
PtrList< volScalarField > rAUs(fluid.phases().size())
Foam::fvc::Sp
tmp< GeometricField< Type, fvPatchField, volMesh > > Sp(const volScalarField &sp, const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvcSup.C:67
Foam::Swap
void Swap(T &a, T &b)
Definition: Swap.H:43
p_rgh
volScalarField & p_rgh
Definition: setRegionFluidFields.H:31
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
fvOptions
fv::options & fvOptions
Definition: setRegionFluidFields.H:16
phase1
phaseModel & phase1
Definition: createFields.H:12
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:190
rAUf
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU))