H2Lib  3.0
tri2d.h
Go to the documentation of this file.
1 
2 /* ------------------------------------------------------------
3  * This is the file "tri2d.h" of the H2Lib package.
4  * All rights reserved, Dirk Boysen 2015
5  * ------------------------------------------------------------ */
6 
10 #ifndef TRI2D_H
11 #define TRI2D_H
12 
18 typedef struct _tri2d tri2d;
19 
21 typedef tri2d *ptri2d;
22 
24 typedef const tri2d *pctri2d;
25 
27 typedef struct _tri2dref tri2dref;
28 
31 
33 typedef const tri2dref *pctri2dref;
34 
36 typedef struct _tri2dbuilder tri2dbuilder;
37 
40 
41 #include "settings.h"
42 
43 /* ------------------------------------------------------------
44  Triangular mesh,
45  described by vertices, edges and triangles
46  ------------------------------------------------------------ */
47 
56 struct _tri2d {
59 
62 
65 
67  real (*x)[2];
68 
70  uint (*e)[2];
71 
73  uint (*t)[3];
74 
76  uint *xb;
77 
79  uint *eb;
80 };
81 
82 /* ------------------------------------------------------------
83  Constructors and destructors
84  ------------------------------------------------------------ */
85 
98 
102 HEADER_PREFIX void
103 del_tri2d(ptri2d t2);
104 
111 
118 
126 
133 
134 /* ------------------------------------------------------------
135  File I/O
136  -------------------------------------------------------------*/
137 
142 HEADER_PREFIX void
143 write_tri2d(pctri2d t2, const char *name);
144 
150 read_tri2d(const char *name);
151 
152 /* ------------------------------------------------------------
153  Get geometrical information
154  ------------------------------------------------------------ */
155 
156 
168 HEADER_PREFIX void
169 getvertices_tri2d(pctri2d t2, uint tn, uint v[]);
170 
171 /* ------------------------------------------------------------
172  Check structure for inconsistencies
173  ------------------------------------------------------------ */
174 
180 HEADER_PREFIX void
182 
183 
188 HEADER_PREFIX void
189 check_tri2d(pctri2d t2);
190 
191 
192 /* ------------------------------------------------------------
193  Regular refinement
194  ------------------------------------------------------------ */
195 
203 struct _tri2dref {
207  uint *xt;
208 
210  uint *ef;
212  uint *et;
213 
215  uint *tf;
216 };
217 
227 refine_tri2d(pctri2d t2, ptri2dref *t2r);
228 
232 HEADER_PREFIX void
234 
235 /* ------------------------------------------------------------
236  Display grid
237  ------------------------------------------------------------ */
238 
249 HEADER_PREFIX void
250 draw_cairo_tri2d(pctri2d t2, const char *filename,
251  bool mark_refedges, int mark_triangle);
252 
253 
254 /* -----------------------------------------------------------
255  ------------------------------------------------------------ */
264 HEADER_PREFIX void
266 
267 /* ------------------------------------------------------------
268  * Tool for constructing meshes
269  * ------------------------------------------------------------ */
270 
277 
281 HEADER_PREFIX void
283 
294 
301 HEADER_PREFIX void
303  uint v0, uint v1, uint v2);
304 
315 
317 #endif
const tri2dref * pctri2dref
Pointer to constant tri2dref object.
Definition: tri2d.h:33
ptri2d new_unitcircle_tri2d()
Create a mesh containing four triangles representing the unit square, .
void del_tri2dbuilder(ptri2dbuilder tb)
Delete a tri2dbuilder object.
ptri2dbuilder new_tri2dbuilder(uint vertices)
Create a new tri2dbuilder object.
void fixnormals_tri2d(ptri2d t2)
Ensure that the vertices of boundary edges are in counter-clockwise order as seen from outside of the...
uint * et
Type of father for an edge: 1 means edge, 2 means triangle.
Definition: tri2d.h:212
ptri2d new_ushape_tri2d()
Create a mesh containing twentyfour triangles representing a U-shaped domain.
real(* getx_tri2dbuilder(ptri2dbuilder tb))[2]
Obtain array of vertex coordinates in tri2dbuilder object.
uint * eb
Boundary flags for edges.
Definition: tri2d.h:79
ptri2d refine_tri2d(pctri2d t2, ptri2dref *t2r)
Regular refinement of a triangular mesh.
ptri2d read_tri2d(const char *name)
Read a triangular mesh from a file.
ptri2d buildmesh_tri2dbuilder(ptri2dbuilder tb)
Create a tri2d mesh from the geometrical and topological information stored in a tri2dbuilder object...
uint vertices
Number of vertices.
Definition: tri2d.h:58
uint(* t)[3]
Edge of a triangle.
Definition: tri2d.h:73
unsigned uint
Unsigned integer type.
Definition: settings.h:70
uint * tf
Father index of a triangle.
Definition: tri2d.h:215
Representation of a two-dimensional triangular mesh.
Definition: tri2d.h:56
Representation of the refinement relationship between two meshes.
Definition: tri2d.h:203
void write_tri2d(pctri2d t2, const char *name)
Write a triangular mesh to a file.
void del_tri2d(ptri2d t2)
Delete a tri2d object.
tri2dref * ptri2dref
Pointer to tri2dref object.
Definition: tri2d.h:30
void draw_cairo_tri2d(pctri2d t2, const char *filename, bool mark_refedges, int mark_triangle)
Draw a tri2d mesh.
uint * xb
Boundary flags for vertices.
Definition: tri2d.h:76
tri2dbuilder * ptri2dbuilder
Definition: tri2d.h:39
uint edges
Number of edges.
Definition: tri2d.h:61
tri2d * ptri2d
Pointer to tri2d object.
Definition: tri2d.h:21
ptri2d new_lshape_tri2d()
Create a mesh containing six triangles representing a L-shaped domain with vertices ...
void addtriangle_tri2dbuilder(ptri2dbuilder tb, uint v0, uint v1, uint v2)
Add a triangle to a tri2dbuilder object.
uint triangles
Number of triangles.
Definition: tri2d.h:64
ptri2d new_tri2d(uint vertices, uint edges, uint triangles)
Create a partially initialized tri2d mesh.
ptri2d new_unitsquare_tri2d()
Create a mesh containing two triangles representing the unit square, .
uint * ef
Father index of an edge.
Definition: tri2d.h:210
#define HEADER_PREFIX
Prefix for function declarations.
Definition: settings.h:43
double real
real floating point type.
Definition: settings.h:97
uint * xf
Father index of a vertex.
Definition: tri2d.h:205
void check_tri2d(pctri2d t2)
Perform various consistency checks.
struct _tri2dbuilder tri2dbuilder
Tool for constructing tri2d meshes.
Definition: tri2d.h:36
uint * xt
Type of father for a vertex: 0 means vertex, 1 means edge.
Definition: tri2d.h:207
real(* x)[2]
coordinates of vertices
Definition: tri2d.h:67
uint(* e)[2]
Start and end points of edges.
Definition: tri2d.h:70
void getvertices_tri2d(pctri2d t2, uint tn, uint v[])
Find the vertices of a triangle.
void smooth_unitcircle_tri2d(ptri2d t2)
Smooth a tri2d unitcircle.
void del_tri2dref(ptri2dref t2r)
Delete a tri2dref object.
const tri2d * pctri2d
Pointer to constant tri2d object.
Definition: tri2d.h:24