mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Moved writing of cloud unifrom data from IOPosition to Cloud
This commit is contained in:
@ -87,6 +87,12 @@ class Cloud
|
||||
//- Initialise cloud on IO constructor
|
||||
void initCloud(const bool checkClass);
|
||||
|
||||
//- Read cloud properties dictionary
|
||||
void readCloudUniformProperties();
|
||||
|
||||
//- Write cloud properties dictionary
|
||||
void writeCloudUniformProperties() const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -104,6 +110,12 @@ public:
|
||||
TypeName("Cloud");
|
||||
|
||||
|
||||
// Static data
|
||||
|
||||
//- Name of cloud properties dictionary
|
||||
static word cloudPropertiesName;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from mesh and a list of particles
|
||||
|
||||
@ -29,11 +29,85 @@ License
|
||||
#include "Time.H"
|
||||
#include "IOPosition.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<class ParticleType>
|
||||
Foam::word Foam::Cloud<ParticleType>::cloudPropertiesName("cloudProperties");
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class ParticleType>
|
||||
void Foam::Cloud<ParticleType>::readCloudUniformProperties()
|
||||
{
|
||||
IOobject uniformPropsDictHeader
|
||||
(
|
||||
cloudPropertiesName,
|
||||
time().timeName(),
|
||||
"uniform"/cloud::prefix/name(),
|
||||
db(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
if (uniformPropsDictHeader.headerOk())
|
||||
{
|
||||
const IOdictionary uniformPropsDict(uniformPropsDictHeader);
|
||||
|
||||
word procName("processor" + Foam::name(Pstream::myProcNo()));
|
||||
if (uniformPropsDict.found(procName))
|
||||
{
|
||||
uniformPropsDict.subDict(procName).lookup("particleCount")
|
||||
>> particleCount_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
particleCount_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class ParticleType>
|
||||
void Foam::Cloud<ParticleType>::writeCloudUniformProperties() const
|
||||
{
|
||||
IOdictionary uniformPropsDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
cloudPropertiesName,
|
||||
time().timeName(),
|
||||
"uniform"/cloud::prefix/name(),
|
||||
db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
labelList np(Pstream::nProcs(), 0);
|
||||
np[Pstream::myProcNo()] = particleCount_;
|
||||
|
||||
Pstream::listCombineGather(np, maxEqOp<label>());
|
||||
Pstream::listCombineScatter(np);
|
||||
|
||||
forAll(np, i)
|
||||
{
|
||||
word procName("processor" + Foam::name(i));
|
||||
uniformPropsDict.add(procName, dictionary());
|
||||
uniformPropsDict.subDict(procName).add("particleCount", np[i]);
|
||||
}
|
||||
|
||||
uniformPropsDict.regIOobject::write();
|
||||
}
|
||||
|
||||
|
||||
template<class ParticleType>
|
||||
void Foam::Cloud<ParticleType>::initCloud(const bool checkClass)
|
||||
{
|
||||
readCloudUniformProperties();
|
||||
|
||||
IOPosition<ParticleType> ioP(*this);
|
||||
|
||||
if (ioP.headerOk())
|
||||
@ -156,6 +230,8 @@ bool Foam::Cloud<ParticleType>::writeObject
|
||||
IOstream::compressionType cmp
|
||||
) const
|
||||
{
|
||||
writeCloudUniformProperties();
|
||||
|
||||
if (this->size())
|
||||
{
|
||||
writeFields();
|
||||
|
||||
@ -26,70 +26,6 @@ License
|
||||
|
||||
#include "IOPosition.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<class ParticleType>
|
||||
Foam::word Foam::IOPosition<ParticleType>::particlePropertiesName
|
||||
(
|
||||
"particleProperties"
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class ParticleType>
|
||||
void Foam::IOPosition<ParticleType>::readParticleProperties()
|
||||
{
|
||||
IOobject propsDictHeader
|
||||
(
|
||||
particlePropertiesName,
|
||||
cloud_.db().time().timeName(),
|
||||
"uniform"/cloud::prefix/cloud_.name(),
|
||||
cloud_.db(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
if (propsDictHeader.headerOk())
|
||||
{
|
||||
const IOdictionary propsDict(propsDictHeader);
|
||||
|
||||
word procName("processor" + Foam::name(Pstream::myProcNo()));
|
||||
if (propsDict.found(procName))
|
||||
{
|
||||
propsDict.subDict(procName).lookup("particleCount")
|
||||
>> cloud_.particleCount_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class ParticleType>
|
||||
void Foam::IOPosition<ParticleType>::writeParticleProperties() const
|
||||
{
|
||||
IOdictionary propsDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
particlePropertiesName,
|
||||
cloud_.db().time().timeName(),
|
||||
"uniform"/cloud::prefix/cloud_.name(),
|
||||
cloud_.db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
word procName("processor" + Foam::name(Pstream::myProcNo()));
|
||||
propsDict.add(procName, dictionary());
|
||||
propsDict.subDict(procName).add("particleCount", cloud_.particleCount_);
|
||||
|
||||
propsDict.regIOobject::write();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ParticleType>
|
||||
@ -132,9 +68,6 @@ bool Foam::IOPosition<ParticleType>::write() const
|
||||
template<class ParticleType>
|
||||
bool Foam::IOPosition<ParticleType>::writeData(Ostream& os) const
|
||||
{
|
||||
// Write global cloud data
|
||||
writeParticleProperties();
|
||||
|
||||
os<< cloud_.size() << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
forAllConstIter(typename Cloud<ParticleType>, cloud_, iter)
|
||||
@ -161,9 +94,6 @@ void Foam::IOPosition<ParticleType>::readData
|
||||
bool checkClass
|
||||
)
|
||||
{
|
||||
// Read global cloud data. Resets count on cloud.
|
||||
readParticleProperties();
|
||||
|
||||
Istream& is = readStream(checkClass ? typeName : "");
|
||||
|
||||
token firstToken(is);
|
||||
|
||||
@ -59,15 +59,6 @@ class IOPosition
|
||||
const Cloud<ParticleType>& cloud_;
|
||||
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Read particle properties dictionary
|
||||
void readParticleProperties();
|
||||
|
||||
//- Write particle properties dictionary
|
||||
void writeParticleProperties() const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Static data
|
||||
@ -78,9 +69,6 @@ public:
|
||||
return cloud_.type();
|
||||
}
|
||||
|
||||
//- Name of particle properties dictionary
|
||||
static word particlePropertiesName;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
|
||||
Reference in New Issue
Block a user