Merge commit 'd3b269b7c6ffa0cd68845adfecdfb849316dba71' into nextRelease
[foam-extend-3.2.git] / src / engine / engineTopoChangerMesh / verticalValves / addValvePistonCellZones.H
blob033db4cc640f4b5d9315541a5ae8b5d20910af33
1 //  Moving mask: moving cells inside the valves....
3     {
5         for(label i = 1; i <= nValves(); i++)
6         {
9             if(valves_[i-1].poppetPatchID().active())
10             {
12                 labelList movingCells(nCells());
14                 label nMovingCells = 0;
16                 label valvePatchID = valves_[i-1].poppetPatchID().index();
17                 scalar minPopZ = min(boundary()[valvePatchID].patch().localPoints()).z();
19                 forAll(cellCentres(),cellI)
20                 {
21                     const vector& v = cellCentres()[cellI];
23                     if
24                     (
25                         inValve(v, i-1)
26                         &&
27                         v.z() > minPopZ
28                     )
29                     {
30                         movingCells[nMovingCells] = cellI;
31                         nMovingCells++;
32                     }
34                 }
36                 movingCells.setSize(nMovingCells);
37                 Info << "Number of cells in the moving region poppet valve: " << nMovingCells << endl;
39                 cz.append
40                 (
41                     new cellZone
42                     (
43                         "movingCellsTopV"+ Foam::name(i),
44                         movingCells,
45                         nCellZones,
46                         cellZones()
47                     )
48                 );
50                 nCellZones++;
52             }
54             if(valves_[i-1].bottomPatchID().active())
55             {
57                 labelList movingCells(nCells());
59                 label nMovingCells = 0;
61                 label valvePatchID = valves_[i-1].bottomPatchID().index();
62                 scalar maxPopZ = max(boundary()[valvePatchID].patch().localPoints()).z();
65                 forAll(cellCentres(),cellI)
66                 {
67                     const vector& v = cellCentres()[cellI];
69                     if
70                     (
71                         inValve(v, i-1)
72                         &&
73                         v.z() < maxPopZ + SMALL
74                     )
75                     {
76                         movingCells[nMovingCells] = cellI;
77                         nMovingCells++;
78                     }
80                 }
82                 movingCells.setSize(nMovingCells);
83                 Info << "Number of cells in the moving region bottom valve: " << nMovingCells << endl;
85                 cz.append
86                 (
87                     new cellZone
88                     (
89                         "movingCellsBotV"+ Foam::name(i),
90                         movingCells,
91                         nCellZones,
92                         cellZones()
93                     )
94                 );
96                 nCellZones++;
98             }
101         }
103     }