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 "thoboisSliding.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(thoboisSliding, 0);
50 addToRunTimeSelectionTable(engineTopoChangerMesh, thoboisSliding, IOobject);
54 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
59 bool Foam::thoboisSliding::realDeformation() const
62 bool deformationValve = false;
63 forAll(valves(), valveI)
66 scalar maxLayer = piston().minLayer();
68 if(valves()[valveI].bottomPatchID().active())
70 maxLayer = max(maxLayer, valves()[valveI].minBottomLayer());
73 scalar valveDisplacement = valves_[valveI].curVelocity()*valves_[valveI].cs().axis().z()*engTime().deltaT().value() ;
74 if(valvePistonPosition()[valveI] + engTime().pistonDisplacement().value() >
75 valveBottomPosition_[valveI] + valveDisplacement - 5.0*maxLayer - 0.001 )
77 deformationValve = true;
85 else if (virtualPistonPosition() + engTime().pistonDisplacement().value() > deckHeight_ - SMALL)
95 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
97 // Construct from components
98 Foam::thoboisSliding::thoboisSliding
103 engineTopoChangerMesh(io),
104 piston_(*this, engTime().engineDict().subDict("piston")),
105 valves_(*this, engTime().engineDict().lookup("thoboisSliding")),
106 movingPointsMaskTopPtr_(NULL),
107 movingPointsMaskBottomPtr_(NULL),
108 deformSwitch_(readScalar(engTime().engineDict().lookup("deformAngle"))),
109 valveTopTol_(readScalar(engTime().engineDict().lookup("valveTopTol"))),
110 pistonPosition_(-GREAT),
111 virtualPistonPosition_(-GREAT),
112 valveTopPosition_(nValves(),-GREAT),
113 valveBottomPosition_(nValves(),GREAT),
114 valvePistonPosition_(nValves(),GREAT),
116 minValveZ_(nValves()),
117 poppetValveTol_(readScalar(engTime().engineDict().lookup("poppetValveTol"))),
118 bottomValveTol_(readScalar(engTime().engineDict().lookup("bottomValveTol"))),
119 msPtr_(motionSolver::New(*this)),
120 isReallyClosed_(valves().size(), false),
121 correctPointsMotion_(engTime().engineDict().lookup("correctPointsMotion"))
125 // Add zones and modifiers if not already there.
126 addZonesAndModifiers();
130 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
133 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
136 void Foam::thoboisSliding::setBoundaryVelocity(volVectorField& U)
140 // Set valve velociaty
141 forAll (valves(), valveI)
145 valves()[valveI].curVelocity()*valves()[valveI].cs().axis();
147 // If valve is present in geometry, set the motion
148 if (valves()[valveI].curtainInPortPatchID().active())
150 // Bottom of the valve moves with given velocity
151 U.boundaryField()[valves()[valveI].curtainInPortPatchID().index()] ==
156 // If valve is present in geometry, set the motion
157 if (valves()[valveI].curtainInCylinderPatchID().active())
159 // Bottom of the valve moves with given velocity
160 U.boundaryField()[valves()[valveI].curtainInCylinderPatchID().index()] ==
165 // If valve is present in geometry, set the motion
166 if (valves()[valveI].poppetPatchID().active())
168 // Bottom of the valve moves with given velocity
169 U.boundaryField()[valves()[valveI].poppetPatchID().index()] ==
173 if (valves()[valveI].bottomPatchID().active())
175 // Bottom of the valve moves with given velocity
176 U.boundaryField()[valves()[valveI].bottomPatchID().index()] ==
181 // If valve is present in geometry, set the motion
182 if (valves()[valveI].stemPatchID().active())
184 // Bottom of the valve moves with given velocity
185 U.boundaryField()[valves()[valveI].stemPatchID().index()] ==
194 bool Foam::thoboisSliding::inValve(const point& p, const label& i) const
196 scalar valveX = valves_[i].cs().origin().x();
197 scalar valveY = valves_[i].cs().origin().y();
198 return (sqrt(sqr(p.x()-valveX)+sqr(p.y()-valveY)) < 0.5*valves_[i].diameter());
201 bool Foam::thoboisSliding::inPiston(const point& p) const
203 scalar pistonX = piston_.cs().origin().x();
204 scalar pistonY = piston_.cs().origin().y();
205 return (sqrt(sqr(p.x()-pistonX)+sqr(p.y()-pistonY)) < 0.5*engTime().bore().value());
209 bool Foam::thoboisSliding::isACylinderHeadFace
211 const labelList& cylHeadFaces,
215 forAll(cylHeadFaces, i)
217 if(cylHeadFaces[i] == face)
228 // ************************************************************************* //