~ubuntu-branches/ubuntu/precise/code-saturne/precise

« back to all changes in this revision

Viewing changes to src/fvm/fvm_io_num.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-24 00:00:08 UTC
  • mfrom: (6.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20111124000008-2vo99e38267942q5
Tags: 2.1.0-3
Install a missing file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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-2011 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
 
 
86
} fvm_io_num_sfc_t;
 
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
 * The corresponding entities must be locally ordered.
 
104
 *
 
105
 * parameters:
 
106
 *   parent_entity_number <-- pointer to list of selected entitie's parent's
 
107
 *                            numbers, or NULL if all first nb_ent entities
 
108
 *                            are used
 
109
 *   parent_global_number <-- pointer to list of global (i.e. domain splitting
 
110
 *                            independent) parent entity numbers
 
111
 *   n_entities           <-- number of entities considered
 
112
 *   share_parent_global  <-- if non zero, try to share parent_global_number
 
113
 *                            instead of using a local copy
 
114
 *
 
115
 * returns:
 
116
 *  pointer to I/O numbering structure
 
117
 *----------------------------------------------------------------------------*/
 
118
 
 
119
fvm_io_num_t *
 
120
fvm_io_num_create(const fvm_lnum_t  parent_entity_number[],
 
121
                  const fvm_gnum_t  parent_global_number[],
 
122
                  const size_t      n_entities,
 
123
                  const int         share_parent_global);
 
124
 
 
125
/*----------------------------------------------------------------------------
 
126
 * Creation of an I/O numbering structure,
 
127
 * sharing a given global numbering array.
 
128
 *
 
129
 * The corresponding entities must be locally ordered.
 
130
 *
 
131
 * parameters:
 
132
 *   global_number <-- pointer to list of global (i.e. domain splitting
 
133
 *                     independent) entity numbers
 
134
 *   global_count  <-- global number of entities
 
135
 *   n_entities    <-- number of local entities considered
 
136
 *
 
137
 * returns:
 
138
 *  pointer to I/O numbering structure
 
139
 *----------------------------------------------------------------------------*/
 
140
 
 
141
fvm_io_num_t *
 
142
fvm_io_num_create_shared(const fvm_gnum_t  global_number[],
 
143
                         fvm_gnum_t        global_count,
 
144
                         size_t            n_entities);
 
145
 
 
146
/*----------------------------------------------------------------------------
 
147
 * Creation of an I/O numbering structure based on an an initial
 
148
 * I/O numbering and a number of new entities per base entity.
 
149
 *
 
150
 * This is useful for example to create an I/O numbering for
 
151
 * triangles based on split polygons, whose I/O numbering is defined.
 
152
 *
 
153
 * parameters:
 
154
 *   base_io_num    <-- pointer to base I/O numbering structure
 
155
 *   n_sub_entities <-- number of new entities per base entity
 
156
 *
 
157
 * returns:
 
158
 *  pointer to I/O numbering structure
 
159
 *----------------------------------------------------------------------------*/
 
160
 
 
161
fvm_io_num_t *
 
162
fvm_io_num_create_from_sub(const fvm_io_num_t  *base_io_num,
 
163
                           const fvm_lnum_t     n_sub_entities[]);
 
164
 
 
165
/*----------------------------------------------------------------------------
 
166
 * Creation of an I/O numbering structure based on a strided adjacency.
 
167
 *
 
168
 * The corresponding entities must be locally ordered.
 
169
 *
 
170
 * parameters:
 
171
 *   parent_entity_number <-- pointer to list of selected entitie's parent's
 
172
 *                            numbers, or NULL if all first n_ent entities
 
173
 *                            are used
 
174
 *   adjacency            <-- entity adjacency (1 to n global numbering)
 
175
 *   n_entities           <-- number of entities considered
 
176
 *   stride               <-- values per entity
 
177
 *
 
178
 * returns:
 
179
 *  pointer to I/O numbering structure
 
180
 *----------------------------------------------------------------------------*/
 
181
 
 
182
fvm_io_num_t *
 
183
fvm_io_num_create_from_adj_s(const fvm_lnum_t  parent_entity_number[],
 
184
                             const fvm_gnum_t  adjacency[],
 
185
                             size_t            n_entities,
 
186
                             size_t            stride);
 
187
 
 
188
/*----------------------------------------------------------------------------
 
189
 * Creation of an I/O numbering structure based on an indexed adjacency.
 
190
 *
 
191
 * The corresponding entities do not need to be locally ordered.
 
192
 *
 
193
 * parameters:
 
194
 *  parent_entity_number <-- pointer to list of selected entitie's parent's
 
195
 *                           numbers, or NULL if all first n_ent entities
 
196
 *                           are used
 
197
 *  index                <-- index on entities for adjacency
 
198
 *  adjacency            <-- entity adjacency (1 to n global numbering)
 
199
 *  n_entities           <-- number of entities considered
 
200
 *
 
201
 * returns:
 
202
 *  pointer to I/O numbering structure
 
203
 *----------------------------------------------------------------------------*/
 
204
 
 
205
fvm_io_num_t *
 
206
fvm_io_num_create_from_adj_i(const fvm_lnum_t  parent_entity_number[],
 
207
                             const fvm_lnum_t  index[],
 
208
                             const fvm_gnum_t  adjacency[],
 
209
                             fvm_lnum_t        n_entities);
 
