OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

Time Class Reference

Class to control time during OpenFOAM simulations that is also the top-level objectRegistry. More...

Inheritance diagram for Time:
Collaboration diagram for Time:

List of all members.


Public Types

enum  writeControls {
  wcTimeStep, wcRunTime, wcAdjustableRunTime, wcClockTime,
  wcCpuTime
}
 Write control options. More...
enum  stopAtControls { saEndTime, saNoWriteNow, saWriteNow, saNextWrite }
 Stop-run control options. More...
enum  fmtflags { general = 0, fixed = ios_base::fixed, scientific = ios_base::scientific }
 Suported time directory name formats. More...

Public Member Functions

 TypeName ("time")
 Time (const word &name, const fileName &rootPath, const fileName &caseName, const word &systemName="system", const word &constantName="constant")
 Construct given name, rootPath and casePath.
 Time (const dictionary &dict, const fileName &rootPath, const fileName &caseName, const word &systemName="system", const word &constantName="constant")
 Construct given dictionary, rootPath and casePath.
 Time (const fileName &rootPath, const fileName &caseName, const word &systemName="system", const word &constantName="constant")
 Construct given endTime, rootPath and casePath.
virtual ~Time ()
 Virtual destructor.
const fileNamerootPath () const
 Return root path.
const fileNamecaseName () const
 Return case name.
fileName path () const
 Return path.
const dictionarycontrolDict () const
virtual const fileNamedbDir () const
 Local directory path of this objectRegistry relative to the time.
fileName timePath () const
 Return current time path.
IOstream::streamFormat writeFormat () const
 Default write format.
IOstream::versionNumber writeVersion () const
 Default write version number.
IOstream::compressionType writeCompression () const
 Default write compression.
const wordgraphFormat () const
 Default graph format.
virtual bool read ()
 Read control dictionary, update controls and time.
void readModifiedObjects ()
 Read the objects that have been modified.
word findInstance (const fileName &dir, const word &name=word::null, const IOobject::readOption rOpt=IOobject::MUST_READ) const
 Return the location of "dir" containing the file "name".
instantList times () const
 Search the case for valid time directories.
word findInstancePath (const instant &) const
 Search the case for the time directory path.
instant findClosestTime (const scalar) const
 Search the case for the time closest to the given time.
virtual bool writeObject (IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType) const
 Write using given format, version and compression.
bool writeNow ()
 Write the objects now and continue the run.
bool writeAndEnd ()
 Write the objects now and end the run.
virtual word timeName () const
 Return current time name.
virtual label startTimeIndex () const
 Return start time index.
virtual dimensionedScalar startTime () const
 Return start time.
virtual dimensionedScalar endTime () const
 Return end time.
const functionObjectListfunctionObjects () const
 Return the list of function objects.
virtual bool run () const
 Return true if run should continue,.
virtual bool loop ()
 Return true if run should continue and if so increment time.
virtual bool end () const
 Return true if end of run,.
virtual void setTime (const Time &)
 Reset the time and time-index to those of the given time.
virtual void setTime (const instant &, const label newIndex)
 Reset the time and time-index.
virtual void setTime (const dimensionedScalar &, const label newIndex)
 Reset the time and time-index.
virtual void setTime (const scalar, const label newIndex)
 Reset the time and time-index.
virtual void setEndTime (const dimensionedScalar &)
 Reset end time.
virtual void setEndTime (const scalar)
 Reset end time.
virtual void setDeltaT (const dimensionedScalar &)
 Reset time step.
virtual void setDeltaT (const scalar)
 Reset time step.
virtual TimeState subCycle (const label nSubCycles)
 Set time to sub-cycle for the given number of steps.
virtual void endSubCycle (const TimeState &)
 Reset time after sub-cycling back to given TimeState.
functionObjectListfunctionObjects ()
 Return non-const access to the list of function objects.
virtual Timeoperator+= (const dimensionedScalar &)
 Set deltaT to that specified and increment time via operator++().
virtual Timeoperator+= (const scalar)
 Set deltaT to that specified and increment time via operator++().
virtual Timeoperator++ ()
 Prefix increment,.
