correctPhi.H
Go to the documentation of this file.
1{
2 if (mesh.changing())
3 {
4 volVectorField::Boundary& bfld = U.boundaryFieldRef();
5 forAll(bfld, patchi)
6 {
7 if (bfld[patchi].fixesValue())
8 {
9 bfld[patchi].initEvaluate();
10 }
11 }
12
13 surfaceScalarField::Boundary& phiBfld = phi.boundaryFieldRef();
14 forAll(bfld, patchi)
15 {
16 if (bfld[patchi].fixesValue())
17 {
18 bfld[patchi].evaluate();
19
20 phiBfld[patchi] =
21 bfld[patchi]
22 & mesh.Sf().boundaryField()[patchi];
23 }
24 }
25 }
26
28 (
29 p_rgh.boundaryField().size(),
31 );
32
33 for (label i=0; i<p_rgh.boundaryField().size(); i++)
34 {
35 if (p_rgh.boundaryField()[i].fixesValue())
36 {
38 }
39 }
40
41 volScalarField pcorr
42 (
43 IOobject
44 (
45 "pcorr",
46 runTime.timeName(),
47 mesh,
48 IOobject::NO_READ,
49 IOobject::NO_WRITE
50 ),
51 mesh,
52 dimensionedScalar(p_rgh.dimensions(), Zero),
54 );
55
56 if (pcorr.needReference())
57 {
58 fvc::makeRelative(phi, U);
60 fvc::makeAbsolute(phi, U);
61 }
62
63 mesh.setFluxRequired(pcorr.name());
64
65 dimensionedScalar rAUf("rAUf", dimTime/rho.dimensions(), 1.0);
66
67 const cellCellStencilObject& overlap = Stencil::New(mesh);
68 const labelList& cellTypes = overlap.cellTypes();
69 const labelIOList& zoneIDs = overlap.zoneID();
70
71 while (pimple.correctNonOrthogonal())
72 {
73 label nZones = gMax(zoneIDs)+1;
74 //label refCellI2 = -1;
75
76 labelList refCells(nZones, -1);
77 labelList refZones(nZones, -1);
78
79 forAll(zoneIDs, cellI)
80 {
81 label zoneId = zoneIDs[cellI];
82 if
83 (
84 refCells[zoneId] == -1
85 && cellTypes[cellI] == cellCellStencil::CALCULATED
86 && refZones[zoneId] == -1
87 )
88 {
89 refCells[zoneId] = cellI;
90 refZones[zoneId] = zoneId;
91 }
92 }
93
94 fvScalarMatrix pcorrEqn
95 (
96 fvm::laplacian(rAUf, pcorr) == fvc::div(phi)
97 );
98
99 // Only set reference for cells that are CALCULATED
100 {
101 DynamicList<label> validCells(refCells.size());
102 forAll(refCells, zoneId)
103 {
104 if (refCells[zoneId] != -1)
105 {
106 validCells.append(refCells[zoneId]);
107 }
108 }
109
110 pcorrEqn.setReferences
111 (
112 validCells,
113 scalar(0),
114 true
115 );
116 }
117
118
119 const dictionary& d = mesh.solver
120 (
121 pcorr.select
122 (
123 pimple.finalInnerIter()
124 )
125 );
126
127 //Bypass virtual layer
128 mesh.fvMesh::solve(pcorrEqn, d);
129
130 if (pimple.finalNonOrthogonalIter())
131 {
132 phi -= pcorrEqn.flux();
133 }
134 }
135}
volScalarField & p_rgh
surfaceScalarField & phi
pimpleControl & pimple
U
Definition: pEqn.H:72
volScalarField pcorr(IOobject("pcorr", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), mesh, dimensionedScalar(p.dimensions(), Zero), pcorrTypes)
wordList pcorrTypes(p.boundaryField().size(), zeroGradientFvPatchScalarField::typeName)
dynamicFvMesh & mesh
engineTime & runTime
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU))
adjustPhi(phiHbyA, U, p_rgh)
const cellCellStencilObject & overlap
Definition: correctPhi.H:57
const labelIOList & zoneIDs
Definition: correctPhi.H:59
const labelList & cellTypes
Definition: correctPhi.H:58
label nZones
List< word > wordList
A List of words.
Definition: fileName.H:63
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
static const char *const typeName
The type name used in ensight case files.