Class to control time during OpenFOAM simulations that is also the top-level objectRegistry. More...
#include <OpenFOAM/Time.H>
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition at line 64 of file Time.H.
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 fileName & | rootPath () const |
Return root path.
| |
const fileName & | caseName () const |
Return case name.
| |
fileName | path () const |
Return path.
| |
const dictionary & | controlDict () const |
virtual const fileName & | dbDir () 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 word & | graphFormat () 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 word &stopInstance=word::null) 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 functionObjectList & | functionObjects () const |
Return the list of function objects.
| |
bool | subCycling () const |
Return true if time currently being sub-cycled, otherwise false.
| |
const TimeState & | prevTimeState () const |
Return previous TimeState if time is being sub-cycled.
| |
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 () |
Reset time after sub-cycling back to previous TimeState.
| |
functionObjectList & | functionObjects () |
Return non-const access to the list of function objects.
| |
virtual Time & | operator+= (const dimensionedScalar &) |
Set deltaT to that specified and increment time via operator++()
| |
virtual Time & | operator+= (const scalar) |
Set deltaT to that specified and increment time via operator++()
| |
virtual Time & | operator++ () |
Prefix increment,.
| |
virtual Time & | operator++ (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< word > | previousOutputTimes_ |
bool | subCycling_ |
Is the time currently being sub-cycled?
| |
autoPtr< TimeState > | prevTimeState_ |
If time is being sub-cycled this is the previous TimeState.
| |
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.
|
enum writeControls |
enum stopAtControls |
enum fmtflags |
void adjustDeltaT | ( | ) | [protected]
|
Adjust the time step so that writing occurs at the specified time.
Definition at line 68 of file Time.C.
References TimeState::deltaT_, Foam::max(), Foam::min(), TimeState::outputTimeIndex_, Time::startTime_, dimensioned< Type >::value(), Time::wcAdjustableRunTime, Time::writeControl_, and Time::writeInterval_.
void setControls | ( | ) | [protected]
|
Set the controls from the current controlDict.
Definition at line 102 of file Time.C.
References Foam::exit(), Foam::FatalIOError, FatalIOErrorIn, Foam::mag(), Pstream::myProcNo(), Foam::nl, IOobject::NO_WRITE, Pstream::nProcs(), Pstream::parRun(), IOobject::READ_IF_PRESENT, dictionary::readIfPresent(), Foam::reduce(), List< T >::size(), and timeName.
void readDict | ( | ) | [protected, virtual]
|
Read the control dictionary and set the write controls etc.
Reimplemented in engineTime.
Definition at line 31 of file TimeIO.C.
References IOstream::compressionEnum(), IOstream::defaultPrecision(), TimeState::deltaT_, TimeState::deltaTchanged_, Foam::endl(), Time::endTime_, Foam::exit(), Foam::FatalIOError, FatalIOErrorIn, Time::fixed, Time::format_, IOstream::formatEnum(), dictionary::found(), Time::general, dictionary::lookup(), dimensioned< Type >::name(), TimeState::outputTimeIndex_, Foam::Perr, Foam::Pout, OSstream::precision(), Time::precision_, Time::purgeWrite_, NamedEnum< Enum, nEnum >::read(), dictionary::readIfPresent(), Foam::readScalar(), Foam::readUint(), Time::saEndTime, Time::scientific, Foam::Serr, Foam::Sout, Time::stopAt_, Time::stopAtControlNames_, Time::timeName(), dimensioned< Type >::value(), WarningIn, Time::wcAdjustableRunTime, Time::wcRunTime, Time::wcTimeStep, Time::writeControl_, Time::writeControlNames_, and Time::writeInterval_.
Referenced by engineTime::readDict().
TypeName | ( | "time" | ) |
const fileName& rootPath | ( | ) | const [inline]
|
Return root path.
Reimplemented from TimePaths.
Definition at line 223 of file Time.H.
Referenced by Time::path().
const fileName& caseName | ( | ) | const [inline]
|
Return case name.
Reimplemented from TimePaths.
Definition at line 229 of file Time.H.
Referenced by Time::path(), triSurface::triSurface(), triSurface::triSurfInstance(), and triSurface::write().
fileName path | ( | ) | const [inline]
|
Return path.
Reimplemented from TimePaths.
Definition at line 235 of file Time.H.
References Time::caseName(), and Time::rootPath().
Referenced by autoLayerDriver::addLayers(), meshRefinement::baffleAndSplitMesh(), autoSnapDriver::calcNearestSurface(), autoSnapDriver::smoothDisplacement(), Time::timePath(), triSurface::triSurface(), triSurface::triSurfInstance(), and triSurface::write().
const dictionary& controlDict | ( | ) | const [inline]
|
virtual const fileName& dbDir | ( | ) | const [inline, virtual]
|
Local directory path of this objectRegistry relative to the time.
Reimplemented from objectRegistry.
Definition at line 245 of file Time.H.
References fileName::null.
fileName timePath | ( | ) | const [inline]
|
Return current time path.
Definition at line 251 of file Time.H.
References Time::path(), and Time::timeName().
Referenced by MeshedSurfaceProxy< Face >::write(), Foam::writeCellGraph(), molecule::writeFields(), and Foam::writePatchGraph().
IOstream::streamFormat writeFormat | ( | ) | const [inline]
|
IOstream::versionNumber writeVersion | ( | ) | const [inline]
|
IOstream::compressionType writeCompression | ( | ) | const [inline]
|
const word& graphFormat | ( | ) | const [inline]
|
bool read | ( | ) | [virtual]
|
Read control dictionary, update controls and time.
Reimplemented from regIOobject.
Reimplemented in engineTime.
Definition at line 186 of file TimeIO.C.
Referenced by engineTime::read().
void readModifiedObjects | ( | ) |
Read the objects that have been modified.
Reimplemented from objectRegistry.
Definition at line 200 of file TimeIO.C.
References Foam::endl(), objectRegistry::modified(), Pstream::parRun(), objectRegistry::readModifiedObjects(), Foam::reduce(), and WarningIn.
Foam::word findInstance | ( | const fileName & | dir, |
const word & | name = word::null ,
|
||
const IOobject::readOption | rOpt = IOobject::MUST_READ ,
|
||
const word & | stopInstance = word::null
|
||
) | 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 38 of file findInstance.C.
References Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorIn, IOobject::headerOk(), Foam::Info, Foam::isDir(), Foam::isFile(), name(), List< T >::size(), and timeName.
Foam::instantList times | ( | ) | const |
Search the case for valid time directories.
Definition at line 385 of file Time.C.
Referenced by timeSelector::select0(), and triSurface::triSurfInstance().
Foam::word findInstancePath | ( | const instant & | t ) | const |
Search the case for the time directory path.
corresponding to the given instance
Definition at line 391 of file Time.C.
References forAllReverse, and word::null.
Referenced by IOobjectList::IOobjectList().
Foam::instant findClosestTime | ( | const scalar | t ) | const |
Search the case for the time closest to the given time.
Definition at line 407 of file Time.C.
References Foam::mag(), and List< T >::size().
Foam::label findClosestTimeIndex | ( | const instantList & | timeDirs, |
const scalar | t | ||
) | [static]
|
Search instantList for the time index closest to the given time.
Definition at line 454 of file Time.C.
References forAll, Foam::mag(), and Foam::name().
Referenced by if().
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 240 of file TimeIO.C.
References dictionary::add(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::path(), Foam::rmDir(), timeName, and objectRegistry::writeObject().
bool writeNow | ( | ) |
bool writeAndEnd | ( | ) |
Foam::word timeName | ( | const scalar | t ) | [static]
|
Return time name of given scalar time.
Definition at line 368 of file Time.C.
Referenced by fieldToCell::applyToSet(), Foam::compressible::autoCreateAlphat(), Foam::compressible::autoCreateLowReMut(), Foam::incompressible::autoCreateLowReNut(), Foam::compressible::autoCreateMut(), Foam::incompressible::autoCreateNut(), laminar::B(), basicMultiComponentMixture::basicMultiComponentMixture(), randomise::calc(), magSqr::calc(), magGrad::calc(), mag::calc(), interpolate::calc(), div::calc(), components::calc(), addSubtract::calc(), motionDirectionalDiffusivity::correct(), inverseVolumeDiffusivity::correct(), inverseDistanceDiffusivity::correct(), cubic< Type >::correction(), linearUpwindV< Type >::correction(), linearUpwind< Type >::correction(), hsRhoMixtureThermo< MixtureType >::Cp(), hRhoMixtureThermo< MixtureType >::Cp(), hsPsiMixtureThermo< MixtureType >::Cp(), hPsiMixtureThermo< MixtureType >::Cp(), hhuMixtureThermo< MixtureType >::Cp(), hsRhoThermo< MixtureType >::Cp(), hRhoThermo< MixtureType >::Cp(), hsPsiThermo< MixtureType >::Cp(), hPsiThermo< MixtureType >::Cp(), ePsiThermo< MixtureType >::Cp(), hsRhoThermo< MixtureType >::Cv(), hRhoThermo< MixtureType >::Cv(), hsPsiThermo< MixtureType >::Cv(), hPsiThermo< MixtureType >::Cv(), ePsiThermo< MixtureType >::Cv(), GenSGSStress::devBeff(), qZeta::devReff(), NonlinearKEShih::devReff(), LienLeschzinerLowRe::devReff(), LienCubicKELowRe::devReff(), LienCubicKE::devReff(), LamBremhorstKE::devReff(), kOmega::devReff(), RNGkEpsilon::devReff(), realizableKE::devReff(), LRR::devReff(), LaunderSharmaKE::devReff(), LaunderGibsonRSTM::devReff(), laminar::devReff(), kOmegaSST::devReff(), kEpsilon::devReff(), SpalartAllmaras::devReff(), kOmega::epsilon(), laminar::epsilon(), kOmegaSST::epsilon(), SpalartAllmaras::epsilon(), spray::evaporationSource(), Foam::MULES::explicitSolve(), steadyStateD2dt2Scheme< Type >::fvcD2dt2(), EulerD2dt2Scheme< Type >::fvcD2dt2(), steadyStateDdtScheme< Type >::fvcDdt(), SLTSDdtScheme< Type >::fvcDdt(), localEulerDdtScheme< Type >::fvcDdt(), EulerDdtScheme< Type >::fvcDdt(), CrankNicholsonDdtScheme< Type >::fvcDdt(), CoEulerDdtScheme< Type >::fvcDdt(), boundedBackwardDdtScheme::fvcDdt(), backwardDdtScheme< Type >::fvcDdt(), steadyStateDdtScheme< Type >::fvcDdtPhiCorr(), SLTSDdtScheme< Type >::fvcDdtPhiCorr(), localEulerDdtScheme< Type >::fvcDdtPhiCorr(), EulerDdtScheme< Type >::fvcDdtPhiCorr(), CrankNicholsonDdtScheme< Type >::fvcDdtPhiCorr(), CoEulerDdtScheme< Type >::fvcDdtPhiCorr(), backwardDdtScheme< Type >::fvcDdtPhiCorr(), fvDOM::fvDOM(), hsRhoMixtureThermo< MixtureType >::hc(), hRhoMixtureThermo< MixtureType >::hc(), hsPsiMixtureThermo< MixtureType >::hc(), hPsiMixtureThermo< MixtureType >::hc(), hhuMixtureThermo< MixtureType >::hc(), spray::heatTransferSource(), Foam::MULES::implicitSolve(), localMin< Type >::interpolate(), localMax< Type >::interpolate(), fvMeshSubset::interpolate(), laminar::k(), SpalartAllmaras::k(), Foam::resError::laplacian(), PhiScheme< Type, PhiLimiter >::limiter(), LimitedScheme< Type, Limiter, LimitFunc >::limiter(), Foam::MULES::limiter(), readFields::loadField(), meshRefinement::makeDisplacementField(), Foam::MapConsistentVolFields(), Foam::MapGeometricFields(), Foam::MapLagrangianFields(), Foam::MapVolFields(), MeshedSurface< Face >::MeshedSurface(), spray::momentumSource(), solidParticle::move(), laminar::nuSgs(), laminar::nut(), Foam::polyMeshZipUpCells(), qZeta::R(), NonlinearKEShih::R(), LienLeschzinerLowRe::R(), LienCubicKELowRe::R(), LienCubicKE::R(), LamBremhorstKE::R(), kOmega::R(), RNGkEpsilon::R(), realizableKE::R(), LaunderSharmaKE::R(), laminar::R(), kOmegaSST::R(), kEpsilon::R(), SpalartAllmaras::R(), forces::rho(), skewCorrected< Type >::skewCorrection(), extendedFaceToCellStencil::weightedSum(), extendedUpwindCellToFaceStencil::weightedSum(), extendedCellToFaceStencil::weightedSum(), reverseLinear< Type >::weights(), clippedLinear< Type >::weights(), MeshedSurfaceProxy< Face >::write(), meshRefinement::write(), addSubtract::writeAddSubtractField(), addSubtract::writeAddSubtractValue(), components::writeComponentFields(), div::writeDivField(), interpolate::writeInterpolateField(), mag::writeMagField(), magGrad::writeMagGradField(), magSqr::writeMagSqrField(), Foam::writeMeshObject(), and randomise::writeRandomField().
Foam::word timeName | ( | ) | const [virtual]
|
Return current time name.
Definition at line 378 of file Time.C.
References dimensioned< scalar >::name().
Referenced by Time::readDict(), and Time::timePath().
Foam::instantList findTimes | ( | const fileName & | directory ) | [static]
|
Search a given directory for valid time directories.
Definition at line 37 of file findTimes.C.
References fileName::DIRECTORY, Foam::endl(), IOstream::eof(), forAll, Foam::Info, token::isNumber(), token::number(), Foam::readDir(), List< T >::setSize(), List< T >::size(), and Foam::sort().
Foam::label startTimeIndex | ( | ) | const [virtual]
|
Foam::dimensionedScalar startTime | ( | ) | const [virtual]
|
Foam::dimensionedScalar endTime | ( | ) | const [virtual]
|
const functionObjectList& functionObjects | ( | ) | const [inline]
|
bool subCycling | ( | ) | const [inline]
|
Return true if time currently being sub-cycled, otherwise false.
Definition at line 352 of file Time.H.
References Time::subCycling_.
const TimeState& prevTimeState | ( | ) | const [inline]
|
Return previous TimeState if time is being sub-cycled.
Definition at line 358 of file Time.H.
References Time::prevTimeState_.
Referenced by fvMesh::Vsc(), and fvMesh::Vsc0().
bool run | ( | ) | const [virtual]
|
Return true if run should continue,.
also invokes the functionObjectList::end() method when the time goes out of range
while (runTime.run()) { runTime++; solve; runTime.write(); }
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
while (runTime.loop()) { solve; runTime.write(); }
bool end | ( | ) | const [virtual]
|
Return true if end of run,.
does not invoke any functionObject methods
Reimplemented from HashTable< regIOobject * >.
void setTime | ( | const Time & | t ) | [virtual]
|
Reset the time and time-index to those of the given time.
Definition at line 534 of file Time.C.
References dimensioned< scalar >::name(), TimeState::timeIndex_, and dimensioned< Type >::value().
Referenced by timeSelector::select0().
void setTime | ( | const instant & | inst, |
const label | newIndex | ||
) | [virtual]
|
Reset the time and time-index.
Definition at line 542 of file Time.C.
References instant::name(), dimensioned< scalar >::name(), IOobject::NO_WRITE, IOobject::READ_IF_PRESENT, dictionary::readIfPresent(), timeName, and instant::value().
void setTime | ( | const dimensionedScalar & | newTime, |
const label | newIndex | ||
) | [virtual]
|
Reset the time and time-index.
Definition at line 568 of file Time.C.
References dimensioned< Type >::value().
void setTime | ( | const scalar | newTime, |
const label | newIndex | ||
) | [virtual]
|
Reset the time and time-index.
Definition at line 574 of file Time.C.
References dimensioned< scalar >::name(), and timeName.
void setEndTime | ( | const dimensionedScalar & | endTime ) | [virtual]
|
void setEndTime | ( | const scalar | endTime ) | [virtual]
|
void setDeltaT | ( | const dimensionedScalar & | deltaT ) | [virtual]
|
void setDeltaT | ( | const scalar | deltaT ) | [virtual]
|
Foam::TimeState subCycle | ( | const label | nSubCycles ) | [virtual]
|
Set time to sub-cycle for the given number of steps.
Definition at line 608 of file Time.C.
References timeIndex.
Referenced by subCycleTime::subCycleTime().
void endSubCycle | ( | ) | [virtual]
|
functionObjectList& functionObjects | ( | ) | [inline]
|
Foam::Time & operator+= | ( | const dimensionedScalar & | deltaT ) | [virtual]
|
Set deltaT to that specified and increment time via operator++()
Definition at line 635 of file Time.C.
References dimensioned< Type >::value().
Foam::Time & operator+= | ( | const scalar | deltaT ) | [virtual]
|
Set deltaT to that specified and increment time via operator++()
Foam::Time & operator++ | ( | ) | [virtual]
|
Prefix increment,.
also invokes the functionObjectList::start() or functionObjectList::execute() method, depending on the time-index
Definition at line 648 of file Time.C.
References Foam::endl(), Foam::mag(), dimensioned< scalar >::name(), Foam::returnReduce(), timeIndex, and WarningIn.
Foam::Time & operator++ | ( | int | ) | [virtual]
|
label startTimeIndex_ [protected]
|
scalar startTime_ [protected]
|
Start time in seconds.
Reimplemented from clock.
Definition at line 112 of file Time.H.
Referenced by Time::adjustDeltaT().
scalar endTime_ [protected]
|
Definition at line 113 of file Time.H.
Referenced by Time::readDict().
const Foam::NamedEnum< Foam::Time::stopAtControls, 4 > stopAtControlNames_ [static, protected]
|
Definition at line 115 of file Time.H.
Referenced by Time::readDict().
stopAtControls stopAt_ [protected]
|
Definition at line 116 of file Time.H.
Referenced by Time::readDict().
const Foam::NamedEnum< Foam::Time::writeControls, 5 > writeControlNames_ [static, protected]
|
Definition at line 118 of file Time.H.
Referenced by Time::readDict().
writeControls writeControl_ [protected]
|
Definition at line 119 of file Time.H.
Referenced by Time::adjustDeltaT(), and Time::readDict().
scalar writeInterval_ [protected]
|
Definition at line 121 of file Time.H.
Referenced by Time::adjustDeltaT(), and Time::readDict().
label purgeWrite_ [protected]
|
Definition at line 123 of file Time.H.
Referenced by Time::readDict().
FIFOStack<word> previousOutputTimes_ [mutable, protected]
|
bool subCycling_ [protected]
|
Is the time currently being sub-cycled?
Definition at line 127 of file Time.H.
Referenced by Time::subCycling().
autoPtr<TimeState> prevTimeState_ [protected]
|
If time is being sub-cycled this is the previous TimeState.
Definition at line 130 of file Time.H.
Referenced by Time::prevTimeState().
Foam::Time::fmtflags format_ [static, protected]
|
int precision_ [static, protected]
|
Time directory name precision.
Definition at line 136 of file Time.H.
Referenced by Time::readDict().
Foam::word controlDictName [static]
|