virtual Timeoperator++ (int)
 Postfix increment, this is identical to the prefix increment.

Static Public Member Functions

static label findClosestTimeIndex (const instantList &, const scalar)
 Search instantList for the time index closest to the given time.
static word timeName (const scalar)
 Return time name of given scalar time.
static instantList findTimes (const fileName &)
 Search a given directory for valid time directories.

Static Public Attributes

static word controlDictName
 The default control dictionary name (normally "controlDict").

Protected Member Functions

void adjustDeltaT ()
 Adjust the time step so that writing occurs at the specified time.
void setControls ()
 Set the controls from the current controlDict.
virtual void readDict ()
 Read the control dictionary and set the write controls etc.

Protected Attributes

label startTimeIndex_
scalar startTime_
 Start time in seconds.
scalar endTime_
stopAtControls stopAt_
writeControls writeControl_
scalar writeInterval_
label purgeWrite_
FIFOStack< wordpreviousOutputTimes_
bool subCycling_
 Is the time currently being sub-cycled?

Static Protected Attributes

static const NamedEnum
< stopAtControls, 4 > 
stopAtControlNames_
static const NamedEnum
< writeControls, 5 > 
writeControlNames_
static fmtflags format_
 Time directory name format.
static int precision_
 Time directory name precision.

Detailed Description

Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.

Source files

Definition at line 59 of file Time.H.


Member Enumeration Documentation

Write control options.

Enumerator:
wcTimeStep 
wcRunTime 
wcAdjustableRunTime 
wcClockTime 
wcCpuTime 

Definition at line 75 of file Time.H.

Stop-run control options.

Enumerator:
saEndTime 
saNoWriteNow 
saWriteNow 
saNextWrite 

Definition at line 85 of file Time.H.

enum fmtflags

Suported time directory name formats.

Enumerator:
general 
fixed 
scientific 

Definition at line 94 of file Time.H.


Constructor & Destructor Documentation

Time ( const word name,
const fileName rootPath,
const fileName caseName,
const word systemName = "system",
const word constantName = "constant" 
)

Construct given name, rootPath and casePath.

Definition at line 180 of file Time.C.

References Time::startTimeIndex_, and TimeState::timeIndex_.

Time ( const dictionary dict,
const fileName rootPath,
const fileName caseName,
const word systemName = "system",
const word constantName = "constant" 
)

Construct given dictionary, rootPath and casePath.

Definition at line 235 of file Time.C.

Time ( const fileName rootPath,
const fileName caseName,
const word systemName = "system",
const word constantName = "constant" 
)

Construct given endTime, rootPath and casePath.

Definition at line 291 of file Time.C.

~Time (  )  [virtual]

Virtual destructor.

Definition at line 344 of file Time.C.


Member Function Documentation

void adjustDeltaT (  )  [protected]

Adjust the time step so that writing occurs at the specified time.

Definition at line 60 of file Time.C.

Referenced by Time::subCycle().

Here is the caller graph for this function:

void setControls (  )  [protected]

Set the controls from the current controlDict.

Definition at line 87 of file Time.C.

TypeName ( "time"   ) 

const fileName& rootPath (  )  const [inline]

Return root path.

Reimplemented from TimePaths.

Definition at line 215 of file Time.H.

Referenced by Time::caseName(), and Time::controlDict().

Here is the caller graph for this function:

const fileName& caseName (  )  const [inline]

Return case name.

Reimplemented from TimePaths.

Definition at line 221 of file Time.H.

References Time::rootPath().

Referenced by Time::controlDict(), and Time::path().

Here is the call graph for this function:

Here is the caller graph for this function:

fileName path (  )  const [inline]

Return path.

Reimplemented from TimePaths.

Definition at line 227 of file Time.H.

References Time::caseName().

Referenced by autoHexMeshDriver::autoHexMeshDriver(), Time::findInstance(), Time::findInstancePath(), and Time::writeFormat().

Here is the call graph for this function:

Here is the caller graph for this function:

const dictionary& controlDict (  )  const [inline]

Definition at line 232 of file Time.H.

References Time::caseName(), and Time::rootPath().

