ENH: boundaryFirstRenumber: add sorting of front cells

This commit is contained in:
mattijs
2012-02-22 14:46:08 +00:00
parent be7186dea1
commit 016dac0e5c
2 changed files with 66 additions and 5 deletions

View File

@ -43,6 +43,30 @@ namespace Foam
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::label Foam::boundaryFirstRenumber::countInternalFaces
(
const primitiveMesh& mesh,
const label cellI
) const
{
const cell& cFaces = mesh.cells()[cellI];
label nInt = 0;
forAll(cFaces, i)
{
label faceI = cFaces[i];
if (mesh.isInternalFace(faceI))
{
nInt++;
}
}
return nInt;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::boundaryFirstRenumber::boundaryFirstRenumber
@ -99,11 +123,19 @@ Foam::labelList Foam::boundaryFirstRenumber::renumber
}
}
DynamicList<label> frontCells(frontFaces.size());
DynamicList<label> frontCellWeights(frontFaces.size());
// - ordering
labelList order;
// Loop over all frontFaces
label currentDistance = 0;
while (frontFaces.size() > 0)
{
DynamicList<label> frontCells(frontFaces.size());
frontCells.clear();
frontCellWeights.clear();
// Set all of frontFaces' neighbours to current distance
@ -118,12 +150,28 @@ Foam::labelList Foam::boundaryFirstRenumber::renumber
{
distance[ownCellI] = currentDistance;
frontCells.append(ownCellI);
frontCellWeights.append
(
countInternalFaces
(
mesh,
ownCellI
)
);
}
label neiCellI = nei[faceI];
if (distance[neiCellI] == -1)
{
distance[neiCellI] = currentDistance;
frontCells.append(neiCellI);
frontCellWeights.append
(
countInternalFaces
(
mesh,
neiCellI
)
);
}
}
else
@ -133,6 +181,14 @@ Foam::labelList Foam::boundaryFirstRenumber::renumber
{
distance[ownCellI] = currentDistance;
frontCells.append(ownCellI);
frontCellWeights.append
(
countInternalFaces
(
mesh,
ownCellI
)
);
}
}
}
@ -142,11 +198,12 @@ Foam::labelList Foam::boundaryFirstRenumber::renumber
// << frontCells.size() << " cells." << endl;
// TBD. Determine order within current shell (frontCells). For now
// just add them.
forAll(frontCells, i)
// Determine order within current shell (frontCells) and add them
sortedOrder(frontCellWeights, order);
// 3. Add in sorted order
forAll(order, i)
{
newOrder[cellInOrder] = frontCells[i];
newOrder[cellInOrder] = frontCells[order[i]];
cellInOrder++;
}

View File

@ -56,6 +56,10 @@ class boundaryFirstRenumber
// Private Member Functions
//- Count the number of internal faces of a cell
label countInternalFaces(const primitiveMesh&, const label) const;
//- Disallow default bitwise copy construct and assignment
void operator=(const boundaryFirstRenumber&);
boundaryFirstRenumber(const boundaryFirstRenumber&);