libMesh
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
libMesh::TriangulatorInterface::MeshedHole Class Reference

Another concrete instantiation of the hole, as general as ArbitraryHole, but based on an existing 1D or 2D mesh. More...

#include <mesh_triangle_holes.h>

Inheritance diagram for libMesh::TriangulatorInterface::MeshedHole:
[legend]

Public Member Functions

 MeshedHole (const MeshBase &mesh, std::set< std::size_t > ids={})
 The constructor requires a mesh defining the hole, and optionally boundary+subdomain ids restricting the definition.
 
virtual unsigned int n_points () const override
 The number of geometric points which define the hole.
 
virtual unsigned int n_midpoints () const override
 The number of geometric midpoints along each of the sides defining the hole.
 
virtual Point point (const unsigned int n) const override
 Return the nth point defining the hole.
 
virtual Point midpoint (const unsigned int m, const unsigned int n) const override
 Return the midpoint m along the side n defining the hole.
 
virtual Point inside () const override
 Return an (arbitrary) point which lies inside the hole.
 
bool contains (Point p) const
 Return true iff p lies inside the hole.
 
Real area () const
 Return the area of the hole.
 
RealGradient areavec () const
 Return a vector with right-hand-rule orientation and length of twice area() squared.
 
virtual std::vector< unsigned intsegment_indices () const
 Starting indices of points for a hole with multiple disconnected boundaries.
 
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 interior.
 
virtual bool refine_boundary_allowed () const
 Get whether or not the triangulation is allowed to refine the mesh boundary when refining the interior.
 

Protected Member Functions

std::vector< Realfind_ray_intersections (Point ray_start, Point ray_target) const
 Helper function for contains(), also useful for MeshedHole::inside()
 
Point calculate_inside_point () const
 Calculate an inside point based on our boundary.
 

Protected Attributes

bool _refine_bdy_allowed = true
 Whether to allow boundary refinement.
 

Private Attributes

Point _center
 An (x,y) location inside the hole.
 
std::vector< Point_points
 The sorted vector of points which makes up the hole.
 
std::vector< Point_midpoints
 The sorted vector of midpoints in between points along the edges of the hole.
 

Detailed Description

Another concrete instantiation of the hole, as general as ArbitraryHole, but based on an existing 1D or 2D mesh.

If ids are given, 2D edges on a boundary with a listed id or 1D edges in a subdomain with a listed id will define the hole.

If no ids are given, the hole will be defined by all 1D Edge elements and all outward-facing 2D boundary edges.

In either case, the hole definition should give a single connected boundary, topologically a circle. The hole is defined when the MeshedHole is constructed, and ignores any subsequent changes to the input mesh.

Definition at line 343 of file mesh_triangle_holes.h.

Constructor & Destructor Documentation

◆ MeshedHole()

libMesh::TriangulatorInterface::MeshedHole::MeshedHole ( const MeshBase mesh,
std::set< std::size_t >  ids = {} 
)

The constructor requires a mesh defining the hole, and optionally boundary+subdomain ids restricting the definition.

Definition at line 457 of file mesh_triangle_holes.C.

