Time.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2019 OpenFOAM Foundation
9  Copyright (C) 2016-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::Time
29 
30 Description
31  Class to control time during OpenFOAM simulations that is also the
32  top-level objectRegistry.
33 
34 SourceFiles
35  Time.C
36  TimeIO.C
37  findInstance.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef Foam_Time_H
42 #define Foam_Time_H
43 
44 #include "TimePaths.H"
45 #include "objectRegistry.H"
46 #include "unwatchedIOdictionary.H"
47 #include "FIFOStack.H"
48 #include "clock.H"
49 #include "cpuTime.H"
50 #include "TimeState.H"
51 #include "Switch.H"
52 #include "instantList.H"
53 #include "Enum.H"
54 #include "typeInfo.H"
55 #include "dlLibraryTable.H"
56 #include "functionObjectList.H"
57 #include "sigWriteNow.H"
58 #include "sigStopAtWriteNow.H"
59 
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 
62 namespace Foam
63 {
64 
65 // Forward Declarations
66 class argList;
67 class profilingTrigger;
68 class OSstream;
69 
70 /*---------------------------------------------------------------------------*\
71  Class Time Declaration
72 \*---------------------------------------------------------------------------*/
73 
74 class Time
75 :
76  public clock,
77  public cpuTime,
78  public TimePaths,
79  public objectRegistry,
80  public TimeState
81 {
82 public:
83 
84  //- Write control options
86  {
91  wcClockTime,
92  wcCpuTime,
93  wcUnknown
94  };
95 
96  //- Stop-run control options, which are primarily used when
97  //- altering the stopAt condition.
98  enum stopAtControls
99  {
104  saUnknown
105  };
106 
107  //- Names for writeControls
110  //- Names for stopAtControls
112 
113 
114  //- Style for "ExecutionTime = " output
115  // 0 = seconds (with trailing 's')
116  // 1 = day-hh:mm:ss
117  //
118  // \note this is public so registered info switches can modify it.
119  static int printExecutionFormat_;
120 
121 
122 private:
123 
124  // Private Data
126  //- Profiling trigger for time-loop (for run, loop)
127  mutable std::unique_ptr<profilingTrigger> loopProfiling_;
128 
129  //- Any loaded dynamic libraries
130  // Construct before reading controlDict
131  mutable dlLibraryTable libs_;
132 
133  //- The controlDict
134  unwatchedIOdictionary controlDict_;
135 
136 
137 protected:
138 
139  // Protected Data
140 
141  label startTimeIndex_;
142 
143  scalar startTime_;
144 
145  mutable scalar endTime_;
146 
147  mutable stopAtControls stopAt_;
148 
150 
151  scalar writeInterval_;
152 
153  label purgeWrite_;
157  //- The total number of sub-cycles, the current sub-cycle index,
158  //- or 0 if time is not being sub-cycled
159  label subCycling_;
161  // One-shot writing
163 
164  //- If time is being sub-cycled this is the previous TimeState
167  //- Signal handler for one-shot writing upon signal
169 
170  //- Signal handler for write and clean exit upon signal
172 
173  //- Format for time directory names (general | fixed | scientific)
175 
176  //- Time directory name precision
177  static int precision_;
178 
179  //- Maximum time directory name precision
180  static const int maxPrecision_;
181 
183  //- Adjust the time step so that writing occurs at the specified time
184  void adjustDeltaT();
185 
186  //- Set the controls from the current controlDict
187  void setControls();
188 
189  //- Set file monitoring, profiling, etc
190  // Optionally force profiling without inspecting the controlDict
191  void setMonitoring(const bool forceProfiling=false);
193  //- Read the control dictionary and set the write controls etc.
194  virtual void readDict();
195 
196 
197 private:
198 
199  //- The write stream option (format, compression, version)
200  IOstreamOption writeStreamOption_;
201 
202  //- Default graph format
203  word graphFormat_;
204 
205  //- Is runtime modification of dictionaries allowed?
206  Switch runTimeModifiable_;
208  //- Is temporary object cache enabled?
209  mutable bool cacheTemporaryObjects_;
210 
211  //- Function objects executed at start and on ++, +=
212  mutable functionObjectList functionObjects_;
213 
214 
215 public:
216 
217  // Static Data Members
218 
219  //- The default control dictionary name (normally "controlDict")
220  static word controlDictName;
221 
222 
223  //- Runtime type information
224  TypeName("time");
225 
226 
227  // Constructors
228 
229  // Construct from argList
230 
231  //- Construct from argument list,
232  //- reading from specified control dictionary name
233  // Uses "system" and "constant" for its directories.
234  inline Time
235  (
236  const word& ctrlDictName,
237  const argList& args,
238  const bool enableFunctionObjects = true,
239  const bool enableLibs = true,
242  );
243 
244  //- Construct from argument list,
245  //- reading from specified control dictionary name.
246  // Use specified system/constant directory names.
247  Time
248  (
249  const word& ctrlDictName,
250  const argList& args,
251  const word& systemDirName,
252  const word& constantDirName,
253  const bool enableFunctionObjects = true,
254  const bool enableLibs = true,
257  );
258 
259 
260  // Construct from root and case paths
261 
262  //- Construct given name of dictionary to read and root/case paths.
263  // Uses "system" and "constant" for its directories.
264  inline Time
265  (
266  const word& ctrlDictName,
267  const fileName& rootPath,
269  const bool enableFunctionObjects = true,
270  const bool enableLibs = true,
273  );
274 
275  //- Construct given name of dictionary to read and root/case paths.
276  // Use specified system/constant directory names.
277  Time
278  (
279  const word& ctrlDictName,
280  const fileName& rootPath,
281  const fileName& caseName,
282  const word& systemDirName,
283  const word& constantDirName,
284  const bool enableFunctionObjects = true,
285  const bool enableLibs = true,
288  );
289 
290  //- Construct from root/case paths,
291  //- with initial dictionary content
292  //- \em without reading from "controlDict".
293  // Uses "system" and "constant" for its directories.
294  inline Time
295  (
296  const dictionary& dict,
297  const fileName& rootPath,
298  const fileName& caseName,
299  const bool enableFunctionObjects = true,
300  const bool enableLibs = true,
303  );
304 
305  //- Construct from root/case paths,
306  //- with initial dictionary content
307  //- \em without reading from "controlDict".
308  // Use specified system/constant directory names.
309  Time
310  (
311  const dictionary& dict,
312  const fileName& rootPath,
313  const fileName& caseName,
314  const word& systemDirName,
315  const word& constantDirName,
316  const bool enableFunctionObjects = true,
317  const bool enableLibs = true,
320  );
321 
322  //- Construct from root/case paths
323  //- \em without reading or requiring a controlDict or other files.
324  // Uses "system" and "constant" for its directories.
325  // Uses default controls values
326  // (write: timeStep, stop: endTime, format: ASCII, ...),
327  inline Time
328  (
329  const fileName& rootPath,
330  const fileName& caseName,
331  const bool enableFunctionObjects = true,
332  const bool enableLibs = true
333  );
334 
335  //- Construct from root/case paths
336  //- \em without reading or requiring a controlDict or other files.
337  // Use specified system/constant directory names.
338  // Uses default controls values
339  // (write: timeStep, stop: endTime, format: ASCII, ...)
340  Time
341  (
342  const fileName& rootPath,
343  const fileName& caseName,
344  const word& systemDirName,
345  const word& constantDirName,
346  const bool enableFunctionObjects = true,
347  const bool enableLibs = true
348  );
349 
350 
351  // Factory Methods
352 
353  //- Construct (dummy) Time - no functionObjects or libraries
354  static autoPtr<Time> New();
355 
356  //- Construct (dummy) Time - no functionObjects or libraries
357  static autoPtr<Time> New(const fileName& caseDir);
358 
359  //- Construct (dummy) Time - no functionObjects or libraries
360  static autoPtr<Time> New(const argList& args);
361 
362  //- Construct (dummy) global Time - no functionObjects or libraries,
363  //- using the global path information stored in the FOAM_CASE
364  //- environment. See argList::envGlobalPath()
365  static autoPtr<Time> NewGlobalTime();
366 
367  //- Construct (dummy) global Time - no functionObjects or libraries,
368  //- using the global path information from the referenced Time.
369  static autoPtr<Time> NewGlobalTime(const Time& runTime);
370 
371 
372  //- Destructor
373  virtual ~Time();
374 
375 
376  // Member Functions
377 
378  // TimeState Functions
379 
380  //- Return the current time name
381  using TimeState::timeName;
382 
383  //- Return a time name for the given scalar time value
384  //- formatted with the given precision
385  static word timeName(const scalar t, const int precision = precision_);
386 
387 
388  // Database names and paths
389 
390  //- Use name from objectRegistry, not TimePaths
391  using objectRegistry::name;
392 
393  //- Return the rootPath
394  using TimePaths::rootPath;
395 
396  //- Return global case name
398 
399  //- Return case name
400  using TimePaths::caseName;
401 
402  //- Return path = rootPath/caseName. Same as TimePaths::path()
403  fileName path() const
404  {
406  }
407 
408  //- Return global path for the case = rootPath/globalCaseName.
409  //- Same as TimePaths::globalPath()
410  fileName globalPath() const
411  {
413  }
414 
415  //- Return current time path = path/timeName
416  fileName timePath() const
417  {
419  }
420 
421  //- Return current time global path = globalPath/timeName
422  fileName globalTimePath() const
423  {
425  }
426 
427 
428  // Database Functions
429 
430  //- Return read access to the controlDict dictionary
431  const dictionary& controlDict() const noexcept { return controlDict_; }
432 
433  virtual const fileName& dbDir() const { return fileName::null; }
434 
435  //- Get write stream option (format, compression, version)
436  inline IOstreamOption writeStreamOption() const noexcept;
437 
438  //- Get write stream format
439  inline IOstreamOption::streamFormat writeFormat() const noexcept;
440 
441  //- Set the write stream format and return the previous value.
442  // This change will only effective until the next readModified.
443  // As a side-effect (eg, changing from ASCII to BINARY)
444  // it may also disable compression
445  inline IOstreamOption::streamFormat
446  writeFormat(IOstreamOption::streamFormat fmt) noexcept;
447 
448  //- Get the write stream compression
449  inline IOstreamOption::compressionType writeCompression()
450  const noexcept;
451 
452  //- Get the write stream version
453  inline IOstreamOption::versionNumber writeVersion() const noexcept;
454 
455  //- Default graph format
456  const word& graphFormat() const noexcept { return graphFormat_; }
457 
458 
459  // Reading
460 
461  //- Supports re-reading
462  Switch runTimeModifiable() const noexcept
463  {
464  return runTimeModifiable_;
465  }
466 
467  //- Set re-reading support on/off (use with caution).
468  // \return the previous value
469  Switch runTimeModifiable(Switch sw) noexcept
470  {
471  Switch old(runTimeModifiable_);
472  runTimeModifiable_ = sw;
473  return old;
474  }
475 
476  //- Read control dictionary, update controls and time
477  virtual bool read();
478 
479  //- Read the objects that have been modified
480  void readModifiedObjects();
481 
482 
483  // Searching
484 
485  //- Return time instance (location) of \em dir that contains
486  //- the file \em name (eg, used in reading mesh data).
487  // When \em is empty, searches for directory \em dir only.
488  // Does not search beyond stopInstance (if set) or \em constant.
489  //
490  // \note If the instance cannot be found, returns the
491  // stopInstance (if set and reached) or \em constant.
492  // FatalError if it cannot be found and readOpt is
493  // (MUST_READ or READ_MODIFIED).
494  word findInstance
495  (
496  const fileName& dir,
497  const word& name = word::null,
499  const word& stopInstance = word::null
500  ) const;
501 
502  //- Search the case for the time directory path
503  //- corresponding to the given instance
505  (
506  const fileName& directory,
507  const instant& t
508  ) const;
509 
510  //- Search the case for the time directory path
511  //- corresponding to the given instance
512  word findInstancePath(const instant& t) const;
513 
514 
515  // Member Functions
516 
517  // Writing
518 
519  //- Write time dictionary to the <time>/uniform directory
520  virtual bool writeTimeDict() const;
521 
522  //- Write using stream options
523  virtual bool writeObject
524  (
525  IOstreamOption streamOpt,
526  const bool writeOnProc
527  ) const;
529  //- Write the objects immediately (not at end of iteration)
530  //- and continue the run
531  bool writeNow();
532 
533  //- Write the objects now (not at end of iteration) and end the run
534  bool writeAndEnd();
535 
536  //- Write the objects once (one shot) and continue the run
537  void writeOnce();
538 
539  //- Print the elapsed ExecutionTime (cpu-time), ClockTime
542 
543  // Access
544 
545  //- Return start time index
546  virtual label startTimeIndex() const;
547 
548  //- Return start time
549  virtual dimensionedScalar startTime() const;
550 
551  //- Return end time
552  virtual dimensionedScalar endTime() const;
553 
554  //- Return the stop control information
555  virtual stopAtControls stopAt() const;
556 
557  //- Return true if adjustTimeStep is true
558  virtual bool isAdjustTimeStep() const;
559 
560  //- Return the list of function objects
562  {
563  return functionObjects_;
564  }
565 
566  //- Mutable access to the loaded dynamic libraries
567  dlLibraryTable& libs() const noexcept
568  {
569  return libs_;
570  }
571 
572  //- Zero (tests as false) if time is not being sub-cycled,
573  //- otherwise the current sub-cycle index or the total number of
574  //- sub-cycles.
575  // The interpretation of non-zero values is dependent on the
576  // routine.
577  label subCycling() const noexcept
578  {
579  return subCycling_;
580  }
581 
582  //- Return previous TimeState if time is being sub-cycled
583  const TimeState& prevTimeState() const
584  {
585  return *prevTimeState_;
586  }
587 
588 
589  // Check
590 
591  //- Return true if run should continue,
592  // also invokes the functionObjectList::end() method
593  // when the time goes out of range
594  // \note
595  // For correct behaviour, the following style of time-loop
596  // is recommended:
597  // \code
598  // while (runTime.run())
599  // {
600  // ++runTime;
601  // solve;
602  // runTime.write();
603  // }
604  // \endcode
605  virtual bool run() const;
606 
607  //- Return true if run should continue and if so increment time
608  // also invokes the functionObjectList::end() method
609  // when the time goes out of range
610  // \note
611  // For correct behaviour, the following style of time-loop
612  // is recommended:
613  // \code
614  // while (runTime.loop())
615  // {
616  // solve;
617  // runTime.write();
618  // }
619  // \endcode
620  virtual bool loop();
621 
622  //- Return true if end of run,
623  // does not invoke any functionObject methods
624  // \note
625  // The rounding heuristics near endTime mean that
626  // \code run() \endcode and \code !end() \endcode may
627  // not yield the same result
628  virtual bool end() const;
629 
630 
631  // Edit
632 
633  //- Adjust the current stopAtControl.
634  // \param stopCtrl the new stop control, whereby
635  // stopAtControls::saUnknown is treated as a no-op.
636  // \note this value only persists until the next time the
637  // dictionary is read.
638  // \return true if the stopAt() value was changed.
639  virtual bool stopAt(const stopAtControls stopCtrl) const;
640 
641  //- Reset the time and time-index to those of the given time
642  virtual void setTime(const Time& t);
643 
644  //- Reset the time and time-index
645  virtual void setTime(const instant& inst, const label newIndex);
646 
647  //- Reset the time and time-index
648  virtual void setTime
649  (
650  const dimensionedScalar& newTime,
651  const label newIndex
652  );
653 
654  //- Reset the time and time-index
655  virtual void setTime(const scalar newTime, const label newIndex);
656 
657  //- Reset end time
658  virtual void setEndTime(const dimensionedScalar& endTime);
659 
660  //- Reset end time
661  virtual void setEndTime(const scalar endTime);
662 
663  //- Reset time step, normally also calling adjustDeltaT()
664  virtual void setDeltaT
665  (
666  const dimensionedScalar& deltaT,
667  const bool adjust = true
668  );
669 
670  //- Reset time step, normally also calling adjustDeltaT()
671  virtual void setDeltaT
672  (
673  const scalar deltaT,
674  const bool adjust = true
675  );
676 
677  //- Set time to sub-cycle for the given number of steps
678  virtual TimeState subCycle(const label nSubCycles);
679 
680  //- Adjust the reported sub-cycle index.
681  // \param index is the sub-cycle index.
682  // This index is ignored sub-cycling was
683  // not already registered, or if the index is zero or
684  // negative.
685  virtual void subCycleIndex(const label index);
686 
687  //- Reset time after sub-cycling back to previous TimeState
688  virtual void endSubCycle();
689 
690  //- Return non-const access to the list of function objects
692  {
693  return functionObjects_;
694  }
695 
696 
697  // Member Operators
698 
699  //- Set deltaT to that specified and increment time via operator++()
700  virtual Time& operator+=(const dimensionedScalar& deltaT);
701 
702  //- Set deltaT to that specified and increment time via operator++()
703  virtual Time& operator+=(const scalar deltaT);
704 
705  //- Prefix increment,
706  // also invokes the functionObjectList::start() or
707  // functionObjectList::execute() method, depending on the time-index
708  virtual Time& operator++();
709 
710  //- Postfix increment, this is identical to the prefix increment
711  virtual Time& operator++(int);
712 };
713 
714 
715 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
716 
717 } // End namespace Foam
718 
719 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
720 
721 #include "TimeI.H"
723 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
724 
725 #endif
726 
727 // ************************************************************************* //
A FIFO stack based on a singly-linked list.
Definition: FIFOStack.H:45
virtual Time & operator++()
Prefix increment,.
Definition: Time.C:1083
Generic output stream using a standard (STL) stream.
Definition: OSstream.H:50
dictionary dict
unwatchedIOdictionary is like IOdictionary but stores dependencies as files instead of fileMonitor wa...
fileName path() const
Return path = rootPath/caseName. Same as TimePaths::path()
Definition: Time.H:503
dlLibraryTable & libs() const noexcept
Mutable access to the loaded dynamic libraries.
Definition: Time.H:730
Address the time paths without using the Time class.
Definition: TimePaths.H:52
A class for handling file names.
Definition: fileName.H:72
bool writeAndEnd()
Write the objects now (not at end of iteration) and end the run.
Definition: TimeIO.C:589
static int printExecutionFormat_
Style for "ExecutionTime = " output.
Definition: Time.H:125
stopAtControls stopAt_
Definition: Time.H:160
sigStopAtWriteNow sigStopAtWriteNow_
Signal handler for write and clean exit upon signal.
Definition: Time.H:192
The time value with time-stepping information, user-defined remapping, etc.
Definition: TimeState.H:47
static autoPtr< Time > NewGlobalTime()
Construct (dummy) global Time - no functionObjects or libraries, using the global path information st...
Definition: TimeNew.C:78
Dummy no-op. Do not change current value.
Definition: Time.H:103
word findInstance(const fileName &dir, const word &name=word::null, IOobjectOption::readOption rOpt=IOobjectOption::MUST_READ, const word &stopInstance=word::null) const
Return time instance (location) of dir that contains the file name (eg, used in reading mesh data)...
Definition: Time.C:725
void adjustDeltaT()
Adjust the time step so that writing occurs at the specified time.
Definition: Time.C:95
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
adjust endTime to stop immediately w/ writing
Definition: Time.H:101
virtual ~Time()
Destructor.
Definition: Time.C:692
virtual bool isAdjustTimeStep() const
Return true if adjustTimeStep is true.
Definition: Time.C:929
fileName timePath() const
Return current time path = path/timeName.
Definition: Time.H:520
scalar writeInterval_
Definition: Time.H:164
virtual stopAtControls stopAt() const
Return the stop control information.
Definition: Time.C:801
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:195
virtual void setEndTime(const dimensionedScalar &endTime)
Reset end time.
Definition: Time.C:985
floatFormat
Float formats (eg, time directory name formats)
Read access to the system clock with formatting.
Definition: clock.H:48
static const fileName null
An empty fileName.
Definition: fileName.H:111
writeControls
Write control options.
Definition: Time.H:82
virtual bool loop()
Return true if run should continue and if so increment time.
Definition: Time.C:889
virtual dimensionedScalar startTime() const
Return start time.
Definition: Time.C:789
engineTime & runTime
"clockTime"
Definition: Time.H:88
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
Definition: Switch.H:77
IOstreamOption writeStreamOption() const noexcept
Get write stream option (format, compression, version)
Definition: TimeI.H:116
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: TimeNew.C:26
static const Enum< stopAtControls > stopAtControlNames
Names for stopAtControls.
Definition: Time.H:114
label subCycling() const noexcept
Zero (tests as false) if time is not being sub-cycled, otherwise the current sub-cycle index or the t...
Definition: Time.H:743
A simple container for options an IOstream can normally have.
Time(const word &ctrlDictName, const argList &args, const bool enableFunctionObjects=true, const bool enableLibs=true, IOobjectOption::readOption rOpt=IOobjectOption::READ_MODIFIED)
Construct from argument list, reading from specified control dictionary name.
Definition: TimeI.H:24
virtual dimensionedScalar endTime() const
Return end time.
Definition: Time.C:795
Dummy no-op.
Definition: Time.H:90
scalar startTime_
Definition: Time.H:156
writeControls writeControl_
Definition: Time.H:162
const TimeState & prevTimeState() const
Return previous TimeState if time is being sub-cycled.
Definition: Time.H:751
void setMonitoring(const bool forceProfiling=false)
Set file monitoring, profiling, etc.
Definition: Time.C:344
const word & timeName() const noexcept
Return the current time name.
Definition: TimeStateI.H:30
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
"runTime"
Definition: Time.H:86
virtual bool run() const
Return true if run should continue,.
Definition: Time.C:807
label subCycling_
The total number of sub-cycles, the current sub-cycle index, or 0 if time is not being sub-cycled...
Definition: Time.H:174
static const int maxPrecision_
Maximum time directory name precision.
Definition: Time.H:207
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options.
Definition: TimeIO.C:533
virtual bool writeTimeDict() const
Write time dictionary to the <time>/uniform directory.
Definition: TimeIO.C:498
IOstreamOption::versionNumber writeVersion() const noexcept
Get the write stream version.
Definition: TimeI.H:150
label purgeWrite_
Definition: Time.H:166
virtual TimeState subCycle(const label nSubCycles)
Set time to sub-cycle for the given number of steps.
Definition: Time.C:1019
"adjustable" / "adjustableRunTime"
Definition: Time.H:87
"timeStep"
Definition: Time.H:85
const functionObjectList & functionObjects() const noexcept
Return the list of function objects.
Definition: Time.H:722
static int precision_
Time directory name precision.
Definition: Time.H:202
fileName globalPath() const
Return global path for the case = rootPath/globalCaseName. Same as TimePaths::globalPath() ...
Definition: Time.H:512
TypeName("time")
Runtime type information.
A class for handling words, derived from Foam::string.
Definition: word.H:63
Extract command arguments and options from the supplied argc and argv parameters. ...
Definition: argList.H:118
static const word null
An empty word.
Definition: word.H:84
static const Enum< writeControls > writeControlNames
Names for writeControls.
Definition: Time.H:109
scalar endTime_
Definition: Time.H:158
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
Definition: Time.C:935
List of function objects with start(), execute() and end() functions that is called for each object...
Signal handler to write once and continue. The interrupt is defined by OptimisationSwitches::writeNow...
Definition: sigWriteNow.H:49
static word controlDictName
The default control dictionary name (normally "controlDict")
Definition: Time.H:268
const dictionary & controlDict() const noexcept
Return read access to the controlDict dictionary.
Definition: Time.H:539
A table of dynamically loaded libraries.
virtual void subCycleIndex(const label index)
Adjust the reported sub-cycle index.
Definition: Time.C:1043
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
FIFOStack< word > previousWriteTimes_
Definition: Time.H:168
IOstreamOption::compressionType writeCompression() const noexcept
Get the write stream compression.
Definition: TimeI.H:143
static IOstreamOption::floatFormat format_
Format for time directory names (general | fixed | scientific)
Definition: Time.H:197
OBJstream os(runTime.globalPath()/outputName)
virtual void readDict()
Read the control dictionary and set the write controls etc.
Definition: TimeIO.C:83
Ostream & printExecutionTime(OSstream &os) const
Print the elapsed ExecutionTime (cpu-time), ClockTime.
Definition: TimeIO.C:604
fileName globalTimePath() const
Return current time global path = globalPath/timeName.
Definition: Time.H:528
void readModifiedObjects()
Read the objects that have been modified.
Definition: TimeIO.C:452
"cpuTime"
Definition: Time.H:89
const word & graphFormat() const noexcept
Default graph format.
Definition: Time.H:577
const word & name() const noexcept
Return const reference to name.
void writeOnce()
Write the objects once (one shot) and continue the run.
Definition: TimeIO.C:598
Adjust endTime to stop immediately w/o writing.
Definition: Time.H:100
word findInstancePath(const fileName &directory, const instant &t) const
Search the case for the time directory path corresponding to the given instance.
Definition: Time.C:749
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
Definition: instant.H:53
const fileName & rootPath() const noexcept
Return root path.
Definition: TimePathsI.H:66
virtual bool end() const
Return true if end of run,.
Definition: Time.C:902
virtual bool read()
Read control dictionary, update controls and time.
Definition: TimeIO.C:427
const fileName & globalCaseName() const noexcept
Return global case name.
Definition: TimePathsI.H:72
Stop when Time reaches prescribed endTime.
Definition: Time.H:99
virtual Time & operator+=(const dimensionedScalar &deltaT)
Set deltaT to that specified and increment time via operator++()
Definition: Time.C:1070
bool writeOnce_
Definition: Time.H:177
sigWriteNow sigWriteNow_
Signal handler for one-shot writing upon signal.
Definition: Time.H:187
virtual void setDeltaT(const dimensionedScalar &deltaT, const bool adjust=true)
Reset time step, normally also calling adjustDeltaT()
Definition: Time.C:998
label startTimeIndex_
Definition: Time.H:154
fileName path() const
Return path for the case = rootPath/caseName.
Definition: TimePathsI.H:90
virtual void endSubCycle()
Reset time after sub-cycling back to previous TimeState.
Definition: Time.C:1056
Signal handler to write and stop the job. The interrupt is defined by OptimisationSwitches::stopAtWri...
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
stop at the next data write interval
Definition: Time.H:102
IOstreamOption::streamFormat writeFormat() const noexcept
Get write stream format.
Definition: TimeI.H:123
stopAtControls
Stop-run control options, which are primarily used when altering the stopAt condition.
Definition: Time.H:97
Registry of regIOobjects.
Switch runTimeModifiable() const noexcept
Supports re-reading.
Definition: Time.H:585
Foam::argList args(argc, argv)
virtual label startTimeIndex() const
Return start time index.
Definition: Time.C:783
"none"
Definition: Time.H:84
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
Definition: Time.H:541
autoPtr< TimeState > prevTimeState_
If time is being sub-cycled this is the previous TimeState.
Definition: Time.H:182
bool writeNow()
Write the objects immediately (not at end of iteration) and continue the run.
Definition: TimeIO.C:582
dimensionedScalar deltaT() const
Return time step.
Definition: TimeStateI.H:61
const fileName & caseName() const noexcept
Return case name.
Definition: TimePathsI.H:78
void setControls()
Set the controls from the current controlDict.
Definition: Time.C:139
Namespace for OpenFOAM.
fileName globalPath() const
Return global path for the case = rootPath/globalCaseName.
Definition: TimePathsI.H:96
Starts timing CPU usage and return elapsed time from start.
Definition: cpuTimePosix.H:52
readOption
Enumeration defining read preferences.