![]() |
|
00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2005 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 the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 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, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Class 00026 engineTime 00027 00028 Description 00029 00030 SourceFiles 00031 engineTime.C 00032 00033 \*---------------------------------------------------------------------------*/ 00034 00035 #ifndef engineTime_H 00036 #define engineTime_H 00037 00038 #include "Time.H" 00039 #include "dictionary.H" 00040 #include "dimensionedScalar.H" 00041 00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00043 00044 namespace Foam 00045 { 00046 00047 /*---------------------------------------------------------------------------*\ 00048 Class engineTime Declaration 00049 \*---------------------------------------------------------------------------*/ 00050 00051 class engineTime 00052 : 00053 public Time 00054 { 00055 // Private data 00056 00057 IOdictionary engineGeometry_; 00058 00059 dimensionedScalar conRodLength_; 00060 dimensionedScalar bore_; 00061 dimensionedScalar stroke_; 00062 dimensionedScalar clearance_; 00063 dimensionedScalar rpm_; 00064 00065 00066 // Private Member Functions 00067 00068 //- Disallow default bitwise copy construct 00069 engineTime(const engineTime&); 00070 00071 //- Disallow default bitwise assignment 00072 void operator=(const engineTime&); 00073 00074 00075 public: 00076 00077 // Constructors 00078 00079 //- Construct from objectRegistry arguments 00080 engineTime 00081 ( 00082 const word& name, 00083 const fileName& rootPath, 00084 const fileName& caseName, 00085 const fileName& systemName = "system", 00086 const fileName& constantName = "constant" 00087 ); 00088 00089 // Destructor 00090 00091 virtual ~engineTime() 00092 {} 00093 00094 00095 // Member Functions 00096 00097 // Conversion 00098 00099 //- Convert degrees to radians 00100 scalar degToRad(const scalar rad) const; 00101 00102 //- Convert degrees to seconds (for given engine speed in RPM) 00103 scalar degToTime(const scalar theta) const; 00104 00105 //- Convert seconds to degrees (for given engine speed in RPM) 00106 scalar timeToDeg(const scalar t) const; 00107 00108 //- Calculate the piston position from the engine geometry 00109 // and given crank angle. 00110 scalar pistonPosition(const scalar theta) const; 00111 00112 00113 // Access 00114 00115 //- Return the engine geometry dictionary 00116 const dictionary& engineDict() const 00117 { 00118 return engineGeometry_; 00119 } 00120 00121 //- Return the engines connecting-rod length 00122 const dimensionedScalar& conRodLength() const 00123 { 00124 return conRodLength_; 00125 } 00126 00127 //- Return the engines bore 00128 const dimensionedScalar& bore() const 00129 { 00130 return bore_; 00131 } 00132 00133 //- Return the engines stroke 00134 const dimensionedScalar& stroke() const 00135 { 00136 return stroke_; 00137 } 00138 00139 //- Return the engines clearance-gap 00140 const dimensionedScalar& clearance() const 00141 { 00142 return clearance_; 00143 } 00144 00145 //- Return the engines current operating RPM 00146 const dimensionedScalar& rpm() const 00147 { 00148 return rpm_; 00149 } 00150 00151 00152 //- Return current crank-angle 00153 scalar theta() const; 00154 00155 //- Return current crank-angle translated to a single revolution 00156 // (value between -180 and 180 with 0 = top dead centre) 00157 scalar thetaRevolution() const; 00158 00159 //- Return crank-angle increment 00160 scalar deltaTheta() const; 00161 00162 //- Return current piston position 00163 dimensionedScalar pistonPosition() const; 00164 00165 //- Return piston displacement for current time step 00166 dimensionedScalar pistonDisplacement() const; 00167 00168 //- Return piston speed for current time step 00169 dimensionedScalar pistonSpeed() const; 00170 00171 00172 // Member functions overriding the virtual functions in time 00173 00174 //- Convert the user-time (CA deg) to real-time (s). 00175 scalar userTimeToTime(const scalar theta) const; 00176 00177 //- Convert the real-time (s) into user-time (CA deg) 00178 scalar timeToUserTime(const scalar t) const; 00179 00180 00181 // Edit 00182 00183 //- Read the controlDict and set all the parameters 00184 bool read(); 00185 }; 00186 00187 00188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00189 00190 } // End namespace Foam 00191 00192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00193 00194 #endif 00195 00196 // ************************************************************************* //