3 if (piston().patchID().active() && offSet() > SMALL)
8 label pistonPatchID = piston().patchID().index();
10 scalar zPist = max(boundary()[pistonPatchID].patch().localPoints()).z();
12 Info << "zPist = " << zPist << endl;
14 scalar zPistV = zPist + offSet();
16 Info << "zPistV = " << zPistV << endl;
18 labelList zone1(faceCentres().size());
19 boolList flipZone1(faceCentres().size(), false);
20 label nZoneFaces1 = 0;
22 bool foundAtLeastOne = false;
23 scalar zHigher = GREAT;
24 scalar zLower = GREAT;
28 forAll (faceCentres(), faceI)
30 scalar zc = faceCentres()[faceI].z();
31 vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]);
32 scalar dd = n & vector(0,0,1);
36 if (zPistV - zc > 0 && zPistV - zc < dl)
42 if (zc - zPistV > 0 && zc - zPistV < dh)
51 && zc < zPistV + delta()
54 foundAtLeastOne = true;
55 if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
57 flipZone1[nZoneFaces1] = true;
60 zone1[nZoneFaces1] = faceI;
66 Info << "Gambit mesh, found " << nZoneFaces1 << " faces for layer addition removal" << endl;
67 Info << "Piston patch size = " << boundaryMesh()[piston().patchID().index()].size() << endl;
69 // if no cut was found use the layer above
73 Info << "NOT FOUND AT LEAST ONE" << endl;
74 Info << "zHigher = " << zHigher << endl;
78 forAll (faceCentres(), faceI)
80 scalar zc = faceCentres()[faceI].z();
81 vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]);
82 scalar dd = n & vector(0,0,1);
89 && zc < zPistV + delta()
92 if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
94 flipZone1[nZoneFaces1] = true;
97 zone1[nZoneFaces1] = faceI;
105 zone1.setSize(nZoneFaces1);
106 flipZone1.setSize(nZoneFaces1);
124 // Construct point zones
127 // Points which don't move (= cylinder head)
128 dynamicLabelList headPoints(nPoints() / 10);
130 // Points below the piston which moves with the piston displacement
131 dynamicLabelList pistonPoints(nPoints() / 10);
133 label nHeadPoints = 0;
135 forAll (points(), pointI)
137 scalar zCoord = points()[pointI].z();
139 if (zCoord > deckHeight() - delta())
141 headPoints.append(pointI);
143 //Info<< "HeadPoint:" << pointI << " coord:" << points[pointI]
146 else if (zCoord < zPistV + delta())
148 pistonPoints.append(pointI);
149 //Info<< "PistonPoint:" << pointI << " coord:" << points[pointI]
154 Info << "Number of head points = " << nHeadPoints << endl;
177 pistonPoints.shrink(),
186 else if(piston().patchID().active() && offSet() <= SMALL)
188 label pistonPatchID = piston().patchID().index();
190 const polyPatch& pistonPatch =
191 boundaryMesh()[piston().patchID().index()];
193 labelList pistonPatchLabels(pistonPatch.size(), pistonPatch.start());
195 forAll (pistonPatchLabels, i)
197 pistonPatchLabels[i] += i;
207 boolList(pistonPatchLabels.size(), true),
213 // Construct point zones
215 scalar zPistV = max(boundary()[pistonPatchID].patch().localPoints()).z();
217 // Points which don't move (= cylinder head)
218 dynamicLabelList headPoints(nPoints() / 10);
220 // Points below the piston which moves with the piston displacement
221 dynamicLabelList pistonPoints(nPoints() / 10);
223 label nHeadPoints = 0;
225 forAll (points(), pointI)
227 scalar zCoord = points()[pointI].z();
229 if (zCoord > deckHeight() - delta())
231 headPoints.append(pointI);
233 //Info<< "HeadPoint:" << pointI << " coord:" << points[pointI]
236 else if (zCoord < zPistV + delta())
238 pistonPoints.append(pointI);
239 //Info<< "PistonPoint:" << pointI << " coord:" << points[pointI]
244 Info << "Number of head points = " << nHeadPoints << endl;
267 pistonPoints.shrink(),
280 // Add the piston zone
281 if (piston().patchID().active() && offSet() > SMALL)
286 label pistonPatchID = piston().patchID().index();
288 scalar zPist = max(boundary()[pistonPatchID].patch().localPoints()).z();
290 Info << "zPist = " << zPist << endl;
292 scalar zPistV = zPist + offSet();
294 Info << "zPistV = " << zPistV << endl;
296 labelList zone1(faceCentres().size());
297 boolList flipZone1(faceCentres().size(), false);
298 label nZoneFaces1 = 0;
300 bool foundAtLeastOne = false;
301 scalar zHigher = GREAT;
302 scalar zLower = GREAT;
306 forAll (faceCentres(), faceI)
308 scalar zc = faceCentres()[faceI].z();
309 vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]);
310 scalar dd = n & vector(0,0,1);
314 if (zPistV - zc > 0 && zPistV - zc < dl)
320 if (zc - zPistV > 0 && zc - zPistV < dh)
328 zc > zPistV - delta()
329 && zc < zPistV + delta()
332 foundAtLeastOne = true;
333 if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
335 flipZone1[nZoneFaces1] = true;
338 zone1[nZoneFaces1] = faceI;
344 Info << "Gambit mesh, found " << nZoneFaces1 << " faces for layer addition removal" << endl;
345 Info << "Piston patch size = " << boundaryMesh()[piston().patchID().index()].size() << endl;
347 // if no cut was found use the layer above
348 if (!foundAtLeastOne)
351 Info << "NOT FOUND AT LEAST ONE" << endl;
352 Info << "zHigher = " << zHigher << endl;
356 forAll (faceCentres(), faceI)
358 scalar zc = faceCentres()[faceI].z();
359 vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]);
360 scalar dd = n & vector(0,0,1);
366 zc > zPistV - delta()
367 && zc < zPistV + delta()
370 if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
372 flipZone1[nZoneFaces1] = true;
375 zone1[nZoneFaces1] = faceI;
383 Info << "zone1.setSize()" << endl;
385 zone1.setSize(nZoneFaces1);
386 flipZone1.setSize(nZoneFaces1);
388 Info << "flip.setSize()" << endl;
402 Info << "fz[nFaceZones]" << endl;
407 // Construct point zones
410 // Points below the piston which moves with the piston displacement
411 dynamicLabelList pistonPoints(nPoints() / 10);
413 forAll (points(), pointI)
415 scalar zCoord = points()[pointI].z();
417 if (zCoord < zPistV + delta())
419 pistonPoints.append(pointI);
420 //Info<< "PistonPoint:" << pointI << " coord:" << points[pointI]
431 pistonPoints.shrink(),
441 FatalErrorIn("void layerSmooth::addLayerSmoothMeshModifiers()")
442 << "the mesh is invalid, because the piston patch does not exist or"
443 << "or the offset value is equal to zero"
444 << abort(FatalError);
447 Info << "Added face zones for piston" << endl;