STYLE: consistent access for particle sizeofFields, particle iterators

This commit is contained in:
Mark Olesen
2019-07-30 14:22:56 +02:00
committed by Andrew Heather
parent 3d0ed07fff
commit 743311df7d
9 changed files with 70 additions and 70 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -64,9 +64,6 @@ class DTRMParticle
{ {
// Private data // Private data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
//- Initial position //- Initial position
point p0_; point p0_;
@ -144,7 +141,12 @@ public:
inline scalar& Q(label celli); inline scalar& Q(label celli);
}; };
// Static data members
// Static Data Members
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
//- String representation of properties //- String representation of properties
AddToPropertyList AddToPropertyList

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -64,12 +64,6 @@ class wallBoundedParticle
: :
public particle public particle
{ {
// Private data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
public: public:
//- Class used to pass tracking data to the trackToFace function //- Class used to pass tracking data to the trackToFace function
@ -151,6 +145,12 @@ protected:
public: public:
// Static Data Members
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
// Constructors // Constructors
//- Construct from components //- Construct from components

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -443,11 +443,12 @@ void Foam::wallBoundedParticle::readFields(TrackCloudType& c)
c.checkFieldIOobject(c, diagEdge); c.checkFieldIOobject(c, diagEdge);
label i = 0; label i = 0;
forAllIters(c, iter) for (wallBoundedParticle& p : c)
{ {
iter().localPosition_ = localPosition[i]; p.localPosition_ = localPosition[i];
iter().meshEdgeStart_ = meshEdgeStart[i]; p.meshEdgeStart_ = meshEdgeStart[i];
iter().diagEdge_ = diagEdge[i]; p.diagEdge_ = diagEdge[i];
++i; ++i;
} }
} }
@ -477,11 +478,12 @@ void Foam::wallBoundedParticle::writeFields(const TrackCloudType& c)
); );
label i = 0; label i = 0;
forAllConstIters(c, iter) for (const wallBoundedParticle& p : c)
{ {
localPosition[i] = iter().localPosition_; localPosition[i] = p.localPosition_;
meshEdgeStart[i] = iter().meshEdgeStart_; meshEdgeStart[i] = p.meshEdgeStart_;
diagEdge[i] = iter().diagEdge_; diagEdge[i] = p.diagEdge_;
++i; ++i;
} }

View File

@ -116,10 +116,8 @@ void Foam::Cloud<ParticleType>::deleteParticle(ParticleType& p)
template<class ParticleType> template<class ParticleType>
void Foam::Cloud<ParticleType>::deleteLostParticles() void Foam::Cloud<ParticleType>::deleteLostParticles()
{ {
forAllIters(*this, pIter) for (ParticleType& p : *this)
{ {
ParticleType& p = pIter();
if (p.cell() == -1) if (p.cell() == -1)
{ {
WarningInFunction WarningInFunction
@ -208,10 +206,8 @@ void Foam::Cloud<ParticleType>::move
} }
// Loop over all particles // Loop over all particles
forAllIters(*this, pIter) for (ParticleType& p : *this)
{ {
ParticleType& p = pIter();
// Move the particle // Move the particle
bool keepParticle = p.move(cloud, td, trackTime); bool keepParticle = p.move(cloud, td, trackTime);
@ -330,10 +326,8 @@ void Foam::Cloud<ParticleType>::move
label pI = 0; label pI = 0;
forAllIters(newParticles, newpIter) for (ParticleType& newp : newParticles)
{ {
ParticleType& newp = newpIter();
label patchi = procPatches[receivePatchIndex[pI++]]; label patchi = procPatches[receivePatchIndex[pI++]];
newp.correctAfterParallelTransfer(patchi, td); newp.correctAfterParallelTransfer(patchi, td);

View File

@ -69,12 +69,6 @@ class injectedParticle
: :
public particle public particle
{ {
public:
//- Size in bytes of the fields
static const std::size_t sizeofFields;
protected: protected:
// Protected data // Protected data
@ -99,7 +93,10 @@ protected:
public: public:
// Static data members // Static Data Members
//- Size in bytes of the fields
static const std::size_t sizeofFields;
//- Runtime type information //- Runtime type information
TypeName("injectedParticle"); TypeName("injectedParticle");

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -36,8 +36,8 @@ Foam::string Foam::injectedParticle::propertyList_ =
const std::size_t Foam::injectedParticle::sizeofFields const std::size_t Foam::injectedParticle::sizeofFields
( (
// Note: does not include position_ // Does not include position_
sizeof(label) + sizeof(scalar) + sizeof(scalar) + sizeof(vector) sizeof(injectedParticle) - offsetof(injectedParticle, tag_)
); );
@ -106,17 +106,14 @@ void Foam::injectedParticle::readFields(Cloud<injectedParticle>& c)
c.checkFieldIOobject(c, U); c.checkFieldIOobject(c, U);
label i = 0; label i = 0;
for (injectedParticle& p : c)
forAllIters(c, iter)
{ {
injectedParticle& p = iter();
p.tag_ = tag[i]; p.tag_ = tag[i];
p.soi_ = soi[i]; p.soi_ = soi[i];
p.d_ = d[i]; p.d_ = d[i];
p.U_ = U[i]; p.U_ = U[i];
i++; ++i;
} }
} }
@ -143,10 +140,8 @@ void Foam::injectedParticle::writeFields(const Cloud<injectedParticle>& c)
label i = 0; label i = 0;
forAllConstIters(c, iter) for (const injectedParticle& p : c)
{ {
const injectedParticle& p = iter();
tag[i] = p.tag(); tag[i] = p.tag();
soi[i] = p.soi(); soi[i] = p.soi();
d[i] = p.d(); d[i] = p.d();
@ -190,10 +185,8 @@ void Foam::injectedParticle::writeObjects
label i = 0; label i = 0;
forAllConstIters(c, iter) for (const injectedParticle& p : c)
{ {
const injectedParticle& p = iter();
tag[i] = p.tag(); tag[i] = p.tag();
soi[i] = p.soi(); soi[i] = p.soi();
d[i] = p.d(); d[i] = p.d();

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -50,6 +50,7 @@ void Foam::particle::readFields(TrackCloudType& c)
IOField<label> origProcId(procIO, valid && haveFile); IOField<label> origProcId(procIO, valid && haveFile);
c.checkFieldIOobject(c, origProcId); c.checkFieldIOobject(c, origProcId);
IOField<label> origId IOField<label> origId
( (
c.fieldIOobject("origId", IOobject::MUST_READ), c.fieldIOobject("origId", IOobject::MUST_READ),
@ -58,13 +59,11 @@ void Foam::particle::readFields(TrackCloudType& c)
c.checkFieldIOobject(c, origId); c.checkFieldIOobject(c, origId);
label i = 0; label i = 0;
forAllIters(c, iter) for (particle& p : c)
{ {
particle& p = iter();
p.origProc_ = origProcId[i]; p.origProc_ = origProcId[i];
p.origId_ = origId[i]; p.origId_ = origId[i];
i++; ++i;
} }
} }
@ -103,10 +102,11 @@ void Foam::particle::writeFields(const TrackCloudType& c)
); );
label i = 0; label i = 0;
forAllConstIters(c, iter) for (const particle& p : c)
{ {
origProc[i] = iter().origProc_; origProc[i] = p.origProc_;
origId[i] = iter().origId_; origId[i] = p.origId_;
++i; ++i;
} }
@ -125,11 +125,12 @@ void Foam::particle::writeObjects(const CloudType& c, objectRegistry& obr)
IOField<point>& position(cloud::createIOField<point>("position", np, obr)); IOField<point>& position(cloud::createIOField<point>("position", np, obr));
label i = 0; label i = 0;
forAllConstIters(c, iter) for (const particle& p : c)
{ {
origProc[i] = iter().origProc_; origProc[i] = p.origProc_;
origId[i] = iter().origId_; origId[i] = p.origId_;
position[i] = iter().position(); position[i] = p.position();
++i; ++i;
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -28,6 +28,14 @@ License
#include "trackedParticle.H" #include "trackedParticle.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const std::size_t Foam::trackedParticle::sizeofFields_
(
sizeof(trackedParticle) - offsetof(trackedParticle, start_)
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::trackedParticle::trackedParticle Foam::trackedParticle::trackedParticle
@ -101,8 +109,7 @@ Foam::trackedParticle::trackedParticle
is.read is.read
( (
reinterpret_cast<char*>(&start_), reinterpret_cast<char*>(&start_),
sizeof(start_) + sizeof(end_) + sizeof(level_) sizeofFields_
+ sizeof(i_) + sizeof(j_) + sizeof(k_)
); );
} }
} }
@ -288,8 +295,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const trackedParticle& p)
os.write os.write
( (
reinterpret_cast<const char*>(&p.start_), reinterpret_cast<const char*>(&p.start_),
sizeof(p.start_) + sizeof(p.end_) + sizeof(p.level_) trackedParticle::sizeofFields_
+ sizeof(p.i_) + sizeof(p.j_) + sizeof(p.k_)
); );
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -117,6 +117,11 @@ public:
}; };
// Static Data Members
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
// Constructors // Constructors