Merge branch 'feature-writeObject' into 'develop'

Feature write object

See merge request Development/openfoam!341
This commit is contained in:
Mattijs Janssens
2020-02-19 09:26:35 +00:00
74 changed files with 442 additions and 757 deletions

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -48,8 +49,8 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
IOstream::streamFormat format=IOstream::BINARY; IOstream::streamFormat format = IOstream::BINARY;
// IOstream::streamFormat format=IOstream::ASCII; // IOstream::streamFormat format = IOstream::ASCII;
const label size = 20000000; const label size = 20000000;
@ -84,12 +85,9 @@ int main(int argc, char *argv[])
<< runTime.cpuTimeIncrement() << " s" << nl << endl; << runTime.cpuTimeIncrement() << " s" << nl << endl;
// Write binary
faces2.writeObject faces2.writeObject
( (
format, IOstreamOption(format),
IOstream::currentVersion,
IOstream::UNCOMPRESSED,
true true
); );
@ -147,12 +145,9 @@ int main(int argc, char *argv[])
<< runTime.cpuTimeIncrement() << " s" << nl << endl; << runTime.cpuTimeIncrement() << " s" << nl << endl;
// Write binary
faces2.writeObject faces2.writeObject
( (
format, IOstreamOption(format),
IOstream::currentVersion,
IOstream::UNCOMPRESSED,
true true
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd. Copyright (C) 2017-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -642,10 +642,12 @@ int main(int argc, char *argv[])
if if
( (
!runTime.objectRegistry::writeObject !runTime.objectRegistry::writeObject
(
IOstreamOption
( (
runTime.writeFormat(), runTime.writeFormat(),
IOstream::currentVersion, runTime.writeCompression()
runTime.writeCompression(), ),
true true
) )
) )

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2018 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -157,12 +157,10 @@ bool writeZones
Info<< " Writing " << name << endl; Info<< " Writing " << name << endl;
// Force writing as ascii // Force writing as ASCII
writeOk = meshObject.regIOobject::writeObject writeOk = meshObject.regIOobject::writeObject
( (
IOstream::ASCII, IOstreamOption(IOstream::ASCII, compression),
IOstream::currentVersion,
compression,
true true
); );
} }
@ -470,10 +468,12 @@ int main(int argc, char *argv[])
Cloud<passiveParticle> parcels(meshPtr(), cloudDirs[i], false); Cloud<passiveParticle> parcels(meshPtr(), cloudDirs[i], false);
parcels.writeObject parcels.writeObject
(
IOstreamOption
( (
runTime.writeFormat(), runTime.writeFormat(),
IOstream::currentVersion, runTime.writeCompression()
runTime.writeCompression(), ),
parcels.size() parcels.size()
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -93,14 +93,8 @@ public:
virtual void autoMap(const mapPolyMesh&) virtual void autoMap(const mapPolyMesh&)
{} {}
//- Switch off writing the objects //- Disable writing objects
virtual bool writeObject virtual bool writeObject(IOstreamOption, const bool valid) const
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid
) const
{ {
return true; return true;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -660,9 +660,7 @@ int main(int argc, char *argv[])
Info<< "Writing modified " << fieldName << endl; Info<< "Writing modified " << fieldName << endl;
dictList.writeObject dictList.writeObject
( (
runTime.writeFormat(), IOstreamOption(runTime.writeFormat()),
IOstream::currentVersion,
IOstream::UNCOMPRESSED,
true true
); );
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2017 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -199,9 +199,7 @@ void createFieldFiles
fieldOut.regIOobject::writeObject fieldOut.regIOobject::writeObject
( (
IOstream::ASCII, IOstreamOption(IOstream::ASCII),
IOstream::currentVersion,
IOstream::UNCOMPRESSED,
true true
); );
} }

View File

@ -7,7 +7,7 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2007-2019 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP Copyright (C) 2013-2019 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -95,9 +95,7 @@ int main(int argc, char *argv[])
// Write modified dictionary // Write modified dictionary
optDict.regIOobject::writeObject optDict.regIOobject::writeObject
( (
IOstream::ASCII, IOstreamOption(IOstream::ASCII),
IOstream::currentVersion,
IOstream::UNCOMPRESSED,
true true
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -175,28 +175,26 @@ Foam::CompactIOField<T, BaseType>::CompactIOField
template<class T, class BaseType> template<class T, class BaseType>
bool Foam::CompactIOField<T, BaseType>::writeObject bool Foam::CompactIOField<T, BaseType>::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
if (fmt == IOstream::ASCII) if (streamOpt.format() == IOstream::ASCII)
{ {
// Change type to be non-compact format type // Change type to be non-compact format type
const word oldTypeName(typeName); const word oldTypeName(typeName);
const_cast<word&>(typeName) = IOField<T>::typeName; const_cast<word&>(typeName) = IOField<T>::typeName;
bool good = regIOobject::writeObject(IOstream::ASCII, ver, cmp, valid); bool good = regIOobject::writeObject(streamOpt, valid);
// Change type back // Restore type
const_cast<word&>(typeName) = oldTypeName; const_cast<word&>(typeName) = oldTypeName;
return good; return good;
} }
return regIOobject::writeObject(fmt, ver, cmp, valid); return regIOobject::writeObject(streamOpt, valid);
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -112,11 +113,10 @@ public:
// Member Functions // Member Functions
//- Write using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat, IOstreamOption streamOpt,
IOstream::versionNumber,
IOstream::compressionType,
const bool valid const bool valid
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -168,21 +168,17 @@ Foam::CompactIOList<T, BaseType>::CompactIOList
template<class T, class BaseType> template<class T, class BaseType>
bool Foam::CompactIOList<T, BaseType>::writeObject bool Foam::CompactIOList<T, BaseType>::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
bool nonCompact = false; if
(
if (fmt == IOstream::ASCII) streamOpt.format() == IOstream::BINARY
&& overflows()
)
{ {
nonCompact = true; streamOpt.format(IOstream::ASCII);
}
else if (overflows())
{
nonCompact = true;
WarningInFunction WarningInFunction
<< "Overall number of elements of CompactIOList of size " << "Overall number of elements of CompactIOList of size "
@ -190,14 +186,14 @@ bool Foam::CompactIOList<T, BaseType>::writeObject
<< nl << " Switching to ascii writing" << endl; << nl << " Switching to ascii writing" << endl;
} }
if (nonCompact) if (streamOpt.format() == IOstream::ASCII)
{ {
// Change to non-compact type // Change type to be non-compact format type
const word oldTypeName(typeName); const word oldTypeName(typeName);
const_cast<word&>(typeName) = IOList<T>::typeName; const_cast<word&>(typeName) = IOList<T>::typeName;
bool good = regIOobject::writeObject(IOstream::ASCII, ver, cmp, valid); bool good = regIOobject::writeObject(streamOpt, valid);
// Change type back // Change type back
const_cast<word&>(typeName) = oldTypeName; const_cast<word&>(typeName) = oldTypeName;
@ -205,7 +201,7 @@ bool Foam::CompactIOList<T, BaseType>::writeObject
return good; return good;
} }
return regIOobject::writeObject(fmt, ver, cmp, valid); return regIOobject::writeObject(streamOpt, valid);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -114,11 +114,10 @@ public:
// Member Functions // Member Functions
//- Write using stream options. Checks for overflow in binary
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat, IOstreamOption streamOpt,
IOstream::versionNumber,
IOstream::compressionType,
const bool valid const bool valid
) const; ) const;

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2018 OpenFOAM Foundation Copyright (C) 2017-2018 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -30,7 +31,6 @@ License
#include "IPstream.H" #include "IPstream.H"
#include "PstreamBuffers.H" #include "PstreamBuffers.H"
#include "Fstream.H" #include "Fstream.H"
#include "StringStream.H"
#include "dictionary.H" #include "dictionary.H"
#include "objectRegistry.H" #include "objectRegistry.H"
#include "SubList.H" #include "SubList.H"
@ -160,12 +160,6 @@ Foam::decomposedBlockData::decomposedBlockData
} }
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
Foam::decomposedBlockData::~decomposedBlockData()
{}
// * * * * * * * * * * * * * * * Members Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Members Functions * * * * * * * * * * * * * //
bool Foam::decomposedBlockData::readMasterHeader(IOobject& io, Istream& is) bool Foam::decomposedBlockData::readMasterHeader(IOobject& io, Istream& is)
@ -181,15 +175,11 @@ bool Foam::decomposedBlockData::readMasterHeader(IOobject& io, Istream& is)
List<char> data(is); List<char> data(is);
is.fatalCheck("read(Istream&) : reading entry"); is.fatalCheck("read(Istream&) : reading entry");
IListStream str
(
std::move(data),
IOstream::ASCII,
IOstream::currentVersion,
is.name()
);
return io.readHeader(str); UIListStream headerStream(data);
headerStream.name() = is.name();
return io.readHeader(headerStream);
} }
@ -254,24 +244,15 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlock
is.fatalCheck("read(Istream&)"); is.fatalCheck("read(Istream&)");
List<char> data;
autoPtr<ISstream> realIsPtr; autoPtr<ISstream> realIsPtr;
if (blocki == 0) if (blocki == 0)
{ {
is >> data; List<char> data(is);
is.fatalCheck("read(Istream&) : reading entry"); is.fatalCheck("read(Istream&) : reading entry");
realIsPtr.reset realIsPtr.reset(new IListStream(std::move(data)));
( realIsPtr->name() = is.name();
new IListStream
(
std::move(data),
IOstream::ASCII,
IOstream::currentVersion,
is.name()
)
);
// Read header // Read header
if (!headerIO.readHeader(realIsPtr())) if (!headerIO.readHeader(realIsPtr()))
@ -284,7 +265,7 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlock
else else
{ {
// Read master for header // Read master for header
is >> data; List<char> data(is);
is.fatalCheck("read(Istream&) : reading entry"); is.fatalCheck("read(Istream&) : reading entry");
IOstream::versionNumber ver(IOstream::currentVersion); IOstream::versionNumber ver(IOstream::currentVersion);
@ -292,13 +273,7 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlock
unsigned labelByteSize; unsigned labelByteSize;
unsigned scalarByteSize; unsigned scalarByteSize;
{ {
UIListStream headerStream UIListStream headerStream(data);
(
data,
IOstream::ASCII,
IOstream::currentVersion,
is.name()
);
// Read header // Read header
if (!headerIO.readHeader(headerStream)) if (!headerIO.readHeader(headerStream))
@ -315,20 +290,12 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlock
for (label i = 1; i < blocki+1; i++) for (label i = 1; i < blocki+1; i++)
{ {
// Read data, override old data // Read and discard data, only retain the last one
is >> data; is >> data;
is.fatalCheck("read(Istream&) : reading entry"); is.fatalCheck("read(Istream&) : reading entry");
} }
realIsPtr.reset realIsPtr.reset(new IListStream(std::move(data)));
( realIsPtr->name() = is.name();
new IListStream
(
std::move(data),
IOstream::ASCII,
IOstream::currentVersion,
is.name()
)
);
// Apply master stream settings to realIsPtr // Apply master stream settings to realIsPtr
realIsPtr().format(fmt); realIsPtr().format(fmt);
@ -336,6 +303,7 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlock
realIsPtr().setLabelByteSize(labelByteSize); realIsPtr().setLabelByteSize(labelByteSize);
realIsPtr().setScalarByteSize(scalarByteSize); realIsPtr().setScalarByteSize(scalarByteSize);
} }
return realIsPtr; return realIsPtr;
} }
@ -358,22 +326,6 @@ bool Foam::decomposedBlockData::readBlocks
bool ok = false; 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 (commsType == UPstream::commsTypes::scheduled)
{ {
if (UPstream::master(comm)) if (UPstream::master(comm))
@ -509,17 +461,8 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks
is >> data; is >> data;
is.fatalCheck("read(Istream&) : reading entry"); is.fatalCheck("read(Istream&) : reading entry");
realIsPtr.reset realIsPtr.reset(new IListStream(std::move(data)));
( realIsPtr->name() = fName;
new IListStream
(
std::move(data),
IOstream::ASCII,
IOstream::currentVersion,
fName
)
);
// Read header // Read header
if (!headerIO.readHeader(realIsPtr())) if (!headerIO.readHeader(realIsPtr()))
@ -566,16 +509,8 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks
); );
is >> data; is >> data;
realIsPtr.reset realIsPtr.reset(new IListStream(std::move(data)));
( realIsPtr->name() = fName;
new IListStream
(
std::move(data),
IOstream::ASCII,
IOstream::currentVersion,
fName
)
);
} }
} }
else else
@ -597,16 +532,8 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks
is >> data; is >> data;
is.fatalCheck("read(Istream&) : reading entry"); is.fatalCheck("read(Istream&) : reading entry");
realIsPtr.reset realIsPtr.reset(new IListStream(std::move(data)));
( realIsPtr->name() = fName;
new IListStream
(
std::move(data),
IOstream::ASCII,
IOstream::currentVersion,
fName
)
);
// Read header // Read header
if (!headerIO.readHeader(realIsPtr())) if (!headerIO.readHeader(realIsPtr()))
@ -643,16 +570,8 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks
UIPstream is(UPstream::masterNo(), pBufs); UIPstream is(UPstream::masterNo(), pBufs);
is >> data; is >> data;
realIsPtr.reset realIsPtr.reset(new IListStream(std::move(data)));
( realIsPtr->name() = fName;
new IListStream
(
std::move(data),
IOstream::ASCII,
IOstream::currentVersion,
fName
)
);
} }
} }
@ -661,26 +580,24 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks
//- Set stream properties from realIsPtr on master //- Set stream properties from realIsPtr on master
// Scatter master header info // Scatter master header info
string ver; string versionString;
string format; label formatValue;
unsigned labelByteSize; unsigned labelByteSize;
unsigned scalarByteSize; unsigned scalarByteSize;
if (UPstream::master(comm)) if (UPstream::master(comm))
{ {
ver = realIsPtr().version().str(); versionString = realIsPtr().version().str();
OStringStream os; formatValue = static_cast<label>(realIsPtr().format());
os << realIsPtr().format();
format = os.str();
labelByteSize = realIsPtr().labelByteSize(); labelByteSize = realIsPtr().labelByteSize();
scalarByteSize = realIsPtr().scalarByteSize(); scalarByteSize = realIsPtr().scalarByteSize();
} }
Pstream::scatter(ver); //, Pstream::msgType(), comm); Pstream::scatter(versionString); //, Pstream::msgType(), comm);
Pstream::scatter(format); //, Pstream::msgType(), comm); Pstream::scatter(formatValue); //, Pstream::msgType(), comm);
Pstream::scatter(labelByteSize); //, Pstream::msgType(), comm); Pstream::scatter(labelByteSize); //, Pstream::msgType(), comm);
Pstream::scatter(scalarByteSize); //, Pstream::msgType(), comm); Pstream::scatter(scalarByteSize); //, Pstream::msgType(), comm);
realIsPtr().version(IOstream::versionNumber(ver)); realIsPtr().version(IOstream::versionNumber(versionString));
realIsPtr().format(format); realIsPtr().format(IOstream::streamFormat(formatValue));
realIsPtr().setLabelByteSize(labelByteSize); realIsPtr().setLabelByteSize(labelByteSize);
realIsPtr().setScalarByteSize(scalarByteSize); realIsPtr().setScalarByteSize(scalarByteSize);
@ -1072,30 +989,17 @@ bool Foam::decomposedBlockData::writeData(Ostream& os) const
// Re-read my own data to find out the header information // Re-read my own data to find out the header information
if (Pstream::master(comm_)) if (Pstream::master(comm_))
{ {
UIListStream is UIListStream headerStream(data);
( io.readHeader(headerStream);
data,
IOstream::ASCII,
IOstream::currentVersion,
name()
);
io.readHeader(is);
} }
// Scatter header information // Scatter header information
// version
string versionString(os.version().str()); string versionString(os.version().str());
Pstream::scatter(versionString, Pstream::msgType(), comm_); Pstream::scatter(versionString, Pstream::msgType(), comm_);
// stream label formatValue(os.format());
string formatString; Pstream::scatter(formatValue, Pstream::msgType(), comm_);
{
OStringStream os;
os << os.format();
formatString = os.str();
Pstream::scatter(formatString, Pstream::msgType(), comm_);
}
//word masterName(name()); //word masterName(name());
//Pstream::scatter(masterName, Pstream::msgType(), comm_); //Pstream::scatter(masterName, Pstream::msgType(), comm_);
@ -1114,7 +1018,7 @@ bool Foam::decomposedBlockData::writeData(Ostream& os) const
( (
os, os,
IOstream::versionNumber(versionString), IOstream::versionNumber(versionString),
IOstream::formatEnum(formatString), IOstream::streamFormat(formatValue),
io.headerClassName(), io.headerClassName(),
io.note(), io.note(),
masterLocation, masterLocation,
@ -1122,12 +1026,18 @@ bool Foam::decomposedBlockData::writeData(Ostream& os) const
); );
} }
string str // Write the character data
( if (isA<OFstream>(os))
reinterpret_cast<const char*>(data.cbegin()), {
data.byteSize() // Serial file output - can use writeRaw()
); os.writeRaw(data.cdata(), data.byteSize());
}
else
{
// Other cases are less fortunate, and no std::string_view
std::string str(data.cdata(), data.byteSize());
os.writeQuoted(str, false); os.writeQuoted(str, false);
}
if (!Pstream::master(comm_)) if (!Pstream::master(comm_))
{ {
@ -1140,18 +1050,19 @@ bool Foam::decomposedBlockData::writeData(Ostream& os) const
bool Foam::decomposedBlockData::writeObject bool Foam::decomposedBlockData::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
// Always write BINARY
streamOpt.format(IOstream::BINARY);
autoPtr<OSstream> osPtr; autoPtr<OSstream> osPtr;
if (UPstream::master(comm_)) if (UPstream::master(comm_))
{ {
// Note: always write binary. These are strings so readable // Note: always write binary. These are strings so readable anyway.
// anyway. They have already be tokenised on the sending side. // They have already be tokenised on the sending side.
osPtr.reset(new OFstream(objectPath(), IOstream::BINARY, ver, cmp)); osPtr.reset(new OFstream(objectPath(), streamOpt));
IOobject::writeHeader(osPtr()); IOobject::writeHeader(osPtr());
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2018 OpenFOAM Foundation Copyright (C) 2017-2018 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -57,7 +58,7 @@ class decomposedBlockData
{ {
protected: protected:
// Protected data // Protected Data
//- Type to use for gather //- Type to use for gather
const UPstream::commsTypes commsType_; const UPstream::commsTypes commsType_;
@ -90,6 +91,7 @@ protected:
public: public:
//- Declare type-name, virtual type (with debug switch)
TypeName("decomposedBlockData"); TypeName("decomposedBlockData");
@ -123,7 +125,7 @@ public:
//- Destructor //- Destructor
virtual ~decomposedBlockData(); virtual ~decomposedBlockData() = default;
// Member functions // Member functions
@ -133,14 +135,12 @@ public:
//- Write separated content. Assumes content is the serialised data //- Write separated content. Assumes content is the serialised data
// and that the master data contains a header // and that the master data contains a header
virtual bool writeData(Ostream&) const; virtual bool writeData(Ostream& os) const;
//- Write using given format, version and compression //- Write using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat, IOstreamOption streamOpt,
IOstream::versionNumber,
IOstream::compressionType,
const bool valid const bool valid
) const; ) const;
@ -226,7 +226,7 @@ public:
); );
//- Detect number of blocks in a file //- Detect number of blocks in a file
static label numBlocks(const fileName&); static label numBlocks(const fileName& fName);
}; };

