9.2
general documentation
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-2026 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#include "base/cs_defs.h"
44
45/*----------------------------------------------------------------------------
46 * Local headers
47 *----------------------------------------------------------------------------*/
48
49#include "fvm/fvm_defs.h"
50
51/*----------------------------------------------------------------------------*/
52
54
55/*=============================================================================
56 * Macro definitions
57 *============================================================================*/
58
59/*============================================================================
60 * Type definitions
61 *============================================================================*/
62
63/*----------------------------------------------------------------------------
64 * Structure defining an I/O numbering scheme
65 *----------------------------------------------------------------------------*/
66
67/*
68 Pointer to an I/O numbering scheme structure. The structure
69 itself is private, and is defined in fvm_io_num.c
70*/
71
72typedef struct _fvm_io_num_t fvm_io_num_t;
73
74/* Space-filling curve types */
75
76typedef enum {
77
78 FVM_IO_NUM_SFC_MORTON_BOX, /* Morton (Z) curve in bounding box */
79 FVM_IO_NUM_SFC_MORTON_CUBE, /* Morton (Z) curve in bounding cube */
80 FVM_IO_NUM_SFC_HILBERT_BOX, /* Peano-Hilbert curve in bounding box */
81 FVM_IO_NUM_SFC_HILBERT_CUBE, /* Peano-Hilbert curve in bounding cube */
82
84
85/*=============================================================================
86 * Static global variables
87 *============================================================================*/
88
89/* Names of space-filling curve types */
90
91extern const char *fvm_io_num_sfc_type_name[];
92
93/*=============================================================================
94 * Public function prototypes
95 *============================================================================*/
96
97/*----------------------------------------------------------------------------
98 * Creation of an I/O numbering structure.
99 *
100 * This function is similar to fvm_io_num_create_from_select, albeit
101 * using parent entity numbers (1 to n) instead of ids (0 to n-1).
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
118fvm_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
122/*----------------------------------------------------------------------------
123 * Creation of an I/O numbering structure based on a selection of entities.
124 *
125 * parameters:
126 * parent_entity_id <-- pointer to list of selected entitie's parent's
127 * ids, or NULL if all first n_ent entities
128 * are used
129 * parent_global_number <-- pointer to list of global (i.e. domain splitting
130 * independent) parent entity numbers
131 * n_entities <-- number of entities considered
132 *
133 * returns:
134 * pointer to I/O numbering structure
135 *----------------------------------------------------------------------------*/
136
138fvm_io_num_create_from_select(const cs_lnum_t parent_entity_id[],
139 const cs_gnum_t parent_global_number[],
140 size_t n_entities);
141
142/*----------------------------------------------------------------------------
143 * Creation of an I/O numbering structure,
144 * sharing a given global numbering array.
145 *
146 * parameters:
147 * global_number <-- pointer to list of global (i.e. domain splitting
148 * independent) entity numbers
149 * global_count <-- global number of entities
150 * n_entities <-- number of local entities considered
151 *
152 * returns:
153 * pointer to I/O numbering structure
154 *----------------------------------------------------------------------------*/
155
157fvm_io_num_create_shared(const cs_gnum_t global_number[],
158 cs_gnum_t global_count,
159 size_t n_entities);
160
161/*----------------------------------------------------------------------------
162 * Creation of an I/O numbering structure based on an an initial
163 * I/O numbering and a number of new entities per base entity.
164 *
165 * This is useful for example to create an I/O numbering for
166 * triangles based on split polygons, whose I/O numbering is defined.
167 *
168 * parameters:
169 * base_io_num <-- pointer to base I/O numbering structure
170 * n_sub_entities <-- number of new entities per base entity
171 *
172 * returns:
173 * pointer to I/O numbering structure
174 *----------------------------------------------------------------------------*/
175
178 const cs_lnum_t n_sub_entities[]);
179
180/*----------------------------------------------------------------------------
181 * Creation of an I/O numbering structure based on a strided adjacency.
182 *
183 * parameters:
184 * parent_entity_id <-- pointer to list of selected entitie's parent's ids,
185 * or NULL if all first n_ent entities are used
186 * adjacency <-- entity adjacency (1 to n global numbering)
187 * n_entities <-- number of entities considered
188 * stride <-- values per entity
189 *
190 * returns:
191 * pointer to I/O numbering structure
192 *----------------------------------------------------------------------------*/
193
195fvm_io_num_create_from_adj_s(const cs_lnum_t parent_entity_id[],
196 const cs_gnum_t adjacency[],
197 size_t n_entities,
198 size_t stride);
199
200/*----------------------------------------------------------------------------
201 * Creation of an I/O numbering structure based on an indexed adjacency.
202 *
203 * The corresponding entities do not need to be locally ordered.
204 *
205 * parameters:
206 * parent_entity_id <-- pointer to list of selected entitie's parent's ids,
207 * or NULL if all first n_ent entities are used
208 * index <-- index on entities for adjacency
209 * adjacency <-- entity adjacency (1 to n global numbering)
210 * n_entities <-- number of entities considered
211 *
212 * returns:
213 * pointer to I/O numbering structure
214 *----------------------------------------------------------------------------*/
215
217fvm_io_num_create_from_adj_i(const cs_lnum_t parent_entity_id[],
218 const cs_lnum_t index[],
219 const cs_gnum_t adjacency[],
220 cs_lnum_t n_entities);
221
222/*----------------------------------------------------------------------------
223 * Creation of an I/O numbering structure based on a space-filling curve.
224 *
225 * It is expected that entities are unique (i.e. not duplicated on 2 or
226 * more ranks). If 2 entities have a same Morton codeor Hilbert, their global
227 * number will be determined by lexicographical ordering of coordinates.
228 *
229 * parameters:
230 * coords <-- pointer to entity coordinates (interlaced)
231 * dim <-- spatial dimension
232 * n_entities <-- number of entities considered
233 * sfc_type <-- type of space-filling curve (Morton or Hilbert)
234 *
235 * returns:
236 * pointer to I/O numbering structure
237 *----------------------------------------------------------------------------*/
238
241 int dim,
242 size_t n_entities,
243 fvm_io_num_sfc_t sfc_type);
244
245/*----------------------------------------------------------------------------
246 * Creation of an I/O numbering structure based on real values, assuming
247 * ordering by increasing values.
248 *
249 * It is expected that entities are unique (i.e. not duplicated on 2 or
250 * more ranks). If 2 entities have a same value, their global
251 * number will be determined by their initial order.
252 *
253 * parameters:
254 * val <-- pointer to real values
255 * n_entities <-- number of entities considered
256 *
257 * returns:
258 * pointer to I/O numbering structure
259 *----------------------------------------------------------------------------*/
260
263 size_t n_entities);
264
265/*----------------------------------------------------------------------------
266 * Creation of an I/O numbering structure based on a simple accumulation
267 * (i.e. scan) of counts on successive ranks.
268 *
269 * parameters:
270 * n_entities <-- number of entities considered
271 *
272 * returns:
273 * pointer to I/O numbering structure
274 *----------------------------------------------------------------------------*/
275
277fvm_io_num_create_from_scan(size_t n_entities);
278
279/*----------------------------------------------------------------------------
280 * Destruction of a I/O numbering structure.
281 *
282 * parameters:
283 * this_io_num <-- pointer to structure that should be destroyed
284 *
285 * returns:
286 * null pointer
287 *----------------------------------------------------------------------------*/
288
290fvm_io_num_destroy(fvm_io_num_t * this_io_num);
291
292/*----------------------------------------------------------------------------
293 * Transfer ownership of global numbering array from IO numbering structure.
294 *
295 * parameters:
296 * this_io_num <-> pointer to structure transferring array ownership.
297 *
298 * returns:
299 * pointer to transferred array
300 *----------------------------------------------------------------------------*/
301
302cs_gnum_t *
304
305/*----------------------------------------------------------------------------
306 * Return local number of entities associated with an I/O numbering
307 * structure.
308 *
309 * parameters:
310 * this_io_num <-- pointer to I/O/ numbering structure
311 *
312 * returns:
313 * local number of associated entities
314 *----------------------------------------------------------------------------*/
315
317fvm_io_num_get_local_count(const fvm_io_num_t *const this_io_num);
318
319/*----------------------------------------------------------------------------
320 * Return global number of entities associated with an I/O numbering
321 * structure.
322 *
323 * parameters:
324 * this_io_num <-- pointer to I/O/ numbering structure
325 *
326 * returns:
327 * global number of associated entities
328 *----------------------------------------------------------------------------*/
329
331fvm_io_num_get_global_count(const fvm_io_num_t *const this_io_num);
332
333/*----------------------------------------------------------------------------
334 * Return global numbering associated with an I/O numbering structure.
335 *
336 * parameters:
337 * this_io_num <-- pointer to I/O/ numbering structure
338 *
339 * returns:
340 * pointer to array of global numbers associated with local entities
341 * (1 to n numbering)
342 *----------------------------------------------------------------------------*/
343
344const cs_gnum_t *
345fvm_io_num_get_global_num(const fvm_io_num_t *const this_io_num);
346
347/*----------------------------------------------------------------------------
348 * Return the global number of sub-entities associated with an initial
349 * entity whose global numbering is known, given the number of
350 * sub-entities per initial entity.
351 *
352 * parameters:
353 * this_io_num <-- pointer to base io numbering
354 * n_sub_entities <-- number of sub-entities per initial entity
355 * comm <-- associated MPI communicator
356 *
357 * returns:
358 * global number of sub-entities
359 *----------------------------------------------------------------------------*/
360
363 const cs_lnum_t n_sub_entities[]);
364
365/*----------------------------------------------------------------------------
366 * Dump printout of a I/O numbering structure.
367 *
368 * parameters:
369 * this_io_num <-- pointer to structure that should be dumped
370 *----------------------------------------------------------------------------*/
371
372void
373fvm_io_num_dump(const fvm_io_num_t *const this_io_num);
374
375/*----------------------------------------------------------------------------*/
376
378
379#endif /* FVM_IO_NUM_H */
#define BEGIN_C_DECLS
Definition: cs_defs.h:528
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
double cs_coord_t
Definition: cs_defs.h:330
unsigned cs_gnum_t
global mesh entity number
Definition: cs_defs.h:317
#define END_C_DECLS
Definition: cs_defs.h:529
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
fvm_io_num_t * fvm_io_num_create_from_adj_i(const cs_lnum_t parent_entity_id[], const cs_lnum_t index[], const cs_gnum_t adjacency[], cs_lnum_t n_entities)
Definition: fvm_io_num.cpp:2064
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.cpp:2198
fvm_io_num_t * fvm_io_num_create_from_scan(size_t n_entities)
Definition: fvm_io_num.cpp:2433
fvm_io_num_t * fvm_io_num_create_from_select(const cs_lnum_t parent_entity_id[], const cs_gnum_t parent_global_number[], size_t n_entities)
Definition: fvm_io_num.cpp:1793
const cs_gnum_t * fvm_io_num_get_global_num(const fvm_io_num_t *const this_io_num)
Definition: fvm_io_num.cpp:2573
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.cpp:1926
fvm_io_num_t * fvm_io_num_create_from_real(const cs_real_t val[], size_t n_entities)
Definition: fvm_io_num.cpp:2242
fvm_io_num_t * fvm_io_num_create_from_adj_s(const cs_lnum_t parent_entity_id[], const cs_gnum_t adjacency[], size_t n_entities, size_t stride)
Definition: fvm_io_num.cpp:1989
cs_lnum_t fvm_io_num_get_local_count(const fvm_io_num_t *const this_io_num)
Definition: fvm_io_num.cpp:2535
fvm_io_num_sfc_t
Definition: fvm_io_num.h:76
@ FVM_IO_NUM_SFC_HILBERT_BOX
Definition: fvm_io_num.h:80
@ FVM_IO_NUM_SFC_HILBERT_CUBE
Definition: fvm_io_num.h:81
@ FVM_IO_NUM_SFC_MORTON_BOX
Definition: fvm_io_num.h:78
@ FVM_IO_NUM_SFC_MORTON_CUBE
Definition: fvm_io_num.h:79
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)
Definition: fvm_io_num.cpp:1755
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.cpp:1891
struct _fvm_io_num_t fvm_io_num_t
Definition: fvm_io_num.h:72
const char * fvm_io_num_sfc_type_name[]
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.cpp:2595
void fvm_io_num_dump(const fvm_io_num_t *const this_io_num)
Definition: fvm_io_num.cpp:2640
cs_gnum_t * fvm_io_num_transfer_global_num(fvm_io_num_t *this_io_num)
Definition: fvm_io_num.cpp:2511
cs_gnum_t fvm_io_num_get_global_count(const fvm_io_num_t *const this_io_num)
Definition: fvm_io_num.cpp:2554
fvm_io_num_t * fvm_io_num_destroy(fvm_io_num_t *this_io_num)
Definition: fvm_io_num.cpp:2490