libMesh
Classes | Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
libMesh::TriangleInterface Class Reference

A C++ interface between LibMesh and the Triangle library written by J.R. More...

#include <mesh_triangle_interface.h>

Classes

class  ArbitraryHole
 Another concrete instantiation of the hole, this one should be sufficiently general for most non-polygonal purposes. More...
 
class  Hole
 An abstract class for defining a 2-dimensional hole. More...
 
class  PolygonHole
 A concrete instantiation of the Hole class that describes polygonal (triangular, square, pentagonal, ...) holes. More...
 

Public Types

enum  TriangulationType { GENERATE_CONVEX_HULL = 0, PSLG = 1, INVALID_TRIANGULATION_TYPE }
 The TriangulationType is used with the general triangulate function defined below. More...
 

Public Member Functions

 TriangleInterface (UnstructuredMesh &mesh)
 The constructor. More...
 
 ~TriangleInterface ()
 Empty destructor. More...
 
void triangulate ()
 This is the main public interface for this function. More...
 
ElemTypeelem_type ()
 Sets and/or gets the desired element type. More...
 
Realdesired_area ()
 Sets and/or gets the desired triangle area. More...
 
Realminimum_angle ()
 Sets and/or gets the minimum angle. More...
 
std::string & extra_flags ()
 Sets and/or gets additional flags to be passed to triangle. More...
 
TriangulationTypetriangulation_type ()
 Sets and/or gets the desired triangulation type. More...
 
bool & insert_extra_points ()
 Sets and/or gets the flag for inserting add'l points. More...
 
bool & smooth_after_generating ()
 Sets/gets flag which tells whether to do Delaunay mesh smoothing after generating the grid. More...
 
void attach_hole_list (const std::vector< Hole *> *holes)
 Attaches a vector of Hole* pointers which will be meshed around. More...
 

Public Attributes

std::vector< std::pair< unsigned int, unsigned int > > segments
 When constructing a PSLG, it is often not possible to do so implicitly through the ordering of the points. More...
 

Private Attributes

UnstructuredMesh_mesh
 Reference to the mesh which is to be created by triangle. More...
 
const std::vector< Hole * > * _holes
 A pointer to a vector of Hole*s. More...
 
ElemType _elem_type
 The type of elements to generate. More...
 
Real _desired_area
 The desired area for the elements in the resulting mesh. More...
 
Real _minimum_angle
 Minimum angle in triangles. More...
 
std::string _extra_flags
 Additional flags to be passed to triangle. More...
 
TriangulationType _triangulation_type
 The type of triangulation to perform: choices are: convex hull PSLG. More...
 
bool _insert_extra_points
 Flag which tells whether or not to insert additional nodes before triangulation. More...
 
bool _smooth_after_generating
 Flag which tells whether we should smooth the mesh after it is generated. More...
 
MeshSerializer _serializer
 Triangle only operates on serial meshes. More...
 

Detailed Description

A C++ interface between LibMesh and the Triangle library written by J.R.

Shewchuk.

Author
John W. Peterson
Date
2011

Definition at line 57 of file mesh_triangle_interface.h.

Member Enumeration Documentation

◆ TriangulationType

The TriangulationType is used with the general triangulate function defined below.

Enumerator
GENERATE_CONVEX_HULL 

Uses the triangle library to first generate a convex hull from the set of points passed in, and then triangulate this set of points.

This is probably the most common type of usage.

PSLG 

Use the triangle library to triangulate a Planar Straight Line Graph which is defined implicitly by the order of the "points" vector: a straight line is assumed to lie between each successive pair of points, with an additional line joining the final and first points.

In case your triangulation is a little too "structured" looking (which can happen when the initial PSLG is really simple) you can try to make the resulting triangulation a little more "unstructured" looking by setting insert_points to true in the triangulate() function.

INVALID_TRIANGULATION_TYPE 

Does nothing, used as a default value.

Definition at line 78 of file mesh_triangle_interface.h.

79  {
86 
97  PSLG = 1,
98 
103  };
Uses the triangle library to first generate a convex hull from the set of points passed in...
Use the triangle library to triangulate a Planar Straight Line Graph which is defined implicitly by t...

Constructor & Destructor Documentation

◆ TriangleInterface()

libMesh::TriangleInterface::TriangleInterface ( UnstructuredMesh mesh)
explicit

The constructor.

A reference to the mesh containing the points which are to be triangulated must be provided. Unless otherwise specified, a convex hull will be computed for the set of input points and the convex hull will be meshed.

◆ ~TriangleInterface()

libMesh::TriangleInterface::~TriangleInterface ( )

Empty destructor.

Definition at line 72 of file mesh_triangle_interface.h.

72 {}

Member Function Documentation

◆ attach_hole_list()

void libMesh::TriangleInterface::attach_hole_list ( const std::vector< Hole *> *  holes)

Attaches a vector of Hole* pointers which will be meshed around.

Definition at line 162 of file mesh_triangle_interface.h.

References _holes.

162 {_holes = holes;}
const std::vector< Hole * > * _holes
A pointer to a vector of Hole*s.

◆ desired_area()

Real& libMesh::TriangleInterface::desired_area ( )

Sets and/or gets the desired triangle area.

Set to zero to disable area constraint.

Definition at line 129 of file mesh_triangle_interface.h.

