8.0
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 /*----------------------------------------------------------------------------*/
138 /*----------------------------------------------------------------------------*/
139 
140 void
142  cs_lnum_t num,
143  cs_lnum_t a[restrict]);
144 
145 /*----------------------------------------------------------------------------*/
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 /*----------------------------------------------------------------------------*/
219 /*----------------------------------------------------------------------------*/
220 
221 void
223  cs_real_t scaling_factor,
224  cs_real_t dest[restrict]);
225 
226 /*----------------------------------------------------------------------------*/
236 /*----------------------------------------------------------------------------*/
237 
238 void
240  int stride,
241  const cs_real_t ref_val[],
242  cs_real_t *a);
243 
244 /*----------------------------------------------------------------------------*/
256 /*----------------------------------------------------------------------------*/
257 
258 void
260  int stride,
261  const cs_real_t ref_val[],
262  const cs_real_t weight[],
263  cs_real_t *a);
264 
265 /*----------------------------------------------------------------------------*/
278 /*----------------------------------------------------------------------------*/
279 
280 void
282  int stride,
283  const cs_lnum_t elt_ids[],
284  const cs_real_t ref_val[],
285  cs_real_t *a);
286 
287 /*----------------------------------------------------------------------------*/
302 /*----------------------------------------------------------------------------*/
303 
304 void
306  int stride,
307  const cs_lnum_t elt_ids[],
308  const cs_real_t ref_val[],
309  const cs_real_t weight[],
310  cs_real_t *a);
311 
312 /*----------------------------------------------------------------------------*/
320 /*----------------------------------------------------------------------------*/
321 
322 void
324  cs_real_t ref_val,
325  cs_real_t a[restrict]);
326 
327 /*----------------------------------------------------------------------------*/
337 /*----------------------------------------------------------------------------*/
338 
339 void
341  cs_real_t ref_val,
342  const cs_real_t weight[],
343  cs_real_t a[restrict]);
344 
345 /*----------------------------------------------------------------------------*/
356 /*----------------------------------------------------------------------------*/
357 
358 void
360  const cs_lnum_t elt_ids[],
361  cs_real_t ref_val,
362  cs_real_t a[restrict]);
363 
364 /*----------------------------------------------------------------------------*/
376 /*----------------------------------------------------------------------------*/
377 
378 void
380  const cs_lnum_t elt_ids[],
381  cs_real_t ref_val,
382  const cs_real_t weight[],
383  cs_real_t a[restrict]);
384 
385 /*----------------------------------------------------------------------------*/
393 /*----------------------------------------------------------------------------*/
394 
395 void
397  const cs_real_t ref_val[3],
398  cs_real_t *a);
399 
400 /*----------------------------------------------------------------------------*/
410 /*----------------------------------------------------------------------------*/
411 
412 void
414  const cs_real_t ref_val[3],
415  const cs_real_t weight[],
416  cs_real_t *a);
417 
418 /*----------------------------------------------------------------------------*/
429 /*----------------------------------------------------------------------------*/
430 
431 void
433  const cs_lnum_t elt_ids[],
434  const cs_real_t ref_val[3],
435  cs_real_t a[]);
436 
437 /*----------------------------------------------------------------------------*/
450 /*----------------------------------------------------------------------------*/
451 
452 void
454  const cs_lnum_t elt_ids[],
455  const cs_real_t ref_val[3],
456  const cs_real_t weight[],
457  cs_real_t *a);
458 
459 /*----------------------------------------------------------------------------*/
468 /*----------------------------------------------------------------------------*/
469 
470 void
472  const cs_real_t ref_tens[3][3],
473  cs_real_t *a);
474 
475 /*----------------------------------------------------------------------------*/
486 /*----------------------------------------------------------------------------*/
487 
488 void
490  const cs_lnum_t elt_ids[],
491  const cs_real_t ref_tens[3][3],
492  cs_real_t *a);
493 
494 /*----------------------------------------------------------------------------*/
501 /*----------------------------------------------------------------------------*/
502 
503 void
505  cs_real_t a[]);
506 
507 /*----------------------------------------------------------------------------*/
516 /*----------------------------------------------------------------------------*/
517 
518 void
520  cs_lnum_t dim,
521  cs_real_t v,
522  cs_real_t a[]);
523 
524 /*----------------------------------------------------------------------------*/
525 
527 
528 #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:848
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:596
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:874
void cs_array_real_scale(cs_lnum_t size, cs_real_t scaling_factor, cs_real_t dest[restrict])
Multiply each value by a scaling factor dest *= scaling_factor.
Definition: cs_array.c:375
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:779
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:397
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:432
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:471
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:512
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:710
void cs_array_lnum_set_value(cs_lnum_t size, 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: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:659
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:683
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:745
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:550
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 all elements of an array. Case of a cs_lnum_t array.
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:814
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:572
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:628
#define restrict
Definition: cs_defs.h:139
#define BEGIN_C_DECLS
Definition: cs_defs.h:509
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
#define END_C_DECLS
Definition: cs_defs.h:510
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
double precision, save a
Definition: cs_fuel_incl.f90:148