H2Lib  3.0
Data Structures | Typedefs | Functions
tri2d

Two-dimensional triangular meshes. More...

Data Structures

struct  _tri2d
 Representation of a two-dimensional triangular mesh. More...
 
struct  _tri2dref
 Representation of the refinement relationship between two meshes. More...
 

Typedefs

typedef struct _tri2d tri2d
 Two-dimensional triangulat mesh.
 
typedef tri2dptri2d
 Pointer to tri2d object.
 
typedef const tri2dpctri2d
 Pointer to constant tri2d object.
 
typedef struct _tri2dref tri2dref
 
typedef tri2drefptri2dref
 Pointer to tri2dref object.
 
typedef const tri2drefpctri2dref
 Pointer to constant tri2dref object.
 
typedef struct _tri2dbuilder tri2dbuilder
 Tool for constructing tri2d meshes.
 
typedef tri2dbuilderptri2dbuilder
 

Functions

ptri2d new_tri2d (uint vertices, uint edges, uint triangles)
 Create a partially initialized tri2d mesh. More...
 
void del_tri2d (ptri2d t2)
 Delete a tri2d object. More...
 
ptri2d new_unitsquare_tri2d ()
 Create a mesh containing two triangles representing the unit square, $[-1,1] \times [-1,1] $. More...
 
ptri2d new_unitcircle_tri2d ()
 Create a mesh containing four triangles representing the unit square, $[-1,1] \times [-1,1] $. More...
 
ptri2d new_lshape_tri2d ()
 Create a mesh containing six triangles representing a L-shaped domain with vertices $(-1,-1), (0,-1), (1,-1), (-1,0), (0,0), (1,0), (-1,1) and (0,1)$. More...
 
ptri2d new_ushape_tri2d ()
 Create a mesh containing twentyfour triangles representing a U-shaped domain. More...
 
void write_tri2d (pctri2d t2, const char *name)
 Write a triangular mesh to a file. More...
 
ptri2d read_tri2d (const char *name)
 Read a triangular mesh from a file. More...
 
void getvertices_tri2d (pctri2d t2, uint tn, uint v[])
 Find the vertices of a triangle. More...
 
void fixnormals_tri2d (ptri2d t2)
 Ensure that the vertices of boundary edges are in counter-clockwise order as seen from outside of the mesh. More...
 
void check_tri2d (pctri2d t2)
 Perform various consistency checks. More...
 
ptri2d refine_tri2d (pctri2d t2, ptri2dref *t2r)
 Regular refinement of a triangular mesh. More...
 
void del_tri2dref (ptri2dref t2r)
 Delete a tri2dref object. More...
 
void draw_cairo_tri2d (pctri2d t2, const char *filename, bool mark_refedges, int mark_triangle)
 Draw a tri2d mesh. More...
 
void smooth_unitcircle_tri2d (ptri2d t2)
 Smooth a tri2d unitcircle. More...
 
ptri2dbuilder new_tri2dbuilder (uint vertices)
 Create a new tri2dbuilder object. More...
 
void del_tri2dbuilder (ptri2dbuilder tb)
 Delete a tri2dbuilder object. More...
 
real(* getx_tri2dbuilder (ptri2dbuilder tb))[2]
 Obtain array of vertex coordinates in tri2dbuilder object. More...
 
void addtriangle_tri2dbuilder (ptri2dbuilder tb, uint v0, uint v1, uint v2)
 Add a triangle to a tri2dbuilder object. More...
 
ptri2d buildmesh_tri2dbuilder (ptri2dbuilder tb)
 Create a tri2d mesh from the geometrical and topological information stored in a tri2dbuilder object. More...
 

Detailed Description

Two-dimensional triangular meshes.

Typedef Documentation

Pointer to tri2dbuilder object

typedef struct _tri2dref tri2dref

Refinement data for triangular meshes

Function Documentation

void addtriangle_tri2dbuilder ( ptri2dbuilder  tb,
uint  v0,
uint  v1,
uint  v2 
)

Add a triangle to a tri2dbuilder object.

Parameters
tbTarget tri2dbuilder object.
v0Index of first vertex.
v1Index of second vertex.
v2Index of third vertex.
ptri2d buildmesh_tri2dbuilder ( ptri2dbuilder  tb)

Create a tri2d mesh from the geometrical and topological information stored in a tri2dbuilder object.

Once the mesh has been created, the corresponding tri2dbuilder object can be deleted.

