BUG: resolve some decomposeParDict problems (issues #60, #265).

- Cleanup/centralize handling of -decomposeParDict by relocating
  common code into argList. Ensures that all processes receive
  identical information about the -decomposeParDict opton.

- Only use alternative decomposeParDict for simpleFoam/motorBike
  tutorial so that this will be included in the test loop for snappy.

- Added Mattijs' fix for surfaceRedistributePar.
This commit is contained in:
Mark Olesen
2016-10-25 18:19:19 +02:00
parent 196a4ea4e5
commit 52d0289ee1
16 changed files with 106 additions and 107 deletions

View File

@ -107,16 +107,12 @@ int main(int argc, char *argv[])
fileName dictPath; fileName dictPath;
// Check if the dictionary is specified on the command-line // Check if the dictionary is specified on the command-line
if (args.optionFound("dict")) if (args.optionReadIfPresent("dict", dictPath))
{ {
dictPath = args["dict"]; if (isDir(dictPath))
{
dictPath = dictPath = dictPath / dictName;
( }
isDir(dictPath)
? dictPath/dictName
: dictPath
);
} }
// Check if dictionary is present in the constant directory // Check if dictionary is present in the constant directory
else if else if

View File

@ -3,7 +3,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-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -67,14 +67,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
fileName decompDictFile; fileName decompDictFile;
if (args.optionReadIfPresent("decomposeParDict", decompDictFile)) args.optionReadIfPresent("decomposeParDict", decompDictFile);
{
if (isDir(decompDictFile))
{
decompDictFile = decompDictFile / "decomposeParDict";
}
}
IOdictionary foamyHexMeshDict IOdictionary foamyHexMeshDict
( (

View File

@ -3,7 +3,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) 2012-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -524,13 +524,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
fileName decompDictFile; fileName decompDictFile;
if (args.optionReadIfPresent("decomposeParDict", decompDictFile)) args.optionReadIfPresent("decomposeParDict", decompDictFile);
{
if (isDir(decompDictFile))
{
decompDictFile = decompDictFile / "decomposeParDict";
}
}
labelList decomp = decompositionModel::New labelList decomp = decompositionModel::New
( (

View File

@ -3,7 +3,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-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -837,13 +837,7 @@ int main(int argc, char *argv[])
if (Pstream::parRun()) if (Pstream::parRun())
{ {
fileName decompDictFile; fileName decompDictFile;
if (args.optionReadIfPresent("decomposeParDict", decompDictFile)) args.optionReadIfPresent("decomposeParDict", decompDictFile);
{
if (isDir(decompDictFile))
{
decompDictFile = decompDictFile/"decomposeParDict";
}
}
decomposeDict = IOdictionary decomposeDict = IOdictionary
( (

View File

@ -211,14 +211,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
fileName decompDictFile; fileName decompDictFile;
if (args.optionReadIfPresent("decomposeParDict", decompDictFile)) args.optionReadIfPresent("decomposeParDict", decompDictFile);
{
if (isDir(decompDictFile))
{
decompDictFile = decompDictFile/"decomposeParDict";
}
}
wordList regionNames; wordList regionNames;
wordList regionDirs; wordList regionDirs;
@ -301,7 +294,6 @@ int main(int argc, char *argv[])
), ),
decompDictFile decompDictFile
) )
).lookup("numberOfSubdomains") ).lookup("numberOfSubdomains")
); );

View File

