diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C index d9af3f11ee..5606e4f731 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C @@ -2408,14 +2408,18 @@ void Foam::meshRefinement::growCellZone List allFaceInfo(mesh_.nFaces()); - FaceCellWave wallDistCalc + + const bitSet isBlockedFace(mesh_.nFaces()); + wallPoints::trackData td(isBlockedFace); + FaceCellWave 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 2eb37d76f8..ff7e5ff556 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> originSurface(2); //DynamicList 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 allFaceInfo(mesh_.nFaces()); List allCellInfo(mesh_.nCells()); - FaceCellWave 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 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 fe8aad6818..015c5115de 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 89d84a3660..ddd9550367 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) - { - const FixedList& nbrSurface = neighbourInfo.surface_[i]; - // Find in my surfaces - label index = surface_.find(nbrSurface); - if (index == -1) + if (!td.isBlockedFace_[thisFacei]) + { + const point& fc = mesh.faceCentres()[thisFacei]; + + 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& 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) - { - const FixedList& nbrSurface = neighbourInfo.surface_[i]; - // Find in my surfaces - label index = surface_.find(nbrSurface); - if (index == -1) + if (!td.isBlockedFace_[thisFacei]) + { + const point& fc = mesh.faceCentres()[thisFacei]; + + 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& 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 2b058fc5a7..0000000000 --- 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 87ac459a35..b6871ce5e3 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; } }