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 "thoboisSliding.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(thoboisSliding, 0);
51 addToRunTimeSelectionTable(engineTopoChangerMesh, thoboisSliding, IOobject);
55 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
60 bool Foam::thoboisSliding::realDeformation() const
63 bool deformationValve = false;
64 forAll(valves(), valveI)
67 scalar maxLayer = piston().minLayer();
69 if(valves()[valveI].bottomPatchID().active())
71 maxLayer = max(maxLayer, valves()[valveI].minBottomLayer());
74 scalar valveDisplacement = valves_[valveI].curVelocity()*valves_[valveI].cs().axis().z()*engTime().deltaT().value() ;
75 if(valvePistonPosition()[valveI] + engTime().pistonDisplacement().value() >
76 valveBottomPosition_[valveI] + valveDisplacement - 5.0*maxLayer - 0.001 )
78 deformationValve = true;
86 else if (virtualPistonPosition() + engTime().pistonDisplacement().value() > deckHeight_ - SMALL)
96 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
98 // Construct from components
99 Foam::thoboisSliding::thoboisSliding
104 engineTopoChangerMesh(io),
105 piston_(*this, engTime().engineDict().subDict("piston")),
106 valves_(*this, engTime().engineDict().lookup("thoboisSliding")),
107 movingPointsMaskTopPtr_(NULL),
108 movingPointsMaskBottomPtr_(NULL),
109 deformSwitch_(readScalar(engTime().engineDict().lookup("deformAngle"))),
110 valveTopTol_(readScalar(engTime().engineDict().lookup("valveTopTol"))),
111 pistonPosition_(-GREAT),
112 virtualPistonPosition_(-GREAT),
113 valveTopPosition_(nValves(),-GREAT),
114 valveBottomPosition_(nValves(),GREAT),
115 valvePistonPosition_(nValves(),GREAT),
117 minValveZ_(nValves()),
118 poppetValveTol_(readScalar(engTime().engineDict().lookup("poppetValveTol"))),
119 bottomValveTol_(readScalar(engTime().engineDict().lookup("bottomValveTol"))),
120 msPtr_(motionSolver::New(*this)),
121 isReallyClosed_(valves().size(), false),
122 correctPointsMotion_(engTime().engineDict().lookup("correctPointsMotion"))
126 // Add zones and modifiers if not already there.
127 addZonesAndModifiers();
131 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
134 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
137 void Foam::thoboisSliding::setBoundaryVelocity(volVectorField& U)
141 // Set valve velociaty
142 forAll (valves(), valveI)
146 valves()[valveI].curVelocity()*valves()[valveI].cs().axis();
148 // If valve is present in geometry, set the motion
149 if (valves()[valveI].curtainInPortPatchID().active())
151 // Bottom of the valve moves with given velocity
152 U.boundaryField()[valves()[valveI].curtainInPortPatchID().index()] ==
157 // If valve is present in geometry, set the motion
158 if (valves()[valveI].curtainInCylinderPatchID().active())
160 // Bottom of the valve moves with given velocity
161 U.boundaryField()[valves()[valveI].curtainInCylinderPatchID().index()] ==
166 // If valve is present in geometry, set the motion
167 if (valves()[valveI].poppetPatchID().active())
169 // Bottom of the valve moves with given velocity
170 U.boundaryField()[valves()[valveI].poppetPatchID().index()] ==
174 if (valves()[valveI].bottomPatchID().active())
176 // Bottom of the valve moves with given velocity
177 U.boundaryField()[valves()[valveI].bottomPatchID().index()] ==
182 // If valve is present in geometry, set the motion
183 if (valves()[valveI].stemPatchID().active())
185 // Bottom of the valve moves with given velocity
186 U.boundaryField()[valves()[valveI].stemPatchID().index()] ==
195 bool Foam::thoboisSliding::inValve(const point& p, const label& i) const
197 scalar valveX = valves_[i].cs().origin().x();
198 scalar valveY = valves_[i].cs().origin().y();
199 return (sqrt(sqr(p.x()-valveX)+sqr(p.y()-valveY)) < 0.5*valves_[i].diameter());
202 bool Foam::thoboisSliding::inPiston(const point& p) const
204 scalar pistonX = piston_.cs().origin().x();
205 scalar pistonY = piston_.cs().origin().y();
206 return (sqrt(sqr(p.x()-pistonX)+sqr(p.y()-pistonY)) < 0.5*engTime().bore().value());
210 bool Foam::thoboisSliding::isACylinderHeadFace
212 const labelList& cylHeadFaces,
216 forAll(cylHeadFaces, i)
218 if(cylHeadFaces[i] == face)
229 // ************************************************************************* //