459 : _center(std::numeric_limits<Real>::max())
460{
461 // We'll want to do this on one processor and broadcast to the rest;
462 // otherwise we can get out of sync by doing things like using
463 // pointers as keys.
464 libmesh_parallel_only(mesh.comm());
465
466 MeshSerializer serial(const_cast<MeshBase &>(mesh),
467 /* serial */ true, /* only proc 0 */ true);
468
469 // Try to keep in sync even if we throw an error on proc 0, so we
470 // can examine errors in our unit tests in parallel too.
471 std::string error_reported;
472
473 auto report_error = [&mesh, &error_reported](std::string er) {
474 error_reported = std::move(er);
475 mesh.comm().broadcast(error_reported);
476 libmesh_error_msg(error_reported);
477 };
478
479 if (mesh.processor_id() != 0)
480 {
481 // Make sure proc 0 didn't just fail
482 mesh.comm().broadcast(error_reported);
483 libmesh_error_msg_if(!error_reported.empty(), error_reported);
484
485 // Receive the points proc 0 will send later
488 return;
489 }
490
491 // We'll find all the line segments first, then stitch them together
492 // afterward. If the line segments come from 2D element sides then
493 // we'll label their edge_type as "1" for clockwise orientation
494 // around the element or "2" for CCW, to make it easier to detect
495 // and scream about cases where we have a disconnected outer
496 // boundary.
497 std::multimap<const Node *,
498 std::pair<const Node *, int>> hole_edge_map;
499
500 // If we're looking at higher-order elements, we have mid-edge edge
501 // nodes to worry about. hole_midpoint_map[{m,n}][i] should give us
502 // the ith mid-edge node traveling from vertex m to vertex n
503 std::map<std::pair<const Node *, const Node *>,
504 std::vector<const Node *>> hole_midpoint_map;
505
506 std::vector<boundary_id_type> bcids;
507
508 const BoundaryInfo & boundary_info = mesh.get_boundary_info();
509
510 for (const auto & elem : mesh.active_element_ptr_range())
511 {
512 if (elem->dim() == 1)
513 {
514 if (ids.empty() || ids.count(elem->subdomain_id()))
515 {
516 hole_edge_map.emplace(elem->node_ptr(0),
517 std::make_pair(elem->node_ptr(1),
518 /*edge*/ 0));
519 hole_edge_map.emplace(elem->node_ptr(1),
520 std::make_pair(elem->node_ptr(0),
521 /*edge*/ 0));
522 if (elem->type() == EDGE3)
523 {
524 hole_midpoint_map.emplace(std::make_pair(elem->node_ptr(0),
525 elem->node_ptr(1)),
526 std::vector<const Node *>{elem->node_ptr(2)});
527 hole_midpoint_map.emplace(std::make_pair(elem->node_ptr(1),
528 elem->node_ptr(0)),
529 std::vector<const Node *>{elem->node_ptr(2)});
530 }
531 else if (elem->type() == EDGE4)
532 {
533 hole_midpoint_map.emplace(std::make_pair(elem->node_ptr(0),
534 elem->node_ptr(1)),
535 std::vector<const Node *>{elem->node_ptr(2),
536 elem->node_ptr(3)});
537 hole_midpoint_map.emplace(std::make_pair(elem->node_ptr(1),
538 elem->node_ptr(0)),
539 std::vector<const Node *>{elem->node_ptr(3),
540 elem->node_ptr(2)});
541 }
542 else
543 libmesh_assert_equal_to(elem->default_side_order(), 1);
544 }
545 continue;
546 }
547
548 if (elem->dim() == 2)
549 {
550 const auto ns = elem->n_sides();
551 for (auto s : make_range(ns))
552 {
553 boundary_info.boundary_ids(elem, s, bcids);
554
555 bool add_edge = false;
556 if (!elem->neighbor_ptr(s) && ids.empty())
557 add_edge = true;
558
559 if (!add_edge)
560 for (auto b : bcids)
561 if (ids.count(b))
562 add_edge = true;
563
564 if (add_edge)
565 {
566 hole_edge_map.emplace(elem->node_ptr(s),
567 std::make_pair(elem->node_ptr((s+1)%ns),
568 /*counter-CW*/ 2));
569 // Do we really need to support flipped 2D elements?
570 hole_edge_map.emplace(elem->node_ptr((s+1)%ns),
571 std::make_pair(elem->node_ptr(s),
572 /*clockwise*/ 1));
573
574 if (elem->default_side_order() == 2)
575 {
576 hole_midpoint_map.emplace(std::make_pair(elem->node_ptr(s),
577 elem->node_ptr((s+1)%ns)),
578 std::vector<const Node *>{elem->node_ptr(s+ns)});
579 hole_midpoint_map.emplace(std::make_pair(elem->node_ptr((s+1)%ns),
580 elem->node_ptr(s)),
581 std::vector<const Node *>{elem->node_ptr(s+ns)});
582 }
583 else
584 libmesh_assert_equal_to(elem->default_side_order(), 1);
585
586 continue;
587 }
588 }
589 }
590 }
591
592 if (hole_edge_map.empty())
593 report_error("No valid hole edges found in mesh!");
594
595 // Function to pull a vector of points out of the map; a loop of
596 // edges connecting these points defines a hole boundary. If the
597 // mesh has multiple boundaries (e.g. because it had holes itself),
598 // then a random vector will be extracted; this function will be
599 // called multiple times so that the various options can be
600 // compared. We choose the largest option.
601 auto extract_edge_vector =
602 [&report_error, &hole_edge_map, &hole_midpoint_map]() {
603 std::tuple<std::vector<const Node *>, std::vector<const Node *>, int>
604 hole_points_and_edge_type
605 {{hole_edge_map.begin()->first, hole_edge_map.begin()->second.first},
606 {}, hole_edge_map.begin()->second.second};
607
608 auto & hole_points = std::get<0>(hole_points_and_edge_type);
609 auto & midpoint_points = std::get<1>(hole_points_and_edge_type);
610 int & edge_type = std::get<2>(hole_points_and_edge_type);
611
612 // We won't be needing to search for this edge
613 hole_edge_map.erase(hole_points.front());
614
615 // Sort the remaining edges into a connected order
616 for (const Node * last = hole_points.front(),
617 * n = hole_points.back();
618 n != hole_points.front();
619 last = n,
620 n = hole_points.back())
621 {
622 auto [next_it_begin, next_it_end] = hole_edge_map.equal_range(n);
623
624 if (std::distance(next_it_begin, next_it_end) != 2)
625 report_error("Bad edge topology found by MeshedHole");
626
627 const Node * next = nullptr;
628 for (const auto & [key, val] : as_range(next_it_begin, next_it_end))
629 {
630 libmesh_assert_equal_to(key, n);
631 libmesh_ignore(key);
632 libmesh_assert_not_equal_to(val.first, n);
633
634 // Don't go backwards on the edge we just traversed
635 if (val.first == last)
636 continue;
637
638 // We can support mixes of Edge and Tri-side edges, but we
639 // can't do proper error detection on flipped triangles.
640 if (val.second != edge_type &&
641 val.second != 0)
642 {
643 if (!edge_type)
644 edge_type = val.second;
645 else
646 report_error("MeshedHole sees inconsistent triangle orientations on boundary");
647 }
648 next = val.first;
649 }
650
651 // We should never hit the same n twice!
652 hole_edge_map.erase(next_it_begin, next_it_end);
653
654 hole_points.push_back(next);
655 }
656
657 for (auto i : make_range(hole_points.size()-1))
658 {
659 const auto & midpoints = hole_midpoint_map[{hole_points[i],hole_points[i+1]}];
660 midpoint_points.insert(midpoint_points.end(),
661 midpoints.begin(), midpoints.end());
662 }
663
664 hole_points.pop_back();
665
666 return hole_points_and_edge_type;
667 };
668
669 /*
670 * If it's not obvious which loop we find is really the loop we
671 * want, then we should die with a nice error message.
672 */
673 int n_negative_areas = 0,
674 n_positive_areas = 0,
675 n_edgeelem_loops = 0;
676
677 std::vector<const Node *> outer_hole_points, outer_mid_points;
678 int outer_edge_type = -1;
679 Real twice_outer_area = 0,
680 abs_twice_outer_area = 0;
681
682#ifdef DEBUG
683 // Area and edge type, for error reporting
684 std::vector<std::pair<Real, int>> areas;
685#endif
686
687 while (!hole_edge_map.empty()) {
688 auto [hole_points, mid_points, edge_type] = extract_edge_vector();
689
690 if (edge_type == 0)
691 {
692 ++n_edgeelem_loops;
693 if (n_edgeelem_loops > 1)
694 report_error("MeshedHole is confused by multiple loops of Edge elements");
695 if (n_positive_areas || n_negative_areas)
696 report_error("MeshedHole is confused by meshes with both Edge and 2D-side boundaries");
697 }
698
699 const std::size_t n_hole_points = hole_points.size();
700 if (n_hole_points < 3)
701 report_error("Loop with only " + std::to_string(n_hole_points) +
702 " hole edges found in mesh!");
703
704 Real twice_this_area = 0;
705 const Point p0 = *hole_points[0];
706 for (unsigned int i=2; i != n_hole_points; ++i)
707 {
708 const Point e_0im = *hole_points[i-1] - p0,
709 e_0i = *hole_points[i] - p0;
710
711 twice_this_area += e_0i.cross(e_0im)(2);
712 }
713
714 auto abs_twice_this_area = std::abs(twice_this_area);
715
716 if (((twice_this_area > 0) && edge_type == 2) ||
717 ((twice_this_area < 0) && edge_type == 1))
718 ++n_positive_areas;
719 else if (edge_type != 0)
720 ++n_negative_areas;
721
722#ifdef DEBUG
723 areas.push_back({twice_this_area/2,edge_type});
724#endif
725
726 if (abs_twice_this_area > abs_twice_outer_area)
727 {
728 twice_outer_area = twice_this_area;
729 abs_twice_outer_area = abs_twice_this_area;
730 outer_hole_points = std::move(hole_points);
731 outer_mid_points = std::move(mid_points);
732 outer_edge_type = edge_type;
733 }
734 }
735
736 _points.resize(outer_hole_points.size());
737 std::transform(outer_hole_points.begin(),
738 outer_hole_points.end(),
739 _points.begin(),
740 [](const Node * n){ return Point(*n); });
741 _midpoints.resize(outer_mid_points.size());
742 std::transform(outer_mid_points.begin(),
743 outer_mid_points.end(),
744 _midpoints.begin(),
745 [](const Node * n){ return Point(*n); });
746
747 if (!twice_outer_area)
748 report_error("Zero-area MeshedHoles are not currently supported");
749
750 // We ordered ourselves counter-clockwise? But a hole is expected
751 // to be clockwise, so use the reverse order.
752 if (twice_outer_area > 0)
753 {
754 std::reverse(_points.begin(), _points.end());
755
756 // Our midpoints are numbered e.g.
757 // (01a)(01b)(12a)(12b)(23a)(23b)(30a)(30b) for points 0123, but
758 // if we reverse to get 3210 then we want our midpoints to be
759 // (23b)(23a)(12b)(12a)(01b)(01a)(30b)(30a)
760 const unsigned int n_midpoints = _midpoints.size() / _points.size();
761 auto split_it = _midpoints.end() - n_midpoints;
762 std::reverse(_midpoints.begin(), split_it);
763 std::reverse(split_it, _midpoints.end());
764 }
765
766#ifdef DEBUG
767 auto print_areas = [areas](){
768 libMesh::out << "Found boundary areas:\n";
769 static const std::vector<std::string> edgenames {"E","CW","CCW"};
770 for (auto area : areas)
771 libMesh::out << '(' << edgenames[area.second] << ' ' <<
772 area.first << ')';
773 libMesh::out << std::endl;
774 };
775#else
776 auto print_areas = [](){};
777#endif
778
779 if (((twice_outer_area > 0) && outer_edge_type == 2) ||
780 ((twice_outer_area < 0) && outer_edge_type == 1))
781 {
782 if (n_positive_areas > 1)
783 {
784 print_areas();
785 report_error("MeshedHole found " +
786 std::to_string(n_positive_areas) +
787 " counter-clockwise boundaries and cannot choose one!");
788 }
789
790 }
791 else if (outer_edge_type != 0)
792 {
793 if (n_negative_areas > 1)
794 {
795 print_areas();
796 report_error("MeshedHole found " +
797 std::to_string(n_negative_areas) +
798 " clockwise boundaries and cannot choose one!");
799 }
800
801 }
802
803 // Hey, no errors! Broadcast that empty string.
804 mesh.comm().broadcast(error_reported);
807}
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
void boundary_ids(const Node *node, std::vector< boundary_id_type > &vec_to_fill) const
Fills a user-provided std::vector with the boundary ids associated with Node node.
This is the MeshBase class.
Definition mesh_base.h:81
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition mesh_base.h:170
Temporarily serialize a DistributedMesh for non-distributed-mesh capable code paths.
A Node is like a Point, but with more information.
Definition node.h:55
processor_id_type processor_id() const
const Parallel::Communicator & comm() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
Real area() const
Return the area of the hole.
std::vector< Point > _midpoints
The sorted vector of midpoints in between points along the edges of the hole.
std::vector< Point > _points
The sorted vector of points which makes up the hole.
Point _center
An (x,y) location inside the hole.
virtual unsigned int n_midpoints() const override
The number of geometric midpoints along each of the sides defining the hole.
TypeVector< typename CompareTypes< T, T2 >::supertype > cross(const TypeVector< T2 > &v) const
static const Real b
MeshBase & mesh
void report_error(const char *file, int line, const char *date, const char *time)
The libMesh namespace provides an interface to certain functionality in the library.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
void libmesh_ignore(const Args &...)
OStreamProxy out
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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...
Definition int_range.h:176

