1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
27 \*---------------------------------------------------------------------------*/
29 #include "engineValveSliding.H"
30 #include "layerAdditionRemoval.H"
31 #include "attachDetach.H"
32 #include "componentMixedTetPolyPatchVectorField.H"
33 #include "mapPolyMesh.H"
34 #include "polyTopoChange.H"
35 #include "addToRunTimeSelectionTable.H"
36 #include "GeometricField.H"
38 #include "engineTime.H"
39 #include "pointField.H"
40 #include "fvPatchField.H"
42 #include "symmetryFvPatch.H"
43 #include "tetMotionSolver.H"
45 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
49 defineTypeNameAndDebug(Foam::engineValveSliding, 0);
51 addToRunTimeSelectionTable
53 engineTopoChangerMesh,
60 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
62 bool Foam::engineValveSliding::realDeformation() const
67 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
69 // Construct from components
70 Foam::engineValveSliding::engineValveSliding
75 engineTopoChangerMesh(io),
76 piston_(*this, engTime().engineDict().subDict("piston")),
77 valves_(*this, engTime().engineDict().lookup("engineValveSliding")),
78 deformSwitch_(readScalar(engTime().engineDict().lookup("deformAngle"))),
79 valveTopTol_(readScalar(engTime().engineDict().lookup("valveTopTol"))),
80 pistonPosition_(-GREAT),
82 minValveZ_(nValves()),
85 readScalar(engTime().engineDict().lookup("poppetValveTol"))
89 readScalar(engTime().engineDict().lookup("bottomValveTol"))
91 msPtr_(motionSolver::New(*this)),
92 isReallyClosed_(valves().size(), false),
93 correctPointsMotion_(engTime().engineDict().lookup("correctPointsMotion"))
95 // Add zones and modifiers if not already there.
96 addZonesAndModifiers();
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 void Foam::engineValveSliding::setBoundaryVelocity(volVectorField& U)
104 // Set valve velociaty
105 forAll (valves(), valveI)
108 valves()[valveI].curVelocity()*valves()[valveI].cs().axis();
110 // If valve is present in geometry, set the motion
111 if (valves()[valveI].curtainInPortPatchID().active())
113 // Bottom of the valve moves with given velocity
115 [valves()[valveI].curtainInPortPatchID().index()] ==
120 // If valve is present in geometry, set the motion
121 if (valves()[valveI].curtainInCylinderPatchID().active())
123 // Bottom of the valve moves with given velocity
125 [valves()[valveI].curtainInCylinderPatchID().index()] ==
130 // If valve is present in geometry, set the motion
131 if (valves()[valveI].poppetPatchID().active())
133 // Bottom of the valve moves with given velocity
134 U.boundaryField()[valves()[valveI].poppetPatchID().index()] ==
138 if (valves()[valveI].bottomPatchID().active())
140 // Bottom of the valve moves with given velocity
141 U.boundaryField()[valves()[valveI].bottomPatchID().index()] ==
145 // If valve is present in geometry, set the motion
146 if (valves()[valveI].stemPatchID().active())
148 // Bottom of the valve moves with given velocity
149 U.boundaryField()[valves()[valveI].stemPatchID().index()] ==
157 bool Foam::engineValveSliding::inValve(const point& p, const label& i) const
159 scalar valveX = valves_[i].cs().origin().x();
160 scalar valveY = valves_[i].cs().origin().y();
163 sqrt(sqr(p.x() - valveX) + sqr(p.y() - valveY))
164 < 0.5*valves_[i].diameter()
168 bool Foam::engineValveSliding::inPiston(const point& p) const
170 scalar pistonX = piston_.cs().origin().x();
171 scalar pistonY = piston_.cs().origin().y();
174 sqrt(sqr(p.x() - pistonX) + sqr(p.y() - pistonY))
175 < 0.5*engTime().bore().value()
180 bool Foam::engineValveSliding::isACylinderHeadFace
182 const labelList& cylHeadFaces,
186 forAll(cylHeadFaces, i)
188 if(cylHeadFaces[i] == face)
199 // ************************************************************************* //