8.1
general documentation
cs_array.h
Go to the documentation of this file.
1 #ifndef __CS_ARRAY_H__
2 #define __CS_ARRAY_H__
3 
4 /*============================================================================
5  * Array handling utilities.
6  *============================================================================*/
7 
8 /*
9  This file is part of code_saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2023 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  * Standard C library headers
32  *----------------------------------------------------------------------------*/
33 
34 #include <string.h>
35 
36 /*----------------------------------------------------------------------------
37  * Local headers
38  *----------------------------------------------------------------------------*/
39 
40 #include "cs_defs.h"
41 
42 /*----------------------------------------------------------------------------*/
43 
45 
46 /*=============================================================================
47  * Macro definitions
48  *============================================================================*/
49 
50 /* Define the way to apply a subset. In case of a copy, the subset is related
51  to the reference (input array) and/or the destination array (output
52  array) */
53 
54 #define CS_ARRAY_SUBSET_NULL -1
55 #define CS_ARRAY_SUBSET_IN 0
56 #define CS_ARRAY_SUBSET_OUT 1
57 #define CS_ARRAY_SUBSET_INOUT 2
58 
59 /*============================================================================
60  * Type definitions
61  *============================================================================*/
62 
63 /*============================================================================
64  * Global variables
65  *============================================================================*/
66 
67 /*=============================================================================
68  * Public inline function prototypes
69  *============================================================================*/
70 
71 /*=============================================================================
72  * Public function prototypes
73  *============================================================================*/
74 
75 /*----------------------------------------------------------------------------*/
82 /*----------------------------------------------------------------------------*/
83 
84 void
86  bool a[restrict]);
87 
88 /*----------------------------------------------------------------------------*/
95 /*----------------------------------------------------------------------------*/
96 
97 void
99  bool a[restrict]);
100 
101 /*----------------------------------------------------------------------------*/
108 /*----------------------------------------------------------------------------*/
109 
110 void
112  cs_flag_t a[restrict]);
113 
114 /*----------------------------------------------------------------------------*/
121 /*----------------------------------------------------------------------------*/
122 
123 void
125  cs_lnum_t a[restrict]);
126 
127 /*----------------------------------------------------------------------------*/
136 /*----------------------------------------------------------------------------*/
137 
138 void
140  cs_lnum_t num,
141  cs_lnum_t a[restrict]);
142 
143 /*----------------------------------------------------------------------------*/
154 /*----------------------------------------------------------------------------*/
155 
156 void
158  const cs_lnum_t elt_ids[],
159  cs_lnum_t num,
160  cs_lnum_t a[restrict]);
161 
162 /*----------------------------------------------------------------------------*/
185 /*----------------------------------------------------------------------------*/
186 
187 void
189  int stride,
190  const cs_lnum_t elt_ids[],
191  int mode,
192  const cs_real_t ref[],
193  cs_real_t dest[]);
194 
195 /*----------------------------------------------------------------------------*/
203 /*----------------------------------------------------------------------------*/
204 
205 void
207  const cs_real_t src[],
208  cs_real_t dest[restrict]);
209 
210 /*----------------------------------------------------------------------------*/
222 /*----------------------------------------------------------------------------*/
223 
224 void
226  int stride,
227  const cs_lnum_t *elt_ids,
228  cs_real_t scaling_factor,
229  cs_real_t dest[restrict]);
230 
231 /*----------------------------------------------------------------------------*/
241 /*----------------------------------------------------------------------------*/
242 
243 void
245  int stride,
246  const cs_real_t ref_val[],
247  cs_real_t *a);
248 
249 /*----------------------------------------------------------------------------*/
261 /*----------------------------------------------------------------------------*/
262 
263 void
265  int stride,
266  const cs_real_t ref_val[],
267  const cs_real_t weight[],
268  cs_real_t *a);
269 
270 /*----------------------------------------------------------------------------*/
283 /*----------------------------------------------------------------------------*/
284 
285 void
287  int stride,
288  const cs_lnum_t elt_ids[],
289  const cs_real_t ref_val[],
290  cs_real_t *a);
291 
292 /*----------------------------------------------------------------------------*/
307 /*----------------------------------------------------------------------------*/
308 
309 void
311  int stride,
312  const cs_lnum_t elt_ids[],
313  const cs_real_t ref_val[],
314  const cs_real_t weight[],
315  cs_real_t *a);
316 
317 /*----------------------------------------------------------------------------*/
325 /*----------------------------------------------------------------------------*/
326 
327 void
329  cs_real_t ref_val,
330  cs_real_t a[restrict]);
331 
332 /*----------------------------------------------------------------------------*/
342 /*----------------------------------------------------------------------------*/
343 
344 void
346  cs_real_t ref_val,
347  const cs_real_t weight[],
348  cs_real_t a[restrict]);
349 
350 /*----------------------------------------------------------------------------*/
361 /*----------------------------------------------------------------------------*/
362 
363 void
365  const cs_lnum_t elt_ids[],
366  cs_real_t ref_val,
367  cs_real_t a[restrict]);
368 
369 /*----------------------------------------------------------------------------*/
381 /*----------------------------------------------------------------------------*/
382 
383 void
385  const cs_lnum_t elt_ids[],
386  cs_real_t ref_val,
387  const cs_real_t weight[],
388  cs_real_t a[restrict]);
389 
390 /*----------------------------------------------------------------------------*/
398 /*----------------------------------------------------------------------------*/
399 
400 void
402  const cs_real_t ref_val[3],
403  cs_real_t *a);
404 
405 /*----------------------------------------------------------------------------*/
415 /*----------------------------------------------------------------------------*/
416 
417 void
419  const cs_real_t ref_val[3],
420  const cs_real_t weight[],
421  cs_real_t *a);
422 
423 /*----------------------------------------------------------------------------*/
434 /*----------------------------------------------------------------------------*/
435 
436 void
438  const cs_lnum_t elt_ids[],
439  const cs_real_t ref_val[3],
440  cs_real_t a[]);
441 
442 /*----------------------------------------------------------------------------*/
455 /*----------------------------------------------------------------------------*/
456 
457 void
459  const cs_lnum_t elt_ids[],
460  const cs_real_t ref_val[3],
461  const cs_real_t weight[],
462  cs_real_t *a);
463 
464 /*----------------------------------------------------------------------------*/
473 /*----------------------------------------------------------------------------*/
474 
475 void
477  const cs_real_t ref_tens[3][3],
478  cs_real_t *a);
479 
480 /*----------------------------------------------------------------------------*/
491 /*----------------------------------------------------------------------------*/
492 
493 void
495  const cs_lnum_t elt_ids[],
496  const cs_real_t ref_tens[3][3],
497  cs_real_t *a);
498 
499 /*----------------------------------------------------------------------------*/
506 /*----------------------------------------------------------------------------*/
507 
508 void
510  cs_real_t a[]);
511 
512 /*----------------------------------------------------------------------------*/
521 /*----------------------------------------------------------------------------*/
522 
523 void
525  cs_lnum_t dim,
526  cs_real_t v,
527  cs_real_t a[]);
528 
529 /*----------------------------------------------------------------------------*/
530 
532 
533 #endif /* __CS_ARRAY_H__ */
void cs_array_real_fill_zero(cs_lnum_t size, cs_real_t a[])
Assign zero to all elements of an array.
Definition: cs_array.c:879
void cs_array_real_scale(cs_lnum_t n_elts, int stride, const cs_lnum_t *elt_ids, cs_real_t scaling_factor, cs_real_t dest[restrict])
Multiply each value by a scaling factor s.t. dest *= scaling_factor If elt_ids is not NULL,...
Definition: cs_array.c:378
void cs_array_real_set_scalar_on_subset(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], cs_real_t ref_val, cs_real_t a[restrict])
Assign a constant scalar value to an array on a selected subset of elements. If elt_ids = NULL,...
Definition: cs_array.c:627
void cs_array_set_value_real(cs_lnum_t n_elts, cs_lnum_t dim, cs_real_t v, cs_real_t a[])
Assign a constant value to an array (deprecated function).
Definition: cs_array.c:905
void cs_array_real_set_tensor(cs_lnum_t n_elts, const cs_real_t ref_tens[3][3], cs_real_t *a)
Assign a constant 3x3 tensor to an array (of stride 9) which is interlaced.
Definition: cs_array.c:810
void cs_array_lnum_fill_zero(cs_lnum_t size, cs_lnum_t a[restrict])
Assign zero to all elements of an array. Case of a cs_lnum_t array.
Definition: cs_array.c:146
void cs_array_real_copy_subset(cs_lnum_t n_elts, int stride, const cs_lnum_t elt_ids[], int mode, const cs_real_t ref[], cs_real_t dest[])
Copy an array ("ref") into another array ("dest") on possibly only a part of the array(s)....
Definition: cs_array.c:233
void cs_array_real_set_value(cs_lnum_t n_elts, int stride, const cs_real_t ref_val[], cs_real_t *a)
Assign a constant value of dim "stride" to an interlaced array sharing the same stride.
Definition: cs_array.c:428
void cs_array_real_set_wvalue(cs_lnum_t n_elts, int stride, const cs_real_t ref_val[], const cs_real_t weight[], cs_real_t *a)
Assign a weighted constant value of dim "stride" to an interlaced array sharing the same stride....
Definition: cs_array.c:463
void cs_array_real_set_value_on_subset(cs_lnum_t n_elts, int stride, const cs_lnum_t elt_ids[], const cs_real_t ref_val[], cs_real_t *a)
Assign a constant value of dim "stride" to an interlaced array sharing the same stride....
Definition: cs_array.c:502
void cs_array_real_set_wvalue_on_subset(cs_lnum_t n_elts, int stride, const cs_lnum_t elt_ids[], const cs_real_t ref_val[], const cs_real_t weight[], cs_real_t *a)
Assign a weighted constant value of dim "stride" to an interlaced array sharing the same stride....
Definition: cs_array.c:543
void cs_array_real_set_vector_on_subset(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], const cs_real_t ref_val[3], cs_real_t a[])
Assign a constant vector to an interlaced array (of stride 3) on a selected subset of elements....
Definition: cs_array.c:741
void cs_array_lnum_set_value(cs_lnum_t size, cs_lnum_t num, cs_lnum_t a[restrict])
Assign the value "num" to all elements of an array. Case of a cs_lnum_t array.
Definition: cs_array.c:170
void cs_array_flag_fill_zero(cs_lnum_t size, cs_flag_t a[restrict])
Assign zero to all elements of an array. Case of a cs_flag_t array.
Definition: cs_array.c:124
void cs_array_bool_fill_true(cs_lnum_t size, bool a[restrict])
Assign true to all elements of an array. Case of an array of booleans.
Definition: cs_array.c:88
void cs_array_real_copy(cs_lnum_t size, const cs_real_t src[], cs_real_t dest[restrict])
Copy real values from an array to another of the same dimensions.
Definition: cs_array.c:348
void cs_array_bool_fill_false(cs_lnum_t size, bool a[restrict])
Assign false to all elements of an array. Case of an array of booleans.
Definition: cs_array.c:106
void cs_array_real_set_vector(cs_lnum_t n_elts, const cs_real_t ref_val[3], cs_real_t *a)
Assign a constant vector to an array of stride 3 which is interlaced.
Definition: cs_array.c:690
void cs_array_real_set_wvector(cs_lnum_t n_elts, const cs_real_t ref_val[3], const cs_real_t weight[], cs_real_t *a)
Assign a weighted constant vector value to an interlaced array (of stride 3). The array of weights ha...
Definition: cs_array.c:714
void cs_array_real_set_wvector_on_subset(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], const cs_real_t ref_val[3], const cs_real_t weight[], cs_real_t *a)
Assign a weighted constant vector value to an interlaced array (of stride 3). The subset selection is...
Definition: cs_array.c:776
void cs_array_real_set_scalar(cs_lnum_t n_elts, cs_real_t ref_val, cs_real_t a[restrict])
Assign a constant scalar value to an array.
Definition: cs_array.c:581
void cs_array_lnum_set_value_on_subset(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], cs_lnum_t num, cs_lnum_t a[restrict])
Assign the value "num" to an array on a selected subset of elements. if elt_ids = NULL,...
Definition: cs_array.c:193
void cs_array_real_set_tensor_on_subset(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], const cs_real_t ref_tens[3][3], cs_real_t *a)
Assign a constant 3x3 tensor to an interlaced array (of stride 9) on a subset of elements....
Definition: cs_array.c:845
void cs_array_real_set_wscalar(cs_lnum_t n_elts, cs_real_t ref_val, const cs_real_t weight[], cs_real_t a[restrict])
Assign a weighted constant scalar value to an array. The weight array has the same size as the array ...
Definition: cs_array.c:603
void cs_array_real_set_wscalar_on_subset(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], cs_real_t ref_val, const cs_real_t weight[], cs_real_t a[restrict])
Assign a weighted constant scalar value to an array on a selected subset of elements....
Definition: cs_array.c:659
#define restrict
Definition: cs_defs.h:139
#define BEGIN_C_DECLS
Definition: cs_defs.h:514
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
#define END_C_DECLS
Definition: cs_defs.h:515
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:313
unsigned short int cs_flag_t
Definition: cs_defs.h:321
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:114