fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / pistonSliding / moveAllTogetherPistonSliding.H
blob0c77bd163fdb8e4dc66aefa9865a8e122b839f26
1 // use tetrahedral decomposition of the engine mesh
4     tetPointVectorField& motionU = mSolver.motionU();
6     vector pistonVel =
7             piston().cs().axis()*engineTime_.pistonSpeed().value();
9     Info << " Set valve velocity " << endl;
10     
11     forAll (valves_, valveI)
12     {
13         // If valve is present in geometry, set the motion
14        
15        Info << " Set valve Bottom velocity " << endl;
16        
17        if (valves_[valveI].bottomPatchID().active())
18         {
19             vector valveVel =
20                 -valves_[valveI].curVelocity()*valves_[valveI].cs().axis();
22             // Bottom of the valve moves with given velocity
23             motionU.boundaryField()[valves_[valveI].bottomPatchID().index()] ==
24                 valveVel;
26             if (debug)
27             {
28                 Info<< "Valve " << valveI << " lift: "
29                     << valves_[valveI].curLift()
30                     << " velocity: " << valves_[valveI].curVelocity()
31                     << endl;
32             }
33         }
35        
36        Info << " Set valve poppet velocity " << endl;
37        
38         if (valves_[valveI].poppetPatchID().active())
39         {
41             // Top of the valve does not move
42             motionU.boundaryField()[valves_[valveI].poppetPatchID().index()] ==
43                 valveVel;
44         }
46        
47        Info << " Set valve curInCyl velocity " << endl;
48        
49         if (valves_[valveI].curtainInCylinderPatchID().active())
50         {
52             label cicIndex = valves_[valveI].curtainInCylinderPatchID().index();
53             
54             componentMixedTetPolyPatchVectorField& pp =
55                 refCast<componentMixedTetPolyPatchVectorField>
56                 (
57                     motionU.boundaryField()[cicIndex]
58                 );
59             
60             scalarField curtainInCylinderPoints =
61                             motionU.boundaryField()[cicIndex].patch()
62                             .localPoints().component(vector::Z);
64             pp.refValue() = pistonVel;
65             pp.valueFraction() = 
66             (1.0-pos(curtainInCylinderPoints - pistonPosition()))*vector(0,0,1);
67                 
68             
69                             
70         }
71        
72        Info << " Set valve curInport velocity " << endl;
73        
75         if (valves_[valveI].curtainInPortPatchID().active())
76         {
77             label cipIndex = valves_[valveI].curtainInPortPatchID().index();
78             
79             componentMixedTetPolyPatchVectorField& pp =
80                 refCast<componentMixedTetPolyPatchVectorField>
81                 (
82                     motionU.boundaryField()[cipIndex]
83                 );
84             
85             scalarField curtainInPortPoints =
86                             motionU.boundaryField()[cipIndex].patch()
87                             .localPoints().component(vector::Z);
89             pp.refValue() = pistonVel;
90             pp.valueFraction() = 
91             (1.0-pos(curtainInPortPoints - pistonPosition()))*vector(0,0,1);;
93         }
94         
95        
96        Info << " Set valve stem velocity " << endl;
97        
98         if (valves_[valveI].stemPatchID().active())
99         {
100             label stemIndex = valves_[valveI].stemPatchID().index();
101             
102             componentMixedTetPolyPatchVectorField& pp =
103                 refCast<componentMixedTetPolyPatchVectorField>
104                 (
105                     motionU.boundaryField()[stemIndex]
106                 );
107             
108             pp.refValue() = vector::zero;
109             pp.valueFraction() = vector(0,0,1);
110         }
111     }    
112 /*        
113         {
114             label linerIndex = boundaryMesh().findPatchID("liner");
115             
116             componentMixedTetPolyPatchVectorField& pp =
117                 refCast<componentMixedTetPolyPatchVectorField>
118                 (
119                     motionU.boundaryField()[linerIndex]
120                 );
121             
122             scalarField linerPoints =
123                             motionU.boundaryField()[linerIndex].patch()
124                             .localPoints().component(vector::Z);
126             pp.refValue() = pistonVel;
127             pp.valueFraction() = 
128             (1.0-pos(linerPoints - pistonPosition()))*vector(0,0,1);;
130         }
131         
132     
134     // Set piston velocity
135     if (piston().patchID().active())
136     {
138         if (debug)
139         {
140             Info<< "Piston velocity: " << pistonVel;
141         }
143         componentMixedTetPolyPatchVectorField& pp =
144             refCast<componentMixedTetPolyPatchVectorField>
145             (
146                 motionU.boundaryField()[piston().patchID().index()]
147             );
149         pp.refValue() = pistonVel;
150         
151     }
152 */    
153     
154     
155     mSolver.solve();
156         
157     Info << "msolved" << endl;
158     
159 //  Setting the boundary position
161     {
162         label cylinderHeadIndex = boundaryMesh().findPatchID("cylinderHead");
163         
164         // Top of the valve does not move
165         motionU.boundaryField()[cylinderHeadIndex] ==
166             vector::zero;
167     }
168         
169