19 #include "libmesh/libmesh_config.h" 21 #ifdef LIBMESH_HAVE_TRIANGLE 24 #include "libmesh/mesh_triangle_wrapper.h" 25 #include "libmesh/boundary_info.h" 26 #include "libmesh/enum_elem_type.h" 27 #include "libmesh/face_tri3.h" 28 #include "libmesh/face_tri6.h" 29 #include "libmesh/point.h" 30 #include "libmesh/unstructured_mesh.h" 31 #include "libmesh/enum_to_string.h" 38 t.pointlist =
static_cast<REAL*
>(
nullptr);
39 t.pointattributelist =
static_cast<REAL*
>(
nullptr);
40 t.pointmarkerlist =
static_cast<int *
>(
nullptr);
41 t.numberofpoints = 0 ;
42 t.numberofpointattributes = 0 ;
44 t.trianglelist =
static_cast<int *
>(
nullptr);
45 t.triangleattributelist =
static_cast<REAL*
>(
nullptr);
46 t.trianglearealist =
static_cast<REAL*
>(
nullptr);
47 t.neighborlist =
static_cast<int *
>(
nullptr);
48 t.numberoftriangles = 0;
49 t.numberofcorners = 0;
50 t.numberoftriangleattributes = 0;
52 t.segmentlist =
static_cast<int *
>(
nullptr);
53 t.segmentmarkerlist =
static_cast<int *
>(
nullptr);
54 t.numberofsegments = 0;
56 t.holelist =
static_cast<REAL*
>(
nullptr);
59 t.regionlist =
static_cast<REAL*
>(
nullptr);
60 t.numberofregions = 0;
62 t.edgelist =
static_cast<int *
>(
nullptr);
63 t.edgemarkerlist =
static_cast<int *
>(
nullptr);
64 t.normlist =
static_cast<REAL*
>(
nullptr);
75 std::free (t.pointlist );
76 std::free (t.pointattributelist );
77 std::free (t.pointmarkerlist );
78 std::free (t.trianglelist );
79 std::free (t.triangleattributelist);
80 std::free (t.trianglearealist );
81 std::free (t.neighborlist );
82 std::free (t.segmentlist );
83 std::free (t.segmentmarkerlist );
88 std::free (t.holelist );
89 std::free (t.regionlist);
92 std::free (t.edgelist );
93 std::free (t.edgemarkerlist);
94 std::free (t.normlist );
108 const triangulateio * voronoi)
117 for (
int i=0, c=0; c<triangle_data_input.numberofpoints; i+=2, ++c)
122 triangle_data_input.pointlist[i+1]),
127 for (
int i=0; i<triangle_data_input.numberoftriangles; ++i)
135 for (
unsigned int n=0; n<3; ++n)
136 elem->
set_node(n, mesh_output.
node_ptr(triangle_data_input.trianglelist[i*3 + n]));
139 if (triangle_data_input.triangleattributelist)
141 std::round(triangle_data_input.
142 triangleattributelist[i * triangle_data_input.numberoftriangleattributes]);
151 elem->
set_node(0, mesh_output.
node_ptr(triangle_data_input.trianglelist[i*6 + 0]));
152 elem->
set_node(1, mesh_output.
node_ptr(triangle_data_input.trianglelist[i*6 + 1]));
153 elem->
set_node(2, mesh_output.
node_ptr(triangle_data_input.trianglelist[i*6 + 2]));
154 elem->
set_node(3, mesh_output.
node_ptr(triangle_data_input.trianglelist[i*6 + 5]));
155 elem->
set_node(4, mesh_output.
node_ptr(triangle_data_input.trianglelist[i*6 + 3]));
156 elem->
set_node(5, mesh_output.
node_ptr(triangle_data_input.trianglelist[i*6 + 4]));
159 if (triangle_data_input.triangleattributelist)
161 std::round(triangle_data_input.
162 triangleattributelist[i * triangle_data_input.numberoftriangleattributes]);
182 if (voronoi && triangle_data_input.edgemarkerlist)
185 for (
int e=0; e<triangle_data_input.numberofedges; ++e)
187 if (triangle_data_input.edgemarkerlist[e] != 0)
189 int p1 = triangle_data_input.edgelist[e + e];
190 int p2 = triangle_data_input.edgelist[e + e + 1];
191 int elem_id = voronoi->edgelist[e + e];
192 unsigned short int s;
193 if (p1 == triangle_data_input.trianglelist[elem_id*3] &&
194 p2 == triangle_data_input.trianglelist[elem_id*3 + 1])
196 else if (p1 == triangle_data_input.trianglelist[elem_id*3 + 1] &&
197 p2 == triangle_data_input.trianglelist[elem_id*3 + 2])
199 else if (p1 == triangle_data_input.trianglelist[elem_id*3 + 2] &&
200 p2 == triangle_data_input.trianglelist[elem_id*3])
203 libmesh_error_msg(
"ERROR: finding element errors for boundary edges.");
205 boundary_info.
add_side(elem_id, s, triangle_data_input.edgemarkerlist[e]);
214 #endif // LIBMESH_HAVE_TRIANGLE ElemType
Defines an enum for geometric element types.
virtual Node *& set_node(const unsigned int i)
This is the base class from which all geometric element types are derived.
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true) override
Other functions from MeshBase requiring re-definition.
The libMesh namespace provides an interface to certain functionality in the library.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
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.
The UnstructuredMesh class is derived from the MeshBase class.
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)
void copy_tri_to_mesh(const triangulateio &triangle_data_input, UnstructuredMesh &mesh_output, const ElemType type, const triangulateio *voronoi=nullptr)
Copies triangulation data computed by triangle from a triangulateio object to a LibMesh mesh...
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
virtual void clear()
Deletes all the element and node data that is currently stored.
std::string enum_to_string(const T e)
subdomain_id_type subdomain_id() const
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure...
void destroy(triangulateio &t, IO_Type)
Frees any memory which has been dynamically allocated by Triangle.
virtual const Node * node_ptr(const dof_id_type i) const =0
A Point defines a location in LIBMESH_DIM dimensional Real space.