1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2005-2010 Tommaso Lucchini
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM 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 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 \*---------------------------------------------------------------------------*/
30 #include "engineValveSliding.H"
31 #include "layerAdditionRemoval.H"
32 #include "attachDetach.H"
33 #include "componentMixedTetPolyPatchVectorField.H"
34 #include "mapPolyMesh.H"
35 #include "polyTopoChange.H"
36 #include "addToRunTimeSelectionTable.H"
37 #include "GeometricField.H"
39 #include "engineTime.H"
40 #include "pointField.H"
41 #include "fvPatchField.H"
43 #include "symmetryFvPatch.H"
44 #include "tetDecompositionMotionSolver.H"
46 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
50 defineTypeNameAndDebug(Foam::engineValveSliding, 0);
52 addToRunTimeSelectionTable
54 engineTopoChangerMesh,
61 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
63 bool Foam::engineValveSliding::realDeformation() const
68 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
70 // Construct from components
71 Foam::engineValveSliding::engineValveSliding
76 engineTopoChangerMesh(io),
77 piston_(*this, engTime().engineDict().subDict("piston")),
78 valves_(*this, engTime().engineDict().lookup("engineValveSliding")),
79 deformSwitch_(readScalar(engTime().engineDict().lookup("deformAngle"))),
80 valveTopTol_(readScalar(engTime().engineDict().lookup("valveTopTol"))),
81 pistonPosition_(-GREAT),
83 minValveZ_(nValves()),
86 readScalar(engTime().engineDict().lookup("poppetValveTol"))
90 readScalar(engTime().engineDict().lookup("bottomValveTol"))
92 msPtr_(motionSolver::New(*this)),
93 isReallyClosed_(valves().size(), false),
94 correctPointsMotion_(engTime().engineDict().lookup("correctPointsMotion"))
96 // Add zones and modifiers if not already there.
97 addZonesAndModifiers();
101 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 void Foam::engineValveSliding::setBoundaryVelocity(volVectorField& U)
105 // Set valve velociaty
106 forAll (valves(), valveI)
109 valves()[valveI].curVelocity()*valves()[valveI].cs().axis();
111 // If valve is present in geometry, set the motion
112 if (valves()[valveI].curtainInPortPatchID().active())
114 // Bottom of the valve moves with given velocity
116 [valves()[valveI].curtainInPortPatchID().index()] ==
121 // If valve is present in geometry, set the motion
122 if (valves()[valveI].curtainInCylinderPatchID().active())
124 // Bottom of the valve moves with given velocity
126 [valves()[valveI].curtainInCylinderPatchID().index()] ==
131 // If valve is present in geometry, set the motion
132 if (valves()[valveI].poppetPatchID().active())
134 // Bottom of the valve moves with given velocity
135 U.boundaryField()[valves()[valveI].poppetPatchID().index()] ==
139 if (valves()[valveI].bottomPatchID().active())
141 // Bottom of the valve moves with given velocity
142 U.boundaryField()[valves()[valveI].bottomPatchID().index()] ==
146 // If valve is present in geometry, set the motion
147 if (valves()[valveI].stemPatchID().active())
149 // Bottom of the valve moves with given velocity
150 U.boundaryField()[valves()[valveI].stemPatchID().index()] ==
158 bool Foam::engineValveSliding::inValve(const point& p, const label& i) const
160 scalar valveX = valves_[i].cs().origin().x();
161 scalar valveY = valves_[i].cs().origin().y();
164 sqrt(sqr(p.x() - valveX) + sqr(p.y() - valveY))
165 < 0.5*valves_[i].diameter()
169 bool Foam::engineValveSliding::inPiston(const point& p) const
171 scalar pistonX = piston_.cs().origin().x();
172 scalar pistonY = piston_.cs().origin().y();
175 sqrt(sqr(p.x() - pistonX) + sqr(p.y() - pistonY))
176 < 0.5*engTime().bore().value()
181 bool Foam::engineValveSliding::isACylinderHeadFace
183 const labelList& cylHeadFaces,
187 forAll(cylHeadFaces, i)
189 if(cylHeadFaces[i] == face)
200 // ************************************************************************* //