mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: for-range, forAllIters() ... in lagrangian/ basic
- reduced clutter when iterating over containers
This commit is contained in:
@ -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) 2008-2011 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2008-2011, 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
@ -320,10 +320,8 @@ void Foam::InteractionLists<ParticleType>::buildInteractionLists()
|
|||||||
// Determine the index of all of the wall faces on this processor
|
// Determine the index of all of the wall faces on this processor
|
||||||
DynamicList<label> localWallFaces;
|
DynamicList<label> localWallFaces;
|
||||||
|
|
||||||
forAll(mesh_.boundaryMesh(), patchi)
|
for (const polyPatch& patch : mesh_.boundaryMesh())
|
||||||
{
|
{
|
||||||
const polyPatch& patch = mesh_.boundaryMesh()[patchi];
|
|
||||||
|
|
||||||
if (isA<wallPolyPatch>(patch))
|
if (isA<wallPolyPatch>(patch))
|
||||||
{
|
{
|
||||||
const scalarField areaFraction(patch.areaFraction());
|
const scalarField areaFraction(patch.areaFraction());
|
||||||
@ -607,11 +605,9 @@ void Foam::InteractionLists<ParticleType>::buildInteractionLists()
|
|||||||
// Reserve space to avoid multiple resizing
|
// Reserve space to avoid multiple resizing
|
||||||
DynamicList<label> cellDIL(interactingElems.size());
|
DynamicList<label> cellDIL(interactingElems.size());
|
||||||
|
|
||||||
forAll(interactingElems, i)
|
for (const label elemi : interactingElems)
|
||||||
{
|
{
|
||||||
label elemI = interactingElems[i];
|
const label c = allCellsTree.shapes().cellLabels()[elemi];
|
||||||
|
|
||||||
label c = allCellsTree.shapes().cellLabels()[elemI];
|
|
||||||
|
|
||||||
// Here, a more detailed geometric test could be applied,
|
// Here, a more detailed geometric test could be applied,
|
||||||
// i.e. a more accurate bounding volume like a OBB or
|
// i.e. a more accurate bounding volume like a OBB or
|
||||||
@ -634,9 +630,9 @@ void Foam::InteractionLists<ParticleType>::buildInteractionLists()
|
|||||||
|
|
||||||
forAll(interactingElems, i)
|
forAll(interactingElems, i)
|
||||||
{
|
{
|
||||||
label elemI = interactingElems[i];
|
const label elemi = interactingElems[i];
|
||||||
|
|
||||||
label f = wallFacesTree.shapes().faceLabels()[elemI];
|
const label f = wallFacesTree.shapes().faceLabels()[elemi];
|
||||||
|
|
||||||
dwfil_[celli][i] = f;
|
dwfil_[celli][i] = f;
|
||||||
}
|
}
|
||||||
@ -849,10 +845,8 @@ void Foam::InteractionLists<ParticleType>::buildMap
|
|||||||
// 1. Count
|
// 1. Count
|
||||||
labelList nSend(Pstream::nProcs(), Zero);
|
labelList nSend(Pstream::nProcs(), Zero);
|
||||||
|
|
||||||
forAll(toProc, i)
|
for (const label proci : toProc)
|
||||||
{
|
{
|
||||||
label proci = toProc[i];
|
|
||||||
|
|
||||||
nSend[proci]++;
|
nSend[proci]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -896,7 +890,7 @@ void Foam::InteractionLists<ParticleType>::buildMap
|
|||||||
{
|
{
|
||||||
if (proci != Pstream::myProcNo())
|
if (proci != Pstream::myProcNo())
|
||||||
{
|
{
|
||||||
label nRecv = recvSizes[proci];
|
const label nRecv = recvSizes[proci];
|
||||||
|
|
||||||
constructMap[proci].setSize(nRecv);
|
constructMap[proci].setSize(nRecv);
|
||||||
|
|
||||||
@ -991,11 +985,11 @@ void Foam::InteractionLists<ParticleType>::fillReferredParticleCloud()
|
|||||||
const IDLList<ParticleType>& refCell =
|
const IDLList<ParticleType>& refCell =
|
||||||
referredParticles_[refCelli];
|
referredParticles_[refCelli];
|
||||||
|
|
||||||
forAllConstIter(typename IDLList<ParticleType>, refCell, iter)
|
for (const ParticleType& p : refCell)
|
||||||
{
|
{
|
||||||
cloud_.addParticle
|
cloud_.addParticle
|
||||||
(
|
(
|
||||||
static_cast<ParticleType*>(iter().clone().ptr())
|
static_cast<ParticleType*>(p.clone().ptr())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1238,9 +1232,9 @@ void Foam::InteractionLists<ParticleType>::receiveReferredData
|
|||||||
forAll(referredParticles_, refCelli)
|
forAll(referredParticles_, refCelli)
|
||||||
{
|
{
|
||||||
IDLList<ParticleType>& refCell = referredParticles_[refCelli];
|
IDLList<ParticleType>& refCell = referredParticles_[refCelli];
|
||||||
forAllIter(typename IDLList<ParticleType>, refCell, iter)
|
for (ParticleType& p : refCell)
|
||||||
{
|
{
|
||||||
iter().correctAfterInteractionListReferral(ril_[refCelli][0]);
|
p.correctAfterInteractionListReferral(ril_[refCelli][0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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) 2004-2011 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2011, 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
@ -78,13 +78,11 @@ void Foam::solidParticle::readFields(Cloud<solidParticle>& c)
|
|||||||
c.checkFieldIOobject(c, U);
|
c.checkFieldIOobject(c, U);
|
||||||
|
|
||||||
label i = 0;
|
label i = 0;
|
||||||
forAllIter(Cloud<solidParticle>, c, iter)
|
for (solidParticle& p : c)
|
||||||
{
|
{
|
||||||
solidParticle& p = iter();
|
|
||||||
|
|
||||||
p.d_ = d[i];
|
p.d_ = d[i];
|
||||||
p.U_ = U[i];
|
p.U_ = U[i];
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,19 +91,17 @@ void Foam::solidParticle::writeFields(const Cloud<solidParticle>& c)
|
|||||||
{
|
{
|
||||||
particle::writeFields(c);
|
particle::writeFields(c);
|
||||||
|
|
||||||
label np = c.size();
|
const label np = c.size();
|
||||||
|
|
||||||
IOField<scalar> d(c.fieldIOobject("d", IOobject::NO_READ), np);
|
IOField<scalar> d(c.fieldIOobject("d", IOobject::NO_READ), np);
|
||||||
IOField<vector> U(c.fieldIOobject("U", IOobject::NO_READ), np);
|
IOField<vector> U(c.fieldIOobject("U", IOobject::NO_READ), np);
|
||||||
|
|
||||||
label i = 0;
|
label i = 0;
|
||||||
forAllConstIter(Cloud<solidParticle>, c, iter)
|
for (const solidParticle& p : c)
|
||||||
{
|
{
|
||||||
const solidParticle& p = iter();
|
|
||||||
|
|
||||||
d[i] = p.d_;
|
d[i] = p.d_;
|
||||||
U[i] = p.U_;
|
U[i] = p.U_;
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
d.write(np > 0);
|
d.write(np > 0);
|
||||||
|
|||||||
@ -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) 2011-2011 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2011-2011, 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -110,9 +110,8 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
|
|||||||
|
|
||||||
label i = 0;
|
label i = 0;
|
||||||
scalar mSum = 0.0;
|
scalar mSum = 0.0;
|
||||||
forAllConstIter(typename SprayCloud<CloudType>, *this, iter)
|
for (const parcelType& p : *this)
|
||||||
{
|
{
|
||||||
const parcelType& p = iter();
|
|
||||||
scalar m = p.nParticle()*p.mass();
|
scalar m = p.nParticle()*p.mass();
|
||||||
scalar d = mag(p.position() - p.position0());
|
scalar d = mag(p.position() - p.position0());
|
||||||
mSum += m;
|
mSum += m;
|
||||||
@ -120,7 +119,7 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
|
|||||||
mass[i] = m;
|
mass[i] = m;
|
||||||
dist[i] = d;
|
dist[i] = d;
|
||||||
|
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate total mass across all processors
|
// calculate total mass across all processors
|
||||||
|
|||||||
@ -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) 2011-2011, 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2011-2011, 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
@ -200,9 +200,8 @@ void Foam::SprayParcel<ParcelType>::readFields
|
|||||||
c.checkFieldIOobject(c, user);
|
c.checkFieldIOobject(c, user);
|
||||||
|
|
||||||
label i = 0;
|
label i = 0;
|
||||||
forAllIter(typename Cloud<SprayParcel<ParcelType>>, c, iter)
|
for (SprayParcel<ParcelType>& p : c)
|
||||||
{
|
{
|
||||||
SprayParcel<ParcelType>& p = iter();
|
|
||||||
p.d0_ = d0[i];
|
p.d0_ = d0[i];
|
||||||
p.position0_ = position0[i];
|
p.position0_ = position0[i];
|
||||||
p.sigma_ = sigma[i];
|
p.sigma_ = sigma[i];
|
||||||
@ -216,7 +215,7 @@ void Foam::SprayParcel<ParcelType>::readFields
|
|||||||
p.injector_ = injector[i];
|
p.injector_ = injector[i];
|
||||||
p.tMom_ = tMom[i];
|
p.tMom_ = tMom[i];
|
||||||
p.user_ = user[i];
|
p.user_ = user[i];
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,9 +267,8 @@ void Foam::SprayParcel<ParcelType>::writeFields
|
|||||||
IOField<scalar> user(c.fieldIOobject("user", IOobject::NO_READ), np);
|
IOField<scalar> user(c.fieldIOobject("user", IOobject::NO_READ), np);
|
||||||
|
|
||||||
label i = 0;
|
label i = 0;
|
||||||
forAllConstIter(typename Cloud<SprayParcel<ParcelType>>, c, iter)
|
for (const SprayParcel<ParcelType>& p : c)
|
||||||
{
|
{
|
||||||
const SprayParcel<ParcelType>& p = iter();
|
|
||||||
d0[i] = p.d0_;
|
d0[i] = p.d0_;
|
||||||
position0[i] = p.position0_;
|
position0[i] = p.position0_;
|
||||||
sigma[i] = p.sigma_;
|
sigma[i] = p.sigma_;
|
||||||
@ -284,7 +282,7 @@ void Foam::SprayParcel<ParcelType>::writeFields
|
|||||||
injector[i] = p.injector_;
|
injector[i] = p.injector_;
|
||||||
tMom[i] = p.tMom_;
|
tMom[i] = p.tMom_;
|
||||||
user[i] = p.user_;
|
user[i] = p.user_;
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool valid = np > 0;
|
const bool valid = np > 0;
|
||||||
@ -354,9 +352,8 @@ void Foam::SprayParcel<ParcelType>::writeObjects
|
|||||||
IOField<scalar>& user(cloud::createIOField<scalar>("user", np, obr));
|
IOField<scalar>& user(cloud::createIOField<scalar>("user", np, obr));
|
||||||
|
|
||||||
label i = 0;
|
label i = 0;
|
||||||
forAllConstIter(typename Cloud<SprayParcel<ParcelType>>, c, iter)
|
for (const SprayParcel<ParcelType>& p : c)
|
||||||
{
|
{
|
||||||
const SprayParcel<ParcelType>& p = iter();
|
|
||||||
d0[i] = p.d0_;
|
d0[i] = p.d0_;
|
||||||
position0[i] = p.position0_;
|
position0[i] = p.position0_;
|
||||||
sigma[i] = p.sigma_;
|
sigma[i] = p.sigma_;
|
||||||
@ -370,7 +367,7 @@ void Foam::SprayParcel<ParcelType>::writeObjects
|
|||||||
injector[i] = p.injector_;
|
injector[i] = p.injector_;
|
||||||
tMom[i] = p.tMom_;
|
tMom[i] = p.tMom_;
|
||||||
user[i] = p.user_;
|
user[i] = p.user_;
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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) 2009-2011 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2009-2011, 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
@ -43,9 +43,9 @@ void Foam::ORourkeCollision<CloudType>::collide
|
|||||||
{
|
{
|
||||||
// Create the occupancy list for the cells
|
// Create the occupancy list for the cells
|
||||||
labelList occupancy(this->owner().mesh().nCells(), Zero);
|
labelList occupancy(this->owner().mesh().nCells(), Zero);
|
||||||
forAllIter(typename CloudType, this->owner(), iter)
|
for (const parcelType& p : this->owner())
|
||||||
{
|
{
|
||||||
occupancy[iter().cell()]++;
|
occupancy[p.cell()]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the sizes of the lists of parcels in each cell
|
// Initialize the sizes of the lists of parcels in each cell
|
||||||
@ -55,9 +55,9 @@ void Foam::ORourkeCollision<CloudType>::collide
|
|||||||
occupancy = 0;
|
occupancy = 0;
|
||||||
|
|
||||||
// Set the parcel pointer lists for each cell
|
// Set the parcel pointer lists for each cell
|
||||||
forAllIter(typename CloudType, this->owner(), iter)
|
for (parcelType& p : this->owner())
|
||||||
{
|
{
|
||||||
pInCell(iter().cell(), occupancy[iter().cell()]++) = &iter();
|
pInCell(p.cell(), occupancy[p.cell()]++) = &p;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (label celli=0; celli<this->owner().mesh().nCells(); celli++)
|
for (label celli=0; celli<this->owner().mesh().nCells(); celli++)
|
||||||
@ -108,9 +108,8 @@ void Foam::ORourkeCollision<CloudType>::collide
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove coalesced parcels that fall below minimum mass threshold
|
// Remove coalesced parcels that fall below minimum mass threshold
|
||||||
forAllIter(typename CloudType, this->owner(), iter)
|
for (parcelType& p : this->owner())
|
||||||
{
|
{
|
||||||
parcelType& p = iter();
|
|
||||||
scalar mass = p.nParticle()*p.mass();
|
scalar mass = p.nParticle()*p.mass();
|
||||||
|
|
||||||
if (mass < this->owner().constProps().minParcelMass())
|
if (mass < this->owner().constProps().minParcelMass())
|
||||||
|
|||||||
Reference in New Issue
Block a user