Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / thoboisSliding / moveValvePointsThoboisSliding.H
blob67744479328e9d60e2991ba8b731f8bb284515e8
1     // valves
2     forAll(valves_,valveI)
3     {
5             vector valveVel =
6             valves_[valveI].curVelocity()*valves_[valveI].cs().axis();
7         
8         scalar valveDeltaZ = valves_[valveI].curVelocity()*valves_[valveI].cs().axis().z()*engTime().deltaT().value() ;
10         if(valves_[valveI].curLift() > valves_[valveI].deformationLift())    
11         {        
12         
14             bool isMoving(false);
15         
16             if(mag(valves_[valveI].curVelocity()) > 0)
17             {
18                 Info << "Valve n. " << valveI << " is moving with velocity = " << valves_[valveI].curVelocity() << endl;
19                 isMoving = true;
20             }
21          
22         
23             Info << "Valve displacement for valve " << valveI << " = " << valveDeltaZ << endl;
25             if(valves_[valveI].poppetPatchID().active() && valves_[valveI].isOpen())
26             {
28                 List<bool> valveTopPoint(newPoints.size(), false);
29                 
30 //                label layeringVPtsIndex = pointZones().findZoneID("movingPointsTopZoneV"+ Foam::name(valveI+1));                              
31 //                      const labelList& layeringVPoints = pointZones()[layeringVPtsIndex];
32                 
33                 labelList layeringVPoints;                
35                 {   
36                     label valveLayeringCellsIndex = cellZones().findZoneID("movingCellsTopZoneV" + Foam::name(valveI + 1));
37           
38                     if (valveLayeringCellsIndex < 0)
39                     {      
40                         FatalErrorIn("bool verticalValves::update()")
41                             << "movingCellsTopZoneV"+ Foam::name(valveI+1)
42                             << abort(FatalError);
43                     }
45                     const labelList& layeringCellsZoneV = cellZones()[valveLayeringCellsIndex];
46     
47                     const labelListList& cp = cellPoints();
49                     boolList count(newPoints.size(), false);
51                     forAll (layeringCellsZoneV, cellI)
52                     {
53                         const labelList& curCellPoints = cp[layeringCellsZoneV[cellI]];
55                         forAll (curCellPoints, i)
56                         {
57                             count[curCellPoints[i]] = true;
58                         }
59                     }
61                     // Count the points
62                     label nCounted = 0;
63                     forAll (count, pointI)
64                     {
65                         if (count[pointI] == true)
66                         {
67                             nCounted++;
68                         }
69                     }
71                     layeringVPoints.setSize(nCounted);
73                     // Collect the points
74                     nCounted = 0;
75                     forAll (count, pointI)
76                     {
77                         if (count[pointI] == true)
78                         {
79                             layeringVPoints[nCounted] = pointI;
80                             nCounted++;
81                         }
82                     }
83               
84                 }
85                 
86                 forAll(layeringVPoints, i)
87                 {
88                     point& p = newPoints[layeringVPoints[i]];
89                     p.z() += valveDeltaZ*
90                          (valves_[valveI].cs().axis().z()/mag(valves_[valveI].cs().axis()));
91                     valveTopPoint[layeringVPoints[i]] = true;
92                 }
93                 
94                 label movingTopPtsVIndex = pointZones().findZoneID("movingPointsV"+ Foam::name(valveI+1));
95                                 
96                         const labelList& movingTopPointsV = pointZones()[movingTopPtsVIndex];
97                 
98                 forAll(movingTopPointsV, i)
99                 {
100                     if(!valveTopPoint[movingTopPointsV[i]])
101                     {
103                         point& p = newPoints[movingTopPointsV[i]];
104                         p.z() += valveDeltaZ*
105                             (valves_[valveI].cs().axis().z()/mag(valves_[valveI].cs().axis()));
106                     }
107                 }
108                                 
109                 deleteDemandDrivenData(movingPointsMaskTopPtr_);
111             }
112             else
113             {
114                 Info << "Valve " << valveI << " is CLOSED!!!" << endl;
115             }
116         
119        }
121        if(valves_[valveI].bottomPatchID().active() )
122        {
124            {
125         
126 //               label valveBottomPtsIndex = pointZones().findZoneID("movingPointsBottomZoneV"+ Foam::name(valveI+1));          
127 //                 const labelList& valveBottomPoints = pointZones()[valveBottomPtsIndex];
128                
129                 labelList valveBottomPoints;
131                 {   
132                     label valveBottomCellsIndex = cellZones().findZoneID("movingCellsBottomZoneV" + Foam::name(valveI + 1));
133           
134                     if (valveBottomCellsIndex < 0)
135                     {      
136                         FatalErrorIn("bool verticalValves::update()")
137                             << "movingCellsBottomZoneV"+ Foam::name(valveI+1)
138                             << abort(FatalError);
139                     }
141                     const labelList& valveMovingCellsBotZoneV = cellZones()[valveBottomCellsIndex];
142     
143                     const labelListList& cp = cellPoints();
145                     boolList count(newPoints.size(), false);
147                     forAll (valveMovingCellsBotZoneV, cellI)
148                     {
149                         const labelList& curCellPoints = cp[valveMovingCellsBotZoneV[cellI]];
151                         forAll (curCellPoints, i)
152                         {
153                             count[curCellPoints[i]] = true;
154                         }
155                     }
157                     // Count the points
158                     label nCounted = 0;
159                     forAll (count, pointI)
160                     {
161                         if (count[pointI] == true)
162                         {
163                             nCounted++;
164                         }
165                     }
167                     valveBottomPoints.setSize(nCounted);
169                     // Collect the points
170                     nCounted = 0;
171                     forAll (count, pointI)
172                     {
173                         if (count[pointI] == true)
174                         {
175                             valveBottomPoints[nCounted] = pointI;
176                             nCounted++;
177                         }
178                     }
179               
180                 }
183                 forAll(valveBottomPoints, i)
184                 {
185                     point& p = newPoints[valveBottomPoints[i]];
186                     p.z() +=    valveDeltaZ*
187                            (valves_[valveI].cs().axis().z()/mag(valves_[valveI].cs().axis()));
188                 }
190            }
192            deleteDemandDrivenData(movingPointsMaskBottomPtr_);
194        }
196     }