Here is the call graph for this function:

virtual const fileName& dbDir (  )  const [inline, virtual]

Local directory path of this objectRegistry relative to the time.

Reimplemented from objectRegistry.

Definition at line 237 of file Time.H.

fileName timePath (  )  const [inline]

Return current time path.

Definition at line 243 of file Time.H.

References fileName::null.

Referenced by Foam::writeCellGraph(), and Foam::writePatchGraph().

Here is the caller graph for this function:

IOstream::streamFormat writeFormat (  )  const [inline]

Default write format.

Definition at line 249 of file Time.H.

References Time::path(), and Time::timeName().

Here is the call graph for this function:

IOstream::versionNumber writeVersion (  )  const [inline]

Default write version number.

Definition at line 255 of file Time.H.

IOstream::compressionType writeCompression (  )  const [inline]

Default write compression.

Definition at line 261 of file Time.H.

const word& graphFormat (  )  const [inline]

Default graph format.

Definition at line 267 of file Time.H.

bool read (  )  [virtual]

Read control dictionary, update controls and time.

Reimplemented from regIOobject.

Reimplemented in engineTime.

Definition at line 178 of file TimeIO.C.

void readModifiedObjects (  ) 

Read the objects that have been modified.

Reimplemented from objectRegistry.

Definition at line 192 of file TimeIO.C.

Foam::word findInstance ( const fileName dir,
const word name = word::null,
const IOobject::readOption  rOpt = IOobject::MUST_READ 
) const

Return the location of "dir" containing the file "name".

(eg, used in reading mesh data) If name is null, search for the directory "dir" only

Definition at line 31 of file findInstance.C.

References TimePaths::constant(), Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorIn, Foam::Info, IOobject::IOobject(), Foam::isDir(), Foam::isFile(), IOobject::MUST_READ, IOobject::name(), Time::path(), Time::timeName(), TimeState::timeOutputValue(), and Time::times().

Here is the call graph for this function:

Foam::instantList times (  )  const

Search the case for valid time directories.

Definition at line 370 of file Time.C.

References IOobject::name().

Referenced by Time::findInstance().

Here is the call graph for this function:

Here is the caller graph for this function:

Foam::word findInstancePath ( const instant t  )  const

Search the case for the time directory path.

corresponding to the given instance

Definition at line 376 of file Time.C.

References Time::findTimes(), and Time::path().

Here is the call graph for this function:

Foam::instant findClosestTime ( const scalar  t  )  const

Search the case for the time closest to the given time.

Definition at line 392 of file Time.C.

Foam::label findClosestTimeIndex ( const instantList timeDirs,
const scalar  t 
) [static]

Search instantList for the time index closest to the given time.

Definition at line 439 of file Time.C.

References forAll, Foam::mag(), and IOobject::name().

Referenced by if().

Here is the call graph for this function:

Here is the caller graph for this function:

bool writeObject ( IOstream::streamFormat  fmt,
IOstream::versionNumber  ver,
IOstream::compressionType  cmp 
) const [virtual]

Write using given format, version and compression.

Reimplemented from objectRegistry.

Definition at line 232 of file TimeIO.C.

bool writeNow (  ) 

Write the objects now and continue the run.

Definition at line 280 of file TimeIO.C.

bool writeAndEnd (  ) 

Write the objects now and end the run.

Definition at line 287 of file TimeIO.C.

References TimeState::outputTime_, and regIOobject::write().

Here is the call graph for this function:

Foam::word timeName ( const scalar  t  )  [static]

Return time name of given scalar time.

Definition at line 353 of file Time.C.

References functionObjectList::clear().

