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 "twoStrokeEngine.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(twoStrokeEngine, 0);
44 addToRunTimeSelectionTable
46 engineTopoChangerMesh,
53 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
55 bool Foam::twoStrokeEngine::realDeformation() const
59 virtualPistonPosition() + engTime().pistonDisplacement().value()
60 > deckHeight() - engTime().clearance().value() - SMALL
72 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
74 // Construct from components
75 Foam::twoStrokeEngine::twoStrokeEngine
80 engineTopoChangerMesh(io),
81 piston_(*this, engTime().engineDict().subDict("piston")),
82 scavInPortPatches_(engTime().engineDict().lookup("scavInPortPatches")),
83 scavInCylPatches_(engTime().engineDict().lookup("scavInCylPatches")),
84 headPointsSetName_(engTime().engineDict().lookup("headPointsSetName")),
85 headCellsSetName_(engTime().engineDict().lookup("headCellsSetName")),
86 movingCellSetName_(engTime().engineDict().lookup("movingCellSetName")),
87 movingPointsMaskPtr_(NULL),
88 deformSwitch_(readScalar(engTime().engineDict().lookup("deformAngle"))),
89 pistonPosition_(-GREAT),
90 virtualPistonPosition_(-GREAT),
97 engTime().engineDict().subDict("coordinateSystem")
102 if(scavInPortPatches_.size() != scavInCylPatches_.size())
106 "Foam::twoStrokeEngine::twoStrokeEngine(const IOobject& io)"
107 ) << "The size of the scavenging-cylinder patches is not"
108 << "the same of the scavenging-port patches"
109 << abort(FatalError);
112 forAll(scavInPortPatches_, patchi)
114 if(boundaryMesh().findPatchID(scavInPortPatches_[patchi]) == -1)
118 "Foam::twoStrokeEngine::twoStrokeEngine(const IOobject& io)"
119 ) << "patch called" << scavInPortPatches_[patchi]
121 << abort(FatalError);
125 forAll(scavInCylPatches_, patchi)
127 if(boundaryMesh().findPatchID(scavInCylPatches_[patchi]) == -1)
131 "Foam::twoStrokeEngine::twoStrokeEngine(const IOobject& io)"
132 ) << "patch called" << scavInCylPatches_[patchi]
134 << abort(FatalError);
138 // Add zones and modifiers if not already there.
139 addZonesAndModifiers();
143 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
146 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
149 void Foam::twoStrokeEngine::setBoundaryVelocity(volVectorField& U)
151 vector pistonVel = piston().cs().axis()*engTime().pistonSpeed().value();
153 // On the piston movingWallVelocity is used.
154 // There is no need to update the piston velocity
155 // U.boundaryField()[piston().patchID().index()] = pistonVel;
157 forAll(scavInPortPatches_, patchi)
160 [boundaryMesh().findPatchID(scavInPortPatches_[patchi])] ==
166 // ************************************************************************* //