From 68a024778e5401af6a41c11a1a44f1ddf6812050 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Wed, 20 Jul 2016 18:50:58 +0100 Subject: [PATCH] decomposePar, reconstructPar: Added support for decomposing "uniform" directories in multi-region cases Resolves bug-report http://bugs.openfoam.org/view.php?id=2156 --- .../decomposePar/decomposePar.C | 114 +++++++++++------- .../reconstructPar/reconstructPar.C | 59 +++++---- 2 files changed, 105 insertions(+), 68 deletions(-) diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index ee8c4f0d9..cb7b4b5e8 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -101,6 +101,9 @@ Usage // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +namespace Foam +{ + const labelIOList& procAddressing ( const PtrList& procMeshList, @@ -135,6 +138,61 @@ const labelIOList& procAddressing } +void decomposeUniform +( + const bool copyUniform, + const domainDecomposition& mesh, + const Time& processorDb, + const word& regionDir = word::null +) +{ + const Time& runTime = mesh.time(); + + // Any uniform data to copy/link? + const fileName uniformDir(regionDir/"uniform"); + + if (isDir(runTime.timePath()/uniformDir)) + { + Info<< "Detected additional non-decomposed files in " + << runTime.timePath()/uniformDir + << endl; + + const fileName timePath = processorDb.timePath(); + + if (copyUniform || mesh.distributed()) + { + cp + ( + runTime.timePath()/uniformDir, + timePath/uniformDir + ); + } + else + { + // link with relative paths + string parentPath = string("..")/".."; + + if (regionDir != word::null) + { + parentPath = parentPath/".."; + } + + fileName currentDir(cwd()); + chDir(timePath); + ln + ( + parentPath/runTime.timeName()/uniformDir, + uniformDir + ); + chDir(currentDir); + } + } +} + +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { @@ -237,10 +295,10 @@ int main(int argc, char *argv[]) - forAll(regionNames, regionI) + forAll(regionNames, regioni) { - const word& regionName = regionNames[regionI]; - const word& regionDir = regionDirs[regionI]; + const word& regionName = regionNames[regioni]; + const word& regionDir = regionDirs[regioni]; Info<< "\n\nDecomposing mesh " << regionName << nl << endl; @@ -779,21 +837,6 @@ int main(int argc, char *argv[]) lagrangianTensorFields.setSize(cloudI); lagrangianTensorFieldFields.setSize(cloudI); - - // Any uniform data to copy/link? - fileName uniformDir("uniform"); - - if (isDir(runTime.timePath()/uniformDir)) - { - Info<< "Detected additional non-decomposed files in " - << runTime.timePath()/uniformDir - << endl; - } - else - { - uniformDir.clear(); - } - Info<< endl; // split the fields over processors @@ -1074,38 +1117,17 @@ int main(int argc, char *argv[]) } } + // Decompose the "uniform" directory in the time region + // directory + decomposeUniform(copyUniform, mesh, processorDb, regionDir); - // Any non-decomposed data to copy? - if (uniformDir.size()) + // For the first region of a multi-region case additionally + // decompose the "uniform" directory in the time directory + if (regionNames.size() > 1 && regioni == 0) { - const fileName timePath = processorDb.timePath(); - - if (copyUniform || mesh.distributed()) - { - cp - ( - runTime.timePath()/uniformDir, - timePath/uniformDir - ); - } - else - { - // link with relative paths - const string parentPath = string("..")/".."; - - fileName currentDir(cwd()); - chDir(timePath); - ln - ( - parentPath/runTime.timeName()/uniformDir, - uniformDir - ); - chDir(currentDir); - } + decomposeUniform(copyUniform, mesh, processorDb); } - - // We have cached all the constant mesh data for the current // processor. This is only important if running with multiple // times, otherwise it is just extra storage. diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C index 3c2aa5d02..4914b0ae6 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C @@ -56,9 +56,9 @@ bool haveAllTimes ) { // Loop over all times - forAll(timeDirs, timeI) + forAll(timeDirs, timei) { - if (!masterTimeDirSet.found(timeDirs[timeI].name())) + if (!masterTimeDirSet.found(timeDirs[timei].name())) { return false; } @@ -284,10 +284,10 @@ int main(int argc, char *argv[]) } - forAll(regionNames, regionI) + forAll(regionNames, regioni) { - const word& regionName = regionNames[regionI]; - const word& regionDir = regionDirs[regionI]; + const word& regionName = regionNames[regioni]; + const word& regionDir = regionDirs[regioni]; Info<< "\n\nReconstructing fields for mesh " << regionName << nl << endl; @@ -328,25 +328,25 @@ int main(int argc, char *argv[]) #include "checkFaceAddressingComp.H" // Loop over all times - forAll(timeDirs, timeI) + forAll(timeDirs, timei) { - if (newTimes && masterTimeDirSet.found(timeDirs[timeI].name())) + if (newTimes && masterTimeDirSet.found(timeDirs[timei].name())) { - Info<< "Skipping time " << timeDirs[timeI].name() + Info<< "Skipping time " << timeDirs[timei].name() << endl << endl; continue; } // Set time for global database - runTime.setTime(timeDirs[timeI], timeI); + runTime.setTime(timeDirs[timei], timei); Info<< "Time = " << runTime.timeName() << endl << endl; // Set time for all databases forAll(databases, proci) { - databases[proci].setTime(timeDirs[timeI], timeI); + databases[proci].setTime(timeDirs[timei], timei); } // Check if any new meshes need to be read. @@ -989,20 +989,35 @@ int main(int argc, char *argv[]) procRefs ).write(); } - } - } - // If there are any "uniform" directories copy them from - // the master processor - forAll(timeDirs, timeI) - { - runTime.setTime(timeDirs[timeI], timeI); - databases[0].setTime(timeDirs[timeI], timeI); + // If there is a "uniform" directory in the time region + // directory copy from the master processor + { + fileName uniformDir0 + ( + databases[0].timePath()/regionDir/"uniform" + ); - fileName uniformDir0 = databases[0].timePath()/"uniform"; - if (isDir(uniformDir0)) - { - cp(uniformDir0, runTime.timePath()); + if (isDir(uniformDir0)) + { + cp(uniformDir0, runTime.timePath()/regionDir); + } + } + + // For the first region of a multi-region case additionally + // copy the "uniform" directory in the time directory + if (regionNames.size() > 1 && regioni == 0) + { + fileName uniformDir0 + ( + databases[0].timePath()/"uniform" + ); + + if (isDir(uniformDir0)) + { + cp(uniformDir0, runTime.timePath()); + } + } } }