Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / verticalValves / moveAllTogether.H
bloba0c5b6a9dc9f2b9d1c3698f688fe94789015cffe
1 // use tetrahedral decomposition of the engine mesh
4     tetPointVectorField& motionU = mSolver.motionU();
6     vector pistonVel =
7             piston().cs().axis()*engineTime_.pistonSpeed().value();
9     // Set valve velocity
10     forAll (valves_, valveI)
11     {
12         // If valve is present in geometry, set the motion
13         if (valves_[valveI].bottomPatchID().active())
14         {
15             vector valveVel =
16                 valves_[valveI].curVelocity()*valves_[valveI].cs().axis();
18             // Bottom of the valve moves with given velocity
19             motionU.boundaryField()[valves_[valveI].bottomPatchID().index()] ==
20                 valveVel;
22             if (debug)
23             {
24                 Info<< "Valve " << valveI << " lift: "
25                     << valves_[valveI].curLift()
26                     << " velocity: " << valves_[valveI].curVelocity()
27                     << endl;
28             }
29         }
31         if (valves_[valveI].poppetPatchID().active())
32         {
33             // Top of the valve does not move
34             motionU.boundaryField()[valves_[valveI].poppetPatchID().index()] ==
35                 vector::zero;
36         }
38         if (valves_[valveI].curtainInCylinderPatchID().active())
39         {
41             label cicIndex = valves_[valveI].curtainInCylinderPatchID().index();
42             
43             componentMixedTetPolyPatchVectorField& pp =
44                 refCast<componentMixedTetPolyPatchVectorField>
45                 (
46                     motionU.boundaryField()[cicIndex]
47                 );
48             
49             scalarField curtainInCylinderPoints =
50                             motionU.boundaryField()[cicIndex].patch()
51                             .localPoints().component(vector::Z);
53             pp.refValue() = pistonVel;
54             pp.valueFraction() = 
55             (1.0-pos(curtainInCylinderPoints - pistonPosition()))*vector(0,0,1);
56                 
57             
58                             
59         }
61         if (valves_[valveI].curtainInPortPatchID().active())
62         {
63             label cipIndex = valves_[valveI].curtainInPortPatchID().index();
64             
65             componentMixedTetPolyPatchVectorField& pp =
66                 refCast<componentMixedTetPolyPatchVectorField>
67                 (
68                     motionU.boundaryField()[cipIndex]
69                 );
70             
71             scalarField curtainInPortPoints =
72                             motionU.boundaryField()[cipIndex].patch()
73                             .localPoints().component(vector::Z);
75             pp.refValue() = pistonVel;
76             pp.valueFraction() = 
77             (1.0-pos(curtainInPortPoints - pistonPosition()))*vector(0,0,1);;
79         }
80         
81         if (valves_[valveI].detachInPortPatchID().active())
82         {
83             motionU.boundaryField()[valves_[valveI].detachInPortPatchID().index()] == vector::zero;
84         }
86         if (valves_[valveI].detachInCylinderPatchID().active())
87         {
88             motionU.boundaryField()[valves_[valveI].detachInCylinderPatchID().index()] == vector::zero;
89         }
91         if (valves_[valveI].stemPatchID().active())
92         {
93             label stemIndex = valves_[valveI].stemPatchID().index();
94             
95             componentMixedTetPolyPatchVectorField& pp =
96                 refCast<componentMixedTetPolyPatchVectorField>
97                 (
98                     motionU.boundaryField()[stemIndex]
99                 );
100             
101             pp.refValue() = vector::zero;
102             pp.valueFraction() = vector(0,0,1);
103         }
104         
105         
106         {
107             label linerIndex = boundaryMesh().findPatchID("liner");
108             
109             componentMixedTetPolyPatchVectorField& pp =
110                 refCast<componentMixedTetPolyPatchVectorField>
111                 (
112                     motionU.boundaryField()[linerIndex]
113                 );
114             
115             scalarField linerPoints =
116                             motionU.boundaryField()[linerIndex].patch()
117                             .localPoints().component(vector::Z);
119             pp.refValue() = pistonVel;
120             pp.valueFraction() = 
121             (1.0-pos(linerPoints - pistonPosition()))*vector(0,0,1);;
123         }
124         
125     }
127     // Set piston velocity
128     if (piston().patchID().active())
129     {
131         if (debug)
132         {
133             Info<< "Piston velocity: " << pistonVel;
134         }
136         componentMixedTetPolyPatchVectorField& pp =
137             refCast<componentMixedTetPolyPatchVectorField>
138             (
139                 motionU.boundaryField()[piston().patchID().index()]
140             );
142         pp.refValue() = pistonVel;
143         
144     }
145     
146     mSolver.solve();
148 //  Setting the boundary position
150     {
151         label cylinderHeadIndex = boundaryMesh().findPatchID("cylinderHead");
152         
153         // Top of the valve does not move
154         motionU.boundaryField()[cylinderHeadIndex] ==
155             vector::zero;
156     }
157         
158