From 92214eb4af7b875dd56a81932fcb1793923dac93 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 11 Feb 2020 17:36:05 +0100 Subject: [PATCH 1/8] CONFIG: misedit of csh mpi settings with foamConfigurePaths --- bin/tools/foamConfigurePaths | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/tools/foamConfigurePaths b/bin/tools/foamConfigurePaths index b267a235e2..7bdf40d98d 100755 --- a/bin/tools/foamConfigurePaths +++ b/bin/tools/foamConfigurePaths @@ -416,7 +416,7 @@ do # Explicitly set WM_MPLIB=... optionValue=$(getOptionValue "$@") replace etc/bashrc WM_MPLIB "$optionValue" - replaceCsh etc/bashrc WM_MPLIB "$optionValue" + replaceCsh etc/cshrc WM_MPLIB "$optionValue" optMpi=system adjusted=true shift From a65b9fdd7c557be21f56459037fb847cae7c2932 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 12 Feb 2020 21:34:59 +0100 Subject: [PATCH 2/8] BUG: file format mangled by collated format (fixes #1587) - incorrectly set BINARY format in the construction of the received data (a side-effect of the parameter ordering). Now use the same default parameters as IFstream and set the correct filename subsequent to construction. --- .../masterUncollatedFileOperation.C | 54 +++++++++---------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C index 2796a2c3ca..5e833dd073 100644 --- a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C +++ b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017-2018 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -723,17 +723,15 @@ Foam::fileOperations::masterUncollatedFileOperation::read Pout<< "masterUncollatedFileOperation::readStream :" << " Done reading " << buf.size() << " bytes" << endl; } - const fileName& fName = filePaths[Pstream::myProcNo(comm)]; - isPtr.reset - ( - new IListStream - ( - std::move(buf), - IOstream::BINARY, - IOstream::currentVersion, - fName - ) - ); + + // A local character buffer copy of the Pstream contents. + // Construct with same parameters (ASCII, current version) + // as the IFstream so that it has the same characteristics. + + isPtr.reset(new IListStream(std::move(buf))); + + // With the proper file name + isPtr->name() = filePaths[Pstream::myProcNo(comm)]; if (!io.readHeader(isPtr())) { @@ -2415,6 +2413,8 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream const fileName& filePath ) const { + autoPtr isPtr; + if (Pstream::parRun()) { // Insert logic of filePath. We assume that if a file is absolute @@ -2497,10 +2497,7 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream if (Pstream::master(Pstream::worldComm)) { // Read myself - return autoPtr - ( - new IFstream(filePaths[Pstream::masterNo()]) - ); + isPtr.reset(new IFstream(filePaths[Pstream::masterNo()])); } else { @@ -2522,26 +2519,23 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream << " Done reading " << buf.size() << " bytes" << endl; } - // Note: IPstream is not an IStream so use a IStringStream to - // convert the buffer. Note that we construct with a string - // so it holds a copy of the buffer. - return autoPtr - ( - new IListStream - ( - std::move(buf), - IOstream::BINARY, - IOstream::currentVersion, - filePath - ) - ); + // A local character buffer copy of the Pstream contents. + // Construct with same parameters (ASCII, current version) + // as the IFstream so that it has the same characteristics. + + isPtr.reset(new IListStream(std::move(buf))); + + // With the proper file name + isPtr->name() = filePath; } } else { // Read myself - return autoPtr(new IFstream(filePath)); + isPtr.reset(new IFstream(filePath)); } + + return isPtr; } From 79cf72d5735ebf3301b04abcc25c3b5d1d6b83ba Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 14 Feb 2020 15:44:03 +0100 Subject: [PATCH 3/8] BUG: foamListTimes does not remove collated directories (fixes #1588) - also now report any verbosity on stderr - fix similar collated directories issue for foamRestoreFields --- .../foamListTimes/foamListTimes.C | 81 +++++++++---- .../foamRestoreFields/foamRestoreFields.C | 111 ++++++++++++++++-- 2 files changed, 159 insertions(+), 33 deletions(-) diff --git a/applications/utilities/miscellaneous/foamListTimes/foamListTimes.C b/applications/utilities/miscellaneous/foamListTimes/foamListTimes.C index 4cae459e9c..d7469d9f05 100644 --- a/applications/utilities/miscellaneous/foamListTimes/foamListTimes.C +++ b/applications/utilities/miscellaneous/foamListTimes/foamListTimes.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,7 +39,7 @@ Usage Options: - \par -processor - List times from processor0/ directory + Times from processor0/ directory - \par -rm Remove selected time directories @@ -58,9 +58,30 @@ Note #include "profiling.H" #include "timeSelector.H" #include "TimePaths.H" +#include "ListOps.H" +#include "stringOps.H" using namespace Foam; +// Many ways to name processor directories +// +// Uncollated | "processor0", "processor1" ... +// Collated (old) | "processors" +// Collated (new) | "processors" +// Host collated | "processors_-" + +const regExp matcher("processors?[0-9]+(_[0-9]+-[0-9]+)?"); + +bool isProcessorDir(const string& dir) +{ + return + ( + dir.starts_with("processor") + && (dir == "processors" || matcher.match(dir)) + ); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) @@ -95,7 +116,7 @@ int main(int argc, char *argv[]) #include "setRootCase.H" const bool removeFiles(args.found("rm")); - const bool verbose(args.found("verbose")); + bool verbose(args.found("verbose")); // Get times list from the master processor and subset based on @@ -116,6 +137,7 @@ int main(int argc, char *argv[]) << exit(FatalError); } + // Obtain time directory names from "processor0/" only timePaths = autoPtr::New ( args.rootPath(), @@ -140,10 +162,34 @@ int main(int argc, char *argv[]) { if (nProcs) { + fileNameList procDirs + ( + Foam::readDir + ( + args.path(), + fileName::DIRECTORY, + false, // No gzip anyhow + false // Do not follow linkts + ) + ); + + inplaceSubsetList(procDirs, isProcessorDir); + + // Perhaps not needed + /// Foam::sort(procDirs, stringOps::natural_sort()); + if (verbose) { - Info<< "Removing " << nTimes - << " processor time directories" << endl; + InfoErr + << "Removing " << nTimes + << " times in " << procDirs.size() + << " processor directories" << endl; + } + + // No processor directories? - silence verbosity + if (procDirs.empty()) + { + verbose = false; } forAllReverse(timeDirs, timei) @@ -152,25 +198,15 @@ int main(int argc, char *argv[]) if (verbose) { - Info<< " rm " << timeName + InfoErr + << " rm " << timeName << " [" << (nTimes - timei) << '/' << nTimes << ']' << endl; } - fileName path(args.path()/"processors"/timeName); - - rmDir(path, true); - - for (label proci=0; proci" +// Host collated | "processors_-" + +const regExp matcher("processors?[0-9]+(_[0-9]+-[0-9]+)?"); + +bool isProcessorDir(const string& dir) +{ + return + ( + dir.starts_with("processor") + && (dir == "processors" || matcher.match(dir)) + ); +} + + //- The known and support types of operations enum restoreMethod { @@ -311,7 +332,6 @@ int main(int argc, char *argv[]) } // Obtain time directory names from "processor0/" only - timePaths = autoPtr::New ( args.rootPath(), @@ -329,10 +349,77 @@ int main(int argc, char *argv[]) const instantList timeDirs(timeSelector::select(timePaths->times(), args)); + fileNameList procDirs; + label leadProcIdx = -1; + if (timeDirs.empty()) { - Info<< "no times selected" << nl; + Info<< "No times selected" << nl; } + else if (nProcs) + { + procDirs = + Foam::readDir + ( + args.path(), + fileName::DIRECTORY, + false, // No gzip anyhow + false // Do not follow linkts + ); + + inplaceSubsetList(procDirs, isProcessorDir); + + // Perhaps not needed + Foam::sort(procDirs, stringOps::natural_sort()); + + // Decide who will be the "leading" processor for obtaining names + // - processor0 + // - processors + // - processors_0- + + // Uncollated + leadProcIdx = procDirs.find("processor0"); + + if (!procDirs.empty()) + { + if (leadProcIdx < 0) + { + // Collated (old) + leadProcIdx = procDirs.find("processors"); + } + + if (leadProcIdx < 0) + { + // Collated (new) + leadProcIdx = procDirs.find("processors" + Foam::name(nProcs)); + } + + if (leadProcIdx < 0) + { + // Host-collated + const std::string prefix + ( + "processors" + Foam::name(nProcs) + "_0-" + ); + + forAll(procDirs, idx) + { + if (procDirs[idx].starts_with(prefix)) + { + leadProcIdx = idx; + break; + } + } + } + + // Just default to anything (safety) + if (leadProcIdx < 0) + { + leadProcIdx = 0; + } + } + } + for (const instant& t : timeDirs) { @@ -341,28 +428,28 @@ int main(int argc, char *argv[]) Info<< "\nTime = " << timeName << nl; label count = 0; + wordList files; if (nProcs) { - const wordHashSet files - ( - getFiles(args.path()/"processor0", timeName) - ); + if (leadProcIdx >= 0) + { + files = getFiles(args.path()/procDirs[leadProcIdx], timeName); + } - for (label proci=0; proci < nProcs; ++proci) + for (const fileName& procDir : procDirs) { count += restoreFields ( method, - args.path()/("processor" + Foam::name(proci))/timeName, - files, + args.path()/procDir/timeName, + wordHashSet(files), targetNames ); } } else { - wordList files; if (Pstream::master()) { files = getFiles(args.path(), timeName); From ca28377642e5a7d00daaf3b2b1151836fd88ae21 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Tue, 3 Mar 2020 11:16:53 +0000 Subject: [PATCH 4/8] BUG: Resolve circular call to ::write(Ostream&). See #1617 --- .../gradientEnergy/gradientEnergyFvPatchScalarField.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnergy/gradientEnergyFvPatchScalarField.C b/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnergy/gradientEnergyFvPatchScalarField.C index 7866817302..75192df266 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnergy/gradientEnergyFvPatchScalarField.C +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnergy/gradientEnergyFvPatchScalarField.C @@ -122,7 +122,7 @@ void Foam::gradientEnergyFvPatchScalarField::updateCoeffs() void Foam::gradientEnergyFvPatchScalarField::write(Ostream& os) const { fixedGradientFvPatchScalarField::write(os); - os.writeEntry("value", *this); + this->writeEntry("value", os); } From 6f230a8b674535ab9a9ade57b026016d21f4d7f3 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Tue, 3 Mar 2020 17:00:20 +0000 Subject: [PATCH 5/8] COMP: Corrections for icc compiler. Fixes #1608 --- .../wallBoundedStreamLine/wallBoundedParticleTemplates.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticleTemplates.C b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticleTemplates.C index d3971611f7..e331976d21 100644 --- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticleTemplates.C +++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticleTemplates.C @@ -118,7 +118,7 @@ Foam::scalar Foam::wallBoundedParticle::trackToEdge { label nbrCelli = ( - cell() == mesh().faceOwner()[face()] + this->cell() == mesh().faceOwner()[face()] ? mesh().faceNeighbour()[face()] : mesh().faceOwner()[face()] ); @@ -135,7 +135,7 @@ Foam::scalar Foam::wallBoundedParticle::trackToEdge // Change into nbrCell. No need to change tetFace, tetPt. //Pout<< " crossed from cell:" << celli_ // << " into " << nbrCelli << endl; - cell() = nbrCelli; + this->cell() = nbrCelli; patchInteraction(cloud, td, trackFraction); } else From 418248709f5a45783f739b5d6d495128a2c03d93 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Wed, 11 Mar 2020 17:47:19 +0000 Subject: [PATCH 6/8] BUG: Corrected update of T field for energyJump[AMI]FvPatchScalarField. See #1624 --- .../energyJump/energyJump/energyJumpFvPatchScalarField.C | 2 +- .../energyJump/energyJumpAMI/energyJumpAMIFvPatchScalarField.C | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/energyJump/energyJump/energyJumpFvPatchScalarField.C b/src/thermophysicalModels/basic/derivedFvPatchFields/energyJump/energyJump/energyJumpFvPatchScalarField.C index 2caa26dcae..7ccaecc93f 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/energyJump/energyJump/energyJumpFvPatchScalarField.C +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/energyJump/energyJump/energyJumpFvPatchScalarField.C @@ -121,7 +121,7 @@ void Foam::energyJumpFvPatchScalarField::updateCoeffs() const_cast(TbPatch); // force update of jump - Tbp.updateCoeffs(); + Tbp.evaluate(Pstream::commsTypes::blocking); const labelUList& faceCells = this->patch().faceCells(); diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/energyJump/energyJumpAMI/energyJumpAMIFvPatchScalarField.C b/src/thermophysicalModels/basic/derivedFvPatchFields/energyJump/energyJumpAMI/energyJumpAMIFvPatchScalarField.C index 42b86a8c0e..ba45de7efd 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/energyJump/energyJumpAMI/energyJumpAMIFvPatchScalarField.C +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/energyJump/energyJumpAMI/energyJumpAMIFvPatchScalarField.C @@ -121,7 +121,7 @@ void Foam::energyJumpAMIFvPatchScalarField::updateCoeffs() const_cast(TbPatch); // force update of jump - Tbp.updateCoeffs(); + Tbp.evaluate(Pstream::commsTypes::blocking); const labelUList& faceCells = this->patch().faceCells(); From 161c66df17888b44df3d101b3afcea15d388e3cb Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 12 Mar 2020 11:09:23 +0100 Subject: [PATCH 7/8] BUG: incorrect EnSight lagrangian fields in parallel (fixes #1629) --- .../conversion/ensight/ensightOutputCloudTemplates.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloudTemplates.C b/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloudTemplates.C index 80c23c414c..497484178e 100644 --- a/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloudTemplates.C +++ b/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloudTemplates.C @@ -76,7 +76,7 @@ bool Foam::ensightOutput::writeCloudField IPstream fromSlave(comm, slave); Field recv(fromSlave); - for (Type val : field) // <-- working on a copy + for (Type val : recv) // <-- working on a copy { if (mag(val) < 1e-90) // approximately root(ROOTVSMALL) { From 28d24fefbca4cf5177b0b53bea591525b6dceffd Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 12 Mar 2020 11:34:14 +0100 Subject: [PATCH 8/8] CONFIG: bump patch level --- META-INFO/api-info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/META-INFO/api-info b/META-INFO/api-info index cc89bc1cef..9614623e84 100644 --- a/META-INFO/api-info +++ b/META-INFO/api-info @@ -1,2 +1,2 @@ api=1912 -patch=200129 +patch=200312