diff --git a/etc/caseDicts/annotated/snappyHexMeshDict b/etc/caseDicts/annotated/snappyHexMeshDict index 0dc0067946..a775ea3b65 100644 --- a/etc/caseDicts/annotated/snappyHexMeshDict +++ b/etc/caseDicts/annotated/snappyHexMeshDict @@ -456,6 +456,10 @@ castellatedMeshControls // Erosion is specified as a number of erosion iterations. // Erosion has less chance of bleeding and changing the zone // for a complete region. + // A negative value implements 'growing' the cellZones which + // might help with small non-physical gaps inbetween cellZones. + // (currently only a single layer growth i.e. -1 is supported) + // Default value is 0. //nCellZoneErodeIter 2; } diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H index 7bbdcf96a3..bce5111d65 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H @@ -805,6 +805,17 @@ private: labelList& cellToZone ) const; + //- Variation of findCellZoneTopo: walks from cellZones but ignores + // face intersections (unnamedSurfaceRegion). WIP + void growCellZone + ( + const label nGrowCellZones, + const label backgroundZoneID, + labelList& unnamedSurfaceRegion, + labelList& namedSurfaceRegion, + labelList& cellToZone + ) const; + //- Make namedSurfaceRegion consistent with cellToZone // - clear out any blocked faces inbetween same cell zone. void makeConsistentFaceIndex diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C index fb15e77059..3b07b51c5e 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C @@ -55,6 +55,9 @@ License #include "zeroGradientFvPatchFields.H" #include "volFields.H" +#include "FaceCellWave.H" +#include "wallPoints.H" + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::label Foam::meshRefinement::createBaffle @@ -2177,6 +2180,313 @@ void Foam::meshRefinement::erodeCellZone } +void Foam::meshRefinement::growCellZone +( + const label nGrowCellZones, + const label backgroundZoneID, + labelList& unnamedSurfaceRegion, + labelList& namedSurfaceRegion, // potentially zero size if no faceZones + labelList& cellToZone +) const +{ + if (nGrowCellZones != 1) + { + WarningInFunction + << "Growing currently only supported for single layer." + << " Exiting zone growing" << endl; + return; + } + + + // See meshRefinement::markProximityRefinementWave: + // - walk out nGrowCellZones iterations from outside of cellZone + // and wall into unassigned cells + // - detect any cells inbetween + // - multiple zones + // - zone and wall + // and + // - assign cells to the cellZone + // - unblock faces (along the path) inbetween + + + // Special tag for walls + const FixedList wallTag + ({ + labelMax, // Special value for wall face. Loses out to cellZone tag + labelMax, + labelMax + }); + + // Work arrays + pointField origins(1); + scalarField distSqrs(1); + List> surfaces(1); + + + // Set up blockage. Marked with 0 distance (so always wins) + + //List allFaceInfo(mesh_.nFaces()); + //for (label facei = 0; facei < mesh_.nInternalFaces(); facei++) + //{ + // if (unnamedSurfaceRegion[facei] != -1) + // { + // origins[0] = mesh_.faceCentres()[facei]; + // distSqrs[0] = 0.0; // Initial distance + // surfaces[0] = wallTag; + // allFaceInfo[facei] = wallPoints(origins, distSqrs, surfaces); + // } + //} + List allCellInfo(mesh_.nCells()); + forAll(cellToZone, celli) + { + if (cellToZone[celli] >= 0) + { + const FixedList zoneTag + ({ + cellToZone[celli], // zone + 0, // 'region' + labelMax // 'sub-region' + }); + + origins[0] = mesh_.cellCentres()[celli]; + distSqrs[0] = 0.0; // Initial distance + surfaces[0] = zoneTag; + allCellInfo[celli] = wallPoints(origins, distSqrs, surfaces); + } + } + + + DynamicList faceDist(mesh_.nFaces()/128); + DynamicList