Code_Saturne
CFD tool
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
fvm_io_num.h
Go to the documentation of this file.
1 #ifndef __FVM_IO_NUM_H__
2 #define __FVM_IO_NUM_H__
3 
4 /*============================================================================
5  * Main structure for an I/O numbering scheme associated with mesh entities
6  * (such as cells, faces, and vertices);
7  *
8  * In parallel mode, such a scheme is important so as to redistribute
9  * locally numbered entities on n processes to files written by p
10  * processes, with p <= n.
11  *
12  * Only the case where p = 1 is presently implemented, so the numbering
13  * scheme is simply based on entity's global labels.
14  *
15  * For p > 1, it would probably be necessary to extend the numbering
16  * schemes so as to account for the fact that a given entity may have
17  * a main index on its main associated domain, but may be present
18  * as a ghost entity with another index on neighboring domains.
19  *============================================================================*/
20 
21 /*
22  This file is part of Code_Saturne, a general-purpose CFD tool.
23 
24  Copyright (C) 1998-2012 EDF S.A.
25 
26  This program is free software; you can redistribute it and/or modify it under
27  the terms of the GNU General Public License as published by the Free Software
28  Foundation; either version 2 of the License, or (at your option) any later
29  version.
30 
31  This program is distributed in the hope that it will be useful, but WITHOUT
32  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
33  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
34  details.
35 
36  You should have received a copy of the GNU General Public License along with
37  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
38  Street, Fifth Floor, Boston, MA 02110-1301, USA.
39 */
40 
41 /*----------------------------------------------------------------------------*/
42 
43 /*----------------------------------------------------------------------------
44  * Local headers
45  *----------------------------------------------------------------------------*/
46 
47 #include "fvm_defs.h"
48 
49 /*----------------------------------------------------------------------------*/
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #if 0
54 } /* Fake brace to force back Emacs auto-indentation back to column 0 */
55 #endif
56 #endif /* __cplusplus */
57 
58 /*=============================================================================
59  * Macro definitions
60  *============================================================================*/
61 
62 /*============================================================================
63  * Type definitions
64  *============================================================================*/
65 
66 /*----------------------------------------------------------------------------
67  * Structure defining an I/O numbering scheme
68  *----------------------------------------------------------------------------*/
69 
70 /*
71  Pointer to an I/O numbering scheme structure. The structure
72  itself is private, and is defined in fvm_io_num.c
73 */
74 
75 typedef struct _fvm_io_num_t fvm_io_num_t;
76 
77 /* Space-filling curve types */
78 
79 typedef enum {
80 
81  FVM_IO_NUM_SFC_MORTON_BOX, /* Morton (Z) curve in bounding box */
82  FVM_IO_NUM_SFC_MORTON_CUBE, /* Morton (Z) curve in bounding cube */
83  FVM_IO_NUM_SFC_HILBERT_BOX, /* Peano-Hilbert curve in bounding box */
84  FVM_IO_NUM_SFC_HILBERT_CUBE, /* Peano-Hilbert curve in bounding cube */
85 
87 
88 /*=============================================================================
89  * Static global variables
90  *============================================================================*/
91 
92 /* Names of space-filling curve types */
93 
94 extern const char *fvm_io_num_sfc_type_name[];
95 
96 /*=============================================================================
97  * Public function prototypes
98  *============================================================================*/
99 
100 /*----------------------------------------------------------------------------
101  * Creation of an I/O numbering structure.
102  *
103  * parameters:
104  * parent_entity_number <-- pointer to list of selected entitie's parent's
105  * numbers, or NULL if all first nb_ent entities
106  * are used
107  * parent_global_number <-- pointer to list of global (i.e. domain splitting
108  * independent) parent entity numbers
109  * n_entities <-- number of entities considered
110  * share_parent_global <-- if non zero, try to share parent_global_number
111  * instead of using a local copy
112  *
113  * returns:
114  * pointer to I/O numbering structure
115  *----------------------------------------------------------------------------*/
116 
117 fvm_io_num_t *
118 fvm_io_num_create(const cs_lnum_t parent_entity_number[],
119  const cs_gnum_t parent_global_number[],
120  const size_t n_entities,
121  const int share_parent_global);
122 
123 /*----------------------------------------------------------------------------
124  * Creation of an I/O numbering structure,
125  * sharing a given global numbering array.
126  *
127  * The corresponding entities must be locally ordered.
128  *
129  * parameters:
130  * global_number <-- pointer to list of global (i.e. domain splitting
131  * independent) entity numbers
132  * global_count <-- global number of entities
133  * n_entities <-- number of local entities considered
134  *
135  * returns:
136  * pointer to I/O numbering structure
137  *----------------------------------------------------------------------------*/
138 
139 fvm_io_num_t *
140 fvm_io_num_create_shared(const cs_gnum_t global_number[],
142  size_t n_entities);
143 
144 /*----------------------------------------------------------------------------
145  * Creation of an I/O numbering structure based on an an initial
146  * I/O numbering and a number of new entities per base entity.
147  *
148  * This is useful for example to create an I/O numbering for
149  * triangles based on split polygons, whose I/O numbering is defined.
150  *
151  * parameters:
152  * base_io_num <-- pointer to base I/O numbering structure
153  * n_sub_entities <-- number of new entities per base entity
154  *
155  * returns:
156  * pointer to I/O numbering structure
157  *----------------------------------------------------------------------------*/
158 
159 fvm_io_num_t *
160 fvm_io_num_create_from_sub(const fvm_io_num_t *base_io_num,
161  const cs_lnum_t n_sub_entities[]);
162 
163 /*----------------------------------------------------------------------------
164  * Creation of an I/O numbering structure based on a strided adjacency.
165  *
166  * The corresponding entities must be locally ordered.
167  *
168  * parameters:
169  * parent_entity_number <-- pointer to list of selected entitie's parent's
170  * numbers, or NULL if all first n_ent entities
171  * are used
172  * adjacency <-- entity adjacency (1 to n global numbering)
173  * n_entities <-- number of entities considered
174  * stride <-- values per entity
175  *
176  * returns:
177  * pointer to I/O numbering structure
178  *----------------------------------------------------------------------------*/
179 
180 fvm_io_num_t *
181 fvm_io_num_create_from_adj_s(const cs_lnum_t parent_entity_number[],
182  const cs_gnum_t adjacency[],
183  size_t n_entities,
184  size_t stride);
185 
186 /*----------------------------------------------------------------------------
187  * Creation of an I/O numbering structure based on an indexed adjacency.
188  *
189  * The corresponding entities do not need to be locally ordered.
190  *
191  * parameters:
192  * parent_entity_number <-- pointer to list of selected entitie's parent's
193  * numbers, or NULL if all first n_ent entities
194  * are used
195  * index <-- index on entities for adjacency
196  * adjacency <-- entity adjacency (1 to n global numbering)
197  * n_entities <-- number of entities considered
198  *
199  * returns:
200  * pointer to I/O numbering structure
201  *----------------------------------------------------------------------------*/
202 
203 fvm_io_num_t *
204 fvm_io_num_create_from_adj_i(const cs_lnum_t parent_entity_number[],
205  const cs_lnum_t index[],
206  const cs_gnum_t adjacency[],
207  cs_lnum_t n_entities);
208 
209 /*----------------------------------------------------------------------------
210  * Creation of an I/O numbering structure based on a space-filling curve.
211  *
212  * It is expected that entities are unique (i.e. not duplicated on 2 or
213  * more ranks). If 2 entities have a same Morton codeor Hilbert, their global
214  * number will be determined by lexicographical ordering of coordinates.
215  *
216  * parameters:
217  * coords <-- pointer to entity coordinates (interlaced)
218  * dim <-- spatial dimension
219  * n_entities <-- number of entities considered
220  * sfc_type <-- type of space-filling curve (Morton or Hilbert)
221  *
222  * returns:
223  * pointer to I/O numbering structure
224  *----------------------------------------------------------------------------*/
225 
226 fvm_io_num_t *
228  int dim,
229  size_t n_entities,
230  fvm_io_num_sfc_t sfc_type);
231 
232 /*----------------------------------------------------------------------------
233  * Creation of an I/O numbering structure based on a simple accumulation
234  * (i.e. scan) of counts on successive ranks.
235  *
236  * parameters:
237  * n_entities <-- number of entities considered
238  *
239  * returns:
240  * pointer to I/O numbering structure
241  *----------------------------------------------------------------------------*/
242 
243 fvm_io_num_t *
244 fvm_io_num_create_from_scan(size_t n_entities);
245 
246 /*----------------------------------------------------------------------------
247  * Destruction of a I/O numbering structure.
248  *
249  * parameters:
250  * this_io_num <-- pointer to structure that should be destroyed
251  *
252  * returns:
253  * NULL pointer
254  *----------------------------------------------------------------------------*/
255 
256 fvm_io_num_t *
257 fvm_io_num_destroy(fvm_io_num_t * this_io_num);
258 
259 /*----------------------------------------------------------------------------
260  * Return local number of entities associated with an I/O numbering
261  * structure.
262  *
263  * parameters:
264  * this_io_num <-- pointer to I/O/ numbering structure
265  *
266  * returns:
267  * local number of associated entities
268  *----------------------------------------------------------------------------*/
269 
270 cs_lnum_t
271 fvm_io_num_get_local_count(const fvm_io_num_t *const this_io_num);
272 
273 /*----------------------------------------------------------------------------
274  * Return global number of entities associated with an I/O numbering
275  * structure.
276  *
277  * parameters:
278  * this_io_num <-- pointer to I/O/ numbering structure
279  *
280  * returns:
281  * global number of associated entities
282  *----------------------------------------------------------------------------*/
283 
284 cs_gnum_t
285 fvm_io_num_get_global_count(const fvm_io_num_t *const this_io_num);
286 
287 /*----------------------------------------------------------------------------
288  * Return global numbering associated with an I/O numbering structure.
289  *
290  * parameters:
291  * this_io_num <-- pointer to I/O/ numbering structure
292  *
293  * returns:
294  * pointer to array of global numbers associated with local entities
295  * (1 to n numbering)
296  *----------------------------------------------------------------------------*/
297 
298 const cs_gnum_t *
299 fvm_io_num_get_global_num(const fvm_io_num_t *const this_io_num);
300 
301 /*----------------------------------------------------------------------------
302  * Return the global number of sub-entities associated with an initial
303  * entity whose global numbering is known, given the number of
304  * sub-entities per initial entity.
305  *
306  * parameters:
307  * this_io_num <-- pointer to base io numbering
308  * n_sub_entities <-- number of sub-entities per initial entity
309  * comm <-- associated MPI communicator
310  *
311  * returns:
312  * global number of sub-entities
313  *----------------------------------------------------------------------------*/
314 
315 cs_gnum_t
316 fvm_io_num_global_sub_size(const fvm_io_num_t *this_io_num,
317  const cs_lnum_t n_sub_entities[]);
318 
319 /*----------------------------------------------------------------------------
320  * Dump printout of a I/O numbering structure.
321  *
322  * parameters:
323  * this_io_num <-- pointer to structure that should be dumped
324  *----------------------------------------------------------------------------*/
325 
326 void
327 fvm_io_num_dump(const fvm_io_num_t *const this_io_num);
328 
329 /*----------------------------------------------------------------------------*/
330 
331 #ifdef __cplusplus
332 }
333 #endif /* __cplusplus */
334 
335 #endif /* __FVM_IO_NUM_H__ */
fvm_io_num_t * fvm_io_num_create_from_scan(size_t n_entities)
Definition: fvm_io_num.c:2374
cs_gnum_t fvm_io_num_global_sub_size(const fvm_io_num_t *this_io_num, const cs_lnum_t n_sub_entities[])
Definition: fvm_io_num.c:2512
Definition: fvm_io_num.c:120
fvm_io_num_t * fvm_io_num_create_from_adj_i(const cs_lnum_t parent_entity_number[], const cs_lnum_t index[], const cs_gnum_t adjacency[], cs_lnum_t n_entities)
Definition: fvm_io_num.c:2201
cs_gnum_t fvm_io_num_get_global_count(const fvm_io_num_t *const this_io_num)
Definition: fvm_io_num.c:2471
fvm_io_num_sfc_t
Definition: fvm_io_num.h:79
double cs_coord_t
Definition: cs_defs.h:261
void fvm_io_num_dump(const fvm_io_num_t *const this_io_num)
Definition: fvm_io_num.c:2554
fvm_io_num_t * fvm_io_num_create_shared(const cs_gnum_t global_number[], cs_gnum_t global_count, size_t n_entities)
Definition: fvm_io_num.c:2018
int cs_lnum_t
Definition: cs_defs.h:260
fvm_io_num_t * fvm_io_num_destroy(fvm_io_num_t *this_io_num)
Definition: fvm_io_num.c:2430
const char * fvm_io_num_sfc_type_name[]
Definition: fvm_io_num.c:137
Definition: fvm_io_num.h:83
fvm_io_num_t * fvm_io_num_create_from_sfc(const cs_coord_t coords[], int dim, size_t n_entities, fvm_io_num_sfc_t sfc_type)
Definition: fvm_io_num.c:2335
unsigned cs_gnum_t
Definition: cs_defs.h:255
Definition: fvm_io_num.h:81
fvm_io_num_t * fvm_io_num_create_from_sub(const fvm_io_num_t *base_io_num, const cs_lnum_t n_sub_entities[])
Definition: fvm_io_num.c:2053
fvm_io_num_t * fvm_io_num_create_from_adj_s(const cs_lnum_t parent_entity_number[], const cs_gnum_t adjacency[], size_t n_entities, size_t stride)
Definition: fvm_io_num.c:2117
const cs_gnum_t * fvm_io_num_get_global_num(const fvm_io_num_t *const this_io_num)
Definition: fvm_io_num.c:2490
cs_lnum_t fvm_io_num_get_local_count(const fvm_io_num_t *const this_io_num)
Definition: fvm_io_num.c:2452
cs_gnum_t global_count
Definition: fvm_io_num.c:122
fvm_io_num_t * fvm_io_num_create(const cs_lnum_t parent_entity_number[], const cs_gnum_t parent_global_number[], const size_t n_entities, const int share_parent_global)
Definition: fvm_io_num.c:1918
Definition: fvm_io_num.h:84
Definition: fvm_io_num.h:82