diff --git a/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloudI.H b/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloudI.H index 38f8add9d2..7fdc77abcd 100644 --- a/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/CollidingCloud/CollidingCloudI.H @@ -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-2016 OpenFOAM Foundation @@ -65,10 +65,8 @@ Foam::CollidingCloud::rotationalKineticEnergyOfSystem() const { scalar rotationalKineticEnergy = 0.0; - forAllConstIter(typename CollidingCloud, *this, iter) + for (const parcelType& p : *this) { - const parcelType& p = iter(); - rotationalKineticEnergy += p.nParticle()*0.5*p.momentOfInertia()*(p.omega() & p.omega()); } diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C index 980060f02b..3c36b4b3e4 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C @@ -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 @@ -155,14 +155,14 @@ void Foam::KinematicCloud::buildCellOccupancy() List>& cellOccupancy = cellOccupancyPtr_(); - forAll(cellOccupancy, cO) + for (auto& list : cellOccupancy) { - cellOccupancy[cO].clear(); + list.clear(); } - forAllIter(typename KinematicCloud, *this, iter) + for (parcelType& p : *this) { - cellOccupancy[iter().cell()].append(&iter()); + cellOccupancy[p.cell()].append(&p); } } diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H index d6d67c4351..b10226c31c 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H @@ -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 @@ -273,10 +273,9 @@ template inline Foam::scalar Foam::KinematicCloud::massInSystem() const { scalar sysMass = 0.0; - forAllConstIter(typename KinematicCloud, *this, iter) + for (const parcelType& p : *this) { - const parcelType& p = iter(); - sysMass += p.nParticle()*p.mass(); + sysMass += p.nParticle()*p.mass(); } return sysMass; @@ -289,10 +288,8 @@ Foam::KinematicCloud::linearMomentumOfSystem() const { vector linearMomentum(Zero); - forAllConstIter(typename KinematicCloud, *this, iter) + for (const parcelType& p : *this) { - const parcelType& p = iter(); - linearMomentum += p.nParticle()*p.mass()*p.U(); } @@ -306,10 +303,8 @@ Foam::KinematicCloud::linearKineticEnergyOfSystem() const { scalar linearKineticEnergy = 0.0; - forAllConstIter(typename KinematicCloud, *this, iter) + for (const parcelType& p : *this) { - const parcelType& p = iter(); - linearKineticEnergy += p.nParticle()*0.5*p.mass()*(p.U() & p.U()); } @@ -326,9 +321,8 @@ inline Foam::scalar Foam::KinematicCloud::Dij { scalar si = 0.0; scalar sj = 0.0; - forAllConstIter(typename KinematicCloud, *this, iter) + for (const parcelType& p : *this) { - const parcelType& p = iter(); si += p.nParticle()*pow(p.d(), i); sj += p.nParticle()*pow(p.d(), j); } @@ -345,9 +339,8 @@ template inline Foam::scalar Foam::KinematicCloud::Dmax() const { scalar d = -GREAT; - forAllConstIter(typename KinematicCloud, *this, iter) + for (const parcelType& p : *this) { - const parcelType& p = iter(); d = max(d, p.d()); } @@ -477,9 +470,8 @@ Foam::KinematicCloud::vDotSweep() const ); volScalarField& vDotSweep = tvDotSweep.ref(); - forAllConstIter(typename KinematicCloud, *this, iter) + for (const parcelType& p : *this) { - const parcelType& p = iter(); const label celli = p.cell(); vDotSweep[celli] += p.nParticle()*p.areaP()*mag(p.U() - U_[celli]); @@ -516,9 +508,8 @@ Foam::KinematicCloud::theta() const ); volScalarField& theta = ttheta.ref(); - forAllConstIter(typename KinematicCloud, *this, iter) + for (const parcelType& p : *this) { - const parcelType& p = iter(); const label celli = p.cell(); theta[celli] += p.nParticle()*p.volume(); @@ -554,9 +545,8 @@ Foam::KinematicCloud::alpha() const ); scalarField& alpha = talpha.ref().primitiveFieldRef(); - forAllConstIter(typename KinematicCloud, *this, iter) + for (const parcelType& p : *this) { - const parcelType& p = iter(); const label celli = p.cell(); alpha[celli] += p.nParticle()*p.mass(); @@ -591,9 +581,8 @@ Foam::KinematicCloud::rhoEff() const ); scalarField& rhoEff = trhoEff.ref().primitiveFieldRef(); - forAllConstIter(typename KinematicCloud, *this, iter) + for (const parcelType& p : *this) { - const parcelType& p = iter(); const label celli = p.cell(); rhoEff[celli] += p.nParticle()*p.mass(); diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H index 9fb7f3bcbc..17e4432628 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H @@ -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 @@ -374,48 +374,42 @@ Foam::ThermoCloud::sigmap() const template inline Foam::scalar Foam::ThermoCloud::Tmax() const { - scalar T = -GREAT; - scalar n = 0; - forAllConstIter(typename ThermoCloud, *this, iter) + scalar val = -GREAT; + bool nonEmpty = false; + + for (const parcelType& p : *this) { - const parcelType& p = iter(); - T = max(T, p.T()); - n++; + val = max(val, p.T()); + nonEmpty = true; } - reduce(T, maxOp()); - reduce(n, sumOp