Commit 743311df authored by Mark OLESEN's avatar Mark OLESEN Committed by Andrew Heather
Browse files

STYLE: consistent access for particle sizeofFields, particle iterators

parent 3d0ed07f
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -64,9 +64,6 @@ class DTRMParticle
{
// Private data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
//- Initial position
point p0_;
......@@ -144,7 +141,12 @@ public:
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
AddToPropertyList
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
......@@ -64,12 +64,6 @@ class wallBoundedParticle
:
public particle
{
// Private data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
public:
//- Class used to pass tracking data to the trackToFace function
......@@ -151,6 +145,12 @@ protected:
public:
// Static Data Members
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
// Constructors
//- Construct from components
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
......@@ -443,11 +443,12 @@ void Foam::wallBoundedParticle::readFields(TrackCloudType& c)
c.checkFieldIOobject(c, diagEdge);
label i = 0;
forAllIters(c, iter)
for (wallBoundedParticle& p : c)
{
iter().localPosition_ = localPosition[i];
iter().meshEdgeStart_ = meshEdgeStart[i];
iter().diagEdge_ = diagEdge[i];
p.localPosition_ = localPosition[i];
p.meshEdgeStart_ = meshEdgeStart[i];
p.diagEdge_ = diagEdge[i];
++i;
}
}
......@@ -458,7 +459,7 @@ void Foam::wallBoundedParticle::writeFields(const TrackCloudType& c)
{
particle::writeFields(c);
label np = c.size();
label np = c.size();
IOField<point> localPosition
(
......@@ -477,11 +478,12 @@ void Foam::wallBoundedParticle::writeFields(const TrackCloudType& c)
);
label i = 0;
forAllConstIters(c, iter)
for (const wallBoundedParticle& p : c)
{
localPosition[i] = iter().localPosition_;
meshEdgeStart[i] = iter().meshEdgeStart_;
diagEdge[i] = iter().diagEdge_;
localPosition[i] = p.localPosition_;
meshEdgeStart[i] = p.meshEdgeStart_;
diagEdge[i] = p.diagEdge_;
++i;
}
......
......@@ -116,10 +116,8 @@ void Foam::Cloud<ParticleType>::deleteParticle(ParticleType& p)
template<class ParticleType>
void Foam::Cloud<ParticleType>::deleteLostParticles()
{
forAllIters(*this, pIter)
for (ParticleType& p : *this)
{
ParticleType& p = pIter();
if (p.cell() == -1)
{
WarningInFunction
......@@ -208,10 +206,8 @@ void Foam::Cloud<ParticleType>::move
}
// Loop over all particles
forAllIters(*this, pIter)
for (ParticleType& p : *this)
{
ParticleType& p = pIter();
// Move the particle
bool keepParticle = p.move(cloud, td, trackTime);
......@@ -330,10 +326,8 @@ void Foam::Cloud<ParticleType>::move
label pI = 0;
forAllIters(newParticles, newpIter)
for (ParticleType& newp : newParticles)
{
ParticleType& newp = newpIter();
label patchi = procPatches[receivePatchIndex[pI++]];
newp.correctAfterParallelTransfer(patchi, td);
......
......@@ -69,12 +69,6 @@ class injectedParticle
:
public particle
{
public:
//- Size in bytes of the fields
static const std::size_t sizeofFields;
protected:
// Protected data
......@@ -99,7 +93,10 @@ protected:
public:
// Static data members
// Static Data Members
//- Size in bytes of the fields
static const std::size_t sizeofFields;
//- Runtime type information
TypeName("injectedParticle");
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -36,8 +36,8 @@ Foam::string Foam::injectedParticle::propertyList_ =
const std::size_t Foam::injectedParticle::sizeofFields
(
// Note: does not include position_
sizeof(label) + sizeof(scalar) + sizeof(scalar) + sizeof(vector)
// Does not include position_
sizeof(injectedParticle) - offsetof(injectedParticle, tag_)
);
......@@ -106,17 +106,14 @@ void Foam::injectedParticle::readFields(Cloud<injectedParticle>& c)
c.checkFieldIOobject(c, U);
label i = 0;
forAllIters(c, iter)
for (injectedParticle& p : c)
{
injectedParticle& p = iter();
p.tag_ = tag[i];
p.soi_ = soi[i];
p.d_ = d[i];
p.U_ = U[i];
i++;
++i;
}
}
......@@ -143,10 +140,8 @@ void Foam::injectedParticle::writeFields(const Cloud<injectedParticle>& c)
label i = 0;
forAllConstIters(c, iter)
for (const injectedParticle& p : c)
{
const injectedParticle& p = iter();
tag[i] = p.tag();
soi[i] = p.soi();
d[i] = p.d();
......@@ -190,10 +185,8 @@ void Foam::injectedParticle::writeObjects
label i = 0;
forAllConstIters(c, iter)
for (const injectedParticle& p : c)
{
const injectedParticle& p = iter();
tag[i] = p.tag();
soi[i] = p.soi();
d[i] = p.d();
......
......@@ -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 |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
......@@ -50,6 +50,7 @@ void Foam::particle::readFields(TrackCloudType& c)
IOField<label> origProcId(procIO, valid && haveFile);
c.checkFieldIOobject(c, origProcId);
IOField<label> origId
(
c.fieldIOobject("origId", IOobject::MUST_READ),
......@@ -58,13 +59,11 @@ void Foam::particle::readFields(TrackCloudType& c)
c.checkFieldIOobject(c, origId);
label i = 0;
forAllIters(c, iter)
for (particle& p : c)
{
particle& p = iter();
p.origProc_ = origProcId[i];
p.origId_ = origId[i];
i++;
++i;
}
}
......@@ -103,10 +102,11 @@ void Foam::particle::writeFields(const TrackCloudType& c)
);
label i = 0;
forAllConstIters(c, iter)
for (const particle& p : c)
{
origProc[i] = iter().origProc_;
origId[i] = iter().origId_;
origProc[i] = p.origProc_;
origId[i] = p.origId_;
++i;
}
......@@ -125,11 +125,12 @@ void Foam::particle::writeObjects(const CloudType& c, objectRegistry& obr)
IOField<point>& position(cloud::createIOField<point>("position", np, obr));
label i = 0;
forAllConstIters(c, iter)
for (const particle& p : c)
{
origProc[i] = iter().origProc_;
origId[i] = iter().origId_;
position[i] = iter().position();
origProc[i] = p.origProc_;
origId[i] = p.origId_;
position[i] = p.position();
++i;
}
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
......@@ -28,6 +28,14 @@ License
#include "trackedParticle.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const std::size_t Foam::trackedParticle::sizeofFields_
(
sizeof(trackedParticle) - offsetof(trackedParticle, start_)
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::trackedParticle::trackedParticle
......@@ -101,8 +109,7 @@ Foam::trackedParticle::trackedParticle
is.read
(
reinterpret_cast<char*>(&start_),
sizeof(start_) + sizeof(end_) + sizeof(level_)
+ sizeof(i_) + sizeof(j_) + sizeof(k_)
sizeofFields_
);
}
}
......@@ -288,8 +295,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const trackedParticle& p)
os.write
(
reinterpret_cast<const char*>(&p.start_),
sizeof(p.start_) + sizeof(p.end_) + sizeof(p.level_)
+ sizeof(p.i_) + sizeof(p.j_) + sizeof(p.k_)
trackedParticle::sizeofFields_
);
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| 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
......
Supports Markdown
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