BUG: foamyHexMesh: Remove internal points that are outside the surface.

This commit is contained in:
laurence
2013-06-05 14:00:18 +01:00
parent 7c00bbe7fa
commit 59ba920721
6 changed files with 147 additions and 70 deletions

View File

@ -787,8 +787,8 @@ Foam::face Foam::conformalVoronoiMesh::buildDualFace
<< "Dual face uses circumcenter defined by a " << "Dual face uses circumcenter defined by a "
<< "Delaunay tetrahedron with no internal " << "Delaunay tetrahedron with no internal "
<< "or boundary points. Defining Delaunay edge ends: " << "or boundary points. Defining Delaunay edge ends: "
<< topoint(vA->point()) << " " << vA->info() << " "
<< topoint(vB->point()) << nl << vB->info() << nl
<< exit(FatalError); << exit(FatalError);
} }
@ -1630,6 +1630,8 @@ void Foam::conformalVoronoiMesh::move()
); );
} }
DynamicList<Vertex_handle> pointsToRemove;
for for
( (
Delaunay::Finite_vertices_iterator vit = finite_vertices_begin(); Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
@ -1640,15 +1642,18 @@ void Foam::conformalVoronoiMesh::move()
if if
( (
(vit->internalPoint() || vit->internalBoundaryPoint()) (vit->internalPoint() || vit->internalBoundaryPoint())
&& !vit->referred() //&& !vit->referred()
) )
{ {
bool inside = geometryToConformTo_.inside const Foam::point& pt = topoint(vit->point());
(
topoint(vit->point())
);
if (!inside) bool inside = geometryToConformTo_.inside(pt);
if
(
!inside
|| !geometryToConformTo_.globalBounds().contains(pt)
)
{ {
if if
( (
@ -1658,13 +1663,16 @@ void Foam::conformalVoronoiMesh::move()
{ {
str().write(topoint(vit->point())); str().write(topoint(vit->point()));
} }
remove(vit);
pointsToRemove.append(vit);
internalPtIsOutside++; internalPtIsOutside++;
} }
} }
} }
Info<< " " << internalPtIsOutside remove(pointsToRemove.begin(), pointsToRemove.end());
Info<< " " << returnReduce(internalPtIsOutside, sumOp<label>())
<< " internal points were inserted outside the domain. " << " internal points were inserted outside the domain. "
<< "They have been removed." << endl; << "They have been removed." << endl;
} }

View File

@ -2458,6 +2458,54 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
|| (vB->internalOrBoundaryPoint() && !vB->referred()) || (vB->internalOrBoundaryPoint() && !vB->referred())
) )
{ {
if
(
(vA->internalPoint() && vB->externalBoundaryPoint())
|| (vB->internalPoint() && vA->externalBoundaryPoint())
)
{
Cell_circulator ccStart = incident_cells(*eit);
Cell_circulator cc1 = ccStart;
Cell_circulator cc2 = cc1;
cc2++;
bool skipEdge = false;
do
{
if
(
cc1->hasFarPoint() || cc2->hasFarPoint()
|| is_infinite(cc1) || is_infinite(cc2)
)
{
Pout<< "Ignoring edge between internal and external: "
<< vA->info()
<< vB->info();
skipEdge = true;
break;
}
cc1++;
cc2++;
} while (cc1 != ccStart);
// Do not create faces if the internal point is outside!
// This occurs because the internal point is not determined to
// be outside in the inside/outside test. This is most likely
// due to the triangle.nearestPointClassify test not returning
// edge/point as the nearest type.
if (skipEdge)
{
continue;
}
}
face newDualFace = buildDualFace(eit); face newDualFace = buildDualFace(eit);
if (newDualFace.size() >= 3) if (newDualFace.size() >= 3)

View File

@ -569,7 +569,20 @@ void Foam::conformalVoronoiMesh::buildSurfaceConformation()
Vertex_handle vA = c->vertex(eit->second); Vertex_handle vA = c->vertex(eit->second);
Vertex_handle vB = c->vertex(eit->third); Vertex_handle vB = c->vertex(eit->third);
if (vA->referred() || vB->referred()) if
(
vA->referred()
|| vB->referred()
)
{
continue;
}
if
(
(vA->internalPoint() && vA->referred())
|| (vB->internalPoint() && vB->referred())
)
{ {
continue; continue;
} }
@ -2183,59 +2196,59 @@ void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits
pointIndexHitAndFeature(edHit, featureHit) pointIndexHitAndFeature(edHit, featureHit)
); );
} }
else if (firstPass) // else if (firstPass)
{ // {
label hitIndex = nearestEdgeHit.index(); // label hitIndex = nearestEdgeHit.index();
//
// Calc new edge location // // Calc new edge location
Foam::point newPt = //// Foam::point newPt =
0.5 //// 0.5
*( //// *(
nearestEdgeHit.hitPoint() //// nearestEdgeHit.hitPoint()
+ edHit.hitPoint() //// + edHit.hitPoint()
); //// );
//
pointIndexHit pHitOld = // pointIndexHit pHitOld =
edgeLocationTreePtr_().findNearest // edgeLocationTreePtr_().findNearest
( // (
nearestEdgeHit.hitPoint(), GREAT // nearestEdgeHit.hitPoint(), GREAT
); // );
//
pointIndexHit pHitNew = // pointIndexHit pHitNew =
edgeLocationTreePtr_().findNearest // edgeLocationTreePtr_().findNearest
( // (
edHit.hitPoint(), GREAT // edHit.hitPoint(), GREAT
); // );
//
if // if
( // (
magSqr(pHitNew.hitPoint() - edHit.hitPoint()) // magSqr(pHitNew.hitPoint() - edHit.hitPoint())
< magSqr // < magSqr
( // (
pHitOld.hitPoint() // pHitOld.hitPoint()
- nearestEdgeHit.hitPoint() // - nearestEdgeHit.hitPoint()
) // )
) // )
{ // {
edHit.setPoint(edHit.hitPoint()); // edHit.setPoint(edHit.hitPoint());
//
featureEdgeHits[hitIndex] = // featureEdgeHits[hitIndex] =
pointIndexHitAndFeature(edHit, featureHit); // pointIndexHitAndFeature(edHit, featureHit);
//
existingEdgeLocations_[hitIndex] = // existingEdgeLocations_[hitIndex] =
edHit.hitPoint(); // edHit.hitPoint();
//
// Change edge location in featureEdgeHits // // Change edge location in featureEdgeHits
// remove index from edge tree // // remove index from edge tree
// reinsert new point into tree // // reinsert new point into tree
edgeLocationTreePtr_().remove(hitIndex); // edgeLocationTreePtr_().remove(hitIndex);
edgeLocationTreePtr_().insert // edgeLocationTreePtr_().insert
( // (
hitIndex, // hitIndex,
hitIndex + 1 // hitIndex + 1
); // );
} // }
} // }
} }
} }
} }

