fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / accordionEngineMesh / setValveMotionBoundaryConditionAccordionEngineMesh.H
blob99a16b5f0598b1b610fbabd0af67e5e31ca22599
1 // use tetrahedral decomposition of the engine mesh
4     
5     Info << "setting valve motion b.c." << endl;
7     tetPointVectorField& motionU = mSolver.motionU();
9     // Set valve velocity
10     forAll (valves_, valveI)
11     {
12         
13         Info << "Valve n. " << valveI + 1 << " velocity = " <<  valves_[valveI].curVelocity() << endl;
15         vector valveVel =
16             valves_[valveI].curVelocity()*valves_[valveI].cs().axis();
17         
18         // If valve is present in geometry, set the motion
19         if (valves_[valveI].bottomPatchID().active())
20         {
21             // Bottom of the valve moves with given velocity
22             motionU.boundaryField()[valves_[valveI].bottomPatchID().index()] ==
23                 valveVel;
25 //            if (debug)
26             {
27                 Info<< "Valve " << valveI << " lift: "
28                     << valves_[valveI].curLift()
29                     << " velocity: " << valves_[valveI].curVelocity()
30                     << endl;
31             }
32         }
34         if (valves_[valveI].poppetPatchID().active())
35         {
36                             
37             // Top of the valve does not move
38             motionU.boundaryField()[valves_[valveI].poppetPatchID().index()] ==
39                 valveVel;
40         }
42         if (valves_[valveI].sidePatchID().active())
43         {
44             // Top of the valve does not move
45             motionU.boundaryField()[valves_[valveI].sidePatchID().index()] ==
46                 valveVel;
47         }
48         
49         if
50         (
51                 moveDetach_ 
52                 && 
53             valves_[valveI].detachInPortPatchID().active()
54             && 
55             valves_[valveI].detachInCylinderPatchID().active()
56         )
57         {
58         
59             label detachInPortIndex = valves_[valveI].detachInPortPatchID().index();
60             label detachInCylIndex = valves_[valveI].detachInCylinderPatchID().index();
62             const coordinateSystem& cSysV = valves_[valveI].cs();
63                         
64             const pointField& detachInPortGlobal = 
65                     motionU.boundaryField()[detachInPortIndex].patch().localPoints();
66             
67             const pointField& detachInCylGlobal = 
68                     motionU.boundaryField()[detachInCylIndex].patch().localPoints();
70             scalarField detachInPortLocal =  cSysV.localPosition(detachInPortGlobal)().component(vector::Z);               
71             scalarField detachInCylLocal =  cSysV.localPosition(detachInCylGlobal)().component(vector::Z);               
72                 
73             scalar maxDetachInPort = max(detachInPortLocal);
74             scalar minDetachInPort = min(detachInPortLocal);
76             scalar maxDetachInCyl = max(detachInCylLocal);
77             scalar minDetachInCyl = min(detachInCylLocal);
78                 
79             Info << "maxDetachInPort = " << maxDetachInPort << endl;
80             Info << "minDetachInPort = " << minDetachInPort << endl;
81             Info << "maxDetachInCyl = " << maxDetachInCyl << endl;
82             Info << "minDetachInCyl = " << minDetachInCyl << endl;
83                                 
84                                 
85             motionU.boundaryField()[detachInPortIndex] == valveVel*(maxDetachInPort -
86             detachInPortLocal)/(maxDetachInPort-minDetachInPort);
87             
88             motionU.boundaryField()[detachInCylIndex] == valveVel*(maxDetachInCyl -
89             detachInCylLocal)/(maxDetachInCyl-minDetachInCyl);
90         }
91         else
92             {
93 /*              if (valves_[valveI].detachInPortPatchID().active())
94                 {
95                         motionU.boundaryField()[valves_[valveI].detachInPortPatchID().index()] == vector::zero;
96                 }
97                 Info << "detach in port" << endl;
99                 if (valves_[valveI].detachInCylinderPatchID().active())
100                 {       
101                         motionU.boundaryField()[valves_[valveI].detachInCylinderPatchID().index()] == vector::zero;
102                 }
103                 Info << "detach in cyl" << endl;
104 */              if
105                 (
106                     !moveDetach_
107                     &&
108                 valves_[valveI].detachInPortPatchID().active()
109                 && 
110                 valves_[valveI].detachInCylinderPatchID().active()
111                 )
113                 {
114                     motionU.boundaryField()[valves_[valveI].detachInPortPatchID().index()] == vector::zero;
115                     motionU.boundaryField()[valves_[valveI].detachInCylinderPatchID().index()] == vector::zero;
116                 }
117                 
118             }
119     }
120 //  Setting the boundary position
122     {
123         label cylinderHeadIndex = boundaryMesh().findPatchID(cylinderHeadName_);
124         
125         // Top of the valve does not move
126         motionU.boundaryField()[cylinderHeadIndex] ==
127             vector::zero;
128     }
129     
130     Info << "valve motion boundary conditions set" << endl;
131