pEqn.H
Go to the documentation of this file.
1 rho = thermo.rho();
2 rho.relax();
3 
4 // Thermodynamic density needs to be updated by psi*d(p) after the
5 // pressure solution
7 
8 const volScalarField rAU("rAU", 1.0/UEqn.A());
10 
11 tmp<volScalarField> rAtU
12 (
13  pimple.consistent()
14  ? volScalarField::New("rAtU", 1.0/(1.0/rAU - UEqn.H1()))
15  : tmp<volScalarField>(nullptr)
16 );
17 tmp<surfaceScalarField> rhorAtUf
18 (
19  pimple.consistent()
21  : tmp<surfaceScalarField>(nullptr)
22 );
23 
24 const volScalarField& rAAtU = pimple.consistent() ? rAtU() : rAU;
25 const surfaceScalarField& rhorAAtUf =
26  pimple.consistent() ? rhorAtUf() : rhorAUf;
27 
29 
30 if (pimple.nCorrPiso() <= 1)
31 {
32  tUEqn.clear();
33 }
34 
36 (
37  "phiHbyA",
39  + MRF.zeroFilter(rhorAUf*fvc::ddtCorr(rho, U, phi, rhoUf))
40 );
41 
42 MRF.makeRelative(fvc::interpolate(rho), phiHbyA);
43 
44 // Update the pressure BCs to ensure flux consistency
45 constrainPressure(p, rho, U, phiHbyA, rhorAAtUf, MRF);
46 
48 
49 bool adjustMass = false;
50 
51 if (pimple.transonic())
52 {
53  const surfaceScalarField phid
54  (
55  "phid",
57  );
58 
59  // Subtract the compressible part
60  // The resulting flux will be zero for a perfect gas
61  phiHbyA -= fvc::interpolate(psi*p)*phiHbyA/fvc::interpolate(rho);
62 
63  if (pimple.consistent())
64  {
65  phiHbyA += (rhorAAtUf - rhorAUf)*fvc::snGrad(p)*mesh.magSf();
66  HbyA += (rAAtU - rAU)*fvc::grad(p);
67  }
68 
69  fvScalarMatrix pDDtEqn
70  (
72  + fvc::div(phiHbyA) + fvm::div(phid, p)
73  ==
74  fvModels.source(psi, p, rho.name())
75  );
76 
77  while (pimple.correctNonOrthogonal())
78  {
79  fvScalarMatrix pEqn(pDDtEqn - fvm::laplacian(rhorAAtUf, p));
80 
81  // Relax the pressure equation to ensure diagonal-dominance
82  pEqn.relax();
83 
84  pEqn.setReference
85  (
86  pressureReference.refCell(),
87  pressureReference.refValue()
88  );
89 
90  pEqn.solve();
91 
92  if (pimple.finalNonOrthogonalIter())
93  {
94  phi = phiHbyA + pEqn.flux();
95  }
96  }
97 }
98 else
99 {
100  if (mesh.schemes().steady())
101  {
102  adjustMass = adjustPhi(phiHbyA, U, p);
103  }
104 
105  if (pimple.consistent())
106  {
107  phiHbyA += (rhorAAtUf - rhorAUf)*fvc::snGrad(p)*mesh.magSf();
108  HbyA += (rAAtU - rAU)*fvc::grad(p);
109  }
110 
111  fvScalarMatrix pDDtEqn
112  (
114  + fvc::div(phiHbyA)
115  ==
116  fvModels.source(psi, p, rho.name())
117  );
118 
119  while (pimple.correctNonOrthogonal())
120  {
121  fvScalarMatrix pEqn(pDDtEqn - fvm::laplacian(rhorAAtUf, p));
122 
123  pEqn.setReference
124  (
125  pressureReference.refCell(),
126  pressureReference.refValue()
127  );
128 
129  pEqn.solve();
130 
131  if (pimple.finalNonOrthogonalIter())
132  {
133  phi = phiHbyA + pEqn.flux();
134  }
135  }
136 }
137 
138 if (mesh.schemes().steady())
139 {
141 }
142 else
143 {
144  const bool constrained = fvConstraints.constrain(p);
145 
146  // Thermodynamic density update
147  thermo.correctRho(psi*p - psip0);
148 
149  if (constrained)
150  {
151  rho = thermo.rho();
152  }
153 
154  #include "rhoEqn.H"
156 }
157 
158 // Explicitly relax pressure for momentum corrector
159 p.relax();
160 
161 U = HbyA - rAAtU*fvc::grad(p);
162 U.correctBoundaryConditions();
164 K = 0.5*magSqr(U);
165 
166 if (mesh.schemes().steady())
167 {
169 }
170 
171 // For steady compressible closed-volume cases adjust the pressure level
172 // to obey overall mass continuity
173 if (adjustMass && !thermo.incompressible())
174 {
177  p.correctBoundaryConditions();
178 }
179 
180 if (mesh.schemes().steady() || pimple.simpleRho() || adjustMass)
181 {
182  rho = thermo.rho();
183 }
184 
185 // Correct rhoUf if the mesh is moving
187 
188 if (mesh.schemes().steady() || pimple.simpleRho())
189 {
190  rho.relax();
191 }
192 
193 if (thermo.dpdt())
194 {
195  dpdt = fvc::ddt(p);
196 
197  if (mesh.moving())
198  {
199  dpdt -= fvc::div(fvc::meshPhi(rho, U), p);
200  }
201 }
tmp< volScalarField > rAtU(pimple.consistent() ? volScalarField::New("rAtU", 1.0/(1.0/rAU - UEqn.H1())) :tmp< volScalarField >(nullptr))
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix.
rAU
Definition: pEqn.H:1
pressureReference & pressureReference
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
fvMatrix< scalar > fvScalarMatrix
Definition: fvMatricesFwd.H:42
fluidReactionThermo & thermo
Definition: createFields.H:28
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
pimpleNoLoopControl & pimple
dimensionedScalar initialMass
Definition: createFields.H:68
U
Definition: pEqn.H:72
mixture MRF().makeRelative(phiHbyA)
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho *rAU))
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:47
tmp< GeometricField< typename flux< Type >::type, fvsPatchField, surfaceMesh > > ddtCorr(const GeometricField< Type, fvPatchField, volMesh > &U, const GeometricField< Type, fvsPatchField, surfaceMesh > &Uf)
Definition: fvcDdt.C:170
MRF makeRelative(fvc::interpolate(rho), phiHbyA)
tmp< surfaceScalarField > rhorAtUf(pimple.consistent() ? surfaceScalarField::New("rhoRAtUf", fvc::interpolate(rho *rAtU())) :tmp< surfaceScalarField >(nullptr))
Calculates and prints the continuity errors.
dimensioned< Type > domainIntegrate(const GeometricField< Type, fvPatchField, volMesh > &vf)
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:59
fvMesh & mesh
tmp< GeometricField< Type, fvPatchField, volMesh > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcLaplacian.C:45
CGAL::Exact_predicates_exact_constructions_kernel K
p
Definition: pEqn.H:125
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:58
volScalarField & dpdt
phiHbyA
Definition: pEqn.H:30
Foam::fvConstraints & fvConstraints
bool adjustMass
Definition: pEqn.H:49
const volScalarField & psi
tmp< volVectorField > constrainHbyA(const tmp< volVectorField > &tHbyA, const volVectorField &U, const volScalarField &p)
Definition: constrainHbyA.C:34
const volScalarField psip0(psi *p)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
tmp< fvVectorMatrix > tUEqn(fvm::ddt(rho, U)+fvm::div(phi, U)+MRF.DDt(rho, U)+turbulence->divDevTau(U)==fvModels.source(rho, U))
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.
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
Foam::fvModels & fvModels
phi
Definition: pEqn.H:98
adjustPhi(phiHbyA, Urel, p)
void correctRhoUf(autoPtr< surfaceVectorField > &rhoUf, const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const MRFType &MRF)
volVectorField & HbyA
Definition: pEqn.H:13
tmp< surfaceScalarField > meshPhi(const volVectorField &U)
Definition: fvcMeshPhi.C:34
Calculates and prints the continuity errors.
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
autoPtr< surfaceVectorField > rhoUf
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > snGrad(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcSnGrad.C:45
constrainPressure(p, rho, U, phiHbyA, rhorAUf, MRF)
rho
Definition: pEqn.H:1
fvVectorMatrix & UEqn
Definition: UEqn.H:13