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 "twoStrokeEngine.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(twoStrokeEngine, 0);
43 addToRunTimeSelectionTable
45 engineTopoChangerMesh,
52 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
54 bool Foam::twoStrokeEngine::realDeformation() const
58 virtualPistonPosition() + engTime().pistonDisplacement().value()
59 > deckHeight() - engTime().clearance().value() - SMALL
71 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
73 // Construct from components
74 Foam::twoStrokeEngine::twoStrokeEngine
79 engineTopoChangerMesh(io),
80 piston_(*this, engTime().engineDict().subDict("piston")),
81 scavInPortPatches_(engTime().engineDict().lookup("scavInPortPatches")),
82 scavInCylPatches_(engTime().engineDict().lookup("scavInCylPatches")),
83 headPointsSetName_(engTime().engineDict().lookup("headPointsSetName")),
84 headCellsSetName_(engTime().engineDict().lookup("headCellsSetName")),
85 movingCellSetName_(engTime().engineDict().lookup("movingCellSetName")),
86 movingPointsMaskPtr_(NULL),
87 deformSwitch_(readScalar(engTime().engineDict().lookup("deformAngle"))),
88 pistonPosition_(-GREAT),
89 virtualPistonPosition_(-GREAT),
96 engTime().engineDict().subDict("coordinateSystem")
101 if(scavInPortPatches_.size() != scavInCylPatches_.size())
105 "Foam::twoStrokeEngine::twoStrokeEngine(const IOobject& io)"
106 ) << "The size of the scavenging-cylinder patches is not"
107 << "the same of the scavenging-port patches"
108 << abort(FatalError);
111 forAll (scavInPortPatches_, patchi)
113 if(boundaryMesh().findPatchID(scavInPortPatches_[patchi]) == -1)
117 "Foam::twoStrokeEngine::twoStrokeEngine(const IOobject& io)"
118 ) << "patch called" << scavInPortPatches_[patchi]
120 << abort(FatalError);
124 forAll (scavInCylPatches_, patchi)
126 if(boundaryMesh().findPatchID(scavInCylPatches_[patchi]) == -1)
130 "Foam::twoStrokeEngine::twoStrokeEngine(const IOobject& io)"
131 ) << "patch called" << scavInCylPatches_[patchi]
133 << abort(FatalError);
137 // Add zones and modifiers if not already there.
138 addZonesAndModifiers();
142 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
144 void Foam::twoStrokeEngine::setBoundaryVelocity(volVectorField& U)
146 vector pistonVel = piston().cs().axis()*engTime().pistonSpeed().value();
148 // On the piston movingWallVelocity is used.
149 // There is no need to update the piston velocity
151 forAll (scavInPortPatches_, patchi)
153 const label curPatchID =
154 boundaryMesh().findPatchID(scavInPortPatches_[patchi]);
156 U.boundaryField()[curPatchID] == pistonVel;
161 // ************************************************************************* //