ENH: add UPstream::subProcs() static method

- returns a range of `int` values that can be iterated across.
  For example,

      for (const int proci : Pstream::subProcs()) { ... }

  instead of

      for
      (
          int proci = Pstream::firstSlave();
          proci <= Pstream::lastSlave();
          ++proci
      )
      {
          ...
      }
This commit is contained in:
Mark Olesen
2020-09-28 11:57:40 +02:00
parent e18ff114a6
commit 5dc5ea928a
43 changed files with 140 additions and 398 deletions

View File

@ -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])
{

View File

@ -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;