View File

@ -392,12 +392,10 @@ public:
//- Write time dictionary to the \<time\>/uniform directory //- Write time dictionary to the \<time\>/uniform directory
virtual bool writeTimeDict() const; virtual bool writeTimeDict() const;
//- Write using given format, version and compression //- Write using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat, IOstreamOption streamOpt,
IOstream::versionNumber,
IOstream::compressionType,
const bool valid const bool valid
) const; ) const;

View File

@ -524,9 +524,7 @@ bool Foam::Time::writeTimeDict() const
return timeDict.regIOobject::writeObject return timeDict.regIOobject::writeObject
( (
IOstream::ASCII, IOstreamOption(IOstream::ASCII),
IOstream::currentVersion,
IOstream::UNCOMPRESSED,
true true
); );
} }
@ -534,9 +532,7 @@ bool Foam::Time::writeTimeDict() const
bool Foam::Time::writeObject bool Foam::Time::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
@ -546,7 +542,7 @@ bool Foam::Time::writeObject
if (writeOK) if (writeOK)
{ {
writeOK = objectRegistry::writeObject(fmt, ver, cmp, valid); writeOK = objectRegistry::writeObject(streamOpt, valid);
} }
if (writeOK) if (writeOK)

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -625,9 +625,7 @@ bool Foam::functionObjectList::execute()
stateDictPtr_->writeObject stateDictPtr_->writeObject
( (
IOstream::ASCII, IOstreamOption(IOstream::ASCII, time_.writeCompression()),
IOstream::currentVersion,
time_.writeCompression(),
true true
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -473,9 +473,7 @@ bool Foam::objectRegistry::readIfModified()
bool Foam::objectRegistry::writeObject bool Foam::objectRegistry::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
@ -496,7 +494,7 @@ bool Foam::objectRegistry::writeObject
if ((*iter)->writeOpt() != NO_WRITE) if ((*iter)->writeOpt() != NO_WRITE)
{ {
ok = (*iter)->writeObject(fmt, ver, cmp, valid) && ok; ok = (*iter)->writeObject(streamOpt, valid) && ok;
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -524,12 +524,10 @@ public:
return false; return false;
} }
//- Write the objects //- Write the objects using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const; ) const;

View File

@ -43,6 +43,7 @@ SourceFiles
#include "IOobject.H" #include "IOobject.H"
#include "typeInfo.H" #include "typeInfo.H"
#include "stdFoam.H"
#include "OSspecific.H" #include "OSspecific.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -319,12 +320,10 @@ public:
// Must be defined in derived types // Must be defined in derived types
virtual bool writeData(Ostream&) const = 0; virtual bool writeData(Ostream&) const = 0;
//- Write using given format, version and compression //- Write using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat, IOstreamOption streamOpt,
IOstream::versionNumber,
IOstream::compressionType,
const bool valid const bool valid
) const; ) const;
@ -345,6 +344,19 @@ public:
//- Copy assignment //- Copy assignment
void operator=(const IOobject& io); void operator=(const IOobject& io);
// Housekeeping
//- Write using given format, version and compression
FOAM_DEPRECATED_FOR(2020-02, "writeObject(IOstreamOption, bool)")
virtual bool writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType comp,
const bool valid
) const;
}; };

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -23,9 +24,6 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
write function for regIOobjects
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "regIOobject.H" #include "regIOobject.H"
@ -37,9 +35,7 @@ Description
bool Foam::regIOobject::writeObject bool Foam::regIOobject::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
@ -62,7 +58,6 @@ bool Foam::regIOobject::writeObject
} }
//- uncomment this if you want to write global objects on master only //- uncomment this if you want to write global objects on master only
//bool isGlobal = global(); //bool isGlobal = global();
bool isGlobal = false; bool isGlobal = false;
@ -119,7 +114,7 @@ bool Foam::regIOobject::writeObject
//if (mkDir(path())) //if (mkDir(path()))
//{ //{
// // Try opening an OFstream for object // // Try opening an OFstream for object
// OFstream os(objectPath(), fmt, ver, cmp); // OFstream os(objectPath(), streamOpt);
// //
// // If any of these fail, return (leave error handling to Ostream // // If any of these fail, return (leave error handling to Ostream
// // class) // // class)
@ -143,7 +138,7 @@ bool Foam::regIOobject::writeObject
// //
// osGood = os.good(); // osGood = os.good();
//} //}
osGood = fileHandler().writeObject(*this, fmt, ver, cmp, valid); osGood = fileHandler().writeObject(*this, streamOpt, valid);
} }
else else
{ {
@ -171,12 +166,22 @@ bool Foam::regIOobject::write(const bool valid) const
{ {
return writeObject return writeObject
( (
time().writeFormat(), IOstreamOption(time().writeFormat(), time().writeCompression()),
IOstream::currentVersion,
time().writeCompression(),
valid valid
); );
} }
bool Foam::regIOobject::writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid
) const
{
return writeObject(IOstreamOption(fmt, ver, cmp), valid);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -118,9 +118,7 @@ bool Foam::fileOperations::collatedFileOperation::appendObject
( (
const regIOobject& io, const regIOobject& io,
const fileName& pathName, const fileName& pathName,
IOstream::streamFormat fmt, IOstreamOption streamOpt
IOstream::versionNumber ver,
IOstream::compressionType cmp
) const ) const
{ {
// Append to processors/ file // Append to processors/ file
@ -169,7 +167,7 @@ bool Foam::fileOperations::collatedFileOperation::appendObject
// Create string from all data to write // Create string from all data to write
string buf; string buf;
{ {
OStringStream os(fmt, ver); OStringStream os(streamOpt.format(), streamOpt.version());
if (isMaster) if (isMaster)
{ {
if (!io.writeHeader(os)) if (!io.writeHeader(os))
@ -199,7 +197,7 @@ bool Foam::fileOperations::collatedFileOperation::appendObject
OFstream os OFstream os
( (
pathName, pathName,
IOstreamOption(IOstream::BINARY, ver), // UNCOMPRESSED IOstreamOption(IOstream::BINARY, streamOpt.version()), // UNCOMPRESSED
!isMaster // append slaves !isMaster // append slaves
); );
@ -461,9 +459,7 @@ Foam::fileName Foam::fileOperations::collatedFileOperation::objectPath
bool Foam::fileOperations::collatedFileOperation::writeObject bool Foam::fileOperations::collatedFileOperation::writeObject
( (
const regIOobject& io, const regIOobject& io,
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
@ -486,7 +482,7 @@ bool Foam::fileOperations::collatedFileOperation::writeObject
masterOFstream os masterOFstream os
( (
pathName, pathName,
IOstreamOption(fmt, ver, cmp), streamOpt,
false, // append=false false, // append=false
valid valid
); );
@ -530,7 +526,7 @@ bool Foam::fileOperations::collatedFileOperation::writeObject
masterOFstream os masterOFstream os
( (
pathName, pathName,
IOstreamOption(fmt, ver, cmp), streamOpt,
false, // append=false false, // append=false
valid valid
); );
@ -565,7 +561,7 @@ bool Foam::fileOperations::collatedFileOperation::writeObject
<< " appending to " << pathName << endl; << " appending to " << pathName << endl;
} }
return appendObject(io, pathName, fmt, ver, cmp); return appendObject(io, pathName, streamOpt);
} }
else else
{ {
@ -590,7 +586,7 @@ bool Foam::fileOperations::collatedFileOperation::writeObject
( (
writer_, writer_,
pathName, pathName,
IOstreamOption(fmt, ver, cmp), streamOpt,
useThread useThread
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -95,9 +95,7 @@ protected:
( (
const regIOobject& io, const regIOobject& io,
const fileName& pathName, const fileName& pathName,
IOstream::streamFormat fmt, IOstreamOption streamOpt
IOstream::versionNumber ver,
IOstream::compressionType cmp
) const; ) const;
@ -150,9 +148,7 @@ public:
virtual bool writeObject virtual bool writeObject
( (
const regIOobject&, const regIOobject&,
IOstream::streamFormat format=IOstream::ASCII, IOstreamOption streamOpt = IOstreamOption(),
IOstream::versionNumber version=IOstream::currentVersion,
IOstream::compressionType compression=IOstream::UNCOMPRESSED,
const bool valid = true const bool valid = true
) const; ) const;

View File

@ -464,9 +464,7 @@ Foam::fileName Foam::fileOperation::objectPath
bool Foam::fileOperation::writeObject bool Foam::fileOperation::writeObject
( (
const regIOobject& io, const regIOobject& io,
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType comp,
const bool valid const bool valid
) const ) const
{ {
@ -476,10 +474,7 @@ bool Foam::fileOperation::writeObject
mkDir(pathName.path()); mkDir(pathName.path());
autoPtr<OSstream> osPtr autoPtr<OSstream> osPtr(NewOFstream(pathName, streamOpt));
(
NewOFstream(pathName, IOstreamOption(fmt, ver, comp))
);
if (!osPtr) if (!osPtr)
{ {

View File

@ -410,9 +410,7 @@ public:
virtual bool writeObject virtual bool writeObject
( (
const regIOobject& io, const regIOobject& io,
IOstream::streamFormat fmt = IOstream::ASCII, IOstreamOption streamOpt = IOstreamOption(),
IOstream::versionNumber ver = IOstream::currentVersion,
IOstream::compressionType comp = IOstream::UNCOMPRESSED,
const bool valid = true const bool valid = true
) const; ) const;

View File

@ -494,93 +494,71 @@ bool Foam::fileOperations::masterUncollatedFileOperation::uniformFile
void Foam::fileOperations::masterUncollatedFileOperation::readAndSend void Foam::fileOperations::masterUncollatedFileOperation::readAndSend
( (
const fileName& filePath, const fileName& filePath,
const IOstream::compressionType cmp,
const labelUList& procs, const labelUList& procs,
PstreamBuffers& pBufs PstreamBuffers& pBufs
) )
{ {
if (cmp == IOstream::compressionType::COMPRESSED) IFstream ifs(filePath, IOstream::streamFormat::BINARY);
if (!ifs.good())
{ {
FatalIOErrorInFunction(filePath)
<< "Cannot open file " << filePath
<< exit(FatalIOError);
}
if (debug) if (debug)
{ {
Pout<< "masterUncollatedFileOperation::readAndSend :" Pout<< "masterUncollatedFileOperation::readAndSend :"
<< " Opening compressed " << filePath << endl; << " compressed:" << bool(ifs.compression()) << " "
<< filePath << endl;
} }
IFstream is(filePath, IOstream::streamFormat::BINARY); if (ifs.compression() == IOstream::compressionType::COMPRESSED)
if (!is.good())
{ {
FatalIOErrorInFunction(filePath) << "Cannot open file " << filePath // Could use Foam::fileSize, estimate uncompressed size (eg, 2x)
<< exit(FatalIOError); // and then string reserve followed by string assign...
}
std::ostringstream stringStr; // Uncompress and read file contents into a character buffer
stringStr << is.stdStream().rdbuf(); const std::string buf
string buf(stringStr.str()); (
std::istreambuf_iterator<char>(ifs.stdStream()),
std::istreambuf_iterator<char>()
);
forAll(procs, i) for (const label proci : procs)
{ {
UOPstream os(procs[i], pBufs); UOPstream os(proci, pBufs);
os.write(&buf[0], buf.size()); os.write(buf.data(), buf.length());
} }
}
else
{
off_t count(Foam::fileSize(filePath));
IFstream is(filePath, IOstream::streamFormat::BINARY);
if (!is.good())
{
FatalIOErrorInFunction(filePath) << "Cannot open file " << filePath
<< exit(FatalIOError);
}
if (debug) if (debug)
{ {
Pout<< "masterUncollatedFileOperation::readStream :" Pout<< "masterUncollatedFileOperation::readStream :"
<< " From " << filePath << " reading " << label(count) << " From " << filePath << " sent " << buf.size()
<< " bytes" << endl; << " bytes" << endl;
} }
List<char> buf(static_cast<label>(count));
is.stdStream().read(buf.begin(), count);
forAll(procs, i)
{
UOPstream os(procs[i], pBufs);
os.write(buf.begin(), count);
}
}
}
void Foam::fileOperations::masterUncollatedFileOperation::readAndSend
(
const fileName& fName,
const labelUList& procs,
PstreamBuffers& pBufs
)
{
if (Foam::exists(fName+".gz", false))
{
readAndSend
(
fName,
IOstream::compressionType::COMPRESSED,
procs,
pBufs
);
} }
else else
{ {
readAndSend const off_t count(Foam::fileSize(filePath));
(
fName, // Read file contents into a character buffer
IOstream::compressionType::UNCOMPRESSED, List<char> buf(static_cast<label>(count));
procs, ifs.stdStream().read(buf.data(), count);
pBufs
); for (const label proci : procs)
{
UOPstream os(proci, pBufs);
os.write(buf.cdata(), count);
}
if (debug)
{
Pout<< "masterUncollatedFileOperation::readStream :"
<< " From " << filePath << " sent " << buf.size()
<< " bytes" << endl;
}
} }
} }
@ -656,18 +634,16 @@ Foam::fileOperations::masterUncollatedFileOperation::read
<< exit(FatalIOError); << exit(FatalIOError);
} }
autoPtr<IFstream> ifsPtr(new IFstream(filePaths[0])); // Open master
isPtr.reset(new IFstream(filePaths[0]));
// Read header // Read header
if (!io.readHeader(ifsPtr())) if (!io.readHeader(isPtr()))
{ {
FatalIOErrorInFunction(ifsPtr()) FatalIOErrorInFunction(isPtr())
<< "problem while reading header for object " << "problem while reading header for object "
<< io.name() << exit(FatalIOError); << io.name() << exit(FatalIOError);
} }
// Open master (steal from ifsPtr)
isPtr.reset(ifsPtr.ptr());
} }
// Read slave files // Read slave files
@ -715,7 +691,7 @@ Foam::fileOperations::masterUncollatedFileOperation::read
List<char> buf(recvSizes[Pstream::masterNo()]); List<char> buf(recvSizes[Pstream::masterNo()]);
if (recvSizes[Pstream::masterNo()] > 0) if (recvSizes[Pstream::masterNo()] > 0)
{ {
is.read(buf.begin(), recvSizes[Pstream::masterNo()]); is.read(buf.data(), recvSizes[Pstream::masterNo()]);
} }
if (debug) if (debug)
@ -723,17 +699,15 @@ Foam::fileOperations::masterUncollatedFileOperation::read
Pout<< "masterUncollatedFileOperation::readStream :" Pout<< "masterUncollatedFileOperation::readStream :"
<< " Done reading " << buf.size() << " bytes" << endl; << " Done reading " << buf.size() << " bytes" << endl;
} }
const fileName& fName = filePaths[Pstream::myProcNo(comm)];
isPtr.reset // A local character buffer copy of the Pstream contents.
( // Construct with same parameters (ASCII, current version)
new IListStream // as the IFstream so that it has the same characteristics.
(
std::move(buf), isPtr.reset(new IListStream(std::move(buf)));
IOstream::BINARY,
IOstream::currentVersion, // With the proper file name
fName isPtr->name() = filePaths[Pstream::myProcNo(comm)];
)
);
if (!io.readHeader(isPtr())) if (!io.readHeader(isPtr()))
{ {
@ -1424,6 +1398,7 @@ Foam::fileName Foam::fileOperations::masterUncollatedFileOperation::dirPath
{ {
// Retest all processors separately since some processors might // Retest all processors separately since some processors might
// have the file and some not (e.g. lagrangian data) // have the file and some not (e.g. lagrangian data)
objPath = masterOp<fileName, fileOrNullOp> objPath = masterOp<fileName, fileOrNullOp>
( (
io.objectPath(), io.objectPath(),
@ -1721,7 +1696,7 @@ Foam::fileOperations::masterUncollatedFileOperation::readObjects
{ {
// Avoid fileOperation::readObjects from triggering parallel ops // Avoid fileOperation::readObjects from triggering parallel ops
// (through call to filePath which triggers parallel ) // (through call to filePath which triggers parallel )
bool oldParRun = UPstream::parRun(); const bool oldParRun = UPstream::parRun();
UPstream::parRun() = false; UPstream::parRun() = false;
//- Use non-time searching version //- Use non-time searching version
@ -1872,8 +1847,8 @@ bool Foam::fileOperations::masterUncollatedFileOperation::readHeader
== decomposedBlockData::typeName == decomposedBlockData::typeName
) )
{ {
// Read the header inside the container (master // Read the header inside the container
// data) // (master data)
result[proci] = decomposedBlockData:: result[proci] = decomposedBlockData::
readMasterHeader readMasterHeader
( (
@ -2003,7 +1978,6 @@ Foam::fileOperations::masterUncollatedFileOperation::readStream
); );
List<char> data;
if (!Pstream::parRun()) if (!Pstream::parRun())
{ {
// Analyse the objectpath to find out the processor we're trying // Analyse the objectpath to find out the processor we're trying
@ -2038,20 +2012,6 @@ Foam::fileOperations::masterUncollatedFileOperation::readStream
} }
else 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);
// Get size of file // Get size of file
off_t sz = Foam::fileSize(fName); off_t sz = Foam::fileSize(fName);
bool bigSize = sz > off_t(maxMasterFileBufferSize); bool bigSize = sz > off_t(maxMasterFileBufferSize);
@ -2131,7 +2091,7 @@ Foam::fileOperations::masterUncollatedFileOperation::readStream
Pstream::gatherList(procValid, Pstream::msgType(), comm_); Pstream::gatherList(procValid, Pstream::msgType(), comm_);
// Uniform in local comm // Uniform in local comm
bool uniform = uniformFile(filePaths); const bool uniform = uniformFile(filePaths);
return read(io, comm_, uniform, filePaths, procValid); return read(io, comm_, uniform, filePaths, procValid);
} }
@ -2161,7 +2121,7 @@ bool Foam::fileOperations::masterUncollatedFileOperation::read
if (Pstream::master()) // comm_)) if (Pstream::master()) // comm_))
{ {
// Do master-only reading always. // Do master-only reading always.
bool oldParRun = UPstream::parRun(); const bool oldParRun = UPstream::parRun();
UPstream::parRun() = false; UPstream::parRun() = false;
ok = io.readData(io.readStream(typeName)); ok = io.readData(io.readStream(typeName));
@ -2244,9 +2204,7 @@ bool Foam::fileOperations::masterUncollatedFileOperation::read
bool Foam::fileOperations::masterUncollatedFileOperation::writeObject bool Foam::fileOperations::masterUncollatedFileOperation::writeObject
( (
const regIOobject& io, const regIOobject& io,
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType comp,
const bool valid const bool valid
) const ) const
{ {
@ -2261,15 +2219,7 @@ bool Foam::fileOperations::masterUncollatedFileOperation::writeObject
// Make sure to pick up any new times // Make sure to pick up any new times
setTime(io.time()); setTime(io.time());
autoPtr<OSstream> osPtr autoPtr<OSstream> osPtr(NewOFstream(pathName, streamOpt, valid));
(
NewOFstream
(
pathName,
IOstreamOption(fmt, ver, comp),
valid
)
);
OSstream& os = osPtr(); OSstream& os = osPtr();
// If any of these fail, return (leave error handling to Ostream class) // If any of these fail, return (leave error handling to Ostream class)
@ -2317,7 +2267,7 @@ Foam::instantList Foam::fileOperations::masterUncollatedFileOperation::findTimes
if (Pstream::master()) // comm_)) if (Pstream::master()) // comm_))
{ {
// Do master-only reading always. // Do master-only reading always.
bool oldParRun = UPstream::parRun(); const bool oldParRun = UPstream::parRun();
UPstream::parRun() = false; UPstream::parRun() = false;
times = fileOperation::findTimes(directory, constantName); times = fileOperation::findTimes(directory, constantName);
UPstream::parRun() = oldParRun; UPstream::parRun() = oldParRun;
@ -2353,6 +2303,8 @@ void Foam::fileOperations::masterUncollatedFileOperation::setTime
} }
// Mutable access to instantList for modification and sorting // Mutable access to instantList for modification and sorting
// - cannot use auto type deduction here
HashPtrTable<instantList>::iterator iter = times_.find(tm.path()); HashPtrTable<instantList>::iterator iter = times_.find(tm.path());
if (iter.found()) if (iter.found())
@ -2361,15 +2313,19 @@ void Foam::fileOperations::masterUncollatedFileOperation::setTime
const instant timeNow(tm.value(), tm.timeName()); const instant timeNow(tm.value(), tm.timeName());
if (times.size() > 0 && times[0].name() == tm.constant()) // Exclude constant when checking and sorting
{ const label skipConst =
// Exclude constant (
SubList<instant> realTimes(times, times.size()-1, 1); (!times.empty() && times[0].name() == tm.constant())
? 1
: 0
);
if if
( (
findSortedIndex findSortedIndex
( (
SubList<instant>(times, times.size()-1, 1), SubList<instant>(times, times.size()-skipConst, skipConst),
timeNow timeNow
) )
== -1 == -1
@ -2383,26 +2339,14 @@ void Foam::fileOperations::masterUncollatedFileOperation::setTime
} }
times.append(timeNow); times.append(timeNow);
SubList<instant> realTimes(times, times.size()-1, 1); SubList<instant> realTimes
(
times, times.size()-skipConst, skipConst
);
Foam::stableSort(realTimes); Foam::stableSort(realTimes);
} }
} }
else
{
if (findSortedIndex(times, timeNow) == -1)
{
if (debug)
{
Pout<< "masterUncollatedFileOperation::setTime :"
<< " Caching time " << tm.timeName()
<< " for case:" << tm.path() << endl;
}
times.append(timeNow);
Foam::stableSort(times);
}
}
}
fileOperation::setTime(tm); fileOperation::setTime(tm);
} }
@ -2413,6 +2357,8 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream
const fileName& filePath const fileName& filePath
) const ) const
{ {
autoPtr<ISstream> isPtr;
if (Pstream::parRun()) if (Pstream::parRun())
{ {
// Insert logic of filePath. We assume that if a file is absolute // Insert logic of filePath. We assume that if a file is absolute
@ -2441,25 +2387,12 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream
<< " Opening global file " << filePath << endl; << " Opening global file " << filePath << endl;
} }
IOstream::compressionType cmp readAndSend
( (
Foam::exists(filePath+".gz", false) filePath,
? IOstream::compressionType::COMPRESSED identity(Pstream::nProcs(Pstream::worldComm)-1, 1),
: IOstream::compressionType::UNCOMPRESSED pBufs
); );
labelList procs(Pstream::nProcs(Pstream::worldComm)-1);
for
(
label proci = 1;
proci < Pstream::nProcs(Pstream::worldComm);
proci++
)
{
procs[proci-1] = proci;
}
readAndSend(filePath, cmp, procs, pBufs);
} }
else else
{ {
@ -2470,17 +2403,9 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream
proci++ proci++
) )
{ {
IOstream::compressionType cmp
(
Foam::exists(filePaths[proci]+".gz", false)
? IOstream::compressionType::COMPRESSED
: IOstream::compressionType::UNCOMPRESSED
);
readAndSend readAndSend
( (
filePaths[proci], filePaths[proci],
cmp,
labelList(1, proci), labelList(1, proci),
pBufs pBufs
); );
@ -2495,10 +2420,7 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream
if (Pstream::master(Pstream::worldComm)) if (Pstream::master(Pstream::worldComm))
{ {
// Read myself // Read myself
return autoPtr<ISstream> isPtr.reset(new IFstream(filePaths[Pstream::masterNo()]));
(
new IFstream(filePaths[Pstream::masterNo()])
);
} }
else else
{ {
@ -2512,7 +2434,7 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream
UIPstream is(Pstream::masterNo(), pBufs); UIPstream is(Pstream::masterNo(), pBufs);
List<char> buf(recvSizes[Pstream::masterNo()]); List<char> buf(recvSizes[Pstream::masterNo()]);
is.read(buf.begin(), buf.size()); is.read(buf.data(), buf.size());
if (debug) if (debug)
{ {
@ -2520,26 +2442,23 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream
<< " Done reading " << buf.size() << " bytes" << endl; << " Done reading " << buf.size() << " bytes" << endl;
} }
// Note: IPstream is not an IStream so use a IStringStream to // A local character buffer copy of the Pstream contents.
// convert the buffer. Note that we construct with a string // Construct with same parameters (ASCII, current version)
// so it holds a copy of the buffer. // as the IFstream so that it has the same characteristics.
return autoPtr<ISstream>
( isPtr.reset(new IListStream(std::move(buf)));
new IListStream
( // With the proper file name
std::move(buf), isPtr->name() = filePath;
IOstream::BINARY,
IOstream::currentVersion,
filePath
)
);
} }
} }
else else
{ {
// Read myself // Read myself
return autoPtr<ISstream>(new IFstream(filePath)); isPtr.reset(new IFstream(filePath));
} }
return isPtr;
} }

View File

@ -448,20 +448,11 @@ protected:
const word& instancePath const word& instancePath
) const; ) const;
//- Read file contents and send to processors //- Read file contents and send to processors.
// Handles compressed or uncompressed files
static void readAndSend static void readAndSend
( (
const fileName& filePath, const fileName& filePath,
const IOstream::compressionType cmp,
const labelUList& procs,
PstreamBuffers& pBufs
);
//- Detect file (possibly compressed), read file contents and send
// to processors
static void readAndSend
(
const fileName& fName,
const labelUList& procs, const labelUList& procs,
PstreamBuffers& pBufs PstreamBuffers& pBufs
); );
@ -697,9 +688,7 @@ public:
virtual bool writeObject virtual bool writeObject
( (
const regIOobject& io, const regIOobject& io,
IOstream::streamFormat format=IOstream::ASCII, IOstreamOption streamOpt = IOstreamOption(),
IOstream::versionNumber version=IOstream::currentVersion,
IOstream::compressionType compression=IOstream::UNCOMPRESSED,
const bool valid = true const bool valid = true
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2009-2016 Bernhard Gschaider Copyright (C) 2009-2016 Bernhard Gschaider
Copyright (C) 2016-2018 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -393,19 +393,11 @@ bool Foam::profiling::writeData(Ostream& os) const
bool Foam::profiling::writeObject bool Foam::profiling::writeObject
( (
IOstream::streamFormat, IOstreamOption,
IOstream::versionNumber ver,
IOstream::compressionType,
const bool valid const bool valid
) const ) const
{ {
return regIOobject::writeObject return regIOobject::writeObject(IOstreamOption(IOstream::ASCII), true);
(
IOstream::ASCII,
ver,
IOstream::UNCOMPRESSED,
true
);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2009-2016 Bernhard Gschaider Copyright (C) 2009-2016 Bernhard Gschaider
Copyright (C) 2016-2018 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -247,12 +247,10 @@ public:
//- writeData member function required by regIOobject //- writeData member function required by regIOobject
virtual bool writeData(Ostream& os) const; virtual bool writeData(Ostream& os) const;
//- Write as uncompressed ASCII, using given format //- Write as uncompressed ASCII
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat ignoreAlwaysASCII, IOstreamOption /*ignore*/,
IOstream::versionNumber ver,
IOstream::compressionType ignoreAlwaysUncompressed,
const bool valid const bool valid
) const; ) const;
}; };

View File

@ -234,9 +234,7 @@ void Foam::uniformInterpolationTable<Type>::write() const
dict.regIOobject::writeObject dict.regIOobject::writeObject
( (
IOstream::ASCII, IOstreamOption(IOstream::ASCII, dict.time().writeCompression()),
IOstream::currentVersion,
dict.time().writeCompression(),
true true
); );
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -1234,13 +1234,12 @@ bool Foam::polyBoundaryMesh::writeData(Ostream& os) const
bool Foam::polyBoundaryMesh::writeObject bool Foam::polyBoundaryMesh::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
return regIOobject::writeObject(fmt, ver, IOstream::UNCOMPRESSED, valid); streamOpt.compression(IOstream::UNCOMPRESSED);
return regIOobject::writeObject(streamOpt, valid);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -270,12 +270,10 @@ public:
//- writeData member function required by regIOobject //- writeData member function required by regIOobject
virtual bool writeData(Ostream& os) const; virtual bool writeData(Ostream& os) const;
//- Write using given format, version, compression //- Write using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const; ) const;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -587,9 +587,7 @@ void Foam::ccm::reader::writeMesh
Info<< "Writing polyMesh" << endl; Info<< "Writing polyMesh" << endl;
mesh.writeObject mesh.writeObject
( (
fmt, IOstreamOption(fmt),
IOstream::currentVersion,
IOstream::UNCOMPRESSED,
true true
); );
writeAux(mesh); writeAux(mesh);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -174,9 +174,7 @@ void Foam::ccm::reader::writeMeshLabelList
// //
ioObj.writeObject ioObj.writeObject
( (
fmt, IOstreamOption(fmt),
IOstream::currentVersion,
IOstream::UNCOMPRESSED,
true true
); );
} }

View File

@ -133,9 +133,7 @@ void Foam::meshReader::writeMesh
Info<< "Writing polyMesh" << endl; Info<< "Writing polyMesh" << endl;
mesh.writeObject mesh.writeObject
( (
fmt, IOstreamOption(fmt),
IOstream::currentVersion,
IOstream::UNCOMPRESSED,
true true
); );
writeAux(mesh); writeAux(mesh);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -135,14 +135,8 @@ void Foam::meshReader::writeMeshLabelList
// NOTE: // NOTE:
// the cellTableId is an integer and almost always < 1000, thus ASCII // the cellTableId is an integer and almost always < 1000, thus ASCII
// will be compacter than binary and makes external scripting easier // will be compacter than binary and makes external scripting easier
//
ioObj.writeObject ioObj.writeObject(IOstreamOption(fmt), true);
(
fmt,
IOstream::currentVersion,
IOstream::UNCOMPRESSED,
true
);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -1387,9 +1387,7 @@ bool Foam::dynamicRefineFvMesh::update()
bool Foam::dynamicRefineFvMesh::writeObject bool Foam::dynamicRefineFvMesh::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
@ -1398,7 +1396,7 @@ bool Foam::dynamicRefineFvMesh::writeObject
bool writeOk = bool writeOk =
( (
dynamicFvMesh::writeObject(fmt, ver, cmp, valid) dynamicFvMesh::writeObject(streamOpt, valid)
&& meshCutter_.write(valid) && meshCutter_.write(valid)
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd. Copyright (C) 2017-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -264,12 +264,10 @@ public:
// Writing // Writing
//- Write using given format, version and compression //- Write using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const; ) const;
}; };

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -222,9 +222,7 @@ void Foam::motionSolver::updateMesh(const mapPolyMesh& mpm)
bool Foam::motionSolver::writeObject bool Foam::motionSolver::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -170,12 +170,10 @@ public:
//- Update local data for topology changes //- Update local data for topology changes
virtual void updateMesh(const mapPolyMesh&) = 0; virtual void updateMesh(const mapPolyMesh&) = 0;
//- Write state using given format, version and compression //- Write state using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -912,9 +912,7 @@ void Foam::fvMesh::updateMesh(const mapPolyMesh& mpm)
bool Foam::fvMesh::writeObject bool Foam::fvMesh::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
@ -932,7 +930,7 @@ bool Foam::fvMesh::writeObject
ok = V0Ptr_->write(valid); ok = V0Ptr_->write(valid);
} }
return ok && polyMesh::writeObject(fmt, ver, cmp, valid); return ok && polyMesh::writeObject(streamOpt, valid);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -455,9 +455,7 @@ public:
//- Write the underlying polyMesh and other data //- Write the underlying polyMesh and other data
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -247,13 +247,11 @@ public:
// this level. // this level.
virtual void writeFields() const; virtual void writeFields() const;
//- Write using given format, version and compression. //- Write using stream options.
// Only writes the cloud file if the Cloud isn't empty // Only writes the cloud file if the Cloud isn't empty
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -121,9 +121,7 @@ void Foam::Cloud<ParticleType>::writeCloudUniformProperties() const
uniformPropsDict.writeObject uniformPropsDict.writeObject
( (
IOstream::ASCII, IOstreamOption(IOstream::ASCII, time().writeCompression()),
IOstream::currentVersion,
time().writeCompression(),
true true
); );
} }
@ -252,16 +250,14 @@ void Foam::Cloud<ParticleType>::writeFields() const
template<class ParticleType> template<class ParticleType>
bool Foam::Cloud<ParticleType>::writeObject bool Foam::Cloud<ParticleType>::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool const bool
) const ) const
{ {
writeCloudUniformProperties(); writeCloudUniformProperties();
writeFields(); writeFields();
return cloud::writeObject(fmt, ver, cmp, this->size()); return cloud::writeObject(streamOpt, this->size());
} }

