Skip to content
Snippets Groups Projects
Commit 3b63c760 authored by Henry Weller's avatar Henry Weller
Browse files

writeRegisteredObject: Now writes the <time>/uniform/time dictionary

parent d6ce71f3
No related merge requests found
...@@ -372,6 +372,9 @@ public: ...@@ -372,6 +372,9 @@ public:
const word& constantName = "constant" const word& constantName = "constant"
); );
//- Write time dictionary to the <time>/uniform directory
virtual bool writeTimeDict() const;
//- Write using given format, version and compression //- Write using given format, version and compression
virtual bool writeObject virtual bool writeObject
( (
......
...@@ -410,6 +410,39 @@ void Foam::Time::readModifiedObjects() ...@@ -410,6 +410,39 @@ void Foam::Time::readModifiedObjects()
} }
bool Foam::Time::writeTimeDict() const
{
const word tmName(timeName());
IOdictionary timeDict
(
IOobject
(
"time",
tmName,
"uniform",
*this,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
)
);
timeDict.add("value", timeName(timeToUserTime(value()), maxPrecision_));
timeDict.add("name", string(tmName));
timeDict.add("index", timeIndex_);
timeDict.add("deltaT", timeToUserTime(deltaT_));
timeDict.add("deltaT0", timeToUserTime(deltaT0_));
return timeDict.regIOobject::writeObject
(
IOstream::ASCII,
IOstream::currentVersion,
IOstream::UNCOMPRESSED
);
}
bool Foam::Time::writeObject bool Foam::Time::writeObject
( (
IOstream::streamFormat fmt, IOstream::streamFormat fmt,
...@@ -419,37 +452,19 @@ bool Foam::Time::writeObject ...@@ -419,37 +452,19 @@ bool Foam::Time::writeObject
{ {
if (writeTime()) if (writeTime())
{ {
const word tmName(timeName()); bool writeOK = writeTimeDict();
IOdictionary timeDict
(
IOobject
(
"time",
tmName,
"uniform",
*this,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
)
);
timeDict.add("value", timeName(timeToUserTime(value()), maxPrecision_));
timeDict.add("name", string(tmName));
timeDict.add("index", timeIndex_);
timeDict.add("deltaT", timeToUserTime(deltaT_));
timeDict.add("deltaT0", timeToUserTime(deltaT0_));
timeDict.regIOobject::writeObject(fmt, ver, cmp); if (writeOK)
bool writeOK = objectRegistry::writeObject(fmt, ver, cmp); {
writeOK = objectRegistry::writeObject(fmt, ver, cmp);
}
if (writeOK) if (writeOK)
{ {
// Does the writeTime trigger purging? // Does the writeTime trigger purging?
if (writeTime_ && purgeWrite_) if (writeTime_ && purgeWrite_)
{ {
previousWriteTimes_.push(tmName); previousWriteTimes_.push(timeName());
while (previousWriteTimes_.size() > purgeWrite_) while (previousWriteTimes_.size() > purgeWrite_)
{ {
......
...@@ -103,6 +103,11 @@ bool Foam::functionObjects::writeRegisteredObject::write ...@@ -103,6 +103,11 @@ bool Foam::functionObjects::writeRegisteredObject::write
{ {
Info<< type() << " " << name() << " output:" << nl; Info<< type() << " " << name() << " output:" << nl;
if (!obr_.time().writeTime())
{
obr_.time().writeTimeDict();
}
DynamicList<word> allNames(obr_.toc().size()); DynamicList<word> allNames(obr_.toc().size());
forAll(objectNames_, i) forAll(objectNames_, i)
{ {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment