1
/*============================================================================
3
* This file is part of the Code_Saturne Kernel, element of the
4
* Code_Saturne CFD tool.
6
* Copyright (C) 2008-2009 EDF S.A., France
8
* contact: saturne-support@edf.fr
10
* The Code_Saturne Kernel is free software; you can redistribute it
11
* and/or modify it under the terms of the GNU General Public License
12
* as published by the Free Software Foundation; either version 2 of
13
* the License, or (at your option) any later version.
15
* The Code_Saturne Kernel is distributed in the hope that it will be
16
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with the Code_Saturne Kernel; if not, write to the
22
* Free Software Foundation, Inc.,
23
* 51 Franklin St, Fifth Floor,
24
* Boston, MA 02110-1301 USA
26
*============================================================================*/
28
/*============================================================================
29
* Subroutines useful to manage list structures
30
*===========================================================================*/
32
#ifndef __CS_JOIN_SET_H__
33
#define __CS_JOIN_SET_H__
35
/*----------------------------------------------------------------------------
36
* Standard C library headers
37
*---------------------------------------------------------------------------*/
41
/*----------------------------------------------------------------------------
43
*---------------------------------------------------------------------------*/
47
/*---------------------------------------------------------------------------*/
51
/*============================================================================
52
* Macro and type definitions
53
*===========================================================================*/
55
typedef struct { /* Definition of a global indexed list of global elements */
60
fvm_gnum_t *g_elts; /* Global numbering of elements */
62
cs_int_t *index; /* Index on elements from */
63
fvm_gnum_t *g_list; /* Global numbering of entities linked with g_elts */
67
typedef struct { /* Resizable array structure */
75
/* ------------------------------------------------------------------ *
76
* Definition of a structure defining a set of equivalence between
77
* vertices for instance
78
* ------------------------------------------------------------------ */
82
cs_int_t n_max_equiv; /* max. number of equiv. allocated */
83
cs_int_t n_equiv; /* number of equivalences */
84
cs_int_t *equiv_couple; /* ids of the two equivalent entities.
88
/*============================================================================
89
* Public function definitions
90
*===========================================================================*/
92
/*----------------------------------------------------------------------------
93
* Allocate a resizable array.
96
* max_size <-- initial number of elements to allocate
99
* pointer to a new alloacted resizable array
100
*---------------------------------------------------------------------------*/
103
cs_join_rset_create(cs_int_t max_size);
105
/*----------------------------------------------------------------------------
106
* Destroy a cs_join_rset_t structure.
109
* set <-- pointer to pointer to the cs_join_rset_t structure to destroy
110
*---------------------------------------------------------------------------*/
113
cs_join_rset_destroy(cs_join_rset_t **set);
115
/*----------------------------------------------------------------------------
116
* Check if we need to resize the current cs_join_rset_t structure and do
120
* set <-- pointer to pointer to the cs_join_rset_t structure to test
121
* test_size <-- target size
122
*---------------------------------------------------------------------------*/
125
cs_join_rset_resize(cs_join_rset_t **set,
128
/*----------------------------------------------------------------------------
129
* Create a new cs_join_eset_t structure.
132
* init_size <-- number of initial equivalences to allocate
135
* a pointer to a new cs_join_eset_t structure
136
*---------------------------------------------------------------------------*/
139
cs_join_eset_create(cs_int_t init_size);
141
/*----------------------------------------------------------------------------
142
* Check if the requested size if allocated in the structure.
144
* Reallocate cs_join_eset_t structure if necessary.
147
* request_size <-- necessary size
148
* equiv_set <-> pointer to pointer to the cs_join_eset_t struct.
149
*---------------------------------------------------------------------------*/
152
cs_join_eset_check_size(cs_int_t request_size,
153
cs_join_eset_t **equiv_set);
155
/*----------------------------------------------------------------------------
156
* Destroy a cs_join_eset_t structure.
159
* equiv_set <-- pointer to pointer to the structure to destroy
160
*---------------------------------------------------------------------------*/
163
cs_join_eset_destroy(cs_join_eset_t **equiv_set);
165
/*----------------------------------------------------------------------------
166
* Clean a cs_join_eset_t structure.
168
* If necessary, create a new cs_join_eset_t structure with no redundancy.
171
* eset <-- pointer to pointer to the cs_join_eset_t structure to clean
172
*---------------------------------------------------------------------------*/
175
cs_join_eset_clean(cs_join_eset_t **eset);
177
/*----------------------------------------------------------------------------
178
* Create a cs_join_gset_t structure (indexed list on global numbering)
181
* n_elts <-- number of elements composing the list
184
* a new allocated pointer to a cs_join_gset_t structure.
185
*---------------------------------------------------------------------------*/
188
cs_join_gset_create(cs_int_t n_elts);
190
/*----------------------------------------------------------------------------
191
* Build a cs_join_gset_t structure to store all the potential groups
194
* Values in g_elts are the tag values and values in g_list
195
* are position in tag array.
198
* n_elts <-- number of elements in tag array
199
* tag <-- tag array used to define a new cs_join_gset_t
202
* a new allocated cs_join_gset_t structure
203
*---------------------------------------------------------------------------*/
206
cs_join_gset_create_from_tag(cs_int_t n_elts,
207
const fvm_gnum_t tag[]);
209
/*----------------------------------------------------------------------------
210
* Create a new cs_join_gset_t which holds equivalences between elements of
211
* g_list in cs_join_gset_t.
213
* For a subset of equivalences, we store their initial value in the return
214
* cs_join_gset_t structure. A subset is defined if at least two elements
217
* The behavior of this function is near from cs_join_gset_create_from_tag
218
* but we don't store the position in init_array but its value in init_array.
221
* set <-- pointer to a cs_join_gset_t structure
222
* init_array <-- initial values of set->g_list
225
* a new allocated cs_join_gset_t structure
226
*---------------------------------------------------------------------------*/
229
cs_join_gset_create_by_equiv(const cs_join_gset_t *set,
230
const fvm_gnum_t init_array[]);
232
/*----------------------------------------------------------------------------
233
* Copy a cs_join_gset_t structure.
236
* src <-- pointer to the cs_join_gset_t structure to copy
239
* a new allocated cs_join_gset_t structure.
240
*---------------------------------------------------------------------------*/
243
cs_join_gset_copy(const cs_join_gset_t *src);
245
/*----------------------------------------------------------------------------
246
* Destroy a cs_join_gset_t structure.
249
* set <-- pointer to pointer to the cs_join_gset_t structure to destroy
250
*---------------------------------------------------------------------------*/
253
cs_join_gset_destroy(cs_join_gset_t **set);
255
/*----------------------------------------------------------------------------
256
* Sort a cs_join_gset_t structure according to the global numbering of
257
* the g_elts in cs_join_gset_t structure.
260
* set <-> pointer to the structure to order
261
*---------------------------------------------------------------------------*/
264
cs_join_gset_sort_elts(cs_join_gset_t *set);
266
/*----------------------------------------------------------------------------
267
* Sort each sub-list of the g_list array in a cs_join_gset_t structure.
270
* p_set <-> pointer to the structure to sort
271
*---------------------------------------------------------------------------*/
274
cs_join_gset_sort_sublist(cs_join_gset_t *set);
276
/*----------------------------------------------------------------------------
277
* Invert a cs_join_gset_t structure.
280
* set <-- pointer to the cs_join_gset_t structure to work with
283
* the new allocated and inverted set structure
284
*---------------------------------------------------------------------------*/
287
cs_join_gset_invert(const cs_join_gset_t *set);
289
/*----------------------------------------------------------------------------
290
* Delete redudancies in a cs_join_gset_t structure.
292
* The output set has an ordered sub-list for each element in the set.
295
* set <-> pointer to the structure to clean
296
*---------------------------------------------------------------------------*/
299
cs_join_gset_clean(cs_join_gset_t *set);
301
/*----------------------------------------------------------------------------
302
* Delete redudancies in g_list array of a cs_join_gset_t structure.
305
* set <-> pointer to the structure to clean
306
* linked_array <-> array for which redundancies are scanned
307
*---------------------------------------------------------------------------*/
310
cs_join_gset_clean_from_array(cs_join_gset_t *set,
311
fvm_gnum_t linked_array[]);
313
/*----------------------------------------------------------------------------
314
* Concatenate the two g_elts and g_list arrays.
316
* Order the new concatenated array and delete redundant elements.
317
* We get a single ordered array.
320
* set <-- pointer to the structure to work with
321
* n_elts --> number of elements in the new set
322
* new_array --> pointer to the new created array
323
*---------------------------------------------------------------------------*/
326
cs_join_gset_single_order(const cs_join_gset_t *set,
328
fvm_gnum_t *new_array[]);
330
/*----------------------------------------------------------------------------
331
* Compress a g_list such as for each element "e" in g_elts:
332
* - there is no redundancy for the linked elements of set->g_list
333
* - there is no element in set->g_list < e except if this element is not
336
* g_list and g_elts need to be ordered before calling this function.
339
* set <-> pointer to the structure to work with
340
*---------------------------------------------------------------------------*/
343
cs_join_gset_compress(cs_join_gset_t *set);
345
/*----------------------------------------------------------------------------
346
* Delete redundancies in set->g_elts.
348
* Merge sub-arrays associated to a common set->g_elts[i].
351
* set <-- pointer to the structure to work with
352
* order_tag <-- 0: set->g_elts is not ordered, 1: ordered
353
*---------------------------------------------------------------------------*/
356
cs_join_gset_merge_elts(cs_join_gset_t *set,
359
#if defined(HAVE_MPI)
361
/*----------------------------------------------------------------------------
362
* Synchronize a cs_join_gset_t structure and distribute the resulting set
363
* over the rank thanks to a round-robin distribution. Elements in sync_set
364
* are ordered and there is no redundancy but list may have redundancies.
365
* Use cs_join_gset_clean() to remove redundancies in g_list.
368
* loc_set <-> pointer to the local structure to work with
369
* comm <-- mpi_comm on which synchro. and distribution take place
372
* a synchronized and distributed cs_join_gset_t structure.
373
*---------------------------------------------------------------------------*/
376
cs_join_gset_robin_sync(cs_join_gset_t *loc_set,
379
/*----------------------------------------------------------------------------
380
* Update a local cs_join_gset_t structure from a distributed and
381
* synchronized cs_join_gset_t structure. Round-robin distribution is used
382
* to store synchronized elements.
385
* sync_set <-- pointer to the structure which holds a synchronized block
386
* loc_set <-> pointer to a local structure holding elements to update
387
* comm <-- comm on which synchronization and distribution take place
388
*---------------------------------------------------------------------------*/
391
cs_join_gset_robin_update(const cs_join_gset_t *sync_set,
392
cs_join_gset_t *loc_set,
395
/*----------------------------------------------------------------------------
396
* Synchronize a cs_join_gset_t structure and distribute the resulting set
397
* over the rank by block
400
* max_gnum <-- max global number in global element numbering
401
* loc_set <-> pointer to the local structure to work with
402
* comm <-- mpi_comm on which synchro. and distribution take place
405
* a synchronized and distributed cs_join_gset_t structure.
406
*---------------------------------------------------------------------------*/
409
cs_join_gset_block_sync(fvm_gnum_t max_gnum,
410
cs_join_gset_t *loc_set,
413
/*----------------------------------------------------------------------------
414
* Update a local cs_join_gset_t structure from a distributed and
415
* synchronized cs_join_gset_t structure.
417
* loc_set should not have redundant elements.
420
* max_gnum <-- max global number in global element numbering
421
* sync_set <-- pointer to the structure which holds a synchronized block
422
* loc_set <-> pointer to a local structure holding elements to update
423
* comm <-- comm on which synchronization and distribution take place
424
*---------------------------------------------------------------------------*/
427
cs_join_gset_block_update(fvm_gnum_t max_gnum,
428
const cs_join_gset_t *sync_set,
429
cs_join_gset_t *loc_set,
432
#endif /* HAVE_MPI */
434
/*----------------------------------------------------------------------------
435
* Dump an array (int or double).
437
* This function is called according to the verbosity.
440
* type <-- type of the array to display
441
* header <-- header to display in front of the array
442
* n_elts <-- number of elements to display
443
* array <-- array to display
444
*---------------------------------------------------------------------------*/
447
cs_join_dump_array(const char *type,
452
/*----------------------------------------------------------------------------
453
* Dump a cs_join_gset_t structure.
456
* file <-- pointer to an output file or NULL
457
* set <-- pointer to the cs_join_gset_t structure to dump
458
*---------------------------------------------------------------------------*/
461
cs_join_gset_dump(FILE *file,
462
const cs_join_gset_t *set);
464
/*---------------------------------------------------------------------------*/
468
#endif /* __CS_JOIN_SET_H__ */