2 if (piston().patchID().active())
7 Info << "Adding face zone for piston layer addition/removal" << endl;
9 label pistonPatchID = piston().patchID().index();
11 scalarField zPistonValves(valves().size() + 1,max(boundary()[pistonPatchID].patch().localPoints()).z());
13 scalarField zPistonValvesOffset = zPistonValves + offSet();
15 labelListList zonePiston(valves().size()+1);
16 boolListList flipZonePiston(valves().size() + 1);
17 labelList nZoneFacesPiston(valves().size() + 1, 0);
18 boolList foundOneFace(valves().size() + 1, false);
19 scalarList zHigher(valves().size() + 1, GREAT);
20 scalarList zLower(valves().size() + 1, GREAT);
21 scalarList dh(valves().size() + 1, GREAT);
22 scalarList dl(valves().size() + 1, GREAT);
24 forAll(zonePiston, zoneI)
26 zonePiston[zoneI].setSize(faceCentres().size());
27 flipZonePiston[zoneI].setSize(faceCentres().size());
28 flipZonePiston[zoneI] = false;
31 forAll (faceCentres(), faceI)
33 bool foundInValve = false;
35 scalar zc = faceCentres()[faceI].z();
37 vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]);
38 scalar dd = n & vector(0,0,1);
40 forAll(valves(), valveI)
43 if(inValve(faceCentres()[faceI], valveI))
47 scalar zPistV = zPistonValvesOffset[valveI];
51 if (zPistV - zc > 0 && zPistV - zc < dl[valveI])
54 dl[valveI] = zPistV - zc;
57 if (zc - zPistV > 0 && zc - zPistV < dh[valveI])
60 dh[valveI] = zc - zHigher[valveI];
66 && zc < zPistV + delta()
70 foundOneFace[valveI] = true;
72 if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
74 flipZonePiston[valveI][nZoneFacesPiston[valveI]] = true;
77 zonePiston[valveI][nZoneFacesPiston[valveI]] = faceI;
78 nZoneFacesPiston[valveI]++;
87 label valveSize = valves().size();
89 scalar zPistV = zPistonValvesOffset[valveSize];
93 if (zPistV - zc > 0 && zPistV - zc < dl[valveSize])
95 zLower[valveSize] = zc;
96 dl[valveSize] = zPistV - zc;
99 if (zc - zPistV > 0 && zc - zPistV < dh[valveSize])
101 zHigher[valveSize] = zc;
102 dh[valveSize] = zc - zHigher[valveSize];
107 zc > zPistV - delta()
108 && zc < zPistV + delta()
112 foundOneFace[valveSize] = true;
114 if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
116 flipZonePiston[valveSize][nZoneFacesPiston[valveSize]] = true;
119 zonePiston[valveSize][nZoneFacesPiston[valveSize]] = faceI;
120 nZoneFacesPiston[valveSize]++;
128 // if no cut was found use the layer above
130 forAll(valves(), valveI)
133 if (!foundOneFace[valveI])
135 zPistonValvesOffset[valveI] = zHigher[valveI];
139 if(!foundOneFace[valves().size()])
141 zPistonValvesOffset[valves().size()] = zHigher[valves().size()];
144 forAll (faceCentres(), faceI)
147 bool foundInValve = false;
149 scalar zc = faceCentres()[faceI].z();
151 vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]);
152 scalar dd = n & vector(0,0,1);
154 forAll(valves(), valveI)
157 if(!foundOneFace[valveI])
160 scalar zPistV = zPistonValvesOffset[valveI];
163 if(inValve(faceCentres()[faceI], valveI))
172 zc > zPistV - delta()
173 && zc < zPistV + delta()
177 if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
179 flipZonePiston[valveI][nZoneFacesPiston[valveI]] = true;
182 zonePiston[valveI][nZoneFacesPiston[valveI]] = faceI;
183 nZoneFacesPiston[valveI]++;
191 if(!foundInValve && !foundOneFace[valves().size()])
193 label valveSize = valves().size();
194 scalar zPistV = zPistonValvesOffset[valveSize];
201 zc > zPistV - delta()
202 && zc < zPistV + delta()
205 if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
207 flipZonePiston[valveSize][nZoneFacesPiston[valveSize]] = true;
210 zonePiston[valveSize][nZoneFacesPiston[valveSize]] = faceI;
211 nZoneFacesPiston[valveSize]++;
217 forAll(valves(), valveI)
219 zonePiston[valveI].setSize(nZoneFacesPiston[valveI]);
220 flipZonePiston[valveI].setSize(nZoneFacesPiston[valveI]);
226 "pistonLayerFacesV" + Foam::name(valveI + 1),
228 flipZonePiston[valveI],
238 label valveSize = valves().size();
239 zonePiston[valveSize].setSize(nZoneFacesPiston[valveSize]);
240 flipZonePiston[valveSize].setSize(nZoneFacesPiston[valveSize]);
247 zonePiston[valveSize],
248 flipZonePiston[valveSize],
258 forAll(valves(), valveI)
261 labelList movingCells(nCells());
263 label nMovingCells = 0;
265 forAll(cellCentres(),cellI)
267 const vector& v = cellCentres()[cellI];
273 v.z() < zPistonValvesOffset[valveI]
276 movingCells[nMovingCells] = cellI;
282 movingCells.setSize(nMovingCells);
283 Info << "Number of cells in the moving region poppet valve: " << nMovingCells << endl;
289 "movingCellsPistonV"+ Foam::name(valveI + 1),
302 label valveSize = valves().size();
303 labelList movingCells(nCells());
305 label nMovingCells = 0;
307 forAll(cellCentres(),cellI)
309 const vector& v = cellCentres()[cellI];
311 bool fallInValve = false;
312 forAll(valves(), valveI)
314 if(inValve(v, valveI))
324 v.z() < zPistonValvesOffset[valveSize]
327 movingCells[nMovingCells] = cellI;
333 movingCells.setSize(nMovingCells);
334 Info << "Number of cells in the moving region poppet valve: " << nMovingCells << endl;