decomposePar, reconstructPar: Added support for decomposing "uniform" directories in multi-region cases

Resolves bug-report http://bugs.openfoam.org/view.php?id=2156
This commit is contained in:
Henry Weller 2016-07-20 18:50:58 +01:00
parent eab6e3199d
commit 68a024778e
2 changed files with 105 additions and 68 deletions

View file

@ -101,6 +101,9 @@ Usage
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
const labelIOList& procAddressing
(
const PtrList<fvMesh>& 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.

View file

@ -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());
}
}
}
}