From 6c3f2f4df1e83b6819bd6fda969f8bb7cec748c4 Mon Sep 17 00:00:00 2001 From: Mattijs Janssens Date: Mon, 25 Mar 2019 16:49:50 +0000 Subject: [PATCH] Snappy hex mesh proximity check --- src/mesh/snappyHexMesh/Make/files | 1 + src/mesh/snappyHexMesh/Make/options | 1 - .../meshRefinement/meshRefinement.C | 216 +++++- .../meshRefinement/meshRefinement.H | 108 ++- .../meshRefinement/meshRefinementBlock.C | 437 +++++++++++ .../meshRefinementProblemCells.C | 90 --- .../meshRefinement/meshRefinementRefine.C | 61 +- .../refinementSurfaces/refinementSurfaces.C | 52 +- .../refinementSurfaces/refinementSurfaces.H | 29 +- .../shellSurfaces/shellSurfaces.H | 12 + .../refinementParameters.C | 3 +- .../refinementParameters.H | 14 +- .../snappyHexMeshDriver/snappyRefineDriver.C | 90 ++- .../snappyHexMeshDriver/snappyRefineDriver.H | 7 + .../triSurfaceMesh/triSurfaceMesh.C | 2 +- .../0/polyMesh/sets/cellsToRemove | 21 + .../snappyHexMesh/opposite_walls/Allclean | 7 + .../mesh/snappyHexMesh/opposite_walls/Allrun | 15 + .../constant/triSurface/gap0.stl | 702 ++++++++++++++++++ .../constant/triSurface/gap1.stl | 702 ++++++++++++++++++ .../constant/triSurface/gap_transformed0.stl | 485 ++++++++++++ .../triSurface/gap_transformed0_with_hook.stl | 702 ++++++++++++++++++ .../constant/triSurface/gap_transformed1.stl | 702 ++++++++++++++++++ .../opposite_walls/system/blockMeshDict | 98 +++ .../opposite_walls/system/controlDict | 49 ++ .../opposite_walls/system/decomposeParDict | 30 + .../opposite_walls/system/fvSchemes | 57 ++ .../opposite_walls/system/fvSolution | 69 ++ .../opposite_walls/system/meshQualityDict | 21 + .../opposite_walls/system/snappyHexMeshDict | 326 ++++++++ 30 files changed, 4974 insertions(+), 135 deletions(-) create mode 100644 src/mesh/snappyHexMesh/meshRefinement/meshRefinementBlock.C create mode 100644 tutorials/mesh/snappyHexMesh/opposite_walls/0/polyMesh/sets/cellsToRemove create mode 100755 tutorials/mesh/snappyHexMesh/opposite_walls/Allclean create mode 100755 tutorials/mesh/snappyHexMesh/opposite_walls/Allrun create mode 100644 tutorials/mesh/snappyHexMesh/opposite_walls/constant/triSurface/gap0.stl create mode 100644 tutorials/mesh/snappyHexMesh/opposite_walls/constant/triSurface/gap1.stl create mode 100644 tutorials/mesh/snappyHexMesh/opposite_walls/constant/triSurface/gap_transformed0.stl create mode 100644 tutorials/mesh/snappyHexMesh/opposite_walls/constant/triSurface/gap_transformed0_with_hook.stl create mode 100644 tutorials/mesh/snappyHexMesh/opposite_walls/constant/triSurface/gap_transformed1.stl create mode 100644 tutorials/mesh/snappyHexMesh/opposite_walls/system/blockMeshDict create mode 100644 tutorials/mesh/snappyHexMesh/opposite_walls/system/controlDict create mode 100644 tutorials/mesh/snappyHexMesh/opposite_walls/system/decomposeParDict create mode 100644 tutorials/mesh/snappyHexMesh/opposite_walls/system/fvSchemes create mode 100644 tutorials/mesh/snappyHexMesh/opposite_walls/system/fvSolution create mode 100644 tutorials/mesh/snappyHexMesh/opposite_walls/system/meshQualityDict create mode 100644 tutorials/mesh/snappyHexMesh/opposite_walls/system/snappyHexMeshDict 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