mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: additional data.class, data.format entries for collated
This commit is contained in:
@ -29,6 +29,7 @@ License
|
|||||||
#include "OFstreamCollator.H"
|
#include "OFstreamCollator.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "decomposedBlockData.H"
|
#include "decomposedBlockData.H"
|
||||||
|
#include "dictionary.H"
|
||||||
#include "masterUncollatedFileOperation.H"
|
#include "masterUncollatedFileOperation.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
@ -50,7 +51,8 @@ bool Foam::OFstreamCollator::writeFile
|
|||||||
const labelUList& recvSizes,
|
const labelUList& recvSizes,
|
||||||
const PtrList<SubList<char>>& slaveData, // optional slave data
|
const PtrList<SubList<char>>& slaveData, // optional slave data
|
||||||
IOstreamOption streamOpt,
|
IOstreamOption streamOpt,
|
||||||
const bool append
|
const bool append,
|
||||||
|
const dictionary* headerEntriesPtr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -93,7 +95,8 @@ bool Foam::OFstreamCollator::writeFile
|
|||||||
objectType,
|
objectType,
|
||||||
"", // note
|
"", // note
|
||||||
"", // location (leave empty instead inaccurate)
|
"", // 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_,
|
ptr->sizes_,
|
||||||
slaveData,
|
slaveData,
|
||||||
ptr->streamOpt_,
|
ptr->streamOpt_,
|
||||||
ptr->append_
|
ptr->append_,
|
||||||
|
ptr->headerEntries_
|
||||||
);
|
);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
@ -345,7 +349,8 @@ bool Foam::OFstreamCollator::write
|
|||||||
const string& data,
|
const string& data,
|
||||||
IOstreamOption streamOpt,
|
IOstreamOption streamOpt,
|
||||||
const bool append,
|
const bool append,
|
||||||
const bool useThread
|
const bool useThread,
|
||||||
|
const dictionary* headerEntriesPtr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Determine (on master) sizes to receive. Note: do NOT use thread
|
// Determine (on master) sizes to receive. Note: do NOT use thread
|
||||||
@ -383,7 +388,8 @@ bool Foam::OFstreamCollator::write
|
|||||||
recvSizes,
|
recvSizes,
|
||||||
dummySlaveData,
|
dummySlaveData,
|
||||||
streamOpt,
|
streamOpt,
|
||||||
append
|
append,
|
||||||
|
headerEntriesPtr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (totalSize <= maxBufferSize_)
|
else if (totalSize <= maxBufferSize_)
|
||||||
@ -420,7 +426,8 @@ bool Foam::OFstreamCollator::write
|
|||||||
),
|
),
|
||||||
recvSizes,
|
recvSizes,
|
||||||
streamOpt,
|
streamOpt,
|
||||||
append
|
append,
|
||||||
|
headerEntriesPtr
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
writeData& fileAndData = fileAndDataPtr();
|
writeData& fileAndData = fileAndDataPtr();
|
||||||
@ -544,7 +551,8 @@ bool Foam::OFstreamCollator::write
|
|||||||
data,
|
data,
|
||||||
recvSizes,
|
recvSizes,
|
||||||
streamOpt,
|
streamOpt,
|
||||||
append
|
append,
|
||||||
|
headerEntriesPtr
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -63,6 +63,9 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
class dictionary;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class OFstreamCollator Declaration
|
Class OFstreamCollator Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -81,6 +84,7 @@ class OFstreamCollator
|
|||||||
PtrList<List<char>> slaveData_;
|
PtrList<List<char>> slaveData_;
|
||||||
const IOstreamOption streamOpt_;
|
const IOstreamOption streamOpt_;
|
||||||
const bool append_;
|
const bool append_;
|
||||||
|
const dictionary* headerEntries_;
|
||||||
|
|
||||||
writeData
|
writeData
|
||||||
(
|
(
|
||||||
@ -90,7 +94,8 @@ class OFstreamCollator
|
|||||||
const string& data,
|
const string& data,
|
||||||
const labelList& sizes,
|
const labelList& sizes,
|
||||||
IOstreamOption streamOpt,
|
IOstreamOption streamOpt,
|
||||||
const bool append
|
const bool append,
|
||||||
|
const dictionary* headerEntriesPtr = nullptr
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
comm_(comm),
|
comm_(comm),
|
||||||
@ -100,7 +105,8 @@ class OFstreamCollator
|
|||||||
sizes_(sizes),
|
sizes_(sizes),
|
||||||
slaveData_(),
|
slaveData_(),
|
||||||
streamOpt_(streamOpt),
|
streamOpt_(streamOpt),
|
||||||
append_(append)
|
append_(append),
|
||||||
|
headerEntries_(headerEntriesPtr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- The (approximate) size of master + any optional slave data
|
//- The (approximate) size of master + any optional slave data
|
||||||
@ -153,7 +159,8 @@ class OFstreamCollator
|
|||||||
const labelUList& recvSizes,
|
const labelUList& recvSizes,
|
||||||
const PtrList<SubList<char>>& slaveData,
|
const PtrList<SubList<char>>& slaveData,
|
||||||
IOstreamOption streamOpt,
|
IOstreamOption streamOpt,
|
||||||
const bool append
|
const bool append,
|
||||||
|
const dictionary* headerEntriesPtr
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Write all files in stack
|
//- Write all files in stack
|
||||||
@ -196,7 +203,8 @@ public:
|
|||||||
const string& data,
|
const string& data,
|
||||||
IOstreamOption streamOpt,
|
IOstreamOption streamOpt,
|
||||||
const bool append,
|
const bool append,
|
||||||
const bool useThread = true
|
const bool useThread = true,
|
||||||
|
const dictionary* headerEntriesPtr = nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Wait for all thread actions to have finished
|
//- Wait for all thread actions to have finished
|
||||||
|
|||||||
@ -493,6 +493,16 @@ bool Foam::fileOperations::collatedFileOperation::writeObject
|
|||||||
ok = ok && io.writeHeader(os);
|
ok = ok && io.writeHeader(os);
|
||||||
|
|
||||||
IOobject::bannerEnabled(old);
|
IOobject::bannerEnabled(old);
|
||||||
|
|
||||||
|
// Additional header content
|
||||||
|
dictionary dict;
|
||||||
|
decomposedBlockData::writeExtraHeaderContent
|
||||||
|
(
|
||||||
|
dict,
|
||||||
|
streamOpt,
|
||||||
|
io
|
||||||
|
);
|
||||||
|
os.setHeaderEntries(dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = ok && io.writeData(os);
|
ok = ok && io.writeData(os);
|
||||||
|
|||||||
@ -44,7 +44,8 @@ Foam::threadedCollatedOFstream::threadedCollatedOFstream
|
|||||||
writer_(writer),
|
writer_(writer),
|
||||||
pathName_(pathName),
|
pathName_(pathName),
|
||||||
compression_(streamOpt.compression()),
|
compression_(streamOpt.compression()),
|
||||||
useThread_(useThread)
|
useThread_(useThread),
|
||||||
|
headerEntries_()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -59,9 +60,18 @@ Foam::threadedCollatedOFstream::~threadedCollatedOFstream()
|
|||||||
str(),
|
str(),
|
||||||
IOstreamOption(IOstream::BINARY, version(), compression_),
|
IOstreamOption(IOstream::BINARY, version(), compression_),
|
||||||
false, // append=false
|
false, // append=false
|
||||||
useThread_
|
useThread_,
|
||||||
|
&headerEntries_
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::threadedCollatedOFstream::setHeaderEntries(const dictionary& dict)
|
||||||
|
{
|
||||||
|
headerEntries_ = dict;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -38,6 +38,7 @@ SourceFiles
|
|||||||
#ifndef threadedCollatedOFstream_H
|
#ifndef threadedCollatedOFstream_H
|
||||||
#define threadedCollatedOFstream_H
|
#define threadedCollatedOFstream_H
|
||||||
|
|
||||||
|
#include "dictionary.H"
|
||||||
#include "StringStream.H"
|
#include "StringStream.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -67,6 +68,9 @@ class threadedCollatedOFstream
|
|||||||
|
|
||||||
const bool useThread_;
|
const bool useThread_;
|
||||||
|
|
||||||
|
//- Additional FoamFile entries for decomposed data
|
||||||
|
dictionary headerEntries_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -86,6 +90,12 @@ public:
|
|||||||
~threadedCollatedOFstream();
|
~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)
|
// Additional constructors and methods (as per v2012 and earlier)
|
||||||
#ifdef Foam_IOstream_extras
|
#ifdef Foam_IOstream_extras
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user