View File

@ -1458,8 +1458,6 @@ void Foam::conformalVoronoiMesh::createFeaturePoints(DynamicList<Vb>& pts)
forAll(feMeshes, i) forAll(feMeshes, i)
{ {
Info<< indent << "Edge mesh = " << feMeshes[i].name() << nl << endl;
const extendedFeatureEdgeMesh& feMesh(feMeshes[i]); const extendedFeatureEdgeMesh& feMesh(feMeshes[i]);
for for

View File

@ -101,7 +101,9 @@ void Foam::conformalVoronoiMesh::drawDelaunayCell
// Supply offset as tet number // Supply offset as tet number
offset *= 4; offset *= 4;
os << "# cell index: " << label(c->cellIndex()) << endl; os << "# cell index: " << label(c->cellIndex())
<< " INT_MIN = " << INT_MIN
<< endl;
os << "# circumradius " os << "# circumradius "
<< mag(c->dual() - topoint(c->vertex(0)->point())) << mag(c->dual() - topoint(c->vertex(0)->point()))
@ -112,7 +114,15 @@ void Foam::conformalVoronoiMesh::drawDelaunayCell
os << "# index / type / procIndex: " os << "# index / type / procIndex: "
<< label(c->vertex(i)->index()) << " " << label(c->vertex(i)->index()) << " "
<< label(c->vertex(i)->type()) << " " << label(c->vertex(i)->type()) << " "
<< label(c->vertex(i)->procIndex()) << endl; << label(c->vertex(i)->procIndex())
<< (is_infinite(c->vertex(i)) ? " # This vertex is infinite!" : "")
<<
(
c->vertex(i)->uninitialised()
? " # This vertex is uninitialised!"
: ""
)
<< endl;
meshTools::writeOBJ(os, topoint(c->vertex(i)->point())); meshTools::writeOBJ(os, topoint(c->vertex(i)->point()));
} }

View File

@ -706,8 +706,8 @@ Foam::Field<bool> Foam::conformationSurfaces::wellInside
// Info<< surface.name() << " = " // Info<< surface.name() << " = "
// << volumeType::names[surfaceVolumeTests[s][i]] << endl; // << volumeType::names[surfaceVolumeTests[s][i]] << endl;
//if (surfaceVolumeTests[s][i] == volumeType::OUTSIDE) if (surfaceVolumeTests[s][i] == volumeType::OUTSIDE)
if (surfaceVolumeTests[s][i] != volumeType::INSIDE) // if (surfaceVolumeTests[s][i] != volumeType::INSIDE)
{ {
insidePoint[i] = false; insidePoint[i] = false;