Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / pistonSliding / poppetDeformationPistonSliding.H
blob8c6677adae301052d594b0b438a2f7d59cbf12a8
1 //if(poppetDeformation)
2 //{
4     Info << "Poppet valve deformation" << endl;
6     tetPointVectorField& motionU = mSolver.motionU();
7     // Blocking vertical motion
9     motionU.internalField().replace
10     (
11         vector::Z,
12         scalarField(mSolver.motionU().internalField().size(), 0)
13     );
15     Info << "motionU.replace" << endl;
16     
17     
18     // Set valve velocity
19     forAll (valves_, valveI)
20     {
22         vector valveVel =
23             valves_[valveI].curVelocity()*valves_[valveI].cs().axis();
24         
25         scalar zPoppetMin = -GREAT;
26         scalar zPoppetMax = GREAT;
27         scalar zCurtainMax = GREAT;
28                 
29         // If valve is present in geometry, set the motion
30         if (valves_[valveI].bottomPatchID().active())
31         {
32             // Bottom of the valve moves with given velocity
34             motionU.boundaryField()[valves_[valveI].bottomPatchID().index()] == vector::zero;
35 //            motionU.boundaryField()[valves_[valveI].bottomPatchID().index()] == valveVel;
36         }
37         
38         if (valves_[valveI].poppetPatchID().active()) 
39         {
40             
41             zPoppetMin = min
42             (
43                 motionU.boundaryField()[valves_[valveI].poppetPatchID().index()].patch()
44                 .localPoints().component(vector::Z)
45             );
46             zPoppetMax = max
47             (
48                 motionU.boundaryField()[valves_[valveI].poppetPatchID().index()].patch()
49                 .localPoints().component(vector::Z)
50             );
51             
52 //            Info << "zpoppet min and max" << endl;        
54             if (valves_[valveI].curLift() > valves_[valveI].deformationLift())        
55 //            if (valves_[valveI].curLift() > valves_[valveI].minLift())
56             {
57                 // Top of the valve does not move
58                 motionU.boundaryField()[valves_[valveI].poppetPatchID().index()] ==
59                     vector::zero;
60             }
61             else
62             {
63 */            
64         
65                 motionU.boundaryField()[valves_[valveI].poppetPatchID().index()] ==
66                     valveVel;
67 //            }
68         
69         }
71         if (valves_[valveI].curtainInCylinderPatchID().active())
72         {
74             label cicIndex = valves_[valveI].curtainInCylinderPatchID().index();
75             
76             componentMixedTetPolyPatchVectorField& pp =
77                 refCast<componentMixedTetPolyPatchVectorField>
78                 (
79                     motionU.boundaryField()[cicIndex]
80                 );
81             
82             pp.refValue() = vector::zero;
83             pp.valueFraction() = vector::zero;
84                             
85         }
86         
87         scalar zDetMin = -GREAT;        
88         scalar zDetMax = GREAT;        
91         if (valves_[valveI].curtainInPortPatchID().active())
92         {
93             label cipIndex = valves_[valveI].curtainInPortPatchID().index();
95             zCurtainMax = max
96             (
97                 motionU.boundaryField()[cipIndex].patch()
98                 .localPoints().component(vector::Z)
99             );
100             
101             
102 //            if (valves_[valveI].curLift() > valves_[valveI].minLift())
103 //            if (valves_[valveI].curLift() > valves_[valveI].deformationLift())
104 //            {
105                 componentMixedTetPolyPatchVectorField& pp =
106                     refCast<componentMixedTetPolyPatchVectorField>
107                     (
108                         motionU.boundaryField()[cipIndex]
109                     );
110             
111                 pp.refValue() = vector::zero;
112                 pp.valueFraction() = vector::zero;
113 //            }
114 /*            else
115             {
116             
117 //              poppet deformation
118             
119                 componentMixedTetPolyPatchVectorField& pp =
120                     refCast<componentMixedTetPolyPatchVectorField>
121                     (
122                         motionU.boundaryField()[cipIndex]
123                     );
124                 
125                 scalarField cicPoints = 
126                 motionU.boundaryField()[cipIndex].patch()
127                 .localPoints().component(vector::Z);
128                 
129                 pp.valueFraction() = pos(cicPoints - zPoppetMin)*vector(0,0,1);
131                 pp.refValue() = (cicPoints - zCurtainMax)/(zPoppetMin - zCurtainMax)*valveVel;                                            
132             
133             }
135         }
137         if (valves_[valveI].stemPatchID().active())
138         {
139             label stemIndex = valves_[valveI].stemPatchID().index();
140             
141 //            if (valves_[valveI].curLift() > valves_[valveI].minLift())
142 //            if (valves_[valveI].curLift() > valves_[valveI].deformationLift())
143 //            {
144                 componentMixedTetPolyPatchVectorField& pp =
145                     refCast<componentMixedTetPolyPatchVectorField>
146                     (
147                         motionU.boundaryField()[stemIndex]
148                     );
149             
150                 pp.refValue() = vector::zero;
151                 pp.valueFraction() = vector::zero;
152 //            }
153 /*            else
154             {
155             
156 //              poppet deformation
157             
158                 componentMixedTetPolyPatchVectorField& pp =
159                     refCast<componentMixedTetPolyPatchVectorField>
160                     (
161                         motionU.boundaryField()[stemIndex]
162                     );
163                 
164                 scalarField stemPoints = 
165                 motionU.boundaryField()[stemIndex].patch()
166                 .localPoints().component(vector::Z);
168                 Info << "zPoppetMax = " << zPoppetMax << endl;
169                 Info << "zDetMax = " << zDetMax << endl;
171                 pp.valueFraction() = (1.0 - pos(stemPoints - zPoppetMax))*vector(0,0,1);
173                 pp.refValue() = (stemPoints - zDetMax)/(zPoppetMax - zDetMax)*valveVel;                                            
174             
175             }
177         }
179         
180        
181        {
182             label linerIndex = boundaryMesh().findPatchID("liner");
183             
184             componentMixedTetPolyPatchVectorField& pp =
185                 refCast<componentMixedTetPolyPatchVectorField>
186                 (
187                     motionU.boundaryField()[linerIndex]
188                 );
189             
190             scalarField linerPoints =
191                             motionU.boundaryField()[linerIndex].patch()
192                             .localPoints().component(vector::Z);
194             pp.refValue() = vector::zero;
195             pp.valueFraction() = vector::zero;
197         }
198        
199     }
201     // Set piston velocity
202     if (piston().patchID().active())
203     {
205         componentMixedTetPolyPatchVectorField& pp =
206             refCast<componentMixedTetPolyPatchVectorField>
207             (
208                 motionU.boundaryField()[piston().patchID().index()]
209             );
211         pp.refValue() = vector::zero;
212         
213     }
215     {
216         label cylinderHeadIndex = boundaryMesh().findPatchID("cylinderHead");
217         
218         // Top of the valve does not move
219         motionU.boundaryField()[cylinderHeadIndex] ==
220             vector::zero;
221     }
222     
223     mSolver.solve();
224     
225 //  Setting the boundary position
226         
227     movePoints(mSolver.curPoints());
229     // Blocking vertical motion
230     motionU.internalField().replace
231     (
232         vector::Z,
233         scalarField(mSolver.motionU().internalField().size(), 0)
234     );
235