FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

engineTime.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::engineTime
00026 
00027 Description
00028     Manage time in terms of engine RPM and crank-angle.
00029 
00030     When engineTime is in effect, the userTime is reported in degrees
00031     crank-angle instead of in seconds. The RPM to be used is specified in
00032     @c constant/engineGeometry. If only a time conversion is required,
00033     the geometric engine parameters can be dropped or set to zero.
00034 
00035     For example,
00036     @verbatim
00037         rpm             rpm  [0 0 -1 0 0]  2000;
00038 
00039         conRodLength    conRodLength  [0 1 0 0 0] 0.0;
00040         bore            bore          [0 1 0 0 0] 0.0;
00041         stroke          stroke        [0 1 0 0 0] 0.0;
00042         clearance       clearance     [0 1 0 0 0] 0.0;
00043     @endverbatim
00044 
00045 Note
00046    The engineTime can currently only be selected at compile-time.
00047 
00048 SourceFiles
00049     engineTime.C
00050 
00051 \*---------------------------------------------------------------------------*/
00052 
00053 #ifndef engineTime_H
00054 #define engineTime_H
00055 
00056 #include <OpenFOAM/Time.H>
00057 #include <OpenFOAM/dictionary.H>
00058 #include <OpenFOAM/dimensionedScalar.H>
00059 
00060 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00061 
00062 namespace Foam
00063 {
00064 
00065 /*---------------------------------------------------------------------------*\
00066                         Class engineTime Declaration
00067 \*---------------------------------------------------------------------------*/
00068 
00069 class engineTime
00070 :
00071     public Time
00072 {
00073     // Private data
00074 
00075         IOdictionary dict_;
00076 
00077         //- RPM is required
00078         dimensionedScalar rpm_;
00079 
00080         //- Optional engine geometry parameters
00081         dimensionedScalar conRodLength_;
00082         dimensionedScalar bore_;
00083         dimensionedScalar stroke_;
00084         dimensionedScalar clearance_;
00085 
00086 
00087     // Private Member Functions
00088 
00089         //- Disallow default bitwise copy construct
00090         engineTime(const engineTime&);
00091 
00092         //- Disallow default bitwise assignment
00093         void operator=(const engineTime&);
00094 
00095         //- adjust read time values
00096         void timeAdjustment();
00097 
00098 public:
00099 
00100     // Constructors
00101 
00102         //- Construct from objectRegistry arguments
00103         engineTime
00104         (
00105             const word& name,
00106             const fileName& rootPath,
00107             const fileName& caseName,
00108             const fileName& systemName = "system",
00109             const fileName& constantName = "constant",
00110             const fileName& dictName = "engineGeometry"
00111         );
00112 
00113     // Destructor
00114 
00115         virtual ~engineTime()
00116         {}
00117 
00118 
00119     // Member Functions
00120 
00121         // Conversion
00122 
00123             //- Convert degrees to radians
00124             scalar degToRad(const scalar rad) const;
00125 
00126             //- Convert degrees to seconds (for given engine speed in RPM)
00127             scalar degToTime(const scalar theta) const;
00128 
00129             //- Convert seconds to degrees (for given engine speed in RPM)
00130             scalar timeToDeg(const scalar t) const;
00131 
00132             //- Calculate the piston position from the engine geometry
00133             //  and given crank angle.
00134             scalar pistonPosition(const scalar theta) const;
00135 
00136 
00137         // Access
00138 
00139             //- Return the engine geometry dictionary
00140             const dictionary& engineDict() const
00141             {
00142                 return dict_;
00143             }
00144 
00145             //- Return the engines current operating RPM
00146             const dimensionedScalar& rpm() const
00147             {
00148                 return rpm_;
00149             }
00150 
00151             //- Return the engines connecting-rod length
00152             const dimensionedScalar& conRodLength() const
00153             {
00154                 return conRodLength_;
00155             }
00156 
00157             //- Return the engines bore
00158             const dimensionedScalar& bore() const
00159             {
00160                 return bore_;
00161             }
00162 
00163             //- Return the engines stroke
00164             const dimensionedScalar& stroke() const
00165             {
00166                 return stroke_;
00167             }
00168 
00169             //- Return the engines clearance-gap
00170             const dimensionedScalar& clearance() const
00171             {
00172                 return clearance_;
00173             }
00174 
00175 
00176             //- Return current crank-angle
00177             scalar theta() const;
00178 
00179             //- Return current crank-angle translated to a single revolution
00180             //  (value between -180 and 180 with 0 = top dead centre)
00181             scalar thetaRevolution() const;
00182 
00183             //- Return crank-angle increment
00184             scalar deltaTheta() const;
00185 
00186             //- Return current piston position
00187             dimensionedScalar pistonPosition() const;
00188 
00189             //- Return piston displacement for current time step
00190             dimensionedScalar pistonDisplacement() const;
00191 
00192             //- Return piston speed for current time step
00193             dimensionedScalar pistonSpeed() const;
00194 
00195 
00196         // Member functions overriding the virtual functions in time
00197 
00198             //- Convert the user-time (CA deg) to real-time (s).
00199             virtual scalar userTimeToTime(const scalar theta) const;
00200 
00201             //- Convert the real-time (s) into user-time (CA deg)
00202             virtual scalar timeToUserTime(const scalar t) const;
00203 
00204             //- Read the control dictionary and set the write controls etc.
00205             virtual void readDict();
00206 
00207 
00208         // Edit
00209 
00210             //- Read the controlDict and set all the parameters
00211             virtual bool read();
00212 };
00213 
00214 
00215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00216 
00217 } // End namespace Foam
00218 
00219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00220 
00221 #endif
00222 
00223 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines