Code_Saturne
CFD tool
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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-2012 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  * FVM library headers
38  *---------------------------------------------------------------------------*/
39 
40 #include <fvm_defs.h>
41 
42 /*----------------------------------------------------------------------------
43  * Local library headers
44  *---------------------------------------------------------------------------*/
45 
46 #include "cs_base.h"
47 #include "cs_join_mesh.h"
48 #include "cs_join_set.h"
49 #include "cs_join_util.h"
50 
51 /*---------------------------------------------------------------------------*/
52 
54 
55 /*============================================================================
56  * Macro and type definitions
57  *===========================================================================*/
58 
59 /* Definition of a structure defining an intersection */
60 /* -------------------------------------------------- */
61 
62 typedef struct {
63 
64  cs_int_t edge_id; /* id of the edge implied in this intersection */
65  cs_int_t vtx_id; /* id of the vertex resulting of the intersection */
66  float curv_abs; /* curvilinear abscissa of the intersection */
67 
69 
70 /* Definition of a structure defining a set of intersections */
71 /* --------------------------------------------------------- */
72 
73 typedef struct {
74 
75  cs_int_t n_max_inter; /* max. number of intersections allocated */
76  cs_int_t n_inter; /* number of intersections */
77 
78  cs_join_inter_t *inter_lst; /* size = 2 * n_intersections
79  one inter_t structure for each edge
80  implied in an intersection */
81 
83 
84 /* Definition of a structure defining a set of intersections on edges */
85 /* ------------------------------------------------------------------ */
86 
87 typedef struct {
88 
89  cs_int_t n_edges; /* Number of edges implied in an intersection */
90 
91  cs_gnum_t *edge_gnum; /* Global number of the related edges */
92  cs_int_t *index; /* Indexed list of vertex num describing
93  intersections on a given edge without
94  vertices at the extremity and ordered
95  by curvilinear abscissa */
96 
97  cs_int_t *vtx_lst; /* List of new vertex num */
98  cs_gnum_t *vtx_glst; /* List of new vertex global num */
99  float *abs_lst; /* List of curvilinear abscissa */
100 
102 
104 
105 /*============================================================================
106  * Public function prototypes
107  *===========================================================================*/
108 
109 /*----------------------------------------------------------------------------
110  * Create a new cs_join_inter_set_t structure.
111  *
112  * parameters:
113  * init_size <-- number of init. cs_join_inter_t structure to allocate
114  *
115  * returns:
116  * a pointer to a new inter_set_t structure.
117  *---------------------------------------------------------------------------*/
118 
121 
122 /*----------------------------------------------------------------------------
123  * Destroy a cs_join_inter_set_t structure.
124  *
125  * parameters:
126  * inter_set <-> a pointer to the inter_set_t structure to destroy
127  *---------------------------------------------------------------------------*/
128 
129 void
131 
132 /*----------------------------------------------------------------------------
133  * Dump a cs_join_inter_set_t structure.
134  *
135  * parameters:
136  * f <-- handle to output file
137  * i_set <-- cs_join_inter_set_t structure to dump
138  * edges <-- associated cs_join_edge_t structure
139  * mesh <-- associated cs_join_mesh_t structure
140  *---------------------------------------------------------------------------*/
141 
142 void
143 cs_join_inter_set_dump(FILE *f,
144  const cs_join_inter_set_t *i_set,
145  const cs_join_edges_t *edges,
146  const cs_join_mesh_t *mesh);
147 
148 /*----------------------------------------------------------------------------
149  * Allocate and initialize a new cs_join_inter_edges_t structure.
150  *
151  * parameters:
152  * n_edges <-- number of edges
153  *
154  * returns:
155  * a pointer to the created cs_join_inter_edges_t structure.
156  *---------------------------------------------------------------------------*/
157 
160 
161 /*----------------------------------------------------------------------------
162  * Build a cs_join_inter_edges_t structure (useful to find equivalence on
163  * edges and to apply vertex merge to a cs_join_mesh_t structure).
164  *
165  * parameters:
166  * edges <-- cs_join_edges_t structure
167  * inter_set <-- structure storing data on edge intersections
168  *
169  * returns:
170  * a pointer to the created cs_join_inter_edges_t structure
171  *---------------------------------------------------------------------------*/
172 
175  const cs_join_inter_set_t *inter_set);
176 
177 /*----------------------------------------------------------------------------
178  * Destroy an cs_join_inter_edges_t structure.
179  *
180  * parameters:
181  * inter_edges <-> pointer to cs_join_inter_edges_t structure to destroy
182  *---------------------------------------------------------------------------*/
183 
184 void
186 
187 /*----------------------------------------------------------------------------
188  * Find non-trivial equivalences between vertices sharing the same edges.
189  *
190  * For instance an equivalence between a vertex from the extremity of an edge
191  * and a vertex created by an edge-edge intersection.
192  *
193  * parameters:
194  * param <-- set of user-defined parameter
195  * mesh <-- pointer to the local cs_join_mesh_t structure
196  * which has initial vertex data
197  * edges <-- list of edges
198  * inter_edges <-- structure including data on edge intersections
199  * vtx_equiv <-> structure dealing with vertex equivalences
200  *---------------------------------------------------------------------------*/
201 
202 void
205  const cs_join_edges_t *edges,
206  const cs_join_inter_edges_t *inter_edges,
207  cs_join_eset_t *vtx_equiv);
208 
209 #if defined(HAVE_MPI)
210 
211 /*----------------------------------------------------------------------------
212  * Synchronize the definition of intersections on each edge by block.
213  *
214  * parameters:
215  * edges <-- cs_join_edges_t structure
216  * mesh <-- cs_join_mesh_t structure
217  * part <-- structure storing data on edge intersections by partition
218  *
219  * returns:
220  * newly allocated cs_join_inter_edges_t, synchronized and defined on
221  * a block
222  *---------------------------------------------------------------------------*/
223 
225 cs_join_inter_edges_part_to_block(const cs_join_mesh_t *mesh,
226  const cs_join_edges_t *edges,
227  const cs_join_inter_edges_t *part);
228 
229 /*----------------------------------------------------------------------------
230  * Synchronize the definition of intersections on each edge from a
231  * cs_join_inter_edges_t structure defined on a block.
232  *
233  * parameters:
234  * n_g_egdes <-- global number of edges
235  * block <-- synchronized cs_join_inter_edges_t struct. by block
236  * part <-> cs_join_inter_edges_t to synchronized on partition
237  *---------------------------------------------------------------------------*/
238 
239 void
240 cs_join_inter_edges_block_to_part(cs_gnum_t n_g_edges,
241  const cs_join_inter_edges_t *block,
242  cs_join_inter_edges_t *part);
243 
244 #endif /* HAVE_MPI */
245 
246 /*----------------------------------------------------------------------------
247  * Redefine a cs_join_inter_edges_t structure to be consistent with the local
248  * numbering of a given couple of cs_join_mesh_t structure and
249  * cs_join_edges_t structure.
250  * Add future new vertices for the face definition in cs_join_mesh_t
251  *
252  * parameters:
253  * verbosity <-- verbosity level
254  * edges <-- cs_join_edges_t structure
255  * mesh <-> cs_join_mesh_t structure
256  * inter_edges <-> current cs_join_inter_edges_t struct. to work with
257  *---------------------------------------------------------------------------*/
258 
259 void
260 cs_join_intersect_update_struct(int verbosity,
261  const cs_join_edges_t *edges,
263  cs_join_inter_edges_t **inter_edges);
264 
265 /*----------------------------------------------------------------------------
266  * Get all real edges intersections among possible edges intersections.
267  *
268  * parameters:
269  * param <-- set of user-defined parameters for the joining
270  * edge_edge_vis <-- a pointer to a cs_join_gset_t structure
271  * edges <-- pointer to a structure defining edges
272  * mesh <-- pointer to the cs_join_mesh_t structure
273  * which has the face connectivity
274  * inter_set <-> pointer to a structure including data on edge
275  * intersections
276  * vtx_eset <-> pointer to a structure dealing with vertex
277  * equivalences
278  *
279  * returns:
280  * the type of joining encountered (conforming or not)
281  *---------------------------------------------------------------------------*/
282 
285  const cs_join_gset_t *edge_edge_vis,
286  const cs_join_edges_t *edges,
287  const cs_join_mesh_t *mesh,
288  cs_join_eset_t **vtx_eset,
289  cs_join_inter_set_t **inter_set);
290 
291 /*----------------------------------------------------------------------------
292  * Build a tree structure on which we associate leaves and face bounding boxes.
293  * Create a cs_join_gset_t structure (indexed list on global numbering)
294  * storing potential intersections between face bounding boxes.
295  *
296  * parameters:
297  * param <-- set of user-defined parameter
298  * mesh <-- cs_join_mesh_t structure where faces are defined
299  *
300  * returns:
301  * a new allocated pointer to a cs_join_gset_t structure storing the
302  * face - face visibility.
303  *---------------------------------------------------------------------------*/
304 
307  const cs_join_mesh_t *mesh);
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 
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__ */
Definition: cs_join_set.h:50
cs_int_t vtx_id
Definition: cs_join_intersect.h:65
cs_int_t n_inter
Definition: cs_join_intersect.h:76
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:3630
cs_join_inter_set_t * cs_join_inter_set_create(cs_int_t init_size)
Definition: cs_join_intersect.c:2329
float curv_abs
Definition: cs_join_intersect.h:66
cs_join_type_t
Definition: cs_join_util.h:62
cs_gnum_t * vtx_glst
Definition: cs_join_intersect.h:98
cs_int_t n_max_inter
Definition: cs_join_intersect.h:75
#define BEGIN_C_DECLS
Definition: cs_defs.h:365
Definition: cs_join_mesh.h:80
cs_join_inter_t * inter_lst
Definition: cs_join_intersect.h:78
cs_gnum_t * edge_gnum
Definition: cs_join_intersect.h:91
Definition: cs_join_intersect.h:62
cs_int_t edge_id
Definition: cs_join_intersect.h:64
int cs_int_t
Definition: cs_defs.h:263
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:3424
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:2656
Definition: cs_join_intersect.h:73
void cs_join_inter_edges_destroy(cs_join_inter_edges_t **inter_edges)
Definition: cs_join_intersect.c:2625
void cs_join_inter_set_destroy(cs_join_inter_set_t **inter_set)
Definition: cs_join_intersect.c:2351
cs_int_t * index
Definition: cs_join_intersect.h:92
Definition: mesh.f90:25
cs_int_t n_edges
Definition: cs_join_intersect.h:89
cs_int_t max_sub_size
Definition: cs_join_intersect.h:101
Definition: cs_join_mesh.h:111
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:2372
Definition: cs_join_set.h:75
unsigned cs_gnum_t
Definition: cs_defs.h:255
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:3958
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:4164
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:2470
cs_int_t * vtx_lst
Definition: cs_join_intersect.h:97
#define END_C_DECLS
Definition: cs_defs.h:366
float * abs_lst
Definition: cs_join_intersect.h:99
Definition: cs_join_intersect.h:87
cs_join_gset_t * cs_join_intersect_faces(const cs_join_param_t param, const cs_join_mesh_t *mesh)
Definition: cs_join_intersect.c:3854
cs_join_inter_edges_t * cs_join_inter_edges_create(cs_int_t n_edges)
Definition: cs_join_intersect.c:2423
Definition: cs_join_util.h:86