diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C index 527abfeea0a46744d8e36a0238b2cdb4afe5faf0..d93a5ca6d37b501bf12a060f503b2adda2c2d2e1 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C @@ -2228,6 +2228,36 @@ void Foam::meshRefinement::selectSeparatedCoupledFaces(boolList& selected) const } +Foam::label Foam::meshRefinement::findRegion +( + const polyMesh& mesh, + const labelList& cellToRegion, + const vector& perturbVec, + const point& p +) +{ + label regionI = -1; + label cellI = mesh.findCell(p); + if (cellI != -1) + { + regionI = cellToRegion[cellI]; + } + reduce(regionI, maxOp<label>()); + + if (regionI == -1) + { + // See if we can perturb a bit + cellI = mesh.findCell(p+perturbVec); + if (cellI != -1) + { + regionI = cellToRegion[cellI]; + } + reduce(regionI, maxOp<label>()); + } + return regionI; +} + + Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMeshRegions ( const labelList& globalToMasterPatch, @@ -2246,16 +2276,13 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMeshRegions regionSplit cellRegion(mesh_, blockedFace); - label regionI = -1; - - label cellI = mesh_.findCell(keepPoint); - - if (cellI != -1) - { - regionI = cellRegion[cellI]; - } - - reduce(regionI, maxOp<label>()); + label regionI = findRegion + ( + mesh_, + cellRegion, + mergeDistance_*vector(1,1,1), // note:1,1,1 should really be normalised + keepPoint + ); if (regionI == -1) { diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H index 5812c38a14a16e3a50ca730e6d19279350154e74..f8d6258ba7c88deb888272674a583525308a19ba 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H @@ -890,6 +890,15 @@ public: //- Select coupled faces that are not collocated void selectSeparatedCoupledFaces(boolList&) const; + //- Find region cell is in. Uses optional perturbation to re-test. + static label findRegion + ( + const polyMesh&, + const labelList& cellRegion, + const vector& perturbVec, + const point& p + ); + //- Split mesh. Keep part containing point. autoPtr<mapPolyMesh> splitMeshRegions ( diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C index 24a5bf02a48bb6f3af7207cb282481ac6ccd9e44..3296d8e08dc3dae7195cb45ec3a9bfd9a6a00a46 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C @@ -1381,18 +1381,16 @@ void Foam::meshRefinement::findCellZoneInsideWalk << endl; // Find the region containing the insidePoint - label keepRegionI = -1; - - label cellI = mesh_.findCell(insidePoint); - - if (cellI != -1) - { - keepRegionI = cellRegion[cellI]; - } - reduce(keepRegionI, maxOp<label>()); + label keepRegionI = findRegion + ( + mesh_, + cellRegion, + mergeDistance_*vector(1,1,1), + insidePoint + ); Info<< "For surface " << surfaces_.names()[surfI] - << " found point " << insidePoint << " in cell " << cellI + << " found point " << insidePoint << " in global region " << keepRegionI << " out of " << cellRegion.nRegions() << " regions." << endl; @@ -1548,19 +1546,16 @@ void Foam::meshRefinement::findCellZoneTopo } - // Find the region containing the keepPoint - label keepRegionI = -1; - - label cellI = mesh_.findCell(keepPoint); - - if (cellI != -1) - { - keepRegionI = cellRegion[cellI]; - } - reduce(keepRegionI, maxOp<label>()); + label keepRegionI = findRegion + ( + mesh_, + cellRegion, + mergeDistance_*vector(1,1,1), + keepPoint + ); - Info<< "Found point " << keepPoint << " in cell " << cellI + Info<< "Found point " << keepPoint << " in global region " << keepRegionI << " out of " << cellRegion.nRegions() << " regions." << endl; @@ -2626,17 +2621,15 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh blockedFace.clear(); // Find the region containing the keepPoint - label keepRegionI = -1; - - label cellI = mesh_.findCell(keepPoint); - - if (cellI != -1) - { - keepRegionI = cellRegion[cellI]; - } - reduce(keepRegionI, maxOp<label>()); + label keepRegionI = findRegion + ( + mesh_, + cellRegion, + mergeDistance_*vector(1,1,1), + keepPoint + ); - Info<< "Found point " << keepPoint << " in cell " << cellI + Info<< "Found point " << keepPoint << " in global region " << keepRegionI << " out of " << cellRegion.nRegions() << " regions." << endl;