diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index a1e4a8d91da090f43415a8730af5844534ad9239..ed0e635787ad1906f4c0c230423caf2943fd8008 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -901,33 +901,42 @@ int main(int argc, char *argv[]) // Read decomposePar dictionary dictionary decomposeDict; + if (Pstream::parRun()) { - if (Pstream::parRun()) - { - fileName decompDictFile; - args.optionReadIfPresent("decomposeParDict", decompDictFile); + fileName decompDictFile; + args.optionReadIfPresent("decomposeParDict", decompDictFile); + + // A demand-driven decompositionMethod can have issues finding + // an alternative decomposeParDict location. - decomposeDict = IOdictionary + IOdictionary* dictPtr = new IOdictionary + ( + decompositionModel::selectIO ( - decompositionModel::selectIO + IOobject ( - IOobject - ( - "decomposeParDict", - runTime.system(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ), - decompDictFile - ) - ); - } - else - { - decomposeDict.add("method", "none"); - decomposeDict.add("numberOfSubdomains", 1); - } + "decomposeParDict", + runTime.system(), + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + decompDictFile + ) + ); + + // Store it on the object registry, but to be found it must also + // have the expected "decomposeParDict" name. + + dictPtr->rename("decomposeParDict"); + runTime.store(dictPtr); + + decomposeDict = *dictPtr; + } + else + { + decomposeDict.add("method", "none"); + decomposeDict.add("numberOfSubdomains", 1); } diff --git a/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C b/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C index fec1fa27a8dcd12c874060c14c5d7f8ab6faa2d1..219a4552090ae138d363cffc6d64b4faeca9e336 100644 --- a/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C +++ b/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C @@ -161,7 +161,10 @@ int main(int argc, char *argv[]) fileName decompDictFile; args.optionReadIfPresent("decomposeParDict", decompDictFile); - IOdictionary* dict = new IOdictionary + // A demand-driven decompositionMethod can have issues finding + // an alternative decomposeParDict location. + + IOdictionary* dictPtr = new IOdictionary ( decompositionModel::selectIO ( @@ -177,11 +180,11 @@ int main(int argc, char *argv[]) ) ); - // The object must have the expected "decomposeParDict" name. - // This also implies that it cannot be changed during the run. - dict->rename("decomposeParDict"); + // Store it on the object registry, but to be found it must also + // have the expected "decomposeParDict" name. - runTime.store(dict); + dictPtr->rename("decomposeParDict"); + runTime.store(dictPtr); } // Determine mesh bounding boxes: diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions index f99ab370b509b491ab5e957b153386c1e481ceb4..c3c6be894831806843952b5562a15d0feb0b0326 100755 --- a/bin/tools/RunFunctions +++ b/bin/tools/RunFunctions @@ -56,15 +56,17 @@ isTest() # getNumberOfProcessors() { + local dict="${1:-system/decomposeParDict}" + # Re-use positional parameters for automatic whitespace elimination - set -- $(foamDictionary -entry numberOfSubdomains -value "${1:-system/decomposeParDict}") + set -- $(foamDictionary -entry numberOfSubdomains -value "$dict" 2>/dev/null) if [ "$#" -eq 1 ] then echo "$1" else - echo "Error retrieving 'numberOfSubdomains' from decomposeParDict" 1>&2 - echo 1 + echo "Warning no 'numberOfSubdomains' in '$dict'" 1>&2 + echo 1 # serial as fallback return 1 fi } diff --git a/tutorials/incompressible/simpleFoam/motorBike/Allrun b/tutorials/incompressible/simpleFoam/motorBike/Allrun index f2d7ed6bb0f4d12f52191115084a78f20adc688b..c110f083ecd737c4e8180e63f5a5b7df9368f9b7 100755 --- a/tutorials/incompressible/simpleFoam/motorBike/Allrun +++ b/tutorials/incompressible/simpleFoam/motorBike/Allrun @@ -4,7 +4,10 @@ cd ${0%/*} || exit 1 # Run from this directory # Source tutorial run functions . $WM_PROJECT_DIR/bin/tools/RunFunctions +# Alternative decomposeParDict name: decompDict="-decomposeParDict system/decomposeParDict.6" +## Standard decomposeParDict name: +# unset decompDict # copy motorbike surface from resources directory \cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/triSurface/ @@ -13,6 +16,14 @@ runApplication surfaceFeatureExtract runApplication blockMesh runApplication decomposePar $decompDict + +# Using distributedTriSurfaceMesh? +if foamDictionary -entry geometry -value system/snappyHexMeshDict | \ + grep -q distributedTriSurfaceMesh +then + runParallel $decompDict surfaceRedistributePar motorBike.obj independent +fi + runParallel $decompDict snappyHexMesh -overwrite #- For non-parallel running: - set the initial fields diff --git a/tutorials/incompressible/simpleFoam/motorBike/system/decomposeParDict.6 b/tutorials/incompressible/simpleFoam/motorBike/system/decomposeParDict.6 index 82f0a4e81a972b7b9a398d5c3693750d6c0447cb..db5f0cd2c283170f048d8113451c047d7f062452 100644 --- a/tutorials/incompressible/simpleFoam/motorBike/system/decomposeParDict.6 +++ b/tutorials/incompressible/simpleFoam/motorBike/system/decomposeParDict.6 @@ -15,20 +15,20 @@ FoamFile // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -numberOfSubdomains 4; +numberOfSubdomains 6; method hierarchical; // method ptscotch; simpleCoeffs { - n (4 1 1); + n (6 1 1); delta 0.001; } hierarchicalCoeffs { - n (2 2 1); + n (3 2 1); delta 0.001; order xyz; }