References _midpoints, _points, libMesh::TriangulatorInterface::Hole::area(), libMesh::as_range(), b, libMesh::BoundaryInfo::boundary_ids(), libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::TypeVector< T >::cross(), libMesh::EDGE3, libMesh::EDGE4, libMesh::MeshBase::get_boundary_info(), libMesh::libmesh_ignore(), libMesh::make_range(), mesh, n_midpoints(), libMesh::out, libMesh::ParallelObject::processor_id(), and libMesh::Real.

Member Function Documentation

◆ area()

Real libMesh::TriangulatorInterface::Hole::area ( ) const
inherited

Return the area of the hole.

This method currently does not take any higher-order hole geometry into account, but treats the hole as a polygon.

Definition at line 190 of file mesh_triangle_holes.C.

191{
192 return this->areavec().norm() / 2;
193}
RealGradient areavec() const
Return a vector with right-hand-rule orientation and length of twice area() squared.
auto norm() const

References libMesh::TriangulatorInterface::Hole::areavec(), and libMesh::TypeVector< T >::norm().

Referenced by MeshedHole(), and MeshTriangulationTest::testTriangleHoleArea().

◆ areavec()

RealGradient libMesh::TriangulatorInterface::Hole::areavec ( ) const
inherited

Return a vector with right-hand-rule orientation and length of twice area() squared.

