Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / thoboisMesh / movePistonPointsThobois.H
blobbe941f696d4c50c6c24aaa292a65f74af168dc61
1     Info << "virtualPistonPosition = " << virtualPistonPosition()
2     << ", deckHeight = " << deckHeight() << endl;
4     // Mesh in three parts:
5     // - pistonPoints - move with deltaZ
6     // - headPoints - do not move
7     
8     const pointZoneMesh& pZones = pointZones();
9     label headPtsIndex = pZones.findZoneID("headPoints");
10     label pistonPtsIndex = pZones.findZoneID("pistonPoints");
11     const labelList& pistonPoints = pZones[pistonPtsIndex];
12     const labelList& headPoints = pZones[headPtsIndex];
15     // Whether point displacement is by scaling
16     boolList scaleDisp(nPoints(), true);
17     label nScaled = nPoints();
18     List<bool> pistonPoint(newPoints.size(), false);
19     List<bool> headPoint(newPoints.size(), false);
21     forAll(pistonPoints, i)
22     {
23         label pointI = pistonPoints[i];
24         pistonPoint[pointI] = true;
25         point& p = newPoints[pointI];
26                 
27         if (p.z() < pistonPosition() - 1.0e-6)
28         {
29             scaleDisp[pointI] = false;
30             nScaled--;
31         }
32     }
33     
35     forAll(headPoints, i)
36     {
37         headPoint[headPoints[i]] = true;
38         scaleDisp[headPoints[i]] = false;
39         nScaled--;
40     }
41     
43     Info<< "Mesh nPoints:" << nPoints()
44         << " inside:" << nScaled
45         << " piston:" << pistonPoints.size()
46         << " head:" << headPoints.size()
47         << endl;
50     if (realDeformation)
51     {
53         forAll(scaleDisp, pointI)
54         {
55             point& p = newPoints[pointI];
57             if (scaleDisp[pointI])
58             {                
59                 p.z() += 
60                     deltaZ
61                   * (deckHeight() - p.z())/(deckHeight() - pistonPosition());
62             }
63             else
64             {
65                 if (!headPoint[pointI])
66                 {
67                     p.z() += deltaZ;
68                 }
69             }
70         }
71     }
72     else
73     {
75         // Always move piston
76         scalar pistonTopZ = -GREAT;
77         forAll(pistonPoints, i)
78         {
79             point& p = newPoints[pistonPoints[i]];
80             p.z() += deltaZ;
81             pistonTopZ = max(pistonTopZ, p.z());
82         }
85         // NN! fix. only needed for compression
86         if (deltaZ > 0.0)
87         {
88             // check if piston-points have moved beyond the layer above
89             forAll(newPoints, i)
90             {
91                 if (!pistonPoint[i])
92                 {
93                     if (virtualPistonPosition() > newPoints[i].z())
94                     {
95                         newPoints[i].z() = pistonTopZ + 0.9*minLayerThickness;
96                     }
97                 }
98             }
99         }
100     }
102     movePoints(newPoints);
103             
104     pistonPosition() += deltaZ;
105     scalar pistonSpeed = deltaZ/engTime().deltaT().value();
107     Info<< "clearance: " << deckHeight() - pistonPosition() << nl
108         << "Piston speed = " << pistonSpeed << " m/s" << endl;