Bug fix for single-cell mesh

This commit is contained in:
Hrvoje Jasak 2011-10-10 12:19:20 +01:00
parent f061215be0
commit 34def356ec

View file

@ -1353,55 +1353,58 @@ bool Foam::primitiveMesh::checkUpperTriangular
} }
} }
nbr.sort(); if (!nbr.empty())
// Now nbr holds the cellCells in incremental order. Check:
// - neighbouring cells appear only once. Since nbr is sorted this
// is simple check on consecutive elements
// - faces indexed in same order as nbr are incrementing as well.
label prevCell = nbr[0];
label prevFace = curFaces[nbr.indices()[0]];
bool hasMultipleFaces = false;
for (label i = 1; i < nbr.size(); i++)
{ {
label thisCell = nbr[i]; nbr.sort();
label thisFace = curFaces[nbr.indices()[i]];
if (thisCell == labelMax) // Now nbr holds the cellCells in incremental order. Check:
// - neighbouring cells appear only once. Since nbr is sorted this
// is simple check on consecutive elements
// - faces indexed in same order as nbr are incrementing as well.
label prevCell = nbr[0];
label prevFace = curFaces[nbr.indices()[0]];
bool hasMultipleFaces = false;
for (label i = 1; i < nbr.size(); i++)
{ {
break; label thisCell = nbr[i];
} label thisFace = curFaces[nbr.indices()[i]];
if (thisCell == prevCell) if (thisCell == labelMax)
{
hasMultipleFaces = true;
if (setPtr)
{ {
setPtr->insert(prevFace); break;
setPtr->insert(thisFace);
} }
}
else if (thisFace < prevFace)
{
error = true;
if (setPtr) if (thisCell == prevCell)
{ {
setPtr->insert(thisFace); hasMultipleFaces = true;
if (setPtr)
{
setPtr->insert(prevFace);
setPtr->insert(thisFace);
}
} }
else if (thisFace < prevFace)
{
error = true;
if (setPtr)
{
setPtr->insert(thisFace);
}
}
prevCell = thisCell;
prevFace = thisFace;
} }
prevCell = thisCell; if (hasMultipleFaces)
prevFace = thisFace; {
} nMultipleCells++;
}
if (hasMultipleFaces)
{
nMultipleCells++;
} }
} }