This is useful for determining orientation of non-planar or non-counter-clockwise holes.

This method currently does not take any higher-order hole geometry into account, but treats the hole as a polygon.

Definition at line 196 of file mesh_triangle_holes.C.

197{
198 const unsigned int np = this->n_points();
199
200 if (np < 3)
201 return 0;
202
203 const Point p0 = this->point(0);
204
205 // Every segment (p_{i-1},p_i) from i=2 on defines a triangle w.r.t.
206 // p_0. Add up the cross products of those triangles. We'll save
207 // the division by 2 and the norm for the end.
208 //
209 // Your hole points had best be coplanar, but this should work
210 // regardless of which plane they're in. If you're in the XY plane,
211 // then the standard counter-clockwise hole point ordering gives you
212 // a positive areavec(2);
213
215
216 for (unsigned int i=2; i != np; ++i)
217 {
218 const Point e_0im = this->point(i-1) - p0,
219 e_0i = this->point(i) - p0;
220
221 areavec += e_0i.cross(e_0im);
222 }
223
224 return areavec;
225}
virtual Point point(const unsigned int n) const =0
Return the nth point defining the hole.
virtual unsigned int n_points() const =0
The number of geometric points which define the hole.

References libMesh::TypeVector< T >::cross().

Referenced by libMesh::TriangulatorInterface::Hole::area().

