decomposePar: Added "-dict" option

to specify an alternative name and/or location for the decomposition dictionary.

Based on patch contributed by Niklas Nordin, Scania.
This commit is contained in:
Henry Weller
2017-05-03 10:35:08 +01:00
parent 8514ff55d0
commit a41f84e925
5 changed files with 62 additions and 21 deletions

View File

@ -74,6 +74,9 @@ Usage
be used with caution when the underlying (serial) geometry or the be used with caution when the underlying (serial) geometry or the
decomposition method etc. have been changed between decompositions. decomposition method etc. have been changed between decompositions.
- \par -dict \<filename\>
Specify alternative dictionary for the decomposition.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "OSspecific.H" #include "OSspecific.H"
@ -248,6 +251,13 @@ int main(int argc, char *argv[])
"only decompose geometry if the number of domains has changed" "only decompose geometry if the number of domains has changed"
); );
argList::addOption
(
"dict",
"dictionary file name",
"specify alternative decomposition dictionary"
);
// Include explicit constant options, have zero from time range // Include explicit constant options, have zero from time range
timeSelector::addOptions(true, false); timeSelector::addOptions(true, false);
@ -262,12 +272,33 @@ int main(int argc, char *argv[])
bool forceOverwrite = args.optionFound("force"); bool forceOverwrite = args.optionFound("force");
bool ifRequiredDecomposition = args.optionFound("ifRequired"); bool ifRequiredDecomposition = args.optionFound("ifRequired");
const word dictName("decomposeParDict");
// Set time from database // Set time from database
#include "createTime.H" #include "createTime.H"
fileName dictPath;
// Check if the dictionary is specified on the command-line
if (args.optionFound("dict"))
{
dictPath = args["dict"];
dictPath =
(
isDir(dictPath)
? dictPath/dictName
: dictPath
);
}
else
{
dictPath = runTime.path()/"system"/dictName;
}
// Allow override of time // Allow override of time
instantList times = timeSelector::selectIfPresent(runTime, args); instantList times = timeSelector::selectIfPresent(runTime, args);
wordList regionNames; wordList regionNames;
wordList regionDirs; wordList regionDirs;
if (allRegions) if (allRegions)
@ -337,7 +368,7 @@ int main(int argc, char *argv[])
( (
IOobject IOobject
( (
"decomposeParDict", dictName,
runTime.time().system(), runTime.time().system(),
regionDir, // use region if non-standard regionDir, // use region if non-standard
runTime, runTime,
@ -358,7 +389,7 @@ int main(int argc, char *argv[])
<< nProcs << " domains" << nProcs << " domains"
<< nl << nl
<< "instead of " << nDomains << "instead of " << nDomains
<< " domains as specified in decomposeParDict" << " domains as specified in " << dictName
<< nl << nl
<< exit(FatalError); << exit(FatalError);
} }
@ -421,13 +452,14 @@ int main(int argc, char *argv[])
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
) ),
dictPath
); );
// Decompose the mesh // Decompose the mesh
if (!decomposeFieldsOnly) if (!decomposeFieldsOnly)
{ {
mesh.decomposeMesh(); mesh.decomposeMesh(dictPath);
mesh.writeDecomposition(decomposeSets); mesh.writeDecomposition(decomposeSets);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -69,7 +69,11 @@ void Foam::domainDecomposition::mark
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::domainDecomposition::domainDecomposition(const IOobject& io) Foam::domainDecomposition::domainDecomposition
(
const IOobject& io,
const fileName& dictFile
)
: :
fvMesh(io), fvMesh(io),
facesInstancePointsPtr_ facesInstancePointsPtr_
@ -96,7 +100,8 @@ Foam::domainDecomposition::domainDecomposition(const IOobject& io)
( (
decompositionModel::New decompositionModel::New
( (
*this *this,
dictFile
).lookup("numberOfSubdomains") ).lookup("numberOfSubdomains")
) )
), ),
@ -115,7 +120,8 @@ Foam::domainDecomposition::domainDecomposition(const IOobject& io)
{ {
decompositionModel::New decompositionModel::New
( (
*this *this,
dictFile
).readIfPresent("distributed", distributed_); ).readIfPresent("distributed", distributed_);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -114,7 +114,7 @@ class domainDecomposition
// Private Member Functions // Private Member Functions
void distributeCells(); void distributeCells(const fileName& dictFile);
//- Mark all elements with value or -2 if occur twice //- Mark all elements with value or -2 if occur twice
static void mark static void mark
@ -156,8 +156,12 @@ public:
// Constructors // Constructors
//- Construct from IOobject //- Construct from IOobject and decomposition dictionary name
domainDecomposition(const IOobject& io); domainDecomposition
(
const IOobject& io,
const fileName& dictFile
);
//- Destructor //- Destructor
@ -179,7 +183,7 @@ public:
} }
//- Decompose mesh. //- Decompose mesh.
void decomposeMesh(); void decomposeMesh(const fileName& dict);
//- Write decomposition //- Write decomposition
bool writeDecomposition(const bool decomposeSets); bool writeDecomposition(const bool decomposeSets);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -34,13 +34,12 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::domainDecomposition::distributeCells() void Foam::domainDecomposition::distributeCells(const fileName& dict)
{ {
Info<< "\nCalculating distribution of cells" << endl; Info<< "\nCalculating distribution of cells" << endl;
cpuTime decompositionTime; cpuTime decompositionTime;
const decompositionModel& method = decompositionModel::New(*this, dict);
const decompositionModel& method = decompositionModel::New(*this);
scalarField cellWeights; scalarField cellWeights;
if (method.found("weightField")) if (method.found("weightField"))

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -94,10 +94,10 @@ void Foam::domainDecomposition::addInterProcFace
} }
void Foam::domainDecomposition::decomposeMesh() void Foam::domainDecomposition::decomposeMesh(const fileName& dict)
{ {
// Decide which cell goes to which processor // Decide which cell goes to which processor
distributeCells(); distributeCells(dict);
// Distribute the cells according to the given processor label // Distribute the cells according to the given processor label