1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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
29 Manage time in terms of engine RPM and crank-angle.
31 When engineTime is in effect, the userTime is reported in degrees
32 crank-angle instead of in seconds. The RPM to be used is specified in
33 @c constant/engineGeometry. If only a time conversion is required,
34 the geometric engine parameters can be dropped or set to zero.
38 rpm rpm [0 0 -1 0 0] 2000;
40 conRodLength conRodLength [0 1 0 0 0] 0.0;
41 bore bore [0 1 0 0 0] 0.0;
42 stroke stroke [0 1 0 0 0] 0.0;
43 clearance clearance [0 1 0 0 0] 0.0;
47 The engineTime can currently only be selected at compile-time.
52 \*---------------------------------------------------------------------------*/
58 #include "dictionary.H"
59 #include "dimensionedScalar.H"
61 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 /*---------------------------------------------------------------------------*\
67 Class engineTime Declaration
68 \*---------------------------------------------------------------------------*/
79 dimensionedScalar rpm_;
81 //- Optional engine geometry parameters
82 dimensionedScalar conRodLength_;
83 dimensionedScalar bore_;
84 dimensionedScalar stroke_;
85 dimensionedScalar clearance_;
88 // Private Member Functions
90 //- Disallow default bitwise copy construct
91 engineTime(const engineTime&);
93 //- Disallow default bitwise assignment
94 void operator=(const engineTime&);
96 //- adjust read time values
97 void timeAdjustment();
103 //- Construct from objectRegistry arguments
107 const fileName& rootPath,
108 const fileName& caseName,
109 const fileName& systemName = "system",
110 const fileName& constantName = "constant",
111 const fileName& dictName = "engineGeometry"
116 virtual ~engineTime()
124 //- Convert degrees to radians
125 scalar degToRad(const scalar rad) const;
127 //- Convert degrees to seconds (for given engine speed in RPM)
128 scalar degToTime(const scalar theta) const;
130 //- Convert seconds to degrees (for given engine speed in RPM)
131 scalar timeToDeg(const scalar t) const;
133 //- Calculate the piston position from the engine geometry
134 // and given crank angle.
135 scalar pistonPosition(const scalar theta) const;
140 //- Return the engine geometry dictionary
141 const dictionary& engineDict() const
146 //- Return the engines current operating RPM
147 const dimensionedScalar& rpm() const
152 //- Return the engines connecting-rod length
153 const dimensionedScalar& conRodLength() const
155 return conRodLength_;
158 //- Return the engines bore
159 const dimensionedScalar& bore() const
164 //- Return the engines stroke
165 const dimensionedScalar& stroke() const
170 //- Return the engines clearance-gap
171 const dimensionedScalar& clearance() const
177 //- Return current crank-angle
178 scalar theta() const;
180 //- Return current crank-angle translated to a single revolution
181 // (value between -180 and 180 with 0 = top dead centre)
182 scalar thetaRevolution() const;
184 //- Return crank-angle increment
185 scalar deltaTheta() const;
187 //- Return current piston position
188 dimensionedScalar pistonPosition() const;
190 //- Return piston displacement for current time step
191 dimensionedScalar pistonDisplacement() const;
193 //- Return piston speed for current time step
194 dimensionedScalar pistonSpeed() const;
197 // Member functions overriding the virtual functions in time
199 //- Convert the user-time (CA deg) to real-time (s).
200 virtual scalar userTimeToTime(const scalar theta) const;
202 //- Convert the real-time (s) into user-time (CA deg)
203 virtual scalar timeToUserTime(const scalar t) const;
205 //- Read the control dictionary and set the write controls etc.
206 virtual void readDict();
211 //- Read the controlDict and set all the parameters
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 } // End namespace Foam
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 // ************************************************************************* //