◆ calculate_inside_point()

Point libMesh::TriangulatorInterface::Hole::calculate_inside_point ( ) const
protectedinherited

Calculate an inside point based on our boundary.

Definition at line 254 of file mesh_triangle_holes.C.

255{
256 // Start with the vertex average
257
258 // Turns out "I'm a fully compliant C++17 compiler!" doesn't
259 // mean "I have a full C++17 standard library!"
260 // inside = std::reduce(points.begin(), points.end());
261 Point inside = 0;
262 for (auto i : make_range(this->n_points()))
263 inside += this->point(i);
264
265 inside /= this->n_points();
266
267 // Count the number of intersections with a ray to the right,
268 // keep track of how far they are
269 Point ray_target = inside + Point(1);
270 std::vector<Real> intersection_distances =
271 this->find_ray_intersections(inside, ray_target);
272
273 // The vertex average isn't on the interior, and we found no
274 // intersections to the right? Try looking to the left.
275 if (!intersection_distances.size())
276 {
277 ray_target = inside - Point(1);
278 intersection_distances =
279 this->find_ray_intersections(inside, ray_target);
280 }
281
282 // I'd make this an assert, but I'm not 100% confident we can't
283 // get here via some kind of FP error on a weird hole shape.
284 libmesh_error_msg_if
285 (!intersection_distances.size(),
286 "Can't find a center for a MeshedHole!");
287
288 if (intersection_distances.size() % 2)
289 return inside;
290
291 // The vertex average is outside. So go from the vertex average to
292 // the closest edge intersection, then halfway to the next-closest.
293
294 // Find the nearest first.
295 Real min_distance = std::numeric_limits<Real>::max(),
296 second_distance = std::numeric_limits<Real>::max();
297 for (Real d : intersection_distances)
298 if (d < min_distance)
299 {
300 second_distance = min_distance;
301 min_distance = d;
302 }
303
304 const Point ray = ray_target - inside;
305 inside += ray * (min_distance + second_distance)/2;
306
307 return inside;
308}
std::vector< Real > find_ray_intersections(Point ray_start, Point ray_target) const
Helper function for contains(), also useful for MeshedHole::inside()
virtual Point inside() const =0
Return an (arbitrary) point which lies inside the hole.

