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 #ifndef twoStrokeEngine_H
28 #define twoStrokeEngine_H
30 #include "engineTopoChangerMesh.H"
31 #include "enginePiston.H"
32 #include "motionSolver.H"
33 #include "polyPatchID.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 // Class forward declarations
42 /*---------------------------------------------------------------------------*\
43 Class twoStrokeEngine Declaration
44 \*---------------------------------------------------------------------------*/
48 public engineTopoChangerMesh
55 //- Scavenging ports patches
56 wordList scavInPortPatches_;
58 //- Scavenging cylinder patches
59 wordList scavInCylPatches_;
61 //- Name of the head pointSet
62 word headPointsSetName_;
64 //- Name of the head pointSet
65 word headCellsSetName_;
67 //- Name of the moving cell set
68 word movingCellSetName_;
71 //- Markup field for points. Moving points marked with 1
72 mutable scalarField* movingPointsMaskPtr_;
74 //- Layering-to-deformation switch in crank-angle degrees
78 scalar pistonPosition_;
80 //- Virtual piston position (pistonPosition + offSet)
81 scalar virtualPistonPosition_;
87 autoPtr<coordinateSystem> csPtr_;
90 // Private Member Functions
92 //- Disallow default bitwise copy construct
93 twoStrokeEngine(const twoStrokeEngine&);
95 //- Disallow default bitwise assignment
96 void operator=(const twoStrokeEngine&);
98 //- Make layering modifiers live
99 void makeLayersLive();
101 //- Make Sliding interface modifiers live
102 void makeSlidersLive();
104 //- Is the sliding interface attached?
105 bool attached() const;
107 //- Check if all patches exist, then calculate virtualPistonPosition,
108 //- pistonPosition and deckHeight for the first time
109 void checkAndCalculate();
111 //- Calculate the virtualPistonPosition,
112 void setVirtualPistonPosition();
114 //- Correct the vertical motion for the points below the
116 void correctVerticalMotion();
118 //- Apply the moving mask, the points of the ports do not move.
119 void applyMovingMask();
121 //- Calculate moving masks
122 void calcMovingMasks() const;
124 //- Return moving points mask
125 const scalarField& movingPointsMask() const;
127 bool realDeformation() const;
129 void checkMotionFluxes();
134 //- Runtime type information
135 TypeName("twoStrokeEngine");
140 //- Construct from database
141 explicit twoStrokeEngine(const IOobject& io);
144 // Destructor - default
149 //- Return coordinate system
150 const coordinateSystem& cs() const
155 const scalar& pistonPosition() const
157 return pistonPosition_;
160 scalar& pistonPosition()
162 return pistonPosition_;
165 const scalar& virtualPistonPosition() const
167 return virtualPistonPosition_;
170 scalar& virtualPistonPosition()
172 return virtualPistonPosition_;
175 const scalar& deckHeight() const
185 const enginePiston& piston() const
190 //- Return true for mesh deformation mode
191 bool deformation() const
194 engTime().thetaRevolution() > -deformSwitch_
195 && engTime().thetaRevolution() < deformSwitch_;
199 //- Add valve and piston zones and modifiers
200 void addZonesAndModifiers();
203 virtual bool update();
205 //- Set boundary velocities
206 void setBoundaryVelocity(volVectorField& U);
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 } // End namespace Foam
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 // ************************************************************************* //