Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / verticalValves / moveTopOfTheValves.H
blob13529f59ff01c8c0bacc9da45befc3a2d84f989c
1     {
2         forAll(valves(), valveI)
3         {
4             scalar valveDeltaZ = valves_[valveI].curVelocity()*engTime().deltaT().value() ;
5             bool isMoving(false);
6         
7             if(mag(valves_[valveI].curVelocity()) > 0)
8             {
9                 Info << "Valve n. " << valveI << " is moving" << endl;
10                 isMoving = true;
11             }
12             
13             if(valves_[valveI].poppetPatchID().active() && valves_[valveI].isOpen())
14             {
15                 
16                 if(valves_[valveI].curLift() > valves_[valveI].deformationLift())
17                 {
18                     const scalarField& movingPointsTop = movingPointsMaskTop(valveI);
19                         
20                     {
22                         List<bool> valveTopPoint(newPoints.size(), false);
24                         labelList valveTopPoints;
25                 
26                         {   
27                             label valveTopCellsIndex = cellZones().findZoneID("movingCellsTopV"+ Foam::name(valveI+1));
28                 
29                             if (valveTopCellsIndex < 0)
30                             {      
31                                 FatalErrorIn("bool verticalValves::update()")
32                                     << "movingCellsTopV"+ Foam::name(valveI+1)
33                                     << abort(FatalError);
34                             }
36                             const labelList& movingCellsTopV = cellZones()[valveTopCellsIndex];
37     
38                             const labelListList& cp = cellPoints();
40                             boolList count(newPoints.size(), false);
42                             forAll (movingCellsTopV, cellI)
43                             {
44                                 const labelList& curCellPoints = cp[movingCellsTopV[cellI]];
46                                 forAll (curCellPoints, i)
47                                 {
48                                     count[curCellPoints[i]] = true;
49                                 }
50                             }
52                             // Count the points
53                             label nCounted = 0;
54                             forAll (count, pointI)
55                             {
56                                 if (count[pointI] == true)
57                                 {
58                                     nCounted++;
59                                 }
60                             }
62                             valveTopPoints.setSize(nCounted);
64                             // Collect the points
65                             nCounted = 0;
66                             forAll (count, pointI)
67                             {
68                                 if (count[pointI] == true)
69                                 {
70                                     valveTopPoints[nCounted] = pointI;
71                                     nCounted++;
72                                 }
73                             }
74                             
75                         }
78 //                        label valveTopPtsIndex = pointZones().findZoneID("valveTopPointsV"+ Foam::name(valveI+1));
79 //                        const labelList& valveTopPoints = pointZones()[valveTopPtsIndex];
81                         forAll(valveTopPoints, i)
82                         {
83                             label pointI = valveTopPoints[i];
84                             valveTopPoint[pointI] = true;
85                         }
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                     }
97             
98                     deleteDemandDrivenData(movingPointsMaskTopPtr_);
99                 }
100                 else
101                 {
102                     poppetDeformation = true;
103                 }
104             }
105             else
106             {
107                 Info << "Valve " << valveI << " is CLOSED!!!" << endl;
108             }
109         }
110     }