ENH: additional data.class, data.format entries for collated

This commit is contained in:
Mark Olesen
2021-03-16 19:06:25 +01:00
parent f8c2928a88
commit dc27daf4f4
5 changed files with 59 additions and 13 deletions

View File

@ -29,6 +29,7 @@ License
#include "OFstreamCollator.H"
#include "OFstream.H"
#include "decomposedBlockData.H"
#include "dictionary.H"
#include "masterUncollatedFileOperation.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,7 +51,8 @@ bool Foam::OFstreamCollator::writeFile
const labelUList& recvSizes,
const PtrList<SubList<char>>& slaveData, // optional slave data
IOstreamOption streamOpt,
const bool append
const bool append,
const dictionary* headerEntriesPtr
)
{
if (debug)
@ -93,7 +95,8 @@ bool Foam::OFstreamCollator::writeFile
objectType,
"", // note
"", // location (leave empty instead inaccurate)
fName.name() // object name
fName.name(), // object name
headerEntriesPtr
);
}
}
@ -210,7 +213,8 @@ void* Foam::OFstreamCollator::writeAll(void *threadarg)
ptr->sizes_,
slaveData,
ptr->streamOpt_,
ptr->append_
ptr->append_,
ptr->headerEntries_
);
if (!ok)
{
@ -345,7 +349,8 @@ bool Foam::OFstreamCollator::write
const string& data,
IOstreamOption streamOpt,
const bool append,
const bool useThread
const bool useThread,
const dictionary* headerEntriesPtr
)
{
// Determine (on master) sizes to receive. Note: do NOT use thread
@ -383,7 +388,8 @@ bool Foam::OFstreamCollator::write
recvSizes,
dummySlaveData,
streamOpt,
append
append,
headerEntriesPtr
);
}
else if (totalSize <= maxBufferSize_)
@ -420,7 +426,8 @@ bool Foam::OFstreamCollator::write
),
recvSizes,
streamOpt,
append
append,
headerEntriesPtr
)
);
writeData& fileAndData = fileAndDataPtr();
@ -544,7 +551,8 @@ bool Foam::OFstreamCollator::write
data,
recvSizes,
streamOpt,
append
append,
headerEntriesPtr
)
);

View File

@ -63,6 +63,9 @@ SourceFiles
namespace Foam
{
// Forward Declarations
class dictionary;
/*---------------------------------------------------------------------------*\
Class OFstreamCollator Declaration
\*---------------------------------------------------------------------------*/
@ -81,6 +84,7 @@ class OFstreamCollator
PtrList<List<char>> slaveData_;
const IOstreamOption streamOpt_;
const bool append_;
const dictionary* headerEntries_;
writeData
(
@ -90,7 +94,8 @@ class OFstreamCollator
const string& data,
const labelList& sizes,
IOstreamOption streamOpt,
const bool append
const bool append,
const dictionary* headerEntriesPtr = nullptr
)
:
comm_(comm),
@ -100,7 +105,8 @@ class OFstreamCollator
sizes_(sizes),
slaveData_(),
streamOpt_(streamOpt),
append_(append)
append_(append),
headerEntries_(headerEntriesPtr)
{}
//- The (approximate) size of master + any optional slave data
@ -153,7 +159,8 @@ class OFstreamCollator
const labelUList& recvSizes,
const PtrList<SubList<char>>& slaveData,
IOstreamOption streamOpt,
const bool append
const bool append,
const dictionary* headerEntriesPtr
);
//- Write all files in stack
@ -196,7 +203,8 @@ public:
const string& data,
IOstreamOption streamOpt,
const bool append,
const bool useThread = true
const bool useThread = true,
const dictionary* headerEntriesPtr = nullptr
);
//- Wait for all thread actions to have finished

View File

@ -493,6 +493,16 @@ bool Foam::fileOperations::collatedFileOperation::writeObject
ok = ok && io.writeHeader(os);
IOobject::bannerEnabled(old);
// Additional header content
dictionary dict;
decomposedBlockData::writeExtraHeaderContent
(
dict,
streamOpt,
io
);
os.setHeaderEntries(dict);
}
ok = ok && io.writeData(os);

View File

@ -44,7 +44,8 @@ Foam::threadedCollatedOFstream::threadedCollatedOFstream
writer_(writer),
pathName_(pathName),
compression_(streamOpt.compression()),
useThread_(useThread)
useThread_(useThread),
headerEntries_()
{}
@ -59,9 +60,18 @@ Foam::threadedCollatedOFstream::~threadedCollatedOFstream()
str(),
IOstreamOption(IOstream::BINARY, version(), compression_),
false, // append=false
useThread_
useThread_,
&headerEntries_
);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::threadedCollatedOFstream::setHeaderEntries(const dictionary& dict)
{
headerEntries_ = dict;
}
// ************************************************************************* //

View File

@ -38,6 +38,7 @@ SourceFiles
#ifndef threadedCollatedOFstream_H
#define threadedCollatedOFstream_H
#include "dictionary.H"
#include "StringStream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -67,6 +68,9 @@ class threadedCollatedOFstream
const bool useThread_;
//- Additional FoamFile entries for decomposed data
dictionary headerEntries_;
public:
@ -86,6 +90,12 @@ public:
~threadedCollatedOFstream();
// Member Functions
//- Define the header entries for the data block(s)
void setHeaderEntries(const dictionary& dict);
// Additional constructors and methods (as per v2012 and earlier)
#ifdef Foam_IOstream_extras