mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -157,8 +157,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
|
||||
|
||||
if (!haveMesh)
|
||||
{
|
||||
const bool oldParRun = Pstream::parRun();
|
||||
Pstream::parRun() = false;
|
||||
const bool oldParRun = Pstream::parRun(false);
|
||||
|
||||
|
||||
// Create dummy mesh. Only used on procs that don't have mesh.
|
||||
@ -241,7 +240,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
|
||||
// << endl;
|
||||
dummyMesh.write();
|
||||
|
||||
Pstream::parRun() = oldParRun;
|
||||
Pstream::parRun(oldParRun); // Restore parallel state
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2425,10 +2425,9 @@ int main(int argc, char *argv[])
|
||||
instantList timeDirs;
|
||||
if (Pstream::master())
|
||||
{
|
||||
const bool oldParRun = Pstream::parRun();
|
||||
Pstream::parRun() = false;
|
||||
const bool oldParRun = Pstream::parRun(false);
|
||||
timeDirs = Time::findTimes(args.path(), "constant");
|
||||
Pstream::parRun() = oldParRun;
|
||||
Pstream::parRun(oldParRun); // Restore parallel state
|
||||
}
|
||||
Pstream::scatter(timeDirs);
|
||||
for (const instant& t : timeDirs)
|
||||
@ -2464,10 +2463,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
const bool oldParRun = Pstream::parRun();
|
||||
Pstream::parRun() = false;
|
||||
const bool oldParRun = Pstream::parRun(false);
|
||||
timeDirs = Time::findTimes(basePath, "constant");
|
||||
Pstream::parRun() = oldParRun;
|
||||
Pstream::parRun(oldParRun); // Restore parallel state
|
||||
}
|
||||
Pstream::scatter(timeDirs);
|
||||
for (const instant& t : timeDirs)
|
||||
@ -3038,11 +3036,10 @@ int main(int argc, char *argv[])
|
||||
if (!Pstream::master() && !haveMesh[Pstream::myProcNo()])
|
||||
{
|
||||
// Remove dummy mesh created by loadOrCreateMesh
|
||||
const bool oldParRun = Pstream::parRun();
|
||||
Pstream::parRun() = false;
|
||||
const bool oldParRun = Pstream::parRun(false);
|
||||
mesh.removeFiles();
|
||||
rmDir(mesh.objectRegistry::objectPath());
|
||||
Pstream::parRun() = oldParRun;
|
||||
Pstream::parRun(oldParRun); // Restore parallel state
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user