Referenced by fieldAverage::addMeanField(), Foam::compressible::autoCreateAlphat(), Foam::incompressible::autoCreateNut(), basicMultiComponentMixture::basicMultiComponentMixture(), linearUpwindV< Type >::correction(), linearUpwind< Type >::correction(), Foam::MULES::explicitSolve(), EulerD2dt2Scheme< Type >::fvcD2dt2(), steadyStateD2dt2Scheme< Type >::fvcD2dt2(), EulerDdtScheme< Type >::fvcDdt(), steadyStateDdtScheme< Type >::fvcDdt(), fvMeshSubset::interpolate(), localMin< Type >::interpolate(), localMax< Type >::interpolate(), LESdelta::LESdelta(), PhiScheme< Type, PhiLimiter >::limiter(), LimitedScheme< Type, Limiter, LimitFunc >::limiter(), Foam::MapConsistentVolFields(), Foam::MapGeometricFields(), Foam::MapLagrangianFields(), Foam::MapVolFields(), solidParticle::move(), multivariateScheme< Type, Scheme >::multivariateScheme(), multivariateSelectionScheme< Type >::multivariateSelectionScheme(), Foam::polyMeshZipUpCells(), extendedUpwindCellToFaceStencil::weightedSum(), clippedLinear< Type >::weights(), reverseLinear< Type >::weights(), addSubtract::writeAddSubtractField(), addSubtract::writeAddSubtractValue(), components::writeComponentFields(), div::writeDivField(), interpolate::writeInterpolateField(), mag::writeMagField(), magGrad::writeMagGradField(), magSqr::writeMagSqrField(), Foam::writeMeshObject(), regIOobject::writeObject(), and randomise::writeRandomField().

Here is the call graph for this function:

Here is the caller graph for this function:

Foam::word timeName (  )  const [virtual]

Return current time name.

Definition at line 363 of file Time.C.

References Time::format_, and Time::precision_.

Referenced by Time::findInstance(), Time::readDict(), Time::setEndTime(), and Time::writeFormat().

Here is the caller graph for this function:

Foam::instantList findTimes ( const fileName directory  )  [static]

Search a given directory for valid time directories.

Definition at line 30 of file findTimes.C.

References fileName::DIRECTORY, Foam::endl(), IOstream::eof(), forAll, Foam::Info, token::isNumber(), token::number(), Foam::readDir(), and Foam::sort().

Referenced by Time::findInstancePath(), and USERD_set_filenames().

Here is the call graph for this function:

Here is the caller graph for this function:

Foam::label startTimeIndex (  )  const [virtual]

Return start time index.

Definition at line 463 of file Time.C.

Foam::dimensionedScalar startTime (  )  const [virtual]

Return start time.

Definition at line 469 of file Time.C.

Foam::dimensionedScalar endTime (  )  const [virtual]

Return end time.

Definition at line 475 of file Time.C.

const functionObjectList& functionObjects (  )  const [inline]

Return the list of function objects.

Definition at line 341 of file Time.H.

bool run (  )  const [virtual]

Return true if run should continue,.

also invokes the functionObjectList::end() method when the time goes out of range

Note:
For correct behaviour, the following style of time-loop is recommended:
    while (runTime.run())
    {
        runTime++;
        solve;
        runTime.write();
    }

Definition at line 481 of file Time.C.

bool loop (  )  [virtual]

Return true if run should continue and if so increment time.

also invokes the functionObjectList::end() method when the time goes out of range

Note:
For correct behaviour, the following style of time-loop is recommended:
    while (runTime.loop())
    {
        solve;
        runTime.write();
    }

Definition at line 500 of file Time.C.

bool end (  )  const [virtual]

Return true if end of run,.

does not invoke any functionObject methods

Note:
The rounding heuristics near endTime mean that
 run() 
and
 !end() 
may not yield the same result

Reimplemented from HashTable< regIOobject * >.

Definition at line 513 of file Time.C.

References Time::operator++().

Here is the call graph for this function:

void setTime ( const Time t  )  [virtual]

Reset the time and time-index to those of the given time.

Definition at line 519 of file Time.C.

void setTime ( const instant inst,
const label  newIndex 
) [virtual]

Reset the time and time-index.

Definition at line 527 of file Time.C.

References IOobject::name(), and TimeState::timeIndex_.

Here is the call graph for this function:

void setTime ( const dimensionedScalar newTime,
const label  newIndex 
) [virtual]

Reset the time and time-index.

Definition at line 553 of file Time.C.

void setTime ( const scalar  newTime,
const label  newIndex 
) [virtual]

Reset the time and time-index.

