My Project
programmer's documentation
cs_order.h
Go to the documentation of this file.
1 #ifndef __CS_ORDER_H__
2 #define __CS_ORDER_H__
3 
4 /*============================================================================
5  * Functions related to the ordering of local arrays.
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2019 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 /*----------------------------------------------------------------------------
31  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_defs.h"
35 
36 /*----------------------------------------------------------------------------*/
37 
39 
40 /*=============================================================================
41  * Macro definitions
42  *============================================================================*/
43 
44 /*============================================================================
45  * Type definitions
46  *============================================================================*/
47 
48 /*=============================================================================
49  * Static global variables
50  *============================================================================*/
51 
52 /*=============================================================================
53  * Public function prototypes
54  *============================================================================*/
55 
56 /*----------------------------------------------------------------------------
57  * Test if an array of global numbers is ordered.
58  *
59  * parameters:
60  * list <-- optional list (1 to n numbering) of selected entities
61  * (or NULL if all nb_ent are selected). This list may
62  * contain element numbers in any order
63  * number <-- array of all entity numbers (number of entity i
64  * given by number[i] or number[list[i] - 1]) if list exists
65  * (if NULL, a default 1 to n numbering is considered)
66  * nb_ent <-- number of entities considered
67  *
68  * returns:
69  * 1 if ordered, 0 otherwise.
70  *----------------------------------------------------------------------------*/
71 
72 int
73 cs_order_gnum_test(const cs_lnum_t list[],
74  const cs_gnum_t number[],
75  size_t nb_ent);
76 
77 /*----------------------------------------------------------------------------
78  * Return an ordering table associated with an array of global numbers.
79  *
80  * parameters:
81  * list <-- optional list (1 to n numbering) of selected entities
82  * (or NULL if all nb_ent are selected). This list may
83  * contain element numbers in any order
84  * number <-- array of all entity numbers (number of entity i
85  * given by number[i] or number[list[i] - 1]) if list exists
86  * (if NULL, a default 1 to n numbering is considered)
87  * nb_ent <-- number of entities considered
88  *
89  * returns:
90  * pointer to list of nb_ent entities (0 to n-1 numbering) ordered by
91  * increasing associated number. The calling code is responsible for
92  * freeing this array when it is not needed anymore
93  *----------------------------------------------------------------------------*/
94 
95 cs_lnum_t *
96 cs_order_gnum(const cs_lnum_t list[],
97  const cs_gnum_t number[],
98  size_t nb_ent);
99 
100 /*----------------------------------------------------------------------------
101  * Return a lexicographical ordering table associated with a strided array
102  * of global numbers.
103  *
104  * parameters:
105  * list <-- optional list (1 to n numbering) of selected entities
106  * (or NULL if all nb_ent are selected). This list may
107  * contain element numbers in any order
108  * number <-- array of all entity numbers (number of entity i
109  * given by number[i] or number[list[i] - 1]) if list exists
110  * (if NULL, a default 1 to n numbering is considered)
111  * stride <-- stride of number array (number of values to compare)
112  * nb_ent <-- number of entities considered
113  *
114  * returns:
115  * pointer to list of nb_ent entities (0 to n-1 numbering) ordered by
116  * increasing associated number. The calling code is responsible for
117  * freeing this array when it is not needed anymore.
118  *----------------------------------------------------------------------------*/
119 
120 cs_lnum_t *
121 cs_order_gnum_s(const cs_lnum_t list[],
122  const cs_gnum_t number[],
123  size_t stride,
124  size_t nb_ent);
125 
126 /*----------------------------------------------------------------------------
127  * Return a lexicographical ordering table associated with an indexed array
128  * of global numbers.
129  *
130  * parameters:
131  * list <-- optional list (1 to n numbering) of selected entities
132  * (or NULL if all nb_ent are selected). This list may
133  * contain element numbers in any order
134  * number <-- array of all entity numbers (numbers of entity i start
135  * at index[i] or _index[i] (reduced index) if list exists).
136  * If list = NULL, a default 1 to n numbering is considered)
137  * index <-- number of values to compare for each entity
138  * nb_ent <-- number of entities considered
139  *
140  * returns:
141  * pointer to list of nb_ent entities (0 to n-1 numbering) ordered by
142  * increasing associated number. The calling code is responsible for
143  * freeing this array when it is not needed anymore.
144  *----------------------------------------------------------------------------*/
145 
146 cs_lnum_t *
147 cs_order_gnum_i(const cs_lnum_t list[],
148  const cs_gnum_t number[],
149  const cs_lnum_t index[],
150  size_t nb_ent);
151 
152 /*----------------------------------------------------------------------------
153  * Compute an ordering table associated with an array of global numbers.
154  *
155  * parameters:
156  * list <-- optional list (1 to n numbering) of selected entities
157  * (or NULL if all nb_ent are selected). This list may
158  * contain element numbers in any order
159  * number <-- array of all entity numbers (number of entity i
160  * given by number[i] or number[list[i] - 1]) if list exists
161  * (if NULL, a default 1 to n numbering is considered)
162  * order --> pointer to pre-allocated ordering table
163  * nb_ent <-- number of entities considered
164  *----------------------------------------------------------------------------*/
165 
166 void
168  const cs_gnum_t number[],
169  cs_lnum_t order[],
170  size_t nb_ent);
171 
172 /*----------------------------------------------------------------------------
173  * Compute a lexicographical ordering table associated with an array of
174  * strided global numbers.
175  *
176  * parameters:
177  * list <-- optional list (1 to n numbering) of selected entities
178  * (or NULL if all nb_ent are selected). This list may
179  * contain element numbers in any order
180  * number <-- array of all entity numbers (numbers of entity i start
181  * at number[i*stride] or number[(list[i] - 1)*stride]) if
182  * list exists (if NULL, a default 1 to n numbering is
183  * considered)
184  * stride <-- stride of number array (number of values to compare)
185  * order --> pointer to pre-allocated ordering table
186  * nb_ent <-- number of entities considered
187  *----------------------------------------------------------------------------*/
188 
189 void
191  const cs_gnum_t number[],
192  size_t stride,
193  cs_lnum_t order[],
194  size_t nb_ent);
195 
196 /*----------------------------------------------------------------------------
197  * Compute a lexicographical ordering table associated with an indexed array
198  * of global numbers.
199  *
200  * parameters:
201  * list <-- optional list (1 to n numbering) of selected entities
202  * (or NULL if all nb_ent are selected). This list may
203  * contain element numbers in any order
204  * number <-- array of all entity numbers (numbers of entity i start
205  * at index[i] or _index[i] (reduced index) if list exists).
206  * If list = NULL, a default 1 to n numbering is considered)
207  * index <-- number of values to compare for each entity (from 0)
208  * order --> pointer to pre-allocated ordering table
209  * nb_ent <-- number of entities considered
210  *----------------------------------------------------------------------------*/
211 
212 void
214  const cs_gnum_t number[],
215  const cs_lnum_t index[],
216  cs_lnum_t order[],
217  size_t nb_ent);
218 
219 /*----------------------------------------------------------------------------
220  * Compute an ordering table associated with an array of local numbers.
221  *
222  * parameters:
223  * list <-- optional list (1 to n numbering) of selected entities
224  * (or NULL if all nb_ent are selected). This list may
225  * contain element numbers in any order
226  * number <-- array of all entity numbers (number of entity i
227  * given by number[i] or number[list[i] - 1]) if list exists
228  * (if NULL, a default 1 to n numbering is considered)
229  * order --> pointer to pre-allocated ordering table
230  * nb_ent <-- number of entities considered
231  *----------------------------------------------------------------------------*/
232 
233 void
235  const cs_lnum_t number[],
236  cs_lnum_t order[],
237  size_t nb_ent);
238 
239 /*----------------------------------------------------------------------------*/
252 /*----------------------------------------------------------------------------*/
253 
254 void
256  const cs_real_t val[],
257  cs_lnum_t order[],
258  size_t nb_ent);
259 
260 /*----------------------------------------------------------------------------
261  * Compute a lexicographical ordering table associated with an array of
262  * strided local numbers.
263  *
264  * parameters:
265  * list <-- optional list (1 to n numbering) of selected entities
266  * (or NULL if all nb_ent are selected). This list may
267  * contain element numbers in any order
268  * number <-- array of all entity numbers (numbers of entity i start
269  * at number[i*stride] or number[(list[i] - 1)*stride]) if
270  * list exists (if NULL, a default 1 to n numbering is
271  * considered)
272  * stride <-- stride of number array (number of values to compare)
273  * order --> pointer to pre-allocated ordering table
274  * nb_ent <-- number of entities considered
275  *----------------------------------------------------------------------------*/
276 
277 void
279  const cs_lnum_t number[],
280  size_t stride,
281  cs_lnum_t order[],
282  size_t nb_ent);
283 
284 /*----------------------------------------------------------------------------
285  * Build local renumbering array based on ordering of entities.
286  *
287  * parameters:
288  * order <-- 0 to n-1 ordering of entities by increasing attribute
289  * nb_ent <-- number of entities considered
290  *
291  * returns:
292  * pointer to renumbering array (0 to n-1 numbering) indicating the new
293  * index of renumbered entities; The calling code is responsible for
294  * freeing this array when it is not needed anymore
295  *----------------------------------------------------------------------------*/
296 
297 cs_lnum_t *
298 cs_order_renumbering(const cs_lnum_t order[],
299  size_t nb_ent);
300 
301 /*----------------------------------------------------------------------------
302  * Reorder data based on ordering array.
303  *
304  * parameters:
305  * n_elts <-- number of elements
306  * elt_size <-- element size
307  * order <-- reordering array
308  * data <-> data
309  *----------------------------------------------------------------------------*/
310 
311 void
313  size_t elt_size,
314  const cs_lnum_t order[],
315  void *data);
316 
317 /*----------------------------------------------------------------------------*/
318 
320 
321 #endif /* __CS_ORDER_H__ */
cs_defs.h
cs_order_gnum_allocated_i
void cs_order_gnum_allocated_i(const cs_lnum_t list[], const cs_gnum_t number[], const cs_lnum_t index[], cs_lnum_t order[], size_t nb_ent)
Compute a lexicographical ordering table associated with an indexed array of global numbers.
Definition: cs_order.c:1081
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_order_renumbering
cs_lnum_t * cs_order_renumbering(const cs_lnum_t order[], size_t nb_ent)
Build local renumbering array based on ordering of entities.
Definition: cs_order.c:1334
cs_order_lnum_allocated
void cs_order_lnum_allocated(const cs_lnum_t list[], const cs_lnum_t number[], cs_lnum_t order[], size_t nb_ent)
Compute an ordering table associated with an array of local numbers.
Definition: cs_order.c:1166
cs_order_gnum_allocated
void cs_order_gnum_allocated(const cs_lnum_t list[], const cs_gnum_t number[], cs_lnum_t order[], size_t nb_ent)
Compute an ordering table associated with an array of global numbers.
Definition: cs_order.c:962
stride
void const cs_int_t const cs_int_t const cs_int_t const cs_int_t * stride
Definition: cs_sat_coupling.h:325
cs_gnum_t
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:286
cs_order_lnum_allocated_s
void cs_order_lnum_allocated_s(const cs_lnum_t list[], const cs_lnum_t number[], size_t stride, cs_lnum_t order[], size_t nb_ent)
Compute a lexicographical ordering table associated with an array of strided local numbers.
Definition: cs_order.c:1235
cs_order_real_allocated
void cs_order_real_allocated(const cs_lnum_t list[], const cs_real_t val[], cs_lnum_t order[], size_t nb_ent)
Compute an ordering table associated with an array of local values.
Definition: cs_order.c:1294
cs_order_gnum_allocated_s
void cs_order_gnum_allocated_s(const cs_lnum_t list[], const cs_gnum_t number[], size_t stride, cs_lnum_t order[], size_t nb_ent)
Compute a lexicographical ordering table associated with an array of strided global numbers.
Definition: cs_order.c:1027
cs_order_gnum
cs_lnum_t * cs_order_gnum(const cs_lnum_t list[], const cs_gnum_t number[], size_t nb_ent)
Return an ordering table associated with an array of global numbers.
Definition: cs_order.c:855
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_order_gnum_test
int cs_order_gnum_test(const cs_lnum_t list[], const cs_gnum_t number[], size_t nb_ent)
Test if an array of global numbers is ordered.
Definition: cs_order.c:792
cs_order_gnum_s
cs_lnum_t * cs_order_gnum_s(const cs_lnum_t list[], const cs_gnum_t number[], size_t stride, size_t nb_ent)
Return a lexicographical ordering table associated with a strided array of global numbers.
Definition: cs_order.c:893
cs_order_gnum_i
cs_lnum_t * cs_order_gnum_i(const cs_lnum_t list[], const cs_gnum_t number[], const cs_lnum_t index[], size_t nb_ent)
Return a lexicographical ordering table associated with an indexed array of global numbers.
Definition: cs_order.c:932
cs_order_reorder_data
void cs_order_reorder_data(cs_lnum_t n_elts, size_t elt_size, const cs_lnum_t order[], void *data)
Reorder data based on ordering array.
Definition: cs_order.c:1383