Manage time in terms of engine RPM and crank-angle. More...
#include <engine/engineTime.H>
Manage time in terms of engine RPM and crank-angle.
When engineTime is in effect, the userTime is reported in degrees crank-angle instead of in seconds. The RPM to be used is specified in constant/engineGeometry
. If only a time conversion is required, the geometric engine parameters can be dropped or set to zero.
For example,
rpm rpm [0 0 -1 0 0] 2000; conRodLengthconRodLength [0 1 0 0 0] 0.0; borebore [0 1 0 0 0] 0.0; stroke stroke[0 1 0 0 0] 0.0; clearance clearance [0 1 0 0 0] 0.0;
Definition at line 69 of file engineTime.H.
Public Member Functions | |
engineTime (const word &name, const fileName &rootPath, const fileName &caseName, const fileName &systemName="system", const fileName &constantName="constant", const fileName &dictName="engineGeometry") | |
Construct from objectRegistry arguments. | |
virtual | ~engineTime () |
scalar | degToRad (const scalar rad) const |
Convert degrees to radians. | |
scalar | degToTime (const scalar theta) const |
Convert degrees to seconds (for given engine speed in RPM) | |
scalar | timeToDeg (const scalar t) const |
Convert seconds to degrees (for given engine speed in RPM) | |
scalar | pistonPosition (const scalar theta) const |
Calculate the piston position from the engine geometry. | |
const dictionary & | engineDict () const |
Return the engine geometry dictionary. | |
const dimensionedScalar & | rpm () const |
Return the engines current operating RPM. | |
const dimensionedScalar & | conRodLength () const |
Return the engines connecting-rod length. | |
const dimensionedScalar & | bore () const |
Return the engines bore. | |
const dimensionedScalar & | stroke () const |
Return the engines stroke. | |
const dimensionedScalar & | clearance () const |
Return the engines clearance-gap. | |
scalar | theta () const |
Return current crank-angle. | |
scalar | thetaRevolution () const |
Return current crank-angle translated to a single revolution. | |
scalar | deltaTheta () const |
Return crank-angle increment. | |
dimensionedScalar | pistonPosition () const |
Return current piston position. | |
dimensionedScalar | pistonDisplacement () const |
Return piston displacement for current time step. | |
dimensionedScalar | pistonSpeed () const |
Return piston speed for current time step. | |
virtual scalar | userTimeToTime (const scalar theta) const |
Convert the user-time (CA deg) to real-time (s). | |
virtual scalar | timeToUserTime (const scalar t) const |
Convert the real-time (s) into user-time (CA deg) | |
virtual void | readDict () |
Read the control dictionary and set the write controls etc. | |
virtual bool | read () |
Read the controlDict and set all the parameters. | |
![]() | |
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. | |
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. | |
![]() | |
clock () | |
Null constructor which stores the start time. | |
time_t | elapsedClockTime () const |
Returns wall-clock time from clock instantiation. | |
time_t | clockTimeIncrement () const |
Returns wall-clock time from last call of clockTimeIncrement() | |
![]() | |
cpuTime () | |
Construct from components. | |
~cpuTime () | |
double | elapsedCpuTime () const |
Returns CPU time from start of run. | |
double | cpuTimeIncrement () const |
Returns CPU time from last call of cpuTimeIncrement() | |
![]() | |
TimePaths (const fileName &rootPath, const fileName &caseName, const word &systemName, const word &constantName) | |
Construct given database name, rootPath and casePath. | |
bool | processorCase () const |
Return true if this is a processor case. | |
const word & | system () const |
Return system name. | |
fileName | caseSystem () const |
Return system name for the case. | |
const word & | constant () const |
Return constant name. | |
fileName | caseConstant () const |
Return constant name for the case. | |
fileName | systemPath () const |
Return system path. | |
fileName | constantPath () const |
Return constant path. | |
![]() | |
TypeName ("objectRegistry") | |
Declare type name for this IOobject. | |
objectRegistry (const Time &db, const label nIoObjects=128) | |
Construct the time objectRegistry given an initial estimate. | |
objectRegistry (const IOobject &io, const label nIoObjects=128) | |
Construct a sub-registry given an IObject to describe the registry. | |
virtual | ~objectRegistry () |
const Time & | time () const |
Return time. | |
const objectRegistry & | parent () const |
Return the parent objectRegistry. | |
wordList | names () const |
Return the list of names of the IOobjects. | |
wordList | names (const word &className) const |
Return the list of names of the IOobjects of given class name. | |
template<class Type > | |
wordList | names () const |
Return the list of names of the IOobjects of given type. | |
const objectRegistry & | subRegistry (const word &name) const |
Lookup and return a const sub-objectRegistry. | |
template<class Type > | |
HashTable< const Type * > | lookupClass () const |
Lookup and return all the object of the given Type. | |
template<class Type > | |
bool | foundObject (const word &name) const |
Is the named Type. | |
template<class Type > | |
const Type & | lookupObject (const word &name) const |
Lookup and return the object of the given Type. | |
label | getEvent () const |
Return new event number. | |
virtual void | rename (const word &newName) |
Rename. | |
bool | checkIn (regIOobject &) const |
Add an regIOobject to registry. | |
bool | checkOut (regIOobject &) const |
Remove an regIOobject from registry. | |
virtual bool | modified () const |
Return true if any of the object's files have been modified. | |
virtual bool | readIfModified () |
Read object if modified. | |
virtual bool | writeData (Ostream &) const |
writeData function required by regIOobject but not used | |
![]() | |
TypeName ("regIOobject") | |
Runtime type information. | |
regIOobject (const IOobject &, const bool isTime=false) | |
Construct from IOobject. Optional flag for if IOobject is the. | |
regIOobject (const regIOobject &) | |
Construct as copy. | |
regIOobject (const regIOobject &, bool registerCopy) | |
Construct as copy, and transferring registry registration to copy. | |
virtual | ~regIOobject () |
bool | checkIn () |
Add object to registry. | |
bool | checkOut () |
Remove object from registry. | |
bool | ownedByRegistry () const |
Is this object owned by the registry? | |
void | store () |
Transfer ownership of this object to its registry. | |
void | release () |
Release ownership of this object from its registry. | |
label | eventNo () const |
Event number at last update. | |
label & | eventNo () |
Event number at last update. | |
bool | upToDate (const word &) const |
Am I uptodate with respect to other regIOobjects. | |
bool | upToDate (const word &, const word &) const |
bool | upToDate (const word &, const word &, const word &) const |
bool | upToDate (const word &, const word &, const word &, const word &) const |
void | setUpToDate () |
Flag me as up to date. | |
Istream & | readStream (const word &) |
Return Istream and check object type against that given. | |
void | close () |
Close Istream. | |
virtual bool | readData (Istream &) |
Virtual readData function. | |
virtual bool | write () const |
Write using setting from DB. | |
void | operator= (const IOobject &) |
![]() | |
TypeName ("IOobject") | |
Runtime type information. | |
IOobject (const word &name, const fileName &instance, const objectRegistry ®istry, readOption r=NO_READ, writeOption w=NO_WRITE, bool registerObject=true) | |
Construct from name, instance, registry, io options. | |
IOobject (const word &name, const fileName &instance, const fileName &local, const objectRegistry ®istry, readOption r=NO_READ, writeOption w=NO_WRITE, bool registerObject=true) | |
Construct from name, instance, local, registry, io options. | |
IOobject (const fileName &path, const objectRegistry ®istry, readOption r=NO_READ, writeOption w=NO_WRITE, bool registerObject=true) | |
Construct from path, registry, io options. | |
Foam::autoPtr< IOobject > | clone () const |
Clone. | |
virtual | ~IOobject () |
const objectRegistry & | db () const |
Return the local objectRegistry. | |
const word & | name () const |
Return name. | |
const word & | headerClassName () const |
Return name of the class name read from header. | |
string & | note () |
Return non-constant access to the optional note. | |
const string & | note () const |
Return the optional note. | |
bool | registerObject () const |
Register object created from this IOobject with registry if true. | |
readOption | readOpt () const |
readOption & | readOpt () |
writeOption | writeOpt () const |
writeOption & | writeOpt () |
const fileName & | instance () const |
fileName & | instance () |
const fileName & | local () const |
fileName | path (const word &instance, const fileName &local="") const |
Return complete path with alternative instance and local. | |
fileName | objectPath () const |
Return complete path + object name. | |
fileName | filePath () const |
Return complete path + object name if the file exists. | |
bool | readHeader (Istream &) |
Read header. | |
bool | headerOk () |
Read and check header info. | |
bool | writeHeader (Ostream &) const |
Write header. | |
bool | good () const |
bool | bad () const |
InfoProxy< IOobject > | info () const |
Return info proxy. | |
![]() | |
bool | set (const word &, const regIOobject *&newElmt) |
Assign a new hashedEntry, overwriting existing entries. | |
HashTable (const label size=128) | |
Construct given initial table size. | |
HashTable (Istream &, const label size=128) | |
Construct from Istream. | |
HashTable (const HashTable< regIOobject *, word, string::hash > &) | |
Construct as copy. | |
HashTable (const Xfer< HashTable< regIOobject *, word, string::hash > > &) | |
Construct by transferring the parameter contents. | |
~HashTable () | |
label | size () const |
Return number of elements in table. | |
bool | empty () const |
Return true if the hash table is empty. | |
bool | found (const word &) const |
Return true if hashedEntry is found in table. | |
iterator | find (const word &) |
Find and return an iterator set at the hashedEntry. | |
const_iterator | find (const word &) const |
Find and return an const_iterator set at the hashedEntry. | |
List< word > | toc () const |
Return the table of contents. | |
List< word > | sortedToc () const |
Return the table of contents as a sorted list. | |
Ostream & | printInfo (Ostream &) const |
Print information. | |
bool | insert (const word &, const regIOobject *&newElmt) |
Insert a new hashedEntry. | |
bool | erase (const iterator &) |
Erase an hashedEntry specified by given iterator. | |
bool | erase (const word &) |
Erase an hashedEntry specified by given key if in table. | |
label | erase (const UList< word > &) |
Remove entries given by the listed keys from this HashTable. | |
label | erase (const HashTable< AnyType, word, AnyHash > &) |
Remove entries given by the given keys from this HashTable. | |
void | resize (const label newSize) |
Resize the hash table for efficiency. | |
void | clear () |
Clear all entries from table. | |
void | clearStorage () |
Clear the table entries and the table itself. | |
void | transfer (HashTable< regIOobject *, word, string::hash > &) |
Transfer the contents of the argument table into this table. | |
Xfer< HashTable< regIOobject *, word, string::hash > > | xfer () |
Transfer contents to the Xfer container. | |
regIOobject *& | operator[] (const word &) |
Find and return an hashedEntry. | |
const regIOobject *& | operator[] (const word &) const |
Find and return an hashedEntry. | |
regIOobject *& | operator() (const word &) |
Find and return an hashedEntry, create it null if not present. | |
void | operator= (const HashTable< regIOobject *, word, string::hash > &) |
Assignment. | |
bool | operator== (const HashTable< regIOobject *, word, string::hash > &) const |
Equality. Two hash tables are equal if all contents of first are. | |
bool | operator!= (const HashTable< regIOobject *, word, string::hash > &) const |
The opposite of the equality operation. Takes linear time. | |
iterator | begin () |
iterator set to the begining of the HashTable | |
const_iterator | begin () const |
const_iterator set to the beginning of the HashTable | |
const iterator & | end () |
iterator set to beyond the end of the HashTable | |
const_iterator | cbegin () const |
const_iterator set to the beginning of the HashTable | |
const const_iterator & | cend () const |
const_iterator set to beyond the end of the HashTable | |
![]() | |
TimeState () | |
virtual | ~TimeState () |
Destructor. | |
scalar | timeOutputValue () const |
Return current time value. | |
label | timeIndex () const |
Return current time index. | |
scalar | deltaTValue () const |
Return time step value. | |
scalar | deltaT0Value () const |
Return old time step value. | |
dimensionedScalar | deltaT () const |
Return time step. | |
dimensionedScalar | deltaT0 () const |
Return old time step. | |
bool | outputTime () const |
Return true if this is an output time. | |
![]() | |
dimensioned (const word &, const dimensionSet &, const Type) | |
Construct given a name, a value and its dimensionSet. | |
dimensioned (const word &, const dimensioned< Type > &) | |
Construct from a dimensioned<Type> changing the name. | |
dimensioned (const Type &t) | |
Construct given a value (creates dimensionless value). | |
dimensioned (Istream &) | |
Construct from Istream. | |
dimensioned (const word &, Istream &) | |
Construct from an Istream with a given name. | |
dimensioned (const word &, const dimensionSet &, Istream &) | |
Construct from an Istream with a given name and dimensions. | |
const word & | name () const |
Return const reference to name. | |
word & | name () |
Return non-const reference to name. | |
const dimensionSet & | dimensions () const |
Return const reference to dimensions. | |
dimensionSet & | dimensions () |
Return non-const reference to dimensions. | |
const Type & | value () const |
Return const reference to value. | |
Type & | value () |
Return non-const reference to value. | |
dimensioned< cmptType > | component (const direction) const |
Return a component as a dimensioned<cmptType> | |
void | replace (const direction, const dimensioned< cmptType > &) |
Return a component with a dimensioned<cmptType> | |
dimensioned< Type > | T () const |
Return transpose. | |
bool | readIfPresent (const dictionary &) |
Update the value of dimensioned<Type> if found in the dictionary. | |
dimensioned< cmptType > | operator[] (const direction) const |
Return a component as a dimensioned<cmptType> | |
void | operator+= (const dimensioned< Type > &) |
void | operator-= (const dimensioned< Type > &) |
void | operator*= (const scalar) |
void | operator/= (const scalar) |
Additional Inherited Members | |
![]() | |
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... | |
![]() | |
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 time_t | getTime () |
Get the current clock time in seconds. | |
static struct tm | rawDate () |
Return the current wall-clock date as a raw struct. | |
static string | dateTime () |
Return the current wall-clock date/time as a string. | |
static string | date () |
Return the current wall-clock date as a string. | |
static string | clockTime () |
Return the current wall-clock time as a string. | |
![]() | |
static word | controlDictName |
The default control dictionary name (normally "controlDict") | |
![]() | |
void | adjustDeltaT () |
Adjust the time step so that writing occurs at the specified time. | |
void | setControls () |
Set the controls from the current controlDict. | |
![]() | |
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. | |
![]() | |
label | timeIndex_ |
scalar | deltaT_ |
scalar | deltaTSave_ |
scalar | deltaT0_ |
bool | deltaTchanged_ |
label | outputTimeIndex_ |
bool | outputTime_ |
![]() | |
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. |
engineTime | ( | const word & | name, |
const fileName & | rootPath, | ||
const fileName & | caseName, | ||
const fileName & | systemName = "system" , |
||
const fileName & | constantName = "constant" , |
||
const fileName & | dictName = "engineGeometry" |
||
) |
Construct from objectRegistry arguments.
Definition at line 51 of file engineTime.C.
References dimensioned< Type >::readIfPresent().
|
inlinevirtual |
Definition at line 115 of file engineTime.H.
Foam::scalar degToRad | ( | const scalar | rad | ) | const |
Convert degrees to radians.
Definition at line 125 of file engineTime.C.
References Foam::mathematicalConstant::pi().
Foam::scalar degToTime | ( | const scalar | theta | ) | const |
Convert degrees to seconds (for given engine speed in RPM)
Definition at line 131 of file engineTime.C.
Foam::scalar timeToDeg | ( | const scalar | t | ) | const |
Convert seconds to degrees (for given engine speed in RPM)
Definition at line 138 of file engineTime.C.
Foam::scalar pistonPosition | ( | const scalar | theta | ) | const |
Calculate the piston position from the engine geometry.
and given crank angle.
Definition at line 177 of file engineTime.C.
References Foam::cos(), Foam::sin(), Foam::sqr(), and Foam::sqrt().
|
inline |
Return the engine geometry dictionary.
Definition at line 140 of file engineTime.H.
Referenced by fvMotionSolverEngineMesh::fvMotionSolverEngineMesh(), and layeredEngineMesh::layeredEngineMesh().
|
inline |
Return the engines current operating RPM.
Definition at line 146 of file engineTime.H.
|
inline |
Return the engines connecting-rod length.
Definition at line 152 of file engineTime.H.
|
inline |
Return the engines bore.
Definition at line 158 of file engineTime.H.
|
inline |
Return the engines stroke.
Definition at line 164 of file engineTime.H.
|
inline |
Return the engines clearance-gap.
Definition at line 170 of file engineTime.H.
Foam::scalar theta | ( | ) | const |
Return current crank-angle.
Definition at line 145 of file engineTime.C.
Foam::scalar thetaRevolution | ( | ) | const |
Return current crank-angle translated to a single revolution.
(value between -180 and 180 with 0 = top dead centre)
Definition at line 153 of file engineTime.C.
Foam::scalar deltaTheta | ( | ) | const |
Return crank-angle increment.
Definition at line 171 of file engineTime.C.
Foam::dimensionedScalar pistonPosition | ( | ) | const |
Return current piston position.
Definition at line 196 of file engineTime.C.
References Foam::dimLength.
Foam::dimensionedScalar pistonDisplacement | ( | ) | const |
Return piston displacement for current time step.
Definition at line 207 of file engineTime.C.
References Foam::dimLength.
Referenced by layeredEngineMesh::move(), and fvMotionSolverEngineMesh::move().
Foam::dimensionedScalar pistonSpeed | ( | ) | const |
Return piston speed for current time step.
Definition at line 218 of file engineTime.C.
References Foam::dimVelocity.
|
virtual |
Convert the user-time (CA deg) to real-time (s).
Reimplemented from TimeState.
Definition at line 229 of file engineTime.C.
|
virtual |
Convert the real-time (s) into user-time (CA deg)
Reimplemented from TimeState.
Definition at line 235 of file engineTime.C.
|
virtual |
Read the control dictionary and set the write controls etc.
Reimplemented from Time.
Definition at line 103 of file engineTime.C.
References Time::readDict().
|
virtual |
Read the controlDict and set all the parameters.
Reimplemented from Time.
Definition at line 111 of file engineTime.C.
References Time::read().