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,44 +110,9 @@ int main(int argc, char *argv[])
++nProcs; ++nProcs;
} }
// Check for previously decomposed case first // get requested numberOfSubdomains
if (decomposeFieldsOnly) label nDomains = 0;
{ {
if (!nProcs)
{
FatalErrorIn(args.executable())
<< "Specifying -fields requires a decomposed geometry!"
<< nl
<< exit(FatalError);
}
}
else
{
if (nProcs)
{
bool hasProcDirs = true;
if (forceOverwrite)
{
Info<< "Removing " << nProcs
<< " 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 IOdictionary decompDict
( (
IOobject IOobject
@ -161,22 +126,59 @@ int main(int argc, char *argv[])
) )
); );
label nDomains decompDict.lookup("numberOfSubdomains") >> nDomains;
( }
readInt(decompDict.lookup("numberOfSubdomains"))
);
// avoid repeated decomposition if (decomposeFieldsOnly)
if (nDomains == nProcs)
{ {
// Sanity check on previously decomposed case
if (nProcs != nDomains)
{
FatalErrorIn(args.executable())
<< "Specified -fields, but the case was decomposed with "
<< nProcs << " domains"
<< nl
<< "instead of " << nDomains
<< " domains as specified in decomposeParDict"
<< nl
<< exit(FatalError);
}
}
else if (nProcs)
{
bool procDirsProblem = true;
if (lazyDecomposition && nProcs == nDomains)
{
// we can reuse the decomposition
decomposeFieldsOnly = true; decomposeFieldsOnly = true;
hasProcDirs = false; procDirsProblem = false;
forceOverwrite = false;
Info<< "Using existing processor directories" << nl; 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)
{
fileName procDir
(
runTime.path()/(word("processor") + name(procI))
);
rmDir(procDir);
} }
if (hasProcDirs) procDirsProblem = false;
}
if (procDirsProblem)
{ {
FatalErrorIn(args.executable()) FatalErrorIn(args.executable())
<< "Case is already decomposed with " << nProcs << "Case is already decomposed with " << nProcs
@ -188,7 +190,6 @@ int main(int argc, char *argv[])
<< exit(FatalError); << exit(FatalError);
} }
} }
}
Info<< "Create mesh" << endl; Info<< "Create mesh" << endl;
domainDecomposition mesh domainDecomposition mesh

View File

@ -1,33 +1,31 @@
// 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;
root "ROOT";
case "CASE";
instance "system";
local "";
class dictionary; class dictionary;
note "mesh decomposition control dictionary";
object decompositionDict; location "system";
object decomposeParDict;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
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
{ {
@ -44,13 +42,15 @@ hierarchicalCoeffs
metisCoeffs metisCoeffs
{ {
//processorWeights /*
//( processorWeights
// 1 (
// 1 1
// 1 1
// 1 1
//); 1
);
*/
} }
manualCoeffs manualCoeffs