Parameters
tbSource tri2dbuilder object.
Returns
tri2d mesh.
void check_tri2d ( pctri2d  t2)

Perform various consistency checks.

Parameters
t2Mesh
Returns
Number of inconsistencies found
void del_tri2d ( ptri2d  t2)

Delete a tri2d object.

Parameters
t2Object to be deleted
void del_tri2dbuilder ( ptri2dbuilder  tb)

Delete a tri2dbuilder object.

Parameters
tbObject to be deleted.
void del_tri2dref ( ptri2dref  t2r)

Delete a tri2dref object.

Parameters
t2rObject to be deleted
void draw_cairo_tri2d ( pctri2d  t2,
const char *  filename,
bool  mark_refedges,
int  mark_triangle 
)

Draw a tri2d mesh.

Draw a tri2d mesh.

Parameters
t2This grid will be drawn.
filenameIn this fill the mesh will be drawn.
mark_refedges
mark_triangle
void fixnormals_tri2d ( ptri2d  t2)

Ensure that the vertices of boundary edges are in counter-clockwise order as seen from outside of the mesh.

Parameters
t2Mesh, offending boundary edges will be reordered
Returns
Number of edges that have been fixed.
void getvertices_tri2d ( pctri2d  t2,
uint  tn,
uint  v[] 
)

Find the vertices of a triangle.

Due to the hierarchical representation of geometric objects, we cannot access the vertices of a triangle directly. This function finds the vertices and returns them in a specific order: v[i] is the vertex opposite the i-th edge.

Parameters
t2Mesh
tnNumber of the triangle
vWill be filled with vertex numbers.
real(* getx_tri2dbuilder ( ptri2dbuilder  tb) )[2]

Obtain array of vertex coordinates in tri2dbuilder object.

Since tri2dbuilder is an opaque class, this function is provided for setting the coordinates of the vertices.

Parameters
tbtri2dbuilder object.
Returns
Pointer to array of with tb->vertices entries of type real [2] representing the vertex coordinates.
ptri2d new_lshape_tri2d ( )

Create a mesh containing six triangles representing a L-shaped domain with vertices $(-1,-1), (0,-1), (1,-1), (-1,0), (0,0), (1,0), (-1,1) and (0,1)$.

Returns
tri2d mesh representing the L-shaped domain
ptri2d new_tri2d ( uint  vertices,
uint  edges,
uint  triangles 
)

Create a partially initialized tri2d mesh.

All arrays are created, but are not filled with meaningful values.

Parameters
verticesNumber of vertices
edgesNumber of edges
trianglesNumber of tetrahedra
Returns
Partially initialized tri2d mesh
ptri2dbuilder new_tri2dbuilder ( uint  vertices)

Create a new tri2dbuilder object.

Parameters
verticesNumber of vertices of the new mesh.
Returns
tri2dbuilder object with no edges or triangles.
ptri2d new_unitcircle_tri2d ( )

Create a mesh containing four triangles representing the unit square, $[-1,1] \times [-1,1] $.

Returns
tri2d mesh representing the unit square.
ptri2d new_unitsquare_tri2d ( )

Create a mesh containing two triangles representing the unit square, $[-1,1] \times [-1,1] $.

Returns
tri2d mesh representing the unit square.
ptri2d new_ushape_tri2d ( )

Create a mesh containing twentyfour triangles representing a U-shaped domain.

Returns
tri2d mesh representing the U-shape.
ptri2d read_tri2d ( const char *  name)

Read a triangular mesh from a file.

Parameters
nameFilename
Returns
tri2d object describing the mesh
ptri2d refine_tri2d ( pctri2d  t2,
ptri2dref t2r 
)

Regular refinement of a triangular mesh.

The mesh is globally refined using regular refinement.

Parameters
t2Coarse mesh
t2rIf not null, the target pointer will be set to a new tri2dref object describing the refinement relationship
Returns
Refined mesh
void smooth_unitcircle_tri2d ( ptri2d  t2)

Smooth a tri2d unitcircle.

Smooth a tri2d mesh representing a unit circle. The vertices of the smooth unit circle are shifted to the boundary.

Parameters
t2mesh representing the unitsquare, will be overwritten with smooth mesh.
void write_tri2d ( pctri2d  t2,
const char *  name 
)

Write a triangular mesh to a file.

Parameters
t2Source mesh
nameFilename