ENH: add UPstream::parRun(const bool)

- slightly neater code when disabling/restoring parallel state

  New
      const bool oldParRun = Pstream::parRun(false);
      ...
      Pstream::parRun(oldParRun);

  Old
      const bool oldParRun = Pstream::parRun();
      Pstream::parRun() = false;
      ...
      Pstream::parRun() = oldParRun;
This commit is contained in:
Mark Olesen
2020-10-08 18:33:17 +02:00
parent ea0de58bbf
commit 9c7aa9727a
12 changed files with 56 additions and 59 deletions

View File

@ -1951,8 +1951,8 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
// What to send to neighbouring domains
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool oldParRun = UPstream::parRun();
UPstream::parRun() = false;
// Disable parallel.
const bool oldParRun = UPstream::parRun(false);
forAll(nSendCells, recvProc)
{
@ -2162,7 +2162,7 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
}
UPstream::parRun() = oldParRun;
UPstream::parRun(oldParRun); // Restore parallel state
// Start sending&receiving from buffers
@ -2279,8 +2279,8 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
// Receive and add what was sent
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
oldParRun = UPstream::parRun();
UPstream::parRun() = false;
// Disable parallel. Original state already known.
UPstream::parRun(false);
forAll(nRevcCells, sendProc)
{
@ -2697,7 +2697,8 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
}
}
UPstream::parRun() = oldParRun;
UPstream::parRun(oldParRun); // Restore parallel state
// Print a bit.
if (debug)