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;
170 autoPtr<fileOperation> newHandler =
175 newHandler->distributed(
true);
182 fileHandler().addWatches(controlDict_, oldWatched);
192 (localDict = controlDict_.
findDict(
"DimensionedConstants")) !=
nullptr 197 <<
"Overriding DimensionedConstants according to " 198 << controlDict_.
name() <<
nl;
205 IStringStream dummyIs(
"");
209 const List<simpleRegIOobject*>& objects = *iter;
211 for (simpleRegIOobject* obj : objects)
213 obj->readData(dummyIs);
218 obj->writeData(
Info);
229 (localDict = controlDict_.
findDict(
"DimensionSets")) !=
nullptr 234 <<
"Overriding DimensionSets according to " 235 << controlDict_.
name() <<
nl;
240 dict.merge(*localDict);
242 simpleObjectRegistryEntry* objPtr = objs.find(
"DimensionSets");
248 const List<simpleRegIOobject*>& objects = *objPtr;
250 for (simpleRegIOobject* obj : objects)
254 IStringStream is(
os.str());
280 <<
"writeInterval < 1 for writeControl timeStep" 317 <<
", should be >= 0, setting to 0" 324 if (controlDict_.
found(
"timeFormat"))
326 const word formatName(controlDict_.
get<word>(
"timeFormat"));
328 if (formatName ==
"general")
332 else if (formatName ==
"fixed")
336 else if (formatName ==
"scientific")
343 <<
"unsupported time format " << formatName
370 if (controlDict_.
found(
"writeVersion"))
372 writeStreamOption_.
version(controlDict_.
get<token>(
"writeVersion"));
375 if (controlDict_.
found(
"writeFormat"))
377 writeStreamOption_.
format(controlDict_.
get<word>(
"writeFormat"));
380 if (controlDict_.
found(
"writePrecision"))
384 controlDict_.
get<
unsigned int>(
"writePrecision")
397 if (controlDict_.
found(
"writeCompression"))
401 controlDict_.
get<word>(
"writeCompression")
409 <<
"Disabled binary format compression" 410 <<
" (inefficient/ineffective)" 418 <<
"Disabled output compression" 419 <<
" (missing libz support)" 428 controlDict_.
readIfPresent(
"runTimeModifiable", runTimeModifiable_);
444 if (controlDict_.regIOobject::read())
448 functionObjects_.read();
450 if (runTimeModifiable_)
456 fileHandler().addWatches(controlDict_, controlDict_.files());
458 controlDict_.files().clear();
469 if (runTimeModifiable_)
486 if (controlDict_.readIfModified())
489 functionObjects_.read();
491 if (runTimeModifiable_)
498 fileHandler().addWatches(controlDict_, controlDict_.files());
500 controlDict_.files().clear();
505 if (registryModified)
519 IOdictionary timeDict
533 timeDict.add(
"value",
timeName(timeToUserTime(value()), maxPrecision_));
534 timeDict.add(
"name",
string(tmName));
535 timeDict.add(
"index", timeIndex_);
536 timeDict.add(
"deltaT", timeToUserTime(deltaT_));
537 timeDict.add(
"deltaT0", timeToUserTime(deltaT0_));
539 return timeDict.regIOobject::writeObject
555 bool writeOK = writeTimeDict();
565 if (writeTime_ && purgeWrite_)
569 previousWriteTimes_.empty()
570 || previousWriteTimes_.top() !=
timeName()
573 previousWriteTimes_.push(
timeName());
576 while (previousWriteTimes_.size() > purgeWrite_)
606 stopAt_ = saWriteNow;
621 switch (printExecutionFormat_)
625 os <<
"ExecutionTime = ";
628 os <<
" ClockTime = ";
635 os <<
"ExecutionTime = " << elapsedCpuTime() <<
" s" 636 <<
" 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...
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write the objects using stream options.
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.
autoPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file 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 writeTimeDict() const
Write time dictionary to the <time>/uniform directory.
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.
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.
List< fileName > fileNameList
A List of fileNames.
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.
bool writeNow()
Write the objects immediately (not at end of iteration) and continue the run.
forAllConstIters(mixture.phases(), phase)
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
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 ...