Commit b67ddcf1 authored by mark's avatar mark

ENH: simplify cloud information for writing

parent 1a4507fc
......@@ -25,6 +25,7 @@ License
#include "adiosWrite.H"
#include "CStringList.H"
#include "nullObject.H"
#include "FlatListOutput.H"
#include "ParcelEncoding.H"
......@@ -42,20 +43,17 @@ bool Foam::adiosWrite::cloudRead
const adiosReader::cloudInfo& src
)
{
const word& cloudType = cld.type();
const word& srcType = src.type();
if (cloudType != srcType)
if (cld.type() != src.type())
{
// probably fatal:
Info<<"WARNING mismatch on cloud " << src
<< " (expected: " << cloudType
<< " but had " << srcType << ")\n";
<< " (expected: " << cld.type()
<< " but had " << src.type() << ")\n";
return false;
}
Info<<"read cloud " << cld.name() << " (type "
<< cloudType << ") from file\n";
<< cld.type() << ") from file\n";
// Pout<<"Current cloud: " << cld.size() << " parcels. Cloud on file: "
// << src.nParcels() << " elements" << endl;
......@@ -88,20 +86,13 @@ template<class CloudType>
Foam::label Foam::adiosWrite::writeCloud
(
const CloudType& cld,
cloudInfo& cInfo,
const regionInfo& rInfo
)
{
typedef OCompactCountStream CloudCountStream;
typedef OCompactBufStream CloudOutputStream;
const word& cloudName = cInfo.name();
const word& cloudType = cInfo.type();
const fileName varName = adiosCore::cloudPath
(
cld.db().name(), // = region name
cld.name() // = cloud name
);
cloudInfo cInfo(cld);
// Number of parcels on this process
const label nParcels = cld.size();
......@@ -110,7 +101,7 @@ Foam::label Foam::adiosWrite::writeCloud
if (cInfo.nParcels(nParcels) == 0)
{
// skip: cloud has no parcels
Info<< " " << cloudName <<": No parcels in cloud ... skipping."
Info<< " " << cld.name() <<": No parcels in cloud ... skipping."
<< endl;
return 0;
......@@ -125,9 +116,9 @@ Foam::label Foam::adiosWrite::writeCloud
// added verbosity
if (0)
{
Info<< "cloud: " << cloudName << " (" << cInfo.nTotal()
Info<< "cloud: " << cld.name() << " (" << cInfo.nTotal()
<< " parcels, " << encoded.length() << " min-size) type: "
<< cloudType << nl
<< cld.type() << nl
<< " types: " << FlatListOutput<word>(encoded.types()) << nl
<< " names: " << FlatListOutput<word>(encoded.names()) << nl
<< " offset:" << FlatListOutput<label>(encoded.offsets()) << nl
......@@ -135,15 +126,16 @@ Foam::label Foam::adiosWrite::writeCloud
}
else
{
Info<< "cloud: " << cloudName << " (" << cInfo.nTotal()
Info<< "cloud: " << cld.name() << " (" << cInfo.nTotal()
<< " parcels, " << encoded.length() << " min-size) type: "
<< cloudType << nl;
<< cld.type() << nl;
}
//
// cloud variables:
//
const fileName& varName = cInfo.fullName();
// number of parcels per processor as a variable
defineIntVariable(varName/"nParcels");
......@@ -223,7 +215,7 @@ Foam::label Foam::adiosWrite::writeCloud
// number of parcels (all processes) as an attribute
//
defineAttribute("class", varName, cloudType);
defineAttribute("class", varName, cInfo.type());
defineIntAttribute("nParcels", varName, cInfo.nTotal());
defineIntAttribute("min-size", varName, encoded.length());
defineIntAttribute("max-size", varName, maxParcelLength);
......@@ -232,7 +224,14 @@ Foam::label Foam::adiosWrite::writeCloud
defineListAttribute("offset", varName, encoded.offsets());
defineListAttribute("byte-size", varName, encoded.sizes());
if (isNull(rInfo))
{
return nParcels;
}
//
// The rest is only if we want expansion
//
// common - local offset value
const string offsetDims = Foam::name(cInfo.offset());
......@@ -391,16 +390,15 @@ Foam::label Foam::adiosWrite::writeCloud
}
// this will likely need rewriting for updated cloudInfo definition
#if 0
template<class CloudType>
Foam::label Foam::adiosWrite::printCloud
(
const CloudType& cld
)
{
const word& cloudName = cld.name();
const word& cloudType = cld.type();
cloudInfo cInfo(cloudName, cloudType);
cloudInfo cInfo(cld.name(), cld.type());
// Number of parcels on this process
const label nParcels = cld.size();
......@@ -409,7 +407,7 @@ Foam::label Foam::adiosWrite::printCloud
if (cInfo.nParcels(nParcels) == 0)
{
// skip: cloud has no parcels
Info<< " " << cloudName <<": No parcels in cloud ... skipping."
Info<< " " << cld.name() <<": No parcels in cloud ... skipping."
<< endl;
return 0;
......@@ -421,9 +419,9 @@ Foam::label Foam::adiosWrite::printCloud
ParcelEncoding encoded(cld);
Info<< "cloud: " << cloudName << " (" << cInfo.nTotal()
Info<< "cloud: " << cld.name() << " (" << cInfo.nTotal()
<< " parcels, " << encoded.length() << " min-size) type: "
<< cloudType << nl
<< cld.type() << nl
<< " types: " << FlatListOutput<word>(encoded.types()) << nl
<< " names: " << FlatListOutput<word>(encoded.names()) << nl
<< " offset:" << FlatListOutput<label>(encoded.offsets()) << nl
......@@ -445,6 +443,6 @@ Foam::label Foam::adiosWrite::printCloud
return nParcels;
}
#endif
// ************************************************************************* //
......@@ -200,14 +200,13 @@ protected:
template<class CloudType>
label writeCloud
(
const CloudType& cloud,
cloudInfo& cInfo,
const CloudType& cld,
const regionInfo& rInfo
);
//- Print cloud (debug only)
template<class CloudType>
label printCloud(const CloudType& cloud);
label printCloud(const CloudType& cld);
// Restart functions
......@@ -274,14 +273,13 @@ public:
};
//- Per-region info variables grouped together to be able to create a list of them
//- Helper for collecting cloud information prior to write
class adiosWrite::cloudInfo
:
public fileName
{
//- Name of the cloud
word name_;
//- Type of the cloud
word type_;
const word type_;
//- Total number of parcels (sum of nParcels_ list)
label nTotal_;
......@@ -289,13 +287,23 @@ class adiosWrite::cloudInfo
//- Array containing number of parcels per process (often used list)
List<label> nParcels_;
cloudInfo(const cloudInfo&) = delete;
void operator=(const cloudInfo&) = delete;
public:
//- Construct with name and type
cloudInfo(const word& name, const word& type)
//- Construct using names from regIOobject
explicit cloudInfo(const regIOobject& cloud)
:
name_(name),
type_(type),
fileName
(
adiosCore::cloudPath
(
cloud.db().name(), // = region name
cloud.name() // = cloud name
)
),
type_(cloud.type()),
nTotal_(0),
nParcels_(Pstream::nProcs())
{
......@@ -306,13 +314,27 @@ public:
~cloudInfo() {}
//- Name of the cloud
const word& name() const
//- The region name is before the first /
const word regionName() const
{
return name_;
return substr(0, find('/')); // not designed for failure
}
//- Return the full variable name
inline const fileName& fullName() const
{
return static_cast<const fileName&>(*this);
}
//- Return file name (part beyond last /)
using fileName::name;
//- Return directory path name (part before last /)
using fileName::path;
//- Type of the cloud
const word& type() const
{
......@@ -553,20 +575,6 @@ public:
}
//- Path name for named cloud
inline fileName cloudPath(const string& cloudName) const
{
return adiosCore::cloudPath(name_, cloudName);
}
//- Path name for named cloud
inline fileName cloudPath(const cloudInfo& cinfo) const
{
return cloudPath(cinfo.name());
}
//- Simple text representation for output purposes
inline word info() const
{
......
......@@ -41,8 +41,6 @@ Foam::label Foam::adiosWrite::writeCloudObject
)
{
label nParcels = -1;
cloudInfo cInfo(obj.name(), obj.type());
const word& cloudType = obj.type();
// this needs reworking:
......@@ -51,7 +49,6 @@ Foam::label Foam::adiosWrite::writeCloudObject
nParcels = writeCloud
(
static_cast<const Cloud<indexedParticle>&>(obj),
cInfo,
rInfo
);
}
......@@ -60,7 +57,6 @@ Foam::label Foam::adiosWrite::writeCloudObject
nParcels = writeCloud
(
static_cast<const Cloud<passiveParticle>&>(obj),
cInfo,
rInfo
);
}
......@@ -69,7 +65,6 @@ Foam::label Foam::adiosWrite::writeCloudObject
nParcels = writeCloud
(
static_cast<const Cloud<basicKinematicCollidingParcel>&>(obj),
cInfo,
rInfo
);
}
......@@ -79,7 +74,6 @@ Foam::label Foam::adiosWrite::writeCloudObject
(
// using alternative
static_cast<const Cloud<basicKinematicParcel>&>(obj),
cInfo,
rInfo
);
}
......@@ -88,7 +82,6 @@ Foam::label Foam::adiosWrite::writeCloudObject
nParcels = writeCloud
(
static_cast<const Cloud<basicKinematicParcel>&>(obj),
cInfo,
rInfo
);
}
......@@ -97,7 +90,6 @@ Foam::label Foam::adiosWrite::writeCloudObject
nParcels = writeCloud
(
static_cast<const Cloud<basicReactingMultiphaseParcel>&>(obj),
cInfo,
rInfo
);
}
......@@ -106,7 +98,6 @@ Foam::label Foam::adiosWrite::writeCloudObject
nParcels = writeCloud
(
static_cast<const Cloud<basicReactingParcel>&>(obj),
cInfo,
rInfo
);
}
......@@ -116,7 +107,6 @@ Foam::label Foam::adiosWrite::writeCloudObject
nParcels = writeCloud
(
static_cast<const Cloud<molecule>&>(obj),
cInfo,
rInfo
);
}
......@@ -126,7 +116,6 @@ Foam::label Foam::adiosWrite::writeCloudObject
nParcels = writeCloud
(
static_cast<const Cloud<basicSprayParcel>&>(obj),
cInfo,
rInfo
);
}
......
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