fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / pistonSliding / setValveMotionBoundaryConditionPistonSliding.H
blobe9b290072e6713df50c6a378af14d0fbf96330d7
1 // use tetrahedral decomposition of the engine mesh
4     
5     Info << "setting valve motion b.c." << endl;
7     tetPointVectorField& motionU = mSolver.motionU();
10     // Set valve velocity
11     forAll (valves_, valveI)
12     {
13         
14         vector valveVel =
15             valves_[valveI].curVelocity()*valves_[valveI].cs().axis();
17         if(valves_[valveI].curLift() > valves_[valveI].deformationLift())
18         {
19             valveVel = vector::zero;
20         }
21         
22         Info << "Valve n. " << valveI + 1 << " velocity = " <<  valves_[valveI].curVelocity() << endl;
24         
25         // If valve is present in geometry, set the motion
26         if (valves_[valveI].bottomPatchID().active())
27         {
28             // Bottom of the valve moves with given velocity
29             motionU.boundaryField()[valves_[valveI].bottomPatchID().index()] ==
30                 vector::zero;
32 //            if (debug)
33             {
34                 Info<< "Valve " << valveI << " lift: "
35                     << valves_[valveI].curLift()
36                     << " velocity: " << valves_[valveI].curVelocity()
37                     << endl;
38             }
39         }
41         if (valves_[valveI].poppetPatchID().active())
42         {
43                             
44             // Top of the valve does not move
45             motionU.boundaryField()[valves_[valveI].poppetPatchID().index()] ==
46                 valveVel;
47             {
48                 Info<< "Valve " << valveI << " lift: "
49                     << valves_[valveI].curLift()
50                     << " velocity: " << valves_[valveI].curVelocity()
51                     << endl;
52             }
53          }
55         if (valves_[valveI].sidePatchID().active())
56         {
57             // Top of the valve does not move
58             motionU.boundaryField()[valves_[valveI].sidePatchID().index()] ==
59                 valveVel;
60         }
61         
62         if (valves_[valveI].detachInPortPatchID().active())
63         {
64             motionU.boundaryField()[valves_[valveI].detachInPortPatchID().index()] == vector::zero;
65         }
67         if (valves_[valveI].detachInCylinderPatchID().active())
68         {
69             motionU.boundaryField()[valves_[valveI].detachInCylinderPatchID().index()] == vector::zero;
70         }
72         // If valve is present in geometry, set the motion
73         if 
74         (
75             valves_[valveI].curtainInPortPatchID().active()
76             &&
77             valves_[valveI].poppetPatchID().active()
78             &&
79             valves_[valveI].curtainInCylinderPatchID().active()
80         )
81         {
84             label curtainInPortIndex = valves_[valveI].curtainInPortPatchID().index();
85             label poppetIndex = valves_[valveI].poppetPatchID().index();
86             label curtainInCylIndex = valves_[valveI].curtainInCylinderPatchID().index();
87             
88             const coordinateSystem& cSysV = valves_[valveI].cs();
89                         
90             const pointField& curtainInPortGlobal = 
91                     motionU.boundaryField()[curtainInPortIndex].patch().localPoints();
92             
93             const pointField& poppetGlobal = 
94                     motionU.boundaryField()[poppetIndex].patch().localPoints();
96             const pointField& curtainInCylGlobal = 
97                     motionU.boundaryField()[curtainInCylIndex].patch().localPoints();
99             scalarField curtainInPortLocal =  cSysV.localPosition(curtainInPortGlobal)().component(vector::Z);               
100             scalarField poppetLocal =  cSysV.localPosition(poppetGlobal)().component(vector::Z);               
101             scalarField curtainInCylLocal =  cSysV.localPosition(curtainInCylGlobal)().component(vector::Z);               
102                 
103             scalar maxCurtain = max(curtainInCylLocal);
104             scalar minPoppet = min(poppetLocal);
105                 
106             Info << "maxCurtain = " << maxCurtain << endl;
107             Info << "minPoppet = " << minPoppet << endl;
108                                 
109             motionU.boundaryField()[curtainInPortIndex] == (pos(curtainInPortLocal - minPoppet))*valveVel*(maxCurtain -
110             curtainInPortLocal)/(maxCurtain-minPoppet);
111             
112                
114 //            if (debug)
115             {
116                 Info<< "Valve " << valveI << " lift: "
117                     << valves_[valveI].curLift()
118                     << " velocity: " << valves_[valveI].curVelocity()
119                     << endl;
120             }
121         }
122                 
123         }
125 //  Setting the boundary position
126     Info << "valve motion boundary conditions set" << endl;
127