diff --git a/applications/test/FixedList/Test-FixedList.C b/applications/test/FixedList/Test-FixedList.C index 5287593c1db695c094ad3106878ada0be5dd4ac9..1257c970916e86b7f7927428176fdbcb2044b292 100644 --- a/applications/test/FixedList/Test-FixedList.C +++ b/applications/test/FixedList/Test-FixedList.C @@ -297,12 +297,7 @@ int main(int argc, char *argv[]) { if (Pstream::master()) { - for - ( - int proci = Pstream::firstSlave(); - proci <= Pstream::lastSlave(); - ++proci - ) + for (const int proci : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, proci); FixedList<label, 2> list3(fromSlave); diff --git a/applications/test/IndirectList/Test-IndirectList.C b/applications/test/IndirectList/Test-IndirectList.C index 6d4a26305f573bc44085c8c67abe6f096bdf5096..6ea616c0ba541e439cd1886d635f45c990fd73d1 100644 --- a/applications/test/IndirectList/Test-IndirectList.C +++ b/applications/test/IndirectList/Test-IndirectList.C @@ -148,12 +148,7 @@ int main(int argc, char *argv[]) Pout<< "full: " << flatOutput(idl3.values()) << nl << "send: " << flatOutput(idl3) << endl; - for - ( - int proci = Pstream::firstSlave(); - proci <= Pstream::lastSlave(); - ++proci - ) + for (const int proci : Pstream::subProcs()) { OPstream toSlave(Pstream::commsTypes::scheduled, proci); toSlave << idl3; diff --git a/applications/test/parallel-communicators/Test-parallel-communicators.C b/applications/test/parallel-communicators/Test-parallel-communicators.C index d0dc8dd1db5b000ea2cb3e37bc89dcdbae4733a4..99a3158d06071bb27995445f4e8541b1417befc5 100644 --- a/applications/test/parallel-communicators/Test-parallel-communicators.C +++ b/applications/test/parallel-communicators/Test-parallel-communicators.C @@ -57,12 +57,7 @@ scalar sumReduce // Add master value and all slaves sum = localValue; - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(comm); - slave++ - ) + for (const int slave : UPstream::subProcs(comm)) { scalar slaveValue; UIPstream::read @@ -80,12 +75,7 @@ scalar sumReduce // Send back to slaves - for - ( - int slave=UPstream::firstSlave(); - slave<=UPstream::lastSlave(comm); - slave++ - ) + for (const int slave : UPstream::subProcs(comm)) { UOPstream::write ( diff --git a/applications/test/parallel-nonBlocking/Test-parallel-nonBlocking.C b/applications/test/parallel-nonBlocking/Test-parallel-nonBlocking.C index 7fca05e3c2221d129692fe2f483bb5e44f0e6ee1..8d80b9bab53f3e8d8dde6fbcce8d564024134c3a 100644 --- a/applications/test/parallel-nonBlocking/Test-parallel-nonBlocking.C +++ b/applications/test/parallel-nonBlocking/Test-parallel-nonBlocking.C @@ -87,12 +87,7 @@ int main(int argc, char *argv[]) // Collect my own data allData.append(data); - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { Perr << "master receiving from slave " << slave << endl; UIPstream fromSlave(slave, pBufs); @@ -105,12 +100,7 @@ int main(int argc, char *argv[]) PstreamBuffers pBufs2(Pstream::commsTypes::nonBlocking); if (Pstream::master()) { - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { Perr << "master sending to slave " << slave << endl; UOPstream toSlave(slave, pBufs2); diff --git a/applications/test/parallel/Test-parallel.C b/applications/test/parallel/Test-parallel.C index f87a699be8e400cb9f655f19d745eed148a77e08..b6ac4f7e288e5e1271eed62a365713a71d84fcda 100644 --- a/applications/test/parallel/Test-parallel.C +++ b/applications/test/parallel/Test-parallel.C @@ -154,12 +154,7 @@ void testTransfer(const T& input) if (Pstream::master()) { - for - ( - int slave = Pstream::firstSlave(); - slave <= Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { Perr<< "master receiving from slave " << slave << endl; IPstream fromSlave(Pstream::commsTypes::blocking, slave); @@ -167,12 +162,7 @@ void testTransfer(const T& input) perrInfo(data) << endl; } - for - ( - int slave = Pstream::firstSlave(); - slave <= Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { Perr<< "master sending to slave " << slave << endl; OPstream toSlave(Pstream::commsTypes::blocking, slave); @@ -207,12 +197,7 @@ void testTokenized(const T& data) if (Pstream::master()) { - for - ( - int slave = Pstream::firstSlave(); - slave <= Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { Perr<< "master receiving from slave " << slave << endl; IPstream fromSlave(Pstream::commsTypes::blocking, slave); @@ -220,12 +205,7 @@ void testTokenized(const T& data) Perr<< tok.info() << endl; } - for - ( - int slave = Pstream::firstSlave(); - slave <= Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { Perr<< "master sending to slave " << slave << endl; OPstream toSlave(Pstream::commsTypes::blocking, slave); diff --git a/applications/test/router/Gather/Gather.C b/applications/test/router/Gather/Gather.C index 176f2b7341fb097b12a10b64637ce864f1c393a3..cf3542edad26a95f736fe95f1186b6dead97b5ee 100644 --- a/applications/test/router/Gather/Gather.C +++ b/applications/test/router/Gather/Gather.C @@ -58,24 +58,14 @@ Gather<T0>::Gather(const T0& localData, const bool redistribute) *outIter = localData; // Receive data - for - ( - int proci = Pstream::firstSlave(); - proci <= Pstream::lastSlave(); - ++proci - ) + for (const int proci : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::scheduled, proci); fromSlave >> *(++outIter); } // Send data - for - ( - int proci = Pstream::firstSlave(); - proci <= Pstream::lastSlave(); - ++proci - ) + for (const int proci : Pstream::subProcs()) { OPstream toSlave(Pstream::commsTypes::scheduled, proci); diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C index 72512b5e8cd4d811cf659377a6663726edf21f0e..3b71ef1cc8cd207e8502be9be36693744e02b889 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2017 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -445,7 +445,7 @@ void Foam::mergeAndWrite pOffset += myPoints.size(); // Receive slave ones - for (int slave=1; slave<Pstream::nProcs(); slave++) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::scheduled, slave); diff --git a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C index 1f429e7777996b09b0fa0c90d21fea1d95c39e21..22060652a6d38f39aa2556e69424ad6513950494 100644 --- a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C +++ b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -387,12 +387,7 @@ void getInterfaceSizes if (Pstream::master()) { // Receive and add to my sizes - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); diff --git a/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C b/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C index fb4245fa2415e292d68ab66e4948e00f48c1141e..f905908adc3acdb5bd27060c29ec44a72ecdad05 100644 --- a/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C +++ b/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -124,12 +124,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh ); // Send patches - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { OPstream toSlave(Pstream::commsTypes::scheduled, slave); toSlave << patchEntries; diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index fd916b8476f1432e9e24abd58e4dcdd81f09e072..9eaae1eb1a97078e09ef10554db3d88d65b55089 100644 --- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -677,7 +677,7 @@ void readFields tmp<GeoField> tsubfld = subsetterPtr->interpolate(fields[i]); // Send to all processors that don't have a mesh - for (label procI = 1; procI < Pstream::nProcs(); ++procI) + for (const int procI : Pstream::subProcs()) { if (!haveMesh[procI]) { diff --git a/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C b/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C index 7be8601aa9ee2646e8c7e660cbb6e1e43612ba00..64b271ab78d7f4fa863b11c87a0b8bde5ed5b88d 100644 --- a/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C +++ b/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C @@ -340,12 +340,7 @@ bool Foam::decomposedBlockData::readBlocks } // Read slave data - for - ( - label proci = 1; - proci < UPstream::nProcs(comm); - ++proci - ) + for (const int proci : UPstream::subProcs(comm)) { List<char> elems(is); is.fatalCheck("read(Istream&) : reading entry"); @@ -397,12 +392,7 @@ bool Foam::decomposedBlockData::readBlocks } // Read slave data - for - ( - label proci = 1; - proci < UPstream::nProcs(comm); - ++proci - ) + for (const int proci : UPstream::subProcs(comm)) { List<char> elems(is); is.fatalCheck("read(Istream&) : reading entry"); @@ -474,12 +464,7 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks } // Read slave data - for - ( - label proci = 1; - proci < UPstream::nProcs(comm); - ++proci - ) + for (const int proci : UPstream::subProcs(comm)) { is >> data; is.fatalCheck("read(Istream&) : reading entry"); @@ -545,12 +530,7 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks } // Read slave data - for - ( - label proci = 1; - proci < UPstream::nProcs(comm); - ++proci - ) + for (const int proci : UPstream::subProcs(comm)) { List<char> elems(is); is.fatalCheck("read(Istream&) : reading entry"); diff --git a/src/OpenFOAM/db/IOstreams/Fstreams/masterOFstream.C b/src/OpenFOAM/db/IOstreams/Fstreams/masterOFstream.C index dc10310c9e947cbb6e5de50ffb6e0ec71954b6a3..d9a9e7a9d266d218846446bc5e852b7cb9c9b5be 100644 --- a/src/OpenFOAM/db/IOstreams/Fstreams/masterOFstream.C +++ b/src/OpenFOAM/db/IOstreams/Fstreams/masterOFstream.C @@ -154,7 +154,7 @@ void Foam::masterOFstream::commit() *std::max_element(recvSizes.cbegin(), recvSizes.cend()) ); - for (label proci = 1; proci < Pstream::nProcs(); ++proci) + for (const int proci : Pstream::subProcs()) { UIPstream is(proci, pBufs); diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H index 4628871b309772b31b8a745db3a0c3c72f4d757a..e8d18edb29d69556cb6537182c5c3ca337b0140b 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H @@ -374,7 +374,7 @@ public: static void addValidParOptions(HashTable<string>& validParOptions); //- Initialisation function called from main - // Spawns slave processes and initialises inter-communication + // Spawns sub-processes and initialises inter-communication static bool init(int& argc, char**& argv, const bool needsThread); //- Special purpose initialisation function. @@ -459,18 +459,6 @@ public: return procIDs_[communicator]; } - //- Process index of first slave - static constexpr int firstSlave() noexcept - { - return 1; - } - - //- Process index of last slave - static int lastSlave(const label communicator = 0) - { - return nProcs(communicator) - 1; - } - //- Range of process indices for all processes static IntRange<int> allProcs(const label communicator = 0) { @@ -478,6 +466,13 @@ public: return IntRange<int>(static_cast<int>(nProcs(communicator))); } + //- Range of process indices for sub-processes + static IntRange<int> subProcs(const label communicator = 0) + { + // Proc 1 -> nProcs + return IntRange<int>(1, static_cast<int>(nProcs(communicator)-1)); + } + //- Communication schedule for linear all-to-master (proc 0) static const List<commsStruct>& linearCommunication ( @@ -578,6 +573,23 @@ public: int recvSize, const label communicator = 0 ); + + + // Housekeeping + + //- Process index of first sub-process + // \deprecated(2020-09) use subProcs() method instead + static constexpr int firstSlave() noexcept + { + return 1; + } + + //- Process index of last sub-process + // \deprecated(2020-09) use subProcs() method instead + static int lastSlave(const label communicator = 0) + { + return nProcs(communicator) - 1; + } }; diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index e808f5993d2465c5f37b3c1c2c6a49b0d1a853e4..fcc4c5357610630681093ed674eb7492f39988ce 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -1105,12 +1105,7 @@ void Foam::argList::parse slaveProcs.resize(Pstream::nProcs()-1); slaveMachine.resize(Pstream::nProcs()-1); label proci = 0; - for - ( - int slave = Pstream::firstSlave(); - slave <= Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::scheduled, slave); @@ -1119,7 +1114,7 @@ void Foam::argList::parse fromSlave >> slaveBuild >> slaveMachine[proci] >> slavePid; slaveProcs[proci] = slaveMachine[proci] + "." + name(slavePid); - proci++; + ++proci; // Verify that all processors are running the same build if (slaveBuild != foamVersion::build) @@ -1339,12 +1334,7 @@ void Foam::argList::parse // Distribute the master's argument list (with new root) const bool hadCaseOpt = options_.found("case"); - for - ( - int slave = Pstream::firstSlave(); - slave <= Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { options_.set("case", roots[slave-1]/globalCase_); @@ -1392,12 +1382,7 @@ void Foam::argList::parse } // Distribute the master's argument list (unaltered) - for - ( - int slave = Pstream::firstSlave(); - slave <= Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { OPstream toSlave(Pstream::commsTypes::scheduled, slave); toSlave << args_ << options_ << roots.size(); diff --git a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C index e1b9401108b699c5ba13820f7aafc484b8ef3e03..ba488be83ea155c6cc0427f47a7200c942c75664 100644 --- a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C +++ b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C @@ -642,12 +642,7 @@ Foam::fileOperations::masterUncollatedFileOperation::read } // Read slave files - for - ( - label proci = 1; - proci < Pstream::nProcs(comm); - proci++ - ) + for (const int proci : Pstream::subProcs(comm)) { if (debug) { @@ -2391,12 +2386,7 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream } else { - for - ( - label proci = 1; - proci < Pstream::nProcs(Pstream::worldComm); - proci++ - ) + for (const int proci : Pstream::subProcs(Pstream::worldComm)) { readAndSend ( diff --git a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperationTemplates.C b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperationTemplates.C index 7f613e5a5f91ba14a313aaa85c388e0ea9b3c456..9b6228f3ab76936e5c519bc4adc1e04917b4783d 100644 --- a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperationTemplates.C +++ b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperationTemplates.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017-2018 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,7 +43,7 @@ Type Foam::fileOperations::masterUncollatedFileOperation::scatterList PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking, tag, comm); if (Pstream::master(comm)) { - for (label proci = 1; proci < Pstream::nProcs(comm); proci++) + for (const int proci : Pstream::subProcs(comm)) { UOPstream os(proci, pBufs); os << masterLst[proci]; diff --git a/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.C b/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.C index e8ab17c740fbe39b389740a493c8bccd79fd9eb8..a8e56660606a3e48074f20a59eea1e1197d53e37 100644 --- a/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.C +++ b/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -85,12 +86,7 @@ Foam::LUscalarMatrix::LUscalarMatrix if (Pstream::master(comm_)) { - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(comm_); - slave++ - ) + for (const int slave : Pstream::subProcs(comm_)) { lduMatrices.set ( diff --git a/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrixTemplates.C b/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrixTemplates.C index fcd19ae15c96f604aa00ecd2715213e0fcc0fc11..1c8d0fe6e738d7a196ee2052645fafbf989659fe 100644 --- a/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrixTemplates.C +++ b/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrixTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -54,12 +54,7 @@ void Foam::LUscalarMatrix::solve SubList<Type>(X, x.size()) = x; - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(comm_); - slave++ - ) + for (const int slave : Pstream::subProcs(comm_)) { IPstream::read ( @@ -94,12 +89,7 @@ void Foam::LUscalarMatrix::solve x = SubList<Type>(X, x.size()); - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(comm_); - slave++ - ) + for (const int slave : Pstream::subProcs(comm_)) { OPstream::write ( diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index e063318239ecef12d76b3cd6a1291ef0dfce64e3..c553ca8affcc1c48f2c42eeed32f2fda778a1ea0 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -391,12 +391,7 @@ void Foam::globalMeshData::calcSharedEdges() const // Receive data from slaves and insert if (Pstream::parRun()) { - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { // Receive the edges using shared points from the slave. IPstream fromSlave(Pstream::commsTypes::blocking, slave); @@ -440,12 +435,7 @@ void Foam::globalMeshData::calcSharedEdges() const // Send back to slaves. if (Pstream::parRun()) { - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { // Receive the edges using shared points from the slave. OPstream toSlave(Pstream::commsTypes::blocking, slave); @@ -1907,12 +1897,7 @@ Foam::pointField Foam::globalMeshData::sharedPoints() const } // Receive data from slaves and insert - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); @@ -1929,12 +1914,7 @@ Foam::pointField Foam::globalMeshData::sharedPoints() const } // Send back - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { OPstream toSlave ( diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C index 5b90f95a532dc434620a45abfaf5a1fec023a0b3..59c00950998482a3b47768be156902522feb204c 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C @@ -80,12 +80,7 @@ Foam::List<Foam::labelPair> Foam::mapDistributeBase::schedule if (Pstream::master()) { // Receive and merge - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::scheduled, slave, 0, tag); List<labelPair> nbrData(fromSlave); @@ -101,12 +96,7 @@ Foam::List<Foam::labelPair> Foam::mapDistributeBase::schedule } } // Send back - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { OPstream toSlave(Pstream::commsTypes::scheduled, slave, 0, tag); toSlave << allComms; diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C index ec523bc956d5e98de5c04e069a6e2f15c2048816..2cb398068ad5eb3ce9b5b5ba6cf84cecca5b33ed 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C @@ -1007,7 +1007,7 @@ bool Foam::polyBoundaryMesh::checkParallelSync(const bool report) const // Have every processor check but print error on master // (in processor sequence). - for (label proci = 1; proci < Pstream::nProcs(); ++proci) + for (const int proci : Pstream::subProcs()) { if ( diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C index c88115b2320ad78b4b7d6b66bae792a3128340e3..23a94cc8eba501bd9a3b9613127f0c7654e8d65b 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -291,12 +291,7 @@ void Foam::syncTools::syncPointMap if (Pstream::master()) { // Receive the edges using shared points from the slave. - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::scheduled, slave); Map<T> nbrValues(fromSlave); @@ -315,12 +310,7 @@ void Foam::syncTools::syncPointMap } // Send back - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { OPstream toSlave(Pstream::commsTypes::scheduled, slave); toSlave << sharedPointValues; @@ -656,12 +646,7 @@ void Foam::syncTools::syncEdgeMap if (Pstream::master()) { // Receive the edges using shared points from the slave. - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::scheduled, slave); EdgeMap<T> nbrValues(fromSlave); @@ -680,14 +665,8 @@ void Foam::syncTools::syncEdgeMap } // Send back - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { - OPstream toSlave(Pstream::commsTypes::scheduled, slave); toSlave << sharedEdgeValues; } diff --git a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsGatherAndMerge.C b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsGatherAndMerge.C index 8eb0020c81c8cae7a4123842b03ba775cfef6181..aeeb4ba59a3eccdb150c6bf26759140c5b049852 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsGatherAndMerge.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsGatherAndMerge.C @@ -170,7 +170,7 @@ void Foam::PatchTools::gatherAndMerge // Receive slave ones - for (int slave=1; slave<Pstream::nProcs(); slave++) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::scheduled, slave); diff --git a/src/Pstream/mpi/allReduceTemplates.C b/src/Pstream/mpi/allReduceTemplates.C index 37c3fdc20f438c929c78a77357f52a176b82592b..2c8e928407d541c14a69a9e08c43dba00ecb7eb6 100644 --- a/src/Pstream/mpi/allReduceTemplates.C +++ b/src/Pstream/mpi/allReduceTemplates.C @@ -54,12 +54,7 @@ void Foam::allReduce { if (UPstream::master(communicator)) { - for - ( - int proci=UPstream::firstSlave(); - proci<=UPstream::lastSlave(communicator); - ++proci - ) + for (const int proci : UPstream::subProcs(communicator)) { Type value; @@ -109,12 +104,7 @@ void Foam::allReduce if (UPstream::master(communicator)) { - for - ( - int proci=UPstream::firstSlave(); - proci<=UPstream::lastSlave(communicator); - ++proci - ) + for (const int proci : UPstream::subProcs(communicator)) { if ( diff --git a/src/conversion/vtk/output/foamVtkPatchWriterTemplates.C b/src/conversion/vtk/output/foamVtkPatchWriterTemplates.C index fe2dbcc1dcfa84f259640018a000d6d1a58312c8..9d52a55f6631e3d4151b479ec9ff73007b1f9e1e 100644 --- a/src/conversion/vtk/output/foamVtkPatchWriterTemplates.C +++ b/src/conversion/vtk/output/foamVtkPatchWriterTemplates.C @@ -97,12 +97,7 @@ void Foam::vtk::patchWriter::write Field<Type> recv; // Receive each patch field and write - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); @@ -214,12 +209,7 @@ void Foam::vtk::patchWriter::write Field<Type> recv; // Receive each patch field and write - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); @@ -348,12 +338,7 @@ void Foam::vtk::patchWriter::write Field<Type> recv; // Receive each patch field and write - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C b/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C index e51b0668f25bbd699555cf721309eac2e01031ed..f98e21d643729b0d485a3efb1073f636eb97ff26 100644 --- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C +++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistributeTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -307,7 +307,7 @@ void Foam::fvMeshDistribute::getFieldNames Pstream::gatherList(allNames); Pstream::scatterList(allNames); - for (label proci = 1; proci < Pstream::nProcs(); proci++) + for (const int proci : Pstream::subProcs()) { if (allNames[proci] != allNames[0]) { diff --git a/src/dynamicMesh/fvMeshTools/fvMeshTools.C b/src/dynamicMesh/fvMeshTools/fvMeshTools.C index c508bb15b922c6360f18b6a9497185ddc2286264..1fbc71b471a3d53af5f76880ec2c2df5892475fd 100644 --- a/src/dynamicMesh/fvMeshTools/fvMeshTools.C +++ b/src/dynamicMesh/fvMeshTools/fvMeshTools.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2016 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -472,12 +472,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshTools::newMesh ); // Send patches - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + for (const int slave : Pstream::subProcs()) { OPstream toSlave(Pstream::commsTypes::scheduled, slave); toSlave << patchEntries; diff --git a/src/fileFormats/ensight/output/ensightOutput.C b/src/fileFormats/ensight/output/ensightOutput.C index da614e896acca6bfb7a21209f03d059f8e01a238..61045f2ef4165596ce651a71255996bb5326ef7b 100644 --- a/src/fileFormats/ensight/output/ensightOutput.C +++ b/src/fileFormats/ensight/output/ensightOutput.C @@ -290,11 +290,11 @@ void Foam::ensightOutput::writeFaceConnectivity parallel = parallel && Pstream::parRun(); - const labelRange senders = + const IntRange<int> senders = ( parallel - ? labelRange(1, Pstream::nProcs()-1) - : labelRange() + ? Pstream::subProcs() + : IntRange<int>() ); if (Pstream::master()) @@ -381,11 +381,11 @@ void Foam::ensightOutput::writeFaceConnectivity parallel = parallel && Pstream::parRun(); - const labelRange senders = + const IntRange<int> senders = ( parallel - ? labelRange(1, Pstream::nProcs()-1) - : labelRange() + ? Pstream::subProcs() + : IntRange<int>() ); diff --git a/src/fileFormats/ensight/output/ensightOutputTemplates.C b/src/fileFormats/ensight/output/ensightOutputTemplates.C index f17cd0d5616bf3e45f9a7e2a07bcf3b76865b8d8..00f5ab4d234585be2db9c44cb2f69c30c4da475e 100644 --- a/src/fileFormats/ensight/output/ensightOutputTemplates.C +++ b/src/fileFormats/ensight/output/ensightOutputTemplates.C @@ -63,11 +63,11 @@ bool Foam::ensightOutput::Detail::writeCoordinates { parallel = parallel && Pstream::parRun(); - const labelRange senders = + const IntRange<int> senders = ( parallel - ? labelRange(1, Pstream::nProcs()-1) - : labelRange() + ? Pstream::subProcs() + : IntRange<int>() ); @@ -130,11 +130,11 @@ bool Foam::ensightOutput::Detail::writeFieldComponents { parallel = parallel && Pstream::parRun(); - const labelRange senders = + const IntRange<int> senders = ( parallel - ? labelRange(1, Pstream::nProcs()-1) - : labelRange() + ? Pstream::subProcs() + : IntRange<int>() ); diff --git a/src/fileFormats/ensight/part/cells/ensightCellsIO.C b/src/fileFormats/ensight/part/cells/ensightCellsIO.C index e5f080803b0b1d286ae83fa91a183a13ea2c3d03..43c1133f82507859b0ad9b1377f3ccae7f96421a 100644 --- a/src/fileFormats/ensight/part/cells/ensightCellsIO.C +++ b/src/fileFormats/ensight/part/cells/ensightCellsIO.C @@ -52,11 +52,11 @@ void Foam::ensightCells::writePolysConnectivity return; } - const labelRange senders = + const IntRange<int> senders = ( parallel - ? labelRange(1, Pstream::nProcs()-1) - : labelRange() + ? Pstream::subProcs() + : IntRange<int>() ); @@ -213,11 +213,11 @@ void Foam::ensightCells::writeShapeConnectivity } - const labelRange senders = + const IntRange<int> senders = ( parallel - ? labelRange(1, Pstream::nProcs()-1) - : labelRange() + ? Pstream::subProcs() + : IntRange<int>() ); diff --git a/src/fileFormats/vtk/output/foamVtkOutput.C b/src/fileFormats/vtk/output/foamVtkOutput.C index cf6351be2605cd452df202a8aaaa576583e990fb..7e32b87dcf01275ad8a4c78027c82b011669a478 100644 --- a/src/fileFormats/vtk/output/foamVtkOutput.C +++ b/src/fileFormats/vtk/output/foamVtkOutput.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -135,12 +135,7 @@ void Foam::vtk::writeListParallel List<uint8_t> recv; // Receive and write - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); @@ -183,12 +178,7 @@ void Foam::vtk::writeListParallel labelList recv; // Receive and write - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); @@ -219,7 +209,6 @@ void Foam::vtk::writeListParallel // * * * * * * * * * * * * * * Legacy Functions * * * * * * * * * * * * * * // - void Foam::vtk::legacy::fileHeader ( std::ostream& os, diff --git a/src/fileFormats/vtk/output/foamVtkOutputTemplates.C b/src/fileFormats/vtk/output/foamVtkOutputTemplates.C index 7573440f08771699e21b86c450832945df67415c..e296a2b2b56ca5788104aeb9c811f4888d2928fa 100644 --- a/src/fileFormats/vtk/output/foamVtkOutputTemplates.C +++ b/src/fileFormats/vtk/output/foamVtkOutputTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -136,12 +136,7 @@ void Foam::vtk::writeListParallel List<Type> recv; // Receive and write - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); @@ -179,12 +174,7 @@ void Foam::vtk::writeListParallel List<Type> recv; // Receive and write - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); @@ -222,12 +212,7 @@ void Foam::vtk::writeListParallel List<Type> recv; // Receive and write - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); @@ -266,12 +251,7 @@ void Foam::vtk::writeListsParallel List<Type> recv1, recv2; // Receive and write - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); @@ -310,14 +290,9 @@ void Foam::vtk::writeListsParallel vtk::writeList(fmt, values2, addressing); List<Type> recv1, recv2; -; + // Receive and write - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); diff --git a/src/fileFormats/vtk/write/foamVtkSurfaceWriter.C b/src/fileFormats/vtk/write/foamVtkSurfaceWriter.C index 2b4369a9591062100f4fe80aec1c2ea7a6f2f96f..bb8b3fac7cc8f3c1d39fff177a6f4ccb6c30cfb2 100644 --- a/src/fileFormats/vtk/write/foamVtkSurfaceWriter.C +++ b/src/fileFormats/vtk/write/foamVtkSurfaceWriter.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -104,12 +104,7 @@ void Foam::vtk::surfaceWriter::writePoints() pointField recv; // Receive each point field and write - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); diff --git a/src/functionObjects/field/externalCoupled/externalCoupledTemplates.C b/src/functionObjects/field/externalCoupled/externalCoupledTemplates.C index c3a7c939755ca7aba8a06060c3668e3b06057d1f..e3e8a3a2409e26e475bd5498ee4b708ce93eb7eb 100644 --- a/src/functionObjects/field/externalCoupled/externalCoupledTemplates.C +++ b/src/functionObjects/field/externalCoupled/externalCoupledTemplates.C @@ -409,7 +409,7 @@ bool Foam::functionObjects::externalCoupled::writeData } masterFilePtr() << os.str().c_str(); - for (label proci = 1; proci < Pstream::nProcs(); proci++) + for (const int proci : Pstream::subProcs()) { IPstream fromSlave ( diff --git a/src/functionObjects/lagrangian/dataCloud/dataCloudTemplates.C b/src/functionObjects/lagrangian/dataCloud/dataCloudTemplates.C index 5f5c3daeb2499f45b52440244994804dad2a316d..c90205543d21a3baa131d94dab379f6295747824 100644 --- a/src/functionObjects/lagrangian/dataCloud/dataCloudTemplates.C +++ b/src/functionObjects/lagrangian/dataCloud/dataCloudTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -85,7 +85,7 @@ void Foam::functionObjects::dataCloud::writeListParallel Field<Type> recvField; // Receive and write - for (int slave=1; slave<Pstream::nProcs(); ++slave) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); @@ -142,7 +142,7 @@ void Foam::functionObjects::dataCloud::writeListParallel Field<Type> recvField; // Receive and write - for (int slave=1; slave<Pstream::nProcs(); ++slave) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); diff --git a/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloud.C b/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloud.C index afdb64d1676633f53a8cf15f5197bbc13cf7a629..28c512a8b431d74d97ca7aaf555e1577903b195b 100644 --- a/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloud.C +++ b/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloud.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -132,7 +132,7 @@ bool Foam::ensightOutput::writeCloudPositions writeMeasured(os, positions); // Slaves - for (int slave=1; slave<Pstream::nProcs(); ++slave) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(comm, slave); pointField recv(fromSlave); @@ -149,7 +149,7 @@ bool Foam::ensightOutput::writeCloudPositions parcelId = writeMeasured(os, parcelId, positions); // Slaves - for (int slave=1; slave<Pstream::nProcs(); ++slave) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(comm, slave); pointField recv(fromSlave); diff --git a/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloudTemplates.C b/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloudTemplates.C index 497484178e9b88923850b2f8584ee7b243516910..c07cb1667f5d17f6f5fe2d047e82885596b7b36e 100644 --- a/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloudTemplates.C +++ b/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloudTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,7 +71,7 @@ bool Foam::ensightOutput::writeCloudField } // Slaves - for (int slave=1; slave<Pstream::nProcs(); ++slave) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(comm, slave); Field<Type> recv(fromSlave); diff --git a/src/meshTools/output/foamVtkIndPatchWriter.C b/src/meshTools/output/foamVtkIndPatchWriter.C index 896e65fda23ade67551150c9f5518e1e10690cc5..2adbf7dfffe6cd04ce3942b6eb2f91dd89605042 100644 --- a/src/meshTools/output/foamVtkIndPatchWriter.C +++ b/src/meshTools/output/foamVtkIndPatchWriter.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -104,12 +104,7 @@ void Foam::vtk::indirectPatchWriter::writePoints() pointField recv; // Receive each point field and write - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); diff --git a/src/meshTools/output/foamVtkPatchMeshWriter.C b/src/meshTools/output/foamVtkPatchMeshWriter.C index 6896777f7fe8870a82d92ba21cfd540fe9224df3..fc66f32ee4d0646f5181f53dd85e2db761af7fff 100644 --- a/src/meshTools/output/foamVtkPatchMeshWriter.C +++ b/src/meshTools/output/foamVtkPatchMeshWriter.C @@ -125,12 +125,7 @@ void Foam::vtk::patchMeshWriter::writePoints() pointField recv; // Receive each point field and write - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); @@ -584,12 +579,7 @@ void Foam::vtk::patchMeshWriter::writePatchIDs() labelList recv; // Receive each pair - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); @@ -793,12 +783,7 @@ bool Foam::vtk::patchMeshWriter::writeNeighIDs() labelList recv; // Receive each pair - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - ++slave - ) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::blocking, slave); diff --git a/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C b/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C index b978a5e64b7fff519e112f4415e9eae0a19d52a4..d4a6198c06481b25e4085efe28eae89598c640dd 100644 --- a/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C +++ b/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -78,7 +78,7 @@ Foam::label Foam::metisLikeDecomp::decomposeGeneral allAdjncy[nTotalConnections++] = adjncy[i]; } - for (int slave=1; slave<Pstream::nProcs(); ++slave) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::scheduled, slave); List<label> nbrAdjncy(fromSlave); @@ -110,7 +110,7 @@ Foam::label Foam::metisLikeDecomp::decomposeGeneral // Send allFinalDecomp back - for (int slave=1; slave<Pstream::nProcs(); ++slave) + for (const int slave : Pstream::subProcs()) { OPstream toSlave(Pstream::commsTypes::scheduled, slave); toSlave << SubList<label> diff --git a/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.C b/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.C index 94b6a10f783e78c12019823dafe4fa604ef59de8..e5625bf2b6a4b64908cd6d4f034f9dc6a53a15a0 100644 --- a/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.C +++ b/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2017-2018 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -350,7 +350,7 @@ Foam::labelList Foam::simpleGeomDecomp::decompose nTotalPoints += points.size(); // Add slaves - for (int slave=1; slave<Pstream::nProcs(); ++slave) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::scheduled, slave); pointField nbrPoints(fromSlave); @@ -367,7 +367,7 @@ Foam::labelList Foam::simpleGeomDecomp::decompose labelList finalDecomp(decomposeOneProc(allPoints)); // Send back - for (int slave=1; slave<Pstream::nProcs(); ++slave) + for (const int slave : Pstream::subProcs()) { OPstream toSlave(Pstream::commsTypes::scheduled, slave); toSlave << SubField<label> @@ -435,7 +435,7 @@ Foam::labelList Foam::simpleGeomDecomp::decompose nTotalPoints += points.size(); // Add slaves - for (int slave=1; slave<Pstream::nProcs(); ++slave) + for (const int slave : Pstream::subProcs()) { IPstream fromSlave(Pstream::commsTypes::scheduled, slave); pointField nbrPoints(fromSlave); @@ -459,7 +459,7 @@ Foam::labelList Foam::simpleGeomDecomp::decompose labelList finalDecomp(decomposeOneProc(allPoints, allWeights)); // Send back - for (int slave=1; slave<Pstream::nProcs(); ++slave) + for (const int slave : Pstream::subProcs()) { OPstream toSlave(Pstream::commsTypes::scheduled, slave); toSlave << SubField<label> diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index 3740e366153a3374f246940a37d7dc1902ffbe9f..0aa35c88d9721f54a2b4ef1280f7566736a0fa3f 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -1655,7 +1655,7 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs bool masterOnly; { masterOnly = true; - for (label proci = 1; proci < Pstream::nProcs(); proci++) + for (const int proci : Pstream::subProcs()) { if (triIndexer.localSize(proci) != 0) { diff --git a/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C index c01eaafb0d617bc0bc1e4c12ba496727ac36bf64..8c0b4bd8861c728cde36afd528db3fcff8788aa1 100644 --- a/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C +++ b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -267,7 +267,7 @@ Foam::scalar surfaceNoise::writeSurfaceData allData[faceI] = data[faceI]; } - for (label procI = 1; procI < Pstream::nProcs(); ++procI) + for (const int procI : Pstream::subProcs()) { UIPstream fromProc(procI, pBufs); scalarList dataSlice(fromProc); @@ -370,7 +370,7 @@ Foam::scalar surfaceNoise::surfaceAverage allData[faceI] = data[faceI]; } - for (label procI = 1; procI < Pstream::nProcs(); procI++) + for (const int procI : Pstream::subProcs()) { UIPstream fromProc(procI, pBufs); scalarList dataSlice(fromProc);