50 const unsigned long ss = seconds;
53 const auto dd = (ss / 86400);
55 if (dd)
os << dd <<
'-';
58 const int hh = ((ss / 3600) % 24);
62 os << std::setw(2) << std::setfill(
'0')
67 os << std::setw(2) << std::setfill(
'0')
68 << ((ss / 60) % 60) <<
':';
71 os << std::setw(2) << std::setfill(
'0')
76 const int hundredths = int(100 * (seconds - ss)) % 100;
80 os <<
'.' << std::setw(2) << std::setfill(
'0') << hundredths;
97 setEnv(
"FOAM_APPLICATION", application,
false);
107 (localDict = controlDict_.findDict(
"DebugSwitches")) !=
nullptr
112 <<
"Overriding DebugSwitches according to "
113 << controlDict_.name() <<
nl;
122 (localDict = controlDict_.findDict(
"InfoSwitches")) !=
nullptr
127 <<
"Overriding InfoSwitches according to "
128 << controlDict_.name() <<
nl;
136 (localDict = controlDict_.findDict(
"OptimisationSwitches")) !=
nullptr
141 <<
"Overriding OptimisationSwitches according to "
142 << controlDict_.name() <<
nl;
153 word fileHandlerName;
157 && localDict->readIfPresent(
"fileHandler", fileHandlerName)
161 DetailInfo <<
"Overriding fileHandler to " << fileHandlerName <<
nl;
164 fileNameList oldWatched(controlDict_.watchIndices().size());
167 const label watchi = controlDict_.watchIndices()[i];
171 controlDict_.watchIndices().clear();
177 refPtr<fileOperation> newHandler
187 newHandler->distributed(
true);
201 (localDict = controlDict_.findDict(
"DimensionedConstants")) !=
nullptr
206 <<
"Overriding DimensionedConstants according to "
207 << controlDict_.name() <<
nl;
221 const List<simpleRegIOobject*>&
objects = *iter;
223 for (simpleRegIOobject* obj :
objects)
225 obj->readData(dummyIs);
230 obj->writeData(
Info);
241 (localDict = controlDict_.findDict(
"DimensionSets")) !=
nullptr
246 <<
"Overriding DimensionSets according to "
247 << controlDict_.name() <<
nl;
252 dict.merge(*localDict);
254 simpleObjectRegistryEntry* objPtr = objs.find(
"DimensionSets");
260 const List<simpleRegIOobject*>&
objects = *objPtr;
264 for (simpleRegIOobject* obj :
objects)
269 ISpanStream is(
os.view());
278 controlDict_.readEntry(
"deltaT",
deltaT_);
295 <<
"writeInterval < 1 for writeControl timeStep"
326 if (controlDict_.readIfPresent(
"purgeWrite",
purgeWrite_))
332 <<
", should be >= 0, setting to 0"
342 controlDict_.readIfPresent(
"timePrecision",
precision_);
350 controlDict_.readEntry(
"endTime",
endTime_);
357 else if (!controlDict_.readIfPresent(
"endTime",
endTime_))
366 if (controlDict_.found(
"writeVersion"))
368 writeStreamOption_.version(controlDict_.get<token>(
"writeVersion"));
374 if (controlDict_.found(
"writeFormat"))
376 writeStreamOption_.format(controlDict_.get<word>(
"writeFormat"));
379 if (controlDict_.found(
"writePrecision"))
383 controlDict_.get<
unsigned int>(
"writePrecision")
396 if (controlDict_.found(
"writeCompression"))
398 writeStreamOption_.compression
400 controlDict_.get<word>(
"writeCompression")
408 <<
"Disabled output compression for non-ascii format"
409 <<
" (inefficient/ineffective)"
417 <<
"Disabled output compression"
418 <<
" (missing libz support)"
426 controlDict_.readIfPresent(
"graphFormat", graphFormat_);
427 controlDict_.readIfPresent(
"runTimeModifiable", runTimeModifiable_);
430 if (!runTimeModifiable_ && controlDict_.watchIndices().size())
443 if (controlDict_.regIOobject::read())
447 functionObjects_.read();
449 if (runTimeModifiable_)
455 fileHandler().addWatches(controlDict_, controlDict_.files());
457 controlDict_.files().clear();
468 if (runTimeModifiable_)
482 if (controlDict_.readIfModified())
485 functionObjects_.read();
487 if (runTimeModifiable_)
494 fileHandler().addWatches(controlDict_, controlDict_.files());
496 controlDict_.files().clear();
501 if (registryModified)
529 timeDict.add(
"value",
timeName(timeToUserTime(value()), maxPrecision_));
530 timeDict.add(
"name",
string(tmName));
531 timeDict.add(
"index", timeIndex_);
532 timeDict.add(
"deltaT", timeToUserTime(deltaT_));
533 timeDict.add(
"deltaT0", timeToUserTime(deltaT0_));
535 return timeDict.regIOobject::writeObject
546 const bool writeOnProc
551 bool writeOK = writeTimeDict();
561 if (writeTime_ && purgeWrite_)
565 previousWriteTimes_.empty()
566 || previousWriteTimes_.top() !=
timeName()
569 previousWriteTimes_.push(
timeName());
572 while (previousWriteTimes_.size() > purgeWrite_)
617 switch (printExecutionFormat_)
621 os <<
"ExecutionTime = ";
624 os <<
" ClockTime = ";
631 os <<
"ExecutionTime = " << elapsedCpuTime() <<
" s"
632 <<
" ClockTime = " << elapsedClockTime() <<
" s";
label size() const noexcept
The number of elements in list.
T * find(const word &keyword)
Find and return an entry, nullptr on failure.
static void warnLocalBoundaryConsistencyCompat(const dictionary &)
Warn about keyword changes for local boundary consistency checks.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static bool fileModificationChecking_masterOnly() noexcept
Test fileModificationChecking for master-only.
fileName path() const
The complete path for the object (with instance, local,...).
A simple container for options an IOstream can normally have.
compressionType compression() const noexcept
Get the stream compression.
static floatFormat floatFormatEnum(const word &fmtName, const floatFormat deflt=floatFormat::general)
Lookup floatFormat enum corresponding to the string (general | fixed | scientific).
@ ASCII
"ascii" (normal default)
@ UNCOMPRESSED
compression = false
@ COMPRESSED
compression = true
static unsigned int defaultPrecision() noexcept
Return the default precision.
Similar to IStringStream but using an externally managed buffer for its input. This allows the input ...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void clear()
Clear the list, i.e. set size to zero.
An OSstream with internal List storage.
Generic output stream using a standard (STL) stream.
virtual int precision() const override
Get precision of output field.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
bool distributed() const noexcept
True if case running with parallel distributed directories (ie. not NFS mounted).
virtual scalar timeToUserTime(const scalar t) const
Convert the real-time (s) into user-time (e.g. CA deg).
bool writeTime() const noexcept
True if this is a write interval.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options.
virtual void readDict()
Read the control dictionary and set the write controls etc.
static int precision_
Time directory name precision.
virtual bool writeTimeDict() const
Write time dictionary to the <time>/uniform directory.
bool writeAndEnd()
Write the objects now (not at end of iteration) and end the run.
static const Enum< stopAtControls > stopAtControlNames
Names for stopAtControls.
static IOstreamOption::floatFormat format_
Format for time directory names (general | fixed | scientific).
@ wcAdjustableRunTime
"adjustable" / "adjustableRunTime"
bool writeNow()
Write the objects immediately (not at end of iteration) and continue the run.
static int printExecutionFormat_
Style for "ExecutionTime = " output.
FIFOStack< word > previousWriteTimes_
void writeOnce()
Write the objects once (one shot) and continue the run.
static const int maxPrecision_
Maximum time directory name precision.
@ saWriteNow
adjust endTime to stop immediately w/ writing
@ saEndTime
Stop when Time reaches prescribed endTime.
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
writeControls writeControl_
static const Enum< writeControls > writeControlNames
Names for writeControls.
Ostream & printExecutionTime(OSstream &os) const
Print the elapsed ExecutionTime (cpu-time), ClockTime.
void readModifiedObjects()
Read the objects that have been modified.
const word & timeName() const noexcept
The current time name.
virtual bool read()
Read control dictionary, update controls and time.
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static bool & parRun() noexcept
Test if this a parallel run.
double elapsedClockTime() const
Returns wall-clock time since clock instantiation.
double elapsedCpuTime() const
Return CPU time [seconds] from the start.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and it is a dictionary) otherwise return nullptr...
bool merge(const dictionary &dict)
Merge entries from the given dictionary.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
const word & name() const noexcept
const scalar & value() const noexcept
OSstream & stream()
Return OSstream for output operations.
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
static const fileOperation & fileHandler()
Return the current file handler. Will create the default file handler if necessary.
static autoPtr< fileOperation > New(const word &handlerType, bool verbose=false)
Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write the objects using stream options.
virtual bool modified() const
Return true if any of the object's files have been modified.
UPtrList< Type > objects()
Return unsorted list of objects with a class satisfying isA<Type> or isType<Type> (with Strict).
void readModifiedObjects()
Read the objects that have been modified.
static bool supports_gz() noexcept
True if compiled with libz support.
A class for managing references or pointers (no reference counting).
virtual fileName filePath() const
Return complete path + object name if the file exists.
const labelList & watchIndices() const noexcept
Read access to file-monitoring handles.
Object registry for simpleRegIOobject. Maintains ordering.
void setValues(const dictionary &dict, bool verbose=false, bool dryrun=false)
Set values (invoke callbacks) from dictionary entries.
Abstract base class for registered object with I/O. Used in debug symbol registration.
A token holds an item read from Istream.
A class for handling words, derived from Foam::string.
Dictionary reading and supplying the dimensioned constants used within OpenFOAM, particularly for the...
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
#define WarningInFunction
Report a warning using Foam::Warning.
simpleObjectRegistry & infoObjects()
Access to registered InfoSwitch objects.
simpleObjectRegistry & dimensionSetObjects()
Access to registered DimensionSets objects.
simpleObjectRegistry & dimensionedConstantObjects()
Access to registered DimensionedConstants objects.
simpleObjectRegistry & optimisationObjects()
Access to registered OptimisationSwitch objects.
simpleObjectRegistry & debugObjects()
Access to registered DebugSwitch objects.
bool setEnv(const word &name, const std::string &value, const bool overwrite)
Set an environment variable, return true on success.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
List< fileName > fileNameList
List of fileName.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler().
messageStream Info
Information stream (stdout output on master, null elsewhere).
dictionary & dimensionSystems()
Top level dictionary.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
OSstream Sout
OSstream wrapped stdout (std::cout).
static std::ostream & printTimeHMS(std::ostream &os, double seconds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
OSstream Serr
OSstream wrapped stderr (std::cerr).
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
int infoDetailLevel
Global for selective suppression of Info output.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dictionary & dimensionedConstants()
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
#define addProfiling(Name,...)
Define profiling trigger with specified name and description string. The description is generated by ...
#define forAllReverse(list, i)
Reverse loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.