Merge commit 'd3b269b7c6ffa0cd68845adfecdfb849316dba71' into nextRelease
[foam-extend-3.2.git] / src / engine / engineTopoChangerMesh / verticalValves / addValvesFacesPointZones.H
blobc66dc91c3f83836f0cecfcc2501eddb1bd78c1e5
2     // adding face zones for the vertical valves
4     for (label valveI = 0; valveI < nValves(); valveI++)
5     {
6         // If both sides of the interface exist, add sliding interface
7         // for a valve
8         if
9         (
10             valves_[valveI].curtainInCylinderPatchID().active()
11          && valves_[valveI].curtainInPortPatchID().active()
12         )
13         {
14             Info<< "Adding sliding interface zones for curtain of valve "
15                 << valveI + 1 << endl;
17             pz.append
18             (
19                 new pointZone
20                 (
21                     "cutPointsV" + Foam::name(valveI + 1),
22                     labelList(0),
23                     nPointZones,
24                     pointZones()
25                 )
26             );
28             nPointZones++;
30             const polyPatch& cylCurtain =
31                 boundaryMesh()
32                     [valves_[valveI].curtainInCylinderPatchID().index()];
34             labelList cylCurtainLabels(cylCurtain.size(), cylCurtain.start());
36             forAll (cylCurtainLabels, i)
37             {
38                 cylCurtainLabels[i] += i;
39             }
41             fz.append
42             (
43                 new faceZone
44                 (
45                     "curtainCylZoneV" + Foam::name(valveI + 1),
46                     cylCurtainLabels,
47                     boolList(cylCurtainLabels.size(), false),
48                     nFaceZones,
49                     faceZones()
50                 )
51             );
53             nFaceZones++;
55             const polyPatch& portCurtain =
56                 boundaryMesh()
57                     [valves_[valveI].curtainInPortPatchID().index()];
59             labelList portCurtainLabels
60             (
61                 portCurtain.size(),
62                 portCurtain.start()
63             );
65             forAll (portCurtainLabels, i)
66             {
67                 portCurtainLabels[i] += i;
68             }
70             fz.append
71             (
72                 new faceZone
73                 (
74                     "curtainPortZoneV" + Foam::name(valveI + 1),
75                     portCurtainLabels,
76                     boolList(portCurtainLabels.size(), false),
77                     nFaceZones,
78                     faceZones()
79                 )
80             );
82             nFaceZones++;
84             // Add empty zone for cut faces
86             fz.append
87             (
88                 new faceZone
89                 (
90                     "cutFaceZoneV" + Foam::name(valveI + 1),
91                     labelList(0),
92                     boolList(0, false),
93                     nFaceZones,
94                     faceZones()
95                 )
96             );
98             nFaceZones++;
100         }
101         else
102         {
103             Info << "No valve curtain for valve " << valveI + 1 << endl;
104         }
106         // Make a zone for layer addition at the top of the valve
107         if (valves_[valveI].poppetPatchID().active())
108         {
109             Info << "Adding face zone for valve top patch layer addition/removal" << endl;
111             label valvePatchID = valves_[valveI].poppetPatchID().index();
113             const polyPatch& valveTopPatch = boundaryMesh()[valvePatchID];
115             labelList valveTopLayerFaces(0);
116             boolList flipZone1(0);
118             forAll(valveTopPatch.faceCentres(), faceI)
119             {
120                 scalar xFacePatch = valveTopPatch.faceCentres()[faceI].x();
121                 scalar yFacePatch = valveTopPatch.faceCentres()[faceI].y();
122                 scalar zFacePatch = valveTopPatch.faceCentres()[faceI].z();
124                 forAll(faceCentres(),faceI)
125                 {
127                     vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]);
129                     scalar dd = n & vector(0,0,1);
131                     if (mag(dd) > SMALL)
132                     {
133                         scalar xFaceMesh = faceCentres()[faceI].x();
134                         scalar yFaceMesh = faceCentres()[faceI].y();
135                         scalar zFaceMesh = faceCentres()[faceI].z();
137                         if
138                         (
139                             mag(xFaceMesh-xFacePatch) < poppetValveTol_ &&
140                             mag(yFaceMesh-yFacePatch) < poppetValveTol_ &&
141                             mag(zFaceMesh-zFacePatch) < valves_[valveI].topLayerOffset() + poppetValveTol_ &&
142                             mag(zFaceMesh-zFacePatch) > valves_[valveI].topLayerOffset() - poppetValveTol_  &&
143                             (zFaceMesh-zFacePatch) >  SMALL
144                         )
145                         {
147                             label sizeTop = valveTopLayerFaces.size();
148                             valveTopLayerFaces.setSize(sizeTop + 1);
149                             valveTopLayerFaces[sizeTop] = faceI;
150                             flipZone1.setSize(sizeTop + 1);
151                             if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
152                             {
153                                 flipZone1[sizeTop] = true;
154                             }
155                             else
156                             {
157                                 flipZone1[sizeTop] = false;
158                             }
160                         }
161                     }
163                 }
165             }
167             fz.append
168             (
169                 new faceZone
170                 (
171                     "poppetZoneV" + Foam::name(valveI + 1),
172                     valveTopLayerFaces,
173                     flipZone1,
174                     nFaceZones,
175                     faceZones()
176                 )
177             );
179             nFaceZones++;
181         }
182         else
183         {
184             Info << "No poppet layer addition zone for valve "
185                 << valveI + 1 << endl;
186         }
188         // Make a zone for layer addition at the bottom of the valve
189         if (valves_[valveI].bottomPatchID().active())
190         {
191             Info << "Adding face zone for valve bottom patch layer addition/removal" << endl;
193             label valvePatchID = valves_[valveI].bottomPatchID().index();
195             const polyPatch& valveBottomPatch = boundaryMesh()[valvePatchID];
197             labelList valveBottomLayerFaces(0);
198             boolList flipZone1(0);
200             forAll(valveBottomPatch.faceCentres(), faceI)
201             {
202                 scalar xFacePatch = valveBottomPatch.faceCentres()[faceI].x();
203                 scalar yFacePatch = valveBottomPatch.faceCentres()[faceI].y();
204                 scalar zFacePatch = valveBottomPatch.faceCentres()[faceI].z();
206                 forAll(faceCentres(),faceI)
207                 {
209                     vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]);
211                     scalar dd = n & vector(0,0,1);
213                     if (mag(dd) > SMALL)
214                     {
215                         scalar xFaceMesh = faceCentres()[faceI].x();
216                         scalar yFaceMesh = faceCentres()[faceI].y();
217                         scalar zFaceMesh = faceCentres()[faceI].z();
219                         if
220                         (
221                             mag(xFaceMesh-xFacePatch) < bottomValveTol_ &&
222                             mag(yFaceMesh-yFacePatch) < bottomValveTol_ &&
223                             mag(zFaceMesh-zFacePatch) < valves_[valveI].bottomLayerOffset() + bottomValveTol_ &&
224                             mag(zFaceMesh-zFacePatch) > valves_[valveI].bottomLayerOffset() - bottomValveTol_  &&
225                             (zFacePatch-zFaceMesh) >  SMALL
226                         )
227                         {
229                             label sizeTop = valveBottomLayerFaces.size();
230                             valveBottomLayerFaces.setSize(sizeTop + 1);
231                             valveBottomLayerFaces[sizeTop] = faceI;
232                             flipZone1.setSize(sizeTop + 1);
233                             if ((faceAreas()[faceI] & vector(0,0,1)) > 0)
234                             {
235                                 flipZone1[sizeTop] = true;
236                             }
237                             else
238                             {
239                                 flipZone1[sizeTop] = false;
240                             }
242                         }
243                     }
245                 }
247             }
249             Info << "valveBottomLayerFaces size = " << valveBottomLayerFaces.size() << endl;
251             fz.append
252             (
253                 new faceZone
254                 (
255                     "bottomZoneV" + Foam::name(valveI + 1),
256                     valveBottomLayerFaces,
257                     flipZone1,
258                     nFaceZones,
259                     faceZones()
260                 )
261             );
263             nFaceZones++;
265         }
266         else
267         {
268             Info << "No bottom layer addition zone for valve "
269                 << valveI + 1 << endl;
270         }
272     }