...
 
Commits (4)
......@@ -15,13 +15,13 @@ ThirdParty
Until this is fully integrated into OpenFOAM, the user should compile
ADIOS using the ThirdParty `makeADIOS` script with the preferred ADIOS version.
Subsequently, set `ADIOS_ARCH_PATH` accordingly. Eg,
Subsequently, set `ADIOS1_ARCH_PATH` accordingly. Eg,
adios_version=ADIOS-1.11.0
export ADIOS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$adios_version
export ADIOS1_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$adios_version
And optionally add it to the PATH
PATH=$ADIOS_ARCH_PATH/bin:$PATH
PATH=$ADIOS1_ARCH_PATH/bin:$PATH
---
* Cold restart
* Not all Lagrangian types are yet supported
......@@ -18,7 +18,7 @@
* Storage directory: "adiosData/"
* Each "ofbp" (OpenFOAM binary packed) adios file is restricted to a
* Each "bp" (OpenFOAM binary packed) adios file is restricted to a
***single*** time-step/iteration.
This makes for simple and efficient handling.
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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/>.
Typedef
Foam::DynamicCharList
Description
A temporary measure to avoid issues with the resizing template parameters
in DynamicList that make it difficult to use for constructors.
May need to consider refactoring DynamicList to use a non-resizing base
class.
\*---------------------------------------------------------------------------*/
#ifndef DynamicCharList_H
#define DynamicCharList_H
#include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef DynamicList<char> DynamicCharList;
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
......@@ -48,7 +48,7 @@ const Foam::word
Foam::adiosCore::dataDirectory("adiosData");
const Foam::word
Foam::adiosCore::fileExt("ofbp");
Foam::adiosCore::fileExt("bp");
const Foam::string
Foam::adiosCore::foamAttribute = "/openfoam";
......@@ -58,45 +58,7 @@ Foam::adiosCore::timeAttribute = "/time";
unsigned Foam::adiosCore::refCount_ = 0;
Foam::DynamicCharList Foam::adiosCore::transfer_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::adiosCore::global_init()
{
if (refCount_ == 0) // first one in
{
if (!Pstream::parRun())
{
// NULL args are OK for openmpi, mpich-2
MPI_Init(nullptr, nullptr);
}
// Runtime assertions (verify assumed sizes) - or emit a fatal error
adiosTraits<label>::ok();
adiosTraits<scalar>::ok();
}
++refCount_;
}
void Foam::adiosCore::global_finalize()
{
if (refCount_ == 1) // last one out
{
// Cleanup our own MPI_Init()
if (!Pstream::parRun())
{
MPI_Finalize();
}
transfer_.clearStorage();
}
--refCount_;
}
Foam::DynamicList<char> Foam::adiosCore::transfer_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -108,7 +70,13 @@ Foam::adiosCore::adiosCore
:
name_(name)
{
global_init();
// runtime assertions (verify assumed sizes) - or emit a fatal error
adiosTraits<label>::ok();
adiosTraits<scalar>::ok();
Pstream::initNull(); // Even in serial, ADIOS needs MPI
++refCount_;
}
......@@ -116,7 +84,13 @@ Foam::adiosCore::adiosCore
Foam::adiosCore::~adiosCore()
{
global_finalize();
--refCount_;
if (!refCount_)
{
// Last one out
transfer_.clearStorage();
}
}
......
......@@ -41,15 +41,14 @@ SourceFiles
#include "IOstreams.H"
#include "Enum.H"
#include "CStringList.H"
#include "DynamicCharList.H"
#include "DynamicList.H"
#include "IBufStream.H"
#include "OBufStream.H"
#include "OCountStream.H"
#include "UListStream.H"
#include "OCompactStringStream.H"
#include "OCompactBufStream.H"
#include "OCompactCountStream.H"
#include "OCountCompactStream.H"
#include "OStringCompactStream.H"
#include "UOListCompactStream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -83,7 +82,7 @@ private:
// Static data
//- Reference counting for handling mpi init/finalize in serial
//- Reference counting for cleanup of common transfer buffer
static unsigned refCount_;
......@@ -93,17 +92,6 @@ private:
word name_;
// Private Member Functions
//- Global initializations.
// Eg, Manual MPI_Init for serial runs (ADIOS always requires mpi).
static void global_init();
//- Cleanup global initializations.
// Eg, Manual MPI_Finalize for serial runs.
static void global_finalize();
protected:
// Protected data
......@@ -115,7 +103,7 @@ protected:
static const word fileExt;
//- Buffer for reading/writing (streamed) content to/from ADIOS files
static DynamicCharList transfer_;
static DynamicList<char> transfer_;
public:
......@@ -129,12 +117,12 @@ public:
// static const IOstream::streamFormat strFormat = IOstream::ASCII;
static const IOstream::streamFormat strFormat = IOstream::BINARY;
typedef OCompactStringStream OutputStringStreamer;
typedef OCompactBufStream OutputBufStreamer;
typedef OCompactCountStream OutputCounter;
typedef OStringCompactStream OutputStringStreamer;
typedef UOListCompactStream OutputListStreamer;
typedef OCountCompactStream OutputCounter;
// typedef OStringStream OStringStreamer;
// typedef OBufStream OutputBufStreamer;
// typedef UOListStream OutputListStreamer;
// typedef OCountStream OutputCounter;
......@@ -210,7 +198,7 @@ public:
//- Buffer for reading/writing (streamed) content to/from ADIOS files.
// Also used when reading/writing dissimilar content.
inline static DynamicCharList& transferBuffer()
inline static DynamicList<char>& transferBuffer()
{
return transfer_;
}
......
......@@ -175,7 +175,7 @@ size_t Foam::adiosCoreWrite::maxSize() const
{
size_t maxLen = 0;
forAllConstIter(VarHashType, vars_, iter)
forAllConstIters(vars_, iter)
{
maxLen = Foam::max(maxLen, adios_expected_var_size(iter()));
}
......@@ -188,7 +188,7 @@ size_t Foam::adiosCoreWrite::outputSize() const
{
size_t total = 0;
forAllConstIter(VarHashType, vars_, iter)
forAllConstIters(vars_, iter)
{
total += adios_expected_var_size(iter());
}
......
......@@ -104,7 +104,7 @@ int64_t Foam::adiosCoreWrite::writeStreamVariable
// - Needs some rework to cleanup or for byte-alignment?
transferBuffer().reserve(adios_expected_var_size(varid));
OutputBufStreamer os(transferBuffer(), adiosCore::strFormat);
OutputListStreamer os(transferBuffer(), adiosCore::strFormat);
os << obj;
// Do the actual write (as stream)
......
......@@ -231,7 +231,7 @@ Foam::adiosReader::getFieldInfo(const word& regName) const
HashTable<fieldInfo> table;
forAllConstIter(VarContainer, variables, iter)
forAllConstIters(variables, iter)
{
const fileName& varName = iter.key();
const VarInfo& varInfo = iter();
......@@ -259,7 +259,7 @@ Foam::adiosReader::getFieldInfo(const word& regName) const
}
// Info<<"Table ";
// forAllConstIter(HashTable<fieldInfo>, table, iter)
// forAllConstIters(table, iter)
// {
// iter().info(Info);
// }
......@@ -275,7 +275,7 @@ Foam::adiosReader::getCloudInfo(const word& regName) const
HashTable<cloudInfo> table;
forAllConstIter(VarContainer, variables, iter)
forAllConstIters(variables, iter)
{
const fileName& varName = iter.key();
const VarInfo& varInfo = iter();
......@@ -454,7 +454,7 @@ bool Foam::adiosReader::readIntListAttributeIfPresent
if (ok)
{
if (type == adios_integer || adios_unsigned_integer)
if (type == adios_integer || type == adios_unsigned_integer)
{
// we don't distinguish between signed/unsigned
// mostly just use signed anyhow
......
......@@ -39,7 +39,7 @@ SourceFiles
#include "fileName.H"
#include "fvMesh.H"
#include "IBufStream.H"
#include "UIListStream.H"
#include "regIOobject.H"
#include "HashTable.H"
#include "Ostream.H"
......
......@@ -24,10 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "fileName.H"
#include "IBufStream.H"
#include "DynamicCharList.H"
#include "HashTable.H"
#include "Ostream.H"
#include "adios.h"
......
......@@ -41,7 +41,7 @@ Foam::label Foam::adiosReader::copyList
const fileName& varName
) const
{
DynamicCharList& buffer = adiosCore::transferBuffer();
DynamicList<char>& buffer = adiosCore::transferBuffer();
label sizeRead = -1;
if (hasVariable(varName))
......@@ -206,7 +206,7 @@ Foam::label Foam::adiosReader::readGeometricField
if (nread)
{
// read fields via dictionary
IBufStream is
UIListStream is
(
adiosCore::transferBuffer(),
nread,
......
......@@ -127,7 +127,7 @@ void Foam::ParcelEncoding::setNames(Istream& is)
// the input types are the driver, get the corresponding name
label nNames = 0;
token tok;
forAllIter(Container, *this, iter)
forAllIters(*this, iter)
{
Fragment& frag = iter();
// Info<<"filling: " << frag.type_ << endl;
......@@ -245,7 +245,7 @@ void Foam::ParcelEncoding::makeSummary()
names_.setSize(size());
label idx = 0;
forAllConstIter(Container, *this, iter)
forAllConstIters(*this, iter)
{
types_[idx] = iter().type_;
names_[idx] = iter().name_;
......@@ -350,7 +350,7 @@ Foam::List<int> Foam::ParcelEncoding::offsets() const
List<int> lst(size());
label i=0;
forAllConstIter(Container, *this, iter)
forAllConstIters(*this, iter)
{
lst[i++] = iter().offset();
}
......@@ -364,7 +364,7 @@ Foam::List<int> Foam::ParcelEncoding::sizes() const
List<int> lst(size());
label i=0;
forAllConstIter(Container, *this, iter)
forAllConstIters(*this, iter)
{
lst[i++] = iter().sizeOf();
}
......@@ -376,7 +376,7 @@ Foam::List<int> Foam::ParcelEncoding::sizes() const
const Foam::ParcelEncoding::Fragment*
Foam::ParcelEncoding::lookupPtr(const word& name) const
{
forAllConstIter(Container, *this, iter)
forAllConstIters(*this, iter)
{
const Fragment& frag = iter();
if (frag.name() == name)
......
......@@ -42,6 +42,10 @@ Description
namespace Foam
{
// Forward declarations
class ParcelEncoding;
Ostream& operator<<(Ostream& os, const ParcelEncoding& lst);
/*---------------------------------------------------------------------------*\
Class ParcelEncoding Declaration
\*---------------------------------------------------------------------------*/
......
......@@ -43,11 +43,13 @@ Description
namespace Foam
{
// forward declaration
class ParcelEncoding;
template<class Type>
class ParcelEncodingAccessor;
// Forward declaration
class ParcelEncoding;
class ParcelEncodingFragment;
template<class Type> class ParcelEncodingAccessor;
Ostream& operator<<(Ostream& os, const ParcelEncodingFragment& frag);
/*---------------------------------------------------------------------------*\
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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/>.
Class
Foam::IBufStream
Description
Similar to IStringStream but using an externally managed buffer for its
input. This allows the input buffer to be filled (and refilled) from
various sources.
Note that this stream will normally be used as a "one-shot" reader.
Caution must be exercised that the referenced buffer remains valid and
without any intermediate resizing for the duration of the stream's use.
An example of possible use:
\code
DynamicList<char> buffer(4096); // allocate some large buffer
nread = something.read(buffer.data(),1024); // fill with content
buffer.setSize(nread); // content size
// construct dictionary, or do something else
IBufStream is(buffer)
dictionary dict1(is);
// sometime later
nread = something.read(buffer.data(),2048); // fill with content
buffer.setSize(nread); // content size
// without intermediate variable
dictionary dict2(IBufStream(buffer)());
\endcode
\*---------------------------------------------------------------------------*/
#ifndef IBufStream_H
#define IBufStream_H
#include "OBufStream.H"
#include "ISstream.H"
#include "UList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class IBufStreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- An allocator for std::istream with external buffers
class IBufStreamAllocator
{
private:
// Private data
//- Reference to the underlying buffer
memorybuf::input buf_;
protected:
// Protected data
//- The stream pointer
std::istream* strPtr_;
public:
// Constructors
//- Construct with buffer and number of bytes
IBufStreamAllocator(const char *buffer, size_t nbytes)
:
buf_(buffer, nbytes),
strPtr_(new std::istream(&buf_))
{}
//- Construct with buffer and number of bytes
IBufStreamAllocator(const void *buffer, size_t nbytes)
:
buf_(buffer, nbytes),
strPtr_(new std::istream(&buf_))
{}
//- Construct using specified buffer and its inherent storage size
template<class T>
IBufStreamAllocator(const UList<T>& buffer)
:
buf_(buffer),
strPtr_(new std::istream(&buf_))
{}
//- Destructor
~IBufStreamAllocator()
{
delete strPtr_;
}
// Member functions
//- Return the current get position in the buffer
std::streampos pos() const
{
return strPtr_->tellg();
}
//- Move to buffer start, clear errors
void rewind()
{
strPtr_->rdbuf()->pubseekpos(0);
strPtr_->clear(); // for safety, clear any old errors
}
};
/*---------------------------------------------------------------------------*\
Class IBufStream Declaration
\*---------------------------------------------------------------------------*/
class IBufStream
:
private IBufStreamAllocator,
public ISstream
{
public:
// Constructors
//- Construct using specified buffer and number of bytes
IBufStream
(
const char* buffer,
size_t nbytes,
streamFormat format=ASCII,
versionNumber version=currentVersion
)
:
IBufStreamAllocator(buffer, nbytes),
ISstream
(
*strPtr_,
"IBufStream.source",
format,
version
)
{}
//- Construct using data area from buffer and number of bytes
template<class T>
IBufStream
(
const UList<T>& buffer,
size_t nbytes,
streamFormat format=ASCII,
versionNumber version=currentVersion
)
:
IBufStreamAllocator(buffer.cdata(), nbytes),
ISstream
(
*strPtr_,
"IBufStream.source",
format,
version
)
{}
//- Construct using specified buffer and its inherent storage size
// Uses addressed size, thus no special treatment for a DynamicList
template<class T>
IBufStream
(
const UList<T>& buffer,
streamFormat format=ASCII,
versionNumber version=currentVersion
)
:
IBufStreamAllocator(buffer),
ISstream
(
*strPtr_,
"IBufStream.source",
format,
version
)
{}
//- Destructor
~IBufStream()
{}
// Member functions
//- Return the current input position in the buffer
using IBufStreamAllocator::pos;
//- Rewind the stream, clearing any old errors
virtual Istream& rewind()
{
IBufStreamAllocator::rewind();
setGood(); // resynchronize with internal state
return *this;
}
// Member operators
//- Return a non-const reference to const Istream
// Needed for read-constructors where the stream argument is temporary:
// e.g. thing thisThing(IFstream("thingFileName")());
Istream& operator()() const
{
return const_cast<Istream&>(static_cast<const Istream&>(*this));
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
This diff is collapsed.
......@@ -43,7 +43,6 @@ Foam::OCompactStream::OCompactStream
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::Ostream& Foam::OCompactStream::writeKeyword(const keyType& kw)
{
write(kw);
......
......@@ -99,7 +99,6 @@ public:
//- Add newline and flush stream
virtual void endl();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::OCompactCountStream
Foam::OCountCompactStream
Description
An output stream for calculating byte counts,
......@@ -30,11 +30,11 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef OCompactCountStream_H
#define OCompactCountStream_H
#ifndef OCountCompactStream_H
#define OCountCompactStream_H
#include "OCompactStream.H"
#include "OCountStream.H"
#include "OCompactStream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -42,72 +42,58 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class OCompactCountStream Declaration
Class OCountCompactStream Declaration
\*---------------------------------------------------------------------------*/
class OCompactCountStream
class OCountCompactStream
:
public Detail::OCountStreamAllocator,
public OCompactStream
{
// Private Member Functions
//- Disallow default bitwise copy construct
OCompactCountStream(const OCompactCountStream&) = delete;
//- Disallow default bitwise assignment
void operator=(const OCompactCountStream&) = delete;
typedef Detail::OCountStreamAllocator allocator_type;
public:
// Constructors
//- Construct and set stream status
OCompactCountStream
OCountCompactStream
(
streamFormat format=ASCII,
versionNumber version=currentVersion
)
:
OCompactStream
(
*(new ocountstream()),
"OCompactCountStream.sink",
format,
version
)
allocator_type(),
OCompactStream(stream_, "output", format, version)
{}
//- Destructor
~OCompactCountStream()
{
delete &dynamic_cast<ocountstream&>(stdStream());
}
//- Copy construct
OCountCompactStream(const OCountCompactStream& os)
:
allocator_type(os.size()),
OCompactStream(stream_, os.name(), os.format(), os.version())
{}
// Member functions
// Access
//- Return the number of bytes counted
std::streamsize size() const
{
return dynamic_cast<const ocountstream&>(stdStream()).size();
}
// Edit
//- Rewind the stream, reset the count, clearing any old errors
void rewind()
virtual void rewind()
{
dynamic_cast<ocountstream&>(stdStream()).rewind();
allocator_type::rewind();
setGood(); // resynchronize with internal state
}
//- Print description to Ostream
virtual void print(Ostream& os) const
{
os << "OCountCompactStream: ";
printBufInfo(os);
os << Foam::endl;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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/>.
Class
Foam::OSCountStream
Description
An output stream for calculating byte counts.
\*---------------------------------------------------------------------------*/
#ifndef OScountStream_H
#define OScountStream_H
#include "OSstream.H"
#include <iostream>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class countstreambuf Declaration
\*---------------------------------------------------------------------------*/
//- A streambuf class for determining byte counts
class countstreambuf
:
public std::streambuf
{
// Private data
//- The number of bytes
std::streamsize n_;
protected:
// Protected members
//- Put sequence of characters
virtual std::streamsize xsputn(const char* s, std::streamsize num)
{
n_ += num;
return num;
}
//- Set position pointer to absolute position
// For the counter, any positioning is ignored and it always acts like
// seekpos(0), which resets the count.
virtual std::streampos seekpos
(
std::streampos sp,
std::ios_base::openmode which = std::ios_base::in | std::ios_base::out
)
{
n_ = 0;
return 0;
}
public:
// Constructors
//- Construct null
countstreambuf()
:
n_(0)
{}
// Access
//- Get number of bytes counted
std::streamsize size() const
{
return n_;
}
};
/*---------------------------------------------------------------------------*\
Class ocountstream Declaration
\*---------------------------------------------------------------------------*/
//- Trivial output stream for calculating byte counts
// Since all output values are discarded, it can also be used as a /dev/null
// output buffer as well
class ocountstream
:
virtual public std::ios,
public std::ostream
{
// Private data
countstreambuf buf_;
public:
// Constructors
//- Construct null
ocountstream()
:
std::ostream(&buf_)
{}
// Member Functions
// Access
//- This hides both signatures of std::basic_ios::rdbuf()
countstreambuf* rdbuf()
{
return &buf_;
}
//- Get number of bytes counted
std::streamsize size() const
{
return buf_.size();
}
//- Rewind the stream, reset the count
void rewind()
{
buf_.pubseekpos(0);
clear(); // for safety, clear any old errors
}
};
/*---------------------------------------------------------------------------*\
Class OCountStream Declaration
\*---------------------------------------------------------------------------*/
//- An output stream for calculating byte counts
class OCountStream
:
public OSstream
{
// Private Member Functions
//- Disallow default bitwise copy construct
OCountStream(const OCountStream&);
//- Disallow default bitwise assignment
void operator=(const OCountStream&);
public:
// Constructors
//- Construct and set stream status
OCountStream
(
streamFormat format=ASCII,
versionNumber version=currentVersion
)
:
OSstream
(
*(new ocountstream()),
"OCountStream.sink",
format,
version
)
{}
//- Destructor
~OCountStream()
{
delete &dynamic_cast<ocountstream&>(stdStream());
}
// Member functions
// Access
//- Return the number of bytes counted
std::streamsize size() const
{
return dynamic_cast<const ocountstream&>(stdStream()).size();
}
// Edit
//- Rewind the stream, reset the count, clearing any old errors
void rewind()
{
dynamic_cast<ocountstream&>(stdStream()).rewind();
setGood(); // resynchronize with internal state
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -22,18 +22,18 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::OCompactStringStream
Foam::OStringCompactStream
Description
Output to memory buffer stream using an output with reduced spacing.
\*---------------------------------------------------------------------------*/
#ifndef OCompactStringStream_H
#define OCompactStringStream_H
#ifndef OStringCompactStream_H
#define OStringCompactStream_H
#include "StringStream.H"
#include "OCompactStream.H"
#include <sstream>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -41,69 +41,62 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class OCompactStringStream Declaration
Class OStringCompactStream Declaration
\*---------------------------------------------------------------------------*/
class OCompactStringStream
class OStringCompactStream
:
public Detail::StringStreamAllocator<std::ostringstream>,
public OCompactStream
{
//- Disallow default bitwise copy construct
OCompactStringStream(const OCompactStringStream&) = delete;
//- Disallow default bitwise assignment
void operator=(const OCompactStringStream&) = delete;
typedef Detail::StringStreamAllocator<std::ostringstream> allocator_type;
public:
// Constructors
//- Construct and set stream status
OCompactStringStream
OStringCompactStream
(
streamFormat format=ASCII,
versionNumber version=currentVersion
)
:
OCompactStream
(
*(new std::ostringstream()),
"OCompactStringStream.sinkFile",
format,
version
)
allocator_type(),
OCompactStream(stream_, "output", format, version)
{}
//- Construct as copy of content
OStringCompactStream(const OStringCompactStream& os)
:
allocator_type(os.str()),
OCompactStream(stream_, os.name(), os.format(), os.version())
{}
//- Destructor
~OCompactStringStream()
{
delete &dynamic_cast<std::ostringstream&>(stdStream());
}
// Member functions
// Access
//- Return the string
string str() const
{
return dynamic_cast<const std::ostringstream&>
(
stdStream()
).str();
}
// Edit
//- Rewind the OStringStream
void rewind()
{
stdStream().rdbuf()->pubseekpos(0);
}
//- Reset the output buffer and rewind the stream
void reset()
{
this->str(""); // No other way to reset the end
this->rewind();
}
//- Rewind the output stream
virtual void rewind()
{
// pubseekpos() instead of seekp() for symmetry with other classes
stream_.rdbuf()->pubseekpos(0, std::ios_base::out);
}
//- Print description to Ostream
virtual void print(Ostream& os) const
{
os << "OStringCompactStream " << name() << " : "
<< "buffer =\n" << str() << Foam::endl;
}
};
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -22,18 +22,17 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::OCompactBufStream
Foam::UOListCompactStream
Description
Similar to OStringStream but using an externally managed buffer for
its output and using a more compact output (fewer spaces)
Like UOListStream but with fewer spaces in the output
\*---------------------------------------------------------------------------*/
#ifndef OCompactBufStream_H
#define OCompactBufStream_H
#ifndef UOListCompactStream_H
#define UOListCompactStream_H
#include "OBufStream.H"
#include "UOListStream.H"
#include "OCompactStream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -42,21 +41,23 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class OCompactBufStream Declaration
Class UOListCompactStream Declaration
\*---------------------------------------------------------------------------*/
//- An OSstream with an attached external buffer and compact output
class OCompactBufStream
//- An Ostream with an attached external buffer and compact output
class UOListCompactStream
:
private OBufStreamAllocator,
public Detail::UOListStreamAllocator,
public OCompactStream
{
typedef Detail::UOListStreamAllocator allocator_type;
public:
// Constructors
//- Construct using specified buffer and number of bytes
OCompactBufStream
UOListCompactStream
(
char* buffer,
size_t nbytes,
......@@ -64,90 +65,80 @@ public:
versionNumber version=currentVersion
)
:
OBufStreamAllocator(buffer, nbytes),
OCompactStream
(
*strPtr_,
"OBufStream.sink",
format,
version
)
allocator_type(buffer, nbytes),
OCompactStream(stream_, "output", format,version)
{}
//- Construct using data area from buffer and number of bytes
template<class T>
OCompactBufStream
//- Construct using data area from a List and number of bytes
UOListCompactStream
(
UList<T>& buffer,
size_t nbytes,
UList<char>& buffer,
size_t size,
streamFormat format=ASCII,
versionNumber version=currentVersion
)
:
OBufStreamAllocator(buffer.data(), nbytes),
OCompactStream
(
*strPtr_,
"OBufStream.sink",
format,
version
)
UOListCompactStream(buffer.data(), size, format, version)
{}
//- Construct using specified buffer and its inherent storage size
template<class T>
OCompactBufStream
//- Construct using data area from a FixedList
template<unsigned FixedSize>
UOListCompactStream
(
UList<T>& buffer,
FixedList<char,FixedSize>& buffer,
streamFormat format=ASCII,
versionNumber version=currentVersion
)
:
OBufStreamAllocator(buffer),
OCompactStream
(
*strPtr_,
"OBufStream.sink",
format,
version
)
UOListCompactStream(buffer.data(), FixedSize, format, version)
{}
//- Construct using data area from a List and its inherent storage size
UOListCompactStream
(
UList<char>& buffer,
streamFormat format=ASCII,
versionNumber version=currentVersion
)
:
UOListCompactStream(buffer.data(), buffer.size(), format, version)
{}
//- Construct using specified buffer and its storage capacity
template<class T>
OCompactBufStream
//- Construct using data area from a DynamicList and its capacity
template<int SizeMin>
UOListCompactStream
(
DynamicList<T>& buffer,
DynamicList<char,SizeMin>& buffer,
streamFormat format=ASCII,
versionNumber version=currentVersion
)
:
OBufStreamAllocator(buffer, buffer.capacity()),
OCompactStream
UOListCompactStream
(
*strPtr_,
"OBufStream.sink",
buffer.data(),
buffer.capacity(),
format,
version
)
{}
//- Destructor
~OCompactBufStream()
{}
// Member functions
//- Return the current output position in the buffer
using OBufStreamAllocator::size;
//- Rewind the output buffer
using OBufStreamAllocator::rewind;
//- Rewind the stream, clearing any old errors
virtual void rewind()
{
allocator_type::rewind();
setGood(); // resynchronize with internal state
}
//- Print description to Ostream
virtual void print(Ostream& os) const
{
os << "UOListCompactStream: ";
printBufInfo(os);
os << Foam::endl;
}
};
......
......@@ -4,8 +4,8 @@ sinclude $(GENERAL_RULES)/mplib$(WM_MPLIB)
sinclude $(RULES)/mplib$(WM_MPLIB)
/* Obtain compile/link flags via adios_config */
ADIOS_INC := $(shell $(ADIOS_ARCH_PATH)/bin/adios_config -c)
ADIOS_LIBS := $(shell $(ADIOS_ARCH_PATH)/bin/adios_config -l)
ADIOS_INC := $(shell $(ADIOS1_ARCH_PATH)/bin/adios_config -c)
ADIOS_LIBS := $(shell $(ADIOS1_ARCH_PATH)/bin/adios_config -l)
EXE_INC = \
......
......@@ -64,12 +64,12 @@ bool Foam::adiosWrite::cloudRead
if (src.nParcels())
{
size_t nread = reader.getBuffered(src.fullName(), transferBuffer());
IBufStream is(transferBuffer(), nread, IOstream::BINARY);
UIListStream is(transferBuffer(), nread, IOstream::BINARY);
newParcels = IDLList<pType>(is, typename pType::iNew(mesh));
}
forAllIter(typename CloudType, newParcels, newpIter)
forAllIters(newParcels, newpIter)
{
pType& newp = newpIter();
......@@ -87,8 +87,8 @@ Foam::label Foam::adiosWrite::writeCloud
const bool expandCloud
)
{
typedef OCompactCountStream CloudCountStream;
typedef OCompactBufStream CloudOutputStream;
typedef OCountCompactStream CloudCountStream;
typedef UOListCompactStream CloudOutputStream;
adiosCoreWrite::cloudInfo cInfo(cld);
......@@ -150,7 +150,7 @@ Foam::label Foam::adiosWrite::writeCloud
// stream the cloud contents - always binary content
CloudCountStream counter(IOstream::BINARY);
forAllConstIter(typename CloudType, cld, pIter)
forAllConstIters(cld, pIter)
{
counter.rewind();
counter << *pIter;
......@@ -177,7 +177,7 @@ Foam::label Foam::adiosWrite::writeCloud
CloudOutputStream os(transferBuffer(), IOstream::BINARY);
os << '('; // opening '('
forAllConstIter(typename CloudType, cld, pIter)
forAllConstIters(cld, pIter)
{
os << *pIter;
}
......@@ -186,12 +186,12 @@ Foam::label Foam::adiosWrite::writeCloud
writeGenericVariable(varid, transferBuffer().cdata());
// more debugging
if (0)
if (false)
{
OCompactStringStream dbg(IOstream::BINARY);
OStringCompactStream dbg(IOstream::BINARY);
dbg << '('; // opening '('
forAllConstIter(typename CloudType, cld, pIter)
forAllConstIters(cld, pIter)
{
dbg << *pIter;
break;
......@@ -249,7 +249,7 @@ Foam::label Foam::adiosWrite::writeCloud
List<char> parcelBuf(maxParcelLength);
CloudOutputStream os(parcelBuf, IOstream::BINARY);
forAllConstIter(ParcelEncoding::Container, encoded, iter)
forAllConstIters(encoded, iter)
{
const ParcelEncoding::Fragment& frag = *iter;
......@@ -258,7 +258,7 @@ Foam::label Foam::adiosWrite::writeCloud
const ParcelEncodingAccessor<label> getter(frag);
label i = 0;
forAllConstIter(typename CloudType, cld, pIter)
forAllConstIters(cld, pIter)
{
os.rewind();
os << *pIter; // binary content
......@@ -285,7 +285,7 @@ Foam::label Foam::adiosWrite::writeCloud
const ParcelEncodingAccessor<scalar> getter(frag);
label i = 0;
forAllConstIter(typename CloudType, cld, pIter)
forAllConstIters(cld, pIter)
{
os.rewind();
os << *pIter; // binary content
......@@ -315,7 +315,7 @@ Foam::label Foam::adiosWrite::writeCloud
const ParcelEncodingAccessor<vector> getter(frag);
label i = 0;
forAllConstIter(typename CloudType, cld, pIter)
forAllConstIters(cld, pIter)
{
os.rewind();
os << *pIter; // binary content
......@@ -392,7 +392,7 @@ Foam::label Foam::adiosWrite::printCloud
// ASCII output
label count=0;
forAllConstIter(typename CloudType, cld, pIter)
forAllConstIters(cld, pIter)
{
OStringStream os;
os << count++ << "=> " << *pIter;
......
......@@ -49,23 +49,24 @@ void Foam::adiosWrite::regionInfo::read
explicitWrite_.readIfPresent("explicit", wrtDict);
expandCloud_.readIfPresent("expandCloud", wrtDict);
if (explicitWrite_ || wrtDict.found("fields"))
{
wrtDict.lookup("fields") >> requestedFields_;
}
if (explicitWrite_ || wrtDict.found("clouds"))
{
wrtDict.lookup("clouds") >> requestedClouds_;
}
wrtDict.readEntry
(
"fields",
requestedFields_,
keyType::LITERAL,
explicitWrite_
);
if (ignDict.found("fields"))
{
ignDict.lookup("fields") >> ignoredFields_;
}
if (ignDict.found("clouds"))
{
ignDict.lookup("clouds") >> ignoredClouds_;
}
wrtDict.readEntry
(
"clouds",
requestedClouds_,
keyType::LITERAL,
explicitWrite_
);
ignDict.readIfPresent("fields", ignoredFields_);
ignDict.readIfPresent("clouds", ignoredClouds_);
// Check if the requested fields are actually accessible
DynamicList<word> missing(requestedFields_.size());
......@@ -147,12 +148,12 @@ bool Foam::adiosWrite::regionInfo::acceptCloudObject
return
(
// clouds only and not explicitly ignored
isA<cloud>(obj) && !findStrings(ignoredClouds_, name)
isA<cloud>(obj) && !ignoredClouds_.match(name)
&&
(
// auto-write or explicitly requested
(autoWrite() && obj.writeOpt() == IOobject::AUTO_WRITE)
|| findStrings(requestedClouds_, name)
|| requestedClouds_.match(name)
)
);
}
......@@ -168,12 +169,12 @@ bool Foam::adiosWrite::regionInfo::acceptFieldObject
return
(
// NO clouds and not explicitly ignored
!isA<cloud>(obj) && !findStrings(ignoredFields_, name)
!isA<cloud>(obj) && !ignoredFields_.match(name)
&&
(
// auto-write or explicitly requested
(autoWrite() && obj.writeOpt() == IOobject::AUTO_WRITE)
|| findStrings(requestedFields_, name)
|| requestedFields_.match(name)
)
&& !name.endsWith("_0") // ignore _0 fields
);
......
......@@ -264,7 +264,7 @@ bool Foam::adiosWrite::read(const dictionary& dict)
const entry& e = iter();
const word& regName = e.keyword();
if (!regionNames.contains(regName))
if (!regionNames.found(regName))
{
warn[nwarn++] = regName;
}
......@@ -347,7 +347,7 @@ bool Foam::adiosWrite::read(const dictionary& dict)
else if (when == "restartTime")
{
restartFrom_ = restartTime;
dict.lookup("restartTime") >> restartTime_;
dict.readEntry("restartTime", restartTime_);
Info<< type() << " " << adiosCore::name()
<< " : Restart requested, Time = " << restartTime_ << endl;
......@@ -388,7 +388,7 @@ bool Foam::adiosWrite::read(const dictionary& dict)
else if (when == "stopTime")
{
stopAt_ = stopTime;
dict.lookup("stopTime") >> stopTime_;
dict.readEntry("stopTime", stopTime_);
Info<< type() << " " << adiosCore::name()
<< " : Stop requested, Time = " << stopTime_ << endl;
......
......@@ -281,10 +281,10 @@ class adiosWrite::regionInfo
Switch explicitWrite_;
//- Names of volume fields to write
wordReList requestedFields_;
wordRes requestedFields_;
//- Names of volume fields to ignore
wordReList ignoredFields_;
wordRes ignoredFields_;
// track changes to mesh status (points/faces)
......@@ -311,10 +311,10 @@ class adiosWrite::regionInfo
public:
//- Names of clouds to write
wordReList requestedClouds_;
wordRes requestedClouds_;
//- Names of clouds to ignored
wordReList ignoredClouds_;
wordRes ignoredClouds_;
//- Normally don't want to expand cloud (debug only)
Switch expandCloud_;
......@@ -335,8 +335,7 @@ public:
);