mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'IOObject-headers' into 'develop'
file "meta" information See merge request Development/openfoam!430
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -96,8 +96,8 @@ void writeAndRead
|
||||
Pout<< "** Writing:" << writeType
|
||||
<< " Reading:" << readType << endl;
|
||||
|
||||
autoPtr<fileOperation> writeHandler(fileOperation::New(writeType, true));
|
||||
fileHandler(writeHandler);
|
||||
// The write handler
|
||||
fileHandler(fileOperation::New(writeType, true));
|
||||
|
||||
// Delete
|
||||
Pout<< "Deleting:" << fileHandler().filePath(io.objectPath()) << endl;
|
||||
@ -107,8 +107,8 @@ void writeAndRead
|
||||
Pout<< "Writing:" << fileHandler().objectPath(io, io.name()) << endl;
|
||||
doWrite<Type>(io, sz);
|
||||
|
||||
autoPtr<fileOperation> readHandler(fileOperation::New(readType, true));
|
||||
fileHandler(readHandler);
|
||||
// The read handler
|
||||
fileHandler(fileOperation::New(readType, true));
|
||||
|
||||
// Read
|
||||
IOobject readIO(io);
|
||||
@ -130,8 +130,7 @@ void readIfPresent
|
||||
const word& readType
|
||||
)
|
||||
{
|
||||
autoPtr<fileOperation> readHandler(fileOperation::New(readType, true));
|
||||
fileHandler(readHandler);
|
||||
fileHandler(fileOperation::New(readType, true));
|
||||
|
||||
// Read
|
||||
Pout<< "Reading:" << fileHandler().filePath(io.objectPath()) << endl;
|
||||
@ -178,6 +177,7 @@ void doTests(IOobject& io, const label sz)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noBanner();
|
||||
argList::addBoolOption("bool", "Use bool for tests");
|
||||
argList::addBoolOption("scalar", "Use scalar for tests");
|
||||
argList::addBoolOption("label", "Use label for tests (default)");
|
||||
@ -209,6 +209,11 @@ int main(int argc, char *argv[])
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
{
|
||||
dictionary headerDict;
|
||||
io.writeHeader(headerDict, "anything", IOstreamOption());
|
||||
Info<< "IOobjectHeader" << headerDict << nl;
|
||||
}
|
||||
|
||||
label tested = 0;
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,6 +37,8 @@ Description
|
||||
#include "HashSet.H"
|
||||
#include "ListOps.H"
|
||||
#include "cpuTime.H"
|
||||
#include "StringStream.H"
|
||||
#include "FlatOutput.H"
|
||||
#include <vector>
|
||||
#include <unordered_set>
|
||||
|
||||
@ -65,6 +67,28 @@ inline Ostream& report
|
||||
}
|
||||
|
||||
|
||||
// Create equivalent to flat output
|
||||
inline void undecorated
|
||||
(
|
||||
Ostream& os,
|
||||
const bitSet& list
|
||||
)
|
||||
{
|
||||
const label len = list.size();
|
||||
|
||||
os << token::BEGIN_LIST;
|
||||
|
||||
// Contents
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
if (i) os << token::SPACE;
|
||||
os << label(list.get(i));
|
||||
}
|
||||
|
||||
os << token::END_LIST;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@ -97,6 +121,28 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<<"bits used: " << flatOutput(set3b.toc()) << nl;
|
||||
Info<<"inverted: " << flatOutput(invert(set3b)) << nl;
|
||||
|
||||
Info<< "Test read/write (ASCII)" << nl;
|
||||
|
||||
OStringStream ostr;
|
||||
|
||||
undecorated(ostr, set3a); // like flatOutput
|
||||
ostr << bitSet();
|
||||
set3a.flip();
|
||||
undecorated(ostr, set3a); // like flatOutput
|
||||
|
||||
{
|
||||
IStringStream istr(ostr.str());
|
||||
Info<< "parse: " << istr.str() << nl;
|
||||
|
||||
bitSet bset1(istr);
|
||||
bitSet bset2(istr);
|
||||
bitSet bset3(istr);
|
||||
|
||||
Info<< "got: " << bset1 << nl
|
||||
<< "and: " << bset2 << nl
|
||||
<< "and: " << bset3 << nl;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
3
applications/test/charList/Make/files
Normal file
3
applications/test/charList/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-charList.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-charList
|
||||
2
applications/test/charList/Make/options
Normal file
2
applications/test/charList/Make/options
Normal file
@ -0,0 +1,2 @@
|
||||
/* EXE_INC = */
|
||||
/* EXE_LIBS = */
|
||||
87
applications/test/charList/Test-charList.C
Normal file
87
applications/test/charList/Test-charList.C
Normal file
@ -0,0 +1,87 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
Test-charList
|
||||
|
||||
Description
|
||||
Some test of UList, List for characters
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OSspecific.H"
|
||||
#include "argList.H"
|
||||
#include "IOstreams.H"
|
||||
#include "messageStream.H"
|
||||
|
||||
#include "charList.H"
|
||||
#include "labelList.H"
|
||||
#include "StringStream.H"
|
||||
#include "ListOps.H"
|
||||
#include "SubList.H"
|
||||
#include "FlatOutput.H"
|
||||
|
||||
#include <numeric>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noBanner();
|
||||
argList::noParallel();
|
||||
argList::noFunctionObjects();
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
Info<< "Known compound tokens: "
|
||||
<< token::compound::IstreamConstructorTablePtr_->sortedToc() << nl;
|
||||
|
||||
OStringStream ostr;
|
||||
|
||||
{
|
||||
List<char> alphabet(64);
|
||||
std::iota(alphabet.begin(), alphabet.end(), '@');
|
||||
|
||||
alphabet.writeEntry("alphabet", Info);
|
||||
|
||||
ostr << alphabet;
|
||||
|
||||
Info<< "wrote: " << ostr.str() << nl;
|
||||
}
|
||||
|
||||
{
|
||||
IStringStream istr(ostr.str());
|
||||
List<char> alphabet(istr);
|
||||
|
||||
Info<< "re-read: " << alphabet << nl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -346,7 +346,7 @@ int main(int argc, char *argv[])
|
||||
is.setScalarByteSize(sizeof(otherType));
|
||||
|
||||
Info<< "Stream scalar-size ("
|
||||
<< is.scalarByteSize() << ") is native: "
|
||||
<< label(is.scalarByteSize()) << ") is native: "
|
||||
<< Switch(is.checkScalarSize<otherType>()) << nl;
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -63,6 +63,7 @@ int main()
|
||||
auto tfld1 = refPtr<scalarField>::New(10, scalar(1));
|
||||
printInfo(tfld1, true);
|
||||
|
||||
Info<< nl << "Dereferenced: " << *tfld1 << nl;
|
||||
|
||||
Info<< nl << "Construct from autoPtr" << nl;
|
||||
refPtr<scalarField> tfld2(autoPtr<scalarField>::New(10, scalar(2)));
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -38,6 +38,7 @@ Description
|
||||
#include "PstreamBuffers.H"
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "IOobject.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
@ -132,6 +133,7 @@ int main(int argc, char *argv[])
|
||||
cout<<"string:" << sizeof(Foam::string) << nl;
|
||||
}
|
||||
|
||||
cout<<"IOobject:" << sizeof(Foam::IOobject) << nl;
|
||||
cout<<"IOstream:" << sizeof(Foam::IOstream) << nl;
|
||||
cout<<"PstreamBuffers:" << sizeof(Foam::PstreamBuffers) << nl;
|
||||
cout<<"Time:" << sizeof(Foam::Time) << nl;
|
||||
|
||||
@ -31,8 +31,10 @@ $(bools)/Switch/Switch.C
|
||||
$(bools)/lists/boolList.C
|
||||
|
||||
chars = primitives/chars
|
||||
$(chars)/char/charIO.C
|
||||
$(chars)/wchar/wcharIO.C
|
||||
$(chars)/char/char.C
|
||||
$(chars)/wchar/wchar.C
|
||||
$(chars)/lists/charList.C
|
||||
$(chars)/lists/charUList.C
|
||||
|
||||
primitives/direction/directionIO.C
|
||||
|
||||
@ -309,6 +311,7 @@ $(IOdictionary)/unwatchedIOdictionary.C
|
||||
|
||||
db/IOobjects/IOMap/IOMapName.C
|
||||
db/IOobjects/decomposedBlockData/decomposedBlockData.C
|
||||
db/IOobjects/decomposedBlockData/decomposedBlockDataHeader.C
|
||||
db/IOobjects/GlobalIOField/GlobalIOFields.C
|
||||
|
||||
|
||||
@ -318,11 +321,13 @@ db/IOobjects/GlobalIOList/globalIOLists.C
|
||||
IOobject = db/IOobject
|
||||
$(IOobject)/IOobject.C
|
||||
$(IOobject)/IOobjectIO.C
|
||||
$(IOobject)/IOobjectMetaData.C
|
||||
$(IOobject)/IOobjectReadHeader.C
|
||||
$(IOobject)/IOobjectWriteHeader.C
|
||||
|
||||
regIOobject = db/regIOobject
|
||||
/* $(regIOobject)/regIOobject.C in global.Cver */
|
||||
$(regIOobject)/regIOobjectMetaData.C
|
||||
$(regIOobject)/regIOobjectRead.C
|
||||
$(regIOobject)/regIOobjectWrite.C
|
||||
|
||||
|
||||
@ -416,7 +416,7 @@ public:
|
||||
Ostream& printBits(Ostream& os, bool debugOutput=false) const;
|
||||
|
||||
//- Clear list and read from stream
|
||||
Istream& read(Istream& is);
|
||||
Istream& readList(Istream& is);
|
||||
|
||||
//- Write List, with line-breaks in ASCII when length exceeds shortLen.
|
||||
// Using '0' suppresses line-breaks entirely.
|
||||
|
||||
@ -212,7 +212,7 @@ inline Foam::PackedList<Width>::PackedList(Istream& is)
|
||||
blocks_(),
|
||||
size_(0)
|
||||
{
|
||||
read(is);
|
||||
readList(is);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -61,70 +61,33 @@ Foam::Ostream& Foam::PackedList<Width>::printBits
|
||||
|
||||
|
||||
template<unsigned Width>
|
||||
Foam::Istream& Foam::PackedList<Width>::read(Istream& is)
|
||||
Foam::Istream& Foam::PackedList<Width>::readList(Istream& is)
|
||||
{
|
||||
PackedList<Width>& list = *this;
|
||||
|
||||
// Anull list
|
||||
list.clear();
|
||||
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
token firstTok(is);
|
||||
is.fatalCheck
|
||||
(
|
||||
"PackedList::read(Istream&) : "
|
||||
"reading first token"
|
||||
);
|
||||
token tok(is);
|
||||
|
||||
if (firstTok.isLabel())
|
||||
is.fatalCheck("PackedList::readList(Istream&) : reading first token");
|
||||
|
||||
if (tok.isLabel())
|
||||
{
|
||||
const label len = firstTok.labelToken();
|
||||
const label len = tok.labelToken();
|
||||
|
||||
// Set list length to that read
|
||||
list.resize(len);
|
||||
|
||||
// Read list contents depending on data format
|
||||
if (is.format() == IOstream::ASCII)
|
||||
if (is.format() == IOstream::BINARY)
|
||||
{
|
||||
// Read beginning of contents
|
||||
const char delimiter = is.readBeginList("PackedList");
|
||||
|
||||
if (len)
|
||||
{
|
||||
if (delimiter == token::BEGIN_LIST)
|
||||
{
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
list[i] = list.readValue(is);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"PackedList::read(Istream&) : "
|
||||
"reading entry"
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assign for all entries
|
||||
list = list.readValue(is);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"PackedList::read(Istream&) : "
|
||||
"reading the single entry"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Read end of contents
|
||||
is.readEndList("PackedList");
|
||||
}
|
||||
else
|
||||
{
|
||||
// NOTE: binary content should be independent of WM_LABEL_SIZE
|
||||
// Binary (always contiguous)
|
||||
|
||||
if (len)
|
||||
{
|
||||
// NOTE: independent of WM_LABEL_SIZE
|
||||
is.read
|
||||
(
|
||||
reinterpret_cast<char*>(list.data()),
|
||||
@ -133,37 +96,73 @@ Foam::Istream& Foam::PackedList<Width>::read(Istream& is)
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"PackedList::read(Istream&) : "
|
||||
"PackedList::readList(Istream&) : "
|
||||
"reading the binary block"
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Begin of contents marker
|
||||
const char delimiter = is.readBeginList("PackedList");
|
||||
|
||||
if (len)
|
||||
{
|
||||
if (delimiter == token::BEGIN_LIST)
|
||||
{
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
list.set(i, list.readValue(is));
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"PackedList::readList(Istream&) : "
|
||||
"reading entry"
|
||||
);
|
||||
}
|
||||
}
|
||||
else // token::BEGIN_BLOCK
|
||||
{
|
||||
// Assign for all entries
|
||||
list = list.readValue(is);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"PackedList::readList(Istream&) : "
|
||||
"reading the single entry"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// End of contents marker
|
||||
is.readEndList("PackedList");
|
||||
}
|
||||
}
|
||||
else if (firstTok.isPunctuation(token::BEGIN_LIST))
|
||||
else if (tok.isPunctuation(token::BEGIN_LIST))
|
||||
{
|
||||
token nextTok(is);
|
||||
is >> tok;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
while (!nextTok.isPunctuation(token::END_LIST))
|
||||
while (!tok.isPunctuation(token::END_LIST))
|
||||
{
|
||||
is.putBack(nextTok);
|
||||
is.putBack(tok);
|
||||
list.append(list.readValue(is));
|
||||
|
||||
is >> nextTok;
|
||||
is >> tok;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
}
|
||||
}
|
||||
else if (firstTok.isPunctuation(token::BEGIN_BLOCK))
|
||||
else if (tok.isPunctuation(token::BEGIN_BLOCK))
|
||||
{
|
||||
token nextTok(is);
|
||||
is >> tok;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
while (!nextTok.isPunctuation(token::END_BLOCK))
|
||||
while (!tok.isPunctuation(token::END_BLOCK))
|
||||
{
|
||||
is.putBack(nextTok);
|
||||
is.putBack(tok);
|
||||
list.setPair(is);
|
||||
|
||||
is >> nextTok;
|
||||
is >> tok;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
}
|
||||
}
|
||||
@ -171,7 +170,7 @@ Foam::Istream& Foam::PackedList<Width>::read(Istream& is)
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "incorrect first token, expected <int>, '(' or '{', found "
|
||||
<< firstTok.info() << nl
|
||||
<< tok.info() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
@ -189,40 +188,11 @@ Foam::Ostream& Foam::PackedList<Width>::writeList
|
||||
const PackedList<Width>& list = *this;
|
||||
const label len = list.size();
|
||||
|
||||
// Write list contents depending on data format
|
||||
if (os.format() == IOstream::ASCII)
|
||||
if (os.format() == IOstream::BINARY)
|
||||
{
|
||||
if (len > 1 && list.uniform())
|
||||
{
|
||||
// Two or more entries, and all have identical values.
|
||||
os << len << token::BEGIN_BLOCK << list[0] << token::END_BLOCK;
|
||||
}
|
||||
else if (!shortLen || len <= shortLen)
|
||||
{
|
||||
// Shorter list, or line-breaks suppressed
|
||||
os << len << token::BEGIN_LIST;
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
if (i) os << token::SPACE;
|
||||
os << list[i];
|
||||
}
|
||||
os << token::END_LIST;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Longer list
|
||||
os << nl << len << nl << token::BEGIN_LIST << nl;
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
os << list[i] << nl;
|
||||
}
|
||||
os << token::END_LIST << nl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Contents are binary and contiguous
|
||||
os << nl << len << nl;
|
||||
// Binary (always contiguous)
|
||||
|
||||
os << nl << len << nl;
|
||||
|
||||
if (len)
|
||||
{
|
||||
@ -234,6 +204,44 @@ Foam::Ostream& Foam::PackedList<Width>::writeList
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (len > 1 && list.uniform())
|
||||
{
|
||||
// Two or more entries, and all entries have identical values.
|
||||
os << len << token::BEGIN_BLOCK << list[0] << token::END_BLOCK;
|
||||
}
|
||||
else if (!shortLen || len <= shortLen)
|
||||
{
|
||||
// Single-line output
|
||||
|
||||
// Size and start delimiter
|
||||
os << len << token::BEGIN_LIST;
|
||||
|
||||
// Contents
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
if (i) os << token::SPACE;
|
||||
os << label(list.get(i));
|
||||
}
|
||||
|
||||
// End delimiter
|
||||
os << token::END_LIST;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Multi-line output
|
||||
|
||||
// Size and start delimiter
|
||||
os << nl << len << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
// Contents
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
os << label(list.get(i)) << nl;
|
||||
}
|
||||
|
||||
// End delimiter
|
||||
os << token::END_LIST << nl;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
@ -260,7 +268,7 @@ void Foam::PackedList<Width>::writeEntry
|
||||
template<unsigned Width>
|
||||
Foam::Istream& Foam::operator>>(Istream& is, PackedList<Width>& list)
|
||||
{
|
||||
return list.read(is);
|
||||
return list.readList(is);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -74,11 +74,6 @@ class bitSet
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Write as a dictionary entry
|
||||
void writeEntry(Ostream& os) const;
|
||||
|
||||
// Logic/Set Operations
|
||||
|
||||
//- The set difference
|
||||
@ -582,16 +577,6 @@ public:
|
||||
inline bitSet& operator-=(const bitSet& other);
|
||||
|
||||
|
||||
// IO
|
||||
|
||||
//- Write bitSet, with line-breaks (ASCII) when length exceeds shortLen.
|
||||
// Using '0' suppresses line-breaks entirely.
|
||||
Ostream& writeList(Ostream& os, const label shortLen=0) const;
|
||||
|
||||
//- Write as a dictionary entry with keyword
|
||||
void writeEntry(const word& keyword, Ostream& os) const;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
//- Return info proxy
|
||||
@ -611,8 +596,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Write bitset to Ostream, as per bitSet::writeList() with default length
|
||||
//- of 40 items.
|
||||
//- Write bitset to Ostream with 40 items per line.
|
||||
Ostream& operator<<(Ostream& os, const bitSet& bitset);
|
||||
|
||||
//- Output bitset information
|
||||
|
||||
@ -28,90 +28,6 @@ License
|
||||
#include "bitSet.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::bitSet::writeEntry(Ostream& os) const
|
||||
{
|
||||
os << *this;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::bitSet::writeList
|
||||
(
|
||||
Ostream& os,
|
||||
const label shortLen
|
||||
) const
|
||||
{
|
||||
const bitSet& list = *this;
|
||||
const label len = list.size();
|
||||
|
||||
// Write list contents depending on data format
|
||||
if (os.format() == IOstream::ASCII)
|
||||
{
|
||||
if (len > 1 && list.uniform())
|
||||
{
|
||||
// Two or more entries, and all entries have identical values.
|
||||
os << len << token::BEGIN_BLOCK << list[0] << token::END_BLOCK;
|
||||
}
|
||||
else if (!shortLen || len <= shortLen)
|
||||
{
|
||||
// Shorter list, or line-breaks suppressed
|
||||
os << len << token::BEGIN_LIST;
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
if (i) os << token::SPACE;
|
||||
os << list[i];
|
||||
}
|
||||
os << token::END_LIST;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Longer list
|
||||
os << nl << len << nl << token::BEGIN_LIST << nl;
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
os << list[i] << nl;
|
||||
}
|
||||
os << token::END_LIST << nl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Contents are binary and contiguous
|
||||
os << nl << len << nl;
|
||||
|
||||
if (len)
|
||||
{
|
||||
// write(...) includes surrounding start/end delimiters
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(list.cdata()),
|
||||
list.size_bytes()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
void Foam::bitSet::writeEntry
|
||||
(
|
||||
const word& keyword,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
if (keyword.size())
|
||||
{
|
||||
os.writeKeyword(keyword);
|
||||
}
|
||||
writeEntry(os);
|
||||
os << token::END_STATEMENT << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Ostream Operators * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const bitSet& bitset)
|
||||
|
||||
@ -168,7 +168,10 @@ public:
|
||||
//- Clear all entries from table and delete any allocated pointers
|
||||
void clear();
|
||||
|
||||
//- Write
|
||||
|
||||
// Reading/writing
|
||||
|
||||
//- Invoke write() on each non-null entry
|
||||
void write(Ostream& os) const;
|
||||
|
||||
|
||||
@ -183,6 +186,7 @@ public:
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
//- Clear table and read from Istream
|
||||
friend Istream& operator>> <T, Key, Hash>
|
||||
(
|
||||
Istream& is,
|
||||
|
||||
@ -44,7 +44,7 @@ void Foam::HashPtrTable<T, Key, Hash>::readIstream
|
||||
{
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
token firstToken(is);
|
||||
token tok(is);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
@ -52,9 +52,9 @@ void Foam::HashPtrTable<T, Key, Hash>::readIstream
|
||||
"reading first token"
|
||||
);
|
||||
|
||||
if (firstToken.isLabel())
|
||||
if (tok.isLabel())
|
||||
{
|
||||
const label len = firstToken.labelToken();
|
||||
const label len = tok.labelToken();
|
||||
|
||||
// Read beginning of contents
|
||||
const char delimiter = is.readBeginList("HashPtrTable");
|
||||
@ -84,7 +84,8 @@ void Foam::HashPtrTable<T, Key, Hash>::readIstream
|
||||
else
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "incorrect first token, '(', found " << firstToken.info()
|
||||
<< "incorrect first token, '(', found "
|
||||
<< tok.info() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
@ -92,12 +93,13 @@ void Foam::HashPtrTable<T, Key, Hash>::readIstream
|
||||
// Read end of contents
|
||||
is.readEndList("HashPtrTable");
|
||||
}
|
||||
else if (firstToken.isPunctuation(token::BEGIN_LIST))
|
||||
else if (tok.isPunctuation(token::BEGIN_LIST))
|
||||
{
|
||||
token lastToken(is);
|
||||
while (!lastToken.isPunctuation(token::END_LIST))
|
||||
is >> tok;
|
||||
|
||||
while (!tok.isPunctuation(token::END_LIST))
|
||||
{
|
||||
is.putBack(lastToken);
|
||||
is.putBack(tok);
|
||||
Key key;
|
||||
is >> key;
|
||||
this->set(key, inew(key, is).ptr());
|
||||
@ -108,14 +110,14 @@ void Foam::HashPtrTable<T, Key, Hash>::readIstream
|
||||
"reading entry"
|
||||
);
|
||||
|
||||
is >> lastToken;
|
||||
is >> tok;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "incorrect first token, expected <int> or '(', found "
|
||||
<< firstToken.info()
|
||||
<< tok.info() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -105,6 +105,12 @@ template<class T> class UList;
|
||||
template<class T, unsigned N> class FixedList;
|
||||
template<class T, class Key, class Hash> class HashTable;
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Istream& operator>>(Istream&, HashTable<T, Key, Hash>&);
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Ostream& operator<<(Ostream&, const HashTable<T, Key, Hash>&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class HashTable Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -148,6 +154,12 @@ class HashTable
|
||||
template<class... Args>
|
||||
bool setEntry(const bool overwrite, const Key& key, Args&&... args);
|
||||
|
||||
//- Read hash table
|
||||
Istream& readTable(Istream& is);
|
||||
|
||||
//- Write hash table
|
||||
Ostream& writeTable(Ostream& os) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -893,7 +905,7 @@ public:
|
||||
inline constexpr const_iterator cend() const noexcept;
|
||||
|
||||
|
||||
// Writing
|
||||
// Reading/writing
|
||||
|
||||
//- Print information
|
||||
Ostream& printInfo(Ostream& os) const;
|
||||
@ -902,18 +914,24 @@ public:
|
||||
//- when length exceeds shortLen.
|
||||
// Using '0' suppresses line-breaks entirely.
|
||||
Ostream& writeKeys(Ostream& os, const label shortLen=0) const;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Istream& operator>> <T, Key, Hash>
|
||||
(
|
||||
Istream&,
|
||||
HashTable<T, Key, Hash>& tbl
|
||||
);
|
||||
|
||||
friend Ostream& operator<< <T, Key, Hash>
|
||||
(
|
||||
Ostream&,
|
||||
const HashTable<T, Key, Hash>& tbl
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Istream& operator>>(Istream& is, HashTable<T, Key, Hash>& tbl);
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Ostream& operator<<(Ostream& os, const HashTable<T, Key, Hash>& tbl);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -141,21 +141,20 @@ Foam::Ostream& Foam::HashTable<T, Key, Hash>::writeKeys
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::Istream& Foam::operator>>
|
||||
Foam::Istream& Foam::HashTable<T, Key, Hash>::readTable
|
||||
(
|
||||
Istream& is,
|
||||
HashTable<T, Key, Hash>& tbl
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
HashTable<T, Key, Hash>& tbl = *this;
|
||||
|
||||
// Anull existing table
|
||||
tbl.clear();
|
||||
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
token firstToken(is);
|
||||
token tok(is);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
@ -163,9 +162,9 @@ Foam::Istream& Foam::operator>>
|
||||
"reading first token"
|
||||
);
|
||||
|
||||
if (firstToken.isLabel())
|
||||
if (tok.isLabel())
|
||||
{
|
||||
const label len = firstToken.labelToken();
|
||||
const label len = tok.labelToken();
|
||||
|
||||
// Read beginning of contents
|
||||
const char delimiter = is.readBeginList("HashTable");
|
||||
@ -175,7 +174,8 @@ Foam::Istream& Foam::operator>>
|
||||
if (delimiter != token::BEGIN_LIST)
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "incorrect first token, '(', found " << firstToken.info()
|
||||
<< "incorrect first token, '(', found "
|
||||
<< tok.info() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
@ -203,12 +203,12 @@ Foam::Istream& Foam::operator>>
|
||||
// Read end of contents
|
||||
is.readEndList("HashTable");
|
||||
}
|
||||
else if (firstToken.isPunctuation(token::BEGIN_LIST))
|
||||
else if (tok.isPunctuation(token::BEGIN_LIST))
|
||||
{
|
||||
token lastToken(is);
|
||||
while (!lastToken.isPunctuation(token::END_LIST))
|
||||
is >> tok;
|
||||
while (!tok.isPunctuation(token::END_LIST))
|
||||
{
|
||||
is.putBack(lastToken);
|
||||
is.putBack(tok);
|
||||
|
||||
Key key;
|
||||
|
||||
@ -222,14 +222,14 @@ Foam::Istream& Foam::operator>>
|
||||
"reading entry"
|
||||
);
|
||||
|
||||
is >> lastToken;
|
||||
is >> tok;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "incorrect first token, expected <int> or '(', found "
|
||||
<< firstToken.info()
|
||||
<< tok.info() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
@ -239,12 +239,13 @@ Foam::Istream& Foam::operator>>
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
Foam::Ostream& Foam::HashTable<T, Key, Hash>::writeTable
|
||||
(
|
||||
Ostream& os,
|
||||
const HashTable<T, Key, Hash>& tbl
|
||||
)
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
const HashTable<T, Key, Hash>& tbl = *this;
|
||||
|
||||
const label len = tbl.size();
|
||||
|
||||
if (len)
|
||||
@ -271,4 +272,28 @@ Foam::Ostream& Foam::operator<<
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::Istream& Foam::operator>>
|
||||
(
|
||||
Istream& is,
|
||||
HashTable<T, Key, Hash>& tbl
|
||||
)
|
||||
{
|
||||
return tbl.readTable(is);
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const HashTable<T, Key, Hash>& tbl
|
||||
)
|
||||
{
|
||||
return tbl.writeTable(os);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -44,59 +44,9 @@ Foam::Ostream& Foam::IndirectListBase<T, Addr>::writeList
|
||||
|
||||
const label len = list.size();
|
||||
|
||||
// Write list contents depending on data format
|
||||
if (os.format() == IOstream::ASCII || !is_contiguous<T>::value)
|
||||
if (os.format() == IOstream::BINARY && is_contiguous<T>::value)
|
||||
{
|
||||
if (len > 1 && is_contiguous<T>::value && list.uniform())
|
||||
{
|
||||
// Two or more entries, and all entries have identical values.
|
||||
os << len << token::BEGIN_BLOCK << list[0] << token::END_BLOCK;
|
||||
}
|
||||
else if
|
||||
(
|
||||
(len <= 1 || !shortLen)
|
||||
||
|
||||
(
|
||||
(len <= shortLen)
|
||||
&&
|
||||
(
|
||||
Detail::ListPolicy::no_linebreak<T>::value
|
||||
|| is_contiguous<T>::value
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
// Size and start delimiter
|
||||
os << len << token::BEGIN_LIST;
|
||||
|
||||
// Contents
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
if (i) os << token::SPACE;
|
||||
os << list[i];
|
||||
}
|
||||
|
||||
// End delimiter
|
||||
os << token::END_LIST;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Size and start delimiter
|
||||
os << nl << len << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
// Contents
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
os << list[i] << nl;
|
||||
}
|
||||
|
||||
// End delimiter
|
||||
os << token::END_LIST << nl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Contents are binary and contiguous
|
||||
// Binary and contiguous
|
||||
os << nl << len << nl;
|
||||
|
||||
if (len)
|
||||
@ -119,6 +69,56 @@ Foam::Ostream& Foam::IndirectListBase<T, Addr>::writeList
|
||||
os.endRawWrite();
|
||||
}
|
||||
}
|
||||
else if (len > 1 && is_contiguous<T>::value && list.uniform())
|
||||
{
|
||||
// Two or more entries, and all entries have identical values.
|
||||
os << len << token::BEGIN_BLOCK << list[0] << token::END_BLOCK;
|
||||
}
|
||||
else if
|
||||
(
|
||||
(len <= 1 || !shortLen)
|
||||
||
|
||||
(
|
||||
(len <= shortLen)
|
||||
&&
|
||||
(
|
||||
is_contiguous<T>::value
|
||||
|| Detail::ListPolicy::no_linebreak<T>::value
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
// Single-line output
|
||||
|
||||
// Size and start delimiter
|
||||
os << len << token::BEGIN_LIST;
|
||||
|
||||
// Contents
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
if (i) os << token::SPACE;
|
||||
os << list[i];
|
||||
}
|
||||
|
||||
// End delimiter
|
||||
os << token::END_LIST;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Multi-line output
|
||||
|
||||
// Size and start delimiter
|
||||
os << nl << len << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
// Contents
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
os << list[i] << nl;
|
||||
}
|
||||
|
||||
// End delimiter
|
||||
os << token::END_LIST << nl;
|
||||
}
|
||||
|
||||
os.check(FUNCTION_NAME);
|
||||
return os;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -46,7 +46,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
|
||||
class Istream;
|
||||
class Ostream;
|
||||
@ -79,7 +79,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null construct
|
||||
//- Default construct
|
||||
ILList() = default;
|
||||
|
||||
//- Construct and insert the initial T item pointer
|
||||
@ -126,7 +126,7 @@ public:
|
||||
void transfer(ILList<LListBase, T>& lst);
|
||||
|
||||
|
||||
// Member operators
|
||||
// Member Operators
|
||||
|
||||
//- Copy assignment using the 'clone()' method for each element
|
||||
void operator=(const ILList<LListBase, T>& lst);
|
||||
@ -135,7 +135,7 @@ public:
|
||||
void operator=(ILList<LListBase, T>&& lst);
|
||||
|
||||
|
||||
// Istream operator
|
||||
// Istream Operator
|
||||
|
||||
//- Read from Istream, discarding existing contents.
|
||||
friend Istream& operator>> <LListBase, T>
|
||||
|
||||
@ -38,7 +38,7 @@ void Foam::ILList<LListBase, T>::readIstream(Istream& is, const INew& inew)
|
||||
{
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
token firstToken(is);
|
||||
token tok(is);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
@ -46,9 +46,9 @@ void Foam::ILList<LListBase, T>::readIstream(Istream& is, const INew& inew)
|
||||
"reading first token"
|
||||
);
|
||||
|
||||
if (firstToken.isLabel())
|
||||
if (tok.isLabel())
|
||||
{
|
||||
const label len = firstToken.labelToken();
|
||||
const label len = tok.labelToken();
|
||||
|
||||
// Read beginning of contents
|
||||
const char delimiter = is.readBeginList("ILList");
|
||||
@ -69,7 +69,7 @@ void Foam::ILList<LListBase, T>::readIstream(Istream& is, const INew& inew)
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
else // BEGIN_BLOCK
|
||||
{
|
||||
T* p = inew(is).ptr();
|
||||
this->append(p);
|
||||
@ -90,19 +90,19 @@ void Foam::ILList<LListBase, T>::readIstream(Istream& is, const INew& inew)
|
||||
// Read end of contents
|
||||
is.readEndList("ILList");
|
||||
}
|
||||
else if (firstToken.isPunctuation(token::BEGIN_LIST))
|
||||
else if (tok.isPunctuation(token::BEGIN_LIST))
|
||||
{
|
||||
token lastToken(is);
|
||||
is >> tok;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
while (!lastToken.isPunctuation(token::END_LIST))
|
||||
while (!tok.isPunctuation(token::END_LIST))
|
||||
{
|
||||
is.putBack(lastToken);
|
||||
is.putBack(tok);
|
||||
|
||||
T* p = inew(is).ptr();
|
||||
this->append(p);
|
||||
|
||||
is >> lastToken;
|
||||
is >> tok;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
}
|
||||
}
|
||||
@ -110,7 +110,7 @@ void Foam::ILList<LListBase, T>::readIstream(Istream& is, const INew& inew)
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "incorrect first token, expected <int> or '(', found "
|
||||
<< firstToken.info()
|
||||
<< tok.info() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -47,7 +47,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
|
||||
class Istream;
|
||||
class Ostream;
|
||||
@ -162,7 +162,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null construct
|
||||
//- Default construct
|
||||
LList() = default;
|
||||
|
||||
//- Construct and copy insert the initial T item
|
||||
@ -283,7 +283,7 @@ public:
|
||||
void transfer(LList<LListBase, T>& lst);
|
||||
|
||||
|
||||
// Member operators
|
||||
// Member Operators
|
||||
|
||||
//- Copy assignment
|
||||
void operator=(const LList<LListBase, T>& lst);
|
||||
@ -295,7 +295,10 @@ public:
|
||||
void operator=(std::initializer_list<T> lst);
|
||||
|
||||
|
||||
// IOstream operators
|
||||
// IOstream Operators
|
||||
|
||||
//- Read list from Istream
|
||||
Istream& readList(Istream& is);
|
||||
|
||||
//- Write LList with line-breaks when length exceeds shortLen.
|
||||
// Using '0' suppresses line-breaks entirely.
|
||||
|
||||
@ -42,22 +42,24 @@ Foam::LList<LListBase, T>::LList(Istream& is)
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class LListBase, class T>
|
||||
Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& lst)
|
||||
Foam::Istream& Foam::LList<LListBase, T>::readList(Istream& is)
|
||||
{
|
||||
LList<LListBase, T>& list = *this;
|
||||
|
||||
// Anull list
|
||||
lst.clear();
|
||||
list.clear();
|
||||
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
token firstToken(is);
|
||||
token tok(is);
|
||||
|
||||
is.fatalCheck("LList::readList : reading first token");
|
||||
|
||||
if (firstToken.isLabel())
|
||||
if (tok.isLabel())
|
||||
{
|
||||
const label len = firstToken.labelToken();
|
||||
const label len = tok.labelToken();
|
||||
|
||||
// Read beginning of contents
|
||||
// Begin of contents marker
|
||||
const char delimiter = is.readBeginList("LList");
|
||||
|
||||
if (len)
|
||||
@ -68,7 +70,7 @@ Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& lst)
|
||||
{
|
||||
T element;
|
||||
is >> element;
|
||||
lst.append(element);
|
||||
list.append(element);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -78,28 +80,28 @@ Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& lst)
|
||||
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
lst.append(element);
|
||||
list.append(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Read end of contents
|
||||
// End of contents marker
|
||||
is.readEndList("LList");
|
||||
}
|
||||
else if (firstToken.isPunctuation(token::BEGIN_LIST))
|
||||
else if (tok.isPunctuation(token::BEGIN_LIST))
|
||||
{
|
||||
token lastToken(is);
|
||||
is >> tok;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
while (!lastToken.isPunctuation(token::END_LIST))
|
||||
while (!tok.isPunctuation(token::END_LIST))
|
||||
{
|
||||
is.putBack(lastToken);
|
||||
is.putBack(tok);
|
||||
|
||||
T element;
|
||||
is >> element;
|
||||
lst.append(element);
|
||||
list.append(element);
|
||||
|
||||
is >> lastToken;
|
||||
is >> tok;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
}
|
||||
}
|
||||
@ -107,7 +109,7 @@ Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& lst)
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "incorrect first token, expected <int> or '(', found "
|
||||
<< firstToken.info()
|
||||
<< tok.info()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
@ -123,6 +125,8 @@ Foam::Ostream& Foam::LList<LListBase, T>::writeList
|
||||
const label shortLen
|
||||
) const
|
||||
{
|
||||
// NB: no binary, contiguous output
|
||||
|
||||
const label len = this->size();
|
||||
|
||||
if
|
||||
@ -167,9 +171,16 @@ Foam::Ostream& Foam::LList<LListBase, T>::writeList
|
||||
|
||||
|
||||
template<class LListBase, class T>
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const LList<LListBase, T>& lst)
|
||||
Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& list)
|
||||
{
|
||||
return lst.writeList(os, -1); // Always with line breaks
|
||||
return list.readList(is);
|
||||
}
|
||||
|
||||
|
||||
template<class LListBase, class T>
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const LList<LListBase, T>& list)
|
||||
{
|
||||
return list.writeList(os, -1); // Always with line breaks
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ void Foam::LPtrList<LListBase, T>::readIstream(Istream& is, const INew& inew)
|
||||
{
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
token firstToken(is);
|
||||
token tok(is);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
@ -47,9 +47,9 @@ void Foam::LPtrList<LListBase, T>::readIstream(Istream& is, const INew& inew)
|
||||
"reading first token"
|
||||
);
|
||||
|
||||
if (firstToken.isLabel())
|
||||
if (tok.isLabel())
|
||||
{
|
||||
const label len = firstToken.labelToken();
|
||||
const label len = tok.labelToken();
|
||||
|
||||
// Read beginning of contents
|
||||
const char delimiter = is.readBeginList("LPtrList");
|
||||
@ -70,7 +70,7 @@ void Foam::LPtrList<LListBase, T>::readIstream(Istream& is, const INew& inew)
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
else // Assumed to be token::BEGIN_BLOCK
|
||||
{
|
||||
T* p = inew(is).ptr();
|
||||
this->append(p);
|
||||
@ -91,17 +91,17 @@ void Foam::LPtrList<LListBase, T>::readIstream(Istream& is, const INew& inew)
|
||||
// Read end of contents
|
||||
is.readEndList("LPtrList");
|
||||
}
|
||||
else if (firstToken.isPunctuation(token::BEGIN_LIST))
|
||||
else if (tok.isPunctuation(token::BEGIN_LIST))
|
||||
{
|
||||
token lastToken(is);
|
||||
is >> tok;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
while (!lastToken.isPunctuation(token::END_LIST))
|
||||
while (!tok.isPunctuation(token::END_LIST))
|
||||
{
|
||||
is.putBack(lastToken);
|
||||
is.putBack(tok);
|
||||
this->append(inew(is).ptr());
|
||||
|
||||
is >> lastToken;
|
||||
is >> tok;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
}
|
||||
}
|
||||
@ -109,7 +109,7 @@ void Foam::LPtrList<LListBase, T>::readIstream(Istream& is, const INew& inew)
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "incorrect first token, expected <int> or '(', found "
|
||||
<< firstToken.info()
|
||||
<< tok.info() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
@ -47,8 +47,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
|
||||
// Forward Declarations
|
||||
class Ostream;
|
||||
|
||||
template<class LListBase, class T> class UILList;
|
||||
@ -107,7 +106,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null construct
|
||||
//- Default construct
|
||||
UILList() = default;
|
||||
|
||||
//- Construct and insert the initial T item
|
||||
@ -179,7 +178,7 @@ public:
|
||||
bool operator!=(const UILList<LListBase, T>& lst) const;
|
||||
|
||||
|
||||
// IOstream operators
|
||||
// IOstream Operators
|
||||
|
||||
//- Write UILList with line-breaks when length exceeds shortLen.
|
||||
// Using '0' suppresses line-breaks entirely.
|
||||
|
||||
@ -39,6 +39,8 @@ Foam::Ostream& Foam::UILList<LListBase, T>::writeList
|
||||
const label shortLen
|
||||
) const
|
||||
{
|
||||
// NB: no binary, contiguous output
|
||||
|
||||
const label len = this->size();
|
||||
|
||||
if
|
||||
|
||||
@ -334,20 +334,26 @@ public:
|
||||
inline void operator=(SortableList<T>&& lst);
|
||||
|
||||
|
||||
// Reading/writing
|
||||
|
||||
//- Read from Istream, discarding existing contents
|
||||
inline Istream& readList(Istream& is);
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
//- Read from Istream, discarding existing contents
|
||||
friend Istream& operator>> <T, SizeMin>
|
||||
(
|
||||
Istream& is,
|
||||
DynamicList<T, SizeMin>& rhs
|
||||
DynamicList<T, SizeMin>& list
|
||||
);
|
||||
|
||||
//- Write to Ostream
|
||||
friend Ostream& operator<< <T, SizeMin>
|
||||
(
|
||||
Ostream& os,
|
||||
const DynamicList<T, SizeMin>& rhs
|
||||
const DynamicList<T, SizeMin>& list
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@ -223,9 +223,11 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::DynamicList<T, SizeMin>::DynamicList(Istream& is)
|
||||
:
|
||||
List<T>(is),
|
||||
capacity_(List<T>::size())
|
||||
{}
|
||||
List<T>(),
|
||||
capacity_(0)
|
||||
{
|
||||
this->readList(is);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
@ -865,20 +867,32 @@ inline void Foam::DynamicList<T, SizeMin>::operator=
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::Istream& Foam::DynamicList<T, SizeMin>::readList
|
||||
(
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
DynamicList<T, SizeMin>& list = *this;
|
||||
|
||||
// Use entire storage - ie, resize(capacity())
|
||||
(void) list.expandStorage();
|
||||
|
||||
static_cast<List<T>&>(list).readList(is);
|
||||
list.capacity_ = list.size();
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::Istream& Foam::operator>>
|
||||
(
|
||||
Istream& is,
|
||||
DynamicList<T, SizeMin>& rhs
|
||||
DynamicList<T, SizeMin>& list
|
||||
)
|
||||
{
|
||||
// Use entire storage - ie, resize(capacity())
|
||||
(void) rhs.expandStorage();
|
||||
|
||||
is >> static_cast<List<T>&>(rhs);
|
||||
rhs.capacity_ = rhs.List<T>::size();
|
||||
|
||||
return is;
|
||||
return list.readList(is);
|
||||
}
|
||||
|
||||
|
||||
@ -886,10 +900,10 @@ template<class T, int SizeMin>
|
||||
inline Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const DynamicList<T, SizeMin>& rhs
|
||||
const DynamicList<T, SizeMin>& list
|
||||
)
|
||||
{
|
||||
os << static_cast<const List<T>&>(rhs);
|
||||
os << static_cast<const List<T>&>(list);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
@ -430,7 +430,10 @@ public:
|
||||
bool operator>=(const FixedList<T, N>& list) const;
|
||||
|
||||
|
||||
// Writing
|
||||
// Reading/writing
|
||||
|
||||
//- Read from Istream, discarding contents of existing List
|
||||
Istream& readList(Istream& is);
|
||||
|
||||
//- Write the list as a dictionary entry with keyword
|
||||
void writeEntry(const word& keyword, Ostream& os) const;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -72,62 +72,65 @@ Foam::Ostream& Foam::FixedList<T, N>::writeList
|
||||
{
|
||||
const FixedList<T, N>& list = *this;
|
||||
|
||||
// Write list contents depending on data format
|
||||
// Unlike UList, no compact ascii output since a FixedList is generally
|
||||
// small and we prefer a consistent appearance.
|
||||
// Eg, FixedList<T,2> or Pair<T> as "(-1 -1)", never as "2{-1}"
|
||||
|
||||
// Unlike UList, no compact output form since a FixedList is generally
|
||||
// small and we desire a consistent appearance.
|
||||
// Eg, FixedList<T,2> or Pair<T> as "(-1 -1)", not as "2{-1}"
|
||||
|
||||
if (os.format() == IOstream::ASCII || !is_contiguous<T>::value)
|
||||
if (os.format() == IOstream::BINARY && is_contiguous<T>::value)
|
||||
{
|
||||
if
|
||||
// Binary and contiguous. Size is always non-zero
|
||||
|
||||
// write(...) includes surrounding start/end delimiters
|
||||
os.write
|
||||
(
|
||||
(N <= 1 || !shortLen)
|
||||
||
|
||||
reinterpret_cast<const char*>(list.cdata()),
|
||||
list.size_bytes()
|
||||
);
|
||||
}
|
||||
else if
|
||||
(
|
||||
(N <= 1 || !shortLen)
|
||||
||
|
||||
(
|
||||
(N <= unsigned(shortLen))
|
||||
&&
|
||||
(
|
||||
(N <= unsigned(shortLen))
|
||||
&&
|
||||
(
|
||||
Detail::ListPolicy::no_linebreak<T>::value
|
||||
|| is_contiguous<T>::value
|
||||
)
|
||||
is_contiguous<T>::value
|
||||
|| Detail::ListPolicy::no_linebreak<T>::value
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
// Single-line output
|
||||
|
||||
// Start delimiter
|
||||
os << token::BEGIN_LIST;
|
||||
|
||||
// Contents
|
||||
for (unsigned i=0; i<N; ++i)
|
||||
{
|
||||
// Start delimiter
|
||||
os << token::BEGIN_LIST;
|
||||
|
||||
// Contents
|
||||
for (unsigned i=0; i<N; ++i)
|
||||
{
|
||||
if (i) os << token::SPACE;
|
||||
os << list[i];
|
||||
}
|
||||
|
||||
// End delimiter
|
||||
os << token::END_LIST;
|
||||
if (i) os << token::SPACE;
|
||||
os << list[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Start delimiter
|
||||
os << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
// Contents
|
||||
for (unsigned i=0; i<N; ++i)
|
||||
{
|
||||
os << list[i] << nl;
|
||||
}
|
||||
|
||||
// End delimiter
|
||||
os << token::END_LIST << nl;
|
||||
}
|
||||
// End delimiter
|
||||
os << token::END_LIST;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Binary, contiguous
|
||||
// Multi-line output
|
||||
|
||||
// write(...) includes surrounding start/end delimiters
|
||||
os.write(reinterpret_cast<const char*>(list.cdata()), N*sizeof(T));
|
||||
// Start delimiter
|
||||
os << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
// Contents
|
||||
for (unsigned i=0; i<N; ++i)
|
||||
{
|
||||
os << list[i] << nl;
|
||||
}
|
||||
|
||||
// End delimiter
|
||||
os << token::END_LIST << nl;
|
||||
}
|
||||
|
||||
os.check(FUNCTION_NAME);
|
||||
@ -135,59 +138,73 @@ Foam::Ostream& Foam::FixedList<T, N>::writeList
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class T, unsigned N>
|
||||
Foam::FixedList<T, N>::FixedList(Istream& is)
|
||||
Foam::Istream& Foam::FixedList<T, N>::readList
|
||||
(
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
operator>>(is, *this);
|
||||
}
|
||||
FixedList<T, N>& list = *this;
|
||||
|
||||
|
||||
template<class T, unsigned N>
|
||||
Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, N>& list)
|
||||
{
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
if (is.format() == IOstream::ASCII || !is_contiguous<T>::value)
|
||||
if (is.format() == IOstream::BINARY && is_contiguous<T>::value)
|
||||
{
|
||||
token firstToken(is);
|
||||
// Binary and contiguous
|
||||
|
||||
Detail::readContiguous<T>
|
||||
(
|
||||
is,
|
||||
reinterpret_cast<char*>(list.data()),
|
||||
list.size_bytes()
|
||||
);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"operator>>(Istream&, FixedList<T, N>&) : "
|
||||
"FixedList<T, N>::readList(Istream&) : "
|
||||
"reading the binary block"
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
token tok(is);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"FixedList<T, N>::readList(Istream&) : "
|
||||
"reading first token"
|
||||
);
|
||||
|
||||
if (firstToken.isCompound())
|
||||
if (tok.isCompound())
|
||||
{
|
||||
// Compound: transfer contents
|
||||
list = dynamicCast<token::Compound<List<T>>>
|
||||
(
|
||||
firstToken.transferCompoundToken(is)
|
||||
tok.transferCompoundToken(is)
|
||||
);
|
||||
}
|
||||
else if (firstToken.isLabel())
|
||||
else if (tok.isLabel())
|
||||
{
|
||||
const label len = firstToken.labelToken();
|
||||
const label len = tok.labelToken();
|
||||
|
||||
// List lengths must match
|
||||
list.checkSize(len);
|
||||
}
|
||||
else if (!firstToken.isPunctuation())
|
||||
else if (!tok.isPunctuation())
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "incorrect first token, expected <label> "
|
||||
"or '(' or '{', found "
|
||||
<< firstToken.info()
|
||||
<< tok.info() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Putback the opening bracket
|
||||
is.putBack(firstToken);
|
||||
is.putBack(tok);
|
||||
}
|
||||
|
||||
// Read beginning of contents
|
||||
// Begin of contents marker
|
||||
const char delimiter = is.readBeginList("FixedList");
|
||||
|
||||
if (delimiter == token::BEGIN_LIST)
|
||||
@ -198,19 +215,21 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, N>& list)
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"operator>>(Istream&, FixedList<T, N>&) : "
|
||||
"FixedList<T, N>::readList(Istream&) : "
|
||||
"reading entry"
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Uniform content (delimiter == token::BEGIN_BLOCK)
|
||||
|
||||
T val;
|
||||
is >> val;
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"operator>>(Istream&, FixedList<T, N>&) : "
|
||||
"FixedList<T, N>::readList(Istream&) : "
|
||||
"reading the single entry"
|
||||
);
|
||||
|
||||
@ -220,29 +239,28 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, N>& list)
|
||||
}
|
||||
}
|
||||
|
||||
// Read end of contents
|
||||
// End of contents marker
|
||||
is.readEndList("FixedList");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Binary and contiguous
|
||||
|
||||
Detail::readContiguous<T>
|
||||
(
|
||||
is,
|
||||
reinterpret_cast<char*>(list.data()),
|
||||
N*sizeof(T)
|
||||
);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"operator>>(Istream&, FixedList<T, N>&) : "
|
||||
"reading the binary block"
|
||||
);
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class T, unsigned N>
|
||||
Foam::FixedList<T, N>::FixedList(Istream& is)
|
||||
{
|
||||
this->readList(is);
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned N>
|
||||
Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, N>& list)
|
||||
{
|
||||
return list.readList(is);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -302,7 +302,13 @@ public:
|
||||
void operator=(SLList<T>&& list);
|
||||
|
||||
|
||||
// Istream Operator
|
||||
// Reading/writing
|
||||
|
||||
//- Read List from Istream, discarding contents of existing List
|
||||
Istream& readList(Istream& is);
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
//- Read List from Istream, discarding contents of existing List
|
||||
friend Istream& operator>> <T>
|
||||
@ -347,6 +353,14 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Template Specializations * * * * * * * * * * * * //
|
||||
|
||||
//- Specialized list reading for character lists which always uses
|
||||
//- binary format.
|
||||
template<>
|
||||
Istream& List<char>::readList(Istream& is);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
|
||||
|
||||
//- Create identity map of the given length with (map[i] == i)
|
||||
|
||||
@ -39,23 +39,25 @@ Foam::List<T>::List(Istream& is)
|
||||
:
|
||||
UList<T>(nullptr, 0)
|
||||
{
|
||||
operator>>(is, *this);
|
||||
this->readList(is);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::Istream& Foam::operator>>(Istream& is, List<T>& list)
|
||||
Foam::Istream& Foam::List<T>::readList(Istream& is)
|
||||
{
|
||||
List<T>& list = *this;
|
||||
|
||||
// Anull list
|
||||
list.resize(0);
|
||||
list.clear();
|
||||
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
token firstToken(is);
|
||||
token tok(is);
|
||||
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
is.fatalCheck("List<T>::readList(Istream&) : reading first token");
|
||||
|
||||
if (firstToken.isCompound())
|
||||
if (tok.isCompound())
|
||||
{
|
||||
// Compound: simply transfer contents
|
||||
|
||||
@ -63,24 +65,42 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& list)
|
||||
(
|
||||
dynamicCast<token::Compound<List<T>>>
|
||||
(
|
||||
firstToken.transferCompoundToken(is)
|
||||
tok.transferCompoundToken(is)
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (firstToken.isLabel())
|
||||
else if (tok.isLabel())
|
||||
{
|
||||
// Label: could be int(..), int{...} or just a plain '0'
|
||||
|
||||
const label len = firstToken.labelToken();
|
||||
const label len = tok.labelToken();
|
||||
|
||||
// Resize to length read
|
||||
// Resize to actual length read
|
||||
list.resize(len);
|
||||
|
||||
// Read list contents depending on data format
|
||||
|
||||
if (is.format() == IOstream::ASCII || !is_contiguous<T>::value)
|
||||
if (is.format() == IOstream::BINARY && is_contiguous<T>::value)
|
||||
{
|
||||
// Read beginning of contents
|
||||
// Binary and contiguous
|
||||
|
||||
if (len)
|
||||
{
|
||||
Detail::readContiguous<T>
|
||||
(
|
||||
is,
|
||||
reinterpret_cast<char*>(list.data()),
|
||||
list.size_bytes()
|
||||
);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"List<T>::readList(Istream&) : "
|
||||
"reading the binary block"
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Begin of contents marker
|
||||
const char delimiter = is.readBeginList("List");
|
||||
|
||||
if (len)
|
||||
@ -93,7 +113,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& list)
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"operator>>(Istream&, List<T>&) : "
|
||||
"List<T>::readList(Istream&) : "
|
||||
"reading entry"
|
||||
);
|
||||
}
|
||||
@ -102,49 +122,32 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& list)
|
||||
{
|
||||
// Uniform content (delimiter == token::BEGIN_BLOCK)
|
||||
|
||||
T element;
|
||||
is >> element;
|
||||
T elem;
|
||||
is >> elem;
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"operator>>(Istream&, List<T>&) : "
|
||||
"List<T>::readList(Istream&) : "
|
||||
"reading the single entry"
|
||||
);
|
||||
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
list[i] = element; // Copy the value
|
||||
list[i] = elem; // Copy the value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Read end of contents
|
||||
// End of contents marker
|
||||
is.readEndList("List");
|
||||
}
|
||||
else if (len)
|
||||
{
|
||||
// Non-empty, binary, contiguous
|
||||
|
||||
Detail::readContiguous<T>
|
||||
(
|
||||
is,
|
||||
reinterpret_cast<char*>(list.data()),
|
||||
len*sizeof(T)
|
||||
);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"operator>>(Istream&, List<T>&) : "
|
||||
"reading the binary block"
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (firstToken.isPunctuation(token::BEGIN_LIST))
|
||||
else if (tok.isPunctuation(token::BEGIN_LIST))
|
||||
{
|
||||
// "(...)" : read as SLList and transfer contents
|
||||
|
||||
is.putBack(firstToken); // Putback the opening bracket
|
||||
SLList<T> sll(is); // Read as singly-linked list
|
||||
is.putBack(tok); // Putback the opening bracket
|
||||
SLList<T> sll(is); // Read as singly-linked list
|
||||
|
||||
// Reallocate and move assign list elements
|
||||
list = std::move(sll);
|
||||
@ -153,7 +156,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& list)
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "incorrect first token, expected <int> or '(', found "
|
||||
<< firstToken.info() << nl
|
||||
<< tok.info() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
@ -161,4 +164,11 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& list)
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::Istream& Foam::operator>>(Istream& is, List<T>& list)
|
||||
{
|
||||
return list.readList(is);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -459,7 +459,11 @@ public:
|
||||
bool operator>=(const UList<T>& a) const;
|
||||
|
||||
|
||||
// Writing
|
||||
// Reading/writing
|
||||
|
||||
//- Read List contents from Istream.
|
||||
// The List must have the proper size before calling
|
||||
Istream& readList(Istream& is);
|
||||
|
||||
//- Write the List as a dictionary entry with keyword
|
||||
void writeEntry(const word& keyword, Ostream& os) const;
|
||||
@ -472,7 +476,7 @@ public:
|
||||
// IOstream Operators
|
||||
|
||||
//- Read List contents from Istream.
|
||||
// Requires size to have been set before
|
||||
// The List must have the proper size before calling
|
||||
friend Istream& operator>> <T>
|
||||
(
|
||||
Istream& os,
|
||||
@ -547,6 +551,24 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Template Specializations * * * * * * * * * * * * //
|
||||
|
||||
//- Specialized list reading for character lists which always uses
|
||||
//- binary format.
|
||||
template<>
|
||||
Istream& UList<char>::readList(Istream& is);
|
||||
|
||||
//- Specialized writeEntry for character lists which always uses
|
||||
//- binary format.
|
||||
template<>
|
||||
void UList<char>::writeEntry(Ostream& os) const;
|
||||
|
||||
//- Specialized writeList for character lists which always uses
|
||||
//- binary format.
|
||||
template<>
|
||||
Ostream& UList<char>::writeList(Ostream& os, const label /*unused*/) const;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
//- Write List to Ostream, as per UList::writeList() with default length.
|
||||
|
||||
@ -85,59 +85,10 @@ Foam::Ostream& Foam::UList<T>::writeList
|
||||
|
||||
const label len = list.size();
|
||||
|
||||
// Write list contents depending on data format
|
||||
if (os.format() == IOstream::ASCII || !is_contiguous<T>::value)
|
||||
if (os.format() == IOstream::BINARY && is_contiguous<T>::value)
|
||||
{
|
||||
if (len > 1 && is_contiguous<T>::value && list.uniform())
|
||||
{
|
||||
// Two or more entries, and all entries have identical values.
|
||||
os << len << token::BEGIN_BLOCK << list[0] << token::END_BLOCK;
|
||||
}
|
||||
else if
|
||||
(
|
||||
(len <= 1 || !shortLen)
|
||||
||
|
||||
(
|
||||
(len <= shortLen)
|
||||
&&
|
||||
(
|
||||
Detail::ListPolicy::no_linebreak<T>::value
|
||||
|| is_contiguous<T>::value
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
// Size and start delimiter
|
||||
os << len << token::BEGIN_LIST;
|
||||
// Binary and contiguous
|
||||
|
||||
// Contents
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
if (i) os << token::SPACE;
|
||||
os << list[i];
|
||||
}
|
||||
|
||||
// End delimiter
|
||||
os << token::END_LIST;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Size and start delimiter
|
||||
os << nl << len << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
// Contents
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
os << list[i] << nl;
|
||||
}
|
||||
|
||||
// End delimiter
|
||||
os << token::END_LIST << nl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Contents are binary and contiguous
|
||||
os << nl << len << nl;
|
||||
|
||||
if (len)
|
||||
@ -150,27 +101,77 @@ Foam::Ostream& Foam::UList<T>::writeList
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (len > 1 && is_contiguous<T>::value && list.uniform())
|
||||
{
|
||||
// Two or more entries, and all entries have identical values.
|
||||
os << len << token::BEGIN_BLOCK << list[0] << token::END_BLOCK;
|
||||
}
|
||||
else if
|
||||
(
|
||||
(len <= 1 || !shortLen)
|
||||
||
|
||||
(
|
||||
(len <= shortLen)
|
||||
&&
|
||||
(
|
||||
is_contiguous<T>::value
|
||||
|| Detail::ListPolicy::no_linebreak<T>::value
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
// Single-line output
|
||||
|
||||
// Size and start delimiter
|
||||
os << len << token::BEGIN_LIST;
|
||||
|
||||
// Contents
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
if (i) os << token::SPACE;
|
||||
os << list[i];
|
||||
}
|
||||
|
||||
// End delimiter
|
||||
os << token::END_LIST;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Multi-line output
|
||||
|
||||
// Size and start delimiter
|
||||
os << nl << len << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
// Contents
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
os << list[i] << nl;
|
||||
}
|
||||
|
||||
// End delimiter
|
||||
os << token::END_LIST << nl;
|
||||
}
|
||||
|
||||
os.check(FUNCTION_NAME);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
Foam::Istream& Foam::operator>>(Istream& is, UList<T>& list)
|
||||
Foam::Istream& Foam::UList<T>::readList(Istream& is)
|
||||
{
|
||||
UList<T>& list = *this;
|
||||
|
||||
// The target list length - must match with sizes read
|
||||
const label len = list.size();
|
||||
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
token firstToken(is);
|
||||
token tok(is);
|
||||
|
||||
is.fatalCheck("operator>>(Istream&, UList<T>&) : reading first token");
|
||||
is.fatalCheck("UList<T>::readList(Istream&) : reading first token");
|
||||
|
||||
if (firstToken.isCompound())
|
||||
if (tok.isCompound())
|
||||
{
|
||||
// Compound: simply transfer contents
|
||||
|
||||
@ -179,7 +180,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& list)
|
||||
(
|
||||
dynamicCast<token::Compound<List<T>>>
|
||||
(
|
||||
firstToken.transferCompoundToken(is)
|
||||
tok.transferCompoundToken(is)
|
||||
)
|
||||
);
|
||||
|
||||
@ -199,11 +200,11 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& list)
|
||||
list[i] = std::move(elems[i]);
|
||||
}
|
||||
}
|
||||
else if (firstToken.isLabel())
|
||||
else if (tok.isLabel())
|
||||
{
|
||||
// Label: could be int(..), int{...} or just a plain '0'
|
||||
|
||||
const label inputLen = firstToken.labelToken();
|
||||
const label inputLen = tok.labelToken();
|
||||
|
||||
// List lengths must match
|
||||
if (inputLen != len)
|
||||
@ -214,11 +215,29 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& list)
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
// Read list contents depending on data format
|
||||
|
||||
if (is.format() == IOstream::ASCII || !is_contiguous<T>::value)
|
||||
if (is.format() == IOstream::BINARY && is_contiguous<T>::value)
|
||||
{
|
||||
// Read beginning of contents
|
||||
// Binary and contiguous
|
||||
|
||||
if (len)
|
||||
{
|
||||
Detail::readContiguous<T>
|
||||
(
|
||||
is,
|
||||
reinterpret_cast<char*>(list.data()),
|
||||
list.size_bytes()
|
||||
);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"UList<T>::readList(Istream&) : "
|
||||
"reading binary block"
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Begin of contents marker
|
||||
const char delimiter = is.readBeginList("List");
|
||||
|
||||
if (len)
|
||||
@ -231,7 +250,8 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& list)
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"operator>>(Istream&, UList<T>&) : reading entry"
|
||||
"UList<T>::readList(Istream&) : "
|
||||
"reading entry"
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -239,48 +259,32 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& list)
|
||||
{
|
||||
// Uniform content (delimiter == token::BEGIN_BLOCK)
|
||||
|
||||
T element;
|
||||
is >> element;
|
||||
T elem;
|
||||
is >> elem;
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"operator>>(Istream&, UList<T>&) : "
|
||||
"UList<T>::readList(Istream&) : "
|
||||
"reading the single entry"
|
||||
);
|
||||
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
list[i] = element; // Copy the value
|
||||
list[i] = elem; // Copy the value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Read end of contents
|
||||
// End of contents marker
|
||||
is.readEndList("List");
|
||||
}
|
||||
else if (len)
|
||||
{
|
||||
// Non-empty, binary, contiguous
|
||||
|
||||
Detail::readContiguous<T>
|
||||
(
|
||||
is,
|
||||
reinterpret_cast<char*>(list.data()),
|
||||
len*sizeof(T)
|
||||
);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"operator>>(Istream&, UList<T>&) : reading the binary block"
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (firstToken.isPunctuation(token::BEGIN_LIST))
|
||||
else if (tok.isPunctuation(token::BEGIN_LIST))
|
||||
{
|
||||
// "(...)" : read as SLList and transfer contents
|
||||
|
||||
is.putBack(firstToken); // Putback the opening bracket
|
||||
SLList<T> sll(is); // Read as singly-linked list
|
||||
is.putBack(tok); // Putback the opening bracket
|
||||
SLList<T> sll(is); // Read as singly-linked list
|
||||
|
||||
// List lengths must match
|
||||
if (sll.size() != len)
|
||||
@ -301,7 +305,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& list)
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "incorrect first token, expected <int> or '(', found "
|
||||
<< firstToken.info() << nl
|
||||
<< tok.info() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
@ -309,4 +313,11 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& list)
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::Istream& Foam::operator>>(Istream& is, UList<T>& list)
|
||||
{
|
||||
return list.readList(is);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -41,20 +41,16 @@ void Foam::PtrList<T>::readIstream(Istream& is, const INew& inew)
|
||||
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
token firstToken(is);
|
||||
token tok(is);
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
"PtrList::readIstream : "
|
||||
"reading first token"
|
||||
);
|
||||
is.fatalCheck("PtrList::readIstream : reading first token");
|
||||
|
||||
if (firstToken.isLabel())
|
||||
if (tok.isLabel())
|
||||
{
|
||||
// Label: could be int(..), int{...} or just a plain '0'
|
||||
|
||||
// Read size of list
|
||||
const label len = firstToken.labelToken();
|
||||
const label len = tok.labelToken();
|
||||
|
||||
// Set list length to that read
|
||||
resize(len);
|
||||
@ -78,7 +74,7 @@ void Foam::PtrList<T>::readIstream(Istream& is, const INew& inew)
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
else // Assumed to be BEGIN_BLOCK
|
||||
{
|
||||
T* p = inew(is).ptr();
|
||||
set(0, p);
|
||||
@ -99,7 +95,7 @@ void Foam::PtrList<T>::readIstream(Istream& is, const INew& inew)
|
||||
// Read end of contents
|
||||
is.readEndList("PtrList");
|
||||
}
|
||||
else if (firstToken.isPunctuation(token::BEGIN_LIST))
|
||||
else if (tok.isPunctuation(token::BEGIN_LIST))
|
||||
{
|
||||
// "(...)" : read as SLList and transfer contents
|
||||
// This would be more efficient (fewer allocations, lower overhead)
|
||||
@ -107,20 +103,20 @@ void Foam::PtrList<T>::readIstream(Istream& is, const INew& inew)
|
||||
|
||||
SLList<T*> slList;
|
||||
|
||||
token lastToken(is);
|
||||
while (!lastToken.isPunctuation(token::END_LIST))
|
||||
is >> tok;
|
||||
while (!tok.isPunctuation(token::END_LIST))
|
||||
{
|
||||
is.putBack(lastToken);
|
||||
is.putBack(tok);
|
||||
|
||||
if (is.eof())
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "Premature EOF after reading " << lastToken.info()
|
||||
<< "Premature EOF after reading " << tok.info() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
slList.append(inew(is).ptr());
|
||||
is >> lastToken;
|
||||
is >> tok;
|
||||
}
|
||||
|
||||
resize(slList.size());
|
||||
@ -136,7 +132,7 @@ void Foam::PtrList<T>::readIstream(Istream& is, const INew& inew)
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "incorrect first token, expected <int> or '(', found "
|
||||
<< firstToken.info() << nl
|
||||
<< tok.info() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,7 +28,7 @@ License
|
||||
|
||||
#include "IOobject.H"
|
||||
#include "Time.H"
|
||||
#include "IFstream.H"
|
||||
#include "Istream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -37,6 +37,8 @@ namespace Foam
|
||||
defineTypeNameAndDebug(IOobject, 0);
|
||||
}
|
||||
|
||||
bool Foam::IOobject::bannerEnabled_(true);
|
||||
|
||||
char Foam::IOobject::scopeSeparator
|
||||
(
|
||||
#ifdef _WIN32
|
||||
@ -47,7 +49,6 @@ char Foam::IOobject::scopeSeparator
|
||||
#endif
|
||||
);
|
||||
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::IOobject::fileCheckTypes
|
||||
@ -60,7 +61,6 @@ Foam::IOobject::fileCheckTypesNames
|
||||
{ fileCheckTypes::inotifyMaster, "inotifyMaster" },
|
||||
});
|
||||
|
||||
|
||||
// Default fileCheck type
|
||||
Foam::IOobject::fileCheckTypes Foam::IOobject::fileModificationChecking
|
||||
(
|
||||
@ -290,7 +290,8 @@ Foam::IOobject::IOobject
|
||||
const objectRegistry& registry,
|
||||
readOption ro,
|
||||
writeOption wo,
|
||||
bool registerObject
|
||||
bool registerObject,
|
||||
bool globalObject
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
@ -298,14 +299,15 @@ Foam::IOobject::IOobject
|
||||
note_(),
|
||||
instance_(instance),
|
||||
local_(),
|
||||
db_(registry),
|
||||
rOpt_(ro),
|
||||
wOpt_(wo),
|
||||
registerObject_(registerObject),
|
||||
globalObject_(false),
|
||||
globalObject_(globalObject),
|
||||
objState_(GOOD),
|
||||
labelByteSize_(sizeof(label)),
|
||||
scalarByteSize_(sizeof(scalar))
|
||||
sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
|
||||
sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
|
||||
|
||||
db_(registry)
|
||||
{
|
||||
if (objectRegistry::debug)
|
||||
{
|
||||
@ -334,14 +336,15 @@ Foam::IOobject::IOobject
|
||||
note_(),
|
||||
instance_(instance),
|
||||
local_(local),
|
||||
db_(registry),
|
||||
rOpt_(ro),
|
||||
wOpt_(wo),
|
||||
registerObject_(registerObject),
|
||||
globalObject_(globalObject),
|
||||
objState_(GOOD),
|
||||
labelByteSize_(sizeof(label)),
|
||||
scalarByteSize_(sizeof(scalar))
|
||||
sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
|
||||
sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
|
||||
|
||||
db_(registry)
|
||||
{
|
||||
if (objectRegistry::debug)
|
||||
{
|
||||
@ -368,14 +371,15 @@ Foam::IOobject::IOobject
|
||||
note_(),
|
||||
instance_(),
|
||||
local_(),
|
||||
db_(registry),
|
||||
rOpt_(ro),
|
||||
wOpt_(wo),
|
||||
registerObject_(registerObject),
|
||||
globalObject_(globalObject),
|
||||
objState_(GOOD),
|
||||
labelByteSize_(sizeof(label)),
|
||||
scalarByteSize_(sizeof(scalar))
|
||||
sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
|
||||
sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
|
||||
|
||||
db_(registry)
|
||||
{
|
||||
if (!fileNameComponents(path, instance_, local_, name_))
|
||||
{
|
||||
@ -405,14 +409,15 @@ Foam::IOobject::IOobject
|
||||
note_(io.note_),
|
||||
instance_(io.instance_),
|
||||
local_(io.local_),
|
||||
db_(registry),
|
||||
rOpt_(io.rOpt_),
|
||||
wOpt_(io.wOpt_),
|
||||
registerObject_(io.registerObject_),
|
||||
globalObject_(io.globalObject_),
|
||||
objState_(io.objState_),
|
||||
labelByteSize_(io.labelByteSize_),
|
||||
scalarByteSize_(io.scalarByteSize_)
|
||||
sizeofLabel_(io.sizeofLabel_),
|
||||
sizeofScalar_(io.sizeofScalar_),
|
||||
|
||||
db_(registry)
|
||||
{}
|
||||
|
||||
|
||||
@ -427,14 +432,15 @@ Foam::IOobject::IOobject
|
||||
note_(io.note_),
|
||||
instance_(io.instance_),
|
||||
local_(io.local_),
|
||||
db_(io.db_),
|
||||
rOpt_(io.rOpt_),
|
||||
wOpt_(io.wOpt_),
|
||||
registerObject_(io.registerObject_),
|
||||
globalObject_(io.globalObject_),
|
||||
objState_(io.objState_),
|
||||
labelByteSize_(io.labelByteSize_),
|
||||
scalarByteSize_(io.scalarByteSize_)
|
||||
sizeofLabel_(io.sizeofLabel_),
|
||||
sizeofScalar_(io.sizeofScalar_),
|
||||
|
||||
db_(io.db_)
|
||||
{}
|
||||
|
||||
|
||||
@ -454,7 +460,7 @@ Foam::IOobject::IOobject
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::objectRegistry& Foam::IOobject::db() const
|
||||
const Foam::objectRegistry& Foam::IOobject::db() const noexcept
|
||||
{
|
||||
return db_;
|
||||
}
|
||||
@ -566,8 +572,8 @@ void Foam::IOobject::operator=(const IOobject& io)
|
||||
wOpt_ = io.wOpt_;
|
||||
globalObject_ = io.globalObject_;
|
||||
objState_ = io.objState_;
|
||||
labelByteSize_ = io.labelByteSize_;
|
||||
scalarByteSize_ = io.scalarByteSize_;
|
||||
sizeofLabel_ = io.sizeofLabel_;
|
||||
sizeofScalar_ = io.sizeofScalar_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -64,6 +64,21 @@ Description
|
||||
- \par NO_WRITE
|
||||
No automatic write on destruction but can be written explicitly
|
||||
|
||||
When serializing, the IOobject characteristics are typically written
|
||||
as a \c FoamFile header, which is a sub-dictionary with the following
|
||||
type of content:
|
||||
|
||||
\table
|
||||
Property | Description | Type | Reqd | Deflt
|
||||
version | The base format version | float | no | 2.0
|
||||
format | The stream format (ascii/binary) | word | yes |
|
||||
arch | The architecture string | string | no |
|
||||
note | Descriptive note about the object | string | no |
|
||||
location | The relative location of the object | string | no |
|
||||
class | The type of the object | word | yes |
|
||||
object | The name of the object | word | yes |
|
||||
\endtable
|
||||
|
||||
Note
|
||||
Specifying registered does not result in the IOobject itself being
|
||||
registered. It is only serves as guidance for a regIOobject using it.
|
||||
@ -86,6 +101,7 @@ SourceFiles
|
||||
#include "fileName.H"
|
||||
#include "typeInfo.H"
|
||||
#include "autoPtr.H"
|
||||
#include "IOstreamOption.H"
|
||||
#include "InfoProxy.H"
|
||||
#include "Enum.H"
|
||||
|
||||
@ -96,6 +112,7 @@ namespace Foam
|
||||
|
||||
// Forward Declarations
|
||||
class Time;
|
||||
class dictionary;
|
||||
class objectRegistry;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -146,6 +163,12 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
// Static Data Members
|
||||
|
||||
//- Use an output file banner, enabled by default
|
||||
static bool bannerEnabled_;
|
||||
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Name
|
||||
@ -163,9 +186,6 @@ private:
|
||||
//- Local path component
|
||||
fileName local_;
|
||||
|
||||
//- Reference to the objectRegistry
|
||||
const objectRegistry& db_;
|
||||
|
||||
//- Read option
|
||||
readOption rOpt_;
|
||||
|
||||
@ -181,17 +201,41 @@ private:
|
||||
//- IOobject state
|
||||
objectState objState_;
|
||||
|
||||
//- The label byte-size (could also be stored as byte)
|
||||
unsigned short labelByteSize_;
|
||||
//- The sizeof (label) in bytes, possibly read from the header
|
||||
unsigned char sizeofLabel_;
|
||||
|
||||
//- The scalar byte-size (could also be stored as byte)
|
||||
unsigned short scalarByteSize_;
|
||||
//- The sizeof (scalar) in bytes, possibly read from the header
|
||||
unsigned char sizeofScalar_;
|
||||
|
||||
//- Reference to the objectRegistry
|
||||
const objectRegistry& db_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Helper: write content for FoamFile IOobject header
|
||||
//- with optional meta information.
|
||||
static void writeHeaderContent
|
||||
(
|
||||
Ostream& os,
|
||||
const IOobject& io,
|
||||
const word& objectType,
|
||||
const dictionary* metaDataDict = nullptr
|
||||
);
|
||||
|
||||
//- Helper: write dictionary content for FoamFile header
|
||||
//- with optional meta information.
|
||||
static void writeHeaderContent
|
||||
(
|
||||
dictionary& os,
|
||||
const IOobject& io,
|
||||
const word& objectType,
|
||||
IOstreamOption streamOpt,
|
||||
const dictionary* metaDataDict = nullptr
|
||||
);
|
||||
|
||||
//- Set the object state to bad
|
||||
void setBad(const string& s);
|
||||
|
||||
@ -214,6 +258,21 @@ public:
|
||||
|
||||
// Static Functions
|
||||
|
||||
//- Status of output file banner
|
||||
static bool bannerEnabled() noexcept
|
||||
{
|
||||
return bannerEnabled_;
|
||||
}
|
||||
|
||||
//- Enable/disable an output file banner
|
||||
// \return the previous value
|
||||
static bool bannerEnabled(bool on) noexcept
|
||||
{
|
||||
bool old(bannerEnabled_);
|
||||
bannerEnabled_ = on;
|
||||
return old;
|
||||
}
|
||||
|
||||
//- Split path into instance, local, name components
|
||||
//
|
||||
// The splitting behaviour is as follows:
|
||||
@ -294,7 +353,8 @@ public:
|
||||
const objectRegistry& registry,
|
||||
readOption r=NO_READ,
|
||||
writeOption w=NO_WRITE,
|
||||
bool registerObject=true
|
||||
bool registerObject = true,
|
||||
bool globalObject = false
|
||||
);
|
||||
|
||||
//- Construct from name, instance, local, registry, io options
|
||||
@ -306,7 +366,7 @@ public:
|
||||
const objectRegistry& registry,
|
||||
readOption r=NO_READ,
|
||||
writeOption w=NO_WRITE,
|
||||
bool registerObject=true,
|
||||
bool registerObject = true,
|
||||
bool globalObject = false
|
||||
);
|
||||
|
||||
@ -363,28 +423,28 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// General access
|
||||
// General Access
|
||||
|
||||
//- Return the local objectRegistry
|
||||
const objectRegistry& db() const;
|
||||
const objectRegistry& db() const noexcept;
|
||||
|
||||
//- Return time
|
||||
//- Return Time associated with the objectRegistry
|
||||
const Time& time() const;
|
||||
|
||||
//- Return name
|
||||
inline const word& name() const;
|
||||
inline const word& name() const noexcept;
|
||||
|
||||
//- Return name of the class name read from header
|
||||
inline const word& headerClassName() const;
|
||||
inline const word& headerClassName() const noexcept;
|
||||
|
||||
//- Return non-constant access to the class name read from header
|
||||
inline word& headerClassName();
|
||||
inline word& headerClassName() noexcept;
|
||||
|
||||
//- Return the optional note
|
||||
inline const string& note() const;
|
||||
inline const string& note() const noexcept;
|
||||
|
||||
//- Return non-constant access to the optional note
|
||||
inline string& note();
|
||||
inline string& note() noexcept;
|
||||
|
||||
//- Rename
|
||||
virtual void rename(const word& newName)
|
||||
@ -393,22 +453,22 @@ public:
|
||||
}
|
||||
|
||||
//- Should object created with this IOobject be registered?
|
||||
inline bool registerObject() const;
|
||||
inline bool registerObject() const noexcept;
|
||||
|
||||
//- Should object created with this IOobject be registered?
|
||||
inline bool& registerObject();
|
||||
inline bool& registerObject() noexcept;
|
||||
|
||||
//- Is object same for all processors?
|
||||
inline bool globalObject() const;
|
||||
inline bool globalObject() const noexcept;
|
||||
|
||||
//- Is object same for all processors?
|
||||
inline bool& globalObject();
|
||||
inline bool& globalObject() noexcept;
|
||||
|
||||
//- The label byte-size, possibly read from the header
|
||||
inline unsigned labelByteSize() const;
|
||||
//- The sizeof (label) in bytes, possibly read from the header
|
||||
inline unsigned labelByteSize() const noexcept;
|
||||
|
||||
//- The scalar byte-size, possibly read from the header
|
||||
inline unsigned scalarByteSize() const;
|
||||
//- The sizeof (scalar) in bytes, possibly read from the header
|
||||
inline unsigned scalarByteSize() const noexcept;
|
||||
|
||||
|
||||
// Checks
|
||||
@ -421,19 +481,25 @@ public:
|
||||
inline bool isHeaderClassName() const;
|
||||
|
||||
|
||||
// Meta-data
|
||||
|
||||
//- Return pointer to meta-data (if any) or nullptr
|
||||
virtual const dictionary* findMetaData() const noexcept;
|
||||
|
||||
|
||||
// Read/write options
|
||||
|
||||
//- The read option
|
||||
inline readOption readOpt() const;
|
||||
inline readOption readOpt() const noexcept;
|
||||
|
||||
//- Non-constant access to the read option
|
||||
inline readOption& readOpt();
|
||||
inline readOption& readOpt() noexcept;
|
||||
|
||||
//- The write option
|
||||
inline writeOption writeOpt() const;
|
||||
inline writeOption writeOpt() const noexcept;
|
||||
|
||||
//- Non-constant access to the write option
|
||||
inline writeOption& writeOpt();
|
||||
inline writeOption& writeOpt() noexcept;
|
||||
|
||||
|
||||
// Path components
|
||||
@ -448,11 +514,11 @@ public:
|
||||
|
||||
const fileName& caseName() const;
|
||||
|
||||
inline const fileName& instance() const;
|
||||
inline const fileName& instance() const noexcept;
|
||||
|
||||
inline fileName& instance();
|
||||
inline fileName& instance() noexcept;
|
||||
|
||||
inline const fileName& local() const;
|
||||
inline const fileName& local() const noexcept;
|
||||
|
||||
//- The complete path
|
||||
fileName path() const;
|
||||
@ -488,9 +554,19 @@ public:
|
||||
|
||||
// Reading
|
||||
|
||||
//- Read header
|
||||
//- Parse 'FoamFile' header contents and set the IOobject
|
||||
//- characteristics and return the stream characteristics.
|
||||
IOstreamOption parseHeader(const dictionary& headerDict);
|
||||
|
||||
//- Read header ('FoamFile' dictionary) and set the
|
||||
//- IOobject and stream characteristics.
|
||||
bool readHeader(Istream& is);
|
||||
|
||||
//- Read header (the 'FoamFile' dictionary) and set the
|
||||
//- IOobject and stream characteristics.
|
||||
// Saves the header content in the given dictionary.
|
||||
bool readHeader(dictionary& headerDict, Istream& is);
|
||||
|
||||
//- Read header (uses typeFilePath to find file) and check its info.
|
||||
// Optionally checks headerClassName against the type-name.
|
||||
// When search is false, simply use the current instance,
|
||||
@ -520,24 +596,31 @@ public:
|
||||
//- Write the standard end file divider
|
||||
static Ostream& writeEndDivider(Ostream& os);
|
||||
|
||||
//- Write header with current type() and arch information
|
||||
//- Write header with current type()
|
||||
bool writeHeader(Ostream& os) const;
|
||||
|
||||
//- Write header with override of type and optionally without
|
||||
//- arch information in ASCII
|
||||
bool writeHeader
|
||||
//- Write header with override of type
|
||||
bool writeHeader(Ostream& os, const word& objectType) const;
|
||||
|
||||
//- Write header into a dictionary with current type()
|
||||
//- and given output format
|
||||
void writeHeader(dictionary& dict, IOstreamOption streamOpt) const;
|
||||
|
||||
//- Write header into a dictionary with override of type
|
||||
//- and given output format
|
||||
void writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
dictionary& dict,
|
||||
const word& objectType,
|
||||
const bool noArchAscii = false
|
||||
IOstreamOption streamOpt
|
||||
) const;
|
||||
|
||||
|
||||
// Error Handling
|
||||
|
||||
inline bool good() const;
|
||||
inline bool good() const noexcept;
|
||||
|
||||
inline bool bad() const;
|
||||
inline bool bad() const noexcept;
|
||||
|
||||
|
||||
// Info
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -67,7 +67,7 @@ inline Foam::word Foam::IOobject::scopedName
|
||||
|
||||
// General access
|
||||
|
||||
inline const Foam::word& Foam::IOobject::name() const
|
||||
inline const Foam::word& Foam::IOobject::name() const noexcept
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
@ -85,63 +85,63 @@ inline Foam::word Foam::IOobject::member() const
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::word& Foam::IOobject::headerClassName() const
|
||||
inline const Foam::word& Foam::IOobject::headerClassName() const noexcept
|
||||
{
|
||||
return headerClassName_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::word& Foam::IOobject::headerClassName()
|
||||
inline Foam::word& Foam::IOobject::headerClassName() noexcept
|
||||
{
|
||||
return headerClassName_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::string& Foam::IOobject::note() const
|
||||
inline const Foam::string& Foam::IOobject::note() const noexcept
|
||||
{
|
||||
return note_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::string& Foam::IOobject::note()
|
||||
inline Foam::string& Foam::IOobject::note() noexcept
|
||||
{
|
||||
return note_;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::IOobject::registerObject() const
|
||||
inline bool Foam::IOobject::registerObject() const noexcept
|
||||
{
|
||||
return registerObject_;
|
||||
}
|
||||
|
||||
|
||||
inline bool& Foam::IOobject::registerObject()
|
||||
inline bool& Foam::IOobject::registerObject() noexcept
|
||||
{
|
||||
return registerObject_;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::IOobject::globalObject() const
|
||||
inline bool Foam::IOobject::globalObject() const noexcept
|
||||
{
|
||||
return globalObject_;
|
||||
}
|
||||
|
||||
|
||||
inline bool& Foam::IOobject::globalObject()
|
||||
inline bool& Foam::IOobject::globalObject() noexcept
|
||||
{
|
||||
return globalObject_;
|
||||
}
|
||||
|
||||
|
||||
inline unsigned Foam::IOobject::labelByteSize() const
|
||||
inline unsigned Foam::IOobject::labelByteSize() const noexcept
|
||||
{
|
||||
return labelByteSize_;
|
||||
return static_cast<unsigned>(sizeofLabel_);
|
||||
}
|
||||
|
||||
|
||||
inline unsigned Foam::IOobject::scalarByteSize() const
|
||||
inline unsigned Foam::IOobject::scalarByteSize() const noexcept
|
||||
{
|
||||
return scalarByteSize_;
|
||||
return static_cast<unsigned>(sizeofScalar_);
|
||||
}
|
||||
|
||||
|
||||
@ -162,25 +162,25 @@ inline bool Foam::IOobject::isHeaderClassName() const
|
||||
|
||||
// Read/write options
|
||||
|
||||
inline Foam::IOobject::readOption Foam::IOobject::readOpt() const
|
||||
inline Foam::IOobject::readOption Foam::IOobject::readOpt() const noexcept
|
||||
{
|
||||
return rOpt_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::IOobject::readOption& Foam::IOobject::readOpt()
|
||||
inline Foam::IOobject::readOption& Foam::IOobject::readOpt() noexcept
|
||||
{
|
||||
return rOpt_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::IOobject::writeOption Foam::IOobject::writeOpt() const
|
||||
inline Foam::IOobject::writeOption Foam::IOobject::writeOpt() const noexcept
|
||||
{
|
||||
return wOpt_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::IOobject::writeOption& Foam::IOobject::writeOpt()
|
||||
inline Foam::IOobject::writeOption& Foam::IOobject::writeOpt() noexcept
|
||||
{
|
||||
return wOpt_;
|
||||
}
|
||||
@ -188,19 +188,19 @@ inline Foam::IOobject::writeOption& Foam::IOobject::writeOpt()
|
||||
|
||||
// Path components
|
||||
|
||||
inline const Foam::fileName& Foam::IOobject::instance() const
|
||||
inline const Foam::fileName& Foam::IOobject::instance() const noexcept
|
||||
{
|
||||
return instance_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::fileName& Foam::IOobject::instance()
|
||||
inline Foam::fileName& Foam::IOobject::instance() noexcept
|
||||
{
|
||||
return instance_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::fileName& Foam::IOobject::local() const
|
||||
inline const Foam::fileName& Foam::IOobject::local() const noexcept
|
||||
{
|
||||
return local_;
|
||||
}
|
||||
@ -214,13 +214,13 @@ inline Foam::fileName Foam::IOobject::objectPath() const
|
||||
|
||||
// Error Handling
|
||||
|
||||
inline bool Foam::IOobject::good() const
|
||||
inline bool Foam::IOobject::good() const noexcept
|
||||
{
|
||||
return objState_ == GOOD;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::IOobject::bad() const
|
||||
inline bool Foam::IOobject::bad() const noexcept
|
||||
{
|
||||
return objState_ == BAD;
|
||||
}
|
||||
|
||||
39
src/OpenFOAM/db/IOobject/IOobjectMetaData.C
Normal file
39
src/OpenFOAM/db/IOobject/IOobjectMetaData.C
Normal file
@ -0,0 +1,39 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IOobject.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::dictionary* Foam::IOobject::findMetaData() const noexcept
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -32,7 +32,45 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::IOobject::readHeader(Istream& is)
|
||||
Foam::IOstreamOption Foam::IOobject::parseHeader(const dictionary& headerDict)
|
||||
{
|
||||
IOstreamOption streamOpt; // == (ASCII, currentVersion)
|
||||
|
||||
// Treat "version" as optional
|
||||
{
|
||||
token tok;
|
||||
if (headerDict.readIfPresent("version", tok))
|
||||
{
|
||||
streamOpt.version(tok);
|
||||
}
|
||||
}
|
||||
|
||||
// Treat "format" as mandatory, could also as optional
|
||||
streamOpt.format(headerDict.get<word>("format"));
|
||||
|
||||
headerClassName_ = headerDict.get<word>("class");
|
||||
|
||||
const word headerObject(headerDict.get<word>("object"));
|
||||
|
||||
// The "note" entry is optional
|
||||
headerDict.readIfPresent("note", note_);
|
||||
|
||||
// The "arch" information may be missing
|
||||
string arch;
|
||||
if (headerDict.readIfPresent("arch", arch))
|
||||
{
|
||||
unsigned val = foamVersion::labelByteSize(arch);
|
||||
if (val) sizeofLabel_ = static_cast<unsigned char>(val);
|
||||
|
||||
val = foamVersion::scalarByteSize(arch);
|
||||
if (val) sizeofScalar_ = static_cast<unsigned char>(val);
|
||||
}
|
||||
|
||||
return streamOpt;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is)
|
||||
{
|
||||
if (IOobject::debug)
|
||||
{
|
||||
@ -64,48 +102,21 @@ bool Foam::IOobject::readHeader(Istream& is)
|
||||
|
||||
if (is.good() && firstToken.isWord("FoamFile"))
|
||||
{
|
||||
const dictionary headerDict(is);
|
||||
headerDict.read(is, false); // Read sub-dictionary content
|
||||
|
||||
is.version(headerDict.get<token>("version"));
|
||||
is.format(headerDict.get<word>("format"));
|
||||
IOstreamOption streamOpt = parseHeader(headerDict);
|
||||
|
||||
headerClassName_ = headerDict.get<word>("class");
|
||||
|
||||
const word headerObject(headerDict.get<word>("object"));
|
||||
|
||||
if (IOobject::debug && headerObject != name())
|
||||
{
|
||||
IOWarningInFunction(is)
|
||||
<< " object renamed from "
|
||||
<< name() << " to " << headerObject
|
||||
<< " for file " << is.name() << endl;
|
||||
}
|
||||
|
||||
// The note entry is optional
|
||||
headerDict.readIfPresent("note", note_);
|
||||
|
||||
labelByteSize_ = sizeof(label);
|
||||
scalarByteSize_ = sizeof(scalar);
|
||||
|
||||
// The arch information is optional
|
||||
string arch;
|
||||
if (headerDict.readIfPresent("arch", arch))
|
||||
{
|
||||
unsigned val = foamVersion::labelByteSize(arch);
|
||||
if (val) labelByteSize_ = val;
|
||||
|
||||
val = foamVersion::scalarByteSize(arch);
|
||||
if (val) scalarByteSize_ = val;
|
||||
}
|
||||
|
||||
is.setLabelByteSize(labelByteSize_);
|
||||
is.setScalarByteSize(scalarByteSize_);
|
||||
is.format(streamOpt.format());
|
||||
is.version(streamOpt.version());
|
||||
is.setLabelByteSize(sizeofLabel_);
|
||||
is.setScalarByteSize(sizeofScalar_);
|
||||
}
|
||||
else
|
||||
{
|
||||
IOWarningInFunction(is)
|
||||
<< "First token could not be read or is not the keyword 'FoamFile'"
|
||||
<< nl << nl << "Check header is of the form:" << nl << endl;
|
||||
<< "First token could not be read or is not 'FoamFile'"
|
||||
<< nl << nl
|
||||
<< "Check header is of the form:" << nl << endl;
|
||||
|
||||
writeHeader(Info);
|
||||
|
||||
@ -151,4 +162,11 @@ bool Foam::IOobject::readHeader(Istream& is)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::IOobject::readHeader(Istream& is)
|
||||
{
|
||||
dictionary headerDict;
|
||||
return IOobject::readHeader(headerDict, is);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -27,10 +27,40 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IOobject.H"
|
||||
#include "dictionary.H"
|
||||
#include "objectRegistry.H"
|
||||
#include "foamVersion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
inline void writeSpaces(Ostream& os, label nSpaces)
|
||||
{
|
||||
if (nSpaces < 1)
|
||||
{
|
||||
nSpaces = 1;
|
||||
}
|
||||
while (nSpaces--)
|
||||
{
|
||||
os.write(char(token::SPACE));
|
||||
}
|
||||
}
|
||||
|
||||
// Similar to writeEntry, but with fewer spaces
|
||||
template<class T>
|
||||
inline void writeHeaderEntry(Ostream& os, const word& key, const T& value)
|
||||
{
|
||||
os << indent << key;
|
||||
writeSpaces(os, 12 - label(key.size()));
|
||||
os << value << char(token::END_STATEMENT) << nl;
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
// A banner corresponding to this:
|
||||
//
|
||||
@ -117,11 +147,93 @@ Foam::Ostream& Foam::IOobject::writeEndDivider(Ostream& os)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::IOobject::writeHeaderContent
|
||||
(
|
||||
Ostream& os,
|
||||
const IOobject& io,
|
||||
const word& objectType,
|
||||
const dictionary* metaDataDict
|
||||
)
|
||||
{
|
||||
// Standard header entries
|
||||
writeHeaderEntry(os, "version", os.version());
|
||||
writeHeaderEntry(os, "format", os.format());
|
||||
writeHeaderEntry(os, "arch", foamVersion::buildArch);
|
||||
|
||||
if (!io.note().empty())
|
||||
{
|
||||
writeHeaderEntry(os, "note", io.note());
|
||||
}
|
||||
|
||||
if (objectType.empty())
|
||||
{
|
||||
// Empty type not allowed - use 'dictionary' fallback
|
||||
writeHeaderEntry(os, "class", word("dictionary"));
|
||||
}
|
||||
else
|
||||
{
|
||||
writeHeaderEntry(os, "class", objectType);
|
||||
}
|
||||
|
||||
writeHeaderEntry(os, "location", io.instance()/io.db().dbDir()/io.local());
|
||||
writeHeaderEntry(os, "object", io.name());
|
||||
|
||||
// Meta-data (if any)
|
||||
if (metaDataDict && !metaDataDict->empty())
|
||||
{
|
||||
metaDataDict->writeEntry("meta", os);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::IOobject::writeHeaderContent
|
||||
(
|
||||
dictionary& dict,
|
||||
const IOobject& io,
|
||||
const word& objectType,
|
||||
IOstreamOption streamOpt,
|
||||
const dictionary* metaDataDict
|
||||
)
|
||||
{
|
||||
// Standard header entries
|
||||
dict.set("version", streamOpt.version());
|
||||
dict.set("format", streamOpt.format());
|
||||
dict.set("arch", foamVersion::buildArch);
|
||||
|
||||
if (!io.note().empty())
|
||||
{
|
||||
dict.set("note", io.note());
|
||||
}
|
||||
|
||||
if (objectType.empty())
|
||||
{
|
||||
// Empty type not allowed - use 'dictionary' fallback
|
||||
dict.set("class", word("dictionary"));
|
||||
}
|
||||
else
|
||||
{
|
||||
dict.set("class", objectType);
|
||||
}
|
||||
|
||||
dict.set("location", io.instance()/io.db().dbDir()/io.local());
|
||||
dict.set("object", io.name());
|
||||
|
||||
// Deep-copy of meta-data (if any)
|
||||
if (metaDataDict && !metaDataDict->empty())
|
||||
{
|
||||
dict.add("meta", *metaDataDict);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::IOobject::writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
const word& objectType,
|
||||
const bool noArchAscii
|
||||
const word& objectType
|
||||
) const
|
||||
{
|
||||
if (!os.good())
|
||||
@ -133,39 +245,28 @@ bool Foam::IOobject::writeHeader
|
||||
return false;
|
||||
}
|
||||
|
||||
IOobject::writeBanner(os)
|
||||
<< "FoamFile" << nl
|
||||
<< '{' << nl
|
||||
<< " version " << os.version() << ';' << nl
|
||||
<< " format " << os.format() << ';' << nl;
|
||||
|
||||
if (os.format() == IOstream::BINARY || !noArchAscii)
|
||||
if (IOobject::bannerEnabled())
|
||||
{
|
||||
// Arch information (BINARY: always, ASCII: can disable)
|
||||
os << " arch " << foamVersion::buildArch << ';' << nl;
|
||||
}
|
||||
if (!note().empty())
|
||||
{
|
||||
os << " note " << note() << ';' << nl;
|
||||
IOobject::writeBanner(os);
|
||||
}
|
||||
|
||||
os << " class ";
|
||||
if (objectType.empty())
|
||||
{
|
||||
// Empty type not allowed - use 'dictionary' fallback
|
||||
os << "dictionary";
|
||||
}
|
||||
else
|
||||
{
|
||||
os << objectType;
|
||||
}
|
||||
os << ';' << nl;
|
||||
os.beginBlock("FoamFile");
|
||||
|
||||
os << " location " << instance()/db().dbDir()/local() << ';' << nl
|
||||
<< " object " << name() << ';' << nl
|
||||
<< '}' << nl;
|
||||
// Standard header entries
|
||||
IOobject::writeHeaderContent
|
||||
(
|
||||
os,
|
||||
*this,
|
||||
objectType,
|
||||
this->findMetaData()
|
||||
);
|
||||
|
||||
writeDivider(os) << nl;
|
||||
os.endBlock();
|
||||
|
||||
if (IOobject::bannerEnabled())
|
||||
{
|
||||
IOobject::writeDivider(os) << nl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -173,7 +274,35 @@ bool Foam::IOobject::writeHeader
|
||||
|
||||
bool Foam::IOobject::writeHeader(Ostream& os) const
|
||||
{
|
||||
return writeHeader(os, type());
|
||||
return IOobject::writeHeader(os, this->type());
|
||||
}
|
||||
|
||||
|
||||
void Foam::IOobject::writeHeader
|
||||
(
|
||||
dictionary& dict,
|
||||
const word& objectType,
|
||||
IOstreamOption streamOpt
|
||||
) const
|
||||
{
|
||||
IOobject::writeHeaderContent
|
||||
(
|
||||
dict,
|
||||
*this,
|
||||
objectType,
|
||||
streamOpt,
|
||||
this->findMetaData()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::IOobject::writeHeader
|
||||
(
|
||||
dictionary& dict,
|
||||
IOstreamOption streamOpt
|
||||
) const
|
||||
{
|
||||
IOobject::writeHeader(dict, this->type(), streamOpt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -34,10 +34,11 @@ License
|
||||
#include "dictionary.H"
|
||||
#include "objectRegistry.H"
|
||||
#include "SubList.H"
|
||||
#include "charList.H"
|
||||
#include "labelPair.H"
|
||||
#include "masterUncollatedFileOperation.H"
|
||||
#include "IListStream.H"
|
||||
#include "foamVersion.H"
|
||||
#include "ListStream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -46,6 +47,30 @@ namespace Foam
|
||||
defineTypeNameAndDebug(decomposedBlockData, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::decomposedBlockData::isCollatedType
|
||||
(
|
||||
const word& objectType
|
||||
)
|
||||
{
|
||||
return
|
||||
(
|
||||
objectType == decomposedBlockData::typeName
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::decomposedBlockData::isCollatedType
|
||||
(
|
||||
const IOobject& io
|
||||
)
|
||||
{
|
||||
return decomposedBlockData::isCollatedType(io.headerClassName());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::decomposedBlockData::decomposedBlockData
|
||||
@ -57,7 +82,8 @@ Foam::decomposedBlockData::decomposedBlockData
|
||||
:
|
||||
regIOobject(io),
|
||||
commsType_(commsType),
|
||||
comm_(comm)
|
||||
comm_(comm),
|
||||
contentData_()
|
||||
{
|
||||
// Temporary warning
|
||||
if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
|
||||
@ -82,162 +108,125 @@ Foam::decomposedBlockData::decomposedBlockData
|
||||
}
|
||||
|
||||
|
||||
Foam::decomposedBlockData::decomposedBlockData
|
||||
(
|
||||
const label comm,
|
||||
const IOobject& io,
|
||||
const UList<char>& list,
|
||||
const UPstream::commsTypes commsType
|
||||
)
|
||||
:
|
||||
regIOobject(io),
|
||||
commsType_(commsType),
|
||||
comm_(comm)
|
||||
{
|
||||
// Temporary warning
|
||||
if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "decomposedBlockData " << name()
|
||||
<< " constructed with IOobject::MUST_READ_IF_MODIFIED"
|
||||
" but decomposedBlockData does not support automatic rereading."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
read();
|
||||
}
|
||||
else
|
||||
{
|
||||
List<char>::operator=(list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::decomposedBlockData::decomposedBlockData
|
||||
(
|
||||
const label comm,
|
||||
const IOobject& io,
|
||||
List<char>&& list,
|
||||
const UPstream::commsTypes commsType
|
||||
)
|
||||
:
|
||||
regIOobject(io),
|
||||
commsType_(commsType),
|
||||
comm_(comm)
|
||||
{
|
||||
// Temporary warning
|
||||
if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "decomposedBlockData " << name()
|
||||
<< " constructed with IOobject::MUST_READ_IF_MODIFIED"
|
||||
" but decomposedBlockData does not support automatic rereading."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
List<char>::transfer(list);
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
read();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Members Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::decomposedBlockData::readMasterHeader(IOobject& io, Istream& is)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "decomposedBlockData::readMasterHeader:"
|
||||
<< " stream:" << is.name() << endl;
|
||||
}
|
||||
|
||||
// Master-only reading of header
|
||||
is.fatalCheck("read(Istream&)");
|
||||
|
||||
List<char> data(is);
|
||||
is.fatalCheck("read(Istream&) : reading entry");
|
||||
|
||||
UIListStream headerStream(data);
|
||||
headerStream.name() = is.name();
|
||||
|
||||
return io.readHeader(headerStream);
|
||||
}
|
||||
|
||||
|
||||
void Foam::decomposedBlockData::writeHeader
|
||||
bool Foam::decomposedBlockData::readBlockEntry
|
||||
(
|
||||
Ostream& os,
|
||||
const IOstream::versionNumber version,
|
||||
const IOstream::streamFormat format,
|
||||
const word& objectType,
|
||||
const string& note,
|
||||
const fileName& location,
|
||||
const word& objectName
|
||||
Istream& is,
|
||||
List<char>& charData
|
||||
)
|
||||
{
|
||||
IOobject::writeBanner(os)
|
||||
<< "FoamFile" << nl
|
||||
<< '{' << nl
|
||||
<< " version " << version << ';' << nl
|
||||
<< " format " << format << ';' << nl
|
||||
<< " arch " << foamVersion::buildArch << ';' << nl;
|
||||
// Handle any of these:
|
||||
|
||||
if (Pstream::parRun())
|
||||
// 0. NCHARS (...)
|
||||
// 1. List<char> NCHARS (...)
|
||||
// 2. processorN List<char> NCHARS (...) ;
|
||||
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
token tok(is);
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
// Dictionary format has primitiveEntry keyword:
|
||||
const bool isDictFormat = (tok.isWord() && !tok.isCompound());
|
||||
|
||||
if (!isDictFormat && tok.good())
|
||||
{
|
||||
os << " blocks " << Pstream::nProcs() << ';' << nl;
|
||||
is.putBack(tok);
|
||||
}
|
||||
if (!note.empty())
|
||||
charData.readList(is);
|
||||
|
||||
if (isDictFormat)
|
||||
{
|
||||
os << " note " << note << ';' << nl;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
is >> tok;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
// Swallow trailing ';'
|
||||
if (tok.good() && !tok.isPunctuation(token::END_STATEMENT))
|
||||
{
|
||||
is.putBack(tok);
|
||||
}
|
||||
}
|
||||
|
||||
os << " class ";
|
||||
if (objectType.empty())
|
||||
{
|
||||
// Empty type not allowed - use 'dictionary' fallback
|
||||
os << "dictionary";
|
||||
}
|
||||
else
|
||||
{
|
||||
os << objectType;
|
||||
}
|
||||
os << ';' << nl;
|
||||
|
||||
if (!location.empty())
|
||||
{
|
||||
os << " location " << location << ';' << nl;
|
||||
}
|
||||
|
||||
os << " object " << objectName << ';' << nl
|
||||
<< '}' << nl;
|
||||
|
||||
IOobject::writeDivider(os) << nl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlock
|
||||
std::streamoff Foam::decomposedBlockData::writeBlockEntry
|
||||
(
|
||||
OSstream& os,
|
||||
const label blocki,
|
||||
const UList<char>& charData
|
||||
)
|
||||
{
|
||||
// Offset to the beginning of this output
|
||||
|
||||
std::streamoff blockOffset = os.stdStream().tellp();
|
||||
|
||||
const word procName("processor" + Foam::name(blocki));
|
||||
|
||||
{
|
||||
os << nl << "// " << procName << nl;
|
||||
charData.writeList(os) << nl;
|
||||
}
|
||||
|
||||
return blockOffset;
|
||||
}
|
||||
|
||||
|
||||
std::streamoff Foam::decomposedBlockData::writeBlockEntry
|
||||
(
|
||||
OSstream& os,
|
||||
IOstreamOption streamOptData,
|
||||
const regIOobject& io,
|
||||
const label blocki,
|
||||
const bool withLocalHeader
|
||||
)
|
||||
{
|
||||
// String(s) from all data to write
|
||||
string contentChars;
|
||||
{
|
||||
OStringStream os(streamOptData);
|
||||
|
||||
bool ok = true;
|
||||
|
||||
// Generate FoamFile header on master, without comment banner
|
||||
if (withLocalHeader)
|
||||
{
|
||||
const bool old = IOobject::bannerEnabled(false);
|
||||
|
||||
ok = io.writeHeader(os);
|
||||
|
||||
IOobject::bannerEnabled(old);
|
||||
}
|
||||
|
||||
// Write the data to the Ostream
|
||||
ok = ok && io.writeData(os);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
return std::streamoff(-1);
|
||||
}
|
||||
|
||||
contentChars = os.str();
|
||||
}
|
||||
|
||||
// The character data
|
||||
UList<char> charData
|
||||
(
|
||||
const_cast<char*>(contentChars.data()),
|
||||
label(contentChars.size())
|
||||
);
|
||||
|
||||
return decomposedBlockData::writeBlockEntry(os, blocki, charData);
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::ISstream>
|
||||
Foam::decomposedBlockData::readBlock
|
||||
(
|
||||
const label blocki,
|
||||
Istream& is,
|
||||
ISstream& is,
|
||||
IOobject& headerIO
|
||||
)
|
||||
{
|
||||
@ -248,66 +237,64 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlock
|
||||
<< endl;
|
||||
}
|
||||
|
||||
is.fatalCheck("read(Istream&)");
|
||||
// Extracted header information
|
||||
IOstreamOption streamOptData;
|
||||
unsigned labelWidth = is.labelByteSize();
|
||||
unsigned scalarWidth = is.scalarByteSize();
|
||||
|
||||
autoPtr<ISstream> realIsPtr;
|
||||
|
||||
// Read master for header
|
||||
List<char> data;
|
||||
decomposedBlockData::readBlockEntry(is, data);
|
||||
|
||||
if (blocki == 0)
|
||||
{
|
||||
List<char> data(is);
|
||||
is.fatalCheck("read(Istream&) : reading entry");
|
||||
|
||||
realIsPtr.reset(new IListStream(std::move(data)));
|
||||
realIsPtr->name() = is.name();
|
||||
|
||||
// Read header
|
||||
if (!headerIO.readHeader(*realIsPtr))
|
||||
{
|
||||
FatalIOErrorInFunction(*realIsPtr)
|
||||
<< "problem while reading header for object "
|
||||
<< is.name() << exit(FatalIOError);
|
||||
// Read header from first block,
|
||||
// advancing the stream position
|
||||
if (!headerIO.readHeader(*realIsPtr))
|
||||
{
|
||||
FatalIOErrorInFunction(*realIsPtr)
|
||||
<< "Problem while reading header for object "
|
||||
<< is.name() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read master for header
|
||||
List<char> data(is);
|
||||
is.fatalCheck("read(Istream&) : reading entry");
|
||||
|
||||
IOstream::versionNumber ver(IOstream::currentVersion);
|
||||
IOstream::streamFormat fmt;
|
||||
unsigned labelByteSize;
|
||||
unsigned scalarByteSize;
|
||||
{
|
||||
// Read header from first block
|
||||
UIListStream headerStream(data);
|
||||
|
||||
// Read header
|
||||
if (!headerIO.readHeader(headerStream))
|
||||
{
|
||||
FatalIOErrorInFunction(headerStream)
|
||||
<< "problem while reading header for object "
|
||||
<< is.name() << exit(FatalIOError);
|
||||
<< "Problem while reading header for object "
|
||||
<< is.name() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
ver = headerStream.version();
|
||||
fmt = headerStream.format();
|
||||
labelByteSize = headerStream.labelByteSize();
|
||||
scalarByteSize = headerStream.scalarByteSize();
|
||||
streamOptData = static_cast<IOstreamOption>(headerStream);
|
||||
labelWidth = headerStream.labelByteSize();
|
||||
scalarWidth = headerStream.scalarByteSize();
|
||||
}
|
||||
|
||||
for (label i = 1; i < blocki+1; i++)
|
||||
{
|
||||
// Read and discard data, only retain the last one
|
||||
is >> data;
|
||||
is.fatalCheck("read(Istream&) : reading entry");
|
||||
decomposedBlockData::readBlockEntry(is, data);
|
||||
}
|
||||
realIsPtr.reset(new IListStream(std::move(data)));
|
||||
realIsPtr->name() = is.name();
|
||||
|
||||
// Apply master stream settings to realIsPtr
|
||||
realIsPtr().format(fmt);
|
||||
realIsPtr().version(ver);
|
||||
realIsPtr().setLabelByteSize(labelByteSize);
|
||||
realIsPtr().setScalarByteSize(scalarByteSize);
|
||||
// Apply stream settings
|
||||
realIsPtr().format(streamOptData.format());
|
||||
realIsPtr().version(streamOptData.version());
|
||||
realIsPtr().setLabelByteSize(labelWidth);
|
||||
realIsPtr().setScalarByteSize(scalarWidth);
|
||||
}
|
||||
|
||||
return realIsPtr;
|
||||
@ -332,24 +319,28 @@ bool Foam::decomposedBlockData::readBlocks
|
||||
|
||||
bool ok = false;
|
||||
|
||||
if (UPstream::master(comm))
|
||||
{
|
||||
auto& is = *isPtr;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
// Read master data
|
||||
decomposedBlockData::readBlockEntry(is, data);
|
||||
}
|
||||
|
||||
if (commsType == UPstream::commsTypes::scheduled)
|
||||
{
|
||||
if (UPstream::master(comm))
|
||||
{
|
||||
Istream& is = *isPtr;
|
||||
is.fatalCheck("read(Istream&)");
|
||||
// Master data already read ...
|
||||
auto& is = *isPtr;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
// Read master data
|
||||
{
|
||||
is >> data;
|
||||
is.fatalCheck("read(Istream&) : reading entry");
|
||||
}
|
||||
|
||||
// Read slave data
|
||||
// Read and transmit slave data
|
||||
for (const int proci : UPstream::subProcs(comm))
|
||||
{
|
||||
List<char> elems(is);
|
||||
is.fatalCheck("read(Istream&) : reading entry");
|
||||
List<char> elems;
|
||||
decomposedBlockData::readBlockEntry(is, elems);
|
||||
|
||||
OPstream os
|
||||
(
|
||||
@ -388,20 +379,15 @@ bool Foam::decomposedBlockData::readBlocks
|
||||
|
||||
if (UPstream::master(comm))
|
||||
{
|
||||
Istream& is = *isPtr;
|
||||
is.fatalCheck("read(Istream&)");
|
||||
// Master data already read ...
|
||||
auto& is = *isPtr;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
// Read master data
|
||||
{
|
||||
is >> data;
|
||||
is.fatalCheck("read(Istream&) : reading entry");
|
||||
}
|
||||
|
||||
// Read slave data
|
||||
// Read and transmit slave data
|
||||
for (const int proci : UPstream::subProcs(comm))
|
||||
{
|
||||
List<char> elems(is);
|
||||
is.fatalCheck("read(Istream&) : reading entry");
|
||||
List<char> elems;
|
||||
decomposedBlockData::readBlockEntry(is, elems);
|
||||
|
||||
UOPstream os(proci, pBufs);
|
||||
os << elems;
|
||||
@ -441,39 +427,45 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
|
||||
List<char> data;
|
||||
autoPtr<ISstream> realIsPtr;
|
||||
|
||||
if (UPstream::master(comm))
|
||||
{
|
||||
auto& is = *isPtr;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
// Read master data
|
||||
decomposedBlockData::readBlockEntry(is, data);
|
||||
|
||||
realIsPtr.reset(new IListStream(std::move(data)));
|
||||
realIsPtr->name() = fName;
|
||||
|
||||
{
|
||||
// Read header from first block,
|
||||
// advancing the stream position
|
||||
if (!headerIO.readHeader(*realIsPtr))
|
||||
{
|
||||
FatalIOErrorInFunction(*realIsPtr)
|
||||
<< "Problem while reading header for object "
|
||||
<< is.name() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (commsType == UPstream::commsTypes::scheduled)
|
||||
{
|
||||
if (UPstream::master(comm))
|
||||
{
|
||||
Istream& is = *isPtr;
|
||||
is.fatalCheck("read(Istream&)");
|
||||
// Master data already read ...
|
||||
auto& is = *isPtr;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
// Read master data
|
||||
{
|
||||
is >> data;
|
||||
is.fatalCheck("read(Istream&) : reading entry");
|
||||
|
||||
realIsPtr.reset(new IListStream(std::move(data)));
|
||||
realIsPtr->name() = fName;
|
||||
|
||||
// Read header
|
||||
if (!headerIO.readHeader(*realIsPtr))
|
||||
{
|
||||
FatalIOErrorInFunction(*realIsPtr)
|
||||
<< "problem while reading header for object "
|
||||
<< is.name() << exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
// Read slave data
|
||||
// Read and transmit slave data
|
||||
for (const int proci : UPstream::subProcs(comm))
|
||||
{
|
||||
is >> data;
|
||||
is.fatalCheck("read(Istream&) : reading entry");
|
||||
decomposedBlockData::readBlockEntry(is, data);
|
||||
|
||||
OPstream os
|
||||
(
|
||||
@ -515,31 +507,15 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks
|
||||
|
||||
if (UPstream::master(comm))
|
||||
{
|
||||
Istream& is = *isPtr;
|
||||
is.fatalCheck("read(Istream&)");
|
||||
// Master data already read ...
|
||||
auto& is = *isPtr;
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
// Read master data
|
||||
{
|
||||
is >> data;
|
||||
is.fatalCheck("read(Istream&) : reading entry");
|
||||
|
||||
realIsPtr.reset(new IListStream(std::move(data)));
|
||||
realIsPtr->name() = fName;
|
||||
|
||||
// Read header
|
||||
if (!headerIO.readHeader(*realIsPtr))
|
||||
{
|
||||
FatalIOErrorInFunction(*realIsPtr)
|
||||
<< "problem while reading header for object "
|
||||
<< is.name() << exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
// Read slave data
|
||||
// Read and transmit slave data
|
||||
for (const int proci : UPstream::subProcs(comm))
|
||||
{
|
||||
List<char> elems(is);
|
||||
is.fatalCheck("read(Istream&) : reading entry");
|
||||
List<char> elems;
|
||||
decomposedBlockData::readBlockEntry(is, elems);
|
||||
|
||||
UOPstream os(proci, pBufs);
|
||||
os << elems;
|
||||
@ -566,26 +542,26 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks
|
||||
//- Set stream properties from realIsPtr on master
|
||||
|
||||
// Scatter master header info
|
||||
string versionString;
|
||||
label formatValue;
|
||||
unsigned labelByteSize;
|
||||
unsigned scalarByteSize;
|
||||
int verValue;
|
||||
int fmtValue;
|
||||
unsigned labelWidth;
|
||||
unsigned scalarWidth;
|
||||
if (UPstream::master(comm))
|
||||
{
|
||||
versionString = realIsPtr().version().str();
|
||||
formatValue = static_cast<label>(realIsPtr().format());
|
||||
labelByteSize = realIsPtr().labelByteSize();
|
||||
scalarByteSize = realIsPtr().scalarByteSize();
|
||||
verValue = realIsPtr().version().canonical();
|
||||
fmtValue = static_cast<int>(realIsPtr().format());
|
||||
labelWidth = realIsPtr().labelByteSize();
|
||||
scalarWidth = realIsPtr().scalarByteSize();
|
||||
}
|
||||
Pstream::scatter(versionString); //, Pstream::msgType(), comm);
|
||||
Pstream::scatter(formatValue); //, Pstream::msgType(), comm);
|
||||
Pstream::scatter(labelByteSize); //, Pstream::msgType(), comm);
|
||||
Pstream::scatter(scalarByteSize); //, Pstream::msgType(), comm);
|
||||
Pstream::scatter(verValue); //, Pstream::msgType(), comm);
|
||||
Pstream::scatter(fmtValue); //, Pstream::msgType(), comm);
|
||||
Pstream::scatter(labelWidth); //, Pstream::msgType(), comm);
|
||||
Pstream::scatter(scalarWidth); //, Pstream::msgType(), comm);
|
||||
|
||||
realIsPtr().version(IOstream::versionNumber(versionString));
|
||||
realIsPtr().format(IOstream::streamFormat(formatValue));
|
||||
realIsPtr().setLabelByteSize(labelByteSize);
|
||||
realIsPtr().setScalarByteSize(scalarByteSize);
|
||||
realIsPtr().version(IOstreamOption::versionNumber::canonical(verValue));
|
||||
realIsPtr().format(IOstreamOption::streamFormat(fmtValue));
|
||||
realIsPtr().setLabelByteSize(labelWidth);
|
||||
realIsPtr().setScalarByteSize(scalarWidth);
|
||||
|
||||
word name(headerIO.name());
|
||||
Pstream::scatter(name, Pstream::msgType(), comm);
|
||||
@ -657,8 +633,8 @@ void Foam::decomposedBlockData::gatherSlaveData
|
||||
{
|
||||
const label numProcs = UPstream::nProcs(comm);
|
||||
|
||||
sliceSizes.setSize(numProcs, 0);
|
||||
sliceOffsets.setSize(numProcs+1, 0);
|
||||
sliceSizes.resize(numProcs, 0);
|
||||
sliceOffsets.resize(numProcs+1, 0);
|
||||
|
||||
int totalSize = 0;
|
||||
label proci = startProc;
|
||||
@ -742,8 +718,8 @@ bool Foam::decomposedBlockData::writeBlocks
|
||||
(
|
||||
const label comm,
|
||||
autoPtr<OSstream>& osPtr,
|
||||
List<std::streamoff>& start,
|
||||
const UList<char>& data,
|
||||
List<std::streamoff>& blockOffset,
|
||||
const UList<char>& masterData,
|
||||
|
||||
const labelUList& recvSizes,
|
||||
const PtrList<SubList<char>>& slaveData,
|
||||
@ -756,7 +732,7 @@ bool Foam::decomposedBlockData::writeBlocks
|
||||
{
|
||||
Pout<< "decomposedBlockData::writeBlocks:"
|
||||
<< " stream:" << (osPtr ? osPtr->name() : "invalid")
|
||||
<< " data:" << data.size()
|
||||
<< " data:" << masterData.size()
|
||||
<< " (master only) slaveData:" << slaveData.size()
|
||||
<< " commsType:" << Pstream::commsTypeNames[commsType] << endl;
|
||||
}
|
||||
@ -765,35 +741,43 @@ bool Foam::decomposedBlockData::writeBlocks
|
||||
|
||||
bool ok = true;
|
||||
|
||||
// Write master data
|
||||
if (UPstream::master(comm))
|
||||
{
|
||||
blockOffset.resize(nProcs);
|
||||
|
||||
OSstream& os = *osPtr;
|
||||
|
||||
blockOffset[UPstream::masterNo()] =
|
||||
decomposedBlockData::writeBlockEntry
|
||||
(
|
||||
os,
|
||||
UPstream::masterNo(),
|
||||
masterData
|
||||
);
|
||||
|
||||
ok = os.good();
|
||||
}
|
||||
|
||||
if (slaveData.size())
|
||||
{
|
||||
// Already have gathered the slave data. communicator only used to
|
||||
// check who is the master
|
||||
// Already have gathered the slave data.
|
||||
|
||||
if (UPstream::master(comm))
|
||||
{
|
||||
// Master data already written ...
|
||||
OSstream& os = *osPtr;
|
||||
|
||||
start.setSize(nProcs);
|
||||
|
||||
// Write master data
|
||||
{
|
||||
os << nl << "// Processor" << UPstream::masterNo() << nl;
|
||||
start[UPstream::masterNo()] = os.stdStream().tellp();
|
||||
os << data;
|
||||
}
|
||||
|
||||
// Write slaves
|
||||
|
||||
label slaveOffset = 0;
|
||||
|
||||
for (label proci = 1; proci < nProcs; ++proci)
|
||||
{
|
||||
os << nl << nl << "// Processor" << proci << nl;
|
||||
start[proci] = os.stdStream().tellp();
|
||||
|
||||
os << slaveData[proci];
|
||||
slaveOffset += recvSizes[proci];
|
||||
blockOffset[proci] =
|
||||
decomposedBlockData::writeBlockEntry
|
||||
(
|
||||
os,
|
||||
proci,
|
||||
slaveData[proci]
|
||||
);
|
||||
}
|
||||
|
||||
ok = os.good();
|
||||
@ -803,21 +787,14 @@ bool Foam::decomposedBlockData::writeBlocks
|
||||
{
|
||||
if (UPstream::master(comm))
|
||||
{
|
||||
start.setSize(nProcs);
|
||||
|
||||
// Master data already written ...
|
||||
OSstream& os = *osPtr;
|
||||
|
||||
// Write master data
|
||||
{
|
||||
os << nl << "// Processor" << UPstream::masterNo() << nl;
|
||||
start[UPstream::masterNo()] = os.stdStream().tellp();
|
||||
os << data;
|
||||
}
|
||||
// Write slaves
|
||||
List<char> elems;
|
||||
// Receive and write slaves
|
||||
DynamicList<char> elems;
|
||||
for (label proci = 1; proci < nProcs; ++proci)
|
||||
{
|
||||
elems.setSize(recvSizes[proci]);
|
||||
elems.resize(recvSizes[proci]);
|
||||
IPstream::read
|
||||
(
|
||||
UPstream::commsTypes::scheduled,
|
||||
@ -828,9 +805,13 @@ bool Foam::decomposedBlockData::writeBlocks
|
||||
comm
|
||||
);
|
||||
|
||||
os << nl << nl << "// Processor" << proci << nl;
|
||||
start[proci] = os.stdStream().tellp();
|
||||
os << elems;
|
||||
blockOffset[proci] =
|
||||
decomposedBlockData::writeBlockEntry
|
||||
(
|
||||
os,
|
||||
proci,
|
||||
elems
|
||||
);
|
||||
}
|
||||
|
||||
ok = os.good();
|
||||
@ -841,8 +822,8 @@ bool Foam::decomposedBlockData::writeBlocks
|
||||
(
|
||||
UPstream::commsTypes::scheduled,
|
||||
UPstream::masterNo(),
|
||||
data.cdata(),
|
||||
data.size_bytes(),
|
||||
masterData.cdata(),
|
||||
masterData.size_bytes(),
|
||||
Pstream::msgType(),
|
||||
comm
|
||||
);
|
||||
@ -850,18 +831,7 @@ bool Foam::decomposedBlockData::writeBlocks
|
||||
}
|
||||
else
|
||||
{
|
||||
// Write master data
|
||||
if (UPstream::master(comm))
|
||||
{
|
||||
start.setSize(nProcs);
|
||||
|
||||
OSstream& os = *osPtr;
|
||||
|
||||
os << nl << "// Processor" << UPstream::masterNo() << nl;
|
||||
start[UPstream::masterNo()] = os.stdStream().tellp();
|
||||
os << data;
|
||||
}
|
||||
|
||||
// Master data already written ...
|
||||
|
||||
// Find out how many processor can be received into
|
||||
// maxMasterFileBufferSize
|
||||
@ -896,11 +866,11 @@ bool Foam::decomposedBlockData::writeBlocks
|
||||
gatherSlaveData
|
||||
(
|
||||
comm,
|
||||
data,
|
||||
masterData,
|
||||
recvSizes,
|
||||
|
||||
startProc, // startProc,
|
||||
nSendProcs, // nProcs,
|
||||
startProc, // startProc,
|
||||
nSendProcs, // nProcs,
|
||||
|
||||
sliceOffsets,
|
||||
recvData
|
||||
@ -915,18 +885,22 @@ bool Foam::decomposedBlockData::writeBlocks
|
||||
(
|
||||
label proci = startProc;
|
||||
proci < startProc+nSendProcs;
|
||||
proci++
|
||||
++proci
|
||||
)
|
||||
{
|
||||
os << nl << nl << "// Processor" << proci << nl;
|
||||
start[proci] = os.stdStream().tellp();
|
||||
SubList<char> dataSlice
|
||||
(
|
||||
recvData,
|
||||
sliceOffsets[proci+1]-sliceOffsets[proci],
|
||||
sliceOffsets[proci]
|
||||
);
|
||||
|
||||
os <<
|
||||
SubList<char>
|
||||
blockOffset[proci] =
|
||||
decomposedBlockData::writeBlockEntry
|
||||
(
|
||||
recvData,
|
||||
sliceOffsets[proci+1]-sliceOffsets[proci],
|
||||
sliceOffsets[proci]
|
||||
os,
|
||||
proci,
|
||||
dataSlice
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -961,30 +935,34 @@ bool Foam::decomposedBlockData::read()
|
||||
IOobject::readHeader(*isPtr);
|
||||
}
|
||||
|
||||
List<char>& data = *this;
|
||||
return readBlocks(comm_, isPtr, data, commsType_);
|
||||
return readBlocks(comm_, isPtr, contentData_, commsType_);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::decomposedBlockData::writeData(Ostream& os) const
|
||||
{
|
||||
const List<char>& data = *this;
|
||||
|
||||
IOobject io(*this);
|
||||
IOstreamOption streamOpt(os);
|
||||
|
||||
int verValue;
|
||||
int fmtValue;
|
||||
|
||||
// Re-read my own data to find out the header information
|
||||
if (Pstream::master(comm_))
|
||||
{
|
||||
UIListStream headerStream(data);
|
||||
UIListStream headerStream(contentData_);
|
||||
io.readHeader(headerStream);
|
||||
|
||||
verValue = headerStream.version().canonical();
|
||||
fmtValue = static_cast<int>(headerStream.format());
|
||||
}
|
||||
|
||||
// Scatter header information
|
||||
Pstream::scatter(verValue, Pstream::msgType(), comm_);
|
||||
Pstream::scatter(fmtValue, Pstream::msgType(), comm_);
|
||||
|
||||
string versionString(os.version().str());
|
||||
label formatValue(os.format());
|
||||
Pstream::scatter(versionString, Pstream::msgType(), comm_);
|
||||
Pstream::scatter(formatValue, Pstream::msgType(), comm_);
|
||||
streamOpt.version(IOstreamOption::versionNumber::canonical(verValue));
|
||||
streamOpt.format(IOstreamOption::streamFormat(fmtValue));
|
||||
|
||||
//word masterName(name());
|
||||
//Pstream::scatter(masterName, Pstream::msgType(), comm_);
|
||||
@ -999,11 +977,10 @@ bool Foam::decomposedBlockData::writeData(Ostream& os) const
|
||||
|
||||
if (!Pstream::master(comm_))
|
||||
{
|
||||
writeHeader
|
||||
decomposedBlockData::writeHeader
|
||||
(
|
||||
os,
|
||||
IOstreamOption::versionNumber(versionString),
|
||||
IOstreamOption::streamFormat(formatValue),
|
||||
streamOpt, // streamOpt for data
|
||||
io.headerClassName(),
|
||||
io.note(),
|
||||
masterLocation,
|
||||
@ -1015,12 +992,12 @@ bool Foam::decomposedBlockData::writeData(Ostream& os) const
|
||||
if (isA<OFstream>(os))
|
||||
{
|
||||
// Serial file output - can use writeRaw()
|
||||
os.writeRaw(data.cdata(), data.size_bytes());
|
||||
os.writeRaw(contentData_.cdata(), contentData_.size_bytes());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Other cases are less fortunate, and no std::string_view
|
||||
std::string str(data.cdata(), data.size_bytes());
|
||||
std::string str(contentData_.cdata(), contentData_.size_bytes());
|
||||
os.writeQuoted(str, false);
|
||||
}
|
||||
|
||||
@ -1039,29 +1016,39 @@ bool Foam::decomposedBlockData::writeObject
|
||||
const bool valid
|
||||
) const
|
||||
{
|
||||
// Always write BINARY
|
||||
streamOpt.format(IOstream::BINARY);
|
||||
|
||||
autoPtr<OSstream> osPtr;
|
||||
if (UPstream::master(comm_))
|
||||
{
|
||||
// Note: always write binary. These are strings so readable anyway.
|
||||
// They have already be tokenised on the sending side.
|
||||
osPtr.reset(new OFstream(objectPath(), streamOpt));
|
||||
IOobject::writeHeader(*osPtr);
|
||||
|
||||
osPtr.reset(new OFstream(objectPath(), IOstreamOption::BINARY));
|
||||
|
||||
// Update meta-data for current state
|
||||
const_cast<regIOobject&>
|
||||
(
|
||||
static_cast<const regIOobject&>(*this)
|
||||
).updateMetaData();
|
||||
|
||||
decomposedBlockData::writeHeader
|
||||
(
|
||||
*osPtr,
|
||||
streamOpt, // streamOpt for data
|
||||
static_cast<const IOobject&>(*this)
|
||||
);
|
||||
}
|
||||
|
||||
labelList recvSizes;
|
||||
gather(comm_, label(this->size_bytes()), recvSizes);
|
||||
gather(comm_, label(contentData_.size_bytes()), recvSizes);
|
||||
|
||||
List<std::streamoff> start;
|
||||
List<std::streamoff> blockOffsets;
|
||||
PtrList<SubList<char>> slaveData; // dummy slave data
|
||||
return writeBlocks
|
||||
(
|
||||
comm_,
|
||||
osPtr,
|
||||
start,
|
||||
*this,
|
||||
blockOffsets,
|
||||
contentData_,
|
||||
recvSizes,
|
||||
slaveData,
|
||||
commsType_
|
||||
@ -1069,51 +1056,4 @@ bool Foam::decomposedBlockData::writeObject
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::decomposedBlockData::numBlocks(const fileName& fName)
|
||||
{
|
||||
label nBlocks = 0;
|
||||
|
||||
IFstream is(fName);
|
||||
is.fatalCheck("decomposedBlockData::numBlocks(const fileName&)");
|
||||
|
||||
if (!is.good())
|
||||
{
|
||||
return nBlocks;
|
||||
}
|
||||
|
||||
// FoamFile header
|
||||
token firstToken(is);
|
||||
|
||||
if (is.good() && firstToken.isWord("FoamFile"))
|
||||
{
|
||||
dictionary headerDict(is);
|
||||
is.version(headerDict.get<token>("version"));
|
||||
is.format(headerDict.get<word>("format"));
|
||||
|
||||
// Obtain number of blocks directly
|
||||
if (headerDict.readIfPresent("blocks", nBlocks))
|
||||
{
|
||||
return nBlocks;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to brute force read of each data block
|
||||
List<char> data;
|
||||
while (is.good())
|
||||
{
|
||||
token sizeToken(is);
|
||||
if (!sizeToken.isLabel())
|
||||
{
|
||||
return nBlocks;
|
||||
}
|
||||
is.putBack(sizeToken);
|
||||
|
||||
is >> data;
|
||||
nBlocks++;
|
||||
}
|
||||
|
||||
return nBlocks;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -28,10 +28,56 @@ Class
|
||||
Foam::decomposedBlockData
|
||||
|
||||
Description
|
||||
decomposedBlockData is a List<char> with IO on the master processor only.
|
||||
The decomposedBlockData comprise a \c List\<char\> for each output
|
||||
processor, typically with IO on the master processor only.
|
||||
|
||||
For decomposedBlockData, we make a distinction between the container
|
||||
description and the individual block contents.
|
||||
|
||||
The \b FoamFile header specifies the container characteristics and thus
|
||||
has \c class = \c %decomposedBlockData and normally \c format = \c binary.
|
||||
This description refers to the \em entire file container, not the
|
||||
individual blocks.
|
||||
|
||||
Each processor block is simply a binary chunk of characters and the
|
||||
first block also contains the header description for all of the blocks.
|
||||
For example,
|
||||
\verbatim
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format binary;
|
||||
arch "LSB;label=32;scalar=64";
|
||||
class decomposedBlockData;
|
||||
location "constant/polyMesh";
|
||||
object points;
|
||||
}
|
||||
|
||||
// processor0
|
||||
NCHARS
|
||||
(FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
arch "LSB;label=32;scalar=64";
|
||||
class vectorField;
|
||||
location "constant/polyMesh";
|
||||
object points;
|
||||
}
|
||||
...content...
|
||||
)
|
||||
|
||||
// processor1
|
||||
NCHARS
|
||||
(...content...)
|
||||
|
||||
...
|
||||
\endverbatim
|
||||
|
||||
|
||||
SourceFiles
|
||||
decomposedBlockData.C
|
||||
decomposedBlockDataHeader.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -53,9 +99,22 @@ namespace Foam
|
||||
|
||||
class decomposedBlockData
|
||||
:
|
||||
public regIOobject,
|
||||
public List<char>
|
||||
public regIOobject
|
||||
{
|
||||
// Private Functions
|
||||
|
||||
//- Helper: write content for FoamFile IOobject header
|
||||
static void writeHeaderContent
|
||||
(
|
||||
Ostream& os,
|
||||
IOstreamOption streamOptContainer,
|
||||
const word& objectType,
|
||||
const string& note,
|
||||
const fileName& location,
|
||||
const word& objectName
|
||||
);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Data
|
||||
@ -66,11 +125,14 @@ protected:
|
||||
//- Communicator for all parallel comms
|
||||
const label comm_;
|
||||
|
||||
//- The block content
|
||||
List<char> contentData_;
|
||||
|
||||
// Protected member functions
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Helper: determine number of processors whose recvSizes fits
|
||||
// ito maxBufferSize
|
||||
//- into maxBufferSize
|
||||
static label calcNumProcs
|
||||
(
|
||||
const label comm,
|
||||
@ -84,7 +146,7 @@ protected:
|
||||
(
|
||||
const label comm,
|
||||
autoPtr<ISstream>& isPtr,
|
||||
List<char>& data,
|
||||
List<char>& contentChars,
|
||||
const UPstream::commsTypes commsType
|
||||
);
|
||||
|
||||
@ -105,30 +167,12 @@ public:
|
||||
const UPstream::commsTypes = UPstream::commsTypes::scheduled
|
||||
);
|
||||
|
||||
//- Construct given an IOobject and for READ_IF_MODIFIED a List<char>
|
||||
decomposedBlockData
|
||||
(
|
||||
const label comm,
|
||||
const IOobject& io,
|
||||
const UList<char>& list,
|
||||
const UPstream::commsTypes = UPstream::commsTypes::scheduled
|
||||
);
|
||||
|
||||
//- Construct by transferring the List contents
|
||||
decomposedBlockData
|
||||
(
|
||||
const label comm,
|
||||
const IOobject& io,
|
||||
List<char>&& list,
|
||||
const UPstream::commsTypes = UPstream::commsTypes::scheduled
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~decomposedBlockData() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
//- Read object
|
||||
virtual bool read();
|
||||
@ -147,31 +191,71 @@ public:
|
||||
|
||||
// Helpers
|
||||
|
||||
//- Read header. Call only on master.
|
||||
static bool readMasterHeader(IOobject&, Istream&);
|
||||
//- True if object type is a known collated type
|
||||
static bool isCollatedType(const word& objectType);
|
||||
|
||||
//- True if object header class is a known collated type
|
||||
static bool isCollatedType(const IOobject& io);
|
||||
|
||||
//- Read header as per IOobject with additional handling of
|
||||
//- decomposedBlockData
|
||||
static bool readHeader(IOobject& io, Istream& is);
|
||||
|
||||
//- Helper: write FoamFile IOobject header
|
||||
static void writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
const IOstream::versionNumber version,
|
||||
const IOstream::streamFormat format,
|
||||
IOstreamOption streamOptContainer,
|
||||
const word& objectType,
|
||||
const string& note,
|
||||
const fileName& location,
|
||||
const word& objectName
|
||||
);
|
||||
|
||||
//- Helper: write FoamFile IOobject header
|
||||
static void writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
IOstreamOption streamOptData,
|
||||
const IOobject& io
|
||||
);
|
||||
|
||||
//- Helper: read block of (binary) character data
|
||||
static bool readBlockEntry
|
||||
(
|
||||
Istream& is,
|
||||
List<char>& charData
|
||||
);
|
||||
|
||||
//- Helper: write block of (binary) character data
|
||||
static std::streamoff writeBlockEntry
|
||||
(
|
||||
OSstream& os,
|
||||
const label blocki,
|
||||
const UList<char>& charData
|
||||
);
|
||||
|
||||
//- Helper: write block of (binary) character data
|
||||
// \return -1 on error
|
||||
static std::streamoff writeBlockEntry
|
||||
(
|
||||
OSstream& os,
|
||||
IOstreamOption streamOptData,
|
||||
const regIOobject& io,
|
||||
const label blocki,
|
||||
const bool withLocalHeader
|
||||
);
|
||||
|
||||
//- Read selected block (non-seeking) + header information
|
||||
static autoPtr<ISstream> readBlock
|
||||
(
|
||||
const label blocki,
|
||||
Istream& is,
|
||||
ISstream& is,
|
||||
IOobject& headerIO
|
||||
);
|
||||
|
||||
//- Read master header information (into headerIO) and return
|
||||
// data in stream. Note: isPtr is only valid on master.
|
||||
//- data in stream. Note: isPtr is only valid on master.
|
||||
static autoPtr<ISstream> readBlocks
|
||||
(
|
||||
const label comm,
|
||||
@ -191,9 +275,11 @@ public:
|
||||
labelList& datas
|
||||
);
|
||||
|
||||
//- Helper: gather data from (subset of) slaves. Returns
|
||||
// recvData : received data
|
||||
// recvOffsets : offset in data. recvOffsets is nProcs+1
|
||||
//- Helper: gather data from (subset of) slaves.
|
||||
//
|
||||
// Returns:
|
||||
// - recvData : received data
|
||||
// - recvOffsets : offset in data. recvOffsets is nProcs+1
|
||||
static void gatherSlaveData
|
||||
(
|
||||
const label comm,
|
||||
@ -207,13 +293,14 @@ public:
|
||||
List<char>& recvData
|
||||
);
|
||||
|
||||
//- Write *this. Ostream only valid on master. Returns starts of
|
||||
// processor blocks
|
||||
//- Write *this. Ostream only valid on master.
|
||||
// Returns offsets of processor blocks in blockOffset
|
||||
static bool writeBlocks
|
||||
(
|
||||
const label comm,
|
||||
autoPtr<OSstream>& osPtr,
|
||||
List<std::streamoff>& start,
|
||||
List<std::streamoff>& blockOffset,
|
||||
|
||||
const UList<char>& masterData,
|
||||
|
||||
const labelUList& recvSizes,
|
||||
@ -224,9 +311,6 @@ public:
|
||||
const UPstream::commsTypes,
|
||||
const bool syncReturnState = true
|
||||
);
|
||||
|
||||
//- Detect number of blocks in a file
|
||||
static label numBlocks(const fileName& fName);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,217 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "decomposedBlockData.H"
|
||||
#include "dictionary.H"
|
||||
#include "foamVersion.H"
|
||||
#include "objectRegistry.H"
|
||||
#include "ListStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
inline void writeSpaces(Ostream& os, label nSpaces)
|
||||
{
|
||||
if (nSpaces < 1)
|
||||
{
|
||||
nSpaces = 1;
|
||||
}
|
||||
while (nSpaces--)
|
||||
{
|
||||
os.write(char(token::SPACE));
|
||||
}
|
||||
}
|
||||
|
||||
// Similar to writeEntry, but with fewer spaces
|
||||
template<class T>
|
||||
inline void writeHeaderEntry(Ostream& os, const word& key, const T& value)
|
||||
{
|
||||
os << indent << key;
|
||||
writeSpaces(os, 12 - label(key.size()));
|
||||
os << value << char(token::END_STATEMENT) << nl;
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::decomposedBlockData::writeHeaderContent
|
||||
(
|
||||
Ostream& os,
|
||||
IOstreamOption streamOptContainer,
|
||||
const word& objectType,
|
||||
const string& note,
|
||||
const fileName& location,
|
||||
const word& objectName
|
||||
)
|
||||
{
|
||||
// Standard header entries
|
||||
writeHeaderEntry(os, "version", streamOptContainer.version());
|
||||
writeHeaderEntry(os, "format", streamOptContainer.format());
|
||||
writeHeaderEntry(os, "arch", foamVersion::buildArch);
|
||||
|
||||
if (!note.empty())
|
||||
{
|
||||
writeHeaderEntry(os, "note", note);
|
||||
}
|
||||
|
||||
if (objectType.empty())
|
||||
{
|
||||
// Empty type not allowed - use 'dictionary' fallback
|
||||
writeHeaderEntry(os, "class", word("dictionary"));
|
||||
}
|
||||
else
|
||||
{
|
||||
writeHeaderEntry(os, "class", objectType);
|
||||
}
|
||||
|
||||
if (!location.empty())
|
||||
{
|
||||
writeHeaderEntry(os, "location", location);
|
||||
}
|
||||
writeHeaderEntry(os, "object", objectName);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Members Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::decomposedBlockData::readHeader(IOobject& io, Istream& is)
|
||||
{
|
||||
dictionary headerDict;
|
||||
|
||||
// Read the regular "FoamFile" header
|
||||
bool ok = io.readHeader(headerDict, is);
|
||||
|
||||
if (decomposedBlockData::isCollatedType(io))
|
||||
{
|
||||
// Quick information - extract from "data.class"
|
||||
if (headerDict.readIfPresent("data.class", io.headerClassName()))
|
||||
{
|
||||
return ok;
|
||||
}
|
||||
|
||||
{
|
||||
// Master-only reading of header
|
||||
List<char> charData;
|
||||
decomposedBlockData::readBlockEntry(is, charData);
|
||||
|
||||
UIListStream headerStream(charData);
|
||||
headerStream.name() = is.name();
|
||||
|
||||
ok = io.readHeader(headerStream);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
void Foam::decomposedBlockData::writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
IOstreamOption streamOptContainer,
|
||||
const word& objectType,
|
||||
const string& note,
|
||||
const fileName& location,
|
||||
const word& objectName
|
||||
)
|
||||
{
|
||||
if (IOobject::bannerEnabled())
|
||||
{
|
||||
IOobject::writeBanner(os);
|
||||
}
|
||||
|
||||
os.beginBlock("FoamFile");
|
||||
|
||||
decomposedBlockData::writeHeaderContent
|
||||
(
|
||||
os,
|
||||
streamOptContainer,
|
||||
objectType,
|
||||
note,
|
||||
location,
|
||||
objectName
|
||||
);
|
||||
|
||||
os.endBlock();
|
||||
|
||||
if (IOobject::bannerEnabled())
|
||||
{
|
||||
IOobject::writeDivider(os) << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::decomposedBlockData::writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
IOstreamOption streamOptData,
|
||||
const IOobject& io
|
||||
)
|
||||
{
|
||||
if (IOobject::bannerEnabled())
|
||||
{
|
||||
IOobject::writeBanner(os);
|
||||
}
|
||||
|
||||
os.beginBlock("FoamFile");
|
||||
|
||||
decomposedBlockData::writeHeaderContent
|
||||
(
|
||||
os,
|
||||
static_cast<IOstreamOption>(os), // streamOpt container
|
||||
decomposedBlockData::typeName, // class
|
||||
io.note(),
|
||||
(io.instance()/io.db().dbDir()/io.local()), // location
|
||||
io.name()
|
||||
);
|
||||
|
||||
{
|
||||
writeHeaderEntry(os, "data.format", streamOptData.format());
|
||||
writeHeaderEntry(os, "data.class", io.type());
|
||||
}
|
||||
|
||||
// Meta-data (if any)
|
||||
const dictionary* metaDataDict = io.findMetaData();
|
||||
if (metaDataDict && !metaDataDict->empty())
|
||||
{
|
||||
metaDataDict->writeEntry("meta", os);
|
||||
}
|
||||
|
||||
os.endBlock();
|
||||
|
||||
if (IOobject::bannerEnabled())
|
||||
{
|
||||
IOobject::writeDivider(os) << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -48,7 +48,7 @@ Foam::IFstream::IFstream
|
||||
Foam::ifstreamPointer(pathname),
|
||||
ISstream(*(ifstreamPointer::get()), pathname, streamOpt)
|
||||
{
|
||||
IOstream::compression(ifstreamPointer::whichCompression());
|
||||
IOstreamOption::compression(ifstreamPointer::whichCompression());
|
||||
|
||||
setClosed();
|
||||
|
||||
@ -73,7 +73,7 @@ Foam::IFstream::IFstream
|
||||
<< "Cannot open empty file name"
|
||||
<< Foam::endl;
|
||||
}
|
||||
else if (IOstreamOption::COMPRESSED == IOstream::compression())
|
||||
else if (IOstreamOption::COMPRESSED == IOstreamOption::compression())
|
||||
{
|
||||
InfoInFunction
|
||||
<< "Decompressing " << (this->name() + ".gz") << Foam::endl;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -76,7 +76,7 @@ public:
|
||||
(
|
||||
const fileName& pathname,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = currentVersion
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
IFstream(pathname, IOstreamOption(fmt, ver))
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -81,12 +81,12 @@ public:
|
||||
(
|
||||
const fileName& pathname,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = currentVersion,
|
||||
IOstreamOption::compressionType comp = IOstreamOption::UNCOMPRESSED,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion,
|
||||
IOstreamOption::compressionType cmp = IOstreamOption::UNCOMPRESSED,
|
||||
const bool append = false
|
||||
)
|
||||
:
|
||||
OFstream(pathname, IOstreamOption(fmt, comp, ver), append)
|
||||
OFstream(pathname, IOstreamOption(fmt, ver, cmp), append)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -54,9 +54,7 @@ void Foam::masterOFstream::checkWrite
|
||||
OFstream os
|
||||
(
|
||||
fName,
|
||||
IOstream::BINARY, //format(),
|
||||
version(),
|
||||
compression_,
|
||||
IOstreamOption(IOstreamOption::BINARY, version(), compression_),
|
||||
append_
|
||||
);
|
||||
if (!os.good())
|
||||
@ -189,7 +187,7 @@ Foam::masterOFstream::masterOFstream
|
||||
const bool valid
|
||||
)
|
||||
:
|
||||
OStringStream(streamOpt.format(), streamOpt.version()),
|
||||
OStringStream(streamOpt),
|
||||
pathName_(pathName),
|
||||
compression_(streamOpt.compression()),
|
||||
append_(append),
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -57,7 +57,7 @@ class masterOFstream
|
||||
|
||||
const fileName pathName_;
|
||||
|
||||
const IOstream::compressionType compression_;
|
||||
const IOstreamOption::compressionType compression_;
|
||||
|
||||
const bool append_;
|
||||
|
||||
@ -99,9 +99,9 @@ public:
|
||||
masterOFstream
|
||||
(
|
||||
const fileName& pathname,
|
||||
streamFormat fmt,
|
||||
versionNumber ver = currentVersion,
|
||||
compressionType comp = compressionType::UNCOMPRESSED,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion,
|
||||
IOstreamOption::compressionType cmp = IOstreamOption::UNCOMPRESSED,
|
||||
const bool append = false,
|
||||
const bool valid = true
|
||||
)
|
||||
@ -109,7 +109,7 @@ public:
|
||||
masterOFstream
|
||||
(
|
||||
pathname,
|
||||
IOstreamOption(fmt, comp, ver),
|
||||
IOstreamOption(fmt, ver, cmp),
|
||||
append,
|
||||
valid
|
||||
)
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -64,6 +64,10 @@ using std::cin;
|
||||
using std::cout;
|
||||
using std::cerr;
|
||||
|
||||
// Additional constructors and methods (as per v2012 and earlier)
|
||||
#define Foam_IOstream_extras
|
||||
// COMPAT_OPENFOAM_ORG
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -84,8 +88,8 @@ public:
|
||||
//- Enumeration for stream open/closed state
|
||||
enum streamAccess : char
|
||||
{
|
||||
CLOSED = 0, //!< stream not open
|
||||
OPENED //!< stream is open
|
||||
CLOSED = 0, //!< The stream is not open
|
||||
OPENED //!< The stream is open
|
||||
};
|
||||
|
||||
|
||||
@ -102,15 +106,17 @@ protected:
|
||||
//- Name for any generic stream - normally treat as readonly
|
||||
static fileName staticName_;
|
||||
|
||||
//- Mirror of internal stream io state
|
||||
std::ios_base::iostate ioState_;
|
||||
|
||||
//- The stream open/closed state
|
||||
streamAccess openClosed_;
|
||||
|
||||
ios_base::iostate ioState_;
|
||||
//- The sizeof (label), possibly read from the header
|
||||
unsigned char sizeofLabel_;
|
||||
|
||||
//- The label byte-size (could also be stored as byte)
|
||||
unsigned short labelByteSize_;
|
||||
|
||||
//- The scalar byte-size (could also be stored as byte)
|
||||
unsigned short scalarByteSize_;
|
||||
//- The sizeof (scalar), possibly read from the header
|
||||
unsigned char sizeofScalar_;
|
||||
|
||||
//- The file line
|
||||
label lineNumber_;
|
||||
@ -121,27 +127,27 @@ protected:
|
||||
// Access
|
||||
|
||||
//- Set stream opened
|
||||
void setOpened()
|
||||
void setOpened() noexcept
|
||||
{
|
||||
openClosed_ = OPENED;
|
||||
}
|
||||
|
||||
//- Set stream closed
|
||||
void setClosed()
|
||||
void setClosed() noexcept
|
||||
{
|
||||
openClosed_ = CLOSED;
|
||||
}
|
||||
|
||||
//- Set stream state
|
||||
void setState(ios_base::iostate state)
|
||||
void setState(std::ios_base::iostate state) noexcept
|
||||
{
|
||||
ioState_ = state;
|
||||
}
|
||||
|
||||
//- Set stream to be good
|
||||
void setGood()
|
||||
//- Set stream state to be good
|
||||
void setGood() noexcept
|
||||
{
|
||||
ioState_ = ios_base::iostate(0);
|
||||
ioState_ = std::ios_base::iostate(0);
|
||||
}
|
||||
|
||||
|
||||
@ -163,10 +169,10 @@ public:
|
||||
explicit IOstream(IOstreamOption streamOpt = IOstreamOption())
|
||||
:
|
||||
IOstreamOption(streamOpt),
|
||||
ioState_(std::ios_base::iostate(0)),
|
||||
openClosed_(CLOSED),
|
||||
ioState_(ios_base::iostate(0)),
|
||||
labelByteSize_(sizeof(label)),
|
||||
scalarByteSize_(sizeof(scalar)),
|
||||
sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
|
||||
sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
|
||||
lineNumber_(0)
|
||||
{
|
||||
setBad();
|
||||
@ -175,12 +181,12 @@ public:
|
||||
//- Construct with format, version (compression)
|
||||
IOstream
|
||||
(
|
||||
streamFormat fmt,
|
||||
versionNumber ver,
|
||||
compressionType comp = compressionType::UNCOMPRESSED
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver,
|
||||
IOstreamOption::compressionType cmp = IOstreamOption::UNCOMPRESSED
|
||||
)
|
||||
:
|
||||
IOstream(IOstreamOption(fmt, comp, ver))
|
||||
IOstream(IOstreamOption(fmt, ver, cmp))
|
||||
{}
|
||||
|
||||
|
||||
@ -209,50 +215,50 @@ public:
|
||||
// Generate a FatalIOError when an error has occurred.
|
||||
bool fatalCheck(const char* operation) const;
|
||||
|
||||
//- Return true if stream has been opened
|
||||
bool opened() const
|
||||
//- True if stream has been opened
|
||||
bool opened() const noexcept
|
||||
{
|
||||
return openClosed_ == OPENED;
|
||||
}
|
||||
|
||||
//- Return true if stream is closed
|
||||
bool closed() const
|
||||
//- True if stream is closed
|
||||
bool closed() const noexcept
|
||||
{
|
||||
return openClosed_ == CLOSED;
|
||||
}
|
||||
|
||||
//- Return true if next operation might succeed
|
||||
bool good() const
|
||||
//- True if next operation might succeed
|
||||
bool good() const noexcept
|
||||
{
|
||||
return ioState_ == 0;
|
||||
}
|
||||
|
||||
//- Return true if end of input seen
|
||||
bool eof() const
|
||||
//- True if end of input seen
|
||||
bool eof() const noexcept
|
||||
{
|
||||
return ioState_ & ios_base::eofbit;
|
||||
return ioState_ & std::ios_base::eofbit;
|
||||
}
|
||||
|
||||
//- Return true if next operation will fail
|
||||
bool fail() const
|
||||
//- True if next operation will fail
|
||||
bool fail() const noexcept
|
||||
{
|
||||
return ioState_ & (ios_base::badbit | ios_base::failbit);
|
||||
return ioState_ & (std::ios_base::badbit | std::ios_base::failbit);
|
||||
}
|
||||
|
||||
//- Return true if stream is corrupted
|
||||
bool bad() const
|
||||
//- True if stream is corrupted
|
||||
bool bad() const noexcept
|
||||
{
|
||||
return ioState_ & ios_base::badbit;
|
||||
return ioState_ & std::ios_base::badbit;
|
||||
}
|
||||
|
||||
//- Return true if the stream has not failed
|
||||
explicit operator bool() const
|
||||
explicit operator bool() const noexcept
|
||||
{
|
||||
return !fail();
|
||||
}
|
||||
|
||||
//- Return true if the stream has failed
|
||||
bool operator!() const
|
||||
bool operator!() const noexcept
|
||||
{
|
||||
return fail();
|
||||
}
|
||||
@ -260,28 +266,28 @@ public:
|
||||
|
||||
// Element sizes (precision)
|
||||
|
||||
//- The label byte-size associated with the stream
|
||||
unsigned labelByteSize() const
|
||||
//- The sizeof (label) in bytes associated with the stream
|
||||
unsigned labelByteSize() const noexcept
|
||||
{
|
||||
return labelByteSize_;
|
||||
return static_cast<unsigned>(sizeofLabel_);
|
||||
}
|
||||
|
||||
//- The scalar byte-size associated with the stream
|
||||
unsigned scalarByteSize() const
|
||||
//- The sizeof (scalar) in bytes associated with the stream
|
||||
unsigned scalarByteSize() const noexcept
|
||||
{
|
||||
return scalarByteSize_;
|
||||
return static_cast<unsigned>(sizeofScalar_);
|
||||
}
|
||||
|
||||
//- Set the label byte-size associated with the stream
|
||||
void setLabelByteSize(unsigned nbytes)
|
||||
//- Set the sizeof (label) in bytes associated with the stream
|
||||
void setLabelByteSize(unsigned nbytes) noexcept
|
||||
{
|
||||
labelByteSize_ = nbytes;
|
||||
sizeofLabel_ = static_cast<unsigned char>(nbytes);
|
||||
}
|
||||
|
||||
//- Set the scalar byte-size associated with the stream
|
||||
void setScalarByteSize(unsigned nbytes)
|
||||
//- Set the sizeof (scalar) in bytes associated with the stream
|
||||
void setScalarByteSize(unsigned nbytes) noexcept
|
||||
{
|
||||
scalarByteSize_ = nbytes;
|
||||
sizeofScalar_ = static_cast<unsigned char>(nbytes);
|
||||
}
|
||||
|
||||
|
||||
@ -289,38 +295,38 @@ public:
|
||||
//- is the same as the given type
|
||||
template<class T = label>
|
||||
typename std::enable_if<std::is_integral<T>::value, bool>::type
|
||||
checkLabelSize() const
|
||||
checkLabelSize() const noexcept
|
||||
{
|
||||
return labelByteSize_ == sizeof(T);
|
||||
return sizeofLabel_ == sizeof(T);
|
||||
}
|
||||
|
||||
//- Check if the scalar byte-size associated with the stream
|
||||
//- is the same as the given type
|
||||
template<class T = scalar>
|
||||
typename std::enable_if<std::is_floating_point<T>::value, bool>::type
|
||||
checkScalarSize() const
|
||||
checkScalarSize() const noexcept
|
||||
{
|
||||
return scalarByteSize_ == sizeof(T);
|
||||
return sizeofScalar_ == sizeof(T);
|
||||
}
|
||||
|
||||
|
||||
// Stream State Functions
|
||||
|
||||
//- Const access to the current stream line number
|
||||
label lineNumber() const
|
||||
label lineNumber() const noexcept
|
||||
{
|
||||
return lineNumber_;
|
||||
}
|
||||
|
||||
//- Non-const access to the current stream line number
|
||||
label& lineNumber()
|
||||
label& lineNumber() noexcept
|
||||
{
|
||||
return lineNumber_;
|
||||
}
|
||||
|
||||
//- Set the stream line number
|
||||
// \return the previous value
|
||||
label lineNumber(const label num)
|
||||
label lineNumber(const label num) noexcept
|
||||
{
|
||||
const label old(lineNumber_);
|
||||
lineNumber_ = num;
|
||||
@ -331,36 +337,36 @@ public:
|
||||
virtual ios_base::fmtflags flags() const = 0;
|
||||
|
||||
//- Return the default precision
|
||||
static unsigned int defaultPrecision()
|
||||
static unsigned int defaultPrecision() noexcept
|
||||
{
|
||||
return precision_;
|
||||
}
|
||||
|
||||
//- Reset the default precision
|
||||
// \return the previous value
|
||||
static unsigned int defaultPrecision(unsigned int prec)
|
||||
static unsigned int defaultPrecision(unsigned int prec) noexcept
|
||||
{
|
||||
unsigned int old(precision_);
|
||||
precision_ = prec;
|
||||
return old;
|
||||
}
|
||||
|
||||
//- Set stream to have reached eof
|
||||
void setEof()
|
||||
//- Set stream state as reached 'eof'
|
||||
void setEof() noexcept
|
||||
{
|
||||
ioState_ |= ios_base::eofbit;
|
||||
ioState_ |= std::ios_base::eofbit;
|
||||
}
|
||||
|
||||
//- Set stream to have failed
|
||||
void setFail()
|
||||
//- Set stream state as 'failed'
|
||||
void setFail() noexcept
|
||||
{
|
||||
ioState_ |= ios_base::failbit;
|
||||
ioState_ |= std::ios_base::failbit;
|
||||
}
|
||||
|
||||
//- Set stream to be bad
|
||||
//- Set stream state to be 'bad'
|
||||
void setBad()
|
||||
{
|
||||
ioState_ |= ios_base::badbit;
|
||||
ioState_ |= std::ios_base::badbit;
|
||||
}
|
||||
|
||||
//- Set flags of stream
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -123,6 +123,30 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- A string representation as major.minor
|
||||
std::string str() const
|
||||
{
|
||||
return
|
||||
(
|
||||
std::to_string(int(number_ / 10)) // major
|
||||
+ '.'
|
||||
+ std::to_string(int(number_ % 10)) // minor
|
||||
);
|
||||
}
|
||||
|
||||
//- From version to canonical integer value
|
||||
int canonical() const noexcept
|
||||
{
|
||||
return number_;
|
||||
}
|
||||
|
||||
//- From canonical integer value to version
|
||||
static versionNumber canonical(int verNum) noexcept
|
||||
{
|
||||
// Split into major/minor
|
||||
return versionNumber(int(verNum / 10), int(verNum % 10));
|
||||
}
|
||||
|
||||
//- Compare differences in the versions
|
||||
// Negative when 'this' is less than other.
|
||||
// Positive when 'this' is greater than other.
|
||||
@ -130,33 +154,6 @@ public:
|
||||
{
|
||||
return number_ - other.number_;
|
||||
}
|
||||
|
||||
//- The canonical major/minor pair as an integer value.
|
||||
int canonical() noexcept
|
||||
{
|
||||
return number_;
|
||||
}
|
||||
|
||||
//- Return the major version number.
|
||||
int getMajor() const noexcept
|
||||
{
|
||||
return int(number_ / 10);
|
||||
}
|
||||
|
||||
//- Return the minor version number
|
||||
int getMinor() const noexcept
|
||||
{
|
||||
return int(number_ % 10);
|
||||
}
|
||||
|
||||
//- A string representation of major.minor
|
||||
std::string str() const
|
||||
{
|
||||
return
|
||||
std::to_string(getMajor())
|
||||
+ '.'
|
||||
+ std::to_string(getMinor());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -364,6 +361,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
//- Output format type as text string (ascii | binary)
|
||||
Ostream& operator<<(Ostream& os, const IOstreamOption::streamFormat& fmt);
|
||||
|
||||
@ -371,6 +370,8 @@ Ostream& operator<<(Ostream& os, const IOstreamOption::streamFormat& fmt);
|
||||
Ostream& operator<<(Ostream& os, const IOstreamOption::versionNumber& ver);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * //
|
||||
|
||||
// Comparison Operators
|
||||
|
||||
//- Version number equality
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -96,12 +96,12 @@ public:
|
||||
//- Construct with format, version (compression)
|
||||
explicit Istream
|
||||
(
|
||||
streamFormat fmt,
|
||||
versionNumber ver = currentVersion,
|
||||
compressionType comp = compressionType::UNCOMPRESSED
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion,
|
||||
IOstreamOption::compressionType cmp = IOstreamOption::UNCOMPRESSED
|
||||
)
|
||||
:
|
||||
Istream(IOstreamOption(fmt, comp, ver))
|
||||
Istream(IOstreamOption(fmt, ver, cmp))
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -96,12 +96,12 @@ public:
|
||||
//- Construct with format, version (compression)
|
||||
explicit Ostream
|
||||
(
|
||||
streamFormat fmt,
|
||||
versionNumber ver = currentVersion,
|
||||
compressionType comp = compressionType::UNCOMPRESSED
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion,
|
||||
IOstreamOption::compressionType cmp = IOstreamOption::UNCOMPRESSED
|
||||
)
|
||||
:
|
||||
Ostream(IOstreamOption(fmt, comp, ver))
|
||||
Ostream(IOstreamOption(fmt, ver, cmp))
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,8 +37,8 @@ Foam::IPstream::IPstream
|
||||
const label bufSize,
|
||||
const int tag,
|
||||
const label comm,
|
||||
streamFormat format,
|
||||
versionNumber version
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver
|
||||
)
|
||||
:
|
||||
Pstream(commsType, bufSize),
|
||||
@ -50,8 +51,8 @@ Foam::IPstream::IPstream
|
||||
tag, // tag
|
||||
comm,
|
||||
false, // do not clear buf_ if at end
|
||||
format,
|
||||
version
|
||||
fmt,
|
||||
ver
|
||||
),
|
||||
externalBufPosition_(0)
|
||||
{}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -64,7 +65,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given process index to read from and optional buffer size,
|
||||
// read format and IO version
|
||||
//- read format and IO version
|
||||
IPstream
|
||||
(
|
||||
const commsTypes commsType,
|
||||
@ -72,10 +73,9 @@ public:
|
||||
const label bufSize = 0,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
streamFormat format=BINARY,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,12 +37,12 @@ Foam::OPstream::OPstream
|
||||
const label bufSize,
|
||||
const int tag,
|
||||
const label comm,
|
||||
streamFormat format,
|
||||
versionNumber version
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver
|
||||
)
|
||||
:
|
||||
Pstream(commsType, bufSize),
|
||||
UOPstream(commsType, toProcNo, buf_, tag, comm, true, format, version)
|
||||
UOPstream(commsType, toProcNo, buf_, tag, comm, true, fmt, ver)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -55,13 +56,12 @@ class OPstream
|
||||
public Pstream,
|
||||
public UOPstream
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given process index to send to and optional buffer size,
|
||||
// write format and IO version
|
||||
//- write format and IO version
|
||||
OPstream
|
||||
(
|
||||
const commsTypes commsType,
|
||||
@ -69,10 +69,9 @@ public:
|
||||
const label bufSize = 0,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
streamFormat format=BINARY,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -39,15 +40,15 @@ Foam::PstreamBuffers::PstreamBuffers
|
||||
const UPstream::commsTypes commsType,
|
||||
const int tag,
|
||||
const label comm,
|
||||
IOstream::streamFormat format,
|
||||
IOstream::versionNumber version
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver
|
||||
)
|
||||
:
|
||||
commsType_(commsType),
|
||||
tag_(tag),
|
||||
comm_(comm),
|
||||
format_(format),
|
||||
version_(version),
|
||||
format_(fmt),
|
||||
version_(ver),
|
||||
sendBuf_(UPstream::nProcs(comm)),
|
||||
recvBuf_(UPstream::nProcs(comm)),
|
||||
recvBufPos_(UPstream::nProcs(comm), 0),
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -99,9 +100,9 @@ class PstreamBuffers
|
||||
|
||||
const label comm_;
|
||||
|
||||
const IOstream::streamFormat format_;
|
||||
const IOstreamOption::streamFormat format_;
|
||||
|
||||
const IOstream::versionNumber version_;
|
||||
const IOstreamOption::versionNumber version_;
|
||||
|
||||
//- Send buffer
|
||||
List<DynamicList<char>> sendBuf_;
|
||||
@ -130,8 +131,8 @@ public:
|
||||
const UPstream::commsTypes commsType,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
IOstream::streamFormat format=IOstream::BINARY,
|
||||
IOstream::versionNumber version=IOstream::currentVersion
|
||||
IOstreamOption::streamFormat vmt = IOstreamOption::BINARY,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
);
|
||||
|
||||
//- Destructor
|
||||
|
||||
@ -101,7 +101,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given process index to read from and optional buffer size,
|
||||
// read format and IO version
|
||||
//- read format and IO version
|
||||
UIPstream
|
||||
(
|
||||
const commsTypes commsType,
|
||||
@ -111,8 +111,8 @@ public:
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const bool clearAtEnd = false, // destroy externalBuf if at end
|
||||
streamFormat format=BINARY,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
);
|
||||
|
||||
//- Construct given buffers
|
||||
|
||||
@ -126,12 +126,12 @@ Foam::UOPstream::UOPstream
|
||||
const int tag,
|
||||
const label comm,
|
||||
const bool sendAtDestruct,
|
||||
streamFormat format,
|
||||
versionNumber version
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver
|
||||
)
|
||||
:
|
||||
UPstream(commsType),
|
||||
Ostream(format, version),
|
||||
Ostream(fmt, ver),
|
||||
toProcNo_(toProcNo),
|
||||
sendBuf_(sendBuf),
|
||||
tag_(tag),
|
||||
|
||||
@ -113,8 +113,8 @@ public:
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm,
|
||||
const bool sendAtDestruct = true,
|
||||
streamFormat format=BINARY,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
);
|
||||
|
||||
//- Construct given buffers
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -103,12 +103,12 @@ public:
|
||||
(
|
||||
std::istream& is,
|
||||
const string& streamName,
|
||||
streamFormat fmt,
|
||||
versionNumber ver = currentVersion,
|
||||
compressionType comp = compressionType::UNCOMPRESSED
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion,
|
||||
IOstreamOption::compressionType cmp = IOstreamOption::UNCOMPRESSED
|
||||
)
|
||||
:
|
||||
ISstream(is, streamName, IOstreamOption(fmt, comp, ver))
|
||||
ISstream(is, streamName, IOstreamOption(fmt, ver, cmp))
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -90,12 +90,12 @@ public:
|
||||
(
|
||||
std::ostream& os,
|
||||
const string& streamName,
|
||||
streamFormat fmt,
|
||||
versionNumber ver = currentVersion,
|
||||
compressionType comp = compressionType::UNCOMPRESSED
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion,
|
||||
IOstreamOption::compressionType cmp = IOstreamOption::UNCOMPRESSED
|
||||
)
|
||||
:
|
||||
OSstream(os, streamName, IOstreamOption(fmt, comp, ver))
|
||||
OSstream(os, streamName, IOstreamOption(fmt, ver, cmp))
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,7 +28,7 @@ Class
|
||||
Foam::prefixOSstream
|
||||
|
||||
Description
|
||||
Version of OSstream which prints a prefix on each line.
|
||||
Version of OSstream that prints a prefix on each line.
|
||||
|
||||
This is useful for running in parallel as it allows the processor number
|
||||
to be automatically prepended to each message line.
|
||||
@ -85,12 +85,12 @@ public:
|
||||
(
|
||||
std::ostream& os,
|
||||
const string& streamName,
|
||||
streamFormat fmt,
|
||||
versionNumber ver = currentVersion,
|
||||
compressionType comp = compressionType::UNCOMPRESSED
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion,
|
||||
IOstreamOption::compressionType cmp = IOstreamOption::UNCOMPRESSED
|
||||
)
|
||||
:
|
||||
prefixOSstream(os, streamName, IOstreamOption(fmt, comp, ver))
|
||||
prefixOSstream(os, streamName, IOstreamOption(fmt, ver, cmp))
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -71,10 +71,7 @@ protected:
|
||||
// Constructors
|
||||
|
||||
//- Default construct
|
||||
StringStreamAllocator()
|
||||
:
|
||||
stream_()
|
||||
{}
|
||||
StringStreamAllocator() = default;
|
||||
|
||||
//- Copy construct from string
|
||||
StringStreamAllocator(const std::string& s)
|
||||
@ -107,7 +104,7 @@ public:
|
||||
Class IStringStream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Input from string buffer, using a ISstream
|
||||
//- Input from string buffer, using a ISstream. Always UNCOMPRESSED.
|
||||
class IStringStream
|
||||
:
|
||||
public Detail::StringStreamAllocator<std::istringstream>,
|
||||
@ -119,41 +116,36 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Default construct
|
||||
//- Default construct or with specified stream option
|
||||
explicit IStringStream
|
||||
(
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
allocator_type(),
|
||||
ISstream(stream_, "input", format, version)
|
||||
ISstream(stream_, "input", streamOpt.format(), streamOpt.version())
|
||||
{}
|
||||
|
||||
//- Construct from std::string
|
||||
explicit IStringStream
|
||||
(
|
||||
const std::string& s,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion,
|
||||
const Foam::string& name="input"
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
allocator_type(s),
|
||||
ISstream(stream_, name, format, version)
|
||||
ISstream(stream_, "input", streamOpt.format(), streamOpt.version())
|
||||
{}
|
||||
|
||||
//- Construct from char*
|
||||
explicit IStringStream
|
||||
(
|
||||
const char* s,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion,
|
||||
const Foam::string& name="input"
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
allocator_type(s),
|
||||
ISstream(stream_, name, format, version)
|
||||
ISstream(stream_, "input", streamOpt.format(), streamOpt.version())
|
||||
{}
|
||||
|
||||
//- Copy construct, copies content and format
|
||||
@ -185,6 +177,44 @@ public:
|
||||
{
|
||||
return const_cast<IStringStream&>(*this);
|
||||
}
|
||||
|
||||
|
||||
// Additional constructors and methods (as per v2012 and earlier)
|
||||
#ifdef Foam_IOstream_extras
|
||||
|
||||
//- Default construct
|
||||
explicit IStringStream
|
||||
(
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
IStringStream(IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Construct from std::string
|
||||
IStringStream
|
||||
(
|
||||
const std::string& s,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
IStringStream(s, IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Construct from char*
|
||||
IStringStream
|
||||
(
|
||||
const char* s,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
IStringStream(s, IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
#endif /* Foam_IOstream_extras */
|
||||
};
|
||||
|
||||
|
||||
@ -192,7 +222,7 @@ public:
|
||||
Class OStringStream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Output to string buffer, using a OSstream
|
||||
//- Output to string buffer, using a OSstream. Always UNCOMPRESSED.
|
||||
class OStringStream
|
||||
:
|
||||
public Detail::StringStreamAllocator<std::ostringstream>,
|
||||
@ -204,15 +234,14 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Default construct
|
||||
//- Default construct or with specified stream option
|
||||
explicit OStringStream
|
||||
(
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
allocator_type(),
|
||||
OSstream(stream_, "output", format, version)
|
||||
OSstream(stream_, "output", streamOpt.format(), streamOpt.version())
|
||||
{}
|
||||
|
||||
//- Copy construct, copies content and format
|
||||
@ -241,6 +270,22 @@ public:
|
||||
|
||||
//- Print stream description to Ostream
|
||||
virtual void print(Ostream& os) const;
|
||||
|
||||
|
||||
// Older style, without stream option (including 2012 release)
|
||||
#ifdef Foam_IOstream_extras
|
||||
|
||||
//- Default construct
|
||||
explicit OStringStream
|
||||
(
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
OStringStream(IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
#endif /* Foam_IOstream_extras */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -55,10 +55,10 @@ Foam::label Foam::ITstream::parseStream(ISstream& is, tokenList& tokens)
|
||||
Foam::tokenList Foam::ITstream::parse
|
||||
(
|
||||
const UList<char>& input,
|
||||
streamFormat format
|
||||
IOstreamOption streamOpt
|
||||
)
|
||||
{
|
||||
UIListStream is(input, format, IOstream::currentVersion);
|
||||
UIListStream is(input, streamOpt);
|
||||
|
||||
tokenList tokens;
|
||||
parseStream(is, tokens);
|
||||
@ -69,16 +69,10 @@ Foam::tokenList Foam::ITstream::parse
|
||||
Foam::tokenList Foam::ITstream::parse
|
||||
(
|
||||
const std::string& input,
|
||||
streamFormat format
|
||||
IOstreamOption streamOpt
|
||||
)
|
||||
{
|
||||
UIListStream is
|
||||
(
|
||||
input.data(),
|
||||
input.size(),
|
||||
format,
|
||||
IOstream::currentVersion
|
||||
);
|
||||
UIListStream is(input.data(), input.size(), streamOpt);
|
||||
|
||||
tokenList tokens;
|
||||
parseStream(is, tokens);
|
||||
@ -89,10 +83,10 @@ Foam::tokenList Foam::ITstream::parse
|
||||
Foam::tokenList Foam::ITstream::parse
|
||||
(
|
||||
const char* input,
|
||||
streamFormat format
|
||||
IOstreamOption streamOpt
|
||||
)
|
||||
{
|
||||
UIListStream is(input, strlen(input), format, IOstream::currentVersion);
|
||||
UIListStream is(input, strlen(input), streamOpt);
|
||||
|
||||
tokenList tokens;
|
||||
parseStream(is, tokens);
|
||||
@ -141,16 +135,15 @@ Foam::ITstream::ITstream
|
||||
(
|
||||
const string& name,
|
||||
const UList<char>& input,
|
||||
streamFormat format,
|
||||
versionNumber version
|
||||
IOstreamOption streamOpt
|
||||
)
|
||||
:
|
||||
Istream(format, version),
|
||||
Istream(streamOpt.format(), streamOpt.version()),
|
||||
tokenList(),
|
||||
name_(name),
|
||||
tokenIndex_(0)
|
||||
{
|
||||
UIListStream is(input, format, version);
|
||||
UIListStream is(input, streamOpt);
|
||||
|
||||
parseStream(is, static_cast<tokenList&>(*this));
|
||||
ITstream::rewind();
|
||||
@ -161,16 +154,15 @@ Foam::ITstream::ITstream
|
||||
(
|
||||
const string& name,
|
||||
const std::string& input,
|
||||
streamFormat format,
|
||||
versionNumber version
|
||||
IOstreamOption streamOpt
|
||||
)
|
||||
:
|
||||
Istream(format, version),
|
||||
Istream(streamOpt.format(), streamOpt.version()),
|
||||
tokenList(),
|
||||
name_(name),
|
||||
tokenIndex_(0)
|
||||
{
|
||||
UIListStream is(input.data(), input.size(), format, version);
|
||||
UIListStream is(input.data(), input.size(), streamOpt);
|
||||
|
||||
parseStream(is, static_cast<tokenList&>(*this));
|
||||
ITstream::rewind();
|
||||
@ -181,16 +173,15 @@ Foam::ITstream::ITstream
|
||||
(
|
||||
const string& name,
|
||||
const char* input,
|
||||
streamFormat format,
|
||||
versionNumber version
|
||||
IOstreamOption streamOpt
|
||||
)
|
||||
:
|
||||
Istream(format, version),
|
||||
Istream(streamOpt.format(), streamOpt.version()),
|
||||
tokenList(),
|
||||
name_(name),
|
||||
tokenIndex_(0)
|
||||
{
|
||||
UIListStream is(input, strlen(input), format, version);
|
||||
UIListStream is(input, strlen(input), streamOpt);
|
||||
|
||||
parseStream(is, static_cast<tokenList&>(*this));
|
||||
ITstream::rewind();
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -115,16 +115,15 @@ public:
|
||||
setGood();
|
||||
}
|
||||
|
||||
//- Construct from components
|
||||
//- Construct from components, copying the tokens
|
||||
ITstream
|
||||
(
|
||||
const string& name,
|
||||
const UList<token>& tokens,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
Istream(format, version),
|
||||
Istream(streamOpt.format(), streamOpt.version()),
|
||||
tokenList(tokens),
|
||||
name_(name),
|
||||
tokenIndex_(0)
|
||||
@ -138,11 +137,10 @@ public:
|
||||
(
|
||||
const string& name,
|
||||
List<token>&& tokens,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
Istream(format, version),
|
||||
Istream(streamOpt.format(), streamOpt.version()),
|
||||
tokenList(std::move(tokens)),
|
||||
name_(name),
|
||||
tokenIndex_(0)
|
||||
@ -157,8 +155,7 @@ public:
|
||||
(
|
||||
const string& name,
|
||||
const UList<char>& input,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
);
|
||||
|
||||
//- Construct token list by parsing the input string
|
||||
@ -167,8 +164,7 @@ public:
|
||||
(
|
||||
const string& name,
|
||||
const std::string& input,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
);
|
||||
|
||||
//- Construct token list by parsing the input character sequence
|
||||
@ -177,8 +173,7 @@ public:
|
||||
(
|
||||
const string& name,
|
||||
const char* input,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
);
|
||||
|
||||
|
||||
@ -193,7 +188,7 @@ public:
|
||||
static tokenList parse
|
||||
(
|
||||
const UList<char>& input,
|
||||
streamFormat format=ASCII
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
);
|
||||
|
||||
//- Create token list by parsing the input string until
|
||||
@ -201,7 +196,7 @@ public:
|
||||
static tokenList parse
|
||||
(
|
||||
const std::string& input,
|
||||
streamFormat format=ASCII
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
);
|
||||
|
||||
//- Create token list by parsing the input character sequence until
|
||||
@ -209,7 +204,7 @@ public:
|
||||
static tokenList parse
|
||||
(
|
||||
const char* input,
|
||||
streamFormat format=ASCII
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
);
|
||||
|
||||
|
||||
@ -359,6 +354,109 @@ public:
|
||||
|
||||
//- Move assignment of tokens, with rewind()
|
||||
void operator=(List<token>&& toks);
|
||||
|
||||
|
||||
// Additional constructors and methods (as per v2012 and earlier)
|
||||
#ifdef Foam_IOstream_extras
|
||||
|
||||
//- Construct from components, copying the tokens
|
||||
ITstream
|
||||
(
|
||||
const string& name,
|
||||
const UList<token>& tokens,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
ITstream(name, tokens, IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Construct from components, transferring the tokens
|
||||
ITstream
|
||||
(
|
||||
const string& name,
|
||||
List<token>&& tokens,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
ITstream(name, std::move(tokens), IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Construct token list by parsing the input character sequence
|
||||
// Uses UIListStream internally.
|
||||
ITstream
|
||||
(
|
||||
const string& name,
|
||||
const UList<char>& input,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
ITstream(name, input, IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Construct token list by parsing the input string
|
||||
// Uses UIListStream internally.
|
||||
ITstream
|
||||
(
|
||||
const string& name,
|
||||
const std::string& input,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
ITstream(name, input, IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Construct token list by parsing the input character sequence
|
||||
// Uses UIListStream internally.
|
||||
ITstream
|
||||
(
|
||||
const string& name,
|
||||
const char* input,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
ITstream(name, input, IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
|
||||
//- Create token list by parsing the input character sequence until
|
||||
//- no good tokens remain.
|
||||
static tokenList parse
|
||||
(
|
||||
const UList<char>& input,
|
||||
IOstreamOption::streamFormat fmt
|
||||
)
|
||||
{
|
||||
return parse(input, IOstreamOption(fmt));
|
||||
}
|
||||
|
||||
//- Create token list by parsing the input string until
|
||||
//- no good tokens remain.
|
||||
static tokenList parse
|
||||
(
|
||||
const std::string& input,
|
||||
IOstreamOption::streamFormat fmt
|
||||
)
|
||||
{
|
||||
return parse(input, IOstreamOption(fmt));
|
||||
}
|
||||
|
||||
//- Create token list by parsing the input character sequence until
|
||||
//- no good tokens remain.
|
||||
static tokenList parse
|
||||
(
|
||||
const char* input,
|
||||
IOstreamOption::streamFormat fmt
|
||||
)
|
||||
{
|
||||
return parse(input, IOstreamOption(fmt));
|
||||
}
|
||||
|
||||
#endif /* Foam_IOstream_extras */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -143,7 +143,7 @@ Foam::Ostream& Foam::OTstream::write(const doubleScalar val)
|
||||
|
||||
Foam::Ostream& Foam::OTstream::write(const char* data, std::streamsize count)
|
||||
{
|
||||
if (format() != BINARY)
|
||||
if (format() != IOstreamOption::BINARY)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "stream format not binary"
|
||||
@ -173,7 +173,7 @@ Foam::Ostream& Foam::OTstream::writeRaw
|
||||
|
||||
bool Foam::OTstream::beginRawWrite(std::streamsize count)
|
||||
{
|
||||
if (format() != BINARY)
|
||||
if (format() != IOstreamOption::BINARY)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "stream format not binary"
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -73,16 +73,6 @@ public:
|
||||
setGood();
|
||||
}
|
||||
|
||||
//- Construct with format, version
|
||||
explicit OTstream
|
||||
(
|
||||
streamFormat fmt,
|
||||
versionNumber ver = currentVersion
|
||||
)
|
||||
:
|
||||
OTstream(IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Copy construct
|
||||
OTstream(const OTstream& os)
|
||||
:
|
||||
@ -268,6 +258,22 @@ public:
|
||||
|
||||
//- Print stream description to Ostream
|
||||
void print(Ostream& os) const;
|
||||
|
||||
|
||||
// Additional constructors and methods (as per v2012 and earlier)
|
||||
#ifdef Foam_IOstream_extras
|
||||
|
||||
//- Construct empty with format, version
|
||||
explicit OTstream
|
||||
(
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
OTstream(IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
#endif /* Foam_IOstream_extras */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -72,10 +72,8 @@ class osha1stream
|
||||
|
||||
public:
|
||||
|
||||
//- Construct null
|
||||
sha1buf()
|
||||
{}
|
||||
|
||||
//- Default construct
|
||||
sha1buf() = default;
|
||||
|
||||
//- Full access to the sha1
|
||||
inline SHA1& sha1()
|
||||
@ -94,7 +92,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
//- Default construct
|
||||
osha1stream()
|
||||
:
|
||||
std::ostream(&buf_)
|
||||
@ -114,7 +112,6 @@ public:
|
||||
{
|
||||
return buf_.sha1();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -140,11 +137,8 @@ protected:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
OSHA1streamAllocator()
|
||||
:
|
||||
stream_()
|
||||
{}
|
||||
//- Default construct
|
||||
OSHA1streamAllocator() = default;
|
||||
|
||||
|
||||
public:
|
||||
@ -170,7 +164,6 @@ public:
|
||||
{
|
||||
return stream_.sha1().clear();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // End namespace Detail
|
||||
@ -201,14 +194,13 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct with an empty digest
|
||||
OSHA1stream
|
||||
explicit OSHA1stream
|
||||
(
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
allocator_type(),
|
||||
OSstream(stream_, "sha1", format, version)
|
||||
OSstream(stream_, "sha1", streamOpt.format(), streamOpt.version())
|
||||
{}
|
||||
|
||||
|
||||
@ -230,6 +222,22 @@ public:
|
||||
{
|
||||
sha1().clear();
|
||||
}
|
||||
|
||||
|
||||
// Additional constructors and methods (as per v2012 and earlier)
|
||||
#ifdef Foam_IOstream_extras
|
||||
|
||||
//- Construct empty
|
||||
explicit OSHA1stream
|
||||
(
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
OSHA1stream(IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
#endif /* Foam_IOstream_extras */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -48,7 +48,6 @@ See Also
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace Detail
|
||||
{
|
||||
|
||||
@ -130,7 +129,7 @@ public:
|
||||
Class IListStream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- An ISstream with internal List storage
|
||||
//- An ISstream with internal List storage. Always UNCOMPRESSED.
|
||||
class IListStream
|
||||
:
|
||||
public Detail::IListStreamAllocator,
|
||||
@ -145,26 +144,22 @@ public:
|
||||
//- Default construct with an empty list
|
||||
explicit IListStream
|
||||
(
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
allocator_type(),
|
||||
ISstream(stream_, "input", format, version)
|
||||
ISstream(stream_, "input", streamOpt.format(), streamOpt.version())
|
||||
{}
|
||||
|
||||
|
||||
//- Move construct from List
|
||||
explicit IListStream
|
||||
(
|
||||
::Foam::List<char>&& buffer, // Fully qualify (issue #1521)
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion,
|
||||
const Foam::string& name="input"
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
allocator_type(std::move(buffer)),
|
||||
ISstream(stream_, name, format, version)
|
||||
ISstream(stream_, "input", streamOpt.format(), streamOpt.version())
|
||||
{}
|
||||
|
||||
|
||||
@ -173,13 +168,11 @@ public:
|
||||
explicit IListStream
|
||||
(
|
||||
DynamicList<char,SizeMin>&& buffer,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion,
|
||||
const Foam::string& name="input"
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
allocator_type(std::move(buffer)),
|
||||
ISstream(stream_, name, format, version)
|
||||
ISstream(stream_, "input", streamOpt.format(), streamOpt.version())
|
||||
{}
|
||||
|
||||
|
||||
@ -215,6 +208,47 @@ public:
|
||||
{
|
||||
return const_cast<Istream&>(static_cast<const Istream&>(*this));
|
||||
}
|
||||
|
||||
|
||||
// Additional constructors and methods (as per v2012 and earlier)
|
||||
#ifdef Foam_IOstream_extras
|
||||
|
||||
//- Construct with an empty list
|
||||
explicit IListStream
|
||||
(
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
IListStream(IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
|
||||
//- Move construct from List
|
||||
IListStream
|
||||
(
|
||||
::Foam::List<char>&& buffer, // Fully qualify (issue #1521)
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
IListStream(std::move(buffer), IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
|
||||
//- Move construct from DynamicList
|
||||
template<int SizeMin>
|
||||
explicit IListStream
|
||||
(
|
||||
DynamicList<char,SizeMin>&& buffer,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
IListStream(std::move(buffer), IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
#endif /* Foam_IOstream_extras */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -260,12 +260,11 @@ public:
|
||||
//- Default construct
|
||||
explicit OCountStream
|
||||
(
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
allocator_type(),
|
||||
OSstream(stream_, "count", format, version)
|
||||
OSstream(stream_, "count", streamOpt.format(), streamOpt.version())
|
||||
{}
|
||||
|
||||
//- Copy construct
|
||||
@ -287,6 +286,23 @@ public:
|
||||
|
||||
//- Print stream description to Ostream
|
||||
virtual void print(Ostream& os) const;
|
||||
|
||||
|
||||
// Additional constructors and methods (as per v2012 and earlier)
|
||||
#ifdef Foam_IOstream_extras
|
||||
|
||||
//- Default construct
|
||||
explicit OCountStream
|
||||
(
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
OCountStream(IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
|
||||
#endif /* Foam_IOstream_extras */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -409,36 +409,33 @@ public:
|
||||
//- Default construct (empty output)
|
||||
explicit OListStream
|
||||
(
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
allocator_type(),
|
||||
OSstream(stream_, "output", format, version)
|
||||
OSstream(stream_, "output", streamOpt.format(), streamOpt.version())
|
||||
{}
|
||||
|
||||
//- Construct with initial reserved number of bytes
|
||||
explicit OListStream
|
||||
(
|
||||
size_t nbytes,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
allocator_type(nbytes),
|
||||
OSstream(stream_, "output", format, version)
|
||||
OSstream(stream_, "output", streamOpt.format(), streamOpt.version())
|
||||
{}
|
||||
|
||||
//- Move construct from an existing List
|
||||
explicit OListStream
|
||||
(
|
||||
List<char>&& buffer,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
allocator_type(std::move(buffer)),
|
||||
OSstream(stream_, "output", format, version)
|
||||
OSstream(stream_, "output", streamOpt.format(), streamOpt.version())
|
||||
{}
|
||||
|
||||
//- Move construct from an existing DynamicList
|
||||
@ -446,12 +443,11 @@ public:
|
||||
explicit OListStream
|
||||
(
|
||||
DynamicList<char,SizeMin>&& buffer,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
allocator_type(std::move(buffer)),
|
||||
OSstream(stream_, "output", format, version)
|
||||
OSstream(stream_, "output", streamOpt.format(), streamOpt.version())
|
||||
{}
|
||||
|
||||
|
||||
@ -466,6 +462,56 @@ public:
|
||||
|
||||
//- Print stream description to Ostream
|
||||
virtual void print(Ostream& os) const;
|
||||
|
||||
|
||||
// Additional constructors and methods (as per v2012 and earlier)
|
||||
#ifdef Foam_IOstream_extras
|
||||
|
||||
//- Default construct (empty output)
|
||||
explicit OListStream
|
||||
(
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
OListStream(IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Construct with initial reserved number of bytes
|
||||
explicit OListStream
|
||||
(
|
||||
size_t nbytes,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
OListStream(nbytes, IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Move construct from an existing List
|
||||
OListStream
|
||||
(
|
||||
List<char>&& buffer,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
OListStream(std::move(buffer), IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Move construct from an existing DynamicList
|
||||
template<int SizeMin>
|
||||
OListStream
|
||||
(
|
||||
DynamicList<char,SizeMin>&& buffer,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
OListStream(std::move(buffer), IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
#endif /* Foam_IOstream_extras */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -216,54 +216,44 @@ public:
|
||||
(
|
||||
const char* buffer,
|
||||
size_t nbytes,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion,
|
||||
const Foam::string& name="input"
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
allocator_type(const_cast<char*>(buffer), nbytes),
|
||||
ISstream(stream_, name, format, version)
|
||||
{}
|
||||
|
||||
|
||||
//- Construct using data area from a FixedList
|
||||
template<unsigned N>
|
||||
explicit UIListStream
|
||||
(
|
||||
const FixedList<char, N>& buffer,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion,
|
||||
const Foam::string& name="input"
|
||||
)
|
||||
:
|
||||
UIListStream(buffer.cdata(), N, format, version, name)
|
||||
ISstream(stream_, "input", streamOpt.format(), streamOpt.version())
|
||||
{}
|
||||
|
||||
//- Construct using data area from a List and number of bytes
|
||||
UIListStream
|
||||
(
|
||||
const UList<char>& buffer,
|
||||
label size,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion,
|
||||
const Foam::string& name="input"
|
||||
size_t nbytes,
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
UIListStream(buffer.cdata(), size, format, version, name)
|
||||
UIListStream(buffer.cdata(), nbytes, streamOpt)
|
||||
{}
|
||||
|
||||
|
||||
//- Construct using data area from a List and its inherent storage size
|
||||
// Uses addressed size, thus no special treatment for a DynamicList
|
||||
explicit UIListStream
|
||||
(
|
||||
const UList<char>& buffer,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion,
|
||||
const Foam::string& name="input"
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
UIListStream(buffer.cdata(), buffer.size(), format, version, name)
|
||||
UIListStream(buffer.cdata(), buffer.size(), streamOpt)
|
||||
{}
|
||||
|
||||
//- Construct using data area from a FixedList
|
||||
template<unsigned N>
|
||||
explicit UIListStream
|
||||
(
|
||||
const FixedList<char, N>& buffer,
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
UIListStream(buffer.cdata(), N, streamOpt)
|
||||
{}
|
||||
|
||||
|
||||
@ -294,6 +284,60 @@ public:
|
||||
{
|
||||
return const_cast<Istream&>(static_cast<const Istream&>(*this));
|
||||
}
|
||||
|
||||
|
||||
// Additional constructors and methods (as per v2012 and earlier)
|
||||
#ifdef Foam_IOstream_extras
|
||||
|
||||
//- Construct using specified buffer and number of bytes
|
||||
UIListStream
|
||||
(
|
||||
const char* buffer,
|
||||
size_t nbytes,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
UIListStream(buffer, nbytes, IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Construct using data area from a List and number of bytes
|
||||
UIListStream
|
||||
(
|
||||
const UList<char>& buffer,
|
||||
size_t nbytes,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
UIListStream(buffer.cdata(), nbytes, IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Construct using data area from a List and its inherent storage size
|
||||
// Uses addressed size, thus no special treatment for a DynamicList
|
||||
UIListStream
|
||||
(
|
||||
const UList<char>& buf,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
UIListStream(buf.cdata(), buf.size(), IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Construct using data area from a FixedList
|
||||
template<unsigned N>
|
||||
UIListStream
|
||||
(
|
||||
const FixedList<char, N>& buffer,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
UIListStream(buffer.cdata(), N, IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
#endif /* Foam_IOstream_extras */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -190,24 +190,32 @@ public:
|
||||
(
|
||||
char* buffer,
|
||||
size_t nbytes,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
allocator_type(buffer, nbytes),
|
||||
OSstream(stream_, "output", format, version)
|
||||
OSstream(stream_, "output", streamOpt.format(), streamOpt.version())
|
||||
{}
|
||||
|
||||
//- Construct using data area from a List and number of bytes
|
||||
UOListStream
|
||||
(
|
||||
UList<char>& buffer,
|
||||
size_t size,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
size_t nbytes,
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
UOListStream(buffer.data(), size, format, version)
|
||||
UOListStream(buffer.data(), nbytes, streamOpt)
|
||||
{}
|
||||
|
||||
//- Construct using data area from a List and its inherent storage size
|
||||
explicit UOListStream
|
||||
(
|
||||
UList<char>& buffer,
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
UOListStream(buffer.data(), buffer.size(), streamOpt)
|
||||
{}
|
||||
|
||||
//- Construct using data area from a FixedList
|
||||
@ -215,35 +223,21 @@ public:
|
||||
explicit UOListStream
|
||||
(
|
||||
FixedList<char, N>& buffer,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
UOListStream(buffer.data(), N, format, version)
|
||||
UOListStream(buffer.data(), N, streamOpt)
|
||||
{}
|
||||
|
||||
//- Construct using data area from a List and its inherent storage size
|
||||
explicit UOListStream
|
||||
(
|
||||
UList<char>& buffer,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
)
|
||||
:
|
||||
UOListStream(buffer.data(), buffer.size(), format, version)
|
||||
{}
|
||||
|
||||
|
||||
//- Construct using data area from a DynamicList and its capacity
|
||||
template<int SizeMin>
|
||||
explicit UOListStream
|
||||
(
|
||||
DynamicList<char,SizeMin>& buffer,
|
||||
streamFormat format=ASCII,
|
||||
versionNumber version=currentVersion
|
||||
IOstreamOption streamOpt = IOstreamOption()
|
||||
)
|
||||
:
|
||||
UOListStream(buffer.data(), buffer.capacity(), format, version)
|
||||
UOListStream(buffer.data(), buffer.capacity(), streamOpt)
|
||||
{}
|
||||
|
||||
|
||||
@ -258,6 +252,71 @@ public:
|
||||
|
||||
//- Print stream description to Ostream
|
||||
virtual void print(Ostream& os) const;
|
||||
|
||||
|
||||
// Additional constructors and methods (as per v2012 and earlier)
|
||||
#ifdef Foam_IOstream_extras
|
||||
|
||||
//- Construct using specified buffer and number of bytes
|
||||
UOListStream
|
||||
(
|
||||
char* buffer,
|
||||
size_t nbytes,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
UOListStream(buffer, nbytes, IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Construct using data area from a List and number of bytes
|
||||
UOListStream
|
||||
(
|
||||
UList<char>& buffer,
|
||||
size_t nbytes,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
UOListStream(buffer.data(), nbytes, IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Construct using data area from a List and its inherent storage size
|
||||
UOListStream
|
||||
(
|
||||
UList<char>& buffer,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
UOListStream(buffer.data(), buffer.size(), IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Construct using data area from a FixedList
|
||||
template<unsigned N>
|
||||
UOListStream
|
||||
(
|
||||
FixedList<char, N>& buffer,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
UOListStream(buffer.data(), N, IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
//- Construct using data area from a DynamicList and its capacity
|
||||
template<int SizeMin>
|
||||
UOListStream
|
||||
(
|
||||
DynamicList<char,SizeMin>& buf,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
|
||||
)
|
||||
:
|
||||
UOListStream(buf.data(), buf.capacity(), IOstreamOption(fmt, ver))
|
||||
{}
|
||||
|
||||
#endif /* Foam_IOstream_extras */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -249,7 +249,7 @@ void Foam::Time::readDict()
|
||||
|
||||
for (simpleRegIOobject* obj : objects)
|
||||
{
|
||||
OStringStream os(IOstream::ASCII);
|
||||
OStringStream os;
|
||||
os << dict;
|
||||
IStringStream is(os.str());
|
||||
obj->readData(is);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -252,8 +252,7 @@ Foam::primitiveEntry::primitiveEntry
|
||||
(
|
||||
is.name() + '.' + key,
|
||||
tokenList(10),
|
||||
is.format(),
|
||||
is.version()
|
||||
static_cast<IOstreamOption>(is)
|
||||
)
|
||||
{
|
||||
readEntry(dict, is);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,8 +29,9 @@ License
|
||||
#include "regIOobject.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "registerSwitch.H"
|
||||
#include "dictionary.H"
|
||||
#include "fileOperation.H"
|
||||
#include "registerSwitch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -73,7 +74,9 @@ Foam::regIOobject::regIOobject(const IOobject& io, const bool isTime)
|
||||
registered_(false),
|
||||
ownedByRegistry_(false),
|
||||
watchIndices_(),
|
||||
eventNo_(isTime ? 0 : db().getEvent()) // No event for top-level Time
|
||||
eventNo_(isTime ? 0 : db().getEvent()), // No event for top-level Time
|
||||
metaDataPtr_(nullptr),
|
||||
isPtr_(nullptr)
|
||||
{
|
||||
if (registerObject())
|
||||
{
|
||||
@ -90,6 +93,7 @@ Foam::regIOobject::regIOobject(const regIOobject& rio)
|
||||
ownedByRegistry_(false),
|
||||
watchIndices_(rio.watchIndices_),
|
||||
eventNo_(db().getEvent()),
|
||||
metaDataPtr_(rio.metaDataPtr_.clone()),
|
||||
isPtr_(nullptr)
|
||||
{
|
||||
// Do not register copy with objectRegistry
|
||||
@ -103,6 +107,7 @@ Foam::regIOobject::regIOobject(const regIOobject& rio, bool registerCopy)
|
||||
ownedByRegistry_(false),
|
||||
watchIndices_(),
|
||||
eventNo_(db().getEvent()),
|
||||
metaDataPtr_(rio.metaDataPtr_.clone()),
|
||||
isPtr_(nullptr)
|
||||
{
|
||||
if (registerCopy)
|
||||
@ -129,6 +134,7 @@ Foam::regIOobject::regIOobject
|
||||
ownedByRegistry_(false),
|
||||
watchIndices_(),
|
||||
eventNo_(db().getEvent()),
|
||||
metaDataPtr_(rio.metaDataPtr_.clone()),
|
||||
isPtr_(nullptr)
|
||||
{
|
||||
if (registerCopy)
|
||||
@ -152,6 +158,7 @@ Foam::regIOobject::regIOobject
|
||||
ownedByRegistry_(false),
|
||||
watchIndices_(),
|
||||
eventNo_(db().getEvent()),
|
||||
metaDataPtr_(rio.metaDataPtr_.clone()),
|
||||
isPtr_(nullptr)
|
||||
{
|
||||
if (registerObject())
|
||||
@ -474,7 +481,7 @@ bool Foam::regIOobject::headerOk()
|
||||
void Foam::regIOobject::operator=(const IOobject& io)
|
||||
{
|
||||
// Close any file
|
||||
isPtr_.clear();
|
||||
isPtr_.reset(nullptr);
|
||||
|
||||
// Check out of objectRegistry
|
||||
checkOut();
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -56,6 +56,8 @@ namespace Foam
|
||||
|
||||
// Forward Declarations
|
||||
|
||||
class dictionary;
|
||||
|
||||
namespace functionEntries
|
||||
{
|
||||
class codeStream;
|
||||
@ -78,7 +80,7 @@ protected:
|
||||
//- Helper: check readOpt flags and read if necessary
|
||||
bool readHeaderOk
|
||||
(
|
||||
const IOstream::streamFormat PstreamFormat,
|
||||
const IOstreamOption::streamFormat fmt,
|
||||
const word& typeName
|
||||
);
|
||||
|
||||
@ -106,6 +108,9 @@ private:
|
||||
//- eventNo of last update
|
||||
label eventNo_;
|
||||
|
||||
//- Dictionary for any meta-data
|
||||
autoPtr<dictionary> metaDataPtr_;
|
||||
|
||||
//- Istream for reading
|
||||
autoPtr<ISstream> isPtr_;
|
||||
|
||||
@ -277,6 +282,21 @@ public:
|
||||
virtual void rename(const word& newName);
|
||||
|
||||
|
||||
// Meta-data
|
||||
|
||||
//- Return pointer to meta-data or nullptr
|
||||
const dictionary* findMetaData() const noexcept;
|
||||
|
||||
//- Get or create meta-data
|
||||
dictionary& getMetaData() noexcept;
|
||||
|
||||
//- Remove meta-data
|
||||
void removeMetaData();
|
||||
|
||||
//- Update internal meta-data (eg, prior to writing)
|
||||
virtual void updateMetaData();
|
||||
|
||||
|
||||
// Reading
|
||||
|
||||
//- Return complete path + object name if the file exists
|
||||
@ -358,9 +378,9 @@ public:
|
||||
FOAM_DEPRECATED_FOR(2020-02, "writeObject(IOstreamOption, bool)")
|
||||
virtual bool writeObject
|
||||
(
|
||||
IOstream::streamFormat fmt,
|
||||
IOstream::versionNumber ver,
|
||||
IOstream::compressionType comp,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver,
|
||||
IOstreamOption::compressionType comp,
|
||||
const bool valid
|
||||
) const;
|
||||
};
|
||||
|
||||
59
src/OpenFOAM/db/regIOobject/regIOobjectMetaData.C
Normal file
59
src/OpenFOAM/db/regIOobject/regIOobjectMetaData.C
Normal file
@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "regIOobject.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::dictionary* Foam::regIOobject::findMetaData() const noexcept
|
||||
{
|
||||
return metaDataPtr_.get();
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary& Foam::regIOobject::getMetaData() noexcept
|
||||
{
|
||||
if (!metaDataPtr_)
|
||||
{
|
||||
metaDataPtr_.reset(new dictionary("meta"));
|
||||
}
|
||||
return *metaDataPtr_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::regIOobject::removeMetaData()
|
||||
{
|
||||
metaDataPtr_.reset(nullptr);
|
||||
}
|
||||
|
||||
|
||||
void Foam::regIOobject::updateMetaData()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,7 +37,7 @@ License
|
||||
|
||||
bool Foam::regIOobject::readHeaderOk
|
||||
(
|
||||
const IOstream::streamFormat format,
|
||||
const IOstreamOption::streamFormat fmt,
|
||||
const word& typeName
|
||||
)
|
||||
{
|
||||
@ -77,7 +77,7 @@ bool Foam::regIOobject::readHeaderOk
|
||||
|| isHeaderOk
|
||||
)
|
||||
{
|
||||
return fileHandler().read(*this, masterOnly, format, typeName);
|
||||
return fileHandler().read(*this, masterOnly, fmt, typeName);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,7 +28,6 @@ License
|
||||
|
||||
#include "regIOobject.H"
|
||||
#include "Time.H"
|
||||
#include "OSspecific.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -42,8 +41,7 @@ bool Foam::regIOobject::writeObject
|
||||
if (!good())
|
||||
{
|
||||
SeriousErrorInFunction
|
||||
<< "bad object " << name()
|
||||
<< endl;
|
||||
<< "bad object " << name() << endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -51,8 +49,7 @@ bool Foam::regIOobject::writeObject
|
||||
if (instance().empty())
|
||||
{
|
||||
SeriousErrorInFunction
|
||||
<< "instance undefined for object " << name()
|
||||
<< endl;
|
||||
<< "instance undefined for object " << name() << endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -97,9 +94,6 @@ bool Foam::regIOobject::writeObject
|
||||
}
|
||||
|
||||
|
||||
bool osGood = false;
|
||||
|
||||
|
||||
// Everyone check or just master
|
||||
bool masterOnly =
|
||||
isGlobal
|
||||
@ -108,36 +102,9 @@ bool Foam::regIOobject::writeObject
|
||||
|| regIOobject::fileModificationChecking == inotifyMaster
|
||||
);
|
||||
|
||||
|
||||
bool osGood = false;
|
||||
if (Pstream::master() || !masterOnly)
|
||||
{
|
||||
//if (mkDir(path()))
|
||||
//{
|
||||
// // Try opening an OFstream for object
|
||||
// OFstream os(objectPath(), streamOpt);
|
||||
//
|
||||
// // If any of these fail, return (leave error handling to Ostream
|
||||
// // class)
|
||||
// if (!os.good())
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if (!writeHeader(os))
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // Write the data to the Ostream
|
||||
// if (!writeData(os))
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// writeEndDivider(os);
|
||||
//
|
||||
// osGood = os.good();
|
||||
//}
|
||||
osGood = fileHandler().writeObject(*this, streamOpt, valid);
|
||||
}
|
||||
else
|
||||
@ -174,9 +141,9 @@ bool Foam::regIOobject::write(const bool valid) const
|
||||
|
||||
bool Foam::regIOobject::writeObject
|
||||
(
|
||||
IOstream::streamFormat fmt,
|
||||
IOstream::versionNumber ver,
|
||||
IOstream::compressionType cmp,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver,
|
||||
IOstreamOption::compressionType cmp,
|
||||
const bool valid
|
||||
) const
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -57,7 +57,7 @@ void Foam::simpleObjectRegistry::setValues
|
||||
|
||||
if (dEntry.isDict())
|
||||
{
|
||||
OStringStream os(IOstream::ASCII);
|
||||
OStringStream os;
|
||||
os << dEntry.dict();
|
||||
IStringStream is(os.str());
|
||||
|
||||
|
||||
@ -44,14 +44,12 @@ namespace Foam
|
||||
bool Foam::OFstreamCollator::writeFile
|
||||
(
|
||||
const label comm,
|
||||
const word& typeName,
|
||||
const word& objectType,
|
||||
const fileName& fName,
|
||||
const string& masterData,
|
||||
const labelUList& recvSizes,
|
||||
const PtrList<SubList<char>>& slaveData, // optional slave data
|
||||
IOstream::streamFormat fmt,
|
||||
IOstream::versionNumber ver,
|
||||
IOstream::compressionType cmp,
|
||||
IOstreamOption streamOpt,
|
||||
const bool append
|
||||
)
|
||||
{
|
||||
@ -60,6 +58,7 @@ bool Foam::OFstreamCollator::writeFile
|
||||
Pout<< "OFstreamCollator : Writing master " << masterData.size()
|
||||
<< " bytes to " << fName
|
||||
<< " using comm " << comm << endl;
|
||||
|
||||
if (slaveData.size())
|
||||
{
|
||||
Pout<< "OFstreamCollator : Slave data" << endl;
|
||||
@ -79,17 +78,7 @@ bool Foam::OFstreamCollator::writeFile
|
||||
if (UPstream::master(comm))
|
||||
{
|
||||
Foam::mkDir(fName.path());
|
||||
osPtr.reset
|
||||
(
|
||||
new OFstream
|
||||
(
|
||||
fName,
|
||||
fmt,
|
||||
ver,
|
||||
cmp,
|
||||
append
|
||||
)
|
||||
);
|
||||
osPtr.reset(new OFstream(fName, streamOpt, append));
|
||||
|
||||
// We don't have IOobject so cannot use IOobject::writeHeader
|
||||
if (!append)
|
||||
@ -97,11 +86,10 @@ bool Foam::OFstreamCollator::writeFile
|
||||
decomposedBlockData::writeHeader
|
||||
(
|
||||
*osPtr,
|
||||
ver,
|
||||
fmt,
|
||||
typeName,
|
||||
streamOpt, // streamOpt for container
|
||||
objectType,
|
||||
"", // note
|
||||
fName, // location
|
||||
"", // location (leave empty instead inaccurate)
|
||||
fName.name() // object name
|
||||
);
|
||||
}
|
||||
@ -119,12 +107,12 @@ bool Foam::OFstreamCollator::writeFile
|
||||
// the master processor in order. However can be unstable
|
||||
// for some mpi so default is non-blocking.
|
||||
|
||||
List<std::streamoff> start;
|
||||
List<std::streamoff> blockOffset;
|
||||
decomposedBlockData::writeBlocks
|
||||
(
|
||||
comm,
|
||||
osPtr,
|
||||
start,
|
||||
blockOffset,
|
||||
slice,
|
||||
recvSizes,
|
||||
slaveData,
|
||||
@ -154,11 +142,8 @@ bool Foam::OFstreamCollator::writeFile
|
||||
{
|
||||
sum += recv;
|
||||
}
|
||||
// Use ostringstream to display long int (until writing these is
|
||||
// supported)
|
||||
std::ostringstream os;
|
||||
os << sum;
|
||||
Pout<< " (overall " << os.str() << ")";
|
||||
// Use std::to_string to display long int
|
||||
Pout<< " (overall " << std::to_string(sum) << ')';
|
||||
}
|
||||
Pout<< " to " << fName
|
||||
<< " using comm " << comm << endl;
|
||||
@ -195,7 +180,7 @@ void* Foam::OFstreamCollator::writeAll(void *threadarg)
|
||||
PtrList<SubList<char>> slaveData;
|
||||
if (ptr->slaveData_.size())
|
||||
{
|
||||
slaveData.setSize(ptr->slaveData_.size());
|
||||
slaveData.resize(ptr->slaveData_.size());
|
||||
forAll(slaveData, proci)
|
||||
{
|
||||
if (ptr->slaveData_.set(proci))
|
||||
@ -216,14 +201,12 @@ void* Foam::OFstreamCollator::writeAll(void *threadarg)
|
||||
bool ok = writeFile
|
||||
(
|
||||
ptr->comm_,
|
||||
ptr->typeName_,
|
||||
ptr->objectType_,
|
||||
ptr->pathName_,
|
||||
ptr->data_,
|
||||
ptr->sizes_,
|
||||
slaveData,
|
||||
ptr->format_,
|
||||
ptr->version_,
|
||||
ptr->compression_,
|
||||
ptr->streamOpt_,
|
||||
ptr->append_
|
||||
);
|
||||
if (!ok)
|
||||
@ -354,12 +337,10 @@ Foam::OFstreamCollator::~OFstreamCollator()
|
||||
|
||||
bool Foam::OFstreamCollator::write
|
||||
(
|
||||
const word& typeName,
|
||||
const word& objectType,
|
||||
const fileName& fName,
|
||||
const string& data,
|
||||
IOstream::streamFormat fmt,
|
||||
IOstream::versionNumber ver,
|
||||
IOstream::compressionType cmp,
|
||||
IOstreamOption streamOpt,
|
||||
const bool append,
|
||||
const bool useThread
|
||||
)
|
||||
@ -372,10 +353,10 @@ bool Foam::OFstreamCollator::write
|
||||
off_t totalSize = 0;
|
||||
label maxLocalSize = 0;
|
||||
{
|
||||
for (label proci = 0; proci < recvSizes.size(); proci++)
|
||||
for (const label recvSize : recvSizes)
|
||||
{
|
||||
totalSize += recvSizes[proci];
|
||||
maxLocalSize = max(maxLocalSize, recvSizes[proci]);
|
||||
totalSize += recvSize;
|
||||
maxLocalSize = max(maxLocalSize, recvSize);
|
||||
}
|
||||
Pstream::scatter(totalSize, Pstream::msgType(), localComm_);
|
||||
Pstream::scatter(maxLocalSize, Pstream::msgType(), localComm_);
|
||||
@ -393,14 +374,12 @@ bool Foam::OFstreamCollator::write
|
||||
return writeFile
|
||||
(
|
||||
localComm_,
|
||||
typeName,
|
||||
objectType,
|
||||
fName,
|
||||
data,
|
||||
recvSizes,
|
||||
dummySlaveData,
|
||||
fmt,
|
||||
ver,
|
||||
cmp,
|
||||
streamOpt,
|
||||
append
|
||||
);
|
||||
}
|
||||
@ -429,7 +408,7 @@ bool Foam::OFstreamCollator::write
|
||||
new writeData
|
||||
(
|
||||
threadComm_, // Note: comm not actually used anymore
|
||||
typeName,
|
||||
objectType,
|
||||
fName,
|
||||
(
|
||||
Pstream::master(localComm_)
|
||||
@ -437,9 +416,7 @@ bool Foam::OFstreamCollator::write
|
||||
: string::null
|
||||
),
|
||||
recvSizes,
|
||||
fmt,
|
||||
ver,
|
||||
cmp,
|
||||
streamOpt,
|
||||
append
|
||||
)
|
||||
);
|
||||
@ -464,7 +441,7 @@ bool Foam::OFstreamCollator::write
|
||||
(
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
proci,
|
||||
reinterpret_cast<char*>(slaveData[proci].data()),
|
||||
slaveData[proci].data(),
|
||||
slaveData[proci].size_bytes(),
|
||||
Pstream::msgType(),
|
||||
localComm_
|
||||
@ -479,7 +456,7 @@ bool Foam::OFstreamCollator::write
|
||||
(
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
0,
|
||||
reinterpret_cast<const char*>(slice.cdata()),
|
||||
slice.cdata(),
|
||||
slice.size_bytes(),
|
||||
Pstream::msgType(),
|
||||
localComm_
|
||||
@ -559,13 +536,11 @@ bool Foam::OFstreamCollator::write
|
||||
new writeData
|
||||
(
|
||||
threadComm_,
|
||||
typeName,
|
||||
objectType,
|
||||
fName,
|
||||
data,
|
||||
recvSizes,
|
||||
fmt,
|
||||
ver,
|
||||
cmp,
|
||||
streamOpt,
|
||||
append
|
||||
)
|
||||
);
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -42,9 +43,6 @@ Description
|
||||
collecting is done locally; the thread only does the writing
|
||||
(since the data has already been collected)
|
||||
|
||||
|
||||
Operation determine
|
||||
|
||||
SourceFiles
|
||||
OFstreamCollator.C
|
||||
|
||||
@ -71,60 +69,52 @@ namespace Foam
|
||||
|
||||
class OFstreamCollator
|
||||
{
|
||||
// Private class
|
||||
// Private Class
|
||||
|
||||
class writeData
|
||||
struct writeData
|
||||
{
|
||||
public:
|
||||
|
||||
const label comm_;
|
||||
const word typeName_;
|
||||
const word objectType_;
|
||||
const fileName pathName_;
|
||||
const string data_;
|
||||
const labelList sizes_;
|
||||
PtrList<List<char>> slaveData_;
|
||||
const IOstream::streamFormat format_;
|
||||
const IOstream::versionNumber version_;
|
||||
const IOstream::compressionType compression_;
|
||||
const IOstreamOption streamOpt_;
|
||||
const bool append_;
|
||||
|
||||
writeData
|
||||
(
|
||||
const label comm,
|
||||
const word& typeName,
|
||||
const word& objectType,
|
||||
const fileName& pathName,
|
||||
const string& data,
|
||||
const labelList& sizes,
|
||||
IOstream::streamFormat format,
|
||||
IOstream::versionNumber version,
|
||||
IOstream::compressionType compression,
|
||||
IOstreamOption streamOpt,
|
||||
const bool append
|
||||
)
|
||||
:
|
||||
comm_(comm),
|
||||
typeName_(typeName),
|
||||
objectType_(objectType),
|
||||
pathName_(pathName),
|
||||
data_(data),
|
||||
sizes_(sizes),
|
||||
slaveData_(0),
|
||||
format_(format),
|
||||
version_(version),
|
||||
compression_(compression),
|
||||
slaveData_(),
|
||||
streamOpt_(streamOpt),
|
||||
append_(append)
|
||||
{}
|
||||
|
||||
//- (approximate) size of master + any optional slave data
|
||||
//- The (approximate) size of master + any optional slave data
|
||||
off_t size() const
|
||||
{
|
||||
off_t sz = data_.size();
|
||||
off_t totalSize = data_.size();
|
||||
forAll(slaveData_, i)
|
||||
{
|
||||
if (slaveData_.set(i))
|
||||
{
|
||||
sz += slaveData_[i].size();
|
||||
totalSize += slaveData_[i].size();
|
||||
}
|
||||
}
|
||||
return sz;
|
||||
return totalSize;
|
||||
}
|
||||
};
|
||||
|
||||
@ -157,14 +147,12 @@ class OFstreamCollator
|
||||
static bool writeFile
|
||||
(
|
||||
const label comm,
|
||||
const word& typeName,
|
||||
const word& objectType,
|
||||
const fileName& fName,
|
||||
const string& masterData,
|
||||
const labelUList& recvSizes,
|
||||
const PtrList<SubList<char>>& slaveData,
|
||||
IOstream::streamFormat fmt,
|
||||
IOstream::versionNumber ver,
|
||||
IOstream::compressionType cmp,
|
||||
IOstreamOption streamOpt,
|
||||
const bool append
|
||||
);
|
||||
|
||||
@ -185,10 +173,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from buffer size. 0 = do not use thread
|
||||
OFstreamCollator(const off_t maxBufferSize);
|
||||
explicit OFstreamCollator(const off_t maxBufferSize);
|
||||
|
||||
//- Construct from buffer size (0 = do not use thread) and local
|
||||
// thread
|
||||
//- Construct from buffer size (0 = do not use thread)
|
||||
//- and specified communicator
|
||||
OFstreamCollator(const off_t maxBufferSize, const label comm);
|
||||
|
||||
|
||||
@ -196,18 +184,17 @@ public:
|
||||
virtual ~OFstreamCollator();
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
//- Write file with contents. Blocks until writethread has space
|
||||
// available (total file sizes < maxBufferSize)
|
||||
//- Write file with contents.
|
||||
// Blocks until writethread has space available
|
||||
// (total file sizes < maxBufferSize)
|
||||
bool write
|
||||
(
|
||||
const word& typeName,
|
||||
const word& objectType,
|
||||
const fileName&,
|
||||
const string& data,
|
||||
IOstream::streamFormat,
|
||||
IOstream::versionNumber,
|
||||
IOstream::compressionType,
|
||||
IOstreamOption streamOpt,
|
||||
const bool append,
|
||||
const bool useThread = true
|
||||
);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -74,13 +74,13 @@ namespace fileOperations
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::labelList Foam::fileOperations::collatedFileOperation::ioRanks()
|
||||
{
|
||||
labelList ioRanks;
|
||||
|
||||
string ioRanksString(getEnv("FOAM_IORANKS"));
|
||||
string ioRanksString(Foam::getEnv("FOAM_IORANKS"));
|
||||
if (!ioRanksString.empty())
|
||||
{
|
||||
IStringStream is(ioRanksString);
|
||||
@ -91,6 +91,102 @@ Foam::labelList Foam::fileOperations::collatedFileOperation::ioRanks()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileOperations::collatedFileOperation::printBanner
|
||||
(
|
||||
const bool printRanks
|
||||
) const
|
||||
{
|
||||
DetailInfo
|
||||
<< "I/O : " << this->type();
|
||||
|
||||
if (maxThreadFileBufferSize == 0)
|
||||
{
|
||||
DetailInfo
|
||||
<< " [unthreaded] (maxThreadFileBufferSize = 0)." << nl
|
||||
<< " Writing may be slow for large file sizes."
|
||||
<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
DetailInfo
|
||||
<< " [threaded] (maxThreadFileBufferSize = "
|
||||
<< maxThreadFileBufferSize << ")." << nl
|
||||
<< " Requires buffer large enough to collect all data"
|
||||
" or thread support" << nl
|
||||
<< " enabled in MPI. If MPI thread support cannot be"
|
||||
" enabled, deactivate" << nl
|
||||
<< " threading by setting maxThreadFileBufferSize"
|
||||
" to 0 in" << nl
|
||||
<< " OpenFOAM etc/controlDict" << endl;
|
||||
}
|
||||
|
||||
if (printRanks)
|
||||
{
|
||||
// Information about the ranks
|
||||
stringList ioRanks(Pstream::nProcs());
|
||||
if (Pstream::master(comm_))
|
||||
{
|
||||
// Don't usually need the pid
|
||||
// ioRanks[Pstream::myProcNo()] = hostName()+"."+name(pid());
|
||||
ioRanks[Pstream::myProcNo()] = hostName();
|
||||
}
|
||||
Pstream::gatherList(ioRanks);
|
||||
|
||||
DynamicList<label> offsetMaster(Pstream::nProcs());
|
||||
|
||||
forAll(ioRanks, ranki)
|
||||
{
|
||||
if (!ioRanks[ranki].empty())
|
||||
{
|
||||
offsetMaster.append(ranki);
|
||||
}
|
||||
}
|
||||
|
||||
if (offsetMaster.size() > 1)
|
||||
{
|
||||
DetailInfo
|
||||
<< "IO nodes:" << nl << '(' << nl;
|
||||
|
||||
offsetMaster.append(Pstream::nProcs());
|
||||
|
||||
for (label group = 1; group < offsetMaster.size(); ++group)
|
||||
{
|
||||
const label beg = offsetMaster[group-1];
|
||||
const label end = offsetMaster[group];
|
||||
|
||||
DetailInfo
|
||||
<< " (" << ioRanks[beg].c_str() << ' '
|
||||
<< (end-beg) << ')' << nl;
|
||||
}
|
||||
DetailInfo
|
||||
<< ')' << nl;
|
||||
}
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
regIOobject::fileModificationChecking
|
||||
== regIOobject::inotifyMaster
|
||||
)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Resetting fileModificationChecking to inotify" << endl;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
regIOobject::fileModificationChecking
|
||||
== regIOobject::timeStampMaster
|
||||
)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Resetting fileModificationChecking to timeStamp" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fileOperations::collatedFileOperation::isMasterRank
|
||||
(
|
||||
const label proci
|
||||
@ -121,9 +217,9 @@ bool Foam::fileOperations::collatedFileOperation::appendObject
|
||||
IOstreamOption streamOpt
|
||||
) const
|
||||
{
|
||||
// Append to processors/ file
|
||||
// Append to processorsNN/ file
|
||||
|
||||
label proci = detectProcessorPath(io.objectPath());
|
||||
const label proci = detectProcessorPath(io.objectPath());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
@ -132,59 +228,21 @@ bool Foam::fileOperations::collatedFileOperation::appendObject
|
||||
<< " appending processor " << proci
|
||||
<< " data to " << pathName << endl;
|
||||
}
|
||||
|
||||
if (proci == -1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Not a valid processor path " << pathName
|
||||
<< "Invalid processor path: " << pathName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const bool isMaster = isMasterRank(proci);
|
||||
|
||||
// Determine local rank (offset) if the pathName is a per-rank one
|
||||
label localProci = proci;
|
||||
// Update meta-data for current state
|
||||
if (isMaster)
|
||||
{
|
||||
fileName path, procDir, local;
|
||||
procRangeType group;
|
||||
label nProcs;
|
||||
splitProcessorPath(pathName, path, procDir, local, group, nProcs);
|
||||
|
||||
// The local rank (offset)
|
||||
if (!group.empty())
|
||||
{
|
||||
localProci = proci - group.start();
|
||||
}
|
||||
const_cast<regIOobject&>(io).updateMetaData();
|
||||
}
|
||||
|
||||
|
||||
// Create string from all data to write
|
||||
string buf;
|
||||
{
|
||||
OStringStream os(streamOpt.format(), streamOpt.version());
|
||||
if (isMaster)
|
||||
{
|
||||
if (!io.writeHeader(os))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Write the data to the Ostream
|
||||
if (!io.writeData(os))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isMaster)
|
||||
{
|
||||
IOobject::writeEndDivider(os);
|
||||
}
|
||||
|
||||
buf = os.str();
|
||||
}
|
||||
|
||||
|
||||
// Note: cannot do append + compression. This is a limitation
|
||||
// of ogzstream (or rather most compressed formats)
|
||||
|
||||
@ -204,34 +262,20 @@ bool Foam::fileOperations::collatedFileOperation::appendObject
|
||||
|
||||
if (isMaster)
|
||||
{
|
||||
IOobject::writeBanner(os)
|
||||
<< "FoamFile\n{\n"
|
||||
<< " version " << os.version() << ";\n"
|
||||
<< " format " << os.format() << ";\n"
|
||||
<< " class " << decomposedBlockData::typeName
|
||||
<< ";\n";
|
||||
|
||||
// This may be useful to have as well
|
||||
if (os.format() == IOstream::BINARY)
|
||||
{
|
||||
os << " arch " << foamVersion::buildArch << ";\n";
|
||||
}
|
||||
|
||||
os << " location " << pathName << ";\n"
|
||||
<< " object " << pathName.name() << ";\n"
|
||||
<< "}" << nl;
|
||||
IOobject::writeDivider(os) << nl;
|
||||
decomposedBlockData::writeHeader(os, streamOpt, io);
|
||||
}
|
||||
|
||||
// Write data
|
||||
UList<char> slice
|
||||
std::streamoff blockOffset = decomposedBlockData::writeBlockEntry
|
||||
(
|
||||
const_cast<char*>(buf.data()),
|
||||
label(buf.size())
|
||||
os,
|
||||
streamOpt,
|
||||
io,
|
||||
proci,
|
||||
// With FoamFile header on master?
|
||||
isMaster
|
||||
);
|
||||
os << nl << "// Processor" << localProci << nl << slice << nl;
|
||||
|
||||
return os.good();
|
||||
return (blockOffset >= 0) && os.good();
|
||||
}
|
||||
|
||||
|
||||
@ -260,81 +304,9 @@ Foam::fileOperations::collatedFileOperation::collatedFileOperation
|
||||
nProcs_(Pstream::nProcs()),
|
||||
ioRanks_(ioRanks())
|
||||
{
|
||||
verbose = (verbose && Foam::infoDetailLevel > 0);
|
||||
|
||||
if (verbose)
|
||||
if (verbose && Foam::infoDetailLevel > 0)
|
||||
{
|
||||
DetailInfo
|
||||
<< "I/O : " << typeName
|
||||
<< " (maxThreadFileBufferSize " << maxThreadFileBufferSize
|
||||
<< ')' << endl;
|
||||
|
||||
if (maxThreadFileBufferSize == 0)
|
||||
{
|
||||
DetailInfo
|
||||
<< " Threading not activated "
|
||||
"since maxThreadFileBufferSize = 0." << nl
|
||||
<< " Writing may run slowly for large file sizes."
|
||||
<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
DetailInfo
|
||||
<< " Threading activated "
|
||||
"since maxThreadFileBufferSize > 0." << nl
|
||||
<< " Requires large enough buffer to collect all data"
|
||||
" or thread support " << nl
|
||||
<< " enabled in MPI. If thread support cannot be "
|
||||
"enabled, deactivate" << nl
|
||||
<< " threading by setting maxThreadFileBufferSize "
|
||||
"to 0 in" << nl
|
||||
<< " OpenFOAM etc/controlDict"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (ioRanks_.size())
|
||||
{
|
||||
// Print a bit of information
|
||||
stringList ioRanks(Pstream::nProcs());
|
||||
if (Pstream::master(comm_))
|
||||
{
|
||||
ioRanks[Pstream::myProcNo()] = hostName()+"."+name(pid());
|
||||
}
|
||||
Pstream::gatherList(ioRanks);
|
||||
|
||||
DetailInfo
|
||||
<< " IO nodes:" << nl;
|
||||
|
||||
for (const string& ranks : ioRanks)
|
||||
{
|
||||
if (!ranks.empty())
|
||||
{
|
||||
DetailInfo
|
||||
<< " " << ranks << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if
|
||||
(
|
||||
regIOobject::fileModificationChecking
|
||||
== regIOobject::inotifyMaster
|
||||
)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Resetting fileModificationChecking to inotify" << endl;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
regIOobject::fileModificationChecking
|
||||
== regIOobject::timeStampMaster
|
||||
)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Resetting fileModificationChecking to timeStamp" << endl;
|
||||
}
|
||||
this->printBanner(ioRanks_.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,56 +325,9 @@ Foam::fileOperations::collatedFileOperation::collatedFileOperation
|
||||
nProcs_(Pstream::nProcs()),
|
||||
ioRanks_(ioRanks)
|
||||
{
|
||||
verbose = (verbose && Foam::infoDetailLevel > 0);
|
||||
|
||||
if (verbose)
|
||||
if (verbose && Foam::infoDetailLevel > 0)
|
||||
{
|
||||
DetailInfo
|
||||
<< "I/O : " << typeName
|
||||
<< " (maxThreadFileBufferSize " << maxThreadFileBufferSize
|
||||
<< ')' << endl;
|
||||
|
||||
if (maxThreadFileBufferSize == 0)
|
||||
{
|
||||
DetailInfo
|
||||
<< " Threading not activated "
|
||||
"since maxThreadFileBufferSize = 0." << nl
|
||||
<< " Writing may run slowly for large file sizes."
|
||||
<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
DetailInfo
|
||||
<< " Threading activated "
|
||||
"since maxThreadFileBufferSize > 0." << nl
|
||||
<< " Requires large enough buffer to collect all data"
|
||||
" or thread support " << nl
|
||||
<< " enabled in MPI. If thread support cannot be "
|
||||
"enabled, deactivate" << nl
|
||||
<< " threading by setting maxThreadFileBufferSize "
|
||||
"to 0 in the OpenFOAM etc/controlDict" << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
regIOobject::fileModificationChecking
|
||||
== regIOobject::inotifyMaster
|
||||
)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Resetting fileModificationChecking to inotify" << endl;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
regIOobject::fileModificationChecking
|
||||
== regIOobject::timeStampMaster
|
||||
)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Resetting fileModificationChecking to timeStamp" << endl;
|
||||
}
|
||||
this->printBanner(ioRanks_.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -460,6 +385,9 @@ bool Foam::fileOperations::collatedFileOperation::writeObject
|
||||
const Time& tm = io.time();
|
||||
const fileName& inst = io.instance();
|
||||
|
||||
// Update meta-data for current state
|
||||
const_cast<regIOobject&>(io).updateMetaData();
|
||||
|
||||
if (inst.isAbsolute() || !tm.processorCase())
|
||||
{
|
||||
mkDir(io.path());
|
||||
@ -481,23 +409,22 @@ bool Foam::fileOperations::collatedFileOperation::writeObject
|
||||
valid
|
||||
);
|
||||
|
||||
// If any of these fail, return (leave error handling to Ostream class)
|
||||
if (!os.good())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!io.writeHeader(os))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Write the data to the Ostream
|
||||
if (!io.writeData(os))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
IOobject::writeEndDivider(os);
|
||||
// If any of these fail, return
|
||||
// (leave error handling to Ostream class)
|
||||
|
||||
return true;
|
||||
const bool ok =
|
||||
(
|
||||
os.good()
|
||||
&& io.writeHeader(os)
|
||||
&& io.writeData(os)
|
||||
);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
IOobject::writeEndDivider(os);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -525,24 +452,22 @@ bool Foam::fileOperations::collatedFileOperation::writeObject
|
||||
valid
|
||||
);
|
||||
|
||||
// If any of these fail, return (leave error handling to Ostream
|
||||
// class)
|
||||
if (!os.good())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!io.writeHeader(os))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Write the data to the Ostream
|
||||
if (!io.writeData(os))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
IOobject::writeEndDivider(os);
|
||||
// If any of these fail, return
|
||||
// (leave error handling to Ostream class)
|
||||
|
||||
return true;
|
||||
const bool ok =
|
||||
(
|
||||
os.good()
|
||||
&& io.writeHeader(os)
|
||||
&& io.writeData(os)
|
||||
);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
IOobject::writeEndDivider(os);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
else if (!Pstream::parRun())
|
||||
{
|
||||
@ -561,7 +486,7 @@ bool Foam::fileOperations::collatedFileOperation::writeObject
|
||||
{
|
||||
// Re-check static maxThreadFileBufferSize variable to see
|
||||
// if needs to use threading
|
||||
bool useThread = (maxThreadFileBufferSize > 0);
|
||||
const bool useThread = (maxThreadFileBufferSize > 0);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
@ -584,27 +509,25 @@ bool Foam::fileOperations::collatedFileOperation::writeObject
|
||||
useThread
|
||||
);
|
||||
|
||||
// If any of these fail, return (leave error handling to Ostream
|
||||
// class)
|
||||
if (!os.good())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (Pstream::master(comm_) && !io.writeHeader(os))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Write the data to the Ostream
|
||||
if (!io.writeData(os))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// If any of these fail, return
|
||||
// (leave error handling to Ostream class)
|
||||
|
||||
bool ok = os.good();
|
||||
|
||||
if (Pstream::master(comm_))
|
||||
{
|
||||
IOobject::writeEndDivider(os);
|
||||
// Suppress comment banner
|
||||
const bool old = IOobject::bannerEnabled(false);
|
||||
|
||||
ok = ok && io.writeHeader(os);
|
||||
|
||||
IOobject::bannerEnabled(old);
|
||||
}
|
||||
|
||||
return true;
|
||||
ok = ok && io.writeData(os);
|
||||
// No end divider for collated output
|
||||
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -637,7 +560,7 @@ Foam::word Foam::fileOperations::collatedFileOperation::processorsDir
|
||||
{
|
||||
procDir +=
|
||||
+ "_"
|
||||
+ Foam::name(procs[0])
|
||||
+ Foam::name(procs.first())
|
||||
+ "-"
|
||||
+ Foam::name(procs.last());
|
||||
}
|
||||
@ -657,19 +580,19 @@ Foam::word Foam::fileOperations::collatedFileOperation::processorsDir
|
||||
// Find lowest io rank
|
||||
label minProc = 0;
|
||||
label maxProc = nProcs_-1;
|
||||
forAll(ioRanks_, i)
|
||||
for (const label ranki : ioRanks_)
|
||||
{
|
||||
if (ioRanks_[i] >= nProcs_)
|
||||
if (ranki >= nProcs_)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (ioRanks_[i] <= proci)
|
||||
else if (ranki <= proci)
|
||||
{
|
||||
minProc = ioRanks_[i];
|
||||
minProc = ranki;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxProc = ioRanks_[i]-1;
|
||||
maxProc = ranki-1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ class collatedFileOperation
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
// Protected Data
|
||||
|
||||
//- Any communicator allocated by me
|
||||
const label myComm_;
|
||||
@ -82,15 +82,19 @@ protected:
|
||||
const labelList ioRanks_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
// Protected Member Functions
|
||||
|
||||
//- Retrieve list of IO ranks from FOAM_IORANKS env variable
|
||||
static labelList ioRanks();
|
||||
|
||||
//- Print banner information, optionally with io ranks
|
||||
void printBanner(const bool printRanks = false) const;
|
||||
|
||||
//- Is proci master of communicator (in parallel) or master of
|
||||
// the io ranks (non-parallel)
|
||||
//- the io ranks (non-parallel)
|
||||
bool isMasterRank(const label proci) const;
|
||||
|
||||
//- Append to processors/ file
|
||||
//- Append to processorsNN/ file
|
||||
bool appendObject
|
||||
(
|
||||
const regIOobject& io,
|
||||
@ -105,7 +109,7 @@ public:
|
||||
TypeName("collated");
|
||||
|
||||
|
||||
// Static data
|
||||
// Static Data
|
||||
|
||||
//- Max size of thread buffer size. This is the overall size of
|
||||
// all files to be written. Starts blocking if not enough size.
|
||||
@ -115,8 +119,8 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
collatedFileOperation(bool verbose);
|
||||
//- Default construct
|
||||
explicit collatedFileOperation(bool verbose);
|
||||
|
||||
//- Construct from user communicator
|
||||
collatedFileOperation
|
||||
@ -163,8 +167,8 @@ public:
|
||||
//- Actual name of processors dir
|
||||
virtual word processorsDir(const fileName&) const;
|
||||
|
||||
//- Set number of processor directories/results. Only used in
|
||||
// decomposePar
|
||||
//- Set number of processor directories/results.
|
||||
//- Only used in decomposePar
|
||||
virtual void setNProcs(const label nProcs);
|
||||
};
|
||||
|
||||
@ -197,9 +201,7 @@ public:
|
||||
//- Needs threading
|
||||
virtual bool needsThreading() const
|
||||
{
|
||||
return
|
||||
collatedFileOperation::maxThreadFileBufferSize
|
||||
> 0;
|
||||
return (collatedFileOperation::maxThreadFileBufferSize > 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -137,31 +138,14 @@ Foam::fileOperations::hostCollatedFileOperation::hostCollatedFileOperation
|
||||
UPstream::worldComm,
|
||||
subRanks(Pstream::nProcs())
|
||||
),
|
||||
(Pstream::parRun() ? labelList(0) : ioRanks()), // processor dirs
|
||||
(Pstream::parRun() ? labelList() : ioRanks()), // processor dirs
|
||||
typeName,
|
||||
verbose
|
||||
false // verbose
|
||||
)
|
||||
{
|
||||
verbose = (verbose && Foam::infoDetailLevel > 0);
|
||||
|
||||
if (verbose)
|
||||
if (verbose && Foam::infoDetailLevel > 0)
|
||||
{
|
||||
// Print a bit of information
|
||||
stringList ioRanks(Pstream::nProcs());
|
||||
if (Pstream::master(comm_))
|
||||
{
|
||||
ioRanks[Pstream::myProcNo()] = hostName()+"."+name(pid());
|
||||
}
|
||||
Pstream::gatherList(ioRanks);
|
||||
|
||||
Info<< " IO nodes:" << nl;
|
||||
for (const string& ranks : ioRanks)
|
||||
{
|
||||
if (!ranks.empty())
|
||||
{
|
||||
Info<< " " << ranks << nl;
|
||||
}
|
||||
}
|
||||
this->printBanner(ioRanks_.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -90,8 +91,8 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
hostCollatedFileOperation(const bool verbose);
|
||||
//- Default construct
|
||||
explicit hostCollatedFileOperation(const bool verbose);
|
||||
|
||||
|
||||
//- Destructor
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -40,7 +40,7 @@ Foam::threadedCollatedOFstream::threadedCollatedOFstream
|
||||
const bool useThread
|
||||
)
|
||||
:
|
||||
OStringStream(streamOpt.format(), streamOpt.version()),
|
||||
OStringStream(streamOpt),
|
||||
writer_(writer),
|
||||
pathName_(pathName),
|
||||
compression_(streamOpt.compression()),
|
||||
@ -57,9 +57,7 @@ Foam::threadedCollatedOFstream::~threadedCollatedOFstream()
|
||||
decomposedBlockData::typeName,
|
||||
pathName_,
|
||||
str(),
|
||||
IOstream::BINARY,
|
||||
version(),
|
||||
compression_,
|
||||
IOstreamOption(IOstream::BINARY, version(), compression_),
|
||||
false, // append=false
|
||||
useThread_
|
||||
);
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -44,6 +45,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
class OFstreamCollator;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -54,13 +56,14 @@ class threadedCollatedOFstream
|
||||
:
|
||||
public OStringStream
|
||||
{
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
//- The backend writer
|
||||
OFstreamCollator& writer_;
|
||||
|
||||
const fileName pathName_;
|
||||
|
||||
const IOstream::compressionType compression_;
|
||||
const IOstreamOption::compressionType compression_;
|
||||
|
||||
const bool useThread_;
|
||||
|
||||
@ -78,14 +81,22 @@ public:
|
||||
const bool useThread = true
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~threadedCollatedOFstream();
|
||||
|
||||
|
||||
// Additional constructors and methods (as per v2012 and earlier)
|
||||
#ifdef Foam_IOstream_extras
|
||||
|
||||
//- Construct and set stream status
|
||||
threadedCollatedOFstream
|
||||
(
|
||||
OFstreamCollator& writer,
|
||||
const fileName& pathname,
|
||||
streamFormat fmt,
|
||||
versionNumber ver = currentVersion,
|
||||
compressionType comp = compressionType::UNCOMPRESSED,
|
||||
IOstreamOption::streamFormat fmt,
|
||||
IOstreamOption::versionNumber ver = IOstreamOption::currentVersion,
|
||||
IOstreamOption::compressionType cmp = IOstreamOption::UNCOMPRESSED,
|
||||
const bool useThread = true
|
||||
)
|
||||
:
|
||||
@ -93,14 +104,12 @@ public:
|
||||
(
|
||||
writer,
|
||||
pathname,
|
||||
IOstreamOption(fmt, ver, comp),
|
||||
IOstreamOption(fmt, ver, cmp),
|
||||
useThread
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
~threadedCollatedOFstream();
|
||||
#endif /* Foam_IOstream_extras */
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -635,24 +635,24 @@ bool Foam::fileOperation::writeObject
|
||||
|
||||
OSstream& os = *osPtr;
|
||||
|
||||
// Update meta-data for current state
|
||||
const_cast<regIOobject&>(io).updateMetaData();
|
||||
|
||||
// If any of these fail, return (leave error handling to Ostream class)
|
||||
if (!os.good())
|
||||
|
||||
const bool ok =
|
||||
(
|
||||
os.good()
|
||||
&& io.writeHeader(os)
|
||||
&& io.writeData(os)
|
||||
);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
return false;
|
||||
IOobject::writeEndDivider(os);
|
||||
}
|
||||
|
||||
if (!io.writeHeader(os))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write the data to the Ostream
|
||||
if (!io.writeData(os))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
IOobject::writeEndDivider(os);
|
||||
return ok;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -1087,29 +1087,15 @@ Foam::label Foam::fileOperation::nProcs
|
||||
}
|
||||
nProcs = maxProc+1;
|
||||
|
||||
|
||||
if (nProcs == 0 && Foam::isDir(dir/processorsBaseDir))
|
||||
{
|
||||
fileName pointsFile
|
||||
(
|
||||
dir
|
||||
/processorsBaseDir
|
||||
/"constant"
|
||||
/local
|
||||
/polyMesh::meshSubDir
|
||||
/"points"
|
||||
);
|
||||
WarningInFunction
|
||||
<< "Defunct collated naming: " << processorsBaseDir << nl
|
||||
<< "Manually rename with the decomposition number. Eg," << nl << nl
|
||||
<< " mv processors processors16" << nl << nl
|
||||
<< "...returning 1" << endl;
|
||||
|
||||
if (Foam::isFile(pointsFile))
|
||||
{
|
||||
nProcs = decomposedBlockData::numBlocks(pointsFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction << "Cannot read file " << pointsFile
|
||||
<< " to determine the number of decompositions."
|
||||
<< " Returning 1" << endl;
|
||||
}
|
||||
nProcs = 1;
|
||||
}
|
||||
}
|
||||
Pstream::scatter(nProcs, Pstream::msgType(), comm_);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -437,7 +437,7 @@ public:
|
||||
(
|
||||
regIOobject&,
|
||||
const bool masterOnly,
|
||||
const IOstream::streamFormat format,
|
||||
const IOstreamOption::streamFormat format,
|
||||
const word& typeName
|
||||
) const = 0;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -500,7 +500,7 @@ void Foam::fileOperations::masterUncollatedFileOperation::readAndSend
|
||||
PstreamBuffers& pBufs
|
||||
)
|
||||
{
|
||||
IFstream ifs(filePath, IOstream::streamFormat::BINARY);
|
||||
IFstream ifs(filePath, IOstreamOption::BINARY);
|
||||
|
||||
if (!ifs.good())
|
||||
{
|
||||
@ -516,7 +516,7 @@ void Foam::fileOperations::masterUncollatedFileOperation::readAndSend
|
||||
<< filePath << endl;
|
||||
}
|
||||
|
||||
if (ifs.compression() == IOstream::compressionType::COMPRESSED)
|
||||
if (ifs.compression() == IOstreamOption::COMPRESSED)
|
||||
{
|
||||
// Could use Foam::fileSize, estimate uncompressed size (eg, 2x)
|
||||
// and then string reserve followed by string assign...
|
||||
@ -832,7 +832,7 @@ masterUncollatedFileOperationInitialise(int& argc, char**& argv)
|
||||
if (argv[i] == s)
|
||||
{
|
||||
index = i;
|
||||
setEnv("FOAM_IORANKS", argv[i+1], true);
|
||||
Foam::setEnv("FOAM_IORANKS", argv[i+1], true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1782,12 +1782,8 @@ bool Foam::fileOperations::masterUncollatedFileOperation::readHeader
|
||||
|
||||
if (is.good())
|
||||
{
|
||||
ok = io.readHeader(is);
|
||||
if (io.headerClassName() == decomposedBlockData::typeName)
|
||||
{
|
||||
// Read the header inside the container (master data)
|
||||
ok = decomposedBlockData::readMasterHeader(io, is);
|
||||
}
|
||||
// Regular header or from decomposed data
|
||||
ok = decomposedBlockData::readHeader(io, is);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1831,22 +1827,8 @@ bool Foam::fileOperations::masterUncollatedFileOperation::readHeader
|
||||
|
||||
if (is.good())
|
||||
{
|
||||
result[proci] = io.readHeader(is);
|
||||
if
|
||||
(
|
||||
io.headerClassName()
|
||||
== decomposedBlockData::typeName
|
||||
)
|
||||
{
|
||||
// Read the header inside the container
|
||||
// (master data)
|
||||
result[proci] = decomposedBlockData::
|
||||
readMasterHeader
|
||||
(
|
||||
io,
|
||||
is
|
||||
);
|
||||
}
|
||||
result[proci] =
|
||||
decomposedBlockData::readHeader(io, is);
|
||||
headerClassName[proci] = io.headerClassName();
|
||||
note[proci] = io.note();
|
||||
}
|
||||
@ -1905,7 +1887,7 @@ Foam::fileOperations::masterUncollatedFileOperation::readStream
|
||||
// have no file to read from. This will only happen when using
|
||||
// normal writing since then the fName for the valid processors is
|
||||
// processorDDD/<instance>/.. . In case of collocated writing
|
||||
// the fName is already rewritten to processors/.
|
||||
// the fName is already rewritten to processorsNN/.
|
||||
|
||||
isPtr.reset(new IFstream(fName));
|
||||
|
||||
@ -1914,11 +1896,9 @@ Foam::fileOperations::masterUncollatedFileOperation::readStream
|
||||
// Read header data (on copy)
|
||||
headerIO.readHeader(*isPtr);
|
||||
|
||||
if (headerIO.headerClassName() == decomposedBlockData::typeName)
|
||||
{
|
||||
isCollated = true;
|
||||
}
|
||||
else if (!Pstream::parRun())
|
||||
isCollated = decomposedBlockData::isCollatedType(headerIO);
|
||||
|
||||
if (!isCollated && !Pstream::parRun())
|
||||
{
|
||||
// Short circuit: non-collated format. No parallel bits.
|
||||
// Copy header and return.
|
||||
@ -2087,7 +2067,7 @@ bool Foam::fileOperations::masterUncollatedFileOperation::read
|
||||
(
|
||||
regIOobject& io,
|
||||
const bool masterOnly,
|
||||
const IOstream::streamFormat format,
|
||||
const IOstreamOption::streamFormat format,
|
||||
const word& typeName
|
||||
) const
|
||||
{
|
||||
@ -2202,29 +2182,27 @@ bool Foam::fileOperations::masterUncollatedFileOperation::writeObject
|
||||
// Make sure to pick up any new times
|
||||
setTime(io.time());
|
||||
|
||||
// Update meta-data for current state
|
||||
const_cast<regIOobject&>(io).updateMetaData();
|
||||
|
||||
autoPtr<OSstream> osPtr(NewOFstream(pathName, streamOpt, valid));
|
||||
OSstream& os = osPtr();
|
||||
OSstream& os = *osPtr;
|
||||
|
||||
// If any of these fail, return (leave error handling to Ostream class)
|
||||
if (!os.good())
|
||||
|
||||
const bool ok =
|
||||
(
|
||||
os.good()
|
||||
&& io.writeHeader(os)
|
||||
&& io.writeData(os)
|
||||
);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
return false;
|
||||
IOobject::writeEndDivider(os);
|
||||
}
|
||||
|
||||
if (!io.writeHeader(os))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write the data to the Ostream
|
||||
if (!io.writeData(os))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
IOobject::writeEndDivider(os);
|
||||
|
||||
return true;
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -89,7 +89,7 @@ class masterUncollatedFileOperation
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
// Protected Data
|
||||
|
||||
//- Any communicator allocated by me
|
||||
const label myComm_;
|
||||
@ -98,7 +98,7 @@ protected:
|
||||
mutable HashPtrTable<instantList> times_;
|
||||
|
||||
|
||||
// Protected classes
|
||||
// Protected Classes
|
||||
|
||||
class mkDirOp
|
||||
{
|
||||
@ -488,8 +488,8 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
masterUncollatedFileOperation(bool verbose);
|
||||
//- Default construct
|
||||
explicit masterUncollatedFileOperation(bool verbose);
|
||||
|
||||
//- Construct from communicator
|
||||
masterUncollatedFileOperation(const label comm, bool verbose);
|
||||
@ -679,7 +679,7 @@ public:
|
||||
(
|
||||
regIOobject&,
|
||||
const bool masterOnly,
|
||||
const IOstream::streamFormat format,
|
||||
const IOstreamOption::streamFormat format,
|
||||
const word& typeName
|
||||
) const;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -508,13 +508,8 @@ bool Foam::fileOperations::uncollatedFileOperation::readHeader
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ok = io.readHeader(*isPtr);
|
||||
|
||||
if (io.headerClassName() == decomposedBlockData::typeName)
|
||||
{
|
||||
// Read the header inside the container (master data)
|
||||
ok = decomposedBlockData::readMasterHeader(io, *isPtr);
|
||||
}
|
||||
// Regular header or from decomposed data
|
||||
bool ok = decomposedBlockData::readHeader(io, *isPtr);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
@ -570,8 +565,9 @@ Foam::fileOperations::uncollatedFileOperation::readStream
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
if (io.headerClassName() != decomposedBlockData::typeName)
|
||||
if (!decomposedBlockData::isCollatedType(io))
|
||||
{
|
||||
// Short circuit: non-collated format.
|
||||
return isPtr;
|
||||
}
|
||||
else
|
||||
@ -613,7 +609,7 @@ bool Foam::fileOperations::uncollatedFileOperation::read
|
||||
(
|
||||
regIOobject& io,
|
||||
const bool masterOnly,
|
||||
const IOstream::streamFormat format,
|
||||
const IOstreamOption::streamFormat format,
|
||||
const word& typeName
|
||||
) const
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -86,7 +86,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Default construct
|
||||
uncollatedFileOperation(bool verbose);
|
||||
explicit uncollatedFileOperation(bool verbose);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -272,7 +272,7 @@ public:
|
||||
(
|
||||
regIOobject&,
|
||||
const bool masterOnly,
|
||||
const IOstream::streamFormat format,
|
||||
const IOstreamOption::streamFormat format,
|
||||
const word& typeName
|
||||
) const;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -225,10 +225,9 @@ void Foam::csvTableReader<Type>::write(Ostream& os) const
|
||||
os.writeEntry("refColumn", refColumn_);
|
||||
|
||||
// Force writing labelList in ASCII
|
||||
const enum IOstream::streamFormat fmt = os.format();
|
||||
os.format(IOstream::ASCII);
|
||||
const auto oldFmt = os.format(IOstream::ASCII);
|
||||
os.writeEntry("componentColumns", componentColumns_);
|
||||
os.format(fmt);
|
||||
os.format(oldFmt);
|
||||
|
||||
os.writeEntry("separator", string(separator_));
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user