Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / verticalValves / addValvePistonCellZones.H
blob98c59a1ef44cfdf42aa6d9bfb53e5650f2fa7b44
1 //  Moving mask: moving cells inside the valves....
3     {
5         for(label i = 1; i <= nValves(); i++)
6         {
7             
8             
9             if(valves_[i-1].poppetPatchID().active())
10             {
11             
12                 labelList movingCells(nCells());
13                                 
14                 label nMovingCells = 0;
15         
16                 label valvePatchID = valves_[i-1].poppetPatchID().index();
17                 const polyPatch& valveTopPatch = boundaryMesh()[valvePatchID];
18                 scalar minPopZ = min(boundary()[valvePatchID].patch().localPoints()).z();
19                         
20                 forAll(cellCentres(),cellI)
21                 {
22                     const vector& v = cellCentres()[cellI];
23                         
24                     if
25                     (
26                         inValve(v, i-1)
27                         &&
28                         v.z() > minPopZ 
29                     )
30                     {
31                         movingCells[nMovingCells] = cellI;
32                         nMovingCells++;
33                     }
34             
35                 }
36                 
37                 movingCells.setSize(nMovingCells);
38                 Info << "Number of cells in the moving region poppet valve: " << nMovingCells << endl;
39                                                 
40                 cz.append
41                 (
42                     new cellZone
43                     (
44                         "movingCellsTopV"+ Foam::name(i),
45                         movingCells,
46                         nCellZones,
47                         cellZones()
48                     )
49                 );
51                 nCellZones++;
53             }
54             
55             if(valves_[i-1].bottomPatchID().active())
56             {
57             
58                 labelList movingCells(nCells());
59                                 
60                 label nMovingCells = 0;
61                 
62                 label valvePatchID = valves_[i-1].bottomPatchID().index();
63                 const polyPatch& valveBottomPatch = boundaryMesh()[valvePatchID];
64                 scalar maxPopZ = max(boundary()[valvePatchID].patch().localPoints()).z();
67                 forAll(cellCentres(),cellI)
68                 {
69                     const vector& v = cellCentres()[cellI];
70                         
71                     if
72                     (
73                         inValve(v, i-1)
74                         &&
75                         v.z() < maxPopZ + SMALL
76                     )
77                     {
78                         movingCells[nMovingCells] = cellI;
79                         nMovingCells++;
80                     }
81             
82                 }
83                 
84                 movingCells.setSize(nMovingCells);
85                 Info << "Number of cells in the moving region bottom valve: " << nMovingCells << endl;
87                 cz.append
88                 (
89                     new cellZone
90                     (
91                         "movingCellsBotV"+ Foam::name(i),
92                         movingCells,
93                         nCellZones,
94                         cellZones()
95                     )
96                 );
98                 nCellZones++;
100             }
102         
103         }
104         
105     }