View File

@ -250,10 +250,12 @@ void Foam::KinematicCloud<CloudType>::postEvolve()
if (this->db().time().writeTime()) if (this->db().time().writeTime())
{ {
outputProperties_.writeObject outputProperties_.writeObject
(
IOstreamOption
( (
IOstream::ASCII, IOstream::ASCII,
IOstream::currentVersion, this->db().time().writeCompression()
this->db().time().writeCompression(), ),
true true
); );
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -443,18 +443,14 @@ bool Foam::coordinateSystems::writeData(Ostream& os) const
bool Foam::coordinateSystems::writeObject bool Foam::coordinateSystems::writeObject
( (
IOstream::streamFormat, IOstreamOption,
IOstream::versionNumber ver,
IOstream::compressionType,
const bool valid const bool valid
) const ) const
{ {
// Force ASCII writing // Force ASCII, uncompressed
return regIOobject::writeObject return regIOobject::writeObject
( (
IOstream::ASCII, IOstreamOption(IOstream::ASCII),
ver,
IOstream::UNCOMPRESSED,
valid valid
); );
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -176,12 +176,10 @@ public:
//- Write data //- Write data
bool writeData(Ostream& os) const; bool writeData(Ostream& os) const;
//- Write data //- Write using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType,
const bool valid = true const bool valid = true
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2018 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -1239,9 +1239,7 @@ void Foam::triSurfaceMesh::getVolumeType
bool Foam::triSurfaceMesh::writeObject bool Foam::triSurfaceMesh::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2018 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -331,12 +331,10 @@ public:
return false; return false;
} }
//- Write using given format, version and compression //- Write using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -229,16 +229,14 @@ Foam::label Foam::cellZoneSet::maxSize(const polyMesh& mesh) const
bool Foam::cellZoneSet::writeObject bool Foam::cellZoneSet::writeObject
( (
IOstream::streamFormat s, IOstreamOption streamOpt,
IOstream::versionNumber v,
IOstream::compressionType c,
const bool valid const bool valid
) const ) const
{ {
// Write shadow cellSet // Write shadow cellSet
word oldTypeName = typeName; word oldTypeName = typeName;
const_cast<word&>(type()) = cellSet::typeName; const_cast<word&>(type()) = cellSet::typeName;
bool ok = cellSet::writeObject(s, v, c, valid); bool ok = cellSet::writeObject(streamOpt, valid);
const_cast<word&>(type()) = oldTypeName; const_cast<word&>(type()) = oldTypeName;
// Modify cellZone // Modify cellZone

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -139,12 +139,10 @@ public:
const label maxLen const label maxLen
) const; ) const;
//- Write cellZone //- Write cellZone using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat, IOstreamOption streamOpt,
IOstream::versionNumber,
IOstream::compressionType,
const bool valid const bool valid
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -451,16 +451,14 @@ Foam::label Foam::faceZoneSet::maxSize(const polyMesh& mesh) const
bool Foam::faceZoneSet::writeObject bool Foam::faceZoneSet::writeObject
( (
IOstream::streamFormat s, IOstreamOption streamOpt,
IOstream::versionNumber v,
IOstream::compressionType c,
const bool valid const bool valid
) const ) const
{ {
// Write shadow faceSet // Write shadow faceSet
word oldTypeName = typeName; word oldTypeName = typeName;
const_cast<word&>(type()) = faceSet::typeName; const_cast<word&>(type()) = faceSet::typeName;
bool ok = faceSet::writeObject(s, v, c, valid); bool ok = faceSet::writeObject(streamOpt, valid);
const_cast<word&>(type()) = oldTypeName; const_cast<word&>(type()) = oldTypeName;
// Modify faceZone // Modify faceZone

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -154,12 +154,10 @@ public:
const label maxLen const label maxLen
) const; ) const;
//- Write faceZone //- Write faceZone using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat, IOstreamOption streamOpt,
IOstream::versionNumber,
IOstream::compressionType,
const bool valid const bool valid
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -229,16 +229,14 @@ Foam::label Foam::pointZoneSet::maxSize(const polyMesh& mesh) const
bool Foam::pointZoneSet::writeObject bool Foam::pointZoneSet::writeObject
( (
IOstream::streamFormat s, IOstreamOption streamOpt,
IOstream::versionNumber v,
IOstream::compressionType c,
const bool valid const bool valid
) const ) const
{ {
// Write shadow pointSet // Write shadow pointSet
word oldTypeName = typeName; word oldTypeName = typeName;
const_cast<word&>(type()) = pointSet::typeName; const_cast<word&>(type()) = pointSet::typeName;
bool ok = pointSet::writeObject(s, v, c, valid); bool ok = pointSet::writeObject(streamOpt, valid);
const_cast<word&>(type()) = oldTypeName; const_cast<word&>(type()) = oldTypeName;
// Modify pointZone // Modify pointZone

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -140,12 +140,10 @@ public:
const label maxLen const label maxLen
) const; ) const;
//- Write pointZone //- Write pointZone using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat, IOstreamOption streamOpt,
IOstream::versionNumber,
IOstream::compressionType,
const bool valid const bool valid
) const; ) const;

