ENH: for-range, forAllIters() ... in lagrangian/intermediate/

- reduced clutter when iterating over containers
This commit is contained in:
Mark Olesen
2019-01-07 09:20:51 +01:00
parent 0fadde13ff
commit c508da8f37
23 changed files with 147 additions and 309 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) 2008-2011 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011, 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -65,10 +65,8 @@ Foam::CollidingCloud<CloudType>::rotationalKineticEnergyOfSystem() const
{ {
scalar rotationalKineticEnergy = 0.0; scalar rotationalKineticEnergy = 0.0;
forAllConstIter(typename CollidingCloud<CloudType>, *this, iter) for (const parcelType& p : *this)
{ {
const parcelType& p = iter();
rotationalKineticEnergy += rotationalKineticEnergy +=
p.nParticle()*0.5*p.momentOfInertia()*(p.omega() & p.omega()); p.nParticle()*0.5*p.momentOfInertia()*(p.omega() & p.omega());
} }

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) 2008-2011, 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011, 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -155,14 +155,14 @@ void Foam::KinematicCloud<CloudType>::buildCellOccupancy()
List<DynamicList<parcelType*>>& cellOccupancy = cellOccupancyPtr_(); List<DynamicList<parcelType*>>& cellOccupancy = cellOccupancyPtr_();
forAll(cellOccupancy, cO) for (auto& list : cellOccupancy)
{ {
cellOccupancy[cO].clear(); list.clear();
} }
forAllIter(typename KinematicCloud<CloudType>, *this, iter) for (parcelType& p : *this)
{ {
cellOccupancy[iter().cell()].append(&iter()); cellOccupancy[p.cell()].append(&p);
} }
} }

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) 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
@ -273,10 +273,9 @@ template<class CloudType>
inline Foam::scalar Foam::KinematicCloud<CloudType>::massInSystem() const inline Foam::scalar Foam::KinematicCloud<CloudType>::massInSystem() const
{ {
scalar sysMass = 0.0; scalar sysMass = 0.0;
forAllConstIter(typename KinematicCloud<CloudType>, *this, iter) for (const parcelType& p : *this)
{ {
const parcelType& p = iter(); sysMass += p.nParticle()*p.mass();
sysMass += p.nParticle()*p.mass();
} }
return sysMass; return sysMass;
@ -289,10 +288,8 @@ Foam::KinematicCloud<CloudType>::linearMomentumOfSystem() const
{ {
vector linearMomentum(Zero); vector linearMomentum(Zero);
forAllConstIter(typename KinematicCloud<CloudType>, *this, iter) for (const parcelType& p : *this)
{ {
const parcelType& p = iter();
linearMomentum += p.nParticle()*p.mass()*p.U(); linearMomentum += p.nParticle()*p.mass()*p.U();
} }
@ -306,10 +303,8 @@ Foam::KinematicCloud<CloudType>::linearKineticEnergyOfSystem() const
{ {
scalar linearKineticEnergy = 0.0; scalar linearKineticEnergy = 0.0;
forAllConstIter(typename KinematicCloud<CloudType>, *this, iter) for (const parcelType& p : *this)
{ {
const parcelType& p = iter();
linearKineticEnergy += p.nParticle()*0.5*p.mass()*(p.U() & p.U()); linearKineticEnergy += p.nParticle()*0.5*p.mass()*(p.U() & p.U());
} }
@ -326,9 +321,8 @@ inline Foam::scalar Foam::KinematicCloud<CloudType>::Dij
{ {
scalar si = 0.0; scalar si = 0.0;
scalar sj = 0.0; scalar sj = 0.0;
forAllConstIter(typename KinematicCloud<CloudType>, *this, iter) for (const parcelType& p : *this)
{ {
const parcelType& p = iter();
si += p.nParticle()*pow(p.d(), i); si += p.nParticle()*pow(p.d(), i);
sj += p.nParticle()*pow(p.d(), j); sj += p.nParticle()*pow(p.d(), j);
} }
@ -345,9 +339,8 @@ template<class CloudType>
inline Foam::scalar Foam::KinematicCloud<CloudType>::Dmax() const inline Foam::scalar Foam::KinematicCloud<CloudType>::Dmax() const
{ {
scalar d = -GREAT; scalar d = -GREAT;
forAllConstIter(typename KinematicCloud<CloudType>, *this, iter) for (const parcelType& p : *this)
{ {
const parcelType& p = iter();
d = max(d, p.d()); d = max(d, p.d());
} }
@ -477,9 +470,8 @@ Foam::KinematicCloud<CloudType>::vDotSweep() const
); );
volScalarField& vDotSweep = tvDotSweep.ref(); volScalarField& vDotSweep = tvDotSweep.ref();
forAllConstIter(typename KinematicCloud<CloudType>, *this, iter) for (const parcelType& p : *this)
{ {
const parcelType& p = iter();
const label celli = p.cell(); const label celli = p.cell();
vDotSweep[celli] += p.nParticle()*p.areaP()*mag(p.U() - U_[celli]); vDotSweep[celli] += p.nParticle()*p.areaP()*mag(p.U() - U_[celli]);
@ -516,9 +508,8 @@ Foam::KinematicCloud<CloudType>::theta() const
); );
volScalarField& theta = ttheta.ref(); volScalarField& theta = ttheta.ref();
forAllConstIter(typename KinematicCloud<CloudType>, *this, iter) for (const parcelType& p : *this)
{ {
const parcelType& p = iter();
const label celli = p.cell(); const label celli = p.cell();
theta[celli] += p.nParticle()*p.volume(); theta[celli] += p.nParticle()*p.volume();
@ -554,9 +545,8 @@ Foam::KinematicCloud<CloudType>::alpha() const
); );
scalarField& alpha = talpha.ref().primitiveFieldRef(); scalarField& alpha = talpha.ref().primitiveFieldRef();
forAllConstIter(typename KinematicCloud<CloudType>, *this, iter) for (const parcelType& p : *this)
{ {
const parcelType& p = iter();
const label celli = p.cell(); const label celli = p.cell();
alpha[celli] += p.nParticle()*p.mass(); alpha[celli] += p.nParticle()*p.mass();
@ -591,9 +581,8 @@ Foam::KinematicCloud<CloudType>::rhoEff() const
); );
scalarField& rhoEff = trhoEff.ref().primitiveFieldRef(); scalarField& rhoEff = trhoEff.ref().primitiveFieldRef();
forAllConstIter(typename KinematicCloud<CloudType>, *this, iter) for (const parcelType& p : *this)
{ {
const parcelType& p = iter();
const label celli = p.cell(); const label celli = p.cell();
rhoEff[celli] += p.nParticle()*p.mass(); rhoEff[celli] += p.nParticle()*p.mass();

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) 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
@ -374,48 +374,42 @@ Foam::ThermoCloud<CloudType>::sigmap() const
template<class CloudType> template<class CloudType>
inline Foam::scalar Foam::ThermoCloud<CloudType>::Tmax() const inline Foam::scalar Foam::ThermoCloud<CloudType>::Tmax() const
{ {
scalar T = -GREAT; scalar val = -GREAT;
scalar n = 0; bool nonEmpty = false;
forAllConstIter(typename ThermoCloud<CloudType>, *this, iter)
for (const parcelType& p : *this)
{ {
const parcelType& p = iter(); val = max(val, p.T());
T = max(T, p.T()); nonEmpty = true;
n++;
} }
reduce(T, maxOp<scalar>()); if (returnReduce(nonEmpty, orOp<bool>()))
reduce(n, sumOp<label>());
if (n > 0)
{ {
return T; return returnReduce(val, maxOp<scalar>());
} }
return 0.0; return 0;
} }
template<class CloudType> template<class CloudType>
inline Foam::scalar Foam::ThermoCloud<CloudType>::Tmin() const inline Foam::scalar Foam::ThermoCloud<CloudType>::Tmin() const
{ {
scalar T = GREAT; scalar val = GREAT;
scalar n = 0; bool nonEmpty = false;
forAllConstIter(typename ThermoCloud<CloudType>, *this, iter)
for (const parcelType& p : *this)
{ {
const parcelType& p = iter(); val = min(val, p.T());
T = min(T, p.T()); nonEmpty = true;
n++;
} }
reduce(T, minOp<scalar>()); if (returnReduce(nonEmpty, orOp<bool>()))
reduce(n, sumOp<label>());
if (n > 0)
{ {
return T; return returnReduce(val, minOp<scalar>());
} }
return 0.0; return 0;
} }

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) 2011-2011 OpenCFD Ltd. \\ / A nd | Copyright (C) 2011-2011, 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -164,10 +164,8 @@ void Foam::CollidingParcel<ParcelType>::readFields(CloudType& c)
label i = 0; label i = 0;
forAllIter(typename CloudType, c, iter) for (CollidingParcel<ParcelType>& p : c)
{ {
CollidingParcel<ParcelType>& p = iter();
p.f_ = f[i]; p.f_ = f[i];
p.angularMomentum_ = angularMomentum[i]; p.angularMomentum_ = angularMomentum[i];
p.torque_ = torque[i]; p.torque_ = torque[i];
@ -183,7 +181,7 @@ void Foam::CollidingParcel<ParcelType>::readFields(CloudType& c)
collisionRecordsWallData[i] collisionRecordsWallData[i]
); );
i++; ++i;
} }
} }
@ -245,11 +243,8 @@ void Foam::CollidingParcel<ParcelType>::writeFields(const CloudType& c)
); );
label i = 0; label i = 0;
for (const CollidingParcel<ParcelType>& p : c)
forAllConstIter(typename CloudType, c, iter)
{ {
const CollidingParcel<ParcelType>& p = iter();
f[i] = p.f(); f[i] = p.f();
angularMomentum[i] = p.angularMomentum(); angularMomentum[i] = p.angularMomentum();
torque[i] = p.torque(); torque[i] = p.torque();
@ -264,7 +259,7 @@ void Foam::CollidingParcel<ParcelType>::writeFields(const CloudType& c)
collisionRecordsWallPRel[i] = p.collisionRecords().wallPRel(); collisionRecordsWallPRel[i] = p.collisionRecords().wallPRel();
collisionRecordsWallData[i] = p.collisionRecords().wallData(); collisionRecordsWallData[i] = p.collisionRecords().wallData();
i++; ++i;
} }
const bool valid = (np > 0); const bool valid = (np > 0);
@ -303,15 +298,13 @@ void Foam::CollidingParcel<ParcelType>::writeObjects
IOField<vector>& torque(cloud::createIOField<vector>("torque", np, obr)); IOField<vector>& torque(cloud::createIOField<vector>("torque", np, obr));
label i = 0; label i = 0;
forAllConstIter(typename CloudType, c, iter) for (const CollidingParcel<ParcelType>& p : c)
{ {
const CollidingParcel<ParcelType>& p = iter();
f[i] = p.f(); f[i] = p.f();
angularMomentum[i] = p.angularMomentum(); angularMomentum[i] = p.angularMomentum();
torque[i] = p.torque(); torque[i] = p.torque();
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 | Copyright (C) 2008-2011, 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011, 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -176,10 +176,8 @@ void Foam::KinematicParcel<ParcelType>::readFields(CloudType& c)
label i = 0; label i = 0;
forAllIter(typename CloudType, c, iter) for (KinematicParcel<ParcelType>& p : c)
{ {
KinematicParcel<ParcelType>& p = iter();
p.active_ = active[i]; p.active_ = active[i];
p.typeId_ = typeId[i]; p.typeId_ = typeId[i];
p.nParticle_ = nParticle[i]; p.nParticle_ = nParticle[i];
@ -191,7 +189,7 @@ void Foam::KinematicParcel<ParcelType>::readFields(CloudType& c)
p.tTurb_ = tTurb[i]; p.tTurb_ = tTurb[i];
p.UTurb_ = UTurb[i]; p.UTurb_ = UTurb[i];
i++; ++i;
} }
} }
@ -221,10 +219,8 @@ void Foam::KinematicParcel<ParcelType>::writeFields(const CloudType& c)
label i = 0; label i = 0;
forAllConstIter(typename CloudType, c, iter) for (const KinematicParcel<ParcelType>& p : c)
{ {
const KinematicParcel<ParcelType>& p = iter();
active[i] = p.active(); active[i] = p.active();
typeId[i] = p.typeId(); typeId[i] = p.typeId();
nParticle[i] = p.nParticle(); nParticle[i] = p.nParticle();
@ -236,7 +232,7 @@ void Foam::KinematicParcel<ParcelType>::writeFields(const CloudType& c)
tTurb[i] = p.tTurb(); tTurb[i] = p.tTurb();
UTurb[i] = p.UTurb(); UTurb[i] = p.UTurb();
i++; ++i;
} }
const bool valid = np > 0; const bool valid = np > 0;
@ -282,10 +278,8 @@ void Foam::KinematicParcel<ParcelType>::writeObjects
label i = 0; label i = 0;
forAllConstIter(typename CloudType, c, iter) for (const KinematicParcel<ParcelType>& p : c)
{ {
const KinematicParcel<ParcelType>& p = iter();
active[i] = p.active(); active[i] = p.active();
typeId[i] = p.typeId(); typeId[i] = p.typeId();
nParticle[i] = p.nParticle(); nParticle[i] = p.nParticle();
@ -297,7 +291,7 @@ void Foam::KinematicParcel<ParcelType>::writeObjects
tTurb[i] = p.tTurb(); tTurb[i] = p.tTurb();
UTurb[i] = p.UTurb(); UTurb[i] = p.UTurb();
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 | Copyright (C) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2013-2017 OpenFOAM Foundation | Copyright (C) 2013-2017 OpenFOAM Foundation
@ -92,14 +92,11 @@ void Foam::MPPICParcel<ParcelType>::readFields(CloudType& c)
c.checkFieldIOobject(c, UCorrect); c.checkFieldIOobject(c, UCorrect);
label i = 0; label i = 0;
for (MPPICParcel<ParcelType>& p : c)
forAllIter(typename CloudType, c, iter)
{ {
MPPICParcel<ParcelType>& p = iter();
p.UCorrect_ = UCorrect[i]; p.UCorrect_ = UCorrect[i];
i++; ++i;
} }
} }
@ -117,13 +114,11 @@ void Foam::MPPICParcel<ParcelType>::writeFields(const CloudType& c)
label i = 0; label i = 0;
forAllConstIter(typename CloudType, c, iter) for (const MPPICParcel<ParcelType>& p : c)
{ {
const MPPICParcel<ParcelType>& p = iter();
UCorrect[i] = p.UCorrect(); UCorrect[i] = p.UCorrect();
i++; ++i;
} }
UCorrect.write(np > 0); UCorrect.write(np > 0);
@ -147,13 +142,11 @@ void Foam::MPPICParcel<ParcelType>::writeObjects
label i = 0; label i = 0;
forAllConstIter(typename CloudType, c, iter) for (const MPPICParcel<ParcelType>& p : c)
{ {
const MPPICParcel<ParcelType>& p = iter();
UCorrect[i] = p.UCorrect(); UCorrect[i] = p.UCorrect();
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) 2013-2017 OpenFOAM Foundation | Copyright (C) 2013-2017 OpenFOAM Foundation
@ -174,9 +174,8 @@ inline void Foam::MPPICParcel<ParcelType>::trackingData::updateAverages
AveragingMethod<scalar>& weightAverage = weightAveragePtr(); AveragingMethod<scalar>& weightAverage = weightAveragePtr();
// averaging sums // averaging sums
forAllConstIter(typename TrackCloudType, cloud, iter) for (const typename TrackCloudType::parcelType& p : cloud)
{ {
const typename TrackCloudType::parcelType& p = iter();
const tetIndices tetIs = p.currentTetIndices(); const tetIndices tetIs = p.currentTetIndices();
const scalar m = p.nParticle()*p.mass(); const scalar m = p.nParticle()*p.mass();
@ -192,9 +191,8 @@ inline void Foam::MPPICParcel<ParcelType>::trackingData::updateAverages
uAverage_->average(*massAverage_); uAverage_->average(*massAverage_);
// squared velocity deviation // squared velocity deviation
forAllConstIter(typename TrackCloudType, cloud, iter) for (const typename TrackCloudType::parcelType& p : cloud)
{ {
const typename TrackCloudType::parcelType& p = iter();
const tetIndices tetIs = p.currentTetIndices(); const tetIndices tetIs = p.currentTetIndices();
const vector u = uAverage_->interpolate(p.coordinates(), tetIs); const vector u = uAverage_->interpolate(p.coordinates(), tetIs);
@ -211,9 +209,8 @@ inline void Foam::MPPICParcel<ParcelType>::trackingData::updateAverages
// sauter mean radius // sauter mean radius
radiusAverage_() = volumeAverage_(); radiusAverage_() = volumeAverage_();
weightAverage = 0; weightAverage = 0;
forAllConstIter(typename TrackCloudType, cloud, iter) for (const typename TrackCloudType::parcelType& p : cloud)
{ {
const typename TrackCloudType::parcelType& p = iter();
const tetIndices tetIs = p.currentTetIndices(); const tetIndices tetIs = p.currentTetIndices();
weightAverage.add weightAverage.add
@ -228,9 +225,8 @@ inline void Foam::MPPICParcel<ParcelType>::trackingData::updateAverages
// collision frequency // collision frequency
weightAverage = 0; weightAverage = 0;
forAllConstIter(typename TrackCloudType, cloud, iter) for (const typename TrackCloudType::parcelType& p : cloud)
{ {
const typename TrackCloudType::parcelType& p = iter();
const tetIndices tetIs = p.currentTetIndices(); const tetIndices tetIs = p.currentTetIndices();
const scalar a = volumeAverage_->interpolate(p.coordinates(), tetIs); const scalar a = volumeAverage_->interpolate(p.coordinates(), tetIs);

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) 2008-2011, 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011, 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -115,9 +115,8 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::readFields
const wordList& stateLabels = compModel.stateLabels(); const wordList& stateLabels = compModel.stateLabels();
// Set storage for each Y... for each parcel // Set storage for each Y... for each parcel
forAllIter(typename Cloud<ReactingMultiphaseParcel<ParcelType>>, c, iter) for (ReactingMultiphaseParcel<ParcelType>& p : c)
{ {
ReactingMultiphaseParcel<ParcelType>& p = iter();
p.YGas_.setSize(gasNames.size(), 0.0); p.YGas_.setSize(gasNames.size(), 0.0);
p.YLiquid_.setSize(liquidNames.size(), 0.0); p.YLiquid_.setSize(liquidNames.size(), 0.0);
p.YSolid_.setSize(solidNames.size(), 0.0); p.YSolid_.setSize(solidNames.size(), 0.0);
@ -137,14 +136,8 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::readFields
); );
label i = 0; label i = 0;
forAllIter for (ReactingMultiphaseParcel<ParcelType>& p : c)
(
typename Cloud<ReactingMultiphaseParcel<ParcelType>>,
c,
iter
)
{ {
ReactingMultiphaseParcel<ParcelType>& p = iter();
p.YGas_[j] = YGas[i++]/(p.Y()[GAS] + ROOTVSMALL); p.YGas_[j] = YGas[i++]/(p.Y()[GAS] + ROOTVSMALL);
} }
} }
@ -162,14 +155,8 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::readFields
); );
label i = 0; label i = 0;
forAllIter for (ReactingMultiphaseParcel<ParcelType>& p : c)
(
typename Cloud<ReactingMultiphaseParcel<ParcelType>>,
c,
iter
)
{ {
ReactingMultiphaseParcel<ParcelType>& p = iter();
p.YLiquid_[j] = YLiquid[i++]/(p.Y()[LIQ] + ROOTVSMALL); p.YLiquid_[j] = YLiquid[i++]/(p.Y()[LIQ] + ROOTVSMALL);
} }
} }
@ -187,14 +174,8 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::readFields
); );
label i = 0; label i = 0;
forAllIter for (ReactingMultiphaseParcel<ParcelType>& p : c)
(
typename Cloud<ReactingMultiphaseParcel<ParcelType>>,
c,
iter
)
{ {
ReactingMultiphaseParcel<ParcelType>& p = iter();
p.YSolid_[j] = YSolid[i++]/(p.Y()[SLD] + ROOTVSMALL); p.YSolid_[j] = YSolid[i++]/(p.Y()[SLD] + ROOTVSMALL);
} }
} }
@ -240,14 +221,8 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::writeFields
); );
label i = 0; label i = 0;
forAllConstIter for (const ReactingMultiphaseParcel<ParcelType>& p0 : c)
(
typename Cloud<ReactingMultiphaseParcel<ParcelType>>,
c,
iter
)
{ {
const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
YGas[i++] = p0.YGas()[j]*p0.Y()[GAS]; YGas[i++] = p0.YGas()[j]*p0.Y()[GAS];
} }
@ -269,14 +244,8 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::writeFields
); );
label i = 0; label i = 0;
forAllConstIter for (const ReactingMultiphaseParcel<ParcelType>& p0 : c)
(
typename Cloud<ReactingMultiphaseParcel<ParcelType>>,
c,
iter
)
{ {
const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
YLiquid[i++] = p0.YLiquid()[j]*p0.Y()[LIQ]; YLiquid[i++] = p0.YLiquid()[j]*p0.Y()[LIQ];
} }
@ -298,14 +267,8 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::writeFields
); );
label i = 0; label i = 0;
forAllConstIter for (const ReactingMultiphaseParcel<ParcelType>& p0 : c)
(
typename Cloud<ReactingMultiphaseParcel<ParcelType>>,
c,
iter
)
{ {
const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
YSolid[i++] = p0.YSolid()[j]*p0.Y()[SLD]; YSolid[i++] = p0.YSolid()[j]*p0.Y()[SLD];
} }
@ -356,14 +319,8 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::writeObjects
); );
label i = 0; label i = 0;
forAllConstIter for (const ReactingMultiphaseParcel<ParcelType>& p0 : c)
(
typename Cloud<ReactingMultiphaseParcel<ParcelType>>,
c,
iter
)
{ {
const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
YGas[i++] = p0.YGas()[j]*p0.Y()[GAS]; YGas[i++] = p0.YGas()[j]*p0.Y()[GAS];
} }
} }
@ -379,14 +336,8 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::writeObjects
); );
label i = 0; label i = 0;
forAllConstIter for (const ReactingMultiphaseParcel<ParcelType>& p0 : c)
(
typename Cloud<ReactingMultiphaseParcel<ParcelType>>,
c,
iter
)
{ {
const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
YLiquid[i++] = p0.YLiquid()[j]*p0.Y()[LIQ]; YLiquid[i++] = p0.YLiquid()[j]*p0.Y()[LIQ];
} }
} }
@ -402,14 +353,8 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::writeObjects
); );
label i = 0; label i = 0;
forAllConstIter for (const ReactingMultiphaseParcel<ParcelType>& p0 : c)
(
typename Cloud<ReactingMultiphaseParcel<ParcelType>>,
c,
iter
)
{ {
const ReactingMultiphaseParcel<ParcelType>& p0 = iter();
YSolid[i++] = p0.YSolid()[j]*p0.Y()[SLD]; YSolid[i++] = p0.YSolid()[j]*p0.Y()[SLD];
} }
} }

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) 2008-2011, 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011, 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -109,10 +109,11 @@ void Foam::ReactingParcel<ParcelType>::readFields
c.checkFieldIOobject(c, mass0); c.checkFieldIOobject(c, mass0);
label i = 0; label i = 0;
forAllIter(typename Cloud<ReactingParcel<ParcelType>>, c, iter) for (ReactingParcel<ParcelType>& p : c)
{ {
ReactingParcel<ParcelType>& p = iter(); p.mass0_ = mass0[i];
p.mass0_ = mass0[i++];
++i;
} }
// Get names and sizes for each Y... // Get names and sizes for each Y...
@ -126,9 +127,8 @@ void Foam::ReactingParcel<ParcelType>::readFields
// Set storage for each Y... for each parcel // Set storage for each Y... for each parcel
forAllIter(typename Cloud<ReactingParcel<ParcelType>>, c, iter) for (ReactingParcel<ParcelType>& p : c)
{ {
ReactingParcel<ParcelType>& p = iter();
p.Y_.setSize(nPhases, 0.0); p.Y_.setSize(nPhases, 0.0);
} }
@ -146,10 +146,11 @@ void Foam::ReactingParcel<ParcelType>::readFields
); );
label i = 0; label i = 0;
forAllIter(typename Cloud<ReactingParcel<ParcelType>>, c, iter) for (ReactingParcel<ParcelType>& p : c)
{ {
ReactingParcel<ParcelType>& p = iter(); p.Y_[j] = Y[i];
p.Y_[j] = Y[i++];
++i;
} }
} }
} }
@ -179,10 +180,11 @@ void Foam::ReactingParcel<ParcelType>::writeFields
IOField<scalar> mass0(c.fieldIOobject("mass0", IOobject::NO_READ), np); IOField<scalar> mass0(c.fieldIOobject("mass0", IOobject::NO_READ), np);
label i = 0; label i = 0;
forAllConstIter(typename Cloud<ReactingParcel<ParcelType>>, c, iter) for (const ReactingParcel<ParcelType>& p : c)
{ {
const ReactingParcel<ParcelType>& p = iter();
mass0[i++] = p.mass0_; mass0[i++] = p.mass0_;
++i;
} }
mass0.write(np > 0); mass0.write(np > 0);
@ -205,16 +207,13 @@ void Foam::ReactingParcel<ParcelType>::writeFields
), ),
np np
); );
label i = 0; label i = 0;
forAllConstIter for (const ReactingParcel<ParcelType>& p : c)
(
typename Cloud<ReactingParcel<ParcelType>>,
c,
iter
)
{ {
const ReactingParcel<ParcelType>& p = iter(); Y[i] = p.Y()[j];
Y[i++] = p.Y()[j];
++i;
} }
Y.write(np > 0); Y.write(np > 0);
@ -253,10 +252,11 @@ void Foam::ReactingParcel<ParcelType>::writeObjects
IOField<scalar>& mass0(cloud::createIOField<scalar>("mass0", np, obr)); IOField<scalar>& mass0(cloud::createIOField<scalar>("mass0", np, obr));
label i = 0; label i = 0;
forAllConstIter(typename Cloud<ReactingParcel<ParcelType>>, c, iter) for (const ReactingParcel<ParcelType>& p : c)
{ {
const ReactingParcel<ParcelType>& p = iter(); mass0[i] = p.mass0_;
mass0[i++] = p.mass0_;
++i;
} }
// Write the composition fractions // Write the composition fractions
@ -276,15 +276,11 @@ void Foam::ReactingParcel<ParcelType>::writeObjects
); );
label i = 0; label i = 0;
forAllConstIter for (const ReactingParcel<ParcelType>& p : c)
(
typename Cloud<ReactingParcel<ParcelType>>,
c,
iter
)
{ {
const ReactingParcel<ParcelType>& p = iter(); Y[i] = p.Y()[j];
Y[i++] = p.Y()[j];
++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 | Copyright (C) 2008-2011, 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011, 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -94,13 +94,11 @@ void Foam::ThermoParcel<ParcelType>::readFields(CloudType& c)
label i = 0; label i = 0;
forAllIter(typename Cloud<ThermoParcel<ParcelType>>, c, iter) for (ThermoParcel<ParcelType>& p : c)
{ {
ThermoParcel<ParcelType>& p = iter();
p.T_ = T[i]; p.T_ = T[i];
p.Cp_ = Cp[i]; p.Cp_ = Cp[i];
i++; ++i;
} }
} }
@ -117,13 +115,11 @@ void Foam::ThermoParcel<ParcelType>::writeFields(const CloudType& c)
IOField<scalar> Cp(c.fieldIOobject("Cp", IOobject::NO_READ), np); IOField<scalar> Cp(c.fieldIOobject("Cp", IOobject::NO_READ), np);
label i = 0; label i = 0;
forAllConstIter(typename Cloud<ThermoParcel<ParcelType>>, c, iter) for (const ThermoParcel<ParcelType>& p : c)
{ {
const ThermoParcel<ParcelType>& p = iter();
T[i] = p.T_; T[i] = p.T_;
Cp[i] = p.Cp_; Cp[i] = p.Cp_;
i++; ++i;
} }
T.write(np > 0); T.write(np > 0);
@ -147,13 +143,11 @@ void Foam::ThermoParcel<ParcelType>::writeObjects
IOField<scalar>& Cp(cloud::createIOField<scalar>("Cp", np, obr)); IOField<scalar>& Cp(cloud::createIOField<scalar>("Cp", np, obr));
label i = 0; label i = 0;
forAllConstIter(typename Cloud<ThermoParcel<ParcelType>>, c, iter) for (const ThermoParcel<ParcelType>& p : c)
{ {
const ThermoParcel<ParcelType>& p = iter();
T[i] = p.T_; T[i] = p.T_;
Cp[i] = p.Cp_; Cp[i] = p.Cp_;
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 | Copyright (C) 2010-2011 OpenCFD Ltd. \\ / A nd | Copyright (C) 2010-2011, 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -46,10 +46,7 @@ void Foam::ParticleTracks<CloudType>::write()
} }
else else
{ {
if (debug) DebugInFunction << "invalid cloud pointer" << endl;
{
InfoInFunction << "cloupPtr invalid" << endl;
}
} }
} }
@ -125,23 +122,12 @@ void Foam::ParticleTracks<CloudType>::postFace(const parcelType& p, bool&)
<< "Cloud storage not allocated" << abort(FatalError); << "Cloud storage not allocated" << abort(FatalError);
} }
labelPairLookup::iterator iter = const label count =
faceHitCounter_.find(labelPair(p.origProc(), p.origId())); ++(faceHitCounter_(labelPair(p.origProc(), p.origId()), 0));
label localI = -1; const label nSamples = floor(count/trackInterval_);
if (iter != faceHitCounter_.end())
{
iter()++;
localI = iter();
}
else
{
localI = 1;
faceHitCounter_.insert(labelPair(p.origProc(), p.origId()), localI);
}
label nSamples = floor(localI/trackInterval_); if ((count % trackInterval_) == 0 && nSamples < maxSamples_)
if ((localI % trackInterval_ == 0) && (nSamples < maxSamples_))
{ {
cloudPtr_->append cloudPtr_->append
( (

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) 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
@ -45,10 +45,8 @@ template<class CloudType>
void Foam::PairCollision<CloudType>::preInteraction() void Foam::PairCollision<CloudType>::preInteraction()
{ {
// Set accumulated quantities to zero // Set accumulated quantities to zero
forAllIter(typename CloudType, this->owner(), iter) for (typename CloudType::parcelType& p : this->owner())
{ {
typename CloudType::parcelType& p = iter();
p.f() = Zero; p.f() = Zero;
p.torque() = Zero; p.torque() = Zero;
@ -145,11 +143,10 @@ void Foam::PairCollision<CloudType>::realReferredInteraction()
// Loop over all referred parcels in the referred cell // Loop over all referred parcels in the referred cell
forAllIter for
( (
typename IDLList<typename CloudType::parcelType>, typename CloudType::parcelType& referredParcel
refCellRefParticles, : refCellRefParticles
referredParcel
) )
{ {
// Loop over all real cells in that the referred cell is // Loop over all real cells in that the referred cell is
@ -165,7 +162,7 @@ void Foam::PairCollision<CloudType>::realReferredInteraction()
evaluatePair evaluatePair
( (
*realCellParcels[realParcelI], *realCellParcels[realParcelI],
referredParcel() referredParcel
); );
} }
} }
@ -481,10 +478,8 @@ void Foam::PairCollision<CloudType>::postInteraction()
{ {
// Delete any collision records where no collision occurred this step // Delete any collision records where no collision occurred this step
forAllIter(typename CloudType, this->owner(), iter) for (typename CloudType::parcelType& p : this->owner())
{ {
typename CloudType::parcelType& p = iter();
p.collisionRecords().update(); p.collisionRecords().update();
} }
} }

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) 2008-2011, 2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011, 2018-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -41,10 +41,8 @@ void Foam::PairSpringSliderDashpot<CloudType>::findMinMaxProperties
rhoMax = -VGREAT; rhoMax = -VGREAT;
UMagMax = -VGREAT; UMagMax = -VGREAT;
forAllConstIter(typename CloudType, this->owner(), iter) for (const typename CloudType::parcelType& p : this->owner())
{ {
const typename CloudType::parcelType& p = iter();
// Finding minimum diameter to avoid excessive arithmetic // Finding minimum diameter to avoid excessive arithmetic
scalar dEff = p.d(); scalar dEff = p.d();
@ -125,13 +123,6 @@ Foam::PairSpringSliderDashpot<CloudType>::PairSpringSliderDashpot
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::PairSpringSliderDashpot<CloudType>::~PairSpringSliderDashpot()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType> template<class CloudType>

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) 2008-2011 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011, 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -136,7 +136,7 @@ public:
//- Destructor //- Destructor
virtual ~PairSpringSliderDashpot(); virtual ~PairSpringSliderDashpot() = default;
// Member Functions // Member Functions

View File

@ -41,10 +41,8 @@ void Foam::WallLocalSpringSliderDashpot<CloudType>::findMinMaxProperties
rhoMax = -VGREAT; rhoMax = -VGREAT;
UMagMax = -VGREAT; UMagMax = -VGREAT;
forAllConstIter(typename CloudType, this->owner(), iter) for (const typename CloudType::parcelType& p : this->owner())
{ {
const typename CloudType::parcelType& p = iter();
// Finding minimum diameter to avoid excessive arithmetic // Finding minimum diameter to avoid excessive arithmetic
scalar dEff = p.d(); scalar dEff = p.d();
@ -213,11 +211,11 @@ Foam::WallLocalSpringSliderDashpot<CloudType>::WallLocalSpringSliderDashpot
DynamicList<label> wallPatchIndices; DynamicList<label> wallPatchIndices;
forAll(bMesh, patchi) for (const polyPatch& pp : bMesh)
{ {
if (isA<wallPolyPatch>(bMesh[patchi])) if (isA<wallPolyPatch>(pp))
{ {
wallPatchIndices.append(bMesh[patchi].index()); wallPatchIndices.append(pp.index());
} }
} }
@ -271,13 +269,6 @@ Foam::WallLocalSpringSliderDashpot<CloudType>::WallLocalSpringSliderDashpot
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::WallLocalSpringSliderDashpot<CloudType>::~WallLocalSpringSliderDashpot()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType> template<class CloudType>

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) 2008-2011 OpenCFD Ltd. \\ / A nd | Copyright (C) 2008-2011, 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -150,7 +150,7 @@ public:
//- Destructor //- Destructor
virtual ~WallLocalSpringSliderDashpot(); virtual ~WallLocalSpringSliderDashpot() = default;
// Member Functions // Member Functions

View File

@ -41,10 +41,8 @@ void Foam::WallSpringSliderDashpot<CloudType>::findMinMaxProperties
rhoMax = -VGREAT; rhoMax = -VGREAT;
UMagMax = -VGREAT; UMagMax = -VGREAT;
forAllConstIter(typename CloudType, this->owner(), iter) for (const typename CloudType::parcelType& p : this->owner())
{ {
const typename CloudType::parcelType& p = iter();
// Finding minimum diameter to avoid excessive arithmetic // Finding minimum diameter to avoid excessive arithmetic
scalar dEff = p.d(); scalar dEff = 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) 2015-2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -45,9 +45,8 @@ void Foam::InjectedParticleDistributionInjection<CloudType>::initialise()
// Flatten all data // Flatten all data
label particlei = 0; label particlei = 0;
forAllConstIter(injectedParticleCloud, ipCloud, iter) for (const injectedParticle& p : ipCloud)
{ {
const injectedParticle& p = iter();
tag[particlei] = p.tag(); tag[particlei] = p.tag();
position[particlei] = p.position(); position[particlei] = p.position();
U[particlei] = p.U(); U[particlei] = p.U();

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) 2015-2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,16 +46,14 @@ void Foam::InjectedParticleInjection<CloudType>::initialise()
label particlei = 0; label particlei = 0;
forAllConstIter(injectedParticleCloud, cloud, iter) for (const injectedParticle& p : cloud)
{ {
const injectedParticle& p = iter();
time[particlei] = p.soi(); time[particlei] = p.soi();
position[particlei] = p.position() + positionOffset_; position[particlei] = p.position() + positionOffset_;
diameter[particlei] = p.d(); diameter[particlei] = p.d();
U[particlei] = p.U(); U[particlei] = p.U();
particlei++; ++particlei;
} }
// Combine all proc data // Combine all proc data
@ -218,13 +216,6 @@ Foam::InjectedParticleInjection<CloudType>::InjectedParticleInjection
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::InjectedParticleInjection<CloudType>::~InjectedParticleInjection()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType> template<class CloudType>
@ -289,7 +280,7 @@ Foam::label Foam::InjectedParticleInjection<CloudType>::parcelsToInject
{ {
if ((time_[particlei] >= time0) && (time_[particlei] < time1)) if ((time_[particlei] >= time0) && (time_[particlei] < time1))
{ {
nParticles++; ++nParticles;
} }
} }

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) 2015-2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -155,7 +155,7 @@ public:
//- Destructor //- Destructor
virtual ~InjectedParticleInjection(); virtual ~InjectedParticleInjection() = default;
// Member Functions // Member Functions

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) 2013-2017 OpenFOAM Foundation | Copyright (C) 2013-2017 OpenFOAM Foundation
@ -165,9 +165,8 @@ void Foam::IsotropyModels::Stochastic<CloudType>::calculate()
)(); )();
// random sampling // random sampling
forAllIter(typename CloudType, this->owner(), iter) for (typename CloudType::parcelType& p : this->owner())
{ {
typename CloudType::parcelType& p = iter();
const tetIndices tetIs(p.currentTetIndices()); const tetIndices tetIs(p.currentTetIndices());
const scalar x = exponentAverage.interpolate(p.coordinates(), tetIs); const scalar x = exponentAverage.interpolate(p.coordinates(), tetIs);
@ -200,9 +199,8 @@ void Foam::IsotropyModels::Stochastic<CloudType>::calculate()
) )
); );
AveragingMethod<vector>& uTildeAverage = uTildeAveragePtr(); AveragingMethod<vector>& uTildeAverage = uTildeAveragePtr();
forAllIter(typename CloudType, this->owner(), iter) for (typename CloudType::parcelType& p : this->owner())
{ {
typename CloudType::parcelType& p = iter();
const tetIndices tetIs(p.currentTetIndices()); const tetIndices tetIs(p.currentTetIndices());
uTildeAverage.add(p.coordinates(), tetIs, p.nParticle()*p.mass()*p.U()); uTildeAverage.add(p.coordinates(), tetIs, p.nParticle()*p.mass()*p.U());
} }
@ -223,9 +221,8 @@ void Foam::IsotropyModels::Stochastic<CloudType>::calculate()
) )
); );
AveragingMethod<scalar>& uTildeSqrAverage = uTildeSqrAveragePtr(); AveragingMethod<scalar>& uTildeSqrAverage = uTildeSqrAveragePtr();
forAllIter(typename CloudType, this->owner(), iter) for (typename CloudType::parcelType& p : this->owner())
{ {
typename CloudType::parcelType& p = iter();
const tetIndices tetIs(p.currentTetIndices()); const tetIndices tetIs(p.currentTetIndices());
const vector uTilde = uTildeAverage.interpolate(p.coordinates(), tetIs); const vector uTilde = uTildeAverage.interpolate(p.coordinates(), tetIs);
uTildeSqrAverage.add uTildeSqrAverage.add
@ -238,9 +235,8 @@ void Foam::IsotropyModels::Stochastic<CloudType>::calculate()
uTildeSqrAverage.average(massAverage); uTildeSqrAverage.average(massAverage);
// conservation correction // conservation correction
forAllIter(typename CloudType, this->owner(), iter) for (typename CloudType::parcelType& p : this->owner())
{ {
typename CloudType::parcelType& p = iter();
const tetIndices tetIs(p.currentTetIndices()); const tetIndices tetIs(p.currentTetIndices());
const vector u = uAverage.interpolate(p.coordinates(), tetIs); const vector u = uAverage.interpolate(p.coordinates(), tetIs);

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) 2013-2017 OpenFOAM Foundation | Copyright (C) 2013-2017 OpenFOAM Foundation
@ -46,10 +46,9 @@ void Foam::SuppressionCollision<CloudType>::collide
dimensionedScalar Dt("dt", dimTime, dt); dimensionedScalar Dt("dt", dimTime, dt);
volScalarField P(type() + ":p", 1.0 - exp(-vDotSweep*Dt)); volScalarField P(type() + ":p", 1.0 - exp(-vDotSweep*Dt));
forAllIter(typename CloudType, this->owner(), iter) for (typename CloudType::parcelType& p : this->owner())
{ {
typename CloudType::parcelType& p = iter(); const label celli = p.cell();
label celli = p.cell();
scalar xx = this->owner().rndGen().template sample01<scalar>(); scalar xx = this->owner().rndGen().template sample01<scalar>();