diff --git a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C
index 41b5a02546da560a8bffad4c3037744af447b0ce..6296b29bf9e681d5cd48f3c9c63269c7ba972f99 100644
--- a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C
+++ b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C
@@ -707,7 +707,7 @@ void Foam::radiation::laserDTRM::calculate()
         Pstream::gatherList(p0);
         Pstream::scatterList(p0);
 
-        for (label proci = 0; proci < Pstream::nProcs(); ++proci)
+        for (const int proci : Pstream::allProcs())
         {
             const pointField& pos = positions[proci];
             const pointField& pfinal = p0[proci];
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 1d9eeebcca0f733c28c05e48476a6ceba39206b4..8d80b9bab53f3e8d8dde6fbcce8d564024134c3a 100644
--- a/applications/test/parallel-nonBlocking/Test-parallel-nonBlocking.C
+++ b/applications/test/parallel-nonBlocking/Test-parallel-nonBlocking.C
@@ -50,7 +50,6 @@ using namespace Foam;
 
 int main(int argc, char *argv[])
 {
-
     #include "setRootCase.H"
     #include "createTime.H"
 
@@ -88,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);
@@ -106,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);
@@ -154,7 +143,7 @@ int main(int argc, char *argv[])
     {
         PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
 
-        for (label proci = 0; proci < Pstream::nProcs(); proci++)
+        for (const int proci : Pstream::allProcs())
         {
             UOPstream toProc(proci, pBufs);
             toProc << Pstream::myProcNo();
@@ -164,7 +153,7 @@ int main(int argc, char *argv[])
         pBufs.finishedSends();
 
         // Consume
-        for (label proci = 0; proci < Pstream::nProcs(); proci++)
+        for (const int proci : Pstream::allProcs())
         {
             UIPstream fromProc(proci, pBufs);
             label data;
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/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C
index e02810916d18065d759981d84edad64179135c68..56b18a898a204c72a791f602dfbb77fd5f3e219e 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C
@@ -489,7 +489,7 @@ Foam::label Foam::DistributedDelaunayMesh<Triangulation>::referVertices
 
     pointMap.distribute(parallelVertices);
 
-    for (label proci = 0; proci < Pstream::nProcs(); proci++)
+    for (const int proci : Pstream::allProcs())
     {
         const labelList& constructMap = pointMap.constructMap()[proci];
 
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C
index 1b022e59e4696404ebf9f86af075a5f73e1fb0bc..4b50b014cac83e7e784b9204b7b82cff3331afc5 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C
@@ -473,7 +473,7 @@ void Foam::backgroundMeshDecomposition::printMeshData
 
     // globalIndex globalBoundaryFaces(mesh.nBoundaryFaces());
 
-    for (label proci = 0; proci < Pstream::nProcs(); proci++)
+    for (const int proci : Pstream::allProcs())
     {
         Info<< "Processor " << proci << " "
             << "Number of cells = " << globalCells.localSize(proci)
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C
index 2ba63abf1ae95a80a14de81098752069dbd8130e..4affaa57581ca7225b987eb0c17e9a80873b0c0b 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C
@@ -703,7 +703,7 @@ Foam::label Foam::conformalVoronoiMesh::synchroniseSurfaceTrees
     label nStoppedInsertion = 0;
 
     // Do the nearness tests here
-    for (label proci = 0; proci < Pstream::nProcs(); ++proci)
+    for (const int proci : Pstream::allProcs())
     {
         // Skip own points
         if (proci >= Pstream::myProcNo())
@@ -795,7 +795,7 @@ Foam::label Foam::conformalVoronoiMesh::synchroniseEdgeTrees
     label nStoppedInsertion = 0;
 
     // Do the nearness tests here
-    for (label proci = 0; proci < Pstream::nProcs(); ++proci)
+    for (const int proci : Pstream::allProcs())
     {
         // Skip own points
         if (proci >= Pstream::myProcNo())
diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C
index 51a68564c5873475258a1d90f25f443674f400b2..111ef191ccf9afc6ae9e8aff1aada58598aea41f 100644
--- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C
+++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C
@@ -130,7 +130,7 @@ void printMeshData(const polyMesh& mesh)
     label totProcPatches = 0;
     label maxProcFaces = 0;
 
-    for (label proci = 0; proci < Pstream::nProcs(); proci++)
+    for (const int proci : Pstream::allProcs())
     {
         Info<< endl
             << "Processor " << proci << nl
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 96f7bc50df6c4851760cea4dc13b183b739fd594..9eaae1eb1a97078e09ef10554db3d88d65b55089 100644
--- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
+++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
@@ -185,7 +185,7 @@ void printMeshData(const polyMesh& mesh)
     label totProcPatches = 0;
     label maxProcFaces = 0;
 
-    for (label procI = 0; procI < Pstream::nProcs(); ++procI)
+    for (const int procI : Pstream::allProcs())
     {
         Info<< nl
             << "Processor " << procI << nl
@@ -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/applications/utilities/preProcessing/viewFactorsGen/shootRays.H b/applications/utilities/preProcessing/viewFactorsGen/shootRays.H
index 9a44e73addc1404a84c9c233e9af9d399df2e340..9f751ecd200ba0bbcdaab8a033fc6cffe94316cf 100644
--- a/applications/utilities/preProcessing/viewFactorsGen/shootRays.H
+++ b/applications/utilities/preProcessing/viewFactorsGen/shootRays.H
@@ -7,7 +7,7 @@ const label maxDynListLength
     viewFactorDict.getOrDefault<label>("maxDynListLength", 100000)
 );
 
-for (label proci = 0; proci < Pstream::nProcs(); proci++)
+for (const int proci : Pstream::allProcs())
 {
     // Shoot rays from me to proci. Note that even if processor has
     // 0 faces we still need to call findLine to keep calls synced.
diff --git a/src/OpenFOAM/containers/Lists/SortableList/ParSortableList.C b/src/OpenFOAM/containers/Lists/SortableList/ParSortableList.C
index d4099adc6bfbd9e7e853ff73629b050a8a0e35f9..5e66e78be7c2a6f9582d0404bcf4e55ca47cde3c 100644
--- a/src/OpenFOAM/containers/Lists/SortableList/ParSortableList.C
+++ b/src/OpenFOAM/containers/Lists/SortableList/ParSortableList.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.
@@ -285,7 +286,7 @@ void Foam::ParSortableList<Type>::sort()
 
     label combinedI = 0;
 
-    for (label proci = 0; proci < Pstream::nProcs(); proci++)
+    for (const int proci : Pstream::allProcs())
     {
         if (proci == Pstream::myProcNo())
         {
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/PstreamBuffers.H b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H
index 1904922c785991397df9a27bf7316fba6e58bd77..df574758242c294ddc8140b8a11def8f919954cd 100644
--- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H
+++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H
@@ -39,7 +39,7 @@ Description
     \code
         PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
 
-        for (label proci = 0; proci < Pstream::nProcs(); ++proci)
+        for (const int proci : Pstream::allProcs())
         {
             if (proci != Pstream::myProcNo())
             {
@@ -52,7 +52,7 @@ Description
 
         pBufs.finishedSends();   // no-op for blocking
 
-        for (label proci = 0; proci < Pstream::nProcs(); ++proci)
+        for (const int proci : Pstream::allProcs())
         {
             if (proci != Pstream::myProcNo())
             {
@@ -62,7 +62,6 @@ Description
         }
     \endcode
 
-
 SourceFiles
     PstreamBuffers.C
 
diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H
index f963347395d0e24527ef35b72783f33b530022e7..e8d18edb29d69556cb6537182c5c3ca337b0140b 100644
--- a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H
+++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H
@@ -75,7 +75,7 @@ public:
     static const Enum<commsTypes> commsTypeNames;
 
 
-    // Public classes
+    // Public Classes
 
         //- Structure for communicating between processors
         class commsStruct
@@ -180,7 +180,7 @@ public:
 
 private:
 
-    // Private data
+    // Private Data
 
         //- By default this is not a parallel run
         static bool parRun_;
@@ -248,7 +248,7 @@ private:
 
 protected:
 
-    // Protected data
+    // Protected Data
 
         //- Communications type of this stream
         commsTypes commsType_;
@@ -298,7 +298,7 @@ public:
         {}
 
 
-    // Member functions
+    // Member Functions
 
         //- Allocate a new communicator
         static label allocateCommunicator
@@ -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.
@@ -424,7 +424,7 @@ public:
             return haveThreads_;
         }
 
-        //- Number of processes in parallel run
+        //- Number of processes in parallel run, and 1 for serial run
         static label nProcs(const label communicator = 0)
         {
             return procIDs_[communicator].size();
@@ -459,16 +459,18 @@ public:
             return procIDs_[communicator];
         }
 
-        //- Process index of first slave
-        static constexpr int firstSlave() noexcept
+        //- Range of process indices for all processes
+        static IntRange<int> allProcs(const label communicator = 0)
         {
-            return 1;
+            // Proc 0 -> nProcs
+            return IntRange<int>(static_cast<int>(nProcs(communicator)));
         }
 
-        //- Process index of last slave
-        static int lastSlave(const label communicator = 0)
+        //- Range of process indices for sub-processes
+        static IntRange<int> subProcs(const label communicator = 0)
         {
-            return nProcs(communicator) - 1;
+            // Proc 1 -> nProcs
+            return IntRange<int>(1, static_cast<int>(nProcs(communicator)-1));
         }
 
         //- Communication schedule for linear all-to-master (proc 0)
@@ -571,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 15be6750a49e5aa0b7cb523824d658150729cb89..ba488be83ea155c6cc0427f47a7200c942c75664 100644
--- a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C
+++ b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C
@@ -598,12 +598,7 @@ Foam::fileOperations::masterUncollatedFileOperation::read
                 }
 
                 DynamicList<label> validProcs(Pstream::nProcs(comm));
-                for
-                (
-                    label proci = 0;
-                    proci < Pstream::nProcs(comm);
-                    proci++
-                )
+                for (const int proci : Pstream::allProcs(comm))
                 {
                     if (procValid[proci])
                     {
@@ -647,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)
                 {
@@ -2396,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/globalIndex.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C
index d42491eddf6d48ba5771b34a10ac311497f088a2..93a33346e545f1a8bcded68474628227558de261 100644
--- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C
+++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2018-2019 OpenCFD Ltd.
+    Copyright (C) 2018-2020 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -119,7 +119,7 @@ void Foam::globalIndex::reset
 
     label offset = 0;
     offsets_[0] = 0;
-    for (label proci = 0; proci < Pstream::nProcs(comm); ++proci)
+    for (const int proci : Pstream::allProcs(comm))
     {
         const label oldOffset = offset;
         offset += localSizes[proci];
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 1f9cb435857355bfeff48737a8b732101ac84fc9..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;
@@ -898,7 +888,7 @@ void Foam::mapDistributeBase::compact(const boolList& elemIsUsed, const int tag)
 
         List<boolList> recvFields(Pstream::nProcs());
 
-        for (label domain = 0; domain < Pstream::nProcs(); domain++)
+        for (const int domain : Pstream::allProcs())
         {
             const labelList& map = subMap_[domain];
 
@@ -919,7 +909,7 @@ void Foam::mapDistributeBase::compact(const boolList& elemIsUsed, const int tag)
 
         List<boolList> sendFields(Pstream::nProcs());
 
-        for (label domain = 0; domain < Pstream::nProcs(); domain++)
+        for (const int domain : Pstream::allProcs())
         {
             const labelList& map = constructMap_[domain];
 
@@ -976,7 +966,7 @@ void Foam::mapDistributeBase::compact(const boolList& elemIsUsed, const int tag)
 
 
         // Compact out all submap entries that are referring to unused elements
-        for (label domain = 0; domain < Pstream::nProcs(); domain++)
+        for (const int domain : Pstream::allProcs())
         {
             const labelList& map = subMap_[domain];
 
@@ -1005,7 +995,7 @@ void Foam::mapDistributeBase::compact(const boolList& elemIsUsed, const int tag)
 
     label maxConstructIndex = -1;
 
-    for (label domain = 0; domain < Pstream::nProcs(); domain++)
+    for (const int domain : Pstream::allProcs())
     {
         const labelList& map = constructMap_[domain];
 
@@ -1065,7 +1055,7 @@ void Foam::mapDistributeBase::compact
 
         List<boolList> recvFields(Pstream::nProcs());
 
-        for (label domain = 0; domain < Pstream::nProcs(); domain++)
+        for (const int domain : Pstream::allProcs())
         {
             const labelList& map = subMap_[domain];
 
@@ -1086,7 +1076,7 @@ void Foam::mapDistributeBase::compact
 
         List<boolList> sendFields(Pstream::nProcs());
 
-        for (label domain = 0; domain < Pstream::nProcs(); domain++)
+        for (const int domain : Pstream::allProcs())
         {
             const labelList& map = constructMap_[domain];
 
@@ -1148,7 +1138,7 @@ void Foam::mapDistributeBase::compact
 
             boolList sendElemIsUsed(localSize, false);
 
-            for (label domain = 0; domain < Pstream::nProcs(); domain++)
+            for (const int domain : Pstream::allProcs())
             {
                 const labelList& map = subMap_[domain];
                 forAll(map, i)
@@ -1177,7 +1167,7 @@ void Foam::mapDistributeBase::compact
 
 
         // Compact out all submap entries that are referring to unused elements
-        for (label domain = 0; domain < Pstream::nProcs(); domain++)
+        for (const int domain : Pstream::allProcs())
         {
             const labelList& map = subMap_[domain];
 
@@ -1227,7 +1217,7 @@ void Foam::mapDistributeBase::compact
         }
     }
 
-    for (label domain = 0; domain < Pstream::nProcs(); domain++)
+    for (const int domain : Pstream::allProcs())
     {
         const labelList& map = constructMap_[domain];
 
diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C
index be48461a9f0ecd98b16ac5dc88074879b0253eae..e9f9ebccd5e595e66c0928b4199f353b6ae8da7e 100644
--- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C
+++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2015-2017 OpenFOAM Foundation
-    Copyright (C) 2015-2016, 2019 OpenCFD Ltd.
+    Copyright (C) 2015-2020 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -168,7 +168,7 @@ void Foam::mapDistributeBase::distribute
         // received data.
 
         // Send sub field to neighbour
-        for (label domain = 0; domain < Pstream::nProcs(); domain++)
+        for (const int domain : Pstream::allProcs())
         {
             const labelList& map = subMap[domain];
 
@@ -216,7 +216,7 @@ void Foam::mapDistributeBase::distribute
         );
 
         // Receive sub field from neighbour
-        for (label domain = 0; domain < Pstream::nProcs(); domain++)
+        for (const int domain : Pstream::allProcs())
         {
             const labelList& map = constructMap[domain];
 
@@ -398,7 +398,7 @@ void Foam::mapDistributeBase::distribute
             PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking, tag);
 
             // Stream data into buffer
-            for (label domain = 0; domain < Pstream::nProcs(); domain++)
+            for (const int domain : Pstream::allProcs())
             {
                 const labelList& map = subMap[domain];
 
@@ -461,7 +461,7 @@ void Foam::mapDistributeBase::distribute
             Pstream::waitRequests(nOutstanding);
 
             // Consume
-            for (label domain = 0; domain < Pstream::nProcs(); domain++)
+            for (const int domain : Pstream::allProcs())
             {
                 const labelList& map = constructMap[domain];
 
@@ -490,7 +490,7 @@ void Foam::mapDistributeBase::distribute
 
             List<List<T>> sendFields(Pstream::nProcs());
 
-            for (label domain = 0; domain < Pstream::nProcs(); domain++)
+            for (const int domain : Pstream::allProcs())
             {
                 const labelList& map = subMap[domain];
 
@@ -524,7 +524,7 @@ void Foam::mapDistributeBase::distribute
 
             List<List<T>> recvFields(Pstream::nProcs());
 
-            for (label domain = 0; domain < Pstream::nProcs(); domain++)
+            for (const int domain : Pstream::allProcs())
             {
                 const labelList& map = constructMap[domain];
 
@@ -592,7 +592,7 @@ void Foam::mapDistributeBase::distribute
 
             // Collect neighbour fields
 
-            for (label domain = 0; domain < Pstream::nProcs(); domain++)
+            for (const int domain : Pstream::allProcs())
             {
                 const labelList& map = constructMap[domain];
 
@@ -671,7 +671,7 @@ void Foam::mapDistributeBase::distribute
         // received data.
 
         // Send sub field to neighbour
-        for (label domain = 0; domain < Pstream::nProcs(); domain++)
+        for (const int domain : Pstream::allProcs())
         {
             const labelList& map = subMap[domain];
 
@@ -711,7 +711,7 @@ void Foam::mapDistributeBase::distribute
         flipAndCombine(map, constructHasFlip, subField, cop, negOp, field);
 
         // Receive sub field from neighbour
-        for (label domain = 0; domain < Pstream::nProcs(); domain++)
+        for (const int domain : Pstream::allProcs())
         {
             const labelList& map = constructMap[domain];
 
@@ -896,7 +896,7 @@ void Foam::mapDistributeBase::distribute
             PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking, tag);
 
             // Stream data into buffer
-            for (label domain = 0; domain < Pstream::nProcs(); domain++)
+            for (const int domain : Pstream::allProcs())
             {
                 const labelList& map = subMap[domain];
 
@@ -962,7 +962,7 @@ void Foam::mapDistributeBase::distribute
             Pstream::waitRequests(nOutstanding);
 
             // Consume
-            for (label domain = 0; domain < Pstream::nProcs(); domain++)
+            for (const int domain : Pstream::allProcs())
             {
                 const labelList& map = constructMap[domain];
 
@@ -991,7 +991,7 @@ void Foam::mapDistributeBase::distribute
 
             List<List<T>> sendFields(Pstream::nProcs());
 
-            for (label domain = 0; domain < Pstream::nProcs(); domain++)
+            for (const int domain : Pstream::allProcs())
             {
                 const labelList& map = subMap[domain];
 
@@ -1025,7 +1025,7 @@ void Foam::mapDistributeBase::distribute
 
             List<List<T>> recvFields(Pstream::nProcs());
 
-            for (label domain = 0; domain < Pstream::nProcs(); domain++)
+            for (const int domain : Pstream::allProcs())
             {
                 const labelList& map = constructMap[domain];
 
@@ -1092,7 +1092,7 @@ void Foam::mapDistributeBase::distribute
 
             // Collect neighbour fields
 
-            for (label domain = 0; domain < Pstream::nProcs(); domain++)
+            for (const int domain : Pstream::allProcs())
             {
                 const labelList& map = constructMap[domain];
 
@@ -1129,7 +1129,7 @@ void Foam::mapDistributeBase::send(PstreamBuffers& pBufs, const List<T>& field)
 const
 {
     // Stream data into buffer
-    for (label domain = 0; domain < Pstream::nProcs(); domain++)
+    for (const int domain : Pstream::allProcs())
     {
         const labelList& map = subMap_[domain];
 
@@ -1165,7 +1165,7 @@ const
     // Consume
     field.setSize(constructSize_);
 
-    for (label domain = 0; domain < Pstream::nProcs(); domain++)
+    for (const int domain : Pstream::allProcs())
     {
         const labelList& map = constructMap_[domain];
 
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/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C
index 73c38e38e184ac45a6e4a2d6a4a848358d472084..032041ad9ca5068ffc4604b1fff648118ba04bb3 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C
@@ -1303,7 +1303,7 @@ void Foam::refinementHistory::distribute(const mapDistributePolyMesh& map)
 
     // Create subsetted refinement tree consisting of all parents that
     // move in their whole to other processor.
-    for (label proci = 0; proci < Pstream::nProcs(); proci++)
+    for (const int proci : Pstream::allProcs())
     {
         //Pout<< "-- Subetting for processor " << proci << endl;
 
@@ -1412,7 +1412,7 @@ void Foam::refinementHistory::distribute(const mapDistributePolyMesh& map)
     visibleCells_.setSize(mesh.nCells());
     visibleCells_ = -1;
 
-    for (label proci = 0; proci < Pstream::nProcs(); proci++)
+    for (const int proci : Pstream::allProcs())
     {
         IPstream fromNbr(Pstream::commsTypes::blocking, proci);
         List<splitCell8> newSplitCells(fromNbr);
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/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C
index 238b84c5029152b6dd4c512189edf187c314bdd0..4a5a681a7d1593751a0276dd06ff488661a50eb0 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C
@@ -692,7 +692,7 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::calcOverlappingProcEddies
 
     PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
 
-    for (label domain = 0; domain < Pstream::nProcs(); domain++)
+    for (const int domain : Pstream::allProcs())
     {
         const labelList& sendElems = map.subMap()[domain];
 
@@ -710,7 +710,7 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::calcOverlappingProcEddies
     pBufs.finishedSends();
 
     // Consume
-    for (label domain = 0; domain < Pstream::nProcs(); domain++)
+    for (const int domain : Pstream::allProcs())
     {
         const labelList& recvElems = map.constructMap()[domain];
 
diff --git a/src/finiteVolume/fvMesh/zoneDistribute/zoneDistribute.C b/src/finiteVolume/fvMesh/zoneDistribute/zoneDistribute.C
index 3194c5ae6d121ab29e5b25cf59b24fa8039f38fd..3cafff4ff9fc3332287ed8565fe894f50cc2dbd7 100644
--- a/src/finiteVolume/fvMesh/zoneDistribute/zoneDistribute.C
+++ b/src/finiteVolume/fvMesh/zoneDistribute/zoneDistribute.C
@@ -6,6 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2020 DLR
+    Copyright (C) 2020 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -162,7 +163,7 @@ void Foam::zoneDistribute::setUpCommforZone
         PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
 
         // Stream data into buffer
-        for (label domain = 0; domain < Pstream::nProcs(); domain++)
+        for (const int domain : Pstream::allProcs())
         {
             if (domain != Pstream::myProcNo())
             {
@@ -176,7 +177,7 @@ void Foam::zoneDistribute::setUpCommforZone
         // wait until everything is written.
         pBufs.finishedSends();
 
-        for (label domain = 0; domain < Pstream::nProcs(); domain++)
+        for (const int domain : Pstream::allProcs())
         {
             send_[domain].clear();
 
diff --git a/src/finiteVolume/fvMesh/zoneDistribute/zoneDistributeI.H b/src/finiteVolume/fvMesh/zoneDistribute/zoneDistributeI.H
index 2289be2509fbe8f9ae429f34743715f94c4dc267..2c733ec6bb534df632ce72ee70deebd58070e615 100644
--- a/src/finiteVolume/fvMesh/zoneDistribute/zoneDistributeI.H
+++ b/src/finiteVolume/fvMesh/zoneDistribute/zoneDistributeI.H
@@ -6,6 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2019-2020 DLR
+    Copyright (C) 2020 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -184,7 +185,7 @@ Foam::Map<Type> Foam::zoneDistribute::getDatafromOtherProc
         PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
 
         // Stream data into buffer
-        for (label domain = 0; domain < Pstream::nProcs(); domain++)
+        for (const int domain : Pstream::allProcs())
         {
             if (domain != Pstream::myProcNo())
             {
@@ -200,7 +201,7 @@ Foam::Map<Type> Foam::zoneDistribute::getDatafromOtherProc
 
         Map<Type> tmpValue;
 
-        for (label domain = 0; domain < Pstream::nProcs(); domain++)
+        for (const int domain : Pstream::allProcs())
         {
             if (domain != Pstream::myProcNo())
             {
diff --git a/src/functionObjects/field/STDMD/STDMD.C b/src/functionObjects/field/STDMD/STDMD.C
index 65d47e68873efe8d609b667d1b0c9909417f51d8..4fc192d670a6d399ae95c10633c283db3b0f8353 100644
--- a/src/functionObjects/field/STDMD/STDMD.C
+++ b/src/functionObjects/field/STDMD/STDMD.C
@@ -293,9 +293,9 @@ void Foam::functionObjects::STDMD::calcAp()
             Log<< tab << "# " << name()
                 << ": Populating the global Rx #" << endl;
             label m = 0;
-            for (label i = 0; i < Pstream::nProcs(); ++i)
+            for (const int i : Pstream::allProcs())
             {
-                label mRows = RxList[i].m();
+                const label mRows = RxList[i].m();
 
                 Rx.subMatrix(m, 0, mRows) = RxList[i];
 
diff --git a/src/functionObjects/field/externalCoupled/externalCoupled.C b/src/functionObjects/field/externalCoupled/externalCoupled.C
index e30488bbea0e11c7d7208f7a97990bedaffb483c..927e764d27fd461e45e1d257ec25cd1c8b9b649f 100644
--- a/src/functionObjects/field/externalCoupled/externalCoupled.C
+++ b/src/functionObjects/field/externalCoupled/externalCoupled.C
@@ -117,7 +117,7 @@ void Foam::functionObjects::externalCoupled::readColumns
 
         // Read data from file and send to destination processor
 
-        for (label proci = 0; proci < Pstream::nProcs(); ++proci)
+        for (const int proci : Pstream::allProcs())
         {
             // Temporary storage
             List<scalarField> values(nColumns);
@@ -188,7 +188,7 @@ void Foam::functionObjects::externalCoupled::readLines
 
         // Read line from file and send to destination processor
 
-        for (label proci = 0; proci < Pstream::nProcs(); ++proci)
+        for (const int proci : Pstream::allProcs())
         {
             // Number of rows to read for processor proci
             const label procNRows = globalFaces.localSize(proci);
@@ -314,7 +314,7 @@ void Foam::functionObjects::externalCoupled::writeGeometry
                 allPoints.clear();
                 allFaces.clear();
 
-                for (label proci=0; proci < Pstream::nProcs(); ++proci)
+                for (const int proci : Pstream::allProcs())
                 {
                     allPoints.append(collectedPoints[proci]);
                     allFaces.append(collectedFaces[proci]);
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/functionObjects/randomProcesses/energySpectrum/energySpectrum.C b/src/functionObjects/randomProcesses/energySpectrum/energySpectrum.C
index 85032821ece0fc1e39b0bcbcb55176391a186142..fb8f794b98381888e173eead5500c98b6761717e 100644
--- a/src/functionObjects/randomProcesses/energySpectrum/energySpectrum.C
+++ b/src/functionObjects/randomProcesses/energySpectrum/energySpectrum.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.
@@ -235,7 +235,7 @@ bool Foam::functionObjects::energySpectrum::write()
             vectorField Uijk(nGlobalCells);
             vectorField Cijk(nGlobalCells);
 
-            for (label proci = 0; proci < Pstream::nProcs(); ++proci)
+            for (const int proci : Pstream::allProcs())
             {
                 UIPstream fromProc(proci, pBufs);
                 vectorField Up;
diff --git a/src/lagrangian/basic/InteractionLists/InteractionLists.C b/src/lagrangian/basic/InteractionLists/InteractionLists.C
index ffd9f041bc882d6bc1f054e0778b5133141d1db9..4e1535ed0958d93bf4ac662ecef77df316e4275f 100644
--- a/src/lagrangian/basic/InteractionLists/InteractionLists.C
+++ b/src/lagrangian/basic/InteractionLists/InteractionLists.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.
@@ -1172,7 +1172,7 @@ void Foam::InteractionLists<ParticleType>::sendReferredData
 
     prepareParticlesToRefer(cellOccupancy);
 
-    for (label domain = 0; domain < Pstream::nProcs(); domain++)
+    for (const int domain : Pstream::allProcs())
     {
         const labelList& subMap = cellMap().subMap()[domain];
 
@@ -1211,7 +1211,7 @@ void Foam::InteractionLists<ParticleType>::receiveReferredData
 
     referredParticles_.setSize(cellMap().constructSize());
 
-    for (label domain = 0; domain < Pstream::nProcs(); domain++)
+    for (const int domain : Pstream::allProcs())
     {
         const labelList& constructMap = cellMap().constructMap()[domain];
 
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/lagrangian/spray/clouds/Templates/SprayCloud/SprayCloudI.H b/src/lagrangian/spray/clouds/Templates/SprayCloud/SprayCloudI.H
index a5fdbf9d8f5fdf7a34bb3210198e7c74f5d272b8..3edd6376c946ef4b41dd5a4da53ba83f3a20aeb8 100644
--- a/src/lagrangian/spray/clouds/Templates/SprayCloud/SprayCloudI.H
+++ b/src/lagrangian/spray/clouds/Templates/SprayCloud/SprayCloudI.H
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2019 OpenCFD Ltd.
+    Copyright (C) 2019-2020 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -133,7 +133,7 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
         // flatten the mass lists
         List<scalar> allMass(nParcelSum, Zero);
         SortableList<scalar> allDist(nParcelSum, Zero);
-        for (label proci = 0; proci < Pstream::nProcs(); proci++)
+        for (const int proci : Pstream::allProcs())
         {
             SubList<scalar>
             (
diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C
index 330cc3426eea7b458c02516d1167aac893508d1d..f5d9c5f39557a5340ade5a40a67cf40ee3e6949e 100644
--- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C
+++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C
@@ -2494,7 +2494,7 @@ Foam::meshRefinement::balanceAndRefine
     //    globalIndex globalCells(mesh_.nCells());
     //
     //    Info<< "** Distribution before balancing/refining:" << endl;
-    //    for (label procI = 0; procI < Pstream::nProcs(); procI++)
+    //    for (const int procI : Pstream::allProcs())
     //    {
     //        Info<< "    " << procI << '\t'
     //            << globalCells.localSize(procI) << endl;
@@ -2505,7 +2505,7 @@ Foam::meshRefinement::balanceAndRefine
     //    globalIndex globalCells(cellsToRefine.size());
     //
     //    Info<< "** Cells to be refined:" << endl;
-    //    for (label procI = 0; procI < Pstream::nProcs(); procI++)
+    //    for (const int procI : Pstream::allProcs())
     //    {
     //        Info<< "    " << procI << '\t'
     //            << globalCells.localSize(procI) << endl;
@@ -2567,7 +2567,7 @@ Foam::meshRefinement::balanceAndRefine
         //    globalIndex globalCells(mesh_.nCells());
         //
         //    Info<< "** Distribution after balancing:" << endl;
-        //    for (label procI = 0; procI < Pstream::nProcs(); procI++)
+        //    for (const int procI : Pstream::allProcs())
         //    {
         //        Info<< "    " << procI << '\t'
         //            << globalCells.localSize(procI) << endl;
@@ -2625,7 +2625,7 @@ Foam::meshRefinement::balanceAndRefine
     //    globalIndex globalCells(mesh_.nCells());
     //
     //    Info<< "** After refinement distribution:" << endl;
-    //    for (label procI = 0; procI < Pstream::nProcs(); procI++)
+    //    for (const int procI : Pstream::allProcs())
     //    {
     //        Info<< "    " << procI << '\t'
     //            << globalCells.localSize(procI) << endl;
diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMIParallelOps.C b/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMIParallelOps.C
index e67d9e6e400cde827065477af3a849195c9e272e..4a87d1c050a96deaa52782ce6aa537bec323d217 100644
--- a/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMIParallelOps.C
+++ b/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMIParallelOps.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2017 OpenFOAM Foundation
-    Copyright (C) 2018 OpenCFD Ltd.
+    Copyright (C) 2018-2020 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -76,7 +76,7 @@ void Foam::advancingFrontAMI::distributePatches
 {
     PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
 
-    for (label domain = 0; domain < Pstream::nProcs(); ++domain)
+    for (const int domain : Pstream::allProcs())
     {
         const labelList& sendElems = map.subMap()[domain];
 
@@ -132,7 +132,7 @@ void Foam::advancingFrontAMI::distributePatches
     }
 
     // Consume
-    for (label domain = 0; domain < Pstream::nProcs(); ++domain)
+    for (const int domain : Pstream::allProcs())
     {
         const labelList& recvElems = map.constructMap()[domain];
 
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/foamVtkInternalMeshWriter.C b/src/meshTools/output/foamVtkInternalMeshWriter.C
index a910aea8a79c0e6ece98990d19e29eddc787fbe3..d48b5830161ac4249368cce0cd72c4a47c343cdc 100644
--- a/src/meshTools/output/foamVtkInternalMeshWriter.C
+++ b/src/meshTools/output/foamVtkInternalMeshWriter.C
@@ -712,7 +712,7 @@ bool Foam::vtk::internalMeshWriter::writeProcIDs()
         }
 
         // Per-processor ids
-        for (label proci=0; proci < Pstream::nProcs(); ++proci)
+        for (const int proci : Pstream::allProcs())
         {
             vtk::write(format(), proci, procMaps.localSize(proci));
         }
diff --git a/src/meshTools/output/foamVtkPatchMeshWriter.C b/src/meshTools/output/foamVtkPatchMeshWriter.C
index f9536d548d90a6ce7350e1668dd10ef8ed35bb53..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);
 
@@ -697,7 +687,7 @@ bool Foam::vtk::patchMeshWriter::writeProcIDs()
         if (Pstream::master())
         {
             // Per-processor ids
-            for (label proci=0; proci < Pstream::nProcs(); ++proci)
+            for (const int proci : Pstream::allProcs())
             {
                 vtk::write(format(), proci, procSizes.localSize(proci));
             }
@@ -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/meshTools/processorLOD/box/box.C b/src/meshTools/processorLOD/box/box.C
index d7ebd5cc663ac9715d019a9a16eb1238eeffc453..4bf8dffc5fdf1b2653b4449964b87804ab292929 100644
--- a/src/meshTools/processorLOD/box/box.C
+++ b/src/meshTools/processorLOD/box/box.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2017 OpenCFD Ltd.
+    Copyright (C) 2017-2020 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -61,7 +61,7 @@ void Foam::processorLODs::box::writeBoxes
     );
 
     label verti = 0;
-    for (label proci = 0; proci < Pstream::nProcs(); ++proci)
+    for (const int proci : Pstream::allProcs())
     {
         if (proci == Pstream::myProcNo())
         {
@@ -111,7 +111,7 @@ void Foam::processorLODs::box::setRefineFlags
     PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
 
     // Identify src boxes that can be refined and send to all remote procs
-    for (label proci = 0; proci < Pstream::nProcs(); ++proci)
+    for (const int proci : Pstream::allProcs())
     {
         if (proci != Pstream::myProcNo())
         {
@@ -124,7 +124,7 @@ void Foam::processorLODs::box::setRefineFlags
 
     // Test each remote src bb with local tgt objects to identify which remote
     // src boxes can/should be refined
-    for (label proci = 0; proci < Pstream::nProcs(); ++proci)
+    for (const int proci : Pstream::allProcs())
     {
         if (proci == Pstream::myProcNo())
         {
@@ -345,7 +345,7 @@ bool Foam::processorLODs::box::doRefineBoxes
     List<DynamicList<label>> newToOld(Pstream::nProcs());
 
 
-    for (label proci = 0; proci < Pstream::nProcs(); ++proci)
+    for (const int proci : Pstream::allProcs())
     {
         if (proci == Pstream::myProcNo())
         {
diff --git a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C
index 616ecce3203c1bb5d5307bdc5c1a7dfacb27bc86..3f40b845032e0f274dad321fcf5ad71127b09930 100644
--- a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C
+++ b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C
@@ -368,7 +368,7 @@ void Foam::cellCellStencils::inverseDistance::markPatchesAsHoles
 
     // 2. Send over srcMesh bits that overlap tgt and do calculation
     pBufs.clear();
-    for (label procI = 0; procI < Pstream::nProcs(); procI++)
+    for (const int procI : Pstream::allProcs())
     {
         if (procI != Pstream::myProcNo())
         {
@@ -385,7 +385,7 @@ void Foam::cellCellStencils::inverseDistance::markPatchesAsHoles
         }
     }
     pBufs.finishedSends();
-    for (label procI = 0; procI < Pstream::nProcs(); procI++)
+    for (const int procI : Pstream::allProcs())
     {
         if (procI != Pstream::myProcNo())
         {
@@ -537,7 +537,7 @@ void Foam::cellCellStencils::inverseDistance::markDonors
     DynamicList<label> tgtOverlapProcs(Pstream::nProcs());
     // (remote) processors where the src overlaps my tgt
     DynamicList<label> srcOverlapProcs(Pstream::nProcs());
-    for (label procI = 0; procI < Pstream::nProcs(); procI++)
+    for (const int procI : Pstream::allProcs())
     {
         if (procI != Pstream::myProcNo())
         {
diff --git a/src/overset/cellCellStencil/trackingInverseDistance/trackingInverseDistanceCellCellStencil.C b/src/overset/cellCellStencil/trackingInverseDistance/trackingInverseDistanceCellCellStencil.C
index 7f643ba29e24286cd7d26b81a3cfe81f66a08ddf..b19b1b544f88839dff316591757f3f1714f8ec46 100644
--- a/src/overset/cellCellStencil/trackingInverseDistance/trackingInverseDistanceCellCellStencil.C
+++ b/src/overset/cellCellStencil/trackingInverseDistance/trackingInverseDistanceCellCellStencil.C
@@ -250,7 +250,7 @@ void Foam::cellCellStencils::trackingInverseDistance::markPatchesAsHoles
 
     // 2. Send over srcMesh bits that overlap tgt and do calculation
     pBufs.clear();
-    for (label procI = 0; procI < Pstream::nProcs(); procI++)
+    for (const int procI : Pstream::allProcs())
     {
         if (procI != Pstream::myProcNo())
         {
@@ -267,7 +267,7 @@ void Foam::cellCellStencils::trackingInverseDistance::markPatchesAsHoles
         }
     }
     pBufs.finishedSends();
-    for (label procI = 0; procI < Pstream::nProcs(); procI++)
+    for (const int procI : Pstream::allProcs())
     {
         if (procI != Pstream::myProcNo())
         {
@@ -373,7 +373,7 @@ void Foam::cellCellStencils::trackingInverseDistance::markDonors
     DynamicList<label> tgtOverlapProcs(Pstream::nProcs());
     // (remote) processors where the src overlaps my tgt
     DynamicList<label> srcOverlapProcs(Pstream::nProcs());
-    for (label procI = 0; procI < Pstream::nProcs(); procI++)
+    for (const int procI : Pstream::allProcs())
     {
         if (procI != Pstream::myProcNo())
         {
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/decompose/ptscotchDecomp/ptscotchDecomp.C b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C
index d51804c3b9220521c91b9d02f4abf6bc242901e2..c4810938ca9dde2cd962e9ba4e6fcc1c8edd9bd8 100644
--- a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C
+++ b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C
@@ -109,7 +109,7 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str)
 //    globalIndex globalCells(initxadj.size()-1);
 //
 //    bool hasZeroDomain = false;
-//    for (label proci = 0; proci < Pstream::nProcs(); proci++)
+//    for (const int proci : Pstream::allProcs())
 //    {
 //        if (globalCells.localSize(proci) == 0)
 //        {
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 66d7b22cf2f8400f93ac237326849786c56e38a9..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.
@@ -169,7 +169,7 @@ void surfaceNoise::readSurfaceData
                 p *= rhoRef_;
 
                 // Send subset of faces to each processor
-                for (label procI = 0; procI < Pstream::nProcs(); ++procI)
+                for (const int procI : Pstream::allProcs())
                 {
                     label face0 = procFaceOffset[procI];
                     label nLocalFace =
@@ -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);
diff --git a/src/sampling/meshToMesh/meshToMeshParallelOps.C b/src/sampling/meshToMesh/meshToMeshParallelOps.C
index 5b3faec2ca03da4360ab2e33eee6e7f063184eb2..0f2a393c50ede85d3aac7f8327eb0916249866de 100644
--- a/src/sampling/meshToMesh/meshToMeshParallelOps.C
+++ b/src/sampling/meshToMesh/meshToMeshParallelOps.C
@@ -322,7 +322,7 @@ void Foam::meshToMesh::distributeCells
     procLocalFaceIDs.setSize(Pstream::nProcs());;
 
 
-    for (label domain = 0; domain < Pstream::nProcs(); domain++)
+    for (const int domain : Pstream::allProcs())
     {
         const labelList& sendElems = map.subMap()[domain];
 
@@ -501,7 +501,7 @@ void Foam::meshToMesh::distributeCells
     pBufs.finishedSends();
 
     // Consume
-    for (label domain = 0; domain < Pstream::nProcs(); domain++)
+    for (const int domain : Pstream::allProcs())
     {
         const labelList& recvElems = map.constructMap()[domain];
 
diff --git a/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.C b/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.C
index f48f1081bf4b54c586978b3650ee9f120057f2f0..2288d8457a171d5f0bee1cce01727c451e0512f0 100644
--- a/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.C
+++ b/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.C
@@ -139,7 +139,7 @@ void Foam::radiation::viewFactor::initialise()
         DebugInFunction
             << "Insert elements in the matrix..." << endl;
 
-        for (label procI = 0; procI < Pstream::nProcs(); procI++)
+        for (const int procI : Pstream::allProcs())
         {
             insertMatrixElements
             (