Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / verticalValves / addValvesFacesPointZones.H
blobe0e3e56d8dae9dab4329babd0d6009e8705a3339
1     
2     // adding face zones for the vertical valves
3     
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             );
27                             
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             );
52                 
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             );
81                 
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         }
105         
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();
112                     
113             const polyPatch& valveTopPatch = boundaryMesh()[valvePatchID];
114             
115             labelList valveTopLayerFaces(0);
116             boolList flipZone1(0);
117             
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                 {
126                 
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();
136                 
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                         {
146                         
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                             }
159                                                              
160                         }
161                     }
162                 
163                 }
164                 
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             );
178         
179             nFaceZones++;
180                         
181         }
182         else
183         {
184             Info << "No poppet layer addition zone for valve "
185                 << valveI + 1 << endl;
186         }
187         
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();
194                     
195             const polyPatch& valveBottomPatch = boundaryMesh()[valvePatchID];
196             
197             labelList valveBottomLayerFaces(0);
198             boolList flipZone1(0);
199             
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                 {
208                 
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();
218                 
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                         {
228                         
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                             }
241                                                              
242                         }
243                     }
244                 
245                 }
246                 
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             );
262         
263             nFaceZones++;
264             
265         }
266         else
267         {
268             Info << "No bottom layer addition zone for valve "
269                 << valveI + 1 << endl;
270         }
272     }