References libMesh::make_range(), and libMesh::Real.

Referenced by libMesh::TriangulatorInterface::ArbitraryHole::ArbitraryHole(), and libMesh::TriangulatorInterface::ArbitraryHole::set_points().

◆ contains()

bool libMesh::TriangulatorInterface::Hole::contains ( Point  p) const
inherited

Return true iff p lies inside the hole.

This method currently does not take any higher-order hole geometry into account, but treats the hole as a polygon.

Definition at line 311 of file mesh_triangle_holes.C.

312{
313 // Count the number of intersections with a ray to the right,
314 // keep track of how far they are
315 Point ray_target = p + Point(1);
316 std::vector<Real> intersection_distances =
317 this->find_ray_intersections(p, ray_target);
318
319 // Odd number of intersections == we're inside
320 // Even number == we're outside
321 return intersection_distances.size() % 2;
322}

Referenced by libMesh::TriangulatorInterface::verify_holes().

◆ find_ray_intersections()

std::vector< Real > libMesh::TriangulatorInterface::Hole::find_ray_intersections ( Point  ray_start,
Point  ray_target 
) const
protectedinherited

Helper function for contains(), also useful for MeshedHole::inside()

Definition at line 230 of file mesh_triangle_holes.C.

232{
233 const auto np = this->n_points();
234
235 std::vector<Real> intersection_distances;
236
237 for (auto i : make_range(np))
238 {
239 const Point & p0 = this->point(i),
240 & p1 = this->point((i+1)%np),
241 & p2 = this->point((i+2)%np);
242 const Real intersection_distance =
243 find_intersection(ray_start, ray_target, p0, p1, p2);
244 if (intersection_distance >= 0)
245 intersection_distances.push_back
246 (intersection_distance);
247 }
248
249 return intersection_distances;
250}

References libMesh::make_range(), and libMesh::Real.

◆ inside()

Point libMesh::TriangulatorInterface::MeshedHole::inside ( ) const
overridevirtual

Return an (arbitrary) point which lies inside the hole.

Implements libMesh::TriangulatorInterface::Hole.

Definition at line 840 of file mesh_triangle_holes.C.

841{
842 // This is expensive to compute, so only do it when we first need it
843 if (_center(0) == std::numeric_limits<Real>::max())
845
846 return _center;
847}
Point calculate_inside_point() const
Calculate an inside point based on our boundary.

◆ midpoint()

Point libMesh::TriangulatorInterface::MeshedHole::midpoint ( const unsigned int  ,
const unsigned int   
) const
overridevirtual

Return the midpoint m along the side n defining the hole.

Reimplemented from libMesh::TriangulatorInterface::Hole.

Definition at line 830 of file mesh_triangle_holes.C.

832{
833 const unsigned int n_mid = this->n_midpoints();
834 libmesh_assert_less (m, n_mid);
835 libmesh_assert_less (n, _points.size());
836 return _midpoints[n*n_mid+m];
837}

◆ n_midpoints()

unsigned int libMesh::TriangulatorInterface::MeshedHole::n_midpoints ( ) const
overridevirtual

The number of geometric midpoints along each of the sides defining the hole.

Reimplemented from libMesh::TriangulatorInterface::Hole.

Definition at line 816 of file mesh_triangle_holes.C.

817{
818 libmesh_assert (!(_midpoints.size() % _points.size()));
819 return _midpoints.size() / _points.size();
820}
libmesh_assert(ctx)

References libMesh::libmesh_assert().

Referenced by MeshedHole().

◆ n_points()

unsigned int libMesh::TriangulatorInterface::MeshedHole::n_points ( ) const
overridevirtual

The number of geometric points which define the hole.

Implements libMesh::TriangulatorInterface::Hole.

Definition at line 810 of file mesh_triangle_holes.C.

811{
812 return _points.size();
813}

◆ point()

Point libMesh::TriangulatorInterface::MeshedHole::point ( const unsigned int  n) const
overridevirtual

Return the nth point defining the hole.

Implements libMesh::TriangulatorInterface::Hole.

Definition at line 823 of file mesh_triangle_holes.C.

824{
825 libmesh_assert_less (n, _points.size());
826 return _points[n];
827}

◆ refine_boundary_allowed()

virtual bool libMesh::TriangulatorInterface::Hole::refine_boundary_allowed ( ) const
inlinevirtualinherited

Get whether or not the triangulation is allowed to refine the mesh boundary when refining the interior.

True by default.

Definition at line 140 of file mesh_triangle_holes.h.

141 { return _refine_bdy_allowed; }
bool _refine_bdy_allowed
Whether to allow boundary refinement.

References libMesh::TriangulatorInterface::Hole::_refine_bdy_allowed.

Referenced by libMesh::Poly2TriTriangulator::is_refine_boundary_allowed(), and MeshTriangulationTest::testPoly2TriHolesInteriorRefinedBase().

◆ segment_indices()

virtual std::vector< unsigned int > libMesh::TriangulatorInterface::Hole::segment_indices ( ) const
inlinevirtualinherited

Starting indices of points for a hole with multiple disconnected boundaries.

Reimplemented in libMesh::TriangulatorInterface::ArbitraryHole.

Definition at line 118 of file mesh_triangle_holes.h.

119 {
120 // default to only one enclosing boundary
121 std::vector<unsigned int> seg;
122 seg.push_back(0);
123 seg.push_back(n_points());
124 return seg;
125 }

References libMesh::TriangulatorInterface::Hole::n_points().

◆ set_refine_boundary_allowed()

virtual void libMesh::TriangulatorInterface::Hole::set_refine_boundary_allowed ( bool  refine_bdy_allowed)
inlinevirtualinherited

Set whether or not a triangulator is allowed to refine the hole boundary when refining the mesh interior.

This is true by default, but may be set to false to make the hole boundary more predictable (and so easier to stitch to other meshes) later.

Definition at line 133 of file mesh_triangle_holes.h.

134 { _refine_bdy_allowed = refine_bdy_allowed; }

References libMesh::TriangulatorInterface::Hole::_refine_bdy_allowed.

Referenced by MeshTriangulationTest::testPoly2TriHolesInteriorRefinedBase().

Member Data Documentation

◆ _center

Point libMesh::TriangulatorInterface::MeshedHole::_center
mutableprivate

An (x,y) location inside the hole.

Cached because this is too expensive to compute for an arbitrary input mesh unless we need it for Triangle.

Definition at line 370 of file mesh_triangle_holes.h.

◆ _midpoints

std::vector<Point> libMesh::TriangulatorInterface::MeshedHole::_midpoints
private

The sorted vector of midpoints in between points along the edges of the hole.

For a hole with m midpoints per edge, between _points[n] and _points[n+1] lies _midpoints[n*m] through _midpoints[n*m+m-1]

Definition at line 383 of file mesh_triangle_holes.h.

Referenced by MeshedHole().

◆ _points

std::vector<Point> libMesh::TriangulatorInterface::MeshedHole::_points
private

The sorted vector of points which makes up the hole.

Definition at line 375 of file mesh_triangle_holes.h.

Referenced by MeshedHole().

◆ _refine_bdy_allowed

bool libMesh::TriangulatorInterface::Hole::_refine_bdy_allowed = true
protectedinherited

Whether to allow boundary refinement.

True by default; specified here so we can use the default constructor.

Definition at line 160 of file mesh_triangle_holes.h.

Referenced by libMesh::TriangulatorInterface::Hole::refine_boundary_allowed(), and libMesh::TriangulatorInterface::Hole::set_refine_boundary_allowed().


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