1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | 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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "simpleTwoStroke.H"
27 #include "layerAdditionRemoval.H"
28 #include "componentMixedTetPolyPatchVectorField.H"
29 #include "mapPolyMesh.H"
30 #include "polyTopoChange.H"
31 #include "addToRunTimeSelectionTable.H"
32 #include "GeometricField.H"
34 #include "engineTime.H"
35 #include "pointField.H"
36 #include "fvPatchField.H"
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(simpleTwoStroke, 0);
43 addToRunTimeSelectionTable(engineTopoChangerMesh, simpleTwoStroke, IOobject);
47 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
52 bool Foam::simpleTwoStroke::realDeformation() const
56 if (virtualPistonPosition()+ engTime().pistonDisplacement().value() > deckHeight()-engTime().clearance().value()-SMALL)
67 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
69 // Construct from components
70 Foam::simpleTwoStroke::simpleTwoStroke
75 engineTopoChangerMesh(io),
76 piston_(*this, engTime().engineDict().subDict("piston")),
77 scavInCylPatchName_(engTime().engineDict().lookup("scavInCylPatch")),
78 scavInPortPatchName_(engTime().engineDict().lookup("scavInPortPatch")),
79 movingPointsMaskPtr_(NULL),
80 deformSwitch_(readScalar(engTime().engineDict().lookup("deformAngle"))),
81 delta_(readScalar(engTime().engineDict().lookup("delta"))),
82 offSet_(readScalar(engTime().engineDict().lookup("offSet"))),
83 pistonPosition_(-GREAT),
84 virtualPistonPosition_(-GREAT),
91 engTime().engineDict().subDict("coordinateSystem")
96 boundaryMesh().findPatchID(scavInCylPatchName_) != -1
98 boundaryMesh().findPatchID(scavInPortPatchName_) != -1
100 scavPortsTol_(readScalar(engTime().engineDict().lookup("scavPortsTol")))
102 // Add zones and modifiers if not already there.
103 addZonesAndModifiers();
107 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113 void Foam::simpleTwoStroke::setBoundaryVelocity(volVectorField& U)
115 vector pistonVel = piston().cs().axis()*engTime().pistonSpeed().value();
117 // On the piston movingWallVelocity is used. There is no need to update
118 // the piston velocity
120 // U.boundaryField()[piston().patchID().index()] = pistonVel;
122 Info << "setting the boundary velocity" << endl;
123 U.boundaryField()[boundaryMesh().findPatchID(scavInPortPatchName_)] ==
128 bool Foam::simpleTwoStroke::portsOpened() const
131 scalar maxScavPortsZ = max
135 boundaryMesh().findPatchID(scavInPortPatchName_)
136 ].patch().localPoints()
140 scalar minLinerZ = min
144 boundaryMesh().findPatchID(scavInCylPatchName_)
145 ].patch().localPoints()
149 if (maxScavPortsZ - scavPortsTol_ < minLinerZ)
160 // ************************************************************************* //