8.2
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-2024 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 /*----------------------------------------------------------------------------*/
168 /*----------------------------------------------------------------------------*/
169 
170 void
172  int a[restrict]);
173 
174 /*----------------------------------------------------------------------------*/
183 /*----------------------------------------------------------------------------*/
184 
185 void
187  int num,
188  int a[restrict]);
189 
190 /*----------------------------------------------------------------------------*/
201 /*----------------------------------------------------------------------------*/
202 
203 void
205  const cs_lnum_t elt_ids[],
206  int num,
207  int a[restrict]);
208 
209 /*----------------------------------------------------------------------------*/
232 /*----------------------------------------------------------------------------*/
233 
234 void
236  int stride,
237  const cs_lnum_t elt_ids[],
238  int mode,
239  const cs_real_t ref[],
240  cs_real_t dest[]);
241 
242 /*----------------------------------------------------------------------------*/
250 /*----------------------------------------------------------------------------*/
251 
252 void
254  const cs_real_t src[],
255  cs_real_t dest[restrict]);
256 
257 /*----------------------------------------------------------------------------*/
269 /*----------------------------------------------------------------------------*/
270 
271 void
273  int stride,
274  const cs_lnum_t *elt_ids,
275  cs_real_t scaling_factor,
276  cs_real_t dest[restrict]);
277 
278 /*----------------------------------------------------------------------------*/
288 /*----------------------------------------------------------------------------*/
289 
290 void
292  int stride,
293  const cs_real_t ref_val[],
294  cs_real_t *a);
295 
296 /*----------------------------------------------------------------------------*/
308 /*----------------------------------------------------------------------------*/
309 
310 void
312  int stride,
313  const cs_real_t ref_val[],
314  const cs_real_t weight[],
315  cs_real_t *a);
316 
317 /*----------------------------------------------------------------------------*/
330 /*----------------------------------------------------------------------------*/
331 
332 void
334  int stride,
335  const cs_lnum_t elt_ids[],
336  const cs_real_t ref_val[],
337  cs_real_t *a);
338 
339 /*----------------------------------------------------------------------------*/
354 /*----------------------------------------------------------------------------*/
355 
356 void
358  int stride,
359  const cs_lnum_t elt_ids[],
360  const cs_real_t ref_val[],
361  const cs_real_t weight[],
362  cs_real_t *a);
363 
364 /*----------------------------------------------------------------------------*/
372 /*----------------------------------------------------------------------------*/
373 
374 void
376  cs_real_t ref_val,
377  cs_real_t a[restrict]);
378 
379 /*----------------------------------------------------------------------------*/
389 /*----------------------------------------------------------------------------*/
390 
391 void
393  cs_real_t ref_val,
394  const cs_real_t weight[],
395  cs_real_t a[restrict]);
396 
397 /*----------------------------------------------------------------------------*/
408 /*----------------------------------------------------------------------------*/
409 
410 void
412  const cs_lnum_t elt_ids[],
413  cs_real_t ref_val,
414  cs_real_t a[restrict]);
415 
416 /*----------------------------------------------------------------------------*/
428 /*----------------------------------------------------------------------------*/
429 
430 void
432  const cs_lnum_t elt_ids[],
433  cs_real_t ref_val,
434  const cs_real_t weight[],
435  cs_real_t a[restrict]);
436 
437 /*----------------------------------------------------------------------------*/
445 /*----------------------------------------------------------------------------*/
446 
447 void
449  const cs_real_t ref_val[3],
450  cs_real_t *a);
451 
452 /*----------------------------------------------------------------------------*/
462 /*----------------------------------------------------------------------------*/
463 
464 void
466  const cs_real_t ref_val[3],
467  const cs_real_t weight[],
468  cs_real_t *a);
469 
470 /*----------------------------------------------------------------------------*/
481 /*----------------------------------------------------------------------------*/
482 
483 void
485  const cs_lnum_t elt_ids[],
486  const cs_real_t ref_val[3],
487  cs_real_t a[]);
488 
489 /*----------------------------------------------------------------------------*/
502 /*----------------------------------------------------------------------------*/
503 
504 void
506  const cs_lnum_t elt_ids[],
507  const cs_real_t ref_val[3],
508  const cs_real_t weight[],
509  cs_real_t *a);
510 
511 /*----------------------------------------------------------------------------*/
520 /*----------------------------------------------------------------------------*/
521 
522 void
524  const cs_real_t ref_tens[3][3],
525  cs_real_t *a);
526 
527 /*----------------------------------------------------------------------------*/
538 /*----------------------------------------------------------------------------*/
539 
540 void
542  const cs_lnum_t elt_ids[],
543  const cs_real_t ref_tens[3][3],
544  cs_real_t *a);
545 
546 /*----------------------------------------------------------------------------*/
553 /*----------------------------------------------------------------------------*/
554 
555 void
557  cs_real_t a[]);
558 
559 /*----------------------------------------------------------------------------*/
568 /*----------------------------------------------------------------------------*/
569 
570 void
572  cs_lnum_t dim,
573  cs_real_t v,
574  cs_real_t a[]);
575 
576 /*----------------------------------------------------------------------------*/
577 
579 
580 #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:952
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:451
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:700
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:978
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:883
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:306
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:501
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:536
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:575
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:616
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:814
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:421
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:763
void cs_array_int_set_value(cs_lnum_t size, int num, int a[restrict])
Assign the value "num" to all elements of an array. Case of a int array.
Definition: cs_array.c:242
void cs_array_int_set_value_on_subset(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], int num, int a[restrict])
Assign the value "num" to an array on a selected subset of elements. if elt_ids = NULL,...
Definition: cs_array.c:265
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:787
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:849
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:654
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:918
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:676
void cs_array_int_fill_zero(cs_lnum_t size, int a[restrict])
Assign zero to all elements of an array. Case of a int array.
Definition: cs_array.c:218
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:732
#define restrict
Definition: cs_defs.h:141
#define BEGIN_C_DECLS
Definition: cs_defs.h:528
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
#define END_C_DECLS
Definition: cs_defs.h:529
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
unsigned short int cs_flag_t
Definition: cs_defs.h:334
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:113