diff --git a/applications/utilities/parallelProcessing/redistributePar/parLagrangianDistributorTemplates.C b/applications/utilities/parallelProcessing/redistributePar/parLagrangianDistributorTemplates.C index bf786a2912..a04291d961 100644 --- a/applications/utilities/parallelProcessing/redistributePar/parLagrangianDistributorTemplates.C +++ b/applications/utilities/parallelProcessing/redistributePar/parLagrangianDistributorTemplates.C @@ -84,15 +84,32 @@ Foam::label Foam::parLagrangianDistributor::distributeFields ) ); + + bool reconstruct = false; + label nFields = 0; for (const word& objectName : fieldNames) { if (!nFields) { - Info<< " Distributing lagrangian " - << fieldType::typeName << "s\n" << endl; + // Performing an all-to-one (reconstruct)? + reconstruct = returnReduce + ( + (!map.constructSize() || Pstream::master()), + andOp() + ); } - Info<< " " << objectName << endl; + + if (verbose_) + { + if (!nFields) + { + Info<< " Distributing lagrangian " + << fieldType::typeName << "s\n" << nl; + } + Info<< " " << objectName << nl; + } + ++nFields; // Read if present IOField field @@ -128,7 +145,7 @@ Foam::label Foam::parLagrangianDistributor::distributeFields { IOField(fieldIO, std::move(field)).write(); } - else + else if (!reconstruct) { // When running with -overwrite it should also delete the old // files. Below works but is not optimal. @@ -138,6 +155,7 @@ Foam::label Foam::parLagrangianDistributor::distributeFields } } + if (nFields && verbose_) Info<< endl; return nFields; } @@ -174,9 +192,21 @@ Foam::label Foam::parLagrangianDistributor::distributeFieldFields ) ); + bool reconstruct = false; + label nFields = 0; for (const word& objectName : fieldNames) { + if (!nFields) + { + // Performing an all-to-one (reconstruct)? + reconstruct = returnReduce + ( + (!map.constructSize() || Pstream::master()), + andOp() + ); + } + if (verbose_) { if (!nFields) @@ -227,7 +257,7 @@ Foam::label Foam::parLagrangianDistributor::distributeFieldFields std::move(field) ).write(); } - else + else if (!reconstruct) { // When running with -overwrite it should also delete the old // files. Below works but is not optimal. @@ -309,19 +339,31 @@ Foam::label Foam::parLagrangianDistributor::distributeStoredFields cloud.lookupClass() ); + bool reconstruct = false; + label nFields = 0; forAllIters(fields, iter) { Container& field = *(iter.val()); + if (!nFields) + { + // Performing an all-to-one (reconstruct)? + reconstruct = returnReduce + ( + (!map.constructSize() || Pstream::master()), + andOp() + ); + } + if (verbose_) { if (!nFields) { Info<< " Distributing lagrangian " - << Container::typeName << "s\n" << endl; + << Container::typeName << "s\n" << nl; } - Info<< " " << field.name() << endl; + Info<< " " << field.name() << nl; } ++nFields; @@ -342,7 +384,7 @@ Foam::label Foam::parLagrangianDistributor::distributeStoredFields { Container(fieldIO, std::move(field)).write(); } - else + else if (!reconstruct) { // When running with -overwrite it should also delete the old // files. Below works but is not optimal. diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index 15e57b0bef..1ab22c7c92 100644 --- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -147,7 +147,7 @@ void createTimeDirs(const fileName& path) //Pout<< "Time:" << t << nl // << " raw :" << timePath << nl // << endl; - mkDir(timePath); + Foam::mkDir(timePath); } } @@ -1141,19 +1141,14 @@ int main(int argc, char *argv[]) Info<< "Reconstructing case (like reconstructParMesh)" << nl << endl; } - - if (decompose || reconstruct) + if ((decompose || reconstruct) && !overwrite) { - if (!overwrite) - { - WarningInFunction - << "Working in decompose or reconstruction mode automatically" - << " implies -overwrite" << nl << endl; - overwrite = true; - } + overwrite = true; + WarningInFunction + << "Working in -decompose or -reconstruct mode:" + " automatically implies -overwrite" << nl << endl; } - if (!Pstream::parRun()) { FatalErrorInFunction @@ -1162,7 +1157,7 @@ int main(int argc, char *argv[]) } - if (!isDir(args.rootPath())) + if (!Foam::isDir(args.rootPath())) { FatalErrorInFunction << ": cannot open root directory " << args.rootPath() @@ -1188,7 +1183,7 @@ int main(int argc, char *argv[]) // want to delay constructing runTime until we've synced all time // directories... const fileName procDir(fileHandler().filePath(args.path())); - if (isDir(procDir)) + if (Foam::isDir(procDir)) { if (decompose) { @@ -2446,7 +2441,7 @@ int main(int argc, char *argv[]) // Remove dummy mesh created by loadOrCreateMesh const bool oldParRun = Pstream::parRun(false); mesh.removeFiles(); - rmDir(mesh.objectRegistry::objectPath()); + Foam::rmDir(mesh.objectRegistry::objectPath()); Pstream::parRun(oldParRun); // Restore parallel state } }