Formatting
[foam-extend-3.2.git] / src / engine / engineTopoChangerMesh / engineValveSliding / setMotionBoundaryConditionEngineValveSliding.H
blobd80d8a1cf31c7db343a259e25459e0021c59d7d6
1 // use tetrahedral decomposition of the engine mesh
5     Info << "setting valve motion b.c." << endl;
7     tetPointVectorField& motionU = mSolver.motionU();
10     // set piston motion boundary conditions
12     // Set piston velocity
13     if (piston().patchID().active())
14     {
15         vector pistonVel =
16             piston().cs().axis()*engineTime_.pistonSpeed().value();
18         if (debug)
19         {
20             Info << "Piston velocity: " << pistonVel;
21         }
23         motionU.boundaryField()[piston().patchID().index()] == pistonVel;
25     }
27     // Set valve velocity
28     forAll (valves_, valveI)
29     {
31         vector valveVel =
32             valves_[valveI].curVelocity()*valves_[valveI].cs().axis();
34         Info << "Valve n. " << valveI + 1 << " velocity = " <<  valves_[valveI].curVelocity() << endl;
36         // If valve is present in geometry, set the motion
37         if (valves_[valveI].bottomPatchID().active())
38         {
39             // Bottom of the valve moves with given velocity
40             motionU.boundaryField()[valves_[valveI].bottomPatchID().index()] ==
41                 valveVel;
43         }
45         if (valves_[valveI].poppetPatchID().active())
46         {
48             if(valves_[valveI].curLift() < valves_[valveI].deformationLift())
49             {
50                 // Top of the valve does not move
51                 motionU.boundaryField()[valves_[valveI].poppetPatchID().index()] ==
52                     valveVel;
53             }
54             else
55             {
56                 // Top of the valve does not move
57                 motionU.boundaryField()[valves_[valveI].poppetPatchID().index()] ==
58                     vector::zero;
59             }
61         }
63         if (valves_[valveI].sidePatchID().active())
64         {
65             // Top of the valve does not move
66             motionU.boundaryField()[valves_[valveI].sidePatchID().index()] ==
67                 valveVel;
68         }
70         if (valves_[valveI].detachInPortPatchID().active())
71         {
72             motionU.boundaryField()[valves_[valveI].detachInPortPatchID().index()] == vector::zero;
73         }
75         if (valves_[valveI].detachInCylinderPatchID().active())
76         {
77             motionU.boundaryField()[valves_[valveI].detachInCylinderPatchID().index()] == vector::zero;
78         }
80         if
81         (
82             valves_[valveI].curtainInPortPatchID().active()
83             &&
84             valves_[valveI].poppetPatchID().active()
85             &&
86             valves_[valveI].curtainInCylinderPatchID().active()
87             &&
88             valves_[valveI].bottomPatchID().active()
89         )
90         {
92 //new
94             label curtainInCylIndex = valves_[valveI].curtainInCylinderPatchID().index();
95             label bottomIndex = valves_[valveI].bottomPatchID().index();
97 //            label poppetIndex = valves_[valveI].poppetPatchID().index();
98 //            label curtainInCylIndex = valves_[valveI].curtainInCylinderPatchID().index();
100             const coordinateSystem& cSysV = valves_[valveI].cs();
102             const pointField& curtainInCylGlobal =
103                     motionU.boundaryField()[curtainInCylIndex].patch().localPoints();
105             const pointField& bottomGlobal =
106                     motionU.boundaryField()[bottomIndex].patch().localPoints();
108             scalarField curtainInCylLocal = cSysV.localPosition(curtainInCylGlobal)().component(vector::Z);
110             scalarField bottomLocal = cSysV.localPosition(bottomGlobal)().component(vector::Z);
113             scalar maxCurtain = max(curtainInCylLocal);
115             scalar minCurtain = min(curtainInCylLocal);
116 //            scalar minCurtain = max(bottomLocal);
117             scalar maxBottom = max(bottomLocal);
120             Info << "minCurtain = " << minCurtain << endl;
121             Info << "maxBottom = " << max(bottomLocal) << endl;
124 //            motionU.boundaryField()[curtainInCylIndex] == (pos(curtainInCylLocal - minCurtain))*valveVel*(maxCurtain -
125 //            curtainInCylLocal)/(maxCurtain-minCurtain);
129             forAll(motionU.boundaryField()[curtainInCylIndex], pointi)
130             {
131                 if(curtainInCylLocal[pointi] > maxBottom)
132                 {
133                     motionU.boundaryField()[curtainInCylIndex][pointi]
134                     ==
135                     valveVel*
136                     (maxCurtain - curtainInCylLocal[pointi])
137                     /
138                     (maxCurtain-maxBottom);
139                 }
140                 else
141                 {
142                     motionU.boundaryField()[curtainInCylIndex][pointi]
143                     ==
144                     valveVel;
145                 }
146             }
151             motionU.boundaryField()[curtainInCylIndex] == valveVel*(maxCurtain -
152             curtainInCylLocal)/(maxCurtain-minCurtain);
154             motionU.boundaryField()[curtainInCylIndex] == pos(curtainInCylLocal - maxBottom) * valveVel*(maxCurtain -
155             curtainInCylLocal)/(maxCurtain-minCurtain) + (1.0 - pos(curtainInCylLocal - maxBottom)) * valveVel;
157 //            Info << "motionU" << motionU.boundaryField()[curtainInCylIndex] << endl;
159             Info << "valveVel" << valveVel << endl;
161 //            Info << "motionU.boundaryField()[curtainInCylIndex]" <<
162 //            motionU.boundaryField()[curtainInCylIndex] << endl;
164         }
166     }
168 //  Setting the boundary position
169     Info << "valve motion boundary conditions set" << endl;