src/fvm/fvm_triangulate.h Source File

| programmer's documentation

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
fvm_triangulate.h
Go to the documentation of this file.
1 #ifndef __FVM_TRIANGULATE_H__
2 #define __FVM_TRIANGULATE_H__
3
4 /*============================================================================
5 * Triangulation of a polygon
6 *============================================================================*/
7
8 /*
9 This file is part of Code_Saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2013 EDF S.A.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25 Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27
28 /*----------------------------------------------------------------------------*/
29
30 #include "cs_defs.h"
31
32 /*----------------------------------------------------------------------------
33 * Local headers
34 *----------------------------------------------------------------------------*/
35
36 #include "fvm_defs.h"
37
38 /*----------------------------------------------------------------------------*/
39
40 BEGIN_C_DECLS
41
42 /*=============================================================================
43 * Macro definitions
44 *============================================================================*/
45
46 /*============================================================================
47 * Type definitions
48 *============================================================================*/
49
50 /*
51 * Pointer to structure maintaining the state of the current triangulation;
52 * the structure itself is private.
53 */
54
55 typedef struct _fvm_triangulate_state_t fvm_triangulate_state_t;
56
57 /*
58 * Describe how the resulting triangle connectivity is defined.
59 */
60
61 typedef enum {
62
63 FVM_TRIANGULATE_MESH_DEF, /* Definition by mesh vertex numbers */
64 FVM_TRIANGULATE_ELT_DEF /* Definition by local (element) vertex
65 position (1 to n) */
66
67 } fvm_triangulate_def_t;
68
69 /*=============================================================================
70 * Static global variables
71 *============================================================================*/
72
73 /*=============================================================================
74 * Public function prototypes
75 *============================================================================*/
76
77 /*----------------------------------------------------------------------------
78 * Create a structure necessary to the polygon triangulation algorithm.
79 *
80 * parameters:
81 * n_vertices_max <-- maximum expected number of vertices per polygon.
82 *
83 * returns:
84 * pointer to polygon triangulation state structure.
85 *----------------------------------------------------------------------------*/
86
87 fvm_triangulate_state_t *
88 fvm_triangulate_state_create(const int n_vertices_max);
89
90 /*----------------------------------------------------------------------------
91 * Destroy a structure necessary to the polygon triangulation algorithm.
92 *
93 * parameters:
94 * this_state <-> pointer to structure that should be destroyed.
95 *
96 * returns:
97 * NULL pointer.
98 *----------------------------------------------------------------------------*/
99
100 fvm_triangulate_state_t *
101 fvm_triangulate_state_destroy(fvm_triangulate_state_t *this_state);
102
103 /*----------------------------------------------------------------------------
104 * Triangulate a polygonal face.
105 *
106 * For a polygon with n vertices, we should obtain a triangluation with
107 * (n-2) triangles and (2n-3) edges. If the polygon_vertices argument
108 * is NULL, 1, 2, ...,n local numbering is implied.
109 *
110 * parameters:
111 * dim <-- spatial dimension (2 or 3).
112 * n_vertices <-- number of vertices defining the polygon.
113 * coords <-- coordinates of the triangulation's vertices.
114 * parent_vertex_num <-- optional indirection to vertex coordinates (1 to n).
115 * polygon_vertices <-- polygon connectivity; size: n_vertices or empty.
116 * mode <-- triangles connectivity by vertex number or
117 * polygon vertex index (1 to n).
118 * triangle_vertices --> triangles connectivity;
119 * size: (n_vertices - 2) * 3.
120 * state <-> associated triangulation state structure.
121 *
122 * returns:
123 * number of resulting triangles.
124 *----------------------------------------------------------------------------*/
125
126 int
127 fvm_triangulate_polygon(int dim,
128 int n_vertices,
129 const cs_coord_t coords[],
130 const cs_lnum_t parent_vertex_num[],
131 const cs_lnum_t polygon_vertices[],
132 fvm_triangulate_def_t mode,
133 cs_lnum_t triangle_vertices[],
134 fvm_triangulate_state_t *const state);
135
136 /*----------------------------------------------------------------------------
137 * Triangulate a quadrangle.
138 *
139 * A convex quadrangle is divided into two triangles along its shortest
140 * diagonal. A non-convex quadrangle may only be divided along the diagonal
141 * which lies inside the quadrangle.
142 *
143 * If the quadrangle_vertices argument is NULL, 1, 2, ...,n local numbering
144 * is implied.
145 *
146 * parameters:
147 * dim <-- spatial dimension (2 or 3).
148 * coords <-- coordinates of the triangulation's vertices.
149 * parent_vertex_num <-- optional indirection to vertex coordinates
150 * quadrangle_vertices <-- polygon connectivity; size: n_vertices or empty.
151 * triangle_vertices --> triangles connectivity; size: 2 * 3.
152 *
153 * returns:
154 * number of resulting triangles.
155 *----------------------------------------------------------------------------*/
156
157 int
158 fvm_triangulate_quadrangle(int dim,
159 const cs_coord_t coords[],
160 const cs_lnum_t parent_vertex_num[],
161 const cs_lnum_t quadrangle_vertices[],
162 cs_lnum_t triangle_vertices[]);
163
164 /*----------------------------------------------------------------------------*/
165
166 END_C_DECLS
167
168 #endif /* __FVM_TRIANGULATE_H__ */