47 static std::ostream&
printTimeHMS(std::ostream&
os,
double seconds)
49 const unsigned long ss = seconds;
52 const auto dd = (ss / 86400);
54 if (dd)
os << dd <<
'-';
57 const int hh = ((ss / 3600) % 24);
67 << ((ss / 60) % 60) <<
':';
75 const int hundredths = int(100 * (seconds - ss)) % 100;
96 setEnv(
"FOAM_APPLICATION", application,
false);
106 (localDict = controlDict_.
findDict(
"DebugSwitches")) !=
nullptr 111 <<
"Overriding DebugSwitches according to " 112 << controlDict_.
name() <<
nl;
121 (localDict = controlDict_.
findDict(
"InfoSwitches")) !=
nullptr 126 <<
"Overriding InfoSwitches according to " 127 << controlDict_.
name() <<
nl;
135 (localDict = controlDict_.
findDict(
"OptimisationSwitches")) !=
nullptr 140 <<
"Overriding OptimisationSwitches according to " 141 << controlDict_.
name() <<
nl;
149 word fileHandlerName;
153 && localDict->readIfPresent(
"fileHandler", fileHandlerName)
157 DetailInfo <<
"Overriding fileHandler to " << fileHandlerName <<
nl;
173 refPtr<fileOperation> newHandler
187 fileHandler().addWatches(controlDict_, oldWatched);
197 (localDict = controlDict_.
findDict(
"DimensionedConstants")) !=
nullptr 202 <<
"Overriding DimensionedConstants according to " 203 << controlDict_.
name() <<
nl;
217 const List<simpleRegIOobject*>&
objects = *iter;
219 for (simpleRegIOobject* obj :
objects)
221 obj->readData(dummyIs);
226 obj->writeData(
Info);
237 (localDict = controlDict_.
findDict(
"DimensionSets")) !=
nullptr 242 <<
"Overriding DimensionSets according to " 243 << controlDict_.
name() <<
nl;
248 dict.merge(*localDict);
250 simpleObjectRegistryEntry* objPtr = objs.find(
"DimensionSets");
256 const List<simpleRegIOobject*>&
objects = *objPtr;
260 for (simpleRegIOobject* obj :
objects)
265 ISpanStream is(
os.view());
291 <<
"writeInterval < 1 for writeControl timeStep" 328 <<
", should be >= 0, setting to 0" 362 if (controlDict_.
found(
"writeVersion"))
364 writeStreamOption_.
version(controlDict_.
get<token>(
"writeVersion"));
370 if (controlDict_.
found(
"writeFormat"))
372 writeStreamOption_.
format(controlDict_.
get<word>(
"writeFormat"));
375 if (controlDict_.
found(
"writePrecision"))
379 controlDict_.
get<
unsigned int>(
"writePrecision")
392 if (controlDict_.
found(
"writeCompression"))
396 controlDict_.
get<word>(
"writeCompression")
404 <<
"Disabled output compression for non-ascii format" 405 <<
" (inefficient/ineffective)" 413 <<
"Disabled output compression" 414 <<
" (missing libz support)" 423 controlDict_.
readIfPresent(
"runTimeModifiable", runTimeModifiable_);
439 if (controlDict_.regIOobject::read())
443 functionObjects_.read();
445 if (runTimeModifiable_)
451 fileHandler().addWatches(controlDict_, controlDict_.files());
453 controlDict_.files().clear();
464 if (runTimeModifiable_)
481 if (controlDict_.readIfModified())
484 functionObjects_.read();
486 if (runTimeModifiable_)
493 fileHandler().addWatches(controlDict_, controlDict_.files());
495 controlDict_.files().clear();
500 if (registryModified)
514 IOdictionary timeDict
528 timeDict.add(
"value",
timeName(timeToUserTime(value()), maxPrecision_));
529 timeDict.add(
"name",
string(tmName));
530 timeDict.add(
"index", timeIndex_);
531 timeDict.add(
"deltaT", timeToUserTime(deltaT_));
532 timeDict.add(
"deltaT0", timeToUserTime(deltaT0_));
534 return timeDict.regIOobject::writeObject
545 const bool writeOnProc
550 bool writeOK = writeTimeDict();
560 if (writeTime_ && purgeWrite_)
564 previousWriteTimes_.empty()
565 || previousWriteTimes_.top() !=
timeName()
568 previousWriteTimes_.push(
timeName());
571 while (previousWriteTimes_.size() > purgeWrite_)
601 stopAt_ = saWriteNow;
616 switch (printExecutionFormat_)
620 os <<
"ExecutionTime = ";
623 os <<
" ClockTime = ";
630 os <<
"ExecutionTime = " << elapsedCpuTime() <<
" s" 631 <<
" ClockTime = " << elapsedClockTime() <<
" s";
Omanip< char > setfill(char fillch)
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
Generic output stream using a standard (STL) stream.
const scalar & value() const noexcept
Return const reference to value.
void size(const label n)
Older name for setAddressableSize.
bool writeAndEnd()
Write the objects now (not at end of iteration) and end the run.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void readModifiedObjects()
Read the objects that have been modified.
Dictionary reading and supplying the dimensioned constants used within OpenFOAM, particularly for the...
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
bool readIfPresent(const word &key, const dictionary &dict, EnumType &val, const bool warnOnly=false) const
Find an entry if present, and assign to T val.
int infoDetailLevel
Global for selective suppression of Info output.
constexpr char nl
The newline '\n' character (0x0a)
static bool supports_gz() noexcept
True if compiled with libz support.
static std::ostream & printTimeHMS(std::ostream &os, double seconds)
virtual bool modified() const
Return true if any of the object's files have been modified.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
#define addProfiling(Name,...)
Define profiling trigger with specified name and description string. The description is generated by ...
static unsigned int defaultPrecision() noexcept
Return the default precision.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler()
static const Enum< stopAtControls > stopAtControlNames
Names for stopAtControls.
A simple container for options an IOstream can normally have.
Ignore writing from objectRegistry::writeObject()
simpleObjectRegistry & debugObjects()
Access to registered DebugSwitch objects.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
writeControls writeControl_
const word & timeName() const noexcept
Return the current time name.
simpleObjectRegistry & optimisationObjects()
Access to registered OptimisationSwitch objects.
fileName path() const
The complete path for the object (with instance, local,...).
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
dictionary & dimensionedConstants()
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options.
virtual bool writeTimeDict() const
Write time dictionary to the <time>/uniform directory.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write the objects using stream options.
virtual const std::ostream & stdStream() const override
Const access to underlying std::ostream.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
bool merge(const dictionary &dict)
Merge entries from the given dictionary.
"adjustable" / "adjustableRunTime"
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
void setValues(const dictionary &dict, bool report=false)
Set values (invoke callbacks) from dictionary entries.
static int precision_
Time directory name precision.
void clear()
Clear the list, i.e. set size to zero.
virtual int precision() const override
Get precision of output field.
static const Enum< writeControls > writeControlNames
Names for writeControls.
OSstream Sout
OSstream wrapped stdout (std::cout)
const word & name() const
Name function is needed to disambiguate those inherited from regIOobject and dictionary.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
const labelList & watchIndices() const noexcept
Read access to file-monitoring handles.
bool distributed() const noexcept
True if case running with parallel distributed directories (ie. not NFS mounted)
static IOstreamOption::floatFormat format_
Format for time directory names (general | fixed | scientific)
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...
OBJstream os(runTime.globalPath()/outputName)
virtual void readDict()
Read the control dictionary and set the write controls etc.
simpleObjectRegistry & infoObjects()
Access to registered InfoSwitch objects.
static fileCheckTypes fileModificationChecking
Type of file modification checking.
compressionType compression() const noexcept
Get the stream compression.
Ostream & printExecutionTime(OSstream &os) const
Print the elapsed ExecutionTime (cpu-time), ClockTime.
static autoPtr< fileOperation > New(const word &handlerType, bool verbose=false)
Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty.
void readModifiedObjects()
Read the objects that have been modified.
simpleObjectRegistry & dimensionSetObjects()
Access to registered DimensionSets objects.
const word & name() const noexcept
Return const reference to name.
void writeOnce()
Write the objects once (one shot) and continue the run.
dictionary & dimensionSystems()
Top level dictionary.
virtual bool read()
Read control dictionary, update controls and time.
#define WarningInFunction
Report a warning using Foam::Warning.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OSstream & stream()
Return OSstream for output operations.
static floatFormat floatFormatEnum(const word &fmtName, const floatFormat deflt=floatFormat::general)
Lookup floatFormat enum corresponding to the string (general | fixed | scientific).
Stop when Time reaches prescribed endTime.
UPtrList< Type > objects()
Return unsorted list of objects with a class satisfying isA<Type> or isType<Type> (with Strict) ...
simpleObjectRegistry & dimensionedConstantObjects()
Access to registered DimensionedConstants objects.
versionNumber version() const noexcept
Get the stream version.
bool distributed() const noexcept
Distributed roots (parallel run)
OSstream Serr
OSstream wrapped stderr (std::cerr)
messageStream Info
Information stream (stdout output on master, null elsewhere)
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
Omanip< int > setw(const int i)
#define forAllReverse(list, i)
Reverse loop across all elements in list.
static const fileOperation & fileHandler()
Return the current file handler. Will create the default file handler if necessary.
List< fileName > fileNameList
List of fileName.
streamFormat format() const noexcept
Get the current stream format.
bool setEnv(const word &name, const std::string &value, const bool overwrite)
Set an environment variable, return true on success.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Do not request registration (bool: false)
bool writeNow()
Write the objects immediately (not at end of iteration) and continue the run.
forAllConstIters(mixture.phases(), phase)
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...
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...