Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / verticalValves / moveValvePoints.H
blob2fe059a0840ed8a67bdf5dd6d537d52839b5679d
1     // valves
3     forAll(valves_,valveI)
4     {
5         
6         bool isMoving(false);
7         
8         if(mag(valves_[valveI].curVelocity()) > 0)
9         {
10             Info << "Valve n. " << valveI << " is moving" << endl;
11             isMoving = true;
12         }
13          
14         scalar valveDeltaZ = valves_[valveI].curVelocity()*engTime().deltaT().value() ;
15         
16         Info << "Valve displacement for valve " << valveI << " = " << valveDeltaZ << endl;
18         if(valves_[valveI].poppetPatchID().active() && valves_[valveI].isOpen())
19         {
20             if(valves_[valveI].curLift() >  valves_[valveI].deformationLift()) 
21             {
22                 const scalarField& movingPointsTop = movingPointsMaskTop(valveI+1);
24                 List<bool> valveTopPoint(newPoints.size(), false);
25                 
26                 labelList valveTopPoints;
27                 
28                 {
29                     label valveTopCellsIndex = cellZones().findZoneID("movingCellsTopV"+ Foam::name(valveI));
30                 
31                     if (valveTopCellsIndex < 0)
32                     {      
33                         FatalErrorIn("bool verticalValves::update()")
34                             << "movingCellsTopV"+ Foam::name(valveI)
35                             << abort(FatalError);
36                     }
38                     const labelList& movingCellsTopV = cellZones()[valveTopCellsIndex];
39     
40                     const labelListList& cp = cellPoints();
42                     boolList count(newPoints.size(), false);
44                     forAll (movingCellsTopV, cellI)
45                     {
46                         const labelList& curCellPoints = cp[movingCellsTopV[cellI]];
48                         forAll (curCellPoints, i)
49                         {
50                             count[curCellPoints[i]] = true;
51                         }
52                     }
54                     // Count the points
55                     label nCounted = 0;
56                     forAll (count, pointI)
57                     {
58                         if (count[pointI] == true)
59                         {
60                             nCounted++;
61                         }
62                     }
64                     valveTopPoints.setSize(nCounted);
66                     // Collect the points
67                     nCounted = 0;
68                     forAll (count, pointI)
69                     {
70                         if (count[pointI] == true)
71                         {
72                             valveTopPoints[nCounted] = pointI;
73                             nCounted++;
74                         }
75                     }
76                             
77                 }
79 //                label valveTopPtsIndex = pointZones().findZoneID("valveTopPointsV"+ Foam::name(valveI+1));
80 //                const labelList& valveTopPoints = pointZones()[valveTopPtsIndex];
82                 forAll(valveTopPoints, i)
83                 {
84                     label pointI = valveTopPoints[i];
85                     valveTopPoint[pointI] = true;
86                 }
87         
88                 forAll(valveTopPoints, i)
89                 {
90                     point& p = newPoints[valveTopPoints[i]];
91                     p.z() +=    valveDeltaZ*
92                                 (valves_[valveI].cs().axis().z()/mag(valves_[valveI].cs().axis()))*
93                                 movingPointsTop[valveTopPoints[i]];
94                 }
96                 deleteDemandDrivenData(movingPointsMaskTopPtr_);
97             }
98             else
99             {
100                 poppetDeformation = true;
101             }
103         }
104         else
105         {
106             Info << "Valve " << valveI << " is CLOSED!!!" << endl;
107         }
108         
109         if(valves_[valveI].bottomPatchID().active() && valves_[valveI].isOpen())
110         {
111             const scalarField& movingPointsBottom = movingPointsMaskBottom(valveI);
112             {
114                 List<bool> valveBottomPoint(newPoints.size(), false);
116                 labelList valveBottomPoints;
117                 
118                 {
119                     label valveBotCellsIndex = cellZones().findZoneID("movingCellsBotV"+ Foam::name(valveI+1));
120                 
121                     if (valveBotCellsIndex < 0)
122                     {      
123                         FatalErrorIn("bool verticalValves::update()")
124                             << "movingCellsBotV"+ Foam::name(valveI)
125                             << abort(FatalError);
126                     }
128                     const labelList& movingCellsBotV = cellZones()[valveBotCellsIndex];
129     
130                     const labelListList& cp = cellPoints();
132                     boolList count(newPoints.size(), false);
134                     forAll (movingCellsBotV, cellI)
135                     {
136                         const labelList& curCellPoints = cp[movingCellsBotV[cellI]];
138                         forAll (curCellPoints, i)
139                         {
140                             count[curCellPoints[i]] = true;
141                         }
142                     }
144                     // Count the points
145                     label nCounted = 0;
146                     forAll (count, pointI)
147                     {
148                         if (count[pointI] == true)
149                         {
150                             nCounted++;
151                         }
152                     }
154                     valveBottomPoints.setSize(nCounted);
156                     // Collect the points
157                     nCounted = 0;
158                     forAll (count, pointI)
159                     {
160                         if (count[pointI] == true)
161                         {
162                             valveBottomPoints[nCounted] = pointI;
163                             nCounted++;
164                         }
165                     }
166                             
167                 }
170 //                label valveBottomPtsIndex = pointZones().findZoneID("valveBottomPointsV"+ Foam::name(valveI+1));
171 //                const labelList& valveBottomPoints = pointZones()[valveBottomPtsIndex];
173                 forAll(valveBottomPoints, i)
174                 {
175                     label pointI = valveBottomPoints[i];
176                     valveBottomPoint[pointI] = true;
177                 }
178                                         
179                 forAll(valveBottomPoints, i)
180                 {
181                     point& p = newPoints[valveBottomPoints[i]];
182                     p.z() +=    valveDeltaZ*
183                                 (valves_[valveI].cs().axis().z()/mag(valves_[valveI].cs().axis()))*
184                                 movingPointsBottom[valveBottomPoints[i]];
185                 }
187             }
188             
189             deleteDemandDrivenData(movingPointsMaskBottomPtr_);
191         }
192         else
193         {
194             Info << "Valve " << valveI << " is CLOSED!!!" << endl;
195         }
196     }