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
decomposition method etc. have been changed between decompositions.
- \par -dict \<filename\>
Specify alternative dictionary for the decomposition.
\*---------------------------------------------------------------------------*/
#include "OSspecific.H"
@ -248,6 +251,13 @@ int main(int argc, char *argv[])
"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
timeSelector::addOptions(true, false);
@ -262,12 +272,33 @@ int main(int argc, char *argv[])
bool forceOverwrite = args.optionFound("force");
bool ifRequiredDecomposition = args.optionFound("ifRequired");
const word dictName("decomposeParDict");
// Set time from database
#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
instantList times = timeSelector::selectIfPresent(runTime, args);
wordList regionNames;
wordList regionDirs;
if (allRegions)
@ -337,7 +368,7 @@ int main(int argc, char *argv[])
(
IOobject
(
"decomposeParDict",
dictName,
runTime.time().system(),
regionDir, // use region if non-standard
runTime,
@ -358,7 +389,7 @@ int main(int argc, char *argv[])
<< nProcs << " domains"
<< nl
<< "instead of " << nDomains
<< " domains as specified in decomposeParDict"
<< " domains as specified in " << dictName
<< nl
<< exit(FatalError);
}
@ -421,13 +452,14 @@ int main(int argc, char *argv[])
IOobject::NO_READ,
IOobject::NO_WRITE,
false
)
),
dictPath
);
// Decompose the mesh
if (!decomposeFieldsOnly)
{
mesh.decomposeMesh();
mesh.decomposeMesh(dictPath);
mesh.writeDecomposition(decomposeSets);

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
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
distributeCells();
distributeCells(dict);
// Distribute the cells according to the given processor label