Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef Time_H
00039 #define Time_H
00040
00041 #include "TimePaths.H"
00042 #include <OpenFOAM/objectRegistry.H>
00043 #include <OpenFOAM/IOdictionary.H>
00044 #include <OpenFOAM/FIFOStack.H>
00045 #include <OpenFOAM/clock.H>
00046 #include <OSspecific/cpuTime.H>
00047 #include "TimeState.H"
00048 #include <OpenFOAM/Switch.H>
00049 #include <OpenFOAM/instantList.H>
00050 #include <OpenFOAM/NamedEnum.H>
00051 #include <OpenFOAM/typeInfo.H>
00052 #include <OpenFOAM/dlLibraryTable.H>
00053 #include <OpenFOAM/functionObjectList.H>
00054
00055
00056
00057 namespace Foam
00058 {
00059
00060
00061
00062
00063
00064 class Time
00065 :
00066 public clock,
00067 public cpuTime,
00068 public TimePaths,
00069 public objectRegistry,
00070 public TimeState
00071 {
00072
00073
00074
00075 IOdictionary controlDict_;
00076
00077 public:
00078
00079
00080 enum writeControls
00081 {
00082 wcTimeStep,
00083 wcRunTime,
00084 wcAdjustableRunTime,
00085 wcClockTime,
00086 wcCpuTime
00087 };
00088
00089
00090 enum stopAtControls
00091 {
00092 saEndTime,
00093 saNoWriteNow,
00094 saWriteNow,
00095 saNextWrite
00096 };
00097
00098
00099 enum fmtflags
00100 {
00101 general = 0,
00102 fixed = ios_base::fixed,
00103 scientific = ios_base::scientific
00104 };
00105
00106
00107 protected:
00108
00109
00110
00111 label startTimeIndex_;
00112 scalar startTime_;
00113 scalar endTime_;
00114
00115 static const NamedEnum<stopAtControls, 4> stopAtControlNames_;
00116 stopAtControls stopAt_;
00117
00118 static const NamedEnum<writeControls, 5> writeControlNames_;
00119 writeControls writeControl_;
00120
00121 scalar writeInterval_;
00122
00123 label purgeWrite_;
00124 mutable FIFOStack<word> previousOutputTimes_;
00125
00126
00127 bool subCycling_;
00128
00129
00130 autoPtr<TimeState> prevTimeState_;
00131
00132
00133 static fmtflags format_;
00134
00135
00136 static int precision_;
00137
00138
00139 void adjustDeltaT();
00140
00141
00142 void setControls();
00143
00144
00145 virtual void readDict();
00146
00147
00148 private:
00149
00150
00151 IOstream::streamFormat writeFormat_;
00152
00153
00154 IOstream::versionNumber writeVersion_;
00155
00156
00157 IOstream::compressionType writeCompression_;
00158
00159
00160 word graphFormat_;
00161
00162
00163 Switch runTimeModifiable_;
00164
00165
00166 dlLibraryTable::readDlLibrary readLibs_;
00167
00168
00169 mutable functionObjectList functionObjects_;
00170
00171
00172 public:
00173
00174 TypeName("time");
00175
00176
00177 static word controlDictName;
00178
00179
00180
00181
00182
00183 Time
00184 (
00185 const word& name,
00186 const fileName& rootPath,
00187 const fileName& caseName,
00188 const word& systemName = "system",
00189 const word& constantName = "constant"
00190 );
00191
00192
00193 Time
00194 (
00195 const dictionary& dict,
00196 const fileName& rootPath,
00197 const fileName& caseName,
00198 const word& systemName = "system",
00199 const word& constantName = "constant"
00200 );
00201
00202
00203 Time
00204 (
00205 const fileName& rootPath,
00206 const fileName& caseName,
00207 const word& systemName = "system",
00208 const word& constantName = "constant"
00209 );
00210
00211
00212
00213
00214
00215 virtual ~Time();
00216
00217
00218
00219
00220
00221
00222
00223 const fileName& rootPath() const
00224 {
00225 return TimePaths::rootPath();
00226 }
00227
00228
00229 const fileName& caseName() const
00230 {
00231 return TimePaths::caseName();
00232 }
00233
00234
00235 fileName path() const
00236 {
00237 return rootPath()/caseName();
00238 }
00239
00240 const dictionary& controlDict() const
00241 {
00242 return controlDict_;
00243 }
00244
00245 virtual const fileName& dbDir() const
00246 {
00247 return fileName::null;
00248 }
00249
00250
00251 fileName timePath() const
00252 {
00253 return path()/timeName();
00254 }
00255
00256
00257 IOstream::streamFormat writeFormat() const
00258 {
00259 return writeFormat_;
00260 }
00261
00262
00263 IOstream::versionNumber writeVersion() const
00264 {
00265 return writeVersion_;
00266 }
00267
00268
00269 IOstream::compressionType writeCompression() const
00270 {
00271 return writeCompression_;
00272 }
00273
00274
00275 const word& graphFormat() const
00276 {
00277 return graphFormat_;
00278 }
00279
00280
00281 virtual bool read();
00282
00283
00284 void readModifiedObjects();
00285
00286
00287
00288
00289 word findInstance
00290 (
00291 const fileName& dir,
00292 const word& name = word::null,
00293 const IOobject::readOption rOpt = IOobject::MUST_READ,
00294 const word& stopInstance = word::null
00295 ) const;
00296
00297
00298 instantList times() const;
00299
00300
00301
00302 word findInstancePath(const instant&) const;
00303
00304
00305 instant findClosestTime(const scalar) const;
00306
00307
00308 static label findClosestTimeIndex(const instantList&, const scalar);
00309
00310
00311 virtual bool writeObject
00312 (
00313 IOstream::streamFormat,
00314 IOstream::versionNumber,
00315 IOstream::compressionType
00316 ) const;
00317
00318
00319 bool writeNow();
00320
00321
00322 bool writeAndEnd();
00323
00324
00325
00326
00327
00328 static word timeName(const scalar);
00329
00330
00331 virtual word timeName() const;
00332
00333
00334 static instantList findTimes(const fileName&);
00335
00336
00337 virtual label startTimeIndex() const;
00338
00339
00340 virtual dimensionedScalar startTime() const;
00341
00342
00343 virtual dimensionedScalar endTime() const;
00344
00345
00346 const functionObjectList& functionObjects() const
00347 {
00348 return functionObjects_;
00349 }
00350
00351
00352 bool subCycling() const
00353 {
00354 return subCycling_;
00355 }
00356
00357
00358 const TimeState& prevTimeState() const
00359 {
00360 return prevTimeState_();
00361 }
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380 virtual bool run() const;
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395 virtual bool loop();
00396
00397
00398
00399
00400
00401
00402
00403 virtual bool end() const;
00404
00405
00406
00407
00408
00409 virtual void setTime(const Time&);
00410
00411
00412 virtual void setTime(const instant&, const label newIndex);
00413
00414
00415 virtual void setTime
00416 (
00417 const dimensionedScalar&,
00418 const label newIndex
00419 );
00420
00421
00422 virtual void setTime(const scalar, const label newIndex);
00423
00424
00425 virtual void setEndTime(const dimensionedScalar&);
00426
00427
00428 virtual void setEndTime(const scalar);
00429
00430
00431 virtual void setDeltaT(const dimensionedScalar&);
00432
00433
00434 virtual void setDeltaT(const scalar);
00435
00436
00437 virtual TimeState subCycle(const label nSubCycles);
00438
00439
00440 virtual void endSubCycle();
00441
00442
00443 functionObjectList& functionObjects()
00444 {
00445 return functionObjects_;
00446 }
00447
00448
00449
00450
00451
00452 virtual Time& operator+=(const dimensionedScalar&);
00453
00454
00455 virtual Time& operator+=(const scalar);
00456
00457
00458
00459
00460 virtual Time& operator++();
00461
00462
00463 virtual Time& operator++(int);
00464 };
00465
00466
00467
00468
00469 }
00470
00471
00472
00473 #endif
00474
00475