Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / thoboisMesh / addPistonFacesPointZonesThoboisMesh.H
blob997a5dd36b84460ea9e398400b45b3ab671069ed
2     // Add the piston zone
3     if (piston().patchID().active() && offSet() > SMALL)
4     {
6         // Piston position
7         
8         label pistonPatchID = piston().patchID().index();
9         
10         scalar zPist = max(boundary()[pistonPatchID].patch().localPoints()).z();
11         
12         Info << "zPist = " << zPist << endl;
14         scalar zPistV = zPist + offSet();
16         Info << "zPistV = " << zPistV << endl;
17         
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;
25         scalar dh = GREAT;
26         scalar dl = GREAT;
28         forAll (faceCentres(), faceI)
29         {
30             scalar zc = faceCentres()[faceI].z();
31             vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]);
32             scalar dd = n & vector(0,0,1);
34             if (mag(dd) > 0.1)
35             {
36                 if (zPistV - zc > 0 && zPistV - zc < dl)
37                 {
38                     zLower = zc;
39                     dl = zPistV - zc;
40                 }
41             
42                 if (zc - zPistV > 0 && zc - zPistV < dh)
43                 {
44                     zHigher = zc;
45                     dh = zc - zHigher;
46                 }
47             
48                 if
49                 (
50                     zc > zPistV - delta()
51                     && zc < zPistV + delta()
52                 )
53                 {
54                     foundAtLeastOne = true;
55                     if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
56                     {
57                         flipZone1[nZoneFaces1] = true;
58                     }
59                 
60                     zone1[nZoneFaces1] = faceI;
61                     nZoneFaces1++;
62                 }
63             }
64         }
65         
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
70         if (!foundAtLeastOne)
71         {
72             
73             Info << "NOT FOUND AT LEAST ONE" << endl;
74             Info << "zHigher = " << zHigher << endl;
75             
76             zPistV = zHigher;
78             forAll (faceCentres(), faceI)
79             {
80                 scalar zc = faceCentres()[faceI].z();
81                 vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]);
82                 scalar dd = n & vector(0,0,1);
83                 if (mag(dd) > 0.1)
84                 {
86                     if
87                     (
88                         zc > zPistV - delta()
89                         && zc < zPistV + delta()
90                     )
91                     {
92                         if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
93                         {
94                             flipZone1[nZoneFaces1] = true;
95                         }
96                     
97                         zone1[nZoneFaces1] = faceI;
98                         nZoneFaces1++;
99                     }
100                 }
101             }
103         }
105         zone1.setSize(nZoneFaces1);
106         flipZone1.setSize(nZoneFaces1);
107     
108 //        fz[nFaceZones]=
109         fz.append
110         (
111             new faceZone
112             (
113                 "pistonLayerFaces",
114                 zone1,
115                 flipZone1,
116                 nFaceZones,
117                 faceZones()
118             )                
119         );
120         
121         nFaceZones++;
124         // Construct point zones
126             
127         // Points below the piston which moves with the piston displacement
128         DynamicList<label> pistonPoints(nPoints() / 10);
129         
130         forAll (points(), pointI)
131         {
132             scalar zCoord = points()[pointI].z();
134             if (zCoord > deckHeight() - delta())
135             {
136             }
137             else if (zCoord < zPistV + delta())
138             {
139                 pistonPoints.append(pointI);
140                 //Info<< "PistonPoint:" << pointI << " coord:" << points[pointI]
141                 //    << endl;
142             }
143         }
144                     
146         pz.append
147         (
148             new pointZone
149             (
150                 "pistonPoints",
151                 pistonPoints.shrink(),
152                 nPointZones,
153                 pointZones()
154             )
155         );
157         nPointZones++;
159     }
160     else if(piston().patchID().active() && offSet() <= SMALL)
161     {
162         label pistonPatchID = piston().patchID().index();
163         
164         const polyPatch& pistonPatch =
165             boundaryMesh()[piston().patchID().index()];
167         labelList pistonPatchLabels(pistonPatch.size(), pistonPatch.start());
169         forAll (pistonPatchLabels, i)
170         {
171             pistonPatchLabels[i] += i;
172         }
174 //        fz[nFaceZones] =
175         fz.append
176         (
177             new faceZone
178             (
179                 "pistonLayerFaces",
180                 pistonPatchLabels,
181                 boolList(pistonPatchLabels.size(), true),
182                 nFaceZones,
183                 faceZones()
184             )
185         );
186         nFaceZones++;
187         // Construct point zones
189         scalar zPistV = max(boundary()[pistonPatchID].patch().localPoints()).z();
190             
191         // Points below the piston which moves with the piston displacement
192         DynamicList<label> pistonPoints(nPoints() / 10);
193         
194         forAll (points(), pointI)
195         {
196             scalar zCoord = points()[pointI].z();
198             if (zCoord > deckHeight() - delta())
199             {
200             }
201             else if (zCoord < zPistV + delta())
202             {
203                 pistonPoints.append(pointI);
204                 //Info<< "PistonPoint:" << pointI << " coord:" << points[pointI]
205                 //    << endl;
206             }
207         }
208                     
209         pz.append
210         (
211             new pointZone
212             (
213                 "pistonPoints",
214                 pistonPoints.shrink(),
215                 nPointZones,
216                 pointZones()
217             )
218         );
220         nPointZones++;
221     
222     }