210
 
 
211
/*----------------------------------------------------------------------------
 
212
 * Creation of an I/O numbering structure based on a space-filling curve.
 
213
 *
 
214
 * It is expected that entities are unique (i.e. not duplicated on 2 or
 
215
 * more ranks). If 2 entities have a same Morton codeor Hilbert, their global
 
216
 * number will be determined by lexicographical ordering of coordinates.
 
217
 *
 
218
 * parameters:
 
219
 *   coords     <-- pointer to entity coordinates (interlaced)
 
220
 *   dim        <-- spatial dimension
 
221
 *   n_entities <-- number of entities considered
 
222
 *   sfc_type   <-- type of space-filling curve (Morton or Hilbert)
 
223
 *
 
224
 * returns:
 
225
 *  pointer to I/O numbering structure
 
226
 *----------------------------------------------------------------------------*/
 
227
 
 
228
fvm_io_num_t *
 
229
fvm_io_num_create_from_sfc(const fvm_coord_t  coords[],
 
230
                           int                dim,
 
231
                           size_t             n_entities,
 
232
                           fvm_io_num_sfc_t   sfc_type);
 
233
 
 
234
/*----------------------------------------------------------------------------
 
235
 * Creation of an I/O numbering structure based on a simple accumulation
 
236
 * (i.e. scan) of counts on successive ranks.
 
237
 *
 
238
 * parameters:
 
239
 *   n_entities <-- number of entities considered
 
240
 *
 
241
 * returns:
 
242
 *  pointer to I/O numbering structure
 
243
 *----------------------------------------------------------------------------*/
 
244
 
 
245
fvm_io_num_t *
 
246
fvm_io_num_create_from_scan(size_t  n_entities);
 
247
 
 
248
/*----------------------------------------------------------------------------
 
249
 * Destruction of a I/O numbering structure.
 
250
 *
 
251
 * parameters:
 
252
 *   this_io_num <-- pointer to structure that should be destroyed
 
253
 *
 
254
 * returns:
 
255
 *   NULL pointer
 
256
 *----------------------------------------------------------------------------*/
 
257
 
 
258
fvm_io_num_t *
 
259
fvm_io_num_destroy(fvm_io_num_t  * this_io_num);
 
260
 
 
261
/*----------------------------------------------------------------------------
 
262
 * Return local number of entities associated with an I/O numbering
 
263
 * structure.
 
264
 *
 
265
 * parameters:
 
266
 *   this_io_num <-- pointer to I/O/ numbering structure
 
267
 *
 
268
 * returns:
 
269
 *  local number of associated entities
 
270
 *----------------------------------------------------------------------------*/
 
271
 
 
272
fvm_lnum_t
 
273
fvm_io_num_get_local_count(const fvm_io_num_t  *const this_io_num);
 
274
 
 
275
/*----------------------------------------------------------------------------
 
276
 * Return global number of entities associated with an I/O numbering
 
277
 * structure.
 
278
 *
 
279
 * parameters:
 
280
 *   this_io_num <-- pointer to I/O/ numbering structure
 
281
 *
 
282
 * returns:
 
283
 *  global number of associated entities
 
284
 *----------------------------------------------------------------------------*/
 
285
 
 
286
fvm_gnum_t
 
287
fvm_io_num_get_global_count(const fvm_io_num_t  *const this_io_num);
 
288
 
 
289
/*----------------------------------------------------------------------------
 
290
 * Return global numbering associated with an I/O numbering structure.
 
291
 *
 
292
 * parameters:
 
293
 *   this_io_num <-- pointer to I/O/ numbering structure
 
294
 *
 
295
 * returns:
 
296
 *  pointer to array of global numbers associated with local entities
 
297
 *  (1 to n numbering)
 
298
 *----------------------------------------------------------------------------*/
 
299
 
 
300
const fvm_gnum_t *
 
301
fvm_io_num_get_global_num(const fvm_io_num_t  *const this_io_num);
 
302
 
 
303
/*----------------------------------------------------------------------------
 
304
 * Return the global number of sub-entities associated with an initial
 
305
 * entity whose global numbering is known, given the number of
 
306
 * sub-entities per initial entity.
 
307
 *
 
308
 * parameters:
 
309
 *   this_io_num    <-- pointer to base io numbering
 
310
 *   n_sub_entities <-- number of sub-entities per initial entity
 
311
 *   comm           <-- associated MPI communicator
 
312
 *
 
313
 * returns:
 
314
 *   global number of sub-entities
 
315
 *----------------------------------------------------------------------------*/
 
316
 
 
317
fvm_gnum_t
 
318
fvm_io_num_global_sub_size(const fvm_io_num_t  *this_io_num,
 
319
                           const fvm_lnum_t     n_sub_entities[]);
 
320
 
 
321
/*----------------------------------------------------------------------------
 
322
 * Dump printout of a I/O numbering structure.
 
323
 *
 
324
 * parameters:
 
325
 *   this_io_num <-- pointer to structure that should be dumped
 
326
 *----------------------------------------------------------------------------*/
 
327
 
 
328
void
 
329
fvm_io_num_dump(const fvm_io_num_t  *const this_io_num);
 
330
 
 
331
/*----------------------------------------------------------------------------*/
 
332
 
 
333
#ifdef __cplusplus
 
334
}
 
335
#endif /* __cplusplus */
 
336
 
 
337
#endif /* __FVM_IO_NUM_H__ */