My Project
programmer's documentation
cs_join_intersect.h
Go to the documentation of this file.
1 #ifndef __CS_JOIN_INTERSECT_H__
2 #define __CS_JOIN_INTERSECT_H__
3 
4 /*============================================================================
5  * Set of subroutines for finding intersections between bounding boxes
6  * - on faces
7  * - on edges
8  *===========================================================================*/
9 
10 /*
11  This file is part of Code_Saturne, a general-purpose CFD tool.
12 
13  Copyright (C) 1998-2019 EDF S.A.
14 
15  This program is free software; you can redistribute it and/or modify it under
16  the terms of the GNU General Public License as published by the Free Software
17  Foundation; either version 2 of the License, or (at your option) any later
18  version.
19 
20  This program is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23  details.
24 
25  You should have received a copy of the GNU General Public License along with
26  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
27  Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 */
29 
30 /*----------------------------------------------------------------------------*/
31 
32 /*----------------------------------------------------------------------------
33  * Standard C library headers
34  *---------------------------------------------------------------------------*/
35 
36 /*----------------------------------------------------------------------------
37  * Local library headers
38  *---------------------------------------------------------------------------*/
39 
40 #include "cs_base.h"
41 #include "cs_join_mesh.h"
42 #include "cs_join_set.h"
43 #include "cs_join_util.h"
44 
45 /*---------------------------------------------------------------------------*/
46 
48 
49 /*============================================================================
50  * Macro and type definitions
51  *===========================================================================*/
52 
55 /* Definition of a structure defining an intersection */
56 /* -------------------------------------------------- */
57 
58 typedef struct {
59 
60  cs_lnum_t edge_id; /* id of the edge implied in this intersection */
61  cs_lnum_t vtx_id; /* id of the vertex resulting of the intersection */
62  cs_coord_t curv_abs; /* curvilinear abscissa of the intersection */
63 
64 } cs_join_inter_t;
65 
66 /* Definition of a structure defining a set of intersections */
67 /* --------------------------------------------------------- */
68 
69 typedef struct {
70 
71  cs_lnum_t n_max_inter; /* max. number of intersections allocated */
72  cs_lnum_t n_inter; /* number of intersections */
73 
74  cs_join_inter_t *inter_lst; /* size = 2 * n_intersections
75  one inter_t structure for each edge
76  implied in an intersection */
77 
78 } cs_join_inter_set_t;
79 
80 /* Definition of a structure defining a set of intersections on edges */
81 /* ------------------------------------------------------------------ */
82 
83 typedef struct {
84 
85  cs_lnum_t n_edges; /* Number of edges implied in an intersection */
86 
87  cs_gnum_t *edge_gnum; /* Global number of the related edges */
88  cs_lnum_t *index; /* Indexed list of vertex num describing
89  intersections on a given edge without
90  vertices at the extremity and ordered
91  by curvilinear abscissa */
92 
93  cs_lnum_t *vtx_lst; /* List of new vertex num */
94  cs_gnum_t *vtx_glst; /* List of new vertex global num */
95  cs_coord_t *abs_lst; /* List of curvilinear abscissa */
96 
97  cs_lnum_t max_sub_size;
98 
99 } cs_join_inter_edges_t;
100 
103 /*============================================================================
104  * Public function prototypes
105  *===========================================================================*/
106 
107 /*----------------------------------------------------------------------------
108  * Create a new cs_join_inter_set_t structure.
109  *
110  * parameters:
111  * init_size <-- number of init. cs_join_inter_t structure to allocate
112  *
113  * returns:
114  * a pointer to a new inter_set_t structure.
115  *---------------------------------------------------------------------------*/
116 
117 cs_join_inter_set_t *
119 
120 /*----------------------------------------------------------------------------
121  * Destroy a cs_join_inter_set_t structure.
122  *
123  * parameters:
124  * inter_set <-> a pointer to the inter_set_t structure to destroy
125  *---------------------------------------------------------------------------*/
126 
127 void
128 cs_join_inter_set_destroy(cs_join_inter_set_t **inter_set);
129 
130 /*----------------------------------------------------------------------------
131  * Dump a cs_join_inter_set_t structure.
132  *
133  * parameters:
134  * f <-- handle to output file
135  * i_set <-- cs_join_inter_set_t structure to dump
136  * edges <-- associated cs_join_edge_t structure
137  * mesh <-- associated cs_join_mesh_t structure
138  *---------------------------------------------------------------------------*/
139 
140 void
141 cs_join_inter_set_dump(FILE *f,
142  const cs_join_inter_set_t *i_set,
143  const cs_join_edges_t *edges,
144  const cs_join_mesh_t *mesh);
145 
146 /*----------------------------------------------------------------------------
147  * Allocate and initialize a new cs_join_inter_edges_t structure.
148  *
149  * parameters:
150  * n_edges <-- number of edges
151  *
152  * returns:
153  * a pointer to the created cs_join_inter_edges_t structure.
154  *---------------------------------------------------------------------------*/
155 
156 cs_join_inter_edges_t *
158 
159 /*----------------------------------------------------------------------------
160  * Build a cs_join_inter_edges_t structure (useful to find equivalence on
161  * edges and to apply vertex merge to a cs_join_mesh_t structure).
162  *
163  * parameters:
164  * edges <-- cs_join_edges_t structure
165  * inter_set <-- structure storing data on edge intersections
166  *
167  * returns:
168  * a pointer to the created cs_join_inter_edges_t structure
169  *---------------------------------------------------------------------------*/
170 
171 cs_join_inter_edges_t *
172 cs_join_inter_edges_define(const cs_join_edges_t *edges,
173  const cs_join_inter_set_t *inter_set);
174 
175 /*----------------------------------------------------------------------------
176  * Destroy an cs_join_inter_edges_t structure.
177  *
178  * parameters:
179  * inter_edges <-> pointer to cs_join_inter_edges_t structure to destroy
180  *---------------------------------------------------------------------------*/
181 
182 void
183 cs_join_inter_edges_destroy(cs_join_inter_edges_t **inter_edges);
184 
185 /*----------------------------------------------------------------------------
186  * Find non-trivial equivalences between vertices sharing the same edges.
187  *
188  * For instance an equivalence between a vertex from the extremity of an edge
189  * and a vertex created by an edge-edge intersection.
190  *
191  * parameters:
192  * param <-- set of user-defined parameter
193  * mesh <-- pointer to the local cs_join_mesh_t structure
194  * which has initial vertex data
195  * edges <-- list of edges
196  * inter_edges <-- structure including data on edge intersections
197  * vtx_equiv <-> structure dealing with vertex equivalences
198  *---------------------------------------------------------------------------*/
199 
200 void
202  cs_join_mesh_t *mesh,
203  const cs_join_edges_t *edges,
204  const cs_join_inter_edges_t *inter_edges,
205  cs_join_eset_t *vtx_equiv);
206 
207 #if defined(HAVE_MPI)
208 
209 /*----------------------------------------------------------------------------
210  * Synchronize the definition of intersections on each edge by block.
211  *
212  * parameters:
213  * edges <-- cs_join_edges_t structure
214  * mesh <-- cs_join_mesh_t structure
215  * part <-- structure storing data on edge intersections by partition
216  *
217  * returns:
218  * newly allocated cs_join_inter_edges_t, synchronized and defined on
219  * a block
220  *---------------------------------------------------------------------------*/
221 
222 cs_join_inter_edges_t *
223 cs_join_inter_edges_part_to_block(const cs_join_mesh_t *mesh,
224  const cs_join_edges_t *edges,
225  const cs_join_inter_edges_t *part);
226 
227 /*----------------------------------------------------------------------------
228  * Synchronize the definition of intersections on each edge from a
229  * cs_join_inter_edges_t structure defined on a block.
230  *
231  * parameters:
232  * n_g_egdes <-- global number of edges
233  * block <-- synchronized cs_join_inter_edges_t struct. by block
234  * part <-> cs_join_inter_edges_t to synchronized on partition
235  *---------------------------------------------------------------------------*/
236 
237 void
238 cs_join_inter_edges_block_to_part(cs_gnum_t n_g_edges,
239  const cs_join_inter_edges_t *block,
240  cs_join_inter_edges_t *part);
241 
242 #endif /* HAVE_MPI */
243 
244 /*----------------------------------------------------------------------------
245  * Redefine a cs_join_inter_edges_t structure to be consistent with the local
246  * numbering of a given couple of cs_join_mesh_t structure and
247  * cs_join_edges_t structure.
248  * Add future new vertices for the face definition in cs_join_mesh_t
249  *
250  * parameters:
251  * verbosity <-- verbosity level
252  * edges <-- cs_join_edges_t structure
253  * mesh <-> cs_join_mesh_t structure
254  * inter_edges <-> current cs_join_inter_edges_t struct. to work with
255  *---------------------------------------------------------------------------*/
256 
257 void
258 cs_join_intersect_update_struct(int verbosity,
259  const cs_join_edges_t *edges,
260  cs_join_mesh_t *mesh,
261  cs_join_inter_edges_t **inter_edges);
262 
263 /*----------------------------------------------------------------------------
264  * Get all real edges intersections among possible edges intersections.
265  *
266  * parameters:
267  * param <-- set of user-defined parameters for the joining
268  * edge_edge_vis <-- a pointer to a cs_join_gset_t structure
269  * edges <-- pointer to a structure defining edges
270  * mesh <-- pointer to the cs_join_mesh_t structure
271  * which has the face connectivity
272  * inter_set <-> pointer to a structure including data on edge
273  * intersections
274  * vtx_eset <-> pointer to a structure dealing with vertex
275  * equivalences
276  *
277  * returns:
278  * the type of joining encountered (conforming or not)
279  *---------------------------------------------------------------------------*/
280 
283  const cs_join_gset_t *edge_edge_vis,
284  const cs_join_edges_t *edges,
285  const cs_join_mesh_t *mesh,
286  cs_join_eset_t **vtx_eset,
287  cs_join_inter_set_t **inter_set);
288 
289 /*----------------------------------------------------------------------------
290  * Build a tree structure on which we associate leaves and face bounding boxes.
291  * Create a cs_join_gset_t structure (indexed list on global numbering)
292  * storing potential intersections between face bounding boxes.
293  *
294  * parameters:
295  * param <-- set of user-defined parameters
296  * join_mesh <-- cs_join_mesh_t structure where faces are defined
297  * stats <-> joining statistics
298  *
299  * returns:
300  * a new allocated pointer to a cs_join_gset_t structure storing the
301  * face - face visibility.
302  *---------------------------------------------------------------------------*/
303 
304 cs_join_gset_t *
306  const cs_join_mesh_t *join_mesh,
307  cs_join_stats_t *stats);
308 
309 /*----------------------------------------------------------------------------
310  * Transform face visibility into edge visibility.
311  *
312  * parameters:
313  * mesh <-- pointer to a cs_join_mesh_t structure
314  * edges <-- pointer to a cs_join_edges_t structure
315  * face_visib <-- pointer to a cs_join_gset_t structure
316  *
317  * returns:
318  * a new allocated cs_join_gset_t structure holding edge visibility
319  *---------------------------------------------------------------------------*/
320 
321 cs_join_gset_t *
322 cs_join_intersect_face_to_edge(const cs_join_mesh_t *mesh,
323  const cs_join_edges_t *edges,
324  const cs_join_gset_t *face_visib);
325 
326 /*----------------------------------------------------------------------------
327  * Dump a cs_join_inter_edges_t structure.
328  *
329  * parameters:
330  * f <-- handle to output file
331  * inter_edges <-- cs_join_inter_edges_t structure to dump
332  * edges <-- list of edges
333  * mesh <-- associated cs_join_mesh_t structure
334  *---------------------------------------------------------------------------*/
335 
336 void
338  const cs_join_inter_edges_t *inter_edges,
339  const cs_join_edges_t *edges,
340  const cs_join_mesh_t *mesh);
341 
342 /*---------------------------------------------------------------------------*/
343 
345 
346 #endif /* __CS_JOIN_INTERSECT_H__ */
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_join_intersect_edges
cs_join_type_t cs_join_intersect_edges(cs_join_param_t param, const cs_join_gset_t *edge_edge_vis, const cs_join_edges_t *edges, const cs_join_mesh_t *mesh, cs_join_eset_t **vtx_eset, cs_join_inter_set_t **inter_set)
Definition: cs_join_intersect.c:3654
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_join_add_equiv_from_edges
void cs_join_add_equiv_from_edges(cs_join_param_t param, cs_join_mesh_t *mesh, const cs_join_edges_t *edges, const cs_join_inter_edges_t *inter_edges, cs_join_eset_t *vtx_equiv)
Definition: cs_join_intersect.c:2660
cs_join_inter_set_dump
void cs_join_inter_set_dump(FILE *f, const cs_join_inter_set_t *i_set, const cs_join_edges_t *edges, const cs_join_mesh_t *mesh)
Definition: cs_join_intersect.c:2376
cs_join_intersect_faces
cs_join_gset_t * cs_join_intersect_faces(const cs_join_param_t param, const cs_join_mesh_t *join_mesh, cs_join_stats_t *stats)
Definition: cs_join_intersect.c:3883
cs_join_inter_edges_create
cs_join_inter_edges_t * cs_join_inter_edges_create(cs_lnum_t n_edges)
Definition: cs_join_intersect.c:2427
cs_join_util.h
mesh
Definition: mesh.f90:26
cs_join_stats_t
Definition: cs_join_util.h:79
cs_join_intersect_update_struct
void cs_join_intersect_update_struct(int verbosity, const cs_join_edges_t *edges, cs_join_mesh_t *mesh, cs_join_inter_edges_t **inter_edges)
Definition: cs_join_intersect.c:3444
cs_join_inter_edges_destroy
void cs_join_inter_edges_destroy(cs_join_inter_edges_t **inter_edges)
Definition: cs_join_intersect.c:2629
cs_gnum_t
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:286
cs_join_inter_edges_define
cs_join_inter_edges_t * cs_join_inter_edges_define(const cs_join_edges_t *edges, const cs_join_inter_set_t *inter_set)
Definition: cs_join_intersect.c:2474
cs_join_inter_set_destroy
void cs_join_inter_set_destroy(cs_join_inter_set_t **inter_set)
Definition: cs_join_intersect.c:2355
cs_join_intersect_face_to_edge
cs_join_gset_t * cs_join_intersect_face_to_edge(const cs_join_mesh_t *mesh, const cs_join_edges_t *edges, const cs_join_gset_t *face_visib)
Definition: cs_join_intersect.c:3996
cs_join_type_t
cs_join_type_t
Definition: cs_join_util.h:55
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_join_mesh.h
cs_join_inter_edges_dump
void cs_join_inter_edges_dump(FILE *f, const cs_join_inter_edges_t *inter_edges, const cs_join_edges_t *edges, const cs_join_mesh_t *mesh)
Definition: cs_join_intersect.c:4206
cs_join_param_t
Definition: cs_join_util.h:115
cs_coord_t
double cs_coord_t
Definition: cs_defs.h:299
cs_join_set.h
cs_join_inter_set_create
cs_join_inter_set_t * cs_join_inter_set_create(cs_lnum_t init_size)
Definition: cs_join_intersect.c:2333
cs_base.h