diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 7b998241d6..ed0e635787 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); - decomposeDict = IOdictionary + // A demand-driven decompositionMethod can have issues finding + // an alternative decomposeParDict location. + + IOdictionary* dictPtr = new IOdictionary + ( + decompositionModel::selectIO ( - decompositionModel::selectIO + IOobject ( - IOobject - ( - "decomposeParDict", - runTime.system(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - 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/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C b/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C index ab692d4706..71013769a1 100644 --- a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C +++ b/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,15 +28,31 @@ Group grpMeshManipulationUtilities Description - Detects faces that share points (baffles). Either merge them or + Detects boundary faces that share points (baffles). Either merges them or duplicate the points. - Notes: +Usage + \b mergeOrSplitBaffles [OPTION] + + Options: + - \par -detect + Detect baffles and write to faceSet duplicateFaces. + + - \par -merge + Detect baffles and convert to internal faces. + + - \par -split + Detect baffles and duplicate the points (used so the two sides + can move independently) + + - \par -dict \ + Specify a dictionary to read actions from. + + +Note - can only handle pairwise boundary faces. So three faces using the same points is not handled (is illegal mesh anyway) - - there is no option to only split/merge some baffles. - - surfaces consisting of duplicate faces can be topologically split if the points on the interior of the surface cannot walk to all the cells that use them in one go. @@ -71,6 +87,7 @@ using namespace Foam; void insertDuplicateMerge ( const polyMesh& mesh, + const labelList& boundaryFaces, const labelList& duplicates, polyTopoChange& meshMod ) @@ -87,8 +104,8 @@ void insertDuplicateMerge { // Two duplicate faces. Merge. - label face0 = mesh.nInternalFaces() + bFacei; - label face1 = mesh.nInternalFaces() + otherFacei; + label face0 = boundaryFaces[bFacei]; + label face1 = boundaryFaces[otherFacei]; label own0 = faceOwner[face0]; label own1 = faceOwner[face1]; @@ -156,6 +173,45 @@ void insertDuplicateMerge } +label patchSize(const polyMesh& mesh, const labelList& patchIDs) +{ + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + label sz = 0; + forAll(patchIDs, i) + { + const polyPatch& pp = patches[patchIDs[i]]; + sz += pp.size(); + } + return sz; +} + + +labelList patchFaces(const polyMesh& mesh, const labelList& patchIDs) +{ + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + labelList faceIDs(patchSize(mesh, patchIDs)); + label sz = 0; + forAll(patchIDs, i) + { + const polyPatch& pp = patches[patchIDs[i]]; + + forAll(pp, ppi) + { + faceIDs[sz++] = pp.start()+ppi; + } + } + +if (faceIDs.size() != sz) +{ + FatalErrorInFunction << exit(FatalError); +} + + return faceIDs; +} + + labelList findBaffles(const polyMesh& mesh, const labelList& boundaryFaces) { // Get all duplicate face labels (in boundaryFaces indices!). @@ -173,7 +229,7 @@ labelList findBaffles(const polyMesh& mesh, const labelList& boundaryFaces) { if (duplicates[bFacei] != -1) { - label facei = mesh.nInternalFaces() + bFacei; + label facei = boundaryFaces[bFacei]; label patchi = patches.whichPatch(facei); if (isA(patches[patchi])) @@ -205,12 +261,12 @@ labelList findBaffles(const polyMesh& mesh, const labelList& boundaryFaces) if (otherFacei != -1 && otherFacei > bFacei) { - duplicateSet.insert(mesh.nInternalFaces() + bFacei); - duplicateSet.insert(mesh.nInternalFaces() + otherFacei); + duplicateSet.insert(boundaryFaces[bFacei]); + duplicateSet.insert(boundaryFaces[otherFacei]); } } - Pout<< "Writing " << duplicateSet.size() + Info<< "Writing " << returnReduce(duplicateSet.size(), sumOp