mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add cloud::readObjects(const objectRegistry&)
- this can be use for situations where the cloud data has been provided by a non-file transport.
This commit is contained in:
@ -86,6 +86,12 @@ void Foam::cloud::autoMap(const mapPolyMesh&)
|
||||
}
|
||||
|
||||
|
||||
void Foam::cloud::readObjects(const objectRegistry& obr)
|
||||
{
|
||||
NotImplemented;
|
||||
}
|
||||
|
||||
|
||||
void Foam::cloud::writeObjects(objectRegistry& obr) const
|
||||
{
|
||||
NotImplemented;
|
||||
|
||||
@ -121,7 +121,7 @@ public:
|
||||
// I-O
|
||||
|
||||
//- Read particle fields from objects in the obr registry
|
||||
//virtual void readObjects(objectRegistry& obr);
|
||||
virtual void readObjects(const objectRegistry& obr);
|
||||
|
||||
//- Write particle fields as objects into the obr registry
|
||||
virtual void writeObjects(objectRegistry& obr) const;
|
||||
|
||||
@ -220,6 +220,13 @@ public:
|
||||
//- Write fields
|
||||
static void writeFields(const Cloud<injectedParticle>& c);
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
static void readObjects
|
||||
(
|
||||
Cloud<injectedParticle>& c,
|
||||
const objectRegistry& obr
|
||||
);
|
||||
|
||||
//- Write particle fields as objects into the obr registry
|
||||
static void writeObjects
|
||||
(
|
||||
|
||||
@ -68,6 +68,12 @@ Foam::injectedParticleCloud::~injectedParticleCloud()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::injectedParticleCloud::readObjects(const objectRegistry& obr)
|
||||
{
|
||||
injectedParticle::readObjects(*this, obr);
|
||||
}
|
||||
|
||||
|
||||
void Foam::injectedParticleCloud::writeObjects(objectRegistry& obr) const
|
||||
{
|
||||
injectedParticle::writeObjects(*this, obr);
|
||||
|
||||
@ -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
|
||||
@ -98,6 +98,9 @@ public:
|
||||
|
||||
// I-O
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
virtual void readObjects(const objectRegistry& obr);
|
||||
|
||||
//- Write particle fields as objects into the obr registry
|
||||
virtual void writeObjects(objectRegistry& obr) const;
|
||||
};
|
||||
|
||||
@ -158,6 +158,35 @@ void Foam::injectedParticle::writeFields(const Cloud<injectedParticle>& c)
|
||||
}
|
||||
|
||||
|
||||
void Foam::injectedParticle::readObjects
|
||||
(
|
||||
Cloud<injectedParticle>& c,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
particle::readObjects(c, obr);
|
||||
|
||||
if (!c.size()) return;
|
||||
|
||||
const auto& tag = cloud::lookupIOField<label>("tag", obr);
|
||||
const auto& soi = cloud::lookupIOField<scalar>("soi", obr);
|
||||
const auto& d = cloud::lookupIOField<scalar>("d", obr);
|
||||
const auto& U = cloud::lookupIOField<vector>("U", obr);
|
||||
|
||||
label i = 0;
|
||||
|
||||
for (injectedParticle& p : c)
|
||||
{
|
||||
p.tag() = tag[i];
|
||||
p.soi() = soi[i];
|
||||
p.d() = d[i];
|
||||
p.U() = U[i];
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::injectedParticle::writeObjects
|
||||
(
|
||||
const Cloud<injectedParticle>& c,
|
||||
@ -167,12 +196,12 @@ void Foam::injectedParticle::writeObjects
|
||||
// Always writes "position", not "coordinates"
|
||||
particle::writeObjects(c, obr);
|
||||
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
|
||||
IOField<label>& tag(cloud::createIOField<label>("tag", np, obr));
|
||||
IOField<scalar>& soi(cloud::createIOField<scalar>("soi", np, obr));
|
||||
IOField<scalar>& d(cloud::createIOField<scalar>("d", np, obr));
|
||||
IOField<vector>& U(cloud::createIOField<vector>("U", np, obr));
|
||||
auto& tag = cloud::createIOField<label>("tag", np, obr);
|
||||
auto& soi = cloud::createIOField<scalar>("soi", np, obr);
|
||||
auto& d = cloud::createIOField<scalar>("d", np, obr);
|
||||
auto& U = cloud::createIOField<vector>("U", np, obr);
|
||||
|
||||
label i = 0;
|
||||
|
||||
|
||||
@ -673,6 +673,10 @@ public:
|
||||
template<class TrackCloudType>
|
||||
static void writeFields(const TrackCloudType& c);
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
template<class CloudType>
|
||||
static void readObjects(CloudType& c, const objectRegistry& obr);
|
||||
|
||||
//- Write particle fields as objects into the obr registry
|
||||
// Always writes "position", not "coordinate"
|
||||
template<class CloudType>
|
||||
|
||||
@ -46,7 +46,7 @@ void Foam::particle::readFields(TrackCloudType& c)
|
||||
|
||||
IOobject procIO(c.fieldIOobject("origProcId", IOobject::MUST_READ));
|
||||
|
||||
bool haveFile = procIO.typeHeaderOk<IOField<label>>(true);
|
||||
const bool haveFile = procIO.typeHeaderOk<IOField<label>>(true);
|
||||
|
||||
IOField<label> origProcId(procIO, valid && haveFile);
|
||||
c.checkFieldIOobject(c, origProcId);
|
||||
@ -63,6 +63,7 @@ void Foam::particle::readFields(TrackCloudType& c)
|
||||
{
|
||||
p.origProc_ = origProcId[i];
|
||||
p.origId_ = origId[i];
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@ -72,11 +73,12 @@ template<class TrackCloudType>
|
||||
void Foam::particle::writeFields(const TrackCloudType& c)
|
||||
{
|
||||
const label np = c.size();
|
||||
const bool valid = np;
|
||||
|
||||
if (writeLagrangianCoordinates)
|
||||
{
|
||||
IOPosition<TrackCloudType> ioP(c);
|
||||
ioP.write(np > 0);
|
||||
ioP.write(valid);
|
||||
}
|
||||
else if (!writeLagrangianPositions)
|
||||
{
|
||||
@ -93,7 +95,7 @@ void Foam::particle::writeFields(const TrackCloudType& c)
|
||||
c,
|
||||
cloud::geometryType::POSITIONS
|
||||
);
|
||||
ioP.write(np > 0);
|
||||
ioP.write(valid);
|
||||
}
|
||||
|
||||
IOField<label> origProc
|
||||
@ -116,8 +118,57 @@ void Foam::particle::writeFields(const TrackCloudType& c)
|
||||
++i;
|
||||
}
|
||||
|
||||
origProc.write(np > 0);
|
||||
origId.write(np > 0);
|
||||
origProc.write(valid);
|
||||
origId.write(valid);
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::particle::readObjects(CloudType& c, const objectRegistry& obr)
|
||||
{
|
||||
typedef typename CloudType::parcelType parcelType;
|
||||
|
||||
const auto* positionPtr = cloud::findIOPosition(obr);
|
||||
|
||||
const label np = c.size();
|
||||
const label newNp = (positionPtr ? positionPtr->size() : 0);
|
||||
|
||||
// Remove excess parcels
|
||||
for (label i = newNp; i < np; ++i)
|
||||
{
|
||||
parcelType* p = c.last();
|
||||
|
||||
c.deleteParticle(*p);
|
||||
}
|
||||
|
||||
if (newNp)
|
||||
{
|
||||
const auto& position = *positionPtr;
|
||||
|
||||
const auto& origProcId = cloud::lookupIOField<label>("origProc", obr);
|
||||
const auto& origId = cloud::lookupIOField<label>("origId", obr);
|
||||
|
||||
// Create new parcels
|
||||
for (label i = np; i < newNp; ++i)
|
||||
{
|
||||
c.addParticle(new parcelType(c.pMesh(), position[i], -1));
|
||||
}
|
||||
|
||||
label i = 0;
|
||||
for (particle& p : c)
|
||||
{
|
||||
p.origProc_ = origProcId[i];
|
||||
p.origId_ = origId[i];
|
||||
|
||||
if (i < np)
|
||||
{
|
||||
// Use relocate for old particles, not new ones
|
||||
p.relocate(position[i]);
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -126,9 +177,9 @@ void Foam::particle::writeObjects(const CloudType& c, objectRegistry& obr)
|
||||
{
|
||||
const label np = c.size();
|
||||
|
||||
IOField<label>& origProc(cloud::createIOField<label>("origProc", np, obr));
|
||||
IOField<label>& origId(cloud::createIOField<label>("origId", np, obr));
|
||||
IOField<point>& position(cloud::createIOField<point>("position", np, obr));
|
||||
auto& origProc = cloud::createIOField<label>("origProc", np, obr);
|
||||
auto& origId = cloud::createIOField<label>("origId", np, obr);
|
||||
auto& position = cloud::createIOField<point>("position", np, obr);
|
||||
|
||||
label i = 0;
|
||||
for (const particle& p : c)
|
||||
|
||||
@ -793,6 +793,13 @@ void Foam::KinematicCloud<CloudType>::info()
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::KinematicCloud<CloudType>::readObjects(const objectRegistry& obr)
|
||||
{
|
||||
parcelType::readObjects(*this, obr);
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::KinematicCloud<CloudType>::writeObjects(objectRegistry& obr) const
|
||||
{
|
||||
|
||||
@ -628,6 +628,9 @@ public:
|
||||
//- Print cloud information
|
||||
void info();
|
||||
|
||||
//- Read particle fields from objects in the obr registry
|
||||
virtual void readObjects(const objectRegistry& obr);
|
||||
|
||||
//- Write particle fields as objects into the obr registry
|
||||
virtual void writeObjects(objectRegistry& obr) const;
|
||||
};
|
||||
|
||||
@ -237,6 +237,14 @@ void Foam::ReactingHeterogeneousCloud<CloudType>::writeFields() const
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::ReactingHeterogeneousCloud<CloudType>::
|
||||
readObjects(const objectRegistry& obr)
|
||||
{
|
||||
CloudType::particleType::readObjects(*this, this->composition(), obr);
|
||||
}
|
||||
|
||||
|
||||
template<class CloudType>
|
||||
void Foam::ReactingHeterogeneousCloud<CloudType>::
|
||||
writeObjects(objectRegistry& obr) const
|
||||
|
||||
@ -243,6 +243,9 @@ public:
|
||||
//- Print cloud information
|
||||
void info();
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
virtual void readObjects(const objectRegistry& obr);
|
||||
|
||||
//- Write the field data for the cloud
|
||||
virtual void writeFields() const;
|
||||
|
||||
|
||||
@ -322,6 +322,10 @@ public:
|
||||
template<class CloudType>
|
||||
static void writeFields(const CloudType& c);
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
template<class CloudType>
|
||||
static void readObjects(CloudType& c, const objectRegistry& obr);
|
||||
|
||||
//- Write particle fields as objects into the obr registry
|
||||
template<class CloudType>
|
||||
static void writeObjects(const CloudType& c, objectRegistry& obr);
|
||||
|
||||
@ -84,7 +84,7 @@ template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::CollidingParcel<ParcelType>::readFields(CloudType& c)
|
||||
{
|
||||
bool valid = c.size();
|
||||
const bool valid = c.size();
|
||||
|
||||
ParcelType::readFields(c);
|
||||
|
||||
@ -192,10 +192,12 @@ void Foam::CollidingParcel<ParcelType>::writeFields(const CloudType& c)
|
||||
{
|
||||
ParcelType::writeFields(c);
|
||||
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
const bool valid = np;
|
||||
|
||||
|
||||
IOField<vector> f(c.fieldIOobject("f", IOobject::NO_READ), np);
|
||||
IOField<vector> angularMomentum
|
||||
IOField<vector> angMom
|
||||
(
|
||||
c.fieldIOobject("angularMomentum", IOobject::NO_READ),
|
||||
np
|
||||
@ -246,7 +248,7 @@ void Foam::CollidingParcel<ParcelType>::writeFields(const CloudType& c)
|
||||
for (const CollidingParcel<ParcelType>& p : c)
|
||||
{
|
||||
f[i] = p.f();
|
||||
angularMomentum[i] = p.angularMomentum();
|
||||
angMom[i] = p.angularMomentum();
|
||||
torque[i] = p.torque();
|
||||
|
||||
collisionRecordsPairAccessed[i] = p.collisionRecords().pairAccessed();
|
||||
@ -262,10 +264,8 @@ void Foam::CollidingParcel<ParcelType>::writeFields(const CloudType& c)
|
||||
++i;
|
||||
}
|
||||
|
||||
const bool valid = (np > 0);
|
||||
|
||||
f.write(valid);
|
||||
angularMomentum.write(valid);
|
||||
angMom.write(valid);
|
||||
torque.write(valid);
|
||||
|
||||
collisionRecordsPairAccessed.write(valid);
|
||||
@ -278,6 +278,34 @@ void Foam::CollidingParcel<ParcelType>::writeFields(const CloudType& c)
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::CollidingParcel<ParcelType>::readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
ParcelType::readObjects(c, obr);
|
||||
|
||||
if (!c.size()) return;
|
||||
|
||||
const auto& f = cloud::lookupIOField<vector>("f", obr);
|
||||
const auto& angMom = cloud::lookupIOField<vector>("angularMomentum", obr);
|
||||
const auto& torque = cloud::lookupIOField<vector>("torque", obr);
|
||||
|
||||
label i = 0;
|
||||
for (CollidingParcel<ParcelType>& p : c)
|
||||
{
|
||||
p.f_ = f[i];
|
||||
p.angularMomentum_ = angMom[i];
|
||||
p.torque_ = torque[i];
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::CollidingParcel<ParcelType>::writeObjects
|
||||
@ -288,20 +316,17 @@ void Foam::CollidingParcel<ParcelType>::writeObjects
|
||||
{
|
||||
ParcelType::writeObjects(c, obr);
|
||||
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
|
||||
IOField<vector>& f(cloud::createIOField<vector>("f", np, obr));
|
||||
IOField<vector>& angularMomentum
|
||||
(
|
||||
cloud::createIOField<vector>("angularMomentum", np, obr)
|
||||
);
|
||||
IOField<vector>& torque(cloud::createIOField<vector>("torque", np, obr));
|
||||
auto& f = cloud::createIOField<vector>("f", np, obr);
|
||||
auto& angMom = cloud::createIOField<vector>("angularMomentum", np, obr);
|
||||
auto& torque = cloud::createIOField<vector>("torque", np, obr);
|
||||
|
||||
label i = 0;
|
||||
for (const CollidingParcel<ParcelType>& p : c)
|
||||
{
|
||||
f[i] = p.f();
|
||||
angularMomentum[i] = p.angularMomentum();
|
||||
angMom[i] = p.angularMomentum();
|
||||
torque[i] = p.torque();
|
||||
|
||||
++i;
|
||||
|
||||
@ -658,6 +658,10 @@ public:
|
||||
template<class TrackCloudType>
|
||||
static void writeFields(const TrackCloudType& c);
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
template<class CloudType>
|
||||
static void readObjects(CloudType& c, const objectRegistry& obr);
|
||||
|
||||
//- Write particle fields as objects into the obr registry
|
||||
template<class CloudType>
|
||||
static void writeObjects(const CloudType& c, objectRegistry& obr);
|
||||
|
||||
@ -97,7 +97,7 @@ template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::KinematicParcel<ParcelType>::readFields(CloudType& c)
|
||||
{
|
||||
bool valid = c.size();
|
||||
const bool valid = c.size();
|
||||
|
||||
ParcelType::readFields(c);
|
||||
|
||||
@ -197,7 +197,8 @@ void Foam::KinematicParcel<ParcelType>::writeFields(const CloudType& c)
|
||||
{
|
||||
ParcelType::writeFields(c);
|
||||
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
const bool valid = np;
|
||||
|
||||
IOField<label> active(c.fieldIOobject("active", IOobject::NO_READ), np);
|
||||
IOField<label> typeId(c.fieldIOobject("typeId", IOobject::NO_READ), np);
|
||||
@ -232,8 +233,6 @@ void Foam::KinematicParcel<ParcelType>::writeFields(const CloudType& c)
|
||||
++i;
|
||||
}
|
||||
|
||||
const bool valid = np > 0;
|
||||
|
||||
active.write(valid);
|
||||
typeId.write(valid);
|
||||
nParticle.write(valid);
|
||||
@ -247,6 +246,49 @@ void Foam::KinematicParcel<ParcelType>::writeFields(const CloudType& c)
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::KinematicParcel<ParcelType>::readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
ParcelType::readObjects(c, obr);
|
||||
|
||||
if (!c.size()) return;
|
||||
|
||||
const auto& active = cloud::lookupIOField<label>("active", obr);
|
||||
const auto& typeId = cloud::lookupIOField<label>("typeId", obr);
|
||||
const auto& nParticle = cloud::lookupIOField<scalar>("nParticle", obr);
|
||||
const auto& d = cloud::lookupIOField<scalar>("d", obr);
|
||||
const auto& dTarget = cloud::lookupIOField<scalar>("dTarget", obr);
|
||||
const auto& U = cloud::lookupIOField<vector>("U", obr);
|
||||
const auto& rho = cloud::lookupIOField<scalar>("rho", obr);
|
||||
const auto& age = cloud::lookupIOField<scalar>("age", obr);
|
||||
const auto& tTurb = cloud::lookupIOField<scalar>("tTurb", obr);
|
||||
const auto& UTurb = cloud::lookupIOField<vector>("UTurb", obr);
|
||||
|
||||
label i = 0;
|
||||
|
||||
for (KinematicParcel<ParcelType>& p : c)
|
||||
{
|
||||
p.active_ = active[i];
|
||||
p.typeId_ = typeId[i];
|
||||
p.nParticle_ = nParticle[i];
|
||||
p.d_ = d[i];
|
||||
p.dTarget_ = dTarget[i];
|
||||
p.U_ = U[i];
|
||||
p.rho_ = rho[i];
|
||||
p.age_ = age[i];
|
||||
p.tTurb_ = tTurb[i];
|
||||
p.UTurb_ = UTurb[i];
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::KinematicParcel<ParcelType>::writeObjects
|
||||
@ -257,21 +299,18 @@ void Foam::KinematicParcel<ParcelType>::writeObjects
|
||||
{
|
||||
ParcelType::writeObjects(c, obr);
|
||||
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
|
||||
IOField<label>& active(cloud::createIOField<label>("active", np, obr));
|
||||
IOField<label>& typeId(cloud::createIOField<label>("typeId", np, obr));
|
||||
IOField<scalar>& nParticle
|
||||
(
|
||||
cloud::createIOField<scalar>("nParticle", np, obr)
|
||||
);
|
||||
IOField<scalar>& d(cloud::createIOField<scalar>("d", np, obr));
|
||||
IOField<scalar>& dTarget(cloud::createIOField<scalar>("dTarget", np, obr));
|
||||
IOField<vector>& U(cloud::createIOField<vector>("U", np, obr));
|
||||
IOField<scalar>& rho(cloud::createIOField<scalar>("rho", np, obr));
|
||||
IOField<scalar>& age(cloud::createIOField<scalar>("age", np, obr));
|
||||
IOField<scalar>& tTurb(cloud::createIOField<scalar>("tTurb", np, obr));
|
||||
IOField<vector>& UTurb(cloud::createIOField<vector>("UTurb", np, obr));
|
||||
auto& active = cloud::createIOField<label>("active", np, obr);
|
||||
auto& typeId = cloud::createIOField<label>("typeId", np, obr);
|
||||
auto& nParticle = cloud::createIOField<scalar>("nParticle", np, obr);
|
||||
auto& d = cloud::createIOField<scalar>("d", np, obr);
|
||||
auto& dTarget = cloud::createIOField<scalar>("dTarget", np, obr);
|
||||
auto& U = cloud::createIOField<vector>("U", np, obr);
|
||||
auto& rho = cloud::createIOField<scalar>("rho", np, obr);
|
||||
auto& age = cloud::createIOField<scalar>("age", np, obr);
|
||||
auto& tTurb = cloud::createIOField<scalar>("tTurb", np, obr);
|
||||
auto&& UTurb = cloud::createIOField<vector>("UTurb", np, obr);
|
||||
|
||||
label i = 0;
|
||||
|
||||
|
||||
@ -307,6 +307,10 @@ public:
|
||||
template<class CloudType>
|
||||
static void writeFields(const CloudType& c);
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
template<class CloudType>
|
||||
static void readObjects(CloudType& c, const objectRegistry& obr);
|
||||
|
||||
//- Write particle fields as objects into the obr registry
|
||||
template<class CloudType>
|
||||
static void writeObjects(const CloudType& c, objectRegistry& obr);
|
||||
|
||||
@ -104,7 +104,7 @@ void Foam::MPPICParcel<ParcelType>::writeFields(const CloudType& c)
|
||||
{
|
||||
ParcelType::writeFields(c);
|
||||
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
|
||||
IOField<vector>
|
||||
UCorrect(c.fieldIOobject("UCorrect", IOobject::NO_READ), np);
|
||||
@ -122,6 +122,30 @@ void Foam::MPPICParcel<ParcelType>::writeFields(const CloudType& c)
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::MPPICParcel<ParcelType>::readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
ParcelType::readObjects(c, obr);
|
||||
|
||||
if (!c.size()) return;
|
||||
|
||||
const auto& UCorrect = cloud::lookupIOField<vector>("UCorrect", obr);
|
||||
|
||||
label i = 0;
|
||||
for (MPPICParcel<ParcelType>& p : c)
|
||||
{
|
||||
p.UCorrect() = UCorrect[i];
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::MPPICParcel<ParcelType>::writeObjects
|
||||
@ -132,13 +156,11 @@ void Foam::MPPICParcel<ParcelType>::writeObjects
|
||||
{
|
||||
ParcelType::writeObjects(c, obr);
|
||||
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
|
||||
IOField<vector>&
|
||||
UCorrect(cloud::createIOField<vector>("UCorrect", np, obr));
|
||||
auto& UCorrect = cloud::createIOField<vector>("UCorrect", np, obr);
|
||||
|
||||
label i = 0;
|
||||
|
||||
for (const MPPICParcel<ParcelType>& p : c)
|
||||
{
|
||||
UCorrect[i] = p.UCorrect();
|
||||
|
||||
@ -369,6 +369,24 @@ public:
|
||||
template<class CloudType>
|
||||
static void writeFields(const CloudType& c);
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
// - no composition
|
||||
template<class CloudType>
|
||||
static void readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const objectRegistry& obr
|
||||
);
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
template<class CloudType, class CompositionType>
|
||||
static void readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const CompositionType& compModel,
|
||||
const objectRegistry& obr
|
||||
);
|
||||
|
||||
//- Write particle fields as objects into the obr registry
|
||||
// - no composition
|
||||
template<class CloudType>
|
||||
|
||||
@ -85,7 +85,7 @@ void Foam::ReactingHeterogeneousParcel<ParcelType>::readFields
|
||||
const CompositionType& compModel
|
||||
)
|
||||
{
|
||||
bool valid = c.size();
|
||||
const bool valid = c.size();
|
||||
|
||||
ParcelType::readFields(c);
|
||||
|
||||
@ -183,7 +183,8 @@ void Foam::ReactingHeterogeneousParcel<ParcelType>::writeFields
|
||||
// writing Ysolids and F
|
||||
ThermoParcel<KinematicParcel<particle>>::writeFields(c);
|
||||
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
const bool valid = np;
|
||||
|
||||
IOField<scalar> mass0(c.fieldIOobject("mass0", IOobject::NO_READ), np);
|
||||
|
||||
@ -199,7 +200,7 @@ void Foam::ReactingHeterogeneousParcel<ParcelType>::writeFields
|
||||
}
|
||||
++i;
|
||||
}
|
||||
mass0.write(np > 0);
|
||||
mass0.write(valid);
|
||||
|
||||
for (label i = 0; i < nF; i++)
|
||||
{
|
||||
@ -218,7 +219,7 @@ void Foam::ReactingHeterogeneousParcel<ParcelType>::writeFields
|
||||
F = p0.F()[i];
|
||||
}
|
||||
|
||||
F.write(np > 0);
|
||||
F.write(valid);
|
||||
}
|
||||
|
||||
const label idSolid = compModel.idSolid();
|
||||
@ -243,11 +244,23 @@ void Foam::ReactingHeterogeneousParcel<ParcelType>::writeFields
|
||||
++i;
|
||||
}
|
||||
|
||||
Y.write(np > 0);
|
||||
Y.write(valid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::ReactingHeterogeneousParcel<ParcelType>::readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
ParcelType::readObjects(c, obr);
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::ReactingHeterogeneousParcel<ParcelType>::writeObjects
|
||||
@ -260,6 +273,27 @@ void Foam::ReactingHeterogeneousParcel<ParcelType>::writeObjects
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType, class CompositionType>
|
||||
void Foam::ReactingHeterogeneousParcel<ParcelType>::readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const CompositionType& compModel,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
//ParcelType::readObjects(c, obr);
|
||||
// Skip Reacting layer
|
||||
ThermoParcel<KinematicParcel<particle>>::readObjects(c, obr);
|
||||
|
||||
// const label np = c.size();
|
||||
|
||||
WarningInFunction
|
||||
<< "Reading of objects is still a work-in-progress" << nl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType, class CompositionType>
|
||||
void Foam::ReactingHeterogeneousParcel<ParcelType>::writeObjects
|
||||
@ -273,7 +307,7 @@ void Foam::ReactingHeterogeneousParcel<ParcelType>::writeObjects
|
||||
// Skip Reacting layer
|
||||
ThermoParcel<KinematicParcel<particle>>::writeObjects(c, obr);
|
||||
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
|
||||
// WIP
|
||||
label nF = 0;
|
||||
@ -288,10 +322,7 @@ void Foam::ReactingHeterogeneousParcel<ParcelType>::writeObjects
|
||||
for (label i = 0; i < nF; i++)
|
||||
{
|
||||
const word fieldName = "F" + name(i);
|
||||
IOField<scalar>& F
|
||||
(
|
||||
cloud::createIOField<scalar>(fieldName, np, obr)
|
||||
);
|
||||
auto& F = cloud::createIOField<scalar>(fieldName, np, obr);
|
||||
|
||||
label j = 0;
|
||||
for (const ReactingHeterogeneousParcel<ParcelType>& p0 : c)
|
||||
@ -306,10 +337,7 @@ void Foam::ReactingHeterogeneousParcel<ParcelType>::writeObjects
|
||||
forAll(solidNames, j)
|
||||
{
|
||||
const word fieldName = "Y" + solidNames[j];
|
||||
IOField<scalar>& Y
|
||||
(
|
||||
cloud::createIOField<scalar>(fieldName, np, obr)
|
||||
);
|
||||
auto& Y = cloud::createIOField<scalar>(fieldName, np, obr);
|
||||
|
||||
label i = 0;
|
||||
for (const ReactingHeterogeneousParcel<ParcelType>& p0 : c)
|
||||
|
||||
@ -461,6 +461,24 @@ public:
|
||||
template<class CloudType>
|
||||
static void writeFields(const CloudType& c);
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
// - no composition
|
||||
template<class CloudType>
|
||||
static void readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const objectRegistry& obr
|
||||
);
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
template<class CloudType, class CompositionType>
|
||||
static void readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const CompositionType& compModel,
|
||||
const objectRegistry& obr
|
||||
);
|
||||
|
||||
//- Write particle fields as objects into the obr registry
|
||||
// - no composition
|
||||
template<class CloudType>
|
||||
|
||||
@ -281,6 +281,18 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::writeFields
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::ReactingMultiphaseParcel<ParcelType>::readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
ParcelType::readObjects(c, obr);
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::ReactingMultiphaseParcel<ParcelType>::writeObjects
|
||||
@ -293,6 +305,72 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::writeObjects
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType, class CompositionType>
|
||||
void Foam::ReactingMultiphaseParcel<ParcelType>::readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const CompositionType& compModel,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
ParcelType::readObjects(c, obr);
|
||||
|
||||
const label np = c.size();
|
||||
|
||||
// The composition fractions
|
||||
if (np > 0)
|
||||
{
|
||||
const wordList& stateLabels = compModel.stateLabels();
|
||||
|
||||
const label idGas = compModel.idGas();
|
||||
const wordList& gasNames = compModel.componentNames(idGas);
|
||||
forAll(gasNames, j)
|
||||
{
|
||||
const word fieldName = "Y" + gasNames[j] + stateLabels[idGas];
|
||||
const auto& YGas = cloud::lookupIOField<scalar>(fieldName, obr);
|
||||
|
||||
label i = 0;
|
||||
for (ReactingMultiphaseParcel<ParcelType>& p0 : c)
|
||||
{
|
||||
p0.YGas()[j]*p0.Y()[GAS] = YGas[i];
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
const label idLiquid = compModel.idLiquid();
|
||||
const wordList& liquidNames = compModel.componentNames(idLiquid);
|
||||
forAll(liquidNames, j)
|
||||
{
|
||||
const word fieldName = "Y" + liquidNames[j] + stateLabels[idLiquid];
|
||||
const auto& YLiquid = cloud::lookupIOField<scalar>(fieldName, obr);
|
||||
|
||||
label i = 0;
|
||||
for (ReactingMultiphaseParcel<ParcelType>& p0 : c)
|
||||
{
|
||||
p0.YLiquid()[j]*p0.Y()[LIQ] = YLiquid[i];
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
const label idSolid = compModel.idSolid();
|
||||
const wordList& solidNames = compModel.componentNames(idSolid);
|
||||
forAll(solidNames, j)
|
||||
{
|
||||
const word fieldName = "Y" + solidNames[j] + stateLabels[idSolid];
|
||||
const auto& YSolid = cloud::lookupIOField<scalar>(fieldName, obr);
|
||||
|
||||
label i = 0;
|
||||
for (ReactingMultiphaseParcel<ParcelType>& p0 : c)
|
||||
{
|
||||
p0.YSolid()[j]*p0.Y()[SLD] = YSolid[i];
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType, class CompositionType>
|
||||
void Foam::ReactingMultiphaseParcel<ParcelType>::writeObjects
|
||||
@ -304,7 +382,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::writeObjects
|
||||
{
|
||||
ParcelType::writeObjects(c, obr);
|
||||
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
|
||||
// Write the composition fractions
|
||||
if (np > 0)
|
||||
@ -316,10 +394,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::writeObjects
|
||||
forAll(gasNames, j)
|
||||
{
|
||||
const word fieldName = "Y" + gasNames[j] + stateLabels[idGas];
|
||||
IOField<scalar>& YGas
|
||||
(
|
||||
cloud::createIOField<scalar>(fieldName, np, obr)
|
||||
);
|
||||
auto& YGas = cloud::createIOField<scalar>(fieldName, np, obr);
|
||||
|
||||
label i = 0;
|
||||
for (const ReactingMultiphaseParcel<ParcelType>& p0 : c)
|
||||
@ -334,10 +409,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::writeObjects
|
||||
forAll(liquidNames, j)
|
||||
{
|
||||
const word fieldName = "Y" + liquidNames[j] + stateLabels[idLiquid];
|
||||
IOField<scalar>& YLiquid
|
||||
(
|
||||
cloud::createIOField<scalar>(fieldName, np, obr)
|
||||
);
|
||||
auto& YLiquid = cloud::createIOField<scalar>(fieldName, np, obr);
|
||||
|
||||
label i = 0;
|
||||
for (const ReactingMultiphaseParcel<ParcelType>& p0 : c)
|
||||
@ -352,10 +424,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::writeObjects
|
||||
forAll(solidNames, j)
|
||||
{
|
||||
const word fieldName = "Y" + solidNames[j] + stateLabels[idSolid];
|
||||
IOField<scalar>& YSolid
|
||||
(
|
||||
cloud::createIOField<scalar>(fieldName, np, obr)
|
||||
);
|
||||
auto& YSolid = cloud::createIOField<scalar>(fieldName, np, obr);
|
||||
|
||||
label i = 0;
|
||||
for (const ReactingMultiphaseParcel<ParcelType>& p0 : c)
|
||||
@ -380,6 +449,7 @@ Foam::Ostream& Foam::operator<<
|
||||
scalarField YGasLoc(p.YGas()*p.Y()[0]);
|
||||
scalarField YLiquidLoc(p.YLiquid()*p.Y()[1]);
|
||||
scalarField YSolidLoc(p.YSolid()*p.Y()[2]);
|
||||
|
||||
if (os.format() == IOstream::ASCII)
|
||||
{
|
||||
os << static_cast<const ParcelType&>(p)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2008-2011, 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2008-2011, 2016-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
@ -414,6 +414,24 @@ public:
|
||||
static void writeFields(const CloudType& c);
|
||||
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
// - no composition
|
||||
template<class CloudType>
|
||||
static void readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const objectRegistry& obr
|
||||
);
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
template<class CloudType, class CompositionType>
|
||||
static void readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const CompositionType& compModel,
|
||||
const objectRegistry& obr
|
||||
);
|
||||
|
||||
//- Write particle fields as objects into the obr registry
|
||||
// - no composition
|
||||
template<class CloudType>
|
||||
@ -432,6 +450,7 @@ public:
|
||||
objectRegistry& obr
|
||||
);
|
||||
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
friend Ostream& operator<< <ParcelType>
|
||||
|
||||
@ -219,6 +219,18 @@ void Foam::ReactingParcel<ParcelType>::writeFields
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::ReactingParcel<ParcelType>::readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
ParcelType::readObjects(c, obr);
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::ReactingParcel<ParcelType>::writeObjects
|
||||
@ -231,6 +243,54 @@ void Foam::ReactingParcel<ParcelType>::writeObjects
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType, class CompositionType>
|
||||
void Foam::ReactingParcel<ParcelType>::readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const CompositionType& compModel,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
ParcelType::readObjects(c, obr);
|
||||
|
||||
if (!c.size()) return;
|
||||
|
||||
|
||||
auto& mass0 = cloud::lookupIOField<scalar>("mass0", obr);
|
||||
|
||||
label i = 0;
|
||||
for (ReactingParcel<ParcelType>& p : c)
|
||||
{
|
||||
p.mass0_ = mass0[i];
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
// The composition fractions
|
||||
const wordList& phaseTypes = compModel.phaseTypes();
|
||||
wordList stateLabels(phaseTypes.size(), "");
|
||||
if (compModel.nPhase() == 1)
|
||||
{
|
||||
stateLabels = compModel.stateLabels()[0];
|
||||
}
|
||||
|
||||
forAll(phaseTypes, j)
|
||||
{
|
||||
const word fieldName = "Y" + phaseTypes[j] + stateLabels[j];
|
||||
auto& Y = cloud::lookupIOField<scalar>(fieldName, obr);
|
||||
|
||||
label i = 0;
|
||||
for (ReactingParcel<ParcelType>& p : c)
|
||||
{
|
||||
p.Y()[j] = Y[i];
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType, class CompositionType>
|
||||
void Foam::ReactingParcel<ParcelType>::writeObjects
|
||||
@ -242,11 +302,11 @@ void Foam::ReactingParcel<ParcelType>::writeObjects
|
||||
{
|
||||
ParcelType::writeObjects(c, obr);
|
||||
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
|
||||
if (np > 0)
|
||||
{
|
||||
IOField<scalar>& mass0(cloud::createIOField<scalar>("mass0", np, obr));
|
||||
auto& mass0 = cloud::createIOField<scalar>("mass0", np, obr);
|
||||
|
||||
label i = 0;
|
||||
for (const ReactingParcel<ParcelType>& p : c)
|
||||
@ -267,10 +327,7 @@ void Foam::ReactingParcel<ParcelType>::writeObjects
|
||||
forAll(phaseTypes, j)
|
||||
{
|
||||
const word fieldName = "Y" + phaseTypes[j] + stateLabels[j];
|
||||
IOField<scalar>& Y
|
||||
(
|
||||
cloud::createIOField<scalar>(fieldName, np, obr)
|
||||
);
|
||||
auto& Y = cloud::createIOField<scalar>(fieldName, np, obr);
|
||||
|
||||
label i = 0;
|
||||
for (const ReactingParcel<ParcelType>& p : c)
|
||||
|
||||
@ -454,6 +454,10 @@ public:
|
||||
template<class CloudType>
|
||||
static void writeFields(const CloudType& c);
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
template<class CloudType>
|
||||
static void readObjects(CloudType& c, const objectRegistry& obr);
|
||||
|
||||
//- Write particle fields as objects into the obr registry
|
||||
template<class CloudType>
|
||||
static void writeObjects(const CloudType& c, objectRegistry& obr);
|
||||
|
||||
@ -78,7 +78,7 @@ template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::ThermoParcel<ParcelType>::readFields(CloudType& c)
|
||||
{
|
||||
bool valid = c.size();
|
||||
const bool valid = c.size();
|
||||
|
||||
ParcelType::readFields(c);
|
||||
|
||||
@ -94,6 +94,7 @@ void Foam::ThermoParcel<ParcelType>::readFields(CloudType& c)
|
||||
{
|
||||
p.T_ = T[i];
|
||||
p.Cp_ = Cp[i];
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@ -105,7 +106,8 @@ void Foam::ThermoParcel<ParcelType>::writeFields(const CloudType& c)
|
||||
{
|
||||
ParcelType::writeFields(c);
|
||||
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
const bool valid = np;
|
||||
|
||||
IOField<scalar> T(c.fieldIOobject("T", IOobject::NO_READ), np);
|
||||
IOField<scalar> Cp(c.fieldIOobject("Cp", IOobject::NO_READ), np);
|
||||
@ -115,11 +117,38 @@ void Foam::ThermoParcel<ParcelType>::writeFields(const CloudType& c)
|
||||
{
|
||||
T[i] = p.T_;
|
||||
Cp[i] = p.Cp_;
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
T.write(np > 0);
|
||||
Cp.write(np > 0);
|
||||
T.write(valid);
|
||||
Cp.write(valid);
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::ThermoParcel<ParcelType>::readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
ParcelType::readFields(c);
|
||||
|
||||
if (!c.size()) return;
|
||||
|
||||
auto& T = cloud::lookupIOField<scalar>("T", obr);
|
||||
auto& Cp = cloud::lookupIOField<scalar>("Cp", obr);
|
||||
|
||||
label i = 0;
|
||||
for (ThermoParcel<ParcelType>& p : c)
|
||||
{
|
||||
p.T_ = T[i];
|
||||
p.Cp_ = Cp[i];
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -133,16 +162,17 @@ void Foam::ThermoParcel<ParcelType>::writeObjects
|
||||
{
|
||||
ParcelType::writeObjects(c, obr);
|
||||
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
|
||||
IOField<scalar>& T(cloud::createIOField<scalar>("T", np, obr));
|
||||
IOField<scalar>& Cp(cloud::createIOField<scalar>("Cp", np, obr));
|
||||
auto& T = cloud::createIOField<scalar>("T", np, obr);
|
||||
auto& Cp = cloud::createIOField<scalar>("Cp", np, obr);
|
||||
|
||||
label i = 0;
|
||||
for (const ThermoParcel<ParcelType>& p : c)
|
||||
{
|
||||
T[i] = p.T_;
|
||||
Cp[i] = p.Cp_;
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ Foam::molecule::molecule
|
||||
|
||||
void Foam::molecule::readFields(Cloud<molecule>& mC)
|
||||
{
|
||||
bool valid = mC.size();
|
||||
const bool valid = mC.size();
|
||||
|
||||
particle::readFields(mC);
|
||||
|
||||
@ -148,7 +148,8 @@ void Foam::molecule::writeFields(const Cloud<molecule>& mC)
|
||||
{
|
||||
particle::writeFields(mC);
|
||||
|
||||
label np = mC.size();
|
||||
const label np = mC.size();
|
||||
const bool valid = np;
|
||||
|
||||
IOField<tensor> Q(mC.fieldIOobject("Q", IOobject::NO_READ), np);
|
||||
IOField<vector> v(mC.fieldIOobject("v", IOobject::NO_READ), np);
|
||||
@ -217,8 +218,6 @@ void Foam::molecule::writeFields(const Cloud<molecule>& mC)
|
||||
++i;
|
||||
}
|
||||
|
||||
const bool valid = np > 0;
|
||||
|
||||
Q.write(valid);
|
||||
v.write(valid);
|
||||
a.write(valid);
|
||||
|
||||
@ -500,6 +500,24 @@ public:
|
||||
template<class CloudType>
|
||||
static void writeFields(const CloudType& c);
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
// - no composition
|
||||
template<class CloudType>
|
||||
static void readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const objectRegistry& obr
|
||||
);
|
||||
|
||||
//- Read particle fields as objects from the obr registry
|
||||
template<class CloudType, class CompositionType>
|
||||
static void readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const CompositionType& compModel,
|
||||
const objectRegistry& obr
|
||||
);
|
||||
|
||||
//- Write particle fields as objects into the obr registry
|
||||
// - no composition
|
||||
template<class CloudType>
|
||||
|
||||
@ -112,7 +112,7 @@ void Foam::SprayParcel<ParcelType>::readFields
|
||||
const CompositionType& compModel
|
||||
)
|
||||
{
|
||||
bool valid = c.size();
|
||||
const bool valid = c.size();
|
||||
|
||||
ParcelType::readFields(c, compModel);
|
||||
|
||||
@ -211,6 +211,7 @@ void Foam::SprayParcel<ParcelType>::readFields
|
||||
p.injector_ = injector[i];
|
||||
p.tMom_ = tMom[i];
|
||||
p.user_ = user[i];
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@ -234,7 +235,9 @@ void Foam::SprayParcel<ParcelType>::writeFields
|
||||
{
|
||||
ParcelType::writeFields(c, compModel);
|
||||
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
const bool valid = np;
|
||||
|
||||
|
||||
IOField<scalar> d0(c.fieldIOobject("d0", IOobject::NO_READ), np);
|
||||
IOField<vector> position0
|
||||
@ -281,8 +284,6 @@ void Foam::SprayParcel<ParcelType>::writeFields
|
||||
++i;
|
||||
}
|
||||
|
||||
const bool valid = np > 0;
|
||||
|
||||
d0.write(valid);
|
||||
position0.write(valid);
|
||||
sigma.write(valid);
|
||||
@ -299,6 +300,18 @@ void Foam::SprayParcel<ParcelType>::writeFields
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::SprayParcel<ParcelType>::readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
ParcelType::readObjects(c, obr);
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType>
|
||||
void Foam::SprayParcel<ParcelType>::writeObjects
|
||||
@ -311,6 +324,55 @@ void Foam::SprayParcel<ParcelType>::writeObjects
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType, class CompositionType>
|
||||
void Foam::SprayParcel<ParcelType>::readObjects
|
||||
(
|
||||
CloudType& c,
|
||||
const CompositionType& compModel,
|
||||
const objectRegistry& obr
|
||||
)
|
||||
{
|
||||
ParcelType::readObjects(c, compModel, obr);
|
||||
|
||||
if (!c.size()) return;
|
||||
|
||||
const auto& d0 = cloud::lookupIOField<scalar>("d0", obr);
|
||||
const auto& position0 = cloud::lookupIOField<vector>("position0", obr);
|
||||
const auto& sigma = cloud::lookupIOField<scalar>("sigma", obr);
|
||||
const auto& mu = cloud::lookupIOField<scalar>("mu", obr);
|
||||
const auto& liquidCore = cloud::lookupIOField<scalar>("liquidCore", obr);
|
||||
const auto& KHindex = cloud::lookupIOField<scalar>("KHindex", obr);
|
||||
const auto& y = cloud::lookupIOField<scalar>("y", obr);
|
||||
const auto& yDot = cloud::lookupIOField<scalar>("yDot", obr);
|
||||
const auto& tc = cloud::lookupIOField<scalar>("tc", obr);
|
||||
const auto& ms = cloud::lookupIOField<scalar>("ms", obr);
|
||||
const auto& injector = cloud::lookupIOField<scalar>("injector", obr);
|
||||
const auto& tMom = cloud::lookupIOField<scalar>("tMom", obr);
|
||||
const auto& user = cloud::lookupIOField<scalar>("user", obr);
|
||||
|
||||
label i = 0;
|
||||
for (SprayParcel<ParcelType>& p : c)
|
||||
{
|
||||
p.d0_ = d0[i];
|
||||
p.position0_ = position0[i];
|
||||
p.sigma_ = sigma[i];
|
||||
p.mu_ = mu[i];
|
||||
p.liquidCore_ = liquidCore[i];
|
||||
p.KHindex_ = KHindex[i];
|
||||
p.y_ = y[i];
|
||||
p.yDot_ = yDot[i];
|
||||
p.tc_ = tc[i];
|
||||
p.ms_ = ms[i];
|
||||
p.injector_ = injector[i];
|
||||
p.tMom_ = tMom[i];
|
||||
p.user_ = user[i];
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class ParcelType>
|
||||
template<class CloudType, class CompositionType>
|
||||
void Foam::SprayParcel<ParcelType>::writeObjects
|
||||
@ -322,30 +384,21 @@ void Foam::SprayParcel<ParcelType>::writeObjects
|
||||
{
|
||||
ParcelType::writeObjects(c, compModel, obr);
|
||||
|
||||
label np = c.size();
|
||||
const label np = c.size();
|
||||
|
||||
IOField<scalar>& d0(cloud::createIOField<scalar>("d0", np, obr));
|
||||
IOField<vector>& position0
|
||||
(
|
||||
cloud::createIOField<vector>("position0", np, obr)
|
||||
);
|
||||
IOField<scalar>& sigma(cloud::createIOField<scalar>("sigma", np, obr));
|
||||
IOField<scalar>& mu(cloud::createIOField<scalar>("mu", np, obr));
|
||||
IOField<scalar>& liquidCore
|
||||
(
|
||||
cloud::createIOField<scalar>("liquidCore", np, obr)
|
||||
);
|
||||
IOField<scalar>& KHindex(cloud::createIOField<scalar>("KHindex", np, obr));
|
||||
IOField<scalar>& y(cloud::createIOField<scalar>("y", np, obr));
|
||||
IOField<scalar>& yDot(cloud::createIOField<scalar>("yDot", np, obr));
|
||||
IOField<scalar>& tc(cloud::createIOField<scalar>("tc", np, obr));
|
||||
IOField<scalar>& ms(cloud::createIOField<scalar>("ms", np, obr));
|
||||
IOField<scalar>& injector
|
||||
(
|
||||
cloud::createIOField<scalar>("injector", np, obr)
|
||||
);
|
||||
IOField<scalar>& tMom(cloud::createIOField<scalar>("tMom", np, obr));
|
||||
IOField<scalar>& user(cloud::createIOField<scalar>("user", np, obr));
|
||||
auto& d0 = cloud::createIOField<scalar>("d0", np, obr);
|
||||
auto& position0 = cloud::createIOField<vector>("position0", np, obr);
|
||||
auto& sigma = cloud::createIOField<scalar>("sigma", np, obr);
|
||||
auto& mu = cloud::createIOField<scalar>("mu", np, obr);
|
||||
auto& liquidCore = cloud::createIOField<scalar>("liquidCore", np, obr);
|
||||
auto& KHindex = cloud::createIOField<scalar>("KHindex", np, obr);
|
||||
auto& y = cloud::createIOField<scalar>("y", np, obr);
|
||||
auto& yDot= cloud::createIOField<scalar>("yDot", np, obr);
|
||||
auto& tc = cloud::createIOField<scalar>("tc", np, obr);
|
||||
auto& ms = cloud::createIOField<scalar>("ms", np, obr);
|
||||
auto& injector = cloud::createIOField<scalar>("injector", np, obr);
|
||||
auto& tMom = cloud::createIOField<scalar>("tMom", np, obr);
|
||||
auto& user = cloud::createIOField<scalar>("user", np, obr);
|
||||
|
||||
label i = 0;
|
||||
for (const SprayParcel<ParcelType>& p : c)
|
||||
@ -363,6 +416,7 @@ void Foam::SprayParcel<ParcelType>::writeObjects
|
||||
injector[i] = p.injector_;
|
||||
tMom[i] = p.tMom_;
|
||||
user[i] = p.user_;
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user