Commit 183f89e6 authored by mark's avatar mark

STYLE: relocate iobuffer_ to adiosCore as transfer_

- makes it easier to centralize/manage later.
  Helps when separating the read routines.
parent f8b02a8f
......@@ -69,6 +69,8 @@ Foam::adiosCore::timeAttribute = "/time";
unsigned Foam::adiosCore::refCount_ = 0;
Foam::DynamicCharList Foam::adiosCore::transfer_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......@@ -100,6 +102,8 @@ void Foam::adiosCore::global_finalize()
{
MPI_Finalize();
}
transfer_.clearStorage();
}
--refCount_;
......
......@@ -40,6 +40,8 @@ SourceFiles
#include "instantList.H"
#include "IOstreams.H"
#include "NamedEnum.H"
#include "CStringList.H"
#include "DynamicCharList.H"
#include "IBufStream.H"
#include "OBufStream.H"
......@@ -49,8 +51,6 @@ SourceFiles
#include "OCompactBufStream.H"
#include "OCompactCountStream.H"
#include "CStringList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
......@@ -114,6 +114,10 @@ protected:
//- File extension for ADIOS files
static const word fileExt;
//- Buffer for reading/writing (streamed) content to/from ADIOS files
static DynamicCharList transfer_;
public:
//- OpenFOAM global attributes within ADIOS file
......
......@@ -40,7 +40,6 @@ SourceFiles
#include "regIOobject.H"
#include "GeometricField.H"
#include "Pstream.H"
#include "DynamicCharList.H"
#include "adios.h"
#include "adios_read.h"
......@@ -108,12 +107,6 @@ private:
protected:
// Protected data
//- Buffer for reading/writing streamed content to/from adios files
DynamicCharList iobuffer_;
// Protected Member Functions
//- MPI communicator
......
......@@ -120,14 +120,14 @@ void Foam::adiosCoreWrite::writeMeshFaces(const polyMesh& mesh)
// this is not particularly elegant, but should be stable
List<label> start(nFaces+1);
// // use iobuffer_ to avoid reallocations
// // use transfer_ to avoid reallocations
// UList<label> start
// (
// reinterpret_cast<label*>(iobuffer_.data()),
// iobuffer_.capacity() / sizeof(label)
// reinterpret_cast<label*>(transfer_.data()),
// transfer_.capacity() / sizeof(label)
// );
// use iobuffer_ to avoid reallocations
// use transfer_ to avoid reallocations
// Pout<< "indices " << start.size() << endl;
// calculate start as per CompactIOList.C:
......@@ -153,11 +153,11 @@ void Foam::adiosCoreWrite::writeMeshFaces(const polyMesh& mesh)
// this is not particularly elegant, but should be stable
List<label> elems(start[start.size()-1]);
// use iobuffer_ to avoid reallocations
// use transfer_ to avoid reallocations
// UList<label> elems
// (
// reinterpret_cast<label*>(iobuffer_.data()),
// iobuffer_.capacity() / sizeof(label)
// reinterpret_cast<label*>(transfer_.data()),
// transfer_.capacity() / sizeof(label)
// );
// Pout<< "size: " << elems.size() << endl;
......
......@@ -84,14 +84,14 @@ int64_t Foam::adiosCoreWrite::writeStreamVariable
int64_t varid = defineStreamVariable(varName, counter.size());
// Use iobuffer_ to avoid too many reallocations - needs some rework?
iobuffer_.reserve(adios_expected_var_size(varid));
// Use transfer_ to avoid too many reallocations - needs some rework?
transfer_.reserve(adios_expected_var_size(varid));
OutputBufStreamer os(iobuffer_, adiosCore::strFormat);
OutputBufStreamer os(transfer_, adiosCore::strFormat);
os << obj;
// Do the actual write (as stream)
writeVariable(varName, iobuffer_);
writeVariable(varName, transfer_);
return varid;
}
......
......@@ -64,8 +64,8 @@ bool Foam::adiosWrite::cloudRead
IDLList<pType> newParcels;
if (src.nParcels())
{
size_t nread = reader.getBuffered(src.fullName(), iobuffer_);
IBufStream is(iobuffer_, nread, IOstream::BINARY);
size_t nread = reader.getBuffered(src.fullName(), transfer_);
IBufStream is(transfer_, nread, IOstream::BINARY);
newParcels = IDLList<pType>(is, typename pType::iNew(mesh));
}
......@@ -175,12 +175,12 @@ Foam::label Foam::adiosWrite::writeCloud
// stream contents
int64_t varid = defineStreamVariable(varName, totalLen);
// use iobuffer_ to avoid too many reallocations
// use transfer_ to avoid too many reallocations
// Needs rework?
iobuffer_.reserve(adios_expected_var_size(varid));
transfer_.reserve(adios_expected_var_size(varid));
// stream the cloud contents - always binary content
CloudOutputStream os(iobuffer_, IOstream::BINARY);
CloudOutputStream os(transfer_, IOstream::BINARY);
os << '('; // opening '('
forAllConstIter(typename CloudType, cld, pIter)
......@@ -205,7 +205,7 @@ Foam::label Foam::adiosWrite::writeCloud
Pout<< "cloud-stream: " << dbg.str() << endl;
}
writeVariable(varName, iobuffer_);
writeVariable(varName, transfer_);
}
......
......@@ -45,11 +45,11 @@ bool Foam::adiosWrite::fieldRead
)
{
// Read data from file - fatal error if this fails!
size_t nread = reader.getBuffered(src.fullName(), iobuffer_);
size_t nread = reader.getBuffered(src.fullName(), transfer_);
if (nread)
{
// read fields via dictionary
IBufStream is(iobuffer_, nread, adiosCore::strFormat);
IBufStream is(transfer_, nread, adiosCore::strFormat);
dictionary dict(is);
// Pout<<"dictionary: " << field.name() << " with "
......@@ -82,12 +82,12 @@ bool Foam::adiosWrite::fieldRead
// Pout<< " readField via dictionary: " << field.name() << endl;
// Read data from file - fatal error if this fails!
size_t nread = reader.getBuffered(src.fullName(), iobuffer_);
size_t nread = reader.getBuffered(src.fullName(), transfer_);
if (nread)
{
// read fields via dictionary
IBufStream is(iobuffer_, nread, adiosCore::strFormat);
IBufStream is(transfer_, nread, adiosCore::strFormat);
dictionary dict(is);
// Pout<<"dictionary: " << field.name() << " with "
......
......@@ -41,7 +41,7 @@ Foam::adiosTime Foam::adiosWrite::readData(const fileName& bpFile)
adiosTime timeInfo(reader);
iobuffer_.reserve(reader.sizeOf()); // this is per process
transfer_.reserve(reader.sizeOf()); // this is per process
// direct lookup via time_.lookupClass<fvMesh>() would be nice,
// but have to trick the compiler not to get the const-version.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment