Forward compatibility: flex
[foam-extend-3.2.git] / src / engine / engineTopoChangerMesh / thoboisSliding / setValveMotionBoundaryConditionThoboisSliding.H
blobe6b93017edefde176f66a6bcb2c407884473d728
1 // use tetrahedral decomposition of the engine mesh
5     Info << "setting valve motion b.c." << endl;
7     tetPointVectorField& motionU = mSolver.motionU();
11     // Set valve velocity
12     forAll (valves_, valveI)
13     {
15         vector valveVel =
16             valves_[valveI].curVelocity()*valves_[valveI].cs().axis();
18         if(valves_[valveI].curLift() > valves_[valveI].deformationLift())
19         {
20             valveVel = vector::zero;
21         }
23         Info << "Valve n. " << valveI + 1 << " velocity = " <<  valves_[valveI].curVelocity() << endl;
26         // If valve is present in geometry, set the motion
27         if (valves_[valveI].bottomPatchID().active())
28         {
29             // Bottom of the valve moves with given velocity
30             motionU.boundaryField()[valves_[valveI].bottomPatchID().index()] ==
31                 vector::zero;
33 //            if (debug)
34             {
35                 Info<< "Valve " << valveI << " lift: "
36                     << valves_[valveI].curLift()
37                     << " velocity: " << valves_[valveI].curVelocity()
38                     << endl;
39             }
40         }
42         if (valves_[valveI].poppetPatchID().active())
43         {
45             // Top of the valve does not move
46             motionU.boundaryField()[valves_[valveI].poppetPatchID().index()] ==
47                 valveVel;
48             {
49                 Info<< "Valve " << valveI << " lift: "
50                     << valves_[valveI].curLift()
51                     << " velocity: " << valves_[valveI].curVelocity()
52                     << endl;
53             }
54          }
56         if (valves_[valveI].sidePatchID().active())
57         {
58             // Top of the valve does not move
59             motionU.boundaryField()[valves_[valveI].sidePatchID().index()] ==
60                 valveVel;
61         }
63         if (valves_[valveI].detachInPortPatchID().active())
64         {
65             motionU.boundaryField()[valves_[valveI].detachInPortPatchID().index()] == vector::zero;
66         }
68         if (valves_[valveI].detachInCylinderPatchID().active())
69         {
70             motionU.boundaryField()[valves_[valveI].detachInCylinderPatchID().index()] == vector::zero;
71         }
73         // If valve is present in geometry, set the motion
74         if
75         (
76             valves_[valveI].curtainInPortPatchID().active()
77             &&
78             valves_[valveI].poppetPatchID().active()
79             &&
80             valves_[valveI].curtainInCylinderPatchID().active()
81         )
82         {
85             label curtainInPortIndex = valves_[valveI].curtainInPortPatchID().index();
86             label poppetIndex = valves_[valveI].poppetPatchID().index();
87             label curtainInCylIndex = valves_[valveI].curtainInCylinderPatchID().index();
89             const coordinateSystem& cSysV = valves_[valveI].cs();
91             const pointField& curtainInPortGlobal =
92                     motionU.boundaryField()[curtainInPortIndex].patch().localPoints();
94             const pointField& poppetGlobal =
95                     motionU.boundaryField()[poppetIndex].patch().localPoints();
97             const pointField& curtainInCylGlobal =
98                     motionU.boundaryField()[curtainInCylIndex].patch().localPoints();
100             scalarField curtainInPortLocal =  cSysV.localPosition(curtainInPortGlobal)().component(vector::Z);
101             scalarField poppetLocal =  cSysV.localPosition(poppetGlobal)().component(vector::Z);
102             scalarField curtainInCylLocal =  cSysV.localPosition(curtainInCylGlobal)().component(vector::Z);
104             scalar maxCurtain = max(curtainInCylLocal);
105             scalar minPoppet = min(poppetLocal);
107             Info << "maxCurtain = " << maxCurtain << endl;
108             Info << "minPoppet = " << minPoppet << endl;
110             motionU.boundaryField()[curtainInPortIndex] == (pos(curtainInPortLocal - minPoppet))*valveVel*(maxCurtain -
111             curtainInPortLocal)/(maxCurtain-minPoppet);
115 //            if (debug)
116             {
117                 Info<< "Valve " << valveI << " lift: "
118                     << valves_[valveI].curLift()
119                     << " velocity: " << valves_[valveI].curVelocity()
120                     << endl;
121             }
122         }
124     }
126 //  Setting the boundary position
127     Info << "valve motion boundary conditions set" << endl;