1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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
25 \*---------------------------------------------------------------------------*/
27 #include "simpleTwoStroke.H"
28 #include "layerAdditionRemoval.H"
29 #include "componentMixedTetPolyPatchVectorField.H"
30 #include "mapPolyMesh.H"
31 #include "polyTopoChange.H"
32 #include "addToRunTimeSelectionTable.H"
33 #include "GeometricField.H"
35 #include "engineTime.H"
36 #include "pointField.H"
37 #include "fvPatchField.H"
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 defineTypeNameAndDebug(simpleTwoStroke, 0);
44 addToRunTimeSelectionTable(engineTopoChangerMesh, simpleTwoStroke, IOobject);
48 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
53 bool Foam::simpleTwoStroke::realDeformation() const
57 if (virtualPistonPosition()+ engTime().pistonDisplacement().value() > deckHeight()-engTime().clearance().value()-SMALL)
68 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
70 // Construct from components
71 Foam::simpleTwoStroke::simpleTwoStroke
76 engineTopoChangerMesh(io),
77 piston_(*this, engTime().engineDict().subDict("piston")),
78 scavInCylPatchName_(engTime().engineDict().lookup("scavInCylPatch")),
79 scavInPortPatchName_(engTime().engineDict().lookup("scavInPortPatch")),
80 movingPointsMaskPtr_(NULL),
81 deformSwitch_(readScalar(engTime().engineDict().lookup("deformAngle"))),
82 delta_(readScalar(engTime().engineDict().lookup("delta"))),
83 offSet_(readScalar(engTime().engineDict().lookup("offSet"))),
84 pistonPosition_(-GREAT),
85 virtualPistonPosition_(-GREAT),
92 engTime().engineDict().subDict("coordinateSystem")
97 boundaryMesh().findPatchID(scavInCylPatchName_) != -1
99 boundaryMesh().findPatchID(scavInPortPatchName_) != -1
101 scavPortsTol_(readScalar(engTime().engineDict().lookup("scavPortsTol")))
103 // Add zones and modifiers if not already there.
104 addZonesAndModifiers();
108 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
111 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114 void Foam::simpleTwoStroke::setBoundaryVelocity(volVectorField& U)
116 vector pistonVel = piston().cs().axis()*engTime().pistonSpeed().value();
118 // On the piston movingWallVelocity is used. There is no need to update
119 // the piston velocity
121 // U.boundaryField()[piston().patchID().index()] = pistonVel;
123 Info << "setting the boundary velocity" << endl;
124 U.boundaryField()[boundaryMesh().findPatchID(scavInPortPatchName_)] ==
129 bool Foam::simpleTwoStroke::portsOpened() const
132 scalar maxScavPortsZ = max
136 boundaryMesh().findPatchID(scavInPortPatchName_)
137 ].patch().localPoints()
141 scalar minLinerZ = min
145 boundaryMesh().findPatchID(scavInCylPatchName_)
146 ].patch().localPoints()
150 if (maxScavPortsZ - scavPortsTol_ < minLinerZ)
161 // ************************************************************************* //