Formatting
[foam-extend-3.2.git] / src / engine / engineTopoChangerMesh / thoboisMesh / addPistonFacesPointZonesThoboisMesh.H
blob08012567b10ff4dbcb63cdbcecd0b41fef6f8f69
2     // Add the piston zone
3     if (piston().patchID().active() && offSet() > SMALL)
4     {
6         // Piston position
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 dh = GREAT;
25         scalar dl = GREAT;
27         forAll (faceCentres(), faceI)
28         {
29             scalar zc = faceCentres()[faceI].z();
30             vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]);
31             scalar dd = n & vector(0,0,1);
33             if (mag(dd) > 0.1)
34             {
35                 if (zPistV - zc > 0 && zPistV - zc < dl)
36                 {
37                     dl = zPistV - zc;
38                 }
40                 if (zc - zPistV > 0 && zc - zPistV < dh)
41                 {
42                     zHigher = zc;
43                     dh = zc - zHigher;
44                 }
46                 if
47                 (
48                     zc > zPistV - delta()
49                     && zc < zPistV + delta()
50                 )
51                 {
52                     foundAtLeastOne = true;
53                     if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
54                     {
55                         flipZone1[nZoneFaces1] = true;
56                     }
58                     zone1[nZoneFaces1] = faceI;
59                     nZoneFaces1++;
60                 }
61             }
62         }
64         Info << "Gambit mesh, found " << nZoneFaces1 << " faces for layer addition removal" << endl;
65         Info << "Piston patch size = " << boundaryMesh()[piston().patchID().index()].size() << endl;
67         // if no cut was found use the layer above
68         if (!foundAtLeastOne)
69         {
71             Info << "NOT FOUND AT LEAST ONE" << endl;
72             Info << "zHigher = " << zHigher << endl;
74             zPistV = zHigher;
76             forAll (faceCentres(), faceI)
77             {
78                 scalar zc = faceCentres()[faceI].z();
79                 vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]);
80                 scalar dd = n & vector(0,0,1);
81                 if (mag(dd) > 0.1)
82                 {
84                     if
85                     (
86                         zc > zPistV - delta()
87                         && zc < zPistV + delta()
88                     )
89                     {
90                         if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
91                         {
92                             flipZone1[nZoneFaces1] = true;
93                         }
95                         zone1[nZoneFaces1] = faceI;
96                         nZoneFaces1++;
97                     }
98                 }
99             }
101         }
103         zone1.setSize(nZoneFaces1);
104         flipZone1.setSize(nZoneFaces1);
106 //        fz[nFaceZones]=
107         fz.append
108         (
109             new faceZone
110             (
111                 "pistonLayerFaces",
112                 zone1,
113                 flipZone1,
114                 nFaceZones,
115                 faceZones()
116             )
117         );
119         nFaceZones++;
122         // Construct point zones
125         // Points below the piston which moves with the piston displacement
126         DynamicList<label> pistonPoints(nPoints() / 10);
128         forAll (points(), pointI)
129         {
130             scalar zCoord = points()[pointI].z();
132             if (zCoord > deckHeight() - delta())
133             {
134             }
135             else if (zCoord < zPistV + delta())
136             {
137                 pistonPoints.append(pointI);
138                 //Info<< "PistonPoint:" << pointI << " coord:" << points[pointI]
139                 //    << endl;
140             }
141         }
144         pz.append
145         (
146             new pointZone
147             (
148                 "pistonPoints",
149                 pistonPoints.shrink(),
150                 nPointZones,
151                 pointZones()
152             )
153         );
155         nPointZones++;
157     }
158     else if(piston().patchID().active() && offSet() <= SMALL)
159     {
160         label pistonPatchID = piston().patchID().index();
162         const polyPatch& pistonPatch =
163             boundaryMesh()[piston().patchID().index()];
165         labelList pistonPatchLabels(pistonPatch.size(), pistonPatch.start());
167         forAll (pistonPatchLabels, i)
168         {
169             pistonPatchLabels[i] += i;
170         }
172 //        fz[nFaceZones] =
173         fz.append
174         (
175             new faceZone
176             (
177                 "pistonLayerFaces",
178                 pistonPatchLabels,
179                 boolList(pistonPatchLabels.size(), true),
180                 nFaceZones,
181                 faceZones()
182             )
183         );
184         nFaceZones++;
185         // Construct point zones
187         scalar zPistV = max(boundary()[pistonPatchID].patch().localPoints()).z();
189         // Points below the piston which moves with the piston displacement
190         DynamicList<label> pistonPoints(nPoints() / 10);
192         forAll (points(), pointI)
193         {
194             scalar zCoord = points()[pointI].z();
196             if (zCoord > deckHeight() - delta())
197             {
198             }
199             else if (zCoord < zPistV + delta())
200             {
201                 pistonPoints.append(pointI);
202                 //Info<< "PistonPoint:" << pointI << " coord:" << points[pointI]
203                 //    << endl;
204             }
205         }
207         pz.append
208         (
209             new pointZone
210             (
211                 "pistonPoints",
212                 pistonPoints.shrink(),
213                 nPointZones,
214                 pointZones()
215             )
216         );
218         nPointZones++;
220     }