Definition at line 559 of file Time.C.

void setEndTime ( const dimensionedScalar endTime  )  [virtual]

Reset end time.

Definition at line 567 of file Time.C.

References IOobject::name(), TimeState::timeIndex_, Time::timeName(), and TimeState::timeToUserTime().

Here is the call graph for this function:

void setEndTime ( const scalar  endTime  )  [virtual]

Reset end time.

Definition at line 573 of file Time.C.

void setDeltaT ( const dimensionedScalar deltaT  )  [virtual]

Reset time step.

Definition at line 579 of file Time.C.

Referenced by Time::operator++().

Here is the caller graph for this function:

void setDeltaT ( const scalar  deltaT  )  [virtual]

Reset time step.

Definition at line 585 of file Time.C.

Foam::TimeState subCycle ( const label  nSubCycles  )  [virtual]

Set time to sub-cycle for the given number of steps.

Definition at line 593 of file Time.C.

References Time::adjustDeltaT(), TimeState::deltaT_, and TimeState::deltaTchanged_.

Here is the call graph for this function:

void endSubCycle ( const TimeState ts  )  [virtual]

Reset time after sub-cycling back to given TimeState.

Definition at line 607 of file Time.C.

Referenced by subCycleTime::operator++().

Here is the caller graph for this function:

functionObjectList& functionObjects (  )  [inline]

Return non-const access to the list of function objects.

Definition at line 432 of file Time.H.

Foam::Time & operator+= ( const dimensionedScalar deltaT  )  [virtual]

Set deltaT to that specified and increment time via operator++().

Definition at line 616 of file Time.C.

References Time::subCycling_.

Referenced by Time::operator+=().

Here is the caller graph for this function:

Foam::Time & operator+= ( const scalar  deltaT  )  [virtual]

Set deltaT to that specified and increment time via operator++().

Definition at line 622 of file Time.C.

References Time::operator+=().

Here is the call graph for this function:

Foam::Time & operator++ (  )  [virtual]

Prefix increment,.

also invokes the functionObjectList::start() or functionObjectList::execute() method, depending on the time-index

Definition at line 629 of file Time.C.

References Time::setDeltaT().

Referenced by Time::end().

Here is the call graph for this function:

Here is the caller graph for this function:

Foam::Time & operator++ ( int   )  [virtual]

Postfix increment, this is identical to the prefix increment.

Definition at line 732 of file Time.C.

References Time::endTime_.


Member Data Documentation

label startTimeIndex_ [protected]

Definition at line 106 of file Time.H.

Referenced by Time::Time().

scalar startTime_ [protected]

Start time in seconds.

Reimplemented from clock.

Definition at line 107 of file Time.H.

scalar endTime_ [protected]

Definition at line 108 of file Time.H.

Referenced by Time::operator++(), and Time::readDict().

Definition at line 110 of file Time.H.

Referenced by Time::readDict().

stopAtControls stopAt_ [protected]

Definition at line 111 of file Time.H.

Referenced by Time::readDict().

Definition at line 113 of file Time.H.

Referenced by Time::readDict().

Definition at line 114 of file Time.H.

Referenced by Time::readDict().

scalar writeInterval_ [protected]

Definition at line 116 of file Time.H.

Referenced by Time::readDict().

label purgeWrite_ [protected]

Definition at line 118 of file Time.H.

Referenced by Time::readDict().

FIFOStack<word> previousOutputTimes_ [mutable, protected]

Definition at line 119 of file Time.H.

bool subCycling_ [protected]

Is the time currently being sub-cycled?

Definition at line 122 of file Time.H.

Referenced by Time::operator+=().

Foam::Time::fmtflags format_ [static, protected]

Time directory name format.

Definition at line 125 of file Time.H.

Referenced by Time::readDict(), and Time::timeName().

int precision_ [static, protected]

Time directory name precision.

Definition at line 128 of file Time.H.

Referenced by Time::readDict(), and Time::timeName().

The default control dictionary name (normally "controlDict").

Definition at line 169 of file Time.H.


The documentation for this class was generated from the following files:
Copyright © 2000-2009 OpenCFD Ltd