Commit c186c884 authored by mattijs's avatar mattijs
Browse files

ENH: collated: pass through label/scalar size. Fixes #1545.

parent 8bbf26f1
......@@ -37,6 +37,7 @@ License
#include "labelPair.H"
#include "masterUncollatedFileOperation.H"
#include "IListStream.H"
#include "foamVersion.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -210,12 +211,10 @@ void Foam::decomposedBlockData::writeHeader
<< " class " << type << ";\n";
// This may be useful to have as well
/*
if (os.format() == IOstream::BINARY)
{
os << " arch " << foamVersion::buildArch << ";\n";
}
*/
if (Pstream::parRun())
{
......@@ -290,6 +289,8 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlock
IOstream::versionNumber ver(IOstream::currentVersion);
IOstream::streamFormat fmt;
unsigned labelByteSize;
unsigned scalarByteSize;
{
UIListStream headerStream
(
......@@ -308,6 +309,8 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlock
}
ver = headerStream.version();
fmt = headerStream.format();
labelByteSize = headerStream.labelByteSize();
scalarByteSize = headerStream.scalarByteSize();
}
for (label i = 1; i < blocki+1; i++)
......@@ -330,6 +333,8 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlock
// Apply master stream settings to realIsPtr
realIsPtr().format(fmt);
realIsPtr().version(ver);
realIsPtr().setLabelByteSize(labelByteSize);
realIsPtr().setScalarByteSize(scalarByteSize);
}
return realIsPtr;
}
......@@ -353,6 +358,22 @@ bool Foam::decomposedBlockData::readBlocks
bool ok = false;
//// Scatter master header info
//string ver;
//unsigned labelByteSize;
//unsigned scalarByteSize;
//if (UPstream::master(comm))
//{
// ver = isPtr().version().str();
// labelByteSize = isPtr().labelByteSize();
// scalarByteSize = isPtr().scalarByteSize();
//}
//Pstream::scatter(ver); //, Pstream::msgType(), comm);
//Pstream::scatter(labelByteSize); //, Pstream::msgType(), comm);
//Pstream::scatter(scalarByteSize); //, Pstream::msgType(), comm);
if (commsType == UPstream::commsTypes::scheduled)
{
if (UPstream::master(comm))
......@@ -637,19 +658,31 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks
Pstream::scatter(ok, Pstream::msgType(), comm);
// version
string versionString(realIsPtr().version().str());
Pstream::scatter(versionString, Pstream::msgType(), comm);
realIsPtr().version(IOstream::versionNumber(versionString));
//- Set stream properties from isPtr on master
// stream
// Scatter master header info
string ver;
string format;
unsigned labelByteSize;
unsigned scalarByteSize;
if (UPstream::master(comm))
{
ver = isPtr().version().str();
OStringStream os;
os << realIsPtr().format();
string formatString(os.str());
Pstream::scatter(formatString, Pstream::msgType(), comm);
realIsPtr().format(formatString);
os << isPtr().format();
format = os.str();
labelByteSize = isPtr().labelByteSize();
scalarByteSize = isPtr().scalarByteSize();
}
Pstream::scatter(ver); //, Pstream::msgType(), comm);
Pstream::scatter(format); //, Pstream::msgType(), comm);
Pstream::scatter(labelByteSize); //, Pstream::msgType(), comm);
Pstream::scatter(scalarByteSize); //, Pstream::msgType(), comm);
realIsPtr().version(IOstream::versionNumber(ver));
realIsPtr().format(format);
realIsPtr().setLabelByteSize(labelByteSize);
realIsPtr().setScalarByteSize(scalarByteSize);
word name(headerIO.name());
Pstream::scatter(name, Pstream::msgType(), comm);
......
......@@ -34,6 +34,7 @@ License
#include "registerSwitch.H"
#include "masterOFstream.H"
#include "OFstream.H"
#include "foamVersion.H"
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
......@@ -217,8 +218,15 @@ bool Foam::fileOperations::collatedFileOperation::appendObject
<< " version " << os.version() << ";\n"
<< " format " << os.format() << ";\n"
<< " class " << decomposedBlockData::typeName
<< ";\n"
<< " location " << pathName << ";\n"
<< ";\n";
// This may be useful to have as well
if (os.format() == IOstream::BINARY)
{
os << " arch " << foamVersion::buildArch << ";\n";
}
os << " location " << pathName << ";\n"
<< " object " << pathName.name() << ";\n"
<< "}" << nl;
IOobject::writeDivider(os) << nl;
......
......@@ -2039,18 +2039,18 @@ Foam::fileOperations::masterUncollatedFileOperation::readStream
else
{
// Scatter master header info
string versionString;
string formatString;
if (isPtr.valid())
{
versionString = isPtr().version().str();
OStringStream os;
os << isPtr().format();
formatString = (os.str());
}
Pstream::scatter(versionString); //, Pstream::msgType(), comm);
Pstream::scatter(formatString); //, Pstream::msgType(), comm);
//string versionString;
//string formatString;
//if (isPtr.valid())
//{
// versionString = isPtr().version().str();
// OStringStream os;
// os << isPtr().format();
// formatString = (os.str());
//}
//
//Pstream::scatter(versionString); //, Pstream::msgType(), comm);
//Pstream::scatter(formatString); //, Pstream::msgType(), comm);
// Get size of file
off_t sz = Foam::fileSize(fName);
......
Markdown is supported
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