@ -3,7 +3,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-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -64,6 +64,7 @@ Usage
#include "fvMeshTools.H" #include "fvMeshTools.H"
#include "fvMeshDistribute.H" #include "fvMeshDistribute.H"
#include "decompositionMethod.H" #include "decompositionMethod.H"
#include "decompositionModel.H"
#include "timeSelector.H" #include "timeSelector.H"
#include "PstreamReduceOps.H" #include "PstreamReduceOps.H"
#include "volFields.H" #include "volFields.H"
@ -74,7 +75,6 @@ Usage
#include "loadOrCreateMesh.H" #include "loadOrCreateMesh.H"
#include "processorFvPatchField.H" #include "processorFvPatchField.H"
#include "zeroGradientFvPatchFields.H" #include "zeroGradientFvPatchFields.H"
#include "decompositionModel.H"
#include "parFvFieldReconstructor.H" #include "parFvFieldReconstructor.H"
#include "parLagrangianRedistributor.H" #include "parLagrangianRedistributor.H"
@ -2153,7 +2153,6 @@ int main(int argc, char *argv[])
bool newTimes = args.optionFound("newTimes"); bool newTimes = args.optionFound("newTimes");
if (env("FOAM_SIGFPE")) if (env("FOAM_SIGFPE"))
{ {
WarningInFunction WarningInFunction
@ -2246,8 +2245,6 @@ int main(int argc, char *argv[])
Pstream::scatter(decompose); Pstream::scatter(decompose);
// If running distributed we have problem of new processors not finding // If running distributed we have problem of new processors not finding
// a system/controlDict. However if we switch on the master-only reading // a system/controlDict. However if we switch on the master-only reading
// the problem becomes that the time directories are differing sizes and // the problem becomes that the time directories are differing sizes and
@ -2331,7 +2328,6 @@ int main(int argc, char *argv[])
// Determine any region // Determine any region
word regionName = polyMesh::defaultRegion; word regionName = polyMesh::defaultRegion;
fileName meshSubDir; fileName meshSubDir;
if (args.optionReadIfPresent("region", regionName)) if (args.optionReadIfPresent("region", regionName))
{ {
meshSubDir = regionName/polyMesh::meshSubDir; meshSubDir = regionName/polyMesh::meshSubDir;
@ -2775,13 +2771,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
fileName decompDictFile; fileName decompDictFile;
if (args.optionReadIfPresent("decomposeParDict", decompDictFile)) args.optionReadIfPresent("decomposeParDict", decompDictFile);
{
if (isDir(decompDictFile))
{
decompDictFile = decompDictFile / "decomposeParDict";
}
}
// Determine decomposition // Determine decomposition

View File

@ -51,13 +51,11 @@ int readNumProcs
const Time& runTime const Time& runTime
) )
{ {
const word dictName = "decomposeParDict";
fileName dictFile; fileName dictFile;
if (args.optionReadIfPresent(optionName, dictFile)) if (args.optionReadIfPresent(optionName, dictFile) && isDir(dictFile))
{ {
if (isDir(dictFile)) dictFile = dictFile / dictName;
{
dictFile = dictFile/"decomposeParDict";
}
} }
return readInt return readInt
@ -68,7 +66,7 @@ int readNumProcs
( (
IOobject IOobject
( (
"decomposeParDict", dictName,
runTime.system(), runTime.system(),
runTime, runTime,
IOobject::MUST_READ_IF_MODIFIED, IOobject::MUST_READ_IF_MODIFIED,
@ -376,7 +374,7 @@ int main(int argc, char *argv[])
if (parallelSource && !parallelTarget) if (parallelSource && !parallelTarget)
{ {
int nProcs = readNumProcs const int nProcs = readNumProcs
( (
args, args,
"sourceDecomposeParDict", "sourceDecomposeParDict",
@ -448,7 +446,7 @@ int main(int argc, char *argv[])
} }
else if (!parallelSource && parallelTarget) else if (!parallelSource && parallelTarget)
{ {
int nProcs = readNumProcs const int nProcs = readNumProcs
( (
args, args,
"targetDecomposeParDict", "targetDecomposeParDict",
@ -521,13 +519,13 @@ int main(int argc, char *argv[])
} }
else if (parallelSource && parallelTarget) else if (parallelSource && parallelTarget)
{ {
int nProcsSource = readNumProcs const int nProcsSource = readNumProcs
( (
args, args,
"sourceDecomposeParDict", "sourceDecomposeParDict",
runTimeSource runTimeSource
); );
int nProcsTarget = readNumProcs const int nProcsTarget = readNumProcs
( (
args, args,
"targetDecomposeParDict", "targetDecomposeParDict",

View File

@ -156,14 +156,10 @@ int main(int argc, char *argv[])
// Note: cannot use setSystemRunTimeDictionaryIO.H since dictionary // Note: cannot use setSystemRunTimeDictionaryIO.H since dictionary
// is in constant // is in constant
fileName dictPath = ""; fileName dictPath;
if (args.optionFound("dict")) if (args.optionReadIfPresent("dict", dictPath) && isDir(dictPath))
{ {
dictPath = args["dict"]; dictPath = dictPath / dictName;
if (isDir(dictPath))
{
dictPath = dictPath / dictName;
}
} }
if (dictPath.size()) if (dictPath.size())

View File

@ -1,9 +1,12 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
-I$(LIB_SRC)/parallel/distributed/lnInclude -I$(LIB_SRC)/parallel/distributed/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-ldistributed \ -ldistributed \
-lmeshTools \ -lmeshTools \
-ltriSurface -ltriSurface \
-ldecompose

View File

@ -3,7 +3,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-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -46,6 +46,7 @@ Note
#include "distributedTriSurfaceMesh.H" #include "distributedTriSurfaceMesh.H"
#include "mapDistribute.H" #include "mapDistribute.H"
#include "localIOdictionary.H" #include "localIOdictionary.H"
#include "decompositionModel.H"
using namespace Foam; using namespace Foam;
@ -103,7 +104,8 @@ int main(int argc, char *argv[])
{ {
argList::addNote argList::addNote
( (
"redistribute a triSurface" "Redistribute a triSurface. "
"The specified surface must be located in the constant/triSurface directory"
); );
argList::validArgs.append("triSurfaceMesh"); argList::validArgs.append("triSurfaceMesh");
@ -127,7 +129,7 @@ int main(int argc, char *argv[])
<< "Using distribution method " << "Using distribution method "
<< distTypeName << nl << endl; << distTypeName << nl << endl;
const bool keepNonMapped = args.options().found("keepNonMapped"); const bool keepNonMapped = args.optionFound("keepNonMapped");
if (keepNonMapped) if (keepNonMapped)
{ {
@ -151,6 +153,37 @@ int main(int argc, char *argv[])
Random rndGen(653213); Random rndGen(653213);
// For independent decomposition, ensure that distributedTriSurfaceMesh
// can find the alternative decomposeParDict specified via the
// -decomposeParDict option.
if (distType == distributedTriSurfaceMesh::INDEPENDENT)
{
fileName decompDictFile;
args.optionReadIfPresent("decomposeParDict", decompDictFile);
IOdictionary* dict = new IOdictionary
(
decompositionModel::selectIO
(
IOobject
(
"decomposeParDict",
runTime.system(),
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
),
decompDictFile
)
);
// The object must have the expected "decomposeParDict" name.
// This also implies that it cannot be changed during the run.
dict->rename("decomposeParDict");
runTime.store(dict);
}
// Determine mesh bounding boxes: // Determine mesh bounding boxes:
List<List<treeBoundBox>> meshBb(Pstream::nProcs()); List<List<treeBoundBox>> meshBb(Pstream::nProcs());
if (distType == distributedTriSurfaceMesh::FOLLOW) if (distType == distributedTriSurfaceMesh::FOLLOW)

View File

@ -2,8 +2,8 @@
========= | ========= |
\\ / 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-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -600,10 +600,29 @@ void Foam::argList::parse
// establish rootPath_/globalCase_/case_ for master // establish rootPath_/globalCase_/case_ for master
getRootCase(); getRootCase();
// See if running distributed (different roots for different procs) // Establish location of decomposeParDict, allow override with
label dictNProcs = -1; // the -decomposeParDict option.
fileName source; fileName source = rootPath_/globalCase_/"system"/"decomposeParDict";
if (options_.found("decomposeParDict"))
{
bool adjustOpt = false;
source = options_["decomposeParDict"];
if (isDir(source))
{
adjustOpt = true;
source = source/"decomposeParDict";
}
// Could also check for absolute path, but shouldn't be needed
if (adjustOpt)
{
source.clean();
options_.set("decomposeParDict", source);
}
}
// If running distributed (different roots for different procs)
label dictNProcs = -1;
if (options_.found("roots")) if (options_.found("roots"))
{ {
source = "-roots"; source = "-roots";
@ -617,16 +636,8 @@ void Foam::argList::parse
} }
else else
{ {
source = rootPath_/globalCase_/"system"/"decomposeParDict"; // Use values from decomposeParDict, the location was already
// Override with -decomposeParDict // established above.
if (options_.found("decomposeParDict"))
{
source = options_["decomposeParDict"];
if (isDir(source))
{
source = source/"decomposeParDict";
}
}
IFstream decompDictStream(source); IFstream decompDictStream(source);

View File

@ -1,7 +1,6 @@
fileName dictPath = ""; fileName dictPath;
if (args.optionFound("dict")) if (args.optionReadIfPresent("dict", dictPath))
{ {
dictPath = args["dict"];
if (isDir(dictPath)) if (isDir(dictPath))
{ {
dictPath = dictPath / dictName; dictPath = dictPath / dictName;

View File

@ -1,7 +1,6 @@
fileName dictPath = ""; fileName dictPath;
if (args.optionFound("dict")) if (args.optionReadIfPresent("dict", dictPath))
{ {
dictPath = args["dict"];
if (isDir(dictPath)) if (isDir(dictPath))
{ {
dictPath = dictPath / dictName; dictPath = dictPath / dictName;

View File

@ -1,7 +1,6 @@
fileName dictPath = ""; fileName dictPath;
if (args.optionFound("dict")) if (args.optionReadIfPresent("dict", dictPath))
{ {
dictPath = args["dict"];
if (isDir(dictPath)) if (isDir(dictPath))
{ {
dictPath = dictPath / dictName; dictPath = dictPath / dictName;

View File

@ -4,14 +4,16 @@ cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions # Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions . $WM_PROJECT_DIR/bin/tools/RunFunctions
decompDict="-decomposeParDict system/decomposeParDict.6"
# copy motorbike surface from resources directory # copy motorbike surface from resources directory
\cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/triSurface/ \cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/triSurface/
runApplication surfaceFeatureExtract runApplication surfaceFeatureExtract
runApplication blockMesh runApplication blockMesh
runApplication decomposePar runApplication decomposePar $decompDict
runParallel snappyHexMesh -overwrite runParallel $decompDict snappyHexMesh -overwrite
#- For non-parallel running: - set the initial fields #- For non-parallel running: - set the initial fields
# restore0Dir # restore0Dir
@ -19,9 +21,9 @@ runParallel snappyHexMesh -overwrite
#- For parallel running: set the initial fields #- For parallel running: set the initial fields
restore0Dir -processor restore0Dir -processor
runParallel patchSummary runParallel $decompDict patchSummary
runParallel potentialFoam runParallel $decompDict potentialFoam
runParallel $(getApplication) runParallel $decompDict $(getApplication)
runApplication reconstructParMesh -constant runApplication reconstructParMesh -constant
runApplication reconstructPar -latestTime runApplication reconstructPar -latestTime

View File

@ -28,7 +28,7 @@ simpleCoeffs
hierarchicalCoeffs hierarchicalCoeffs
{ {
n (3 2 1); n (2 2 1);
delta 0.001; delta 0.001;
order xyz; order xyz;
} }