Skip to content

Commit 890d938

Browse files
roystgnrmiaoyinb
authored andcommitted
New unit test
This fails for me on master, and works for me with the new patch, so hopefully it'll be a reliable way of making sure that any improved code doesn't revert the fix.
1 parent 3767c48 commit 890d938

File tree

1 file changed

+69
-1
lines changed

1 file changed

+69
-1
lines changed

tests/mesh/mesh_triangulation.C

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public:
5454
// This covers an old poly2tri collinearity-tolerance bug
5555
CPPUNIT_TEST( testPoly2TriHolesExtraRefined );
5656

57+
// This covers a more recent tolerance bug when verifying holes
58+
CPPUNIT_TEST( testPoly2TriHolePerturbed );
59+
5760
CPPUNIT_TEST( testPoly2TriNonUniformRefined );
5861
CPPUNIT_TEST( testPoly2TriHolesNonUniformRefined );
5962
#endif
@@ -64,6 +67,7 @@ public:
6467
CPPUNIT_TEST( testTriangleInterp );
6568
CPPUNIT_TEST( testTriangleInterp2 );
6669
CPPUNIT_TEST( testTriangleHoles );
70+
CPPUNIT_TEST( testTriangleHolePerturbed );
6771
CPPUNIT_TEST( testTriangleMeshedHoles );
6872
CPPUNIT_TEST( testTriangleEdges );
6973
CPPUNIT_TEST( testTriangleSegments );
@@ -84,7 +88,7 @@ public:
8488
triangulator.triangulation_type() = TriangulatorInterface::PSLG;
8589

8690
// Don't try to insert points unless we're requested to later
87-
triangulator.desired_area() = 1000;
91+
triangulator.desired_area() = 1e16;
8892
triangulator.minimum_angle() = 0;
8993
triangulator.smooth_after_generating() = false;
9094
triangulator.set_verify_hole_boundaries(true);
@@ -469,6 +473,50 @@ public:
469473
}
470474

471475

476+
void testTriangulatorHolePerturbed(MeshBase & mesh,
477+
TriangulatorInterface & triangulator)
478+
{
479+
// Points based on a simplification of a hole verification failure
480+
// case
481+
mesh.add_point(Point(100,0), 0);
482+
mesh.add_point(Point(100,100), 1);
483+
mesh.add_point(Point(0,100), 2);
484+
mesh.add_point(Point(-100,100), 3);
485+
mesh.add_point(Point(-100,0), 4);
486+
mesh.add_point(Point(-100,-100), 5);
487+
mesh.add_point(Point(0,-100), 6);
488+
mesh.add_point(Point(100,-100), 7);
489+
490+
commonSettings(triangulator);
491+
492+
// Add a diamond hole in *almost* the center
493+
TriangulatorInterface::PolygonHole
494+
diamond(Point(0,4.e-16),
495+
std::sqrt(2)/2, 4);
496+
const std::vector<TriangulatorInterface::Hole*> holes { &diamond };
497+
triangulator.attach_hole_list(&holes);
498+
499+
triangulator.triangulate();
500+
501+
CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(12));
502+
503+
// Center coordinates for all the elements we expect
504+
const Real r2p200o6 = (std::sqrt(Real(2))+200)/6,
505+
r2p400o6 = (std::sqrt(Real(2))+400)/6;
506+
507+
std::vector <Point> expected_centers
508+
{ {r2p400o6,100./3}, {-r2p400o6,100./3},
509+
{r2p400o6,-100./3}, {-r2p400o6,-100./3},
510+
{100./3,r2p400o6}, {-100./3,r2p400o6},
511+
{100./3,-r2p400o6}, {-100./3,-r2p400o6},
512+
{r2p200o6,r2p200o6}, {-r2p200o6,r2p200o6},
513+
{r2p200o6,-r2p200o6}, {-r2p200o6,-r2p200o6},
514+
};
515+
516+
testFoundCenters(mesh, expected_centers);
517+
}
518+
519+
472520
void testTriangulatorMeshedHoles(MeshBase & mesh,
473521
TriangulatorInterface & triangulator)
474522
{
@@ -652,6 +700,16 @@ public:
652700
}
653701

654702

703+
void testTriangleHolePerturbed()
704+
{
705+
LOG_UNIT_TEST;
706+
707+
Mesh mesh(*TestCommWorld);
708+
TriangleInterface triangle(mesh);
709+
testTriangulatorHolePerturbed(mesh, triangle);
710+
}
711+
712+
655713
void testTriangleMeshedHoles()
656714
{
657715
LOG_UNIT_TEST;
@@ -736,6 +794,16 @@ public:
736794
}
737795

738796

797+
void testPoly2TriHolePerturbed()
798+
{
799+
LOG_UNIT_TEST;
800+
801+
Mesh mesh(*TestCommWorld);
802+
Poly2TriTriangulator p2t_tri(mesh);
803+
testTriangulatorHolePerturbed(mesh, p2t_tri);
804+
}
805+
806+
739807
void testPoly2TriMeshedHoles()
740808
{
741809
LOG_UNIT_TEST;

0 commit comments

Comments
 (0)