diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C index d9af3f11ee63579bd73774bc7497f0e36a26fecb..5606e4f731bb8dacf5cb5dab57f07a505435a49f 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C @@ -2408,14 +2408,18 @@ void Foam::meshRefinement::growCellZone List<wallPoints> allFaceInfo(mesh_.nFaces()); - FaceCellWave<wallPoints> wallDistCalc + + const bitSet isBlockedFace(mesh_.nFaces()); + wallPoints::trackData td(isBlockedFace); + FaceCellWave<wallPoints, wallPoints::trackData> wallDistCalc ( mesh_, changedFaces, faceDist, allFaceInfo, allCellInfo, - 0 // max iterations + 0, // max iterations + td ); wallDistCalc.iterate(nGrowCellZones); diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBlock.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBlock.C index 2eb37d76f8df184ddd4a4e8b8517918552bcfd9b..ff7e5ff556fbd686975e4c63cfb92f958253fbe6 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBlock.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBlock.C @@ -514,8 +514,8 @@ Foam::label Foam::meshRefinement::markProximityRefinementWave } } // Clever limiting of the number of iterations (= max cells in the channel) - // since it has too many problematic issues, e.g. with volume refinement. - // Since the real check uses the proper distance anyway just disable. + // since it has too many problematic issues, e.g. with volume refinement + // and the real check uses the proper distance anyway just disable. const label nIters = mesh_.globalData().nTotalCells(); @@ -613,11 +613,21 @@ Foam::label Foam::meshRefinement::markProximityRefinementWave DynamicList<FixedList<label, 3>> originSurface(2); //DynamicList<point> originNormal(2); + + //- To avoid walking through surfaces we mark all faces that have been + // intersected. We can either mark only those faces intersecting + // blockedSurfaces (i.e. with a 'blockLevel') or mark faces intersecting + // any (refinement) surface (this includes e.g. faceZones). This is + // much easier since that information is already cached + // (meshRefinement::intersectedFaces()) + + //bitSet isBlockedFace(mesh_.nFaces()); forAll(testFaces, i) { if (hit1[i].hit()) { const label facei = testFaces[i]; + //isBlockedFace.set(facei); const point& fc = mesh_.faceCentres()[facei]; const labelList& fz1 = faceZones[surface1[i]]; @@ -656,6 +666,8 @@ Foam::label Foam::meshRefinement::markProximityRefinementWave ); } + // Collect all seed data. Currently walking does not look at + // surface direction - if so pass in surface normal as well faceDist[n] = wallPoints ( originLocation, // origin @@ -683,14 +695,21 @@ Foam::label Foam::meshRefinement::markProximityRefinementWave List<wallPoints> allFaceInfo(mesh_.nFaces()); List<wallPoints> allCellInfo(mesh_.nCells()); - FaceCellWave<wallPoints> wallDistCalc + // Any refinement surface (even a faceZone) should stop the gap walking. + // This is exactly the information which is cached in the surfaceIndex_ + // field. + const bitSet isBlockedFace(intersectedFaces()); + + wallPoints::trackData td(isBlockedFace); + FaceCellWave<wallPoints, wallPoints::trackData> wallDistCalc ( mesh_, changedFaces, faceDist, allFaceInfo, allCellInfo, - 0 // max iterations + 0, // max iterations + td ); wallDistCalc.iterate(nIters); diff --git a/src/mesh/snappyHexMesh/meshRefinement/wallPoints.H b/src/mesh/snappyHexMesh/meshRefinement/wallPoints.H index fe8aad6818ea473b09bfb6920279035c92230cd7..015c5115de7708e28db0074584997f34ad550f24 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/wallPoints.H +++ b/src/mesh/snappyHexMesh/meshRefinement/wallPoints.H @@ -42,6 +42,7 @@ SourceFiles #include "tensor.H" #include "DynamicList.H" #include "labelList.H" +#include "bitSet.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -61,6 +62,23 @@ Ostream& operator<<(Ostream&, const wallPoints&); class wallPoints { +public: + + //- Class used to pass additional data in + class trackData + { + public: + + //- Per face whether the face should not be walked through + const bitSet& isBlockedFace_; + + trackData(const bitSet& isBlockedFace) + : + isBlockedFace_(isBlockedFace) + {} + }; + + protected: // Protected Data diff --git a/src/mesh/snappyHexMesh/meshRefinement/wallPointsI.H b/src/mesh/snappyHexMesh/meshRefinement/wallPointsI.H index 89d84a3660a8c5d62930179dbba2bd009c870a4b..ddd95503675b5defc9eeb62f38fbccb036a2dfdf 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/wallPointsI.H +++ b/src/mesh/snappyHexMesh/meshRefinement/wallPointsI.H @@ -241,30 +241,34 @@ inline bool Foam::wallPoints::updateFace TrackingData& td ) { - const point& fc = mesh.faceCentres()[thisFacei]; - // From cell to its faces. bool hasChanged = false; - forAll(neighbourInfo.surface_, i) + + if (!td.isBlockedFace_[thisFacei]) { - const FixedList<label, 3>& nbrSurface = neighbourInfo.surface_[i]; + const point& fc = mesh.faceCentres()[thisFacei]; - // Find in my surfaces - label index = surface_.find(nbrSurface); - if (index == -1) + forAll(neighbourInfo.surface_, i) { - // Append - origin_.append(neighbourInfo.origin_[i]); - distSqr_.append(magSqr(fc-neighbourInfo.origin_[i])); - surface_.append(nbrSurface); - //normal_.append(neighbourInfo.normal_[i]); - hasChanged = true; - } - else - { - hasChanged = - update(fc, index, neighbourInfo, i, tol, td) - || hasChanged; + const FixedList<label, 3>& nbrSurface = neighbourInfo.surface_[i]; + + // Find in my surfaces + label index = surface_.find(nbrSurface); + if (index == -1) + { + // Append + origin_.append(neighbourInfo.origin_[i]); + distSqr_.append(magSqr(fc-neighbourInfo.origin_[i])); + surface_.append(nbrSurface); + //normal_.append(neighbourInfo.normal_[i]); + hasChanged = true; + } + else + { + hasChanged = + update(fc, index, neighbourInfo, i, tol, td) + || hasChanged; + } } } @@ -283,30 +287,34 @@ inline bool Foam::wallPoints::updateFace TrackingData& td ) { - const point& fc = mesh.faceCentres()[thisFacei]; - // From face to face (e.g. coupled faces) bool hasChanged = false; - forAll(neighbourInfo.surface_, i) + + if (!td.isBlockedFace_[thisFacei]) { - const FixedList<label, 3>& nbrSurface = neighbourInfo.surface_[i]; + const point& fc = mesh.faceCentres()[thisFacei]; - // Find in my surfaces - label index = surface_.find(nbrSurface); - if (index == -1) + forAll(neighbourInfo.surface_, i) { - // Append - origin_.append(neighbourInfo.origin_[i]); - distSqr_.append(magSqr(fc-neighbourInfo.origin_[i])); - surface_.append(nbrSurface); - //normal_.append(neighbourInfo.normal_[i]); - hasChanged = true; - } - else - { - hasChanged = - update(fc, index, neighbourInfo, i, tol, td) - || hasChanged; + const FixedList<label, 3>& nbrSurface = neighbourInfo.surface_[i]; + + // Find in my surfaces + const label index = surface_.find(nbrSurface); + if (index == -1) + { + // Append + origin_.append(neighbourInfo.origin_[i]); + distSqr_.append(magSqr(fc-neighbourInfo.origin_[i])); + surface_.append(nbrSurface); + //normal_.append(neighbourInfo.normal_[i]); + hasChanged = true; + } + else + { + hasChanged = + update(fc, index, neighbourInfo, i, tol, td) + || hasChanged; + } } } diff --git a/tutorials/mesh/snappyHexMesh/opposite_walls/0/polyMesh/sets/cellsToRemove b/tutorials/mesh/snappyHexMesh/opposite_walls/0/polyMesh/sets/cellsToRemove deleted file mode 100644 index 2b058fc5a7ad97087999b8fb43c8be058422a0de..0000000000000000000000000000000000000000 --- a/tutorials/mesh/snappyHexMesh/opposite_walls/0/polyMesh/sets/cellsToRemove +++ /dev/null @@ -1,21 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2012 | -| \\ / A nd | Website: www.openfoam.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format binary; - class cellSet; - arch "LSB;label=32;scalar=64"; - location "0/polyMesh/sets"; - object cellsToRemove; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -0() - -// ************************************************************************* // diff --git a/tutorials/mesh/snappyHexMesh/opposite_walls/system/snappyHexMeshDict b/tutorials/mesh/snappyHexMesh/opposite_walls/system/snappyHexMeshDict index 87ac459a354b02344e020b1da1278a621e4f2bca..b6871ce5e388f45557f3015833a367201582550a 100644 --- a/tutorials/mesh/snappyHexMesh/opposite_walls/system/snappyHexMeshDict +++ b/tutorials/mesh/snappyHexMesh/opposite_walls/system/snappyHexMeshDict @@ -113,8 +113,10 @@ castellatedMeshControls // surfaces //gapLevel (1 2 10); - //MEJ: from cell level 2 onwards start checking for opposite - // surfaces + // Block any gap (opposite surfaces or opposite disconnected region + // of surface): + // - thinner than 2*blockcellsize where blockcellsize + // is the size of a cell at blockLevel blockLevel 2; } }