ENH: Add cellIndex enum and move use tests away from <0, == -1 tests.

This commit is contained in:
graham
2011-06-27 15:19:23 +01:00
parent 30c79d4a3e
commit 0565328638
3 changed files with 40 additions and 22 deletions

View File

@ -1622,11 +1622,7 @@ Foam::face Foam::conformalVoronoiMesh::buildDualFace
do
{
label cc1I = cc1->cellIndex();
label cc2I = cc2->cellIndex();
if (cc1I < 0 || cc2I < 0)
if (cc1->farCell() || cc2->farCell())
{
Cell_handle c = eit->first;
Vertex_handle vA = c->vertex(eit->second);
@ -1641,6 +1637,10 @@ Foam::face Foam::conformalVoronoiMesh::buildDualFace
<< exit(FatalError);
}
label cc1I = cc1->cellIndex();
label cc2I = cc2->cellIndex();
if (cc1I != cc2I)
{
if (findIndex(verticesOnFace, cc1I) == -1)
@ -1691,7 +1691,7 @@ Foam::label Foam::conformalVoronoiMesh::maxFilterCount
do
{
if (cc->cellIndex() < 0)
if (cc->farCell())
{
Cell_handle c = eit->first;
Vertex_handle vA = c->vertex(eit->second);
@ -1963,7 +1963,7 @@ void Foam::conformalVoronoiMesh::move()
++cit
)
{
cit->cellIndex() = -1;
cit->cellIndex() = Cb::ctFar;
if (cit->anyInternalOrBoundaryDualVertex())
{

View File

@ -328,7 +328,7 @@ void Foam::conformalVoronoiMesh::calcTetMesh
}
else
{
cit->cellIndex() = -1;
cit->cellIndex() = Cb::ctFar;
}
}
@ -368,18 +368,18 @@ void Foam::conformalVoronoiMesh::calcTetMesh
const int oppositeVertex = fit->second;
const Cell_handle c2(c1->neighbor(oppositeVertex));
if (c1->farCell() && c2->farCell())
{
// Both tets are outside, skip
continue;
}
label c1I = c1->cellIndex();
label c2I = c2->cellIndex();
label ownerCell = -1;
label neighbourCell = -1;
if (c1I == -1 && c2I == -1)
{
// Both tets are outside, skip
continue;
}
for (label i = 0; i < 3; i++)
{
verticesOnTriFace[i] = vertexMap
@ -390,10 +390,10 @@ void Foam::conformalVoronoiMesh::calcTetMesh
newFace = face(verticesOnTriFace);
if (c1I == -1 || c2I == -1)
if (c1->farCell() || c2->farCell())
{
// Boundary face...
if (c1I == -1)
if (c1->farCell())
{
//... with c1 outside
ownerCell = c2I;
@ -539,7 +539,7 @@ Foam::label Foam::conformalVoronoiMesh::mergeCloseDualVertices
continue;
}
if (c1I != -1 && c2I != -1 && (c1I != c2I))
if (!c1->farCell() && !c2->farCell() && (c1I != c2I))
{
if
(
@ -1828,7 +1828,7 @@ void Foam::conformalVoronoiMesh::indexDualVertices
}
else
{
cit->cellIndex() = -1;
cit->cellIndex() = Cb::ctFar;
}
}

View File

@ -57,7 +57,15 @@ class indexedCell
{
// Private data
//- The index for this Delaunay tetrahedral cell
//- The index for this Delaunay tetrahedral cell. Type information is
//- also carried:
// ctFar : the dual point of this cell does not form part of the
// internal or boundary of the dual mesh
// >=0 : the (local) index of an internal or boundary dual point,
// not on a processor face
// < 0 && > ctFar : the (global) index of a dual point on a processor
// face
int index_;
//- The number of times that this Delaunay cell has been limited
@ -67,6 +75,12 @@ class indexedCell
public:
enum cellTypes
{
ctFar = INT_MIN
};
typedef typename Cb::Vertex_handle Vertex_handle;
typedef typename Cb::Cell_handle Cell_handle;
@ -81,7 +95,7 @@ public:
indexedCell()
:
Cb(),
index_(-1),
index_(ctFar),
filterCount_(0)
{}
@ -92,7 +106,7 @@ public:
)
:
Cb(v0, v1, v2, v3),
index_(-1),
index_(ctFar),
filterCount_(0)
{}
@ -110,7 +124,7 @@ public:
)
:
Cb(v0, v1, v2, v3, n0, n1, n2, n3),
index_(-1),
index_(ctFar),
filterCount_(0)
{}
@ -126,6 +140,10 @@ public:
return index_;
}
inline bool farCell() const
{
return index_ == ctFar;
}
inline int& filterCount()
{