correctPhi.H
Go to the documentation of this file.
1if (mesh.changing())
2{
3 volVectorField::Boundary& bfld = U.boundaryFieldRef();
4 forAll(bfld, patchi)
5 {
6 if (bfld[patchi].fixesValue())
7 {
8 bfld[patchi].initEvaluate();
9 }
10 }
11
12 surfaceScalarField::Boundary& phiBfld = phi.boundaryFieldRef();
13 forAll(bfld, patchi)
14 {
15 if (bfld[patchi].fixesValue())
16 {
17 bfld[patchi].evaluate();
18
19 phiBfld[patchi] = bfld[patchi] & mesh.Sf().boundaryField()[patchi];
20 }
21 }
22}
23 // Initialize BCs list for pcorr to zero-gradient
24 wordList pcorrTypes
25 (
26 p.boundaryField().size(),
28 );
29
30 // Set BCs of pcorr to fixed-value for patches at which p is fixed
31 forAll(p.boundaryField(), patchi)
32 {
33 if (p.boundaryField()[patchi].fixesValue())
34 {
36 }
37 }
38
39 volScalarField pcorr
40 (
41 IOobject
42 (
43 "pcorr",
44 runTime.timeName(),
45 mesh,
46 IOobject::NO_READ,
47 IOobject::NO_WRITE
48 ),
49 mesh,
50 dimensionedScalar(p.dimensions(), Zero),
52 );
53
54{
55 dimensionedScalar rAUf("rAUf", dimTime, 1.0);
56
57 const cellCellStencilObject& overlap = Stencil::New(mesh);
58 const labelList& cellTypes = overlap.cellTypes();
59 const labelIOList& zoneIDs = overlap.zoneID();
60
61 while (pimple.correctNonOrthogonal())
62 {
63 label nZones = gMax(zoneIDs)+1;
64
65 //label refCellI2 = -1;
66 labelList refCells(nZones, -1);
67 labelList refZones(nZones, -1);
68
69 forAll(zoneIDs, cellI)
70 {
71 label zoneId = zoneIDs[cellI];
72 if
73 (
74 refCells[zoneId] == -1
75 && cellTypes[cellI] == cellCellStencil::CALCULATED
76 && refZones[zoneId] == -1
77 )
78 {
79 refCells[zoneId] = cellI;
80 refZones[zoneId] = zoneId;
81 }
82 }
83
84 fvScalarMatrix pcorrEqn
85 (
86 fvm::laplacian(rAUf, pcorr) == fvc::div(phi)
87 );
88
89
90 // Only set reference for cells that are CALCULATED
91 {
92 DynamicList<label> validCells(refCells.size());
93 forAll(refCells, zoneId)
94 {
95 if (refCells[zoneId] != -1)
96 {
97 validCells.append(refCells[zoneId]);
98 }
99 }
100
101 pcorrEqn.setReferences
102 (
103 validCells,
104 scalar(0),
105 true
106 );
107 }
108
109 const dictionary& d = mesh.solver
110 (
111 pcorr.select
112 (
113 pimple.finalInnerIter()
114 )
115 );
116 //Bypass virtual layer
117 mesh.fvMesh::solve(pcorrEqn, d);
118
119 if (pimple.finalNonOrthogonalIter())
120 {
121 phi -= pcorrEqn.flux();
122 }
123 }
124}
surfaceScalarField & phi
pimpleControl & pimple
U
Definition: pEqn.H:72
volScalarField & p
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))
const cellCellStencilObject & overlap
Definition: correctPhi.H:57
const labelIOList & zoneIDs
Definition: correctPhi.H:59
const labelList & cellTypes
Definition: correctPhi.H:58
label nZones
#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.