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);
101 const dictionary* localDict =
nullptr;
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;
210 IStringStream dummyIs(
"");
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;
258 for (simpleRegIOobject* obj : objects)
262 IStringStream is(
os.str());
288 <<
"writeInterval < 1 for writeControl timeStep" 325 <<
", should be >= 0, setting to 0" 332 if (controlDict_.
found(
"timeFormat"))
334 const word formatName(controlDict_.
get<word>(
"timeFormat"));
336 if (formatName ==
"general")
340 else if (formatName ==
"fixed")
344 else if (formatName ==
"scientific")
351 <<
"unsupported time format " << formatName
378 if (controlDict_.
found(
"writeVersion"))
380 writeStreamOption_.
version(controlDict_.
get<token>(
"writeVersion"));
383 if (controlDict_.
found(
"writeFormat"))
385 writeStreamOption_.
format(controlDict_.
get<word>(
"writeFormat"));
388 if (controlDict_.
found(
"writePrecision"))
392 controlDict_.
get<
unsigned int>(
"writePrecision")
405 if (controlDict_.
found(
"writeCompression"))
409 controlDict_.
get<word>(
"writeCompression")
417 <<
"Disabled binary format compression" 418 <<
" (inefficient/ineffective)" 426 <<
"Disabled output compression" 427 <<
" (missing libz support)" 436 controlDict_.
readIfPresent(
"runTimeModifiable", runTimeModifiable_);
452 if (controlDict_.regIOobject::read())
456 functionObjects_.read();
458 if (runTimeModifiable_)
464 fileHandler().addWatches(controlDict_, controlDict_.files());
466 controlDict_.files().clear();
477 if (runTimeModifiable_)
494 if (controlDict_.readIfModified())
497 functionObjects_.read();
499 if (runTimeModifiable_)
506 fileHandler().addWatches(controlDict_, controlDict_.files());
508 controlDict_.files().clear();
513 if (registryModified)
527 IOdictionary timeDict
541 timeDict.add(
"value",
timeName(timeToUserTime(value()), maxPrecision_));
542 timeDict.add(
"name",
string(tmName));
543 timeDict.add(
"index", timeIndex_);
544 timeDict.add(
"deltaT", timeToUserTime(deltaT_));
545 timeDict.add(
"deltaT0", timeToUserTime(deltaT0_));
547 return timeDict.regIOobject::writeObject
558 const bool writeOnProc
563 bool writeOK = writeTimeDict();
573 if (writeTime_ && purgeWrite_)
577 previousWriteTimes_.empty()
578 || previousWriteTimes_.top() !=
timeName()
581 previousWriteTimes_.push(
timeName());
584 while (previousWriteTimes_.size() > purgeWrite_)
614 stopAt_ = saWriteNow;
629 switch (printExecutionFormat_)
633 os <<
"ExecutionTime = ";
636 os <<
" ClockTime = ";
643 os <<
"ExecutionTime = " << elapsedCpuTime() <<
" s" 644 <<
" 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 Type & value() const noexcept
Return const reference to value.
void size(const label n)
Older name for setAddressableSize.
#define addProfiling(name, descr)
Define profiling trigger with specified name and description string.
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.
virtual int precision() const
Get precision of output field.
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...
int infoDetailLevel
Global for selective suppression of Info output.
constexpr char nl
The newline '\n' character (0x0a)
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.
static fmtflags format_
Time directory name format.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
static bool supports_gz()
True if compiled with libz support.
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.
virtual std::ostream & stdStream()
Access to underlying std::ostream.
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_
virtual word timeName() const
Return current time name.
simpleObjectRegistry & optimisationObjects()
Access to registered OptimisationSwitch objects.
fileName path() const
The complete path.
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.
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.
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)
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.
Stop when Time reaches prescribed endTime.
simpleObjectRegistry & dimensionedConstantObjects()
Access to registered DimensionedConstants objects.
versionNumber version() const noexcept
Get the stream version.
bool readIfPresent(const word &key, const dictionary &dict, EnumType &val) const
Find an entry if present, and assign to T val.
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 a sub-dictionary) otherwise return nullptr...
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...