libMesh
Loading...
Searching...
No Matches
Public Member Functions | List of all members
LibMeshPoly2TriTest Class Reference
Inheritance diagram for LibMeshPoly2TriTest:
[legend]

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (LibMeshPoly2TriTest)
 
 CPPUNIT_TEST (testLibMeshPoly2Tri)
 
 CPPUNIT_TEST (testLibMeshPoly2TriHole)
 
 CPPUNIT_TEST (testLibMeshPoly2TriSlivers)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testLibMeshPoly2Tri ()
 
void testLibMeshPoly2TriHole ()
 
void testLibMeshPoly2TriSlivers ()
 

Detailed Description

Definition at line 12 of file libmesh_poly2tri.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/3]

LibMeshPoly2TriTest::CPPUNIT_TEST ( testLibMeshPoly2Tri  )

◆ CPPUNIT_TEST() [2/3]

LibMeshPoly2TriTest::CPPUNIT_TEST ( testLibMeshPoly2TriHole  )

◆ CPPUNIT_TEST() [3/3]

LibMeshPoly2TriTest::CPPUNIT_TEST ( testLibMeshPoly2TriSlivers  )

◆ CPPUNIT_TEST_SUITE_END()

LibMeshPoly2TriTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

LibMeshPoly2TriTest::LIBMESH_CPPUNIT_TEST_SUITE ( LibMeshPoly2TriTest  )

◆ setUp()

void LibMeshPoly2TriTest::setUp ( )
inline

Definition at line 27 of file libmesh_poly2tri.C.

28 {}

◆ tearDown()

void LibMeshPoly2TriTest::tearDown ( )
inline

Definition at line 30 of file libmesh_poly2tri.C.

31 {}

◆ testLibMeshPoly2Tri()

void LibMeshPoly2TriTest::testLibMeshPoly2Tri ( )
inline

Definition at line 34 of file libmesh_poly2tri.C.

35 {
36 LOG_UNIT_TEST;
37
38 std::vector<p2t::Point> pentagon {{0,0},{1,0},{1,1},{.5,1.5},{0,1}};
39
40 std::vector<p2t::Point *> api_shim(pentagon.size());
41 std::iota(api_shim.begin(), api_shim.end(), pentagon.data());
42
43 p2t::CDT cdt(api_shim);
44
45 cdt.Triangulate();
46
47 auto tris = cdt.GetTriangles();
48
49 // We mostly wanted to make sure this compiled, but might as well
50 // make sure it gave us the expected triangle count while we're at
51 // it.
52 CPPUNIT_ASSERT_EQUAL(tris.size(), std::size_t(3));
53 }

◆ testLibMeshPoly2TriHole()

void LibMeshPoly2TriTest::testLibMeshPoly2TriHole ( )
inline

Definition at line 55 of file libmesh_poly2tri.C.

56 {
57// const double eps = 0; // This (or negative eps) succeeds
58// const double eps = 1e-12; // This (or larger eps) succeeds
59 const double eps = 1e-15; // This gave EdgeEvent - null triangle with older Poly2Tri
60
61 std::vector<p2t::Point> outer_boundary
62 {{0,0},{0.5,eps},{1,0},{1-eps,0.836541},
63 {1,2},{.46,1.46+eps},{0,1},{eps,0.5}};
64
65 std::vector<p2t::Point *> api_shim(outer_boundary.size());
66 std::iota(api_shim.begin(), api_shim.end(), outer_boundary.data());
67
68 const double r2o4 = std::sqrt(2.)/4;
69 std::vector<p2t::Point> hole_boundary
70 {{0.5+r2o4,0.5},{0.5,0.5+r2o4},{0.5-r2o4,0.5},{0.5-eps,0.5-r2o4}};
71
72 std::vector<p2t::Point *> hole_shim(hole_boundary.size());
73 std::iota(hole_shim.begin(), hole_shim.end(), hole_boundary.data());
74
75 p2t::CDT cdt(api_shim);
76 cdt.AddHole(hole_shim);
77
78 std::vector<p2t::Point> interior_points
79 {{0.21,0.79},{0.21,0.21},{0.79,0.21}};
80 for (auto & p : interior_points)
81 cdt.AddPoint(&p);
82
83 cdt.Triangulate();
84
85 auto tris = cdt.GetTriangles();
86
87 std::cout << "With perturbation " << eps << " we got " << tris.size() << " triangles!" << std::endl;
88
89 // We mostly wanted to make sure this compiled, but might as well
90 // make sure it gave us the expected triangle count while we're at
91 // it.
92 CPPUNIT_ASSERT_EQUAL(tris.size(), std::size_t(18));
93 }

◆ testLibMeshPoly2TriSlivers()

void LibMeshPoly2TriTest::testLibMeshPoly2TriSlivers ( )
inline

Definition at line 95 of file libmesh_poly2tri.C.

96 {
97 // Points from a libMesh Poly2TriTriangulator failure case
98 std::vector<p2t::Point> outer_boundary
99 {{0, 0}, {1, 0}, {1, 2}, {0, 1}};
100
101 std::vector<p2t::Point *> api_shim(outer_boundary.size());
102 std::iota(api_shim.begin(), api_shim.end(), outer_boundary.data());
103
104 const double r2o4 = std::sqrt(2.)/4;
105 std::vector<p2t::Point> hole_boundary
106 {{0.5,0.5+r2o4},{0.5-r2o4,0.5},{0.5,0.5}};
107
108 std::vector<p2t::Point *> hole_shim(hole_boundary.size());
109 std::iota(hole_shim.begin(), hole_shim.end(), hole_boundary.data());
110
111 p2t::CDT cdt(api_shim);
112 cdt.AddHole(hole_shim);
113
114 // const double eps = 1e-12; // fails
115 const double eps = 1e-11; // succeeds
116
117 std::vector<p2t::Point> interior_points
118 {{0.5-(r2o4/2)-eps, 0.5+(r2o4/2)+eps}};
119
120 for (auto & p : interior_points)
121 cdt.AddPoint(&p);
122
123 cdt.Triangulate();
124 }

The documentation for this class was generated from the following file: