Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / engine / engineTopoChangerMesh / deformingEngineMesh / addValveFaceZonesDeformingEngineMesh.H
blob7e857c6131362fc5db5594bcb4cf94aa65ffd4e3
2     for (label valveI = 0; valveI < nValves(); valveI++)
3     {
5         // for each valve the following zones have to be created:
6         //
7         //  - movingFaceZone
8         //  - movingPointZone
9         //  - staticFaceZone
10         //  - staticPointZone
12         IOobject movingCellsHeader
13         (
14             valves_[valveI].movingCellsName(),
15             time().constant()+"/polyMesh/sets/",
16             *this,
17             IOobject::MUST_READ
18         );
20         if(!movingCellsHeader.headerOk())
21         {
22             WarningIn
23             (
24                 "deformingEngineMesh::addZonesAndModifiers()"
25             )   << "cellSet called " << valves_[valveI].movingCellsName()
26                 << " does not exist. Continuing mesh motion without rigid motion points for valve " << valves_[valveI].name() << endl;
28             pz.append
29             (
30                 new pointZone
31                 (
32                     "movingPointsV" + Foam::name(valveI + 1),
33                     labelList(0),
34                     nPointZones,
35                     pointZones()
36                 )
37             );
39             nPointZones++;
41         }
42         else
43         {
44             cellSet movingCellsSet(*this, valves_[valveI].movingCellsName());
46             labelList movingCells = movingCellsSet.toc();
48             labelList movingPoints;
50             const labelListList& cp = cellPoints();
52             boolList count(allPoints().size(), false);
54             forAll (movingCells, cellI)
55             {
56                 const labelList& curCellPoints = cp[movingCells[cellI]];
58                 forAll (curCellPoints, i)
59                 {
60                     count[curCellPoints[i]] = true;
61                 }
62             }
64             // Count the points
65             label nCounted = 0;
66             forAll (count, pointI)
67             {
68                 if (count[pointI] == true)
69                 {
70                     nCounted++;
71                 }
72             }
74             movingPoints.setSize(nCounted);
76             // Collect the points
77             nCounted = 0;
78             forAll (count, pointI)
79             {
80                 if (count[pointI] == true)
81                 {
82                     movingPoints[nCounted] = pointI;
83                     nCounted++;
84                 }
85             }
87             pz.append
88             (
89                 new pointZone
90                 (
91                     "movingPointsV" + Foam::name(valveI + 1),
92                     movingPoints,
93                     nPointZones,
94                     pointZones()
95                 )
96             );
98             nPointZones++;
99         }
101         IOobject staticCellsHeader
102         (
103             valves_[valveI].staticCellsName(),
104             time().constant()+"/polyMesh/sets/",
105             *this,
106             IOobject::MUST_READ
107         );
109         if(!staticCellsHeader.headerOk())
110         {
111             WarningIn
112             (
113                 "deformingEngineMesh::addZonesAndModifiers()"
114             )   << "cellSet called " << valves_[valveI].staticCellsName()
115                 << " does not exist. Continuing mesh motion without static points for valve " << valves_[valveI].name() << endl;
117             pz.append
118             (
119                 new pointZone
120                 (
121                     "staticPointsV" + Foam::name(valveI + 1),
122                     labelList(0),
123                     nPointZones,
124                     pointZones()
125                 )
126             );
128             nPointZones++;
130         }
131         else
132         {
133             cellSet staticCellSet(*this, valves_[valveI].staticCellsName());
135             labelList staticCells = staticCellSet.toc();
137             labelList staticPoints;
139             const labelListList& cp = cellPoints();
141             boolList count(allPoints().size(), false);
143             forAll (staticCells, cellI)
144             {
145                 const labelList& curCellPoints = cp[staticCells[cellI]];
147                 forAll (curCellPoints, i)
148                 {
149                     count[curCellPoints[i]] = true;
150                 }
151             }
153             // Count the points
154             label nCounted = 0;
155             forAll (count, pointI)
156             {
157                 if (count[pointI] == true)
158                 {
159                     nCounted++;
160                 }
161             }
163             staticPoints.setSize(nCounted);
165             // Collect the points
166             nCounted = 0;
167             forAll (count, pointI)
168             {
169                 if (count[pointI] == true)
170                 {
171                     staticPoints[nCounted] = pointI;
172                     nCounted++;
173                 }
174             }
176             pz.append
177             (
178                 new pointZone
179                 (
180                     "staticPointsV" + Foam::name(valveI + 1),
181                     staticPoints,
182                     nPointZones,
183                     pointZones()
184                 )
185             );
187             nPointZones++;
188         }
189     }