decomposePar changes

* improved error checking for the -fields option
 * allow -lazy and -force combination
This commit is contained in:
Mark Olesen
2008-07-03 09:46:44 +02:00
parent 7d9f709ecc
commit e9a0d8147d
2 changed files with 103 additions and 102 deletions

View File

@ -48,15 +48,15 @@ Usage
@param -force \n @param -force \n
Remove any existing @a processor subdirectories before decomposing the Remove any existing @a processor subdirectories before decomposing the
geometry. Has precedence over the @a -lazy option. geometry.
@param -lazy \n @param -lazy \n
Only decompose the geometry if the number of domains has changed Only decompose the geometry if the number of domains has changed from a
from a previous decomposition. Any existing @a processor subdirectories previous decomposition. No @a processor subdirectories will be removed
are removed as necessary. This option can be used to avoid redundant unless the @a -force option is also specified. This option can be used
geometry decomposition (eg, in scripts), but should be used with caution to avoid redundant geometry decomposition (eg, in scripts), but should
when the underlying (serial) geometry or the decomposition method etc be used with caution when the underlying (serial) geometry or the
have been changed between decompositions. decomposition method etc. have been changed between decompositions.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -110,83 +110,84 @@ int main(int argc, char *argv[])
++nProcs; ++nProcs;
} }
// Check for previously decomposed case first // get requested numberOfSubdomains
label nDomains = 0;
{
IOdictionary decompDict
(
IOobject
(
"decomposeParDict",
runTime.time().system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
decompDict.lookup("numberOfSubdomains") >> nDomains;
}
if (decomposeFieldsOnly) if (decomposeFieldsOnly)
{ {
if (!nProcs) // Sanity check on previously decomposed case
if (nProcs != nDomains)
{ {
FatalErrorIn(args.executable()) FatalErrorIn(args.executable())
<< "Specifying -fields requires a decomposed geometry!" << "Specified -fields, but the case was decomposed with "
<< nProcs << " domains"
<< nl
<< "instead of " << nDomains
<< " domains as specified in decomposeParDict"
<< nl << nl
<< exit(FatalError); << exit(FatalError);
} }
} }
else else if (nProcs)
{ {
if (nProcs) bool procDirsProblem = true;
if (lazyDecomposition && nProcs == nDomains)
{ {
bool hasProcDirs = true; // we can reuse the decomposition
decomposeFieldsOnly = true;
procDirsProblem = false;
forceOverwrite = false;
if (forceOverwrite) Info<< "Using existing processor directories" << nl;
}
if (forceOverwrite)
{
Info<< "Removing " << nProcs
<< " existing processor directories" << endl;
// remove existing processor dirs
// reverse order to avoid gaps if someone interrupts the process
for (label procI = nProcs-1; procI >= 0; --procI)
{ {
Info<< "Removing " << nProcs fileName procDir
<< " existing processor directories" << endl;
// remove existing processor dirs
for (label procI = nProcs-1; procI >= 0; --procI)
{
fileName procDir
(
runTime.path()/(word("processor") + name(procI))
);
rmDir(procDir);
}
hasProcDirs = false;
}
else if (lazyDecomposition)
{
// lazy decomposition
IOdictionary decompDict
( (
IOobject runTime.path()/(word("processor") + name(procI))
(
"decomposeParDict",
runTime.time().system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
); );
label nDomains rmDir(procDir);
(
readInt(decompDict.lookup("numberOfSubdomains"))
);
// avoid repeated decomposition
if (nDomains == nProcs)
{
decomposeFieldsOnly = true;
hasProcDirs = false;
Info<< "Using existing processor directories" << nl;
}
} }
if (hasProcDirs) procDirsProblem = false;
{ }
FatalErrorIn(args.executable())
<< "Case is already decomposed with " << nProcs if (procDirsProblem)
<< " domains, use the -force option or manually" << nl {
<< "remove processor directories before decomposing. e.g.," FatalErrorIn(args.executable())
<< nl << "Case is already decomposed with " << nProcs
<< " rm -rf " << runTime.path().c_str() << "/processor*" << " domains, use the -force option or manually" << nl
<< nl << "remove processor directories before decomposing. e.g.,"
<< exit(FatalError); << nl
} << " rm -rf " << runTime.path().c_str() << "/processor*"
<< nl
<< exit(FatalError);
} }
} }

View File

@ -1,61 +1,61 @@
// Mesh decomposition control dictionary /*-------------------------------*- C++ -*---------------------------------*\
| ========= |
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | \\ / OpenFOAM |
| \\ / |
| \\ / The Open Source CFD Toolbox |
| \\/ http://www.OpenFOAM.org |
\*-------------------------------------------------------------------------*/
FoamFile FoamFile
{ {
version 0.5; version 2.0;
format ascii; format ascii;
class dictionary;
root "ROOT"; note "mesh decomposition control dictionary";
case "CASE"; location "system";
instance "system"; object decomposeParDict;
local "";
class dictionary;
object decompositionDict;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 4; numberOfSubdomains 4;
//preservePatches (inlet); // preservePatches (inlet);
//preserveFaceZones (heater solid1 solid3); // preserveFaceZones (heater solid1 solid3);
method simple; method simple;
//method hierarchical; // method hierarchical;
//method metis; // method metis;
//method manual; // method manual;
simpleCoeffs simpleCoeffs
{ {
n (2 2 1); n (2 2 1);
delta 0.001; delta 0.001;
} }
hierarchicalCoeffs hierarchicalCoeffs
{ {
n (2 2 1); n (2 2 1);
delta 0.001; delta 0.001;
order xyz; order xyz;
} }
metisCoeffs metisCoeffs
{ {
//processorWeights /*
//( processorWeights
// 1 (
// 1 1
// 1 1
// 1 1
//); 1
);
*/
} }
manualCoeffs manualCoeffs
{ {
dataFile "decompositionData"; dataFile "decompositionData";
} }
// ************************************************************************* // // ************************************************************************* //