fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / thoboisSliding / movePistonPointsThoboisSliding.H
blob544b033ef9ca28a77ca4810527e16d7ccb1e14b5
1     {
2         
3         Info << "moving piston points" << endl;
4     
5         boolList scaleDisp(nPoints(), true);
6         label nScaled = nPoints();
8         List<bool> pistonPoint(newPoints.size(), false);
10         label pistonPtsIndex = pointZones().findZoneID("pistonPoints");
11         const labelList& pistonPoints = pointZones()[pistonPtsIndex];
12          
13         const scalarField& movingPointsMPiston = movingPointsMaskPiston(); 
14          
15         forAll(pistonPoints, i)
16         {
17             label pointI = pistonPoints[i];
18             pistonPoint[pointI] = true;
19             point& p = newPoints[pointI];
20             
21             if (p.z() < pistonPosition() - 1.0e-6)
22             {
23                 scaleDisp[pointI] = false;
24                 nScaled--;
25             }
26         }
27            
28         {
29                         
30             // Always move piston
31             scalar pistonTopZ = -GREAT;
32             forAll(pistonPoints, i)
33             {
34                 point& p = newPoints[pistonPoints[i]];
35                 p.z() = p.z() + deltaZ*movingPointsMPiston[pistonPoints[i]];
36                 pistonTopZ = max(pistonTopZ, p.z());
37             }
39         // NN! fix. only needed for compression
40             if (deltaZ > 0.0)
41             {
42                 // check if piston-points have moved beyond the layer above
43                 forAll(newPoints, i)
44                 {
45                     if (!pistonPoint[i])
46                     {
47                         bool foundLow = false;
48                         if (virtualPistonPosition() > newPoints[i].z())
49                         {
51                             foundLow = true;
52                             
53                             newPoints[i].z() 
54                             = 
55                             (1.0 - movingPointsMPiston[i])*newPoints[i].z() 
56                             +
57                             movingPointsMPiston[i] *
58                             (
59                                 pistonTopZ 
60                             +   
61                                 (
62                                     0.9*minLayerThickness
63                                 )
64                             );
65                             
66                         }
67                     }
68                 }
69             }
70         }
71         
72         deleteDemandDrivenData(movingPointsMaskPistonPtr_);
73         
74         forAll(valves(), valveI)
75         {
77             Info << "moving valve points valve n. " << valveI << endl;
78         
79             boolList scaleDisp(nPoints(), true);
80             label nScaled = nPoints();
82             List<bool> pistonPointValve(newPoints.size(), false);
84             label pistonValvePtsIndex =
85             pointZones().findZoneID("valvePistonPointsV"+Foam::name(valveI + 1));
87             const labelList& pistonPointsV = pointZones()[pistonValvePtsIndex];
88          
89             const scalarField& movingPointsMPistonValves = movingPointsMaskPistonValves(valveI); 
91             forAll(pistonPointsV, i)
92             {
93                 label pointI = pistonPointsV[i];
94                 pistonPointValve[pointI] = true;
95                 point& p = newPoints[pointI];
96             
97                 if (p.z() < pistonPosition() - 1.0e-6)
98                 {
99                     scaleDisp[pointI] = false;
100                     nScaled--;
101                 }
102             }
103            
104             {
105                         
106                 // Always move piston
107                 scalar pistonTopZ = -GREAT;
108                 forAll(pistonPointsV, i)
109                 {
110                     point& p = newPoints[pistonPointsV[i]];
111                     
112                     p.z() = p.z() + deltaZ*movingPointsMPistonValves[pistonPointsV[i]];
113                     pistonTopZ = max(pistonTopZ, p.z());
114                 }
116         // NN! fix. only needed for compression
117                 if (deltaZ > 0.0)
118                 {
119                     // check if piston-points have moved beyond the layer above
120                     forAll(newPoints, i)
121                     {
122                         if (!pistonPointValve[i])
123                         {
124                             bool foundLow = false;
125                             if (virtualPistonPosition() > newPoints[i].z())
126                             {
128                                 foundLow = true;
129                             
130                                 newPoints[i].z() 
131                                 = 
132                                 (1.0 - movingPointsMPistonValves[i])*newPoints[i].z() 
133                                 +
134                                 movingPointsMPistonValves[i] *
135                                 (
136                                     pistonTopZ 
137                                 +      
138                                     (
139                                         0.9*minLayerThickness
140                                     )
141                                 );
142                             
143                             }
144                         }   
145                     }
146                 }
147             }
148             
149             deleteDemandDrivenData(movingPointsMaskPistonValvesPtr_);
150         }
151     
152     }