View File

@ -7,7 +7,7 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2007-2019 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP Copyright (C) 2013-2019 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -206,9 +206,7 @@ Foam::lineSearch& Foam::lineSearch::operator++()
lineSearchDict_.add<label>("iter", iter_, true); lineSearchDict_.add<label>("iter", iter_, true);
lineSearchDict_.regIOobject::writeObject lineSearchDict_.regIOobject::writeObject
( (
IOstream::ASCII, IOstreamOption(IOstream::ASCII),
IOstream::currentVersion,
IOstream::UNCOMPRESSED,
true true
); );

View File

@ -7,7 +7,7 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2007-2019 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP Copyright (C) 2013-2019 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -413,9 +413,7 @@ void Foam::updateMethod::write()
// (e.g. continuation) // (e.g. continuation)
optMethodIODict_.regIOobject::writeObject optMethodIODict_.regIOobject::writeObject
( (
IOstream::ASCII, IOstreamOption(IOstream::ASCII, mesh_.time().writeCompression()),
IOstream::currentVersion,
mesh_.time().writeCompression(),
true true
); );
} }

View File

@ -7,7 +7,7 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2007-2019 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP Copyright (C) 2013-2019 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -1893,16 +1893,11 @@ void Foam::NURBS3DVolume::writeCpsInDict() const
); );
cpsDict.add("controlPoints", cps_); cpsDict.add("controlPoints", cps_);
// Always write in ASCII format.
// Even when choosing to write in binary through controlDict, // Always write in ASCII, but allow compression
// the content is written in ASCII format but with a binary header.
// This creates problems when the content is read back in
// (e.g. continuation)
cpsDict.regIOobject::writeObject cpsDict.regIOobject::writeObject
( (
IOstream::ASCII, IOstreamOption(IOstream::ASCII, mesh_.time().writeCompression()),
IOstream::currentVersion,
mesh_.time().writeCompression(),
true true
); );
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2014-2019 OpenCFD Ltd. Copyright (C) 2014-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -648,14 +648,12 @@ bool Foam::dynamicOversetFvMesh::interpolateFields()
bool Foam::dynamicOversetFvMesh::writeObject bool Foam::dynamicOversetFvMesh::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
//bool ok = dynamicMotionSolverFvMesh::writeObject(fmt, ver, cmp, valid); //bool ok = dynamicMotionSolverFvMesh::writeObject(streamOpt, valid);
bool ok = dynamicMotionSolverListFvMesh::writeObject(fmt, ver, cmp, valid); bool ok = dynamicMotionSolverListFvMesh::writeObject(streamOpt, valid);
// For postprocessing : write cellTypes and zoneID // For postprocessing : write cellTypes and zoneID
{ {
@ -684,7 +682,7 @@ bool Foam::dynamicOversetFvMesh::writeObject
volTypes[cellI] = cellTypes[cellI]; volTypes[cellI] = cellTypes[cellI];
} }
volTypes.correctBoundaryConditions(); volTypes.correctBoundaryConditions();
volTypes.writeObject(fmt, ver, cmp, valid); volTypes.writeObject(streamOpt, valid);
} }
{ {
volScalarField volZoneID volScalarField volZoneID
@ -711,7 +709,7 @@ bool Foam::dynamicOversetFvMesh::writeObject
volZoneID[cellI] = zoneID[cellI]; volZoneID[cellI] = zoneID[cellI];
} }
volZoneID.correctBoundaryConditions(); volZoneID.correctBoundaryConditions();
volZoneID.writeObject(fmt, ver, cmp, valid); volZoneID.writeObject(streamOpt, valid);
} }
if (debug) if (debug)
{ {
@ -764,7 +762,7 @@ bool Foam::dynamicOversetFvMesh::writeObject
} }
//- Do not correctBoundaryConditions since re-interpolates! //- Do not correctBoundaryConditions since re-interpolates!
//volDonorZoneID.correctBoundaryConditions(); //volDonorZoneID.correctBoundaryConditions();
volDonorZoneID.writeObject(fmt, ver, cmp, valid); volDonorZoneID.writeObject(streamOpt, valid);
} }
return ok; return ok;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -350,12 +350,10 @@ public:
//- Update fields when mesh is updated //- Update fields when mesh is updated
virtual bool interpolateFields(); virtual bool interpolateFields();
//- Write using given format, version and compression //- Write using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat, IOstreamOption streamOpt,
IOstream::versionNumber,
IOstream::compressionType,
const bool valid const bool valid
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -4835,9 +4835,7 @@ void Foam::distributedTriSurfaceMesh::distribute
bool Foam::distributedTriSurfaceMesh::writeObject bool Foam::distributedTriSurfaceMesh::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
@ -4871,7 +4869,8 @@ bool Foam::distributedTriSurfaceMesh::writeObject
} }
// Dictionary needs to be written in ascii - binary output not supported. // Dictionary needs to be written in ascii - binary output not supported.
bool ok = dict_.writeObject(IOstream::ASCII, ver, cmp, true); streamOpt.format(IOstream::ASCII);
bool ok = dict_.writeObject(streamOpt, true);
if (debug) if (debug)
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -577,16 +577,14 @@ public:
// regIOobject implementation // regIOobject implementation
//- Write using given format, version and compression //- Write using stream options
// Do not use the triSurfaceMesh::writeObject since it // Do not use the triSurfaceMesh::writeObject since it
// would filter out empty regions. These need to be preserved // would filter out empty regions. These need to be preserved
// in case we want to make decisions based on the number of // in case we want to make decisions based on the number of
// regions. // regions.
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -502,9 +502,7 @@ void Foam::regionModels::regionModel::evolve()
{ {
outputProperties().writeObject outputProperties().writeObject
( (
IOstream::ASCII, IOstreamOption(IOstream::ASCII, time_.writeCompression()),
IOstream::currentVersion,
time_.writeCompression(),
true true
); );
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -342,12 +342,13 @@ void Foam::rigidBodyMeshMotion::solve()
bool Foam::rigidBodyMeshMotion::writeObject bool Foam::rigidBodyMeshMotion::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
// Force ASCII writing
streamOpt.format(IOstream::ASCII);
IOdictionary dict IOdictionary dict
( (
IOobject IOobject
@ -363,8 +364,7 @@ bool Foam::rigidBodyMeshMotion::writeObject
); );
model_.state().write(dict); model_.state().write(dict);
// Force ascii writing return dict.regIOobject::writeObject(streamOpt, valid);
return dict.regIOobject::writeObject(IOstream::ASCII, ver, cmp, valid);
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -165,12 +166,10 @@ public:
//- Solve for motion //- Solve for motion
virtual void solve(); virtual void solve();
//- Write state using given format, version and compression //- Write state using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -278,12 +278,13 @@ void Foam::rigidBodyMeshMotionSolver::solve()
bool Foam::rigidBodyMeshMotionSolver::writeObject bool Foam::rigidBodyMeshMotionSolver::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
// Force ASCII writing
streamOpt.format(IOstream::ASCII);
IOdictionary dict IOdictionary dict
( (
IOobject IOobject
@ -299,8 +300,7 @@ bool Foam::rigidBodyMeshMotionSolver::writeObject
); );
model_.state().write(dict); model_.state().write(dict);
// Force ascii writing return dict.regIOobject::writeObject(streamOpt, valid);
return dict.regIOobject::writeObject(IOstream::ASCII, ver, cmp, valid);
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -155,12 +156,10 @@ public:
//- Solve for motion //- Solve for motion
virtual void solve(); virtual void solve();
//- Write state using given format, version and compression //- Write state using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -294,9 +294,7 @@ void Foam::sixDoFRigidBodyMotionSolver::solve()
bool Foam::sixDoFRigidBodyMotionSolver::writeObject bool Foam::sixDoFRigidBodyMotionSolver::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -141,12 +141,10 @@ public:
//- Solve for motion //- Solve for motion
virtual void solve(); virtual void solve();
//- Write state using given format, version and compression //- Write state using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -102,16 +102,14 @@ void Foam::Detail::MeshedSurfaceIOAllocator::clear()
bool Foam::Detail::MeshedSurfaceIOAllocator::writeObject bool Foam::Detail::MeshedSurfaceIOAllocator::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
return return
( (
points_.writeObject(fmt, ver, cmp, valid) points_.writeObject(streamOpt, valid)
&& faces_.writeObject(fmt, ver, cmp, valid) && faces_.writeObject(streamOpt, valid)
); );
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -148,15 +148,12 @@ public:
// Writing // Writing
//- Write using given format, version and compression //- Write using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const; ) const;
}; };

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -393,12 +393,10 @@ public:
// Writing // Writing
//- Write all components using given format, version and compression //- Write - this is a no-op
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const; ) const;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -31,9 +31,7 @@ License
bool Foam::polySurface::writeObject bool Foam::polySurface::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {

View File

@ -351,9 +351,7 @@ public:
//- Write all components using given format, version and compression //- Write all components using given format, version and compression
virtual bool writeObject virtual bool writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const; ) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -193,17 +193,15 @@ Foam::surfMesh::readUpdateState Foam::surfMesh::readUpdate()
bool Foam::surfMesh::writeObject bool Foam::surfMesh::writeObject
( (
IOstream::streamFormat fmt, IOstreamOption streamOpt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool valid const bool valid
) const ) const
{ {
bool ok = Allocator::writeObject(fmt, ver, cmp, valid); bool ok = Allocator::writeObject(streamOpt, valid);
if (ok) if (ok)
{ {
surfZones_.writeObject(fmt, ver, cmp, valid); surfZones_.writeObject(streamOpt, valid);
} }
return ok; return ok;