Refactorisation in refinement polyMeshModifier

Moved extendMarkedCellsAcrossFaces and extendMarkedCellsAcrossPoints from
refinement to meshTools.
This commit is contained in:
Vuko Vukcevic 2019-02-20 12:55:06 +01:00
parent 0efa19e651
commit cea60ab8ab
6 changed files with 150 additions and 134 deletions

View file

@ -31,6 +31,7 @@ Author
#include "faceSet.H" #include "faceSet.H"
#include "pointSet.H" #include "pointSet.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "meshTools.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -2042,7 +2043,7 @@ void Foam::polyhedralRefinement::setCellsToRefine
// layers // layers
for (label i = 0; i < nRefinementBufferLayers_; ++i) for (label i = 0; i < nRefinementBufferLayers_; ++i)
{ {
extendMarkedCellsAcrossFaces(refineCell); meshTools::extendMarkedCellsAcrossFaces(mesh_, refineCell);
} }
// Remove all cells that would exceed the maximum refinement level // Remove all cells that would exceed the maximum refinement level
@ -2266,7 +2267,7 @@ void Foam::polyhedralRefinement::setSplitPointsToUnrefine
// unrefinement buffer layers // unrefinement buffer layers
for (label i = 0; i < nUnrefinementBufferLayers_; ++i) for (label i = 0; i < nUnrefinementBufferLayers_; ++i)
{ {
extendMarkedCellsAcrossPoints(protectedCell); meshTools::extendMarkedCellsAcrossPoints(mesh_, 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

@ -33,6 +33,7 @@ Author
#include "emptyPolyPatch.H" #include "emptyPolyPatch.H"
#include "wedgePolyPatch.H" #include "wedgePolyPatch.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "meshTools.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -2601,7 +2602,7 @@ void Foam::prismatic2DRefinement::setCellsToRefine
// layers // layers
for (label i = 0; i < nRefinementBufferLayers_; ++i) for (label i = 0; i < nRefinementBufferLayers_; ++i)
{ {
extendMarkedCellsAcrossFaces(refineCell); meshTools::extendMarkedCellsAcrossFaces(mesh_, refineCell);
} }
// Remove all cells that exceed the maximum refinement level // Remove all cells that exceed the maximum refinement level
@ -2838,7 +2839,7 @@ void Foam::prismatic2DRefinement::setSplitPointsToUnrefine
// unrefinement buffer layers // unrefinement buffer layers
for (label i = 0; i < nUnrefinementBufferLayers_; ++i) for (label i = 0; i < nUnrefinementBufferLayers_; ++i)
{ {
extendMarkedCellsAcrossPoints(protectedCell); meshTools::extendMarkedCellsAcrossPoints(mesh_, 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

@ -66,130 +66,6 @@ void Foam::refinement::setInstance(const fileName& inst) const
} }
void Foam::refinement::extendMarkedCellsAcrossFaces
(
boolList& markedCell
) const
{
// Mark all faces for all marked cells
const label nFaces = mesh_.nFaces();
boolList markedFace(nFaces, false);
// Get mesh cells
const cellList& meshCells = mesh_.cells();
// Loop through all cells
forAll (markedCell, cellI)
{
if (markedCell[cellI])
{
// This cell is marked, get its faces
const cell& cFaces = meshCells[cellI];
forAll (cFaces, i)
{
markedFace[cFaces[i]] = true;
}
}
}
// Snyc the face list across processor boundaries
syncTools::syncFaceList(mesh_, markedFace, orEqOp<bool>(), false);
// Get necessary mesh data
const label nInternalFaces = mesh_.nInternalFaces();
const labelList& owner = mesh_.faceOwner();
const labelList& neighbour = mesh_.faceNeighbour();
// Internal faces
for (label faceI = 0; faceI < nInternalFaces; ++faceI)
{
if (markedFace[faceI])
{
// Face is marked, mark both owner and neighbour if the maximum
// refinement level is not exceeded
const label& own = owner[faceI];
const label& nei = neighbour[faceI];
// Mark owner and neighbour cells
markedCell[own] = true;
markedCell[nei] = true;
}
}
// Boundary faces
for (label faceI = nInternalFaces; faceI < nFaces; ++faceI)
{
if (markedFace[faceI])
{
// Face is marked, mark owner if the maximum refinement level is not
// exceeded
const label& own = owner[faceI];
// Mark owner
markedCell[own] = true;
}
}
}
void Foam::refinement::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;
}
}
}
}
Foam::label Foam::refinement::addFace Foam::label Foam::refinement::addFace
( (
polyTopoChange& ref, polyTopoChange& ref,

View file

@ -159,12 +159,6 @@ protected:
//- 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 marked cells across faces
void extendMarkedCellsAcrossFaces(boolList& markedCell) const;
//- Extend marked cells across points
void extendMarkedCellsAcrossPoints(boolList& markedCell) const;
// Local topology modification functions (operate on cells/faces) // Local topology modification functions (operate on cells/faces)

View file

@ -27,6 +27,7 @@ License
#include "polyMesh.H" #include "polyMesh.H"
#include "hexMatcher.H" #include "hexMatcher.H"
#include "faceZone.H" #include "faceZone.H"
#include "syncTools.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -927,4 +928,128 @@ void Foam::meshTools::setFaceInfo
} }
void Foam::meshTools::extendMarkedCellsAcrossFaces
(
const polyMesh& mesh,
boolList& markedCell
)
{
// Mark all faces for all marked cells
const label nFaces = mesh.nFaces();
boolList markedFace(nFaces, false);
// Get mesh cells
const cellList& meshCells = mesh.cells();
// Loop through all cells
forAll (markedCell, cellI)
{
if (markedCell[cellI])
{
// This cell is marked, get its faces
const cell& cFaces = meshCells[cellI];
forAll (cFaces, i)
{
markedFace[cFaces[i]] = true;
}
}
}
// Snyc the face list across processor boundaries
syncTools::syncFaceList(mesh, markedFace, orEqOp<bool>(), false);
// Get necessary mesh data
const label nInternalFaces = mesh.nInternalFaces();
const labelList& owner = mesh.faceOwner();
const labelList& neighbour = mesh.faceNeighbour();
// Internal faces
for (label faceI = 0; faceI < nInternalFaces; ++faceI)
{
if (markedFace[faceI])
{
// Face is marked, mark both owner and neighbour
const label& own = owner[faceI];
const label& nei = neighbour[faceI];
// Mark owner and neighbour cells
markedCell[own] = true;
markedCell[nei] = true;
}
}
// Boundary faces
for (label faceI = nInternalFaces; faceI < nFaces; ++faceI)
{
if (markedFace[faceI])
{
// Face is marked, mark owner
const label& own = owner[faceI];
// Mark owner
markedCell[own] = true;
}
}
}
void Foam::meshTools::extendMarkedCellsAcrossPoints
(
const polyMesh& mesh,
boolList& markedCell
)
{
// 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;
}
}
}
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -318,6 +318,25 @@ namespace meshTools
label& zoneFlip label& zoneFlip
); );
// Mark-up of mesh bits. Relocated from refinement polyMeshModifier
//- Extend marked cells across faces given a bool list of already marked
// cells
void extendMarkedCellsAcrossFaces
(
const polyMesh& mesh,
boolList& markedCell
);
//- Extend marked cells across points given a bool list of already
// marked cells
void extendMarkedCellsAcrossPoints
(
const polyMesh& mesh,
boolList& markedCell
);
} // End namespace meshTools } // End namespace meshTools