Bugfix while setting split points to unrefine

There was a bug when we had refinement and unrefinement in the same iteration.
Setting split points to unrefine needs to take into account existing cells to
refine by considering point neighbours, not face neighbours. This ensures that
the first split point to unrefine is far away from refinement region.
This commit is contained in:
Vuko Vukcevic 2018-02-06 16:11:40 +01:00
parent 6c693cb8d4
commit 0d4bd534e2
2 changed files with 72 additions and 10 deletions

View file

@ -315,7 +315,10 @@ void Foam::polyhedralRefinement::setInstance(const fileName& inst) const
} }
void Foam::polyhedralRefinement::extendMarkedCells(boolList& markedCell) const void Foam::polyhedralRefinement::extendMarkedCellsAcrossFaces
(
boolList& markedCell
) const
{ {
// Mark all faces for all marked cells // Mark all faces for all marked cells
const label nFaces = mesh_.nFaces(); const label nFaces = mesh_.nFaces();
@ -370,6 +373,63 @@ void Foam::polyhedralRefinement::extendMarkedCells(boolList& markedCell) const
} }
void Foam::polyhedralRefinement::extendMarkedCellsAcrossPoints
(
boolList& markedCell
) const
{
// Mark all points for all marked cells
const label nPoints = mesh_.nPoints();
boolList markedPoint(nPoints, false);
// Get cell points
const labelListList& meshCellPoints = mesh_.cellPoints();
// Loop through all cells
forAll (markedCell, cellI)
{
if (markedCell[cellI])
{
// This cell is marked, get its points
const labelList& cPoints = meshCellPoints[cellI];
forAll (cPoints, i)
{
markedPoint[cPoints[i]] = true;
}
}
}
// Snyc point list across processor boundaries
syncTools::syncPointList
(
mesh_,
markedPoint,
orEqOp<bool>(),
true, // Default value
true // Apply separation for parallel cyclics
);
// Get point cells
const labelListList& meshPointCells = mesh_.pointCells();
// Loop through all points
forAll (markedPoint, pointI)
{
if (markedPoint[pointI])
{
// This point is marked, mark all of its cells
const labelList& pCells = meshPointCells[pointI];
forAll (pCells, i)
{
markedCell[pCells[i]] = true;
}
}
}
}
void Foam::polyhedralRefinement::setPolyhedralRefinement void Foam::polyhedralRefinement::setPolyhedralRefinement
( (
polyTopoChange& ref polyTopoChange& ref
@ -3435,10 +3495,10 @@ void Foam::polyhedralRefinement::setCellsToRefine
} }
} }
// Extend cells using a specified number of buffer layers // Extend cells across faces using a specified number of buffer layers
for (label i = 0; i < nBufferLayers_; ++i) for (label i = 0; i < nBufferLayers_; ++i)
{ {
extendMarkedCells(refineCell); extendMarkedCellsAcrossFaces(refineCell);
} }
// Make sure that the refinement is face consistent (2:1 consistency) and // Make sure that the refinement is face consistent (2:1 consistency) and
@ -3648,11 +3708,12 @@ void Foam::polyhedralRefinement::setSplitPointsToUnrefine
protectedCell[cellsToRefine_[i]] = true; protectedCell[cellsToRefine_[i]] = true;
} }
// Extend protected cells using a specified number of buffer layers + 1 // Extend protected cells across points using a specified number of buffer
// in order to stay far away from cells that are going to be refined // layers + 1 in order to stay far away from cells that are going to be
// refined
for (label i = 0; i < nBufferLayers_ + 1; ++i) for (label i = 0; i < nBufferLayers_ + 1; ++i)
{ {
extendMarkedCells(protectedCell); extendMarkedCellsAcrossPoints(protectedCell);
} }
// Loop through all cells and if the cell should be protected, protect all // Loop through all cells and if the cell should be protected, protect all

View file

@ -145,10 +145,11 @@ private:
//- Set file instance for cellLevel_ and pointLevel_ //- Set file instance for cellLevel_ and pointLevel_
void setInstance(const fileName& inst) const; void setInstance(const fileName& inst) const;
//- Extend cells to refine. Given a markup field of refinement //- Extend marked cells across faces
// candidates (true for cells to refine), marks the neigbhours of void extendMarkedCellsAcrossFaces(boolList& markedCell) const;
// marked cells as well
void extendMarkedCells(boolList& refineCell) const; //- Extend marked cells across points
void extendMarkedCellsAcrossPoints(boolList& markedCell) const;
// Global topology modification functions (operate on whole polyMesh) // Global topology modification functions (operate on whole polyMesh)