diff --git a/src/mesh/snappyHexMesh/Make/files b/src/mesh/snappyHexMesh/Make/files index 00c46b066e..0bdadb9848 100644 --- a/src/mesh/snappyHexMesh/Make/files +++ b/src/mesh/snappyHexMesh/Make/files @@ -14,6 +14,7 @@ meshRefinement/meshRefinementMerge.C meshRefinement/meshRefinementProblemCells.C meshRefinement/meshRefinementRefine.C meshRefinement/meshRefinementGapRefine.C +meshRefinement/meshRefinementBlock.C meshRefinement/patchFaceOrientation.C refinementFeatures/refinementFeatures.C diff --git a/src/mesh/snappyHexMesh/Make/options b/src/mesh/snappyHexMesh/Make/options index 2cf98acf6b..f76521cbc2 100644 --- a/src/mesh/snappyHexMesh/Make/options +++ b/src/mesh/snappyHexMesh/Make/options @@ -1,5 +1,4 @@ EXE_INC = \ - /* -g -DFULLDEBUG -O0 */ \ -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C index 9717e6e553..1f1839bac4 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C @@ -58,6 +58,8 @@ License #include "fvMeshTools.H" #include "motionSmoother.H" #include "faceSet.H" +#include "topoDistanceData.H" +#include "FaceCellWave.H" // Leak path #include "shortestPathSet.H" @@ -358,6 +360,218 @@ void Foam::meshRefinement::updateIntersections(const labelList& changedFaces) } +Foam::labelList Foam::meshRefinement::nearestPatch +( + const labelList& adaptPatchIDs +) const +{ + // Determine nearest patch for all mesh faces. Used when removing cells + // to give some reasonable patch to exposed faces. + + const polyBoundaryMesh& patches = mesh_.boundaryMesh(); + + labelList nearestAdaptPatch; + + if (adaptPatchIDs.size()) + { + nearestAdaptPatch.setSize(mesh_.nFaces(), adaptPatchIDs[0]); + + + // Count number of faces in adaptPatchIDs + label nFaces = 0; + forAll(adaptPatchIDs, i) + { + const polyPatch& pp = patches[adaptPatchIDs[i]]; + nFaces += pp.size(); + } + + // Field on cells and faces. + List cellData(mesh_.nCells()); + List faceData(mesh_.nFaces()); + + // Start of changes + labelList patchFaces(nFaces); + List patchData(nFaces); + nFaces = 0; + forAll(adaptPatchIDs, i) + { + label patchi = adaptPatchIDs[i]; + const polyPatch& pp = patches[patchi]; + + forAll(pp, i) + { + patchFaces[nFaces] = pp.start()+i; + patchData[nFaces] = topoDistanceData(patchi, 0); + nFaces++; + } + } + + // Propagate information inwards + FaceCellWave deltaCalc + ( + mesh_, + patchFaces, + patchData, + faceData, + cellData, + mesh_.globalData().nTotalCells()+1 + ); + + // And extract + + bool haveWarned = false; + forAll(faceData, facei) + { + if (!faceData[facei].valid(deltaCalc.data())) + { + if (!haveWarned) + { + WarningInFunction + << "Did not visit some faces, e.g. face " << facei + << " at " << mesh_.faceCentres()[facei] << endl + << "Assigning these faces to patch " + << adaptPatchIDs[0] + << endl; + haveWarned = true; + } + } + else + { + nearestAdaptPatch[facei] = faceData[facei].data(); + } + } + } + else + { + // Use patch 0 + nearestAdaptPatch.setSize(mesh_.nFaces(), 0); + } + + return nearestAdaptPatch; +} + + +Foam::labelList Foam::meshRefinement::nearestIntersection +( + const labelList& surfacesToTest, + const label defaultRegion +) const +{ + // Determine nearest intersection for all mesh faces. Used when removing + // cells to give some reasonable patch to exposed faces. Use this + // function instead of nearestPatch if you don't have patches yet. + + + // Swap neighbouring cell centres and cell level + labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces()); + pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces()); + calcNeighbourData(neiLevel, neiCc); + + + // Collect segments + // ~~~~~~~~~~~~~~~~ + + const labelList testFaces(intersectedFaces()); + + pointField start(testFaces.size()); + pointField end(testFaces.size()); + labelList minLevel(testFaces.size()); + + calcCellCellRays + ( + neiCc, + neiLevel, + testFaces, + start, + end, + minLevel + ); + + // Do tests in one go + labelList surface1; + List hit1; + labelList region1; + labelList surface2; + List hit2; + labelList region2; + surfaces_.findNearestIntersection + ( + surfacesToTest, + start, + end, + + surface1, + hit1, + region1, + surface2, + hit2, + region2 + ); + + labelList nearestRegion(mesh_.nFaces(), defaultRegion); + + // Field on cells and faces. + List cellData(mesh_.nCells()); + List faceData(mesh_.nFaces()); + + // Start walking from all intersected faces + DynamicList