References _desired_area.

129 {return _desired_area;}
Real _desired_area
The desired area for the elements in the resulting mesh.

◆ elem_type()

ElemType& libMesh::TriangleInterface::elem_type ( )

Sets and/or gets the desired element type.

Definition at line 123 of file mesh_triangle_interface.h.

References _elem_type.

123 {return _elem_type;}
ElemType _elem_type
The type of elements to generate.

◆ extra_flags()

std::string& libMesh::TriangleInterface::extra_flags ( )

Sets and/or gets additional flags to be passed to triangle.

Definition at line 140 of file mesh_triangle_interface.h.

References _extra_flags.

140 {return _extra_flags;}
std::string _extra_flags
Additional flags to be passed to triangle.

◆ insert_extra_points()

bool& libMesh::TriangleInterface::insert_extra_points ( )

Sets and/or gets the flag for inserting add'l points.

Definition at line 150 of file mesh_triangle_interface.h.

References _insert_extra_points.

150 {return _insert_extra_points;}
bool _insert_extra_points
Flag which tells whether or not to insert additional nodes before triangulation.

◆ minimum_angle()

Real& libMesh::TriangleInterface::minimum_angle ( )

Sets and/or gets the minimum angle.

Set to zero to disable area constraint.

Definition at line 135 of file mesh_triangle_interface.h.

References _minimum_angle.

135 {return _minimum_angle;}
Real _minimum_angle
Minimum angle in triangles.

◆ smooth_after_generating()

bool& libMesh::TriangleInterface::smooth_after_generating ( )

Sets/gets flag which tells whether to do Delaunay mesh smoothing after generating the grid.

Definition at line 156 of file mesh_triangle_interface.h.

References _smooth_after_generating.

156 {return _smooth_after_generating;}
bool _smooth_after_generating
Flag which tells whether we should smooth the mesh after it is generated.

◆ triangulate()

void libMesh::TriangleInterface::triangulate ( )

This is the main public interface for this function.

Internally, it calls Triangle's triangulate routine.

◆ triangulation_type()

TriangulationType& libMesh::TriangleInterface::triangulation_type ( )

Sets and/or gets the desired triangulation type.

Definition at line 145 of file mesh_triangle_interface.h.

References _triangulation_type.

145 {return _triangulation_type;}
TriangulationType _triangulation_type
The type of triangulation to perform: choices are: convex hull PSLG.

Member Data Documentation

◆ _desired_area

Real libMesh::TriangleInterface::_desired_area
private

The desired area for the elements in the resulting mesh.

Definition at line 198 of file mesh_triangle_interface.h.

Referenced by desired_area().

◆ _elem_type

ElemType libMesh::TriangleInterface::_elem_type
private

The type of elements to generate.

(Defaults to TRI3).

Definition at line 193 of file mesh_triangle_interface.h.

Referenced by elem_type().

◆ _extra_flags

std::string libMesh::TriangleInterface::_extra_flags
private

Additional flags to be passed to triangle.

Definition at line 208 of file mesh_triangle_interface.h.

Referenced by extra_flags().

◆ _holes

const std::vector<Hole*>* libMesh::TriangleInterface::_holes
private

A pointer to a vector of Hole*s.

If this is nullptr, there are no holes!

Definition at line 187 of file mesh_triangle_interface.h.

Referenced by attach_hole_list().

◆ _insert_extra_points

bool libMesh::TriangleInterface::_insert_extra_points
private

Flag which tells whether or not to insert additional nodes before triangulation.

This can sometimes be used to "de-regularize" the resulting triangulation.

Definition at line 222 of file mesh_triangle_interface.h.

Referenced by insert_extra_points().

◆ _mesh

UnstructuredMesh& libMesh::TriangleInterface::_mesh
private

Reference to the mesh which is to be created by triangle.

Definition at line 181 of file mesh_triangle_interface.h.

◆ _minimum_angle

Real libMesh::TriangleInterface::_minimum_angle
private

Minimum angle in triangles.

Definition at line 203 of file mesh_triangle_interface.h.

Referenced by minimum_angle().

◆ _serializer

MeshSerializer libMesh::TriangleInterface::_serializer
private

Triangle only operates on serial meshes.

Definition at line 233 of file mesh_triangle_interface.h.

◆ _smooth_after_generating

bool libMesh::TriangleInterface::_smooth_after_generating
private

Flag which tells whether we should smooth the mesh after it is generated.

True by default.

Definition at line 228 of file mesh_triangle_interface.h.

Referenced by smooth_after_generating().

◆ _triangulation_type

TriangulationType libMesh::TriangleInterface::_triangulation_type
private

The type of triangulation to perform: choices are: convex hull PSLG.

Definition at line 215 of file mesh_triangle_interface.h.

Referenced by triangulation_type().

◆ segments

std::vector<std::pair<unsigned int, unsigned int> > libMesh::TriangleInterface::segments

When constructing a PSLG, it is often not possible to do so implicitly through the ordering of the points.

You can use the segments vector to specify the segments explicitly, Ex: unit square numbered counter-clockwise starting from origin segments[0] = (0,1) segments[1] = (1,2) segments[2] = (2,3) segments[3] = (3,0) For this case you could actually use the implicit ordering!

Definition at line 175 of file mesh_triangle_interface.h.


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