From 6974c3f99f9e5acd42c7c16b45b7505a19b9ea13 Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Thu, 26 Jul 2018 07:35:16 +0200 Subject: [PATCH] Bugfix in protectedInitialRefinement strategy Protect only if the current cell level is equal to the initial cell level, otherwise allow to unrefine. --- .../protectedInitialRefinement.C | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/refinementSelection/protectedInitialRefinement/protectedInitialRefinement.C b/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/refinementSelection/protectedInitialRefinement/protectedInitialRefinement.C index 7346ece6a..d776f917f 100644 --- a/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/refinementSelection/protectedInitialRefinement/protectedInitialRefinement.C +++ b/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/refinementSelection/protectedInitialRefinement/protectedInitialRefinement.C @@ -155,13 +155,19 @@ Foam::protectedInitialRefinement::unrefinementPointCandidates() const // Loop through all cells and count number of protected points label nProtectedPoints = 0; + // Get current cell level + const labelIOList& curCellLevel = + mesh().lookupObject("cellLevel"); + forAll (initialCellLevelIn, cellI) { const scalar& cl = initialCellLevelIn[cellI]; + const scalar curcl = curCellLevel[cellI]; - if (cl > SMALL) + if ((cl > SMALL) && equal(cl, curcl)) { - // Cell has been refined during meshing, mark all of its points + // Cell has been refined during meshing and the original level is + // equal to the current level, mark all of its points const labelList& curCellPoints = meshCellPoints[cellI]; forAll (curCellPoints, i) @@ -178,6 +184,21 @@ Foam::protectedInitialRefinement::unrefinementPointCandidates() const } } } + else if (cl > (curcl + SMALL)) + { + FatalErrorIn + ( + "Xfer\n" + "protectedInitialRefinement::unrefinementPointCandidates()" + " const" + ) << "Detected a cell with initial refinement level greater" + << " than current refinement level." << nl + << "cellI: " << cellI << nl + << "current level: " << curcl << nl + << "initial level: " << cl << nl + << "This should not happen." + << abort(FatalError); + } } // Create the list for unrefinement candidates