diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C index db59fd4fc3..81f81dc508 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C @@ -268,8 +268,6 @@ void Foam::meshRefinement::calcCellCellRays // Returns first intersection if there are more than one. void Foam::meshRefinement::updateIntersections(const labelList& changedFaces) { - const pointField& cellCentres = mesh_.cellCentres(); - // Stats on edges to test. Count proc faces only once. PackedBoolList isMasterFace(syncTools::getMasterFaces(mesh_)); @@ -309,28 +307,17 @@ void Foam::meshRefinement::updateIntersections(const labelList& changedFaces) // Collect segments we want to test for pointField start(changedFaces.size()); pointField end(changedFaces.size()); - - forAll(changedFaces, i) { - label faceI = changedFaces[i]; - label own = mesh_.faceOwner()[faceI]; - - start[i] = cellCentres[own]; - if (mesh_.isInternalFace(faceI)) - { - end[i] = cellCentres[mesh_.faceNeighbour()[faceI]]; - } - else - { - end[i] = neiCc[faceI-mesh_.nInternalFaces()]; - } - } - - // Extend segments a bit - { - const vectorField smallVec(ROOTSMALL*(end-start)); - start -= smallVec; - end += smallVec; + labelList minLevel; + calcCellCellRays + ( + neiCc, + neiLevel, + changedFaces, + start, + end, + minLevel + ); } @@ -2964,8 +2951,6 @@ void Foam::meshRefinement::dumpRefinementLevel() const void Foam::meshRefinement::dumpIntersections(const fileName& prefix) const { { - const pointField& cellCentres = mesh_.cellCentres(); - OFstream str(prefix + "_edges.obj"); label vertI = 0; Pout<< "meshRefinement::dumpIntersections :" @@ -2986,27 +2971,17 @@ void Foam::meshRefinement::dumpIntersections(const fileName& prefix) const // Collect segments we want to test for pointField start(intersectionFaces.size()); pointField end(intersectionFaces.size()); - - forAll(intersectionFaces, i) { - label faceI = intersectionFaces[i]; - start[i] = cellCentres[mesh_.faceOwner()[faceI]]; - - if (mesh_.isInternalFace(faceI)) - { - end[i] = cellCentres[mesh_.faceNeighbour()[faceI]]; - } - else - { - end[i] = neiCc[faceI-mesh_.nInternalFaces()]; - } - } - - // Extend segments a bit - { - const vectorField smallVec(ROOTSMALL*(end-start)); - start -= smallVec; - end += smallVec; + labelList minLevel; + calcCellCellRays + ( + neiCc, + labelList(neiCc.size(), -1), + intersectionFaces, + start, + end, + minLevel + ); } diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H index c0b2724da1..50523060f9 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H @@ -669,7 +669,6 @@ private: //- Determines cell zone from cell region information. bool calcRegionToZone ( - const label backgroundZoneID, const label surfZoneI, const label ownRegion, const label neiRegion, @@ -681,7 +680,6 @@ private: // marked in namedSurfaceIndex regarded as blocked. void findCellZoneTopo ( - const label backgroundZoneID, const pointField& locationsInMesh, const labelList& allSurfaceIndex, const labelList& namedSurfaceIndex, @@ -702,7 +700,6 @@ private: void zonify ( const bool allowFreeStandingZoneFaces, - const label backgroundZoneID, const pointField& locationsInMesh, const wordList& zonesInMesh, diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C index 9af9efa7d8..8f6986d682 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C @@ -311,7 +311,6 @@ void Foam::meshRefinement::getBafflePatches zonify ( true, // allowFreeStandingZoneFaces - -2, // zone to put unreached cells into locationsInMesh, zonesInMesh, @@ -1811,75 +1810,8 @@ void Foam::meshRefinement::findCellZoneInsideWalk } -bool Foam::meshRefinement::calcRegionToZone -( - const label backgroundZoneID, - const label surfZoneI, - const label ownRegion, - const label neiRegion, - - labelList& regionToCellZone -) const -{ - bool changed = false; - - // Check whether inbetween different regions - if (ownRegion != neiRegion) - { - // Jump. Change one of the sides to my type. - - // 1. Interface between my type and unset region. - // Set region to keepRegion - - if (regionToCellZone[ownRegion] == -2) - { - if (regionToCellZone[neiRegion] == surfZoneI) - { - // Face between unset and my region. Put unset - // region into keepRegion - //MEJ: see comment in findCellZoneTopo - if (backgroundZoneID != -2) - { - regionToCellZone[ownRegion] = backgroundZoneID; - changed = true; - } - } - else if (regionToCellZone[neiRegion] != -2) - { - // Face between unset and other region. - // Put unset region into my region - regionToCellZone[ownRegion] = surfZoneI; - changed = true; - } - } - else if (regionToCellZone[neiRegion] == -2) - { - if (regionToCellZone[ownRegion] == surfZoneI) - { - // Face between unset and my region. Put unset - // region into keepRegion - if (backgroundZoneID != -2) - { - regionToCellZone[neiRegion] = backgroundZoneID; - changed = true; - } - } - else if (regionToCellZone[ownRegion] != -2) - { - // Face between unset and other region. - // Put unset region into my region - regionToCellZone[neiRegion] = surfZoneI; - changed = true; - } - } - } - return changed; -} - - void Foam::meshRefinement::findCellZoneTopo ( - const label backgroundZoneID, const pointField& locationsInMesh, const labelList& allSurfaceIndex, const labelList& namedSurfaceIndex, @@ -1893,17 +1825,12 @@ void Foam::meshRefinement::findCellZoneTopo // know which side of the face it relates to. So all we are doing here // is get the correspondence between surface/cellZone and regionSplit // region. - // See the logic in calcRegionToZone. The problem is what to do - // with unreachable parts of the mesh (cellToZone = -2). - // In 23x this routine was only called for actually zoneing an existing - // mesh so we had to do something with these cells and they - // would get set to -1 (background). However in this version this routine - // also gets used much earlier on when after the surface refinement it - // removes unreachable cells ('Removing mesh beyond surface intersections') - // and this is when we keep -2 so it gets removed. - // So the zone to set these unmarked cells to is provided as argument: - // - backgroundZoneID = -2 : do not change so remove cells - // - backgroundZoneID = -1 : put into background + // This can occasionally go wrong when surfaces pass through a + // cell centre and a cell completely gets blocked off so becomes a + // separate region. The problem is to distinguish between a cell which + // properly should be deleted (so in the 'background' mesh) + // or just a single-cell region from incorrect baffling. Currently the + // logic is just to detect cells that are on different regions. // Assumes: @@ -1993,95 +1920,107 @@ void Foam::meshRefinement::findCellZoneTopo } } + // Synchronise any changes due to locationInMesh + Pstream::listCombineGather(regionToCellZone, maxEqOp