9.2
general documentation
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-2026 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 "base/cs_defs.h"
31
32/*----------------------------------------------------------------------------
33 * Local headers
34 *----------------------------------------------------------------------------*/
35
36#include "fvm/fvm_defs.h"
37
38/*=============================================================================
39 * Macro definitions
40 *============================================================================*/
41
42/*============================================================================
43 * Type definitions
44 *============================================================================*/
45
46/*
47 * Pointer to structure maintaining the state of the current triangulation;
48 * the structure itself is private.
49 */
50
51typedef struct _fvm_triangulate_state_t fvm_triangulate_state_t;
52
53/*
54 * Describe how the resulting triangle connectivity is defined.
55 */
56
57typedef enum {
58
59 FVM_TRIANGULATE_MESH_DEF, /* Definition by mesh vertex numbers */
60 FVM_TRIANGULATE_ELT_DEF /* Definition by local (element) vertex
61 position (1 to n) */
62
64
65/*=============================================================================
66 * Static global variables
67 *============================================================================*/
68
69/*=============================================================================
70 * Public function prototypes
71 *============================================================================*/
72
73/*----------------------------------------------------------------------------
74 * Create a structure necessary to the polygon triangulation algorithm.
75 *
76 * parameters:
77 * n_vertices_max <-- maximum expected number of vertices per polygon.
78 *
79 * returns:
80 * pointer to polygon triangulation state structure.
81 *----------------------------------------------------------------------------*/
82
84fvm_triangulate_state_create(const int n_vertices_max);
85
86/*----------------------------------------------------------------------------
87 * Destroy a structure necessary to the polygon triangulation algorithm.
88 *
89 * parameters:
90 * this_state <-> pointer to structure that should be destroyed.
91 *
92 * returns:
93 * null pointer.
94 *----------------------------------------------------------------------------*/
95
98
99/*----------------------------------------------------------------------------
100 * Triangulate a polygonal face.
101 *
102 * For a polygon with n vertices, we should obtain a triangluation with
103 * (n-2) triangles and (2n-3) edges. If the polygon_vertices argument
104 * is NULL, 1, 2, ...,n local numbering is implied.
105 *
106 * parameters:
107 * dim <-- spatial dimension (2 or 3).
108 * base <-- base numbering (usually 0 or 1)
109 * n_vertices <-- number of vertices defining the polygon.
110 * coords <-- coordinates of the triangulation's vertices.
111 * parent_vertex_id <-- optional indirection to vertex coordinates
112 * (0 to n-1).
113 * polygon_vertices <-- polygon connectivity; size: n_vertices or empty.
114 * mode <-- triangles connectivity by vertex number or
115 * polygon vertex index.
116 * triangle_vertices --> triangles connectivity;
117 * size: (n_vertices - 2) * 3.
118 * state <-> associated triangulation state structure.
119 *
120 * returns:
121 * number of resulting triangles.
122 *----------------------------------------------------------------------------*/
123
124int
126 int base,
127 int n_vertices,
128 const cs_coord_t coords[],
129 const cs_lnum_t parent_vertex_id[],
130 const cs_lnum_t polygon_vertices[],
132 cs_lnum_t triangle_vertices[],
133 fvm_triangulate_state_t *const state);
134
135/*----------------------------------------------------------------------------
136 * Triangulate a quadrangle.
137 *
138 * A convex quadrangle is divided into two triangles along its shortest
139 * diagonal. A non-convex quadrangle may only be divided along the diagonal
140 * which lies inside the quadrangle.
141 *
142 * If the quadrangle_vertices argument is NULL, 1, 2, ...,n local numbering
143 * is implied.
144 *
145 * parameters:
146 * dim <-- spatial dimension (2 or 3).
147 * base <-- base numbering (usually 0 or 1)
148 * coords <-- coordinates of the triangulation's vertices.
149 * parent_vertex_id <-- optional indirection to vertex coordinates
150 * (0 to n-1).
151 * quadrangle_vertices <-- polygon connectivity; size: n_vertices or empty.
152 * triangle_vertices --> triangles connectivity; size: 2 * 3.
153 *
154 * returns:
155 * number of resulting triangles.
156 *----------------------------------------------------------------------------*/
157
158int
160 int base,
161 const cs_coord_t coords[],
162 const cs_lnum_t parent_vertex_id[],
163 const cs_lnum_t quadrangle_vertices[],
164 cs_lnum_t triangle_vertices[]);
165
166/*----------------------------------------------------------------------------*/
167
168#endif /* FVM_TRIANGULATE_H */
double cs_coord_t
Definition: cs_defs.h:330
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
fvm_triangulate_state_t * fvm_triangulate_state_create(const int n_vertices_max)
Definition: fvm_triangulate.cpp:985
int fvm_triangulate_polygon(int dim, int base, int n_vertices, const cs_coord_t coords[], const cs_lnum_t parent_vertex_id[], const cs_lnum_t polygon_vertices[], fvm_triangulate_def_t mode, cs_lnum_t triangle_vertices[], fvm_triangulate_state_t *const state)
Definition: fvm_triangulate.cpp:1076
struct _fvm_triangulate_state_t fvm_triangulate_state_t
Definition: fvm_triangulate.h:51
fvm_triangulate_state_t * fvm_triangulate_state_destroy(fvm_triangulate_state_t *this_state)
Definition: fvm_triangulate.cpp:1031
int fvm_triangulate_quadrangle(int dim, int base, const cs_coord_t coords[], const cs_lnum_t parent_vertex_id[], const cs_lnum_t quadrangle_vertices[], cs_lnum_t triangle_vertices[])
Definition: fvm_triangulate.cpp:1292
fvm_triangulate_def_t
Definition: fvm_triangulate.h:57
@ FVM_TRIANGULATE_MESH_DEF
Definition: fvm_triangulate.h:59
@ FVM_TRIANGULATE_ELT_DEF
Definition: fvm_triangulate.h:60