1 #include <libmesh/boundary_info.h> 2 #include <libmesh/elem.h> 3 #include <libmesh/mesh.h> 4 #include <libmesh/mesh_generation.h> 5 #include <libmesh/mesh_modification.h> 6 #include <libmesh/mesh_triangle_holes.h> 7 #include <libmesh/mesh_triangle_interface.h> 8 #include <libmesh/parallel_implementation.h> 9 #include <libmesh/parsed_function.h> 10 #include <libmesh/point.h> 11 #include <libmesh/poly2tri_triangulator.h> 32 CPPUNIT_TEST( testTriangleHoleArea );
33 CPPUNIT_TEST( testTriangleHoleContains );
35 #ifdef LIBMESH_HAVE_POLY2TRI 36 CPPUNIT_TEST( testPoly2Tri );
37 CPPUNIT_TEST( testPoly2TriHalfDomain );
38 CPPUNIT_TEST( testPoly2TriHalfDomainEdge3 );
39 CPPUNIT_TEST( testPoly2TriInterp );
40 CPPUNIT_TEST( testPoly2TriInterp2 );
41 CPPUNIT_TEST( testPoly2TriHoles );
42 CPPUNIT_TEST( testPoly2TriMeshedHoles );
43 # ifdef LIBMESH_ENABLE_AMR 44 CPPUNIT_TEST( testPoly2TriRoundHole );
46 CPPUNIT_TEST( testPoly2TriEdges );
47 CPPUNIT_TEST( testPoly2TriEdge3s );
48 CPPUNIT_TEST( testPoly2TriBadEdges );
49 CPPUNIT_TEST( testPoly2TriBad1DMultiBoundary );
50 CPPUNIT_TEST( testPoly2TriBad2DMultiBoundary );
51 CPPUNIT_TEST( testPoly2TriEdgesRefined );
52 CPPUNIT_TEST( testPoly2TriSegments );
53 CPPUNIT_TEST( testPoly2TriRefined );
54 CPPUNIT_TEST( testPoly2TriNonRefined );
55 CPPUNIT_TEST( testPoly2TriExtraRefined );
56 CPPUNIT_TEST( testPoly2TriHolesRefined );
57 CPPUNIT_TEST( testPoly2TriHolesInterpRefined );
58 CPPUNIT_TEST( testPoly2TriHolesInteriorRefined );
59 CPPUNIT_TEST( testPoly2TriHolesInteriorExtraRefined );
61 CPPUNIT_TEST( testPoly2TriHolesExtraRefined );
63 CPPUNIT_TEST( testPoly2TriNonUniformRefined );
64 CPPUNIT_TEST( testPoly2TriHolesNonUniformRefined );
67 #ifdef LIBMESH_HAVE_TRIANGLE 68 CPPUNIT_TEST( testTriangle );
69 CPPUNIT_TEST( testTriangleHalfDomain );
70 CPPUNIT_TEST( testTriangleInterp );
71 CPPUNIT_TEST( testTriangleInterp2 );
72 CPPUNIT_TEST( testTriangleHoles );
73 CPPUNIT_TEST( testTriangleMeshedHoles );
74 # ifdef LIBMESH_ENABLE_AMR 75 CPPUNIT_TEST( testTriangleRoundHole );
77 CPPUNIT_TEST( testTriangleEdges );
78 CPPUNIT_TEST( testTriangleSegments );
81 CPPUNIT_TEST_SUITE_END();
106 #ifdef LIBMESH_ENABLE_EXCEPTIONS 110 bool threw_desired_exception =
false;
112 this->testTriangulatorBase(
mesh, triangulator);
115 std::regex msg_regex(re);
116 CPPUNIT_ASSERT(std::regex_search(e.what(), msg_regex));
117 threw_desired_exception =
true;
119 catch (CppUnit::Exception & e) {
123 CPPUNIT_ASSERT_MESSAGE(
"Unexpected exception type thrown",
false);
125 CPPUNIT_ASSERT(threw_desired_exception);
137 std::vector<TriangulatorInterface::PolygonHole> polyholes;
140 polyholes.emplace_back(center,
radius, 2);
142 polyholes.emplace_back(center,
radius, 3);
144 polyholes.emplace_back(center,
radius, 4);
146 polyholes.emplace_back(center,
radius, 5);
148 polyholes.emplace_back(center,
radius, 6);
150 for (
int i=0; i != 5; ++i)
152 const int n_sides = i+2;
155 const Real computed_area = hole.
area();
156 const Real theta =
pi/n_sides;
157 const Real half_side_length =
radius*std::cos(theta);
159 const Real area = n_sides * apothem * half_side_length;
167 #ifdef LIBMESH_HAVE_TRIANGLE 169 TriangleInterface::PolygonHole square(center,
radius, 4);
182 std::vector<TriangulatorInterface::PolygonHole> polyholes;
184 auto check_corners = [center,
radius]
188 CPPUNIT_ASSERT_EQUAL(np, hole.n_points());
192 const Real xin = center(0) +
radius * .99 * std::cos(theta);
193 const Real xout = center(0) +
radius * 1.01 * std::cos(theta);
194 const Real yin = center(1) +
radius * .99 * std::sin(theta);
195 const Real yout = center(1) +
radius * 1.01 * std::sin(theta);
197 CPPUNIT_ASSERT(hole.contains(
Point(xin, yin)));
198 CPPUNIT_ASSERT(!hole.contains(
Point(xout, yout)));
203 check_corners(triangle, 3);
205 check_corners(diamond, 4);
207 check_corners(hexagon, 6);
210 {{1,0}, {{0,-1},{2,-1},{2,1},{1.75,-.5},{1.5,1},{1.25,-.5},
211 {1,1},{.75,-.5},{.5,1},{.25,-.5},{0,1}}};
213 CPPUNIT_ASSERT(jaggy.contains({.1,-.3}));
214 CPPUNIT_ASSERT(jaggy.contains({.5,.9}));
215 CPPUNIT_ASSERT(jaggy.contains({.9,-.3}));
216 CPPUNIT_ASSERT(jaggy.contains({1,0}));
217 CPPUNIT_ASSERT(jaggy.contains({1.1,-.4}));
218 CPPUNIT_ASSERT(jaggy.contains({1.5,.9}));
219 CPPUNIT_ASSERT(jaggy.contains({1.9,-.3}));
221 CPPUNIT_ASSERT(jaggy.contains({1.9,-.5}));
222 CPPUNIT_ASSERT(jaggy.contains({1.6,-.5}));
223 CPPUNIT_ASSERT(jaggy.contains({1.1,-.5}));
224 CPPUNIT_ASSERT(jaggy.contains({.5,-.5}));
225 CPPUNIT_ASSERT(jaggy.contains({.2,-.5}));
227 CPPUNIT_ASSERT(!jaggy.contains({.1,.7}));
228 CPPUNIT_ASSERT(!jaggy.contains({.5,1.1}));
229 CPPUNIT_ASSERT(!jaggy.contains({.9,.7}));
230 CPPUNIT_ASSERT(!jaggy.contains({1,-1.1}));
231 CPPUNIT_ASSERT(!jaggy.contains({1.1,.8}));
232 CPPUNIT_ASSERT(!jaggy.contains({1.5,1.1}));
233 CPPUNIT_ASSERT(!jaggy.contains({1.9,.9}));
235 CPPUNIT_ASSERT(!jaggy.contains({1.9,1}));
236 CPPUNIT_ASSERT(!jaggy.contains({1.4,1}));
237 CPPUNIT_ASSERT(!jaggy.contains({.9,1}));
238 CPPUNIT_ASSERT(!jaggy.contains({.4,1}));
239 CPPUNIT_ASSERT(!jaggy.contains({-.2,1}));
240 CPPUNIT_ASSERT(!jaggy.contains({-.2,0}));
241 CPPUNIT_ASSERT(!jaggy.contains({1.2,0}));
244 {{1,0}, {{-.25,-1},{2,-1},{2,1},{1.75,1},{1.75,-.5},{1.5,-.5},
245 {1.5,1},{1.25,1},{1.25,-.5},{1,-.5},{1,1},{.75,1},
246 {.75,-.5},{.5,-.5},{.5,1},{.25,1},{.25,-.5},{0,-.5},
249 CPPUNIT_ASSERT(square_jaggy.contains({-.1,-.3}));
250 CPPUNIT_ASSERT(square_jaggy.contains({.4,.9}));
251 CPPUNIT_ASSERT(square_jaggy.contains({.9,-.3}));
252 CPPUNIT_ASSERT(square_jaggy.contains({.9,0}));
253 CPPUNIT_ASSERT(square_jaggy.contains({1.1,-.6}));
254 CPPUNIT_ASSERT(square_jaggy.contains({1.4,.9}));
255 CPPUNIT_ASSERT(square_jaggy.contains({1.9,-.3}));
257 CPPUNIT_ASSERT(!square_jaggy.contains({.1,-.3}));
258 CPPUNIT_ASSERT(!square_jaggy.contains({.6,.9}));
259 CPPUNIT_ASSERT(!square_jaggy.contains({1.1,-.3}));
260 CPPUNIT_ASSERT(!square_jaggy.contains({1.1,0}));
261 CPPUNIT_ASSERT(!square_jaggy.contains({1.1,-1.6}));
262 CPPUNIT_ASSERT(!square_jaggy.contains({1.6,.9}));
263 CPPUNIT_ASSERT(!square_jaggy.contains({2.1,-.3}));
265 CPPUNIT_ASSERT(square_jaggy.contains({-.1,-.5}));
266 CPPUNIT_ASSERT(square_jaggy.contains({.3,-.5}));
267 CPPUNIT_ASSERT(square_jaggy.contains({.9,-.5}));
268 CPPUNIT_ASSERT(square_jaggy.contains({1.3,-.5}));
269 CPPUNIT_ASSERT(square_jaggy.contains({1.9,-.5}));
271 CPPUNIT_ASSERT(!square_jaggy.contains({-.3,1}));
272 CPPUNIT_ASSERT(!square_jaggy.contains({.2,1}));
273 CPPUNIT_ASSERT(!square_jaggy.contains({.6,1}));
274 CPPUNIT_ASSERT(!square_jaggy.contains({1.1,1}));
275 CPPUNIT_ASSERT(!square_jaggy.contains({1.6,1}));
276 CPPUNIT_ASSERT(!square_jaggy.contains({2.1,1}));
283 commonSettings(triangulator);
288 for (
const auto & elem :
mesh.element_ptr_range())
290 CPPUNIT_ASSERT_EQUAL(elem->type(),
TRI3);
294 (elem->point(1) - elem->point(0)).cross
295 (elem->point(2) - elem->point(0));
297 CPPUNIT_ASSERT_GREATER(
Real(0), cross_prod(2));
299 bool found_triangle =
false;
300 for (
const auto & node : elem->node_ref_range())
302 const Point & point = node;
303 if (point ==
Point(0,0))
305 found_triangle =
true;
306 CPPUNIT_ASSERT((elem->point(0) ==
Point(0,0) &&
307 elem->point(1) ==
Point(1,0) &&
308 elem->point(2) ==
Point(0,1)) ||
309 (elem->point(1) ==
Point(0,0) &&
310 elem->point(2) ==
Point(1,0) &&
311 elem->point(0) ==
Point(0,1)) ||
312 (elem->point(2) ==
Point(0,0) &&
313 elem->point(0) ==
Point(1,0) &&
314 elem->point(1) ==
Point(0,1)));
316 if (point ==
Point(1,2))
318 found_triangle =
true;
319 CPPUNIT_ASSERT((elem->point(0) ==
Point(0,1) &&
320 elem->point(1) ==
Point(1,0) &&
321 elem->point(2) ==
Point(1,2)) ||
322 (elem->point(1) ==
Point(0,1) &&
323 elem->point(2) ==
Point(1,0) &&
324 elem->point(0) ==
Point(1,2)) ||
325 (elem->point(2) ==
Point(0,1) &&
326 elem->point(0) ==
Point(1,0) &&
327 elem->point(1) ==
Point(1,2)));
330 CPPUNIT_ASSERT(found_triangle);
347 this->testTriangulatorBase(
mesh, triangulator);
366 int interpolate_boundary_points,
368 Real expected_total_area = 1.5,
369 Real desired_area = 1000)
371 commonSettings(triangulator);
374 testTriangulatorTrapMesh(
mesh);
385 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), n_expected_elem);
388 for (
const auto & elem :
mesh.active_local_element_ptr_range())
390 CPPUNIT_ASSERT_EQUAL(elem->level(), 0u);
391 CPPUNIT_ASSERT_EQUAL(elem->type(),
TRI3);
393 area += elem->volume();
403 const std::vector<Point> & expected_centers)
405 std::vector<bool> found_centers(expected_centers.size(),
false);
407 for (
const auto & elem :
mesh.element_ptr_range())
409 CPPUNIT_ASSERT_EQUAL(elem->type(),
TRI3);
413 (elem->point(1) - elem->point(0)).cross
414 (elem->point(2) - elem->point(0));
416 CPPUNIT_ASSERT_GREATER(
Real(0), cross_prod(2));
419 Point center = elem->vertex_average();
421 bool found_mine =
false;
424 Point possible = expected_centers[i];
429 found_centers[i] =
true;
432 CPPUNIT_ASSERT(found_mine);
437 for (
auto found_it : found_centers)
438 CPPUNIT_ASSERT(found_it);
452 commonSettings(triangulator);
456 const std::vector<TriangulatorInterface::Hole*> holes { &diamond };
464 Real r2p2o6 = (std::sqrt(2_R)+2)/6;
465 Real r2p4o6 = (std::sqrt(2_R)+4)/6;
467 std::vector <Point> expected_centers
468 { {r2p2o6,r2p2o6}, {r2p2o6,-r2p2o6},
469 {-r2p2o6,r2p2o6}, {-r2p2o6,-r2p2o6},
470 {0,r2p4o6}, {r2p4o6, 0},
471 {0,-r2p4o6}, {-r2p4o6, 0}
474 testFoundCenters(
mesh, expected_centers);
488 commonSettings(triangulator);
496 CPPUNIT_ASSERT_EQUAL(centerhole.n_points(), 8u);
497 CPPUNIT_ASSERT_EQUAL(centerhole.area(),
Real(1));
498 Point inside = centerhole.inside();
499 CPPUNIT_ASSERT_EQUAL(inside(0),
Real(20));
500 CPPUNIT_ASSERT_EQUAL(inside(1),
Real(20));
502 const std::vector<TriangulatorInterface::Hole*> holes { ¢erhole };
510 std::vector <Point> expected_centers
511 { {-0.5,
Real(2)/3}, {0,
Real(5)/6},
515 {-0.5, -
Real(2)/3}, {0, -
Real(5)/6},
517 {-
Real(2)/3, -0.5}, {-
Real(5)/6, 0},
521 for (
auto & p : expected_centers)
524 testFoundCenters(
mesh, expected_centers);
528 #ifdef LIBMESH_ENABLE_AMR 538 commonSettings(triangulator);
542 const Point center{20,20};
550 CPPUNIT_ASSERT_EQUAL(centerhole.n_points(), 8u);
551 Point inside = centerhole.inside();
552 CPPUNIT_ASSERT_EQUAL(inside(0),
Real(20));
553 CPPUNIT_ASSERT_EQUAL(inside(1),
Real(20));
555 const std::vector<TriangulatorInterface::Hole*> holes { ¢erhole };
567 std::map<std::pair<Real, Real>,
Point> outer_midpoints
568 {{{19, 19}, {20, 19}},
569 {{21, 19}, {21, 20}},
570 {{21, 21}, {20, 21}},
574 for (
const auto & elem :
mesh.active_local_element_ptr_range())
575 for (
const auto n :
make_range(elem->n_sides()))
577 if (elem->neighbor_ptr(n))
581 outer_midpoints.find(std::make_pair(elem->point(n)(0),
583 if (it != outer_midpoints.end())
585 const Point error = it->second - elem->point(n+3);
591 const Point radius1 = elem->point(n) - center;
595 const Point radius2 = elem->point((n+1)%3) - center;
599 const Point radius3 = elem->point(n+3) - center;
605 #endif // LIBMESH_ENABLE_AMR 618 triangulator.
segments = {{0,2},{2,1},{1,3},{3,0}};
620 this->testTriangulatorBase(
mesh, triangulator);
635 edge13->set_node(1, node3);
638 edge02->set_node(1, node2);
641 edge30->set_node(1, node0);
644 edge21->set_node(1, node1);
647 if (elem_type ==
EDGE3)
650 edge13->set_node(2, node4);
652 edge02->set_node(2, node5);
654 edge30->set_node(2, node6);
656 edge21->set_node(2, node7);
682 edge45->set_node(1, node5);
683 edge45->subdomain_id() = 1;
686 edge56->set_node(1, node6);
687 edge56->subdomain_id() = 1;
690 edge67->set_node(1, node7);
691 edge67->subdomain_id() = 1;
694 edge78->set_node(1, node8);
695 edge78->subdomain_id() = 1;
698 edge84->set_node(1, node4);
699 edge84->subdomain_id() = 1;
701 if (elem_type ==
EDGE3)
704 edge45->set_node(2, node9);
706 edge56->set_node(2, node10);
708 edge67->set_node(2, node11);
710 edge78->set_node(2, node12);
712 edge84->set_node(2, node13);
717 testEdgesMesh(
mesh, elem_type);
719 std::set<std::size_t> bdy_ids {0};
722 this->testTriangulatorBase(
mesh, triangulator);
726 #ifdef LIBMESH_HAVE_TRIANGLE 733 testTriangulator(
mesh, triangle);
753 testTriangulatorInterp(
mesh, triangle, 1, 6);
763 testTriangulatorInterp(
mesh, triangle, 2, 10);
773 testTriangulatorHoles(
mesh, triangle);
783 testTriangulatorMeshedHoles(
mesh, triangle);
787 #ifdef LIBMESH_ENABLE_AMR 794 testTriangulatorRoundHole(
mesh, triangle);
796 #endif // LIBMESH_ENABLE_AMR 807 this->testTriangulatorBase(
mesh, triangulator);
817 testTriangulatorSegments(
mesh, triangle);
819 #endif // LIBMESH_HAVE_TRIANGLE 822 #ifdef LIBMESH_HAVE_POLY2TRI 829 testTriangulator(
mesh, p2t_tri);
859 testTriangulatorInterp(
mesh, p2t_tri, 1, 6);
869 testTriangulatorInterp(
mesh, p2t_tri, 2, 10);
879 testTriangulatorHoles(
mesh, p2t_tri);
889 testTriangulatorMeshedHoles(
mesh, p2t_tri);
893 #ifdef LIBMESH_ENABLE_AMR 900 testTriangulatorRoundHole(
mesh, p2t_tri);
902 #endif // LIBMESH_ENABLE_AMR 913 this->testTriangulatorBase(
mesh, triangulator);
925 this->testTriangulatorBase(
mesh, triangulator);
945 edge13->set_node(1, node3);
948 edge02->set_node(1, node2);
951 edge30->set_node(1, node0);
955 testExceptionBase(
mesh, triangulator,
"Bad edge topology");
977 edge01->set_node(1, node1);
980 edge12->set_node(1, node2);
983 edge20->set_node(1, node0);
987 edge34->set_node(1, node4);
990 edge45->set_node(1, node5);
993 edge53->set_node(1, node3);
997 testExceptionBase(
mesh, triangulator,
"multiple loops of Edge");
1018 tri012->set_node(1, node1);
1019 tri012->set_node(2, node2);
1022 tri345->set_node(1, node4);
1023 tri345->set_node(2, node5);
1027 testExceptionBase(
mesh, triangulator,
"cannot choose one");
1038 testPoly2TriRefinementBase(
mesh,
nullptr, 1.5, 14);
1048 testTriangulatorSegments(
mesh, p2t_tri);
1051 void testPoly2TriRefinementBase
1053 const std::vector<TriangulatorInterface::Hole*> * holes,
1054 Real expected_total_area,
1056 Real desired_area = 0.1,
1061 commonSettings(triangulator);
1073 if (desired_area || area_func)
1074 CPPUNIT_ASSERT_GREATER(n_original_elem,
mesh.
n_elem());
1076 CPPUNIT_ASSERT_EQUAL(
mesh.
n_elem(), n_original_elem);
1079 for (
const auto & elem :
mesh.active_local_element_ptr_range())
1081 CPPUNIT_ASSERT_EQUAL(elem->level(), 0u);
1082 CPPUNIT_ASSERT_EQUAL(elem->type(),
TRI3);
1084 const Real my_area = elem->volume();
1087 if (desired_area != 0)
1088 CPPUNIT_ASSERT_LESSEQUAL(desired_area, my_area);
1090 if (area_func !=
nullptr)
1091 for (
auto v :
make_range(elem->n_vertices()))
1093 const Real local_desired_area =
1094 (*area_func)(elem->point(v));
1095 CPPUNIT_ASSERT_LESSEQUAL(local_desired_area, my_area);
1111 testTriangulatorTrapMesh(
mesh);
1112 testPoly2TriRefinementBase(
mesh,
nullptr, 1.5, 15);
1120 testTriangulatorTrapMesh(
mesh);
1122 testPoly2TriRefinementBase(
mesh,
nullptr, 1.5, 2, 0);
1131 testTriangulatorTrapMesh(
mesh);
1132 testPoly2TriRefinementBase(
mesh,
nullptr, 1.5, 150, 0.01);
1137 #ifdef LIBMESH_HAVE_FPARSER 1140 testTriangulatorTrapMesh(
mesh);
1141 testPoly2TriRefinementBase(
mesh,
nullptr, 1.5, 150, 0, &var_area);
1142 #endif // LIBMESH_HAVE_FPARSER 1151 const std::vector<TriangulatorInterface::Hole*> holes { &diamond };
1154 testTriangulatorTrapMesh(
mesh);
1155 testPoly2TriRefinementBase(
mesh, &holes, 1.25, 13);
1163 testTriangulatorTrapMesh(
mesh);
1166 Real total_area = 1.5;
1176 std::vector<TriangulatorInterface::AffineHole> hole_data;
1178 hole_data.reserve(M*N);
1179 std::vector<TriangulatorInterface::Hole*> holes;
1184 hole_data.emplace_back(diamond, 0, shift);
1185 holes.push_back(&hole_data.back());
1186 total_area -= hole_data.back().area();
1193 testTriangulatorInterp(
mesh, p2t_tri, 4, 0, total_area, 0.03_R);
1196 void testPoly2TriHolesInteriorRefinedBase
1207 const std::vector<TriangulatorInterface::Hole*> holes { &diamond };
1212 testTriangulatorTrapMesh(
mesh);
1213 testPoly2TriRefinementBase(
mesh, &holes, 1.25, n_original_elem, desired_area);
1219 int n_outer_sides = std::count_if(side_bcs.begin(), side_bcs.end(),
1220 [](
auto t){
return std::get<2>(t) == 0;});
1221 CPPUNIT_ASSERT_GREATER(4, n_outer_sides);
1222 int n_hole_sides = std::count_if(side_bcs.begin(), side_bcs.end(),
1223 [](
auto t){
return std::get<2>(t) == 1;});
1224 CPPUNIT_ASSERT_EQUAL(n_hole_sides, 4);
1231 testPoly2TriHolesInteriorRefinedBase(25, 0.05);
1239 testPoly2TriHolesInteriorRefinedBase(60, 0.02);
1247 const std::vector<TriangulatorInterface::Hole*> holes { &diamond };
1250 testTriangulatorTrapMesh(
mesh);
1251 testPoly2TriRefinementBase(
mesh, &holes, 1.25, 125, 0.01);
1256 #ifdef LIBMESH_HAVE_FPARSER 1259 const std::vector<TriangulatorInterface::Hole*> holes { &diamond };
1263 testTriangulatorTrapMesh(
mesh);
1264 testPoly2TriRefinementBase(
mesh, &holes, 1.25, 150, 0, &var_area);
1265 #endif // LIBMESH_HAVE_FPARSER 1269 #endif // LIBMESH_HAVE_POLY2TRI void testTriangleHoleArea()
void testPoly2TriEdge3s()
void testTriangulatorTrapMesh(UnstructuredMesh &mesh)
ElemType
Defines an enum for geometric element types.
virtual Node *& set_node(const unsigned int i)
void testPoly2TriHolesNonUniformRefined()
virtual void triangulate()=0
This is the main public interface for this function.
auto norm() const -> decltype(std::norm(T()))
void testTriangleInterp2()
void testPoly2TriHolesInteriorExtraRefined()
virtual void set_refine_boundary_allowed(bool refine_bdy_allowed) override
Set whether or not the triangulation is allowed to refine the mesh boundary when refining the interio...
void testPoly2TriHolesExtraRefined()
A Function generated (via FParser) by parsing a mathematical expression.
void testPoly2TriHolesInterpRefined()
void testPoly2TriBad1DMultiBoundary()
libMesh::Parallel::Communicator * TestCommWorld
static constexpr Real TOLERANCE
An abstract class for defining a 2-dimensional hole.
void set_verify_hole_boundaries(bool v)
Verifying that hole boundaries don't cross the outer boundary or each other is something like O(N_bdy...
void testTriangleInterp()
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
Prepare a newly ecreated (or read) mesh for use.
void testTriangulatorSegments(MeshBase &mesh, TriangulatorInterface &triangulator)
Real area() const
Return the area of the hole.
const Parallel::Communicator & comm() const
void set_interpolate_boundary_points(int n_points)
Complicated setter, for compatibility with insert_extra_points()
void set_outer_boundary_ids(std::set< std::size_t > bdy_ids)
A set of ids to allow on the outer boundary loop: interpreted as boundary ids of 2D elements and/or s...
The libMesh namespace provides an interface to certain functionality in the library.
ElemType & elem_type()
Sets and/or gets the desired element type.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
void testTriangulatorHoles(MeshBase &mesh, TriangulatorInterface &triangulator)
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
void testPoly2TriEdgesRefined()
void testHalfDomain(MeshBase &mesh, TriangulatorInterface &triangulator, ElemType elem_type)
This is the MeshBase class.
void build_side_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &side_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of element numbers, sides, and ids for those sides.
void testTriangleRoundHole()
TriangulationType & triangulation_type()
Sets and/or gets the desired triangulation type.
void testPoly2TriNonRefined()
void testPoly2TriHalfDomain()
void testPoly2TriInterp2()
void commonSettings(TriangulatorInterface &triangulator)
auto norm_sq() const -> decltype(std::norm(T()))
void testPoly2TriNonUniformRefined()
void attach_hole_list(const std::vector< Hole *> *holes)
Attaches a vector of Hole* pointers which will be meshed around.
virtual void set_desired_area_function(FunctionBase< Real > *desired) override
Set a function giving desired triangle area as a function of position.
The UnstructuredMesh class is derived from the MeshBase class.
void testPoly2TriExtraRefined()
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Real & minimum_angle()
Sets and/or gets the minimum desired angle.
void testPoly2TriSegments()
void testTriangleHalfDomain()
CPPUNIT_TEST_SUITE_REGISTRATION(MeshTriangulationTest)
void testTriangulatorInterp(UnstructuredMesh &mesh, TriangulatorInterface &triangulator, int interpolate_boundary_points, dof_id_type n_expected_elem, Real expected_total_area=1.5, Real desired_area=1000)
bool absolute_fuzzy_equals(const TypeVector< T > &rhs, Real tol=TOLERANCE) const
void testPoly2TriMeshedHoles()
void testTriangleHoleContains()
virtual bool refine_boundary_allowed() const
Get whether or not the triangulation is allowed to refine the mesh boundary when refining the interio...
virtual void triangulate() override
Internally, this calls the poly2tri triangulation code in a loop, inserting our owner Steiner points ...
Real & desired_area()
Sets and/or gets the desired triangle area.
Triangulate the interior of a Planar Straight Line Graph, which is defined implicitly by the order of...
void testPoly2TriRoundHole()
void testPoly2TriBad2DMultiBoundary()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< std::pair< unsigned int, unsigned int > > segments
When constructing a PSLG, if the node numbers do not define the desired boundary segments implicitly ...
void testTriangulatorRoundHole(MeshBase &mesh, TriangulatorInterface &triangulator)
void max(const T &r, T &o, Request &req) const
A class to represent the internal "this should never happen" errors, to be thrown by "libmesh_error()...
Another concrete instantiation of the hole, as general as ArbitraryHole, but based on an existing 1D ...
void testPoly2TriHolesRefined()
virtual void set_refine_boundary_allowed(bool refine_bdy_allowed)
Set whether or not a triangulator is allowed to refine the hole boundary when refining the mesh inter...
A concrete instantiation of the Hole class that describes polygonal (triangular, square, pentagonal, ...) holes.
void testTriangulatorBase(MeshBase &mesh, TriangulatorInterface &triangulator)
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
void testPoly2TriBadEdges()
void testTriangulator(MeshBase &mesh, TriangulatorInterface &triangulator)
void testEdgesMesh(MeshBase &mesh, ElemType elem_type)
Another concrete instantiation of the hole, this one should be sufficiently general for most non-poly...
void testPoly2TriHalfDomainEdge3()
virtual const Node & node_ref(const dof_id_type i) const
A C++ interface between LibMesh and the poly2tri library, with custom code for Steiner point insertio...
void testTriangleSegments()
virtual dof_id_type n_elem() const =0
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
A C++ interface between LibMesh and the Triangle library written by J.R.
void testTriangulatorMeshedHoles(MeshBase &mesh, TriangulatorInterface &triangulator)
void testPoly2TriInterp()
A Point defines a location in LIBMESH_DIM dimensional Real space.
void testPoly2TriRefined()
void testPoly2TriHolesInteriorRefined()
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
void testTriangleMeshedHoles()
virtual dof_id_type n_nodes() const =0
void testExceptionBase(MeshBase &mesh, TriangulatorInterface &triangulator, const char *re)
bool & smooth_after_generating()
Sets/gets flag which tells whether to do two steps of Laplace mesh smoothing after generating the gri...
void testFoundCenters(const MeshBase &mesh, const std::vector< Point > &expected_centers)