8.3
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 and C++ library headers
32 *----------------------------------------------------------------------------*/
33
34#include <string.h>
35
36/*----------------------------------------------------------------------------
37 * Local headers
38 *----------------------------------------------------------------------------*/
39
40#include "cs_defs.h"
41#include "cs_base_accel.h"
42#if defined (__NVCC__)
43#include "cs_array_cuda.h"
44#include "cs_base_cuda.h"
45#endif
46
47/*----------------------------------------------------------------------------*/
48
49/*=============================================================================
50 * Macro definitions
51 *============================================================================*/
52
53/* Define the way to apply a subset. In case of a copy, the subset is related
54 to the reference (input array) and/or the destination array (output
55 array) */
56
57#define CS_ARRAY_SUBSET_NULL -1
58#define CS_ARRAY_SUBSET_IN 0
59#define CS_ARRAY_SUBSET_OUT 1
60#define CS_ARRAY_SUBSET_INOUT 2
61
62/*============================================================================
63 * Type definitions
64 *============================================================================*/
65
66/*============================================================================
67 * Global variables
68 *============================================================================*/
69
70/*=============================================================================
71 * Public inline function prototypes
72 *============================================================================*/
73
74/*=============================================================================
75 * Public function prototypes
76 *============================================================================*/
77
78#if defined(__cplusplus)
79/*----------------------------------------------------------------------------*/
94/*----------------------------------------------------------------------------*/
95
96template <typename T, size_t stride, typename... Arrays>
97void
99 const T *ref_val,
100 Arrays&&... arrays)
101{
102 /* Expand the parameter pack */
103 T* array_ptrs[] = {arrays ... };
104
105#if defined (__NVCC__)
106 bool is_available_on_device = cs_check_device_ptr(ref_val);
107 for (T* array : array_ptrs)
108 is_available_on_device = is_available_on_device
109 && (cs_check_device_ptr(array)
111
112 if (is_available_on_device) {
113 cudaStream_t stream_ = cs_cuda_get_stream(0);
114 cs_arrays_set_value<T, stride>(stream_,
115 n_elts,
116 ref_val,
117 arrays...);
118 return;
119 }
120#endif
121
122 auto set_value = [=](cs_lnum_t i_elt) {
123 for (T* array : array_ptrs)
124 memcpy(array + i_elt*stride, ref_val, stride*sizeof(T));
125 };
126
127 /* Loop through each index and assign values */
128# pragma omp parallel for if (n_elts >= CS_THR_MIN)
129 for (cs_lnum_t i = 0; i < n_elts; i++)
130 set_value(i);
131}
132
133/*----------------------------------------------------------------------------*/
148/*----------------------------------------------------------------------------*/
149
150template <typename T, size_t stride, typename... Arrays>
151void
152cs_arrays_set_value(const cs_lnum_t n_elts,
153 const T ref_val,
154 Arrays&&... arrays)
155{
156
157 /* Expand the parameter pack */
158 T* array_ptrs[] = {arrays ... };
159
160#if defined (__NVCC__)
161 bool is_available_on_device = true;
162 for (T* array : array_ptrs)
163 is_available_on_device = is_available_on_device
164 && (cs_check_device_ptr(array)
166
167 if (is_available_on_device) {
168 cudaStream_t stream_ = cs_cuda_get_stream(0);
169 cs_arrays_set_value<T, stride>(stream_,
170 n_elts,
171 ref_val,
172 arrays...);
173 return;
174 }
175#endif
176
177 auto set_value = [=](cs_lnum_t i_elt) {
178 for (T* array : array_ptrs)
179 for (size_t k = 0; k < stride; k++) {
180 array[i_elt*stride + k] = ref_val;
181 }
182 };
183
184 /* Loop through each index and assign values */
185# pragma omp parallel for if (n_elts >= CS_THR_MIN)
186 for (cs_lnum_t i = 0; i < n_elts; i++)
187 set_value(i);
188}
189
190/*----------------------------------------------------------------------------*/
206/*----------------------------------------------------------------------------*/
207
208template <typename T, size_t stride, typename... Arrays>
209void
210cs_arrays_set_value_on_subset(const cs_lnum_t n_elts,
211 const cs_lnum_t *elt_ids,
212 const T *ref_val,
213 Arrays&&... arrays)
214{
215 if (n_elts < 1)
216 return;
217
218 if (elt_ids == NULL)
219 cs_arrays_set_value<T, stride>(n_elts, ref_val, arrays...);
220 else {
221 /* Expand the parameter pack */
222 T* array_ptrs[] = {arrays ... };
223
224 auto set_value = [=](cs_lnum_t i_elt) {
225 for (T* array : array_ptrs)
226 memcpy(array + i_elt*stride, ref_val, stride*sizeof(T));
227 };
228
229 /* Loop through each index on the subset and assign values */
230# pragma omp parallel for if (n_elts >= CS_THR_MIN)
231 for (cs_lnum_t i = 0; i < n_elts; i++)
232 set_value(elt_ids[i]);
233 }
234}
235
236/*----------------------------------------------------------------------------*/
252/*----------------------------------------------------------------------------*/
253
254template <typename T, size_t stride, typename... Arrays>
255void
256cs_arrays_set_value_on_subset(const cs_lnum_t n_elts,
257 const cs_lnum_t *elt_ids,
258 const T ref_val,
259 Arrays&&... arrays)
260{
261 if (n_elts < 1)
262 return;
263
264 if (elt_ids == NULL)
265 cs_arrays_set_value<T, stride>(n_elts, ref_val, arrays...);
266 else {
267
268 /* Expand the parameter pack */
269 T* array_ptrs[] = {arrays ... };
270
271 auto set_value = [=](cs_lnum_t i_elt) {
272 for (T* array : array_ptrs)
273 for (size_t k = 0; k < stride; k++) {
274 array[i_elt*stride + k] = ref_val;
275 }
276 };
277
278 /* Loop through each index on the subset and assign values */
279# pragma omp parallel for if (n_elts >= CS_THR_MIN)
280 for (cs_lnum_t i = 0; i < n_elts; i++)
281 set_value(elt_ids[i]);
282 }
283}
284
285/*----------------------------------------------------------------------------*/
296/*----------------------------------------------------------------------------*/
297
298template <typename T>
299void
300cs_array_copy(const cs_lnum_t size,
301 const T* src,
302 T* dest)
303{
304#if defined (__NVCC__)
305 bool is_available_on_device = cs_check_device_ptr(src)
306 && cs_check_device_ptr(dest);
307
308 if (is_available_on_device) {
309 cudaStream_t stream_ = cs_cuda_get_stream(0);
310 cs_array_copy<T>(stream_, size, src, dest);
311 return;
312 }
313#endif
314
315# pragma omp parallel for if (size > CS_THR_MIN)
316 for (cs_lnum_t ii = 0; ii < size; ii++)
317 dest[ii] = src[ii];
318}
319
320/*----------------------------------------------------------------------------*/
334/*----------------------------------------------------------------------------*/
335
336template <typename T>
337void
338cs_array_difference(const cs_lnum_t size, const T *x, const T *y, T *diff)
339{
340 cs_array_copy(size, x, diff);
341
342#pragma omp parallel for if (size > CS_THR_MIN)
343 for (cs_lnum_t ii = 0; ii < size; ii++)
344 diff[ii] -= y[ii];
345}
346
347#endif // __cplusplus
348
350
351/*----------------------------------------------------------------------------*/
352/*
353 * \brief Assign true to all elements of an array. Case of an array of booleans
354 *
355 * \param[in] size total number of elements to set
356 * \param[in, out] a array to set
357 */
358/*----------------------------------------------------------------------------*/
359
360void
362 bool a[]);
363
364/*----------------------------------------------------------------------------*/
365/*
366 * \brief Assign false to all elements of an array. Case of an array of booleans
367 *
368 * \param[in] size total number of elements to set
369 * \param[in, out] a array to set
370 */
371/*----------------------------------------------------------------------------*/
372
373void
375 bool a[]);
376
377/*----------------------------------------------------------------------------*/
378/*
379 * \brief Assign zero to all elements of an array. Case of a cs_flag_t array.
380 *
381 * \param[in] size total number of elements to set to zero
382 * \param[in, out] a array of flags to set
383 */
384/*----------------------------------------------------------------------------*/
385
386void
388 cs_flag_t a[]);
389
390/*----------------------------------------------------------------------------*/
391/*
392 * \brief Assign zero to all elements of an array. Case of a cs_lnum_t array.
393 *
394 * \param[in] size total number of elements to set to zero
395 * \param[in, out] a array to set
396 */
397/*----------------------------------------------------------------------------*/
398
399void
401 cs_lnum_t a[]);
402
403/*----------------------------------------------------------------------------*/
404/*
405 * \brief Copy values from an array of cs_lnum_t type to another of the same
406 * dimensions.
407 *
408 * \param[in] size number of elements * dimension
409 * \param[in] src source array values (size: n_elts*dim)
410 * \param[out] dest destination array values (size: n_elts*dim)
411 */
412/*----------------------------------------------------------------------------*/
413
414void
416 const cs_lnum_t src[],
417 cs_lnum_t dest[]);
418
419/*----------------------------------------------------------------------------*/
420/*
421 * \brief Assign the value "num" to all elements of an array. Case of a
422 * cs_lnum_t array.
423 *
424 * \param[in] size total number of elements to set
425 * \param[in] num value to set
426 * \param[in, out] a array to set
427 */
428/*----------------------------------------------------------------------------*/
429
430void
432 cs_lnum_t num,
433 cs_lnum_t a[]);
434
435/*----------------------------------------------------------------------------*/
436/*
437 * \brief Assign the value "num" to an array on a selected subset of elements.
438 * if elt_ids is null, then one recovers the function
439 * \ref cs_array_lnum_set_value
440 *
441 * \param[in] n_elts number of elements
442 * \param[in] elt_ids list of ids in the subset or null (size: n_elts)
443 * \param[in] num value to set
444 * \param[in, out] a array to set
445 */
446/*----------------------------------------------------------------------------*/
447
448void
450 const cs_lnum_t elt_ids[],
451 cs_lnum_t num,
452 cs_lnum_t a[]);
453/*----------------------------------------------------------------------------*/
454/*
455 * \brief Assign zero to all elements of an array. Case of a int array.
456 *
457 * \param[in] size total number of elements to set to zero
458 * \param[in, out] a array to set
459 */
460/*----------------------------------------------------------------------------*/
461
462void
464 int a[]);
465
466/*----------------------------------------------------------------------------*/
467/*
468 * \brief Assign the value "num" to all elements of an array. Case of a
469 * int array.
470 *
471 * \param[in] size total number of elements to set
472 * \param[in] num value to set
473 * \param[in, out] a array to set
474 */
475/*----------------------------------------------------------------------------*/
476
477void
479 int num,
480 int a[]);
481
482/*----------------------------------------------------------------------------*/
483/*
484 * \brief Assign the value "num" to an array on a selected subset of elements.
485 * if elt_ids is null, then one recovers the function
486 * \ref cs_array_int_set_value
487 *
488 * \param[in] n_elts number of elements
489 * \param[in] elt_ids list of ids in the subset or null (size: n_elts)
490 * \param[in] num value to set
491 * \param[in, out] a array to set
492 */
493/*----------------------------------------------------------------------------*/
494
495void
497 const cs_lnum_t elt_ids[],
498 int num,
499 int a[]);
500
501/*----------------------------------------------------------------------------*/
502/*
503 * \brief Copy an array ("ref") into another array ("dest") on possibly only a
504 * part of the array(s). Array with stride > 1 are assumed to be
505 * interlaced. The subset of elements on which working is defined by
506 * "elt_ids". The way to apply the subset is defined with the parameter
507 * "mode" as follows:
508 * - Only the "ref" array if mode = 0 (CS_ARRAY_SUBSET_IN)
509 * - Only the "dest" array if mode = 1 (CS_ARRAY_SUBSET_OUT)
510 * - Both "ref" and "dest" arrays if mode = 2 (CS_ARRAY_SUBSET_INOUT)
511 *
512 * It elt_ids is null or mode < 0 (CS_ARRAY_SUBSET_NULL), then the
513 * behavior is as \ref cs_array_real_copy
514 *
515 * One assumes that all arrays are allocated with a correct size.
516 *
517 * \param[in] n_elts number of elements in the array
518 * \param[in] stride number of values for each element
519 * \param[in] mode apply the subset ids to which array(s)
520 * \param[in] elt_ids list of ids in the subset or null (size: n_elts)
521 * \param[in] ref reference values to copy
522 * \param[in, out] dest array storing values after applying the indirection
523 */
524/*----------------------------------------------------------------------------*/
525
526void
528 int stride,
529 const cs_lnum_t elt_ids[],
530 int mode,
531 const cs_real_t ref[],
532 cs_real_t dest[]);
533
534/*----------------------------------------------------------------------------*/
535/*
536 * \brief Copy real values from an array to another of the same dimensions.
537 *
538 * \param[in] size number of elements * dimension
539 * \param[in] src source array values (size: n_elts*dim)
540 * \param[out] dest destination array values (size: n_elts*dim)
541 */
542/*----------------------------------------------------------------------------*/
543
544void
546 const cs_real_t src[],
547 cs_real_t dest[]);
548
549/*----------------------------------------------------------------------------*/
550/*
551 * \brief Multiply each value by a scaling factor s.t. dest *= scaling_factor
552 * If elt_ids is non-null, one applies an indirection.
553 * A stride can also be applied. One assumes an interlaced array.
554 *
555 * \param[in] n_elts number of elements
556 * \param[in] stride number of values for each element
557 * \param[in] elt_ids list of ids in the subset or null (size: n_elts)
558 * \param[in] scaling_factor value of the scaling factor
559 * \param[out] dest destination array values
560 */
561/*----------------------------------------------------------------------------*/
562
563void
565 int stride,
566 const cs_lnum_t *elt_ids,
567 cs_real_t scaling_factor,
568 cs_real_t dest[]);
569
570/*----------------------------------------------------------------------------*/
571/*
572 * \brief Add in place an array s.t. r += l_add
573 *
574 * \param[in] n_elts number of elements
575 * \param[in] l_add array to add
576 * \param[out] r destination array values
577 */
578/*----------------------------------------------------------------------------*/
579
580void
582 const cs_real_t l_add[],
583 cs_real_t r[]);
584
585/*----------------------------------------------------------------------------*/
586/*
587 * \brief Assign a constant value of dim "stride" to an interlaced array
588 * sharing the same stride
589 *
590 * \param[in] n_elts number of elements
591 * \param[in] stride number of values for each element
592 * \param[in] ref_val list of values to assign (size: stride)
593 * \param[in, out] a array to set (size: n_elts*stride)
594 */
595/*----------------------------------------------------------------------------*/
596
597void
599 int stride,
600 const cs_real_t ref_val[],
601 cs_real_t a[]);
602
603/*----------------------------------------------------------------------------*/
604/*
605 * \brief Assign a weighted constant value of dim "stride" to an interlaced
606 * array sharing the same stride. Apply a weight for each element. This
607 * weight is constant for each component of an element.
608 *
609 * \param[in] n_elts number of elements
610 * \param[in] stride number of values for each element
611 * \param[in] ref_val list of values to assign (size: stride)
612 * \param[in] weight values of the weight to apply (size: n_elts)
613 * \param[in, out] a array to set (size: n_elts*stride)
614 */
615/*----------------------------------------------------------------------------*/
616
617void
619 int stride,
620 const cs_real_t ref_val[],
621 const cs_real_t weight[],
622 cs_real_t a[]);
623
624/*----------------------------------------------------------------------------*/
625/*
626 * \brief Assign a constant value of dim "stride" to an interlaced array
627 * sharing the same stride. Only a subset of elements are considered.
628 * If elt_ids is null, then one recovers the function
629 * \ref cs_array_real_set_value
630 *
631 * \param[in] n_elts number of elements
632 * \param[in] stride number of values for each element
633 * \param[in] elt_ids list of ids in the subset or null (size: n_elts)
634 * \param[in] ref_val list of values to assign (size: stride)
635 * \param[in, out] a array to set (size >= n_elts * stride)
636 */
637/*----------------------------------------------------------------------------*/
638
639void
641 int stride,
642 const cs_lnum_t elt_ids[],
643 const cs_real_t ref_val[],
644 cs_real_t a[]);
645
646/*----------------------------------------------------------------------------*/
647/*
648 * \brief Assign a weighted constant value of dim "stride" to an interlaced
649 * array sharing the same stride. Only a subset of elements are
650 * considered. If elt_ids is null, then one recovers the function \ref
651 * cs_array_real_set_wvalue Apply a weight for each element. This
652 * weight is constant for each component of an element.
653 *
654 * \param[in] n_elts number of elements
655 * \param[in] stride number of values for each element
656 * \param[in] elt_ids list of ids in the subset or null (size: n_elts)
657 * \param[in] ref_val list of values to assign (size: stride)
658 * \param[in] weight values of the weight to apply (size >= n_elts)
659 * \param[in, out] a array to set (size >= n_elts*stride)
660 */
661/*----------------------------------------------------------------------------*/
662
663void
665 int stride,
666 const cs_lnum_t elt_ids[],
667 const cs_real_t ref_val[],
668 const cs_real_t weight[],
669 cs_real_t a[]);
670
671/*----------------------------------------------------------------------------*/
672/*
673 * \brief Assign a constant scalar value to an array.
674 *
675 * \param[in] n_elts number of elements
676 * \param[in] ref_val value to assign
677 * \param[in, out] a array to set
678 */
679/*----------------------------------------------------------------------------*/
680
681void
683 cs_real_t ref_val,
684 cs_real_t a[]);
685
686/*----------------------------------------------------------------------------*/
687/*
688 * \brief Assign a weighted constant scalar value to an array.
689 * The weight array has the same size as the array "a".
690 *
691 * \param[in] n_elts number of elements
692 * \param[in] ref_val value to assign
693 * \param[in] weight values of the weight to apply
694 * \param[in, out] a array to set
695 */
696/*----------------------------------------------------------------------------*/
697
698void
700 cs_real_t ref_val,
701 const cs_real_t weight[],
702 cs_real_t a[]);
703
704/*----------------------------------------------------------------------------*/
705/*
706 * \brief Assign a constant scalar value to an array on a selected subset of
707 * elements. If elt_ids is null, then one recovers the function
708 * cs_array_real_set_scalar
709 *
710 * \param[in] n_elts number of elements
711 * \param[in] elt_ids list of ids in the subset or null (size: n_elts)
712 * \param[in] ref_val value to assign
713 * \param[in, out] a array to set
714 */
715/*----------------------------------------------------------------------------*/
716
717void
719 const cs_lnum_t elt_ids[],
720 cs_real_t ref_val,
721 cs_real_t a[]);
722
723/*----------------------------------------------------------------------------*/
724/*
725 * \brief Assign a weighted constant scalar value to an array on a selected
726 * subset of elements. If elt_ids is null, then one recovers the function
727 * cs_array_real_set_wscalar
728 *
729 * \param[in] n_elts number of elements
730 * \param[in] elt_ids list of ids in the subset or null (size: n_elts)
731 * \param[in] ref_val value to assign
732 * \param[in] weight values of weights to apply
733 * \param[in, out] a array to set
734 */
735/*----------------------------------------------------------------------------*/
736
737void
739 const cs_lnum_t elt_ids[],
740 cs_real_t ref_val,
741 const cs_real_t weight[],
742 cs_real_t a[]);
743
744/*----------------------------------------------------------------------------*/
745/*
746 * \brief Assign a constant vector to an array of stride 3 which is interlaced
747 *
748 * \param[in] n_elts number of elements
749 * \param[in] ref_val vector to assign
750 * \param[in, out] a array to set
751 */
752/*----------------------------------------------------------------------------*/
753
754void
756 const cs_real_t ref_val[3],
757 cs_real_t a[]);
758
759/*----------------------------------------------------------------------------*/
760/*
761 * \brief Assign a weighted constant vector value to an interlaced array (of
762 * stride 3). The array of weights has the same size as the array "a".
763 *
764 * \param[in] n_elts number of elements
765 * \param[in] ref_val vector to assign
766 * \param[in] weight values of the weight to apply
767 * \param[in, out] a array to set
768 */
769/*----------------------------------------------------------------------------*/
770
771void
773 const cs_real_t ref_val[3],
774 const cs_real_t weight[],
775 cs_real_t a[]);
776
777/*----------------------------------------------------------------------------*/
778/*
779 * \brief Assign a constant vector to an interlaced array (of stride 3) on a
780 * selected subset of elements. If elt_ids is null, then one recovers the
781 * function cs_array_real_set_vector
782 *
783 * \param[in] n_elts number of elements
784 * \param[in] elt_ids list of ids in the subset or null (size: n_elts)
785 * \param[in] ref_val vector to assign
786 * \param[in, out] a array to set
787 */
788/*----------------------------------------------------------------------------*/
789
790void
792 const cs_lnum_t elt_ids[],
793 const cs_real_t ref_val[3],
794 cs_real_t a[]);
795
796/*----------------------------------------------------------------------------*/
797/*
798 * \brief Assign a weighted constant vector value to an interlaced array (of
799 * stride 3). The subset selection is given by elt_ids. If null, then
800 * one recovers the function \ref cs_array_real_set_wvector
801 * The array of weights has the same size as the array "a".
802 *
803 * \param[in] n_elts number of elements
804 * \param[in] elt_ids list of ids in the subset or null (size: n_elts)
805 * \param[in] ref_val vector to assign
806 * \param[in] weight values of the weight to apply
807 * \param[in, out] a array to set
808 */
809/*----------------------------------------------------------------------------*/
810
811void
813 const cs_lnum_t elt_ids[],
814 const cs_real_t ref_val[3],
815 const cs_real_t weight[],
816 cs_real_t a[]);
817
818/*----------------------------------------------------------------------------*/
819/*
820 * \brief Assign a constant 3x3 tensor to an array (of stride 9) which is
821 * interlaced
822 *
823 * \param[in] n_elts number of elements
824 * \param[in] ref_tens tensor to assign
825 * \param[in, out] a array to set
826 */
827/*----------------------------------------------------------------------------*/
828
829void
831 const cs_real_t ref_tens[3][3],
832 cs_real_t a[]);
833
834/*----------------------------------------------------------------------------*/
835/*
836 * \brief Assign a constant 3x3 tensor to an interlaced array (of stride 9) on
837 * a subset of elements. If elt_ids is null, then one recovers the
838 * function cs_array_real_set_tensor
839 *
840 * \param[in] n_elts number of elements
841 * \param[in] elt_ids list of ids defining the subset or nullptr
842 * \param[in] ref_tens tensor to assign
843 * \param[in, out] a array to set
844 */
845/*----------------------------------------------------------------------------*/
846
847void
849 const cs_lnum_t elt_ids[],
850 const cs_real_t ref_tens[3][3],
851 cs_real_t a[]);
852
853/*----------------------------------------------------------------------------*/
854/*
855 * \brief Assign zero to all elements of an array.
856 *
857 * \param[in] size total number of elements to set to zero
858 * \param[in, out] a array to set
859 */
860/*----------------------------------------------------------------------------*/
861
862void
864 cs_real_t a[]);
865
866/*----------------------------------------------------------------------------*/
867/*
868 * \brief Assign a constant value to an array (deprecated function).
869 *
870 * \param[in] n_elts number of associated elements
871 * \param[in] dim associated dimension
872 * \param[in] v value to assign
873 * \param[out] a array values (size: n_elts*dim)
874 */
875/*----------------------------------------------------------------------------*/
876
877void
879 cs_lnum_t dim,
880 cs_real_t v,
881 cs_real_t a[]);
882
883/*----------------------------------------------------------------------------*/
884
886
887#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.cpp:1019
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.cpp:602
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[])
Assign a constant scalar value to an array on a selected subset of elements. If elt_ids is null,...
Definition: cs_array.cpp:766
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.cpp:1045
void cs_array_bool_fill_false(cs_lnum_t size, bool a[])
Assign false to all elements of an array. Case of an array of booleans.
Definition: cs_array.cpp:106
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.cpp:950
void cs_array_int_fill_zero(cs_lnum_t size, int a[])
Assign zero to all elements of an array. Case of a int array.
Definition: cs_array.cpp:247
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.cpp:830
void cs_array_flag_fill_zero(cs_lnum_t size, cs_flag_t a[])
Assign zero to all elements of an array. Case of a cs_flag_t array.
Definition: cs_array.cpp:124
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[])
Multiply each value by a scaling factor s.t. dest *= scaling_factor If elt_ids is non-null,...
Definition: cs_array.cpp:489
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.cpp:916
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.cpp:336
void cs_array_lnum_fill_zero(cs_lnum_t size, cs_lnum_t a[])
Assign zero to all elements of an array. Case of a cs_lnum_t array.
Definition: cs_array.cpp:146
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[])
Assign the value "num" to an array on a selected subset of elements. if elt_ids is null,...
Definition: cs_array.cpp:222
void cs_array_real_set_scalar(cs_lnum_t n_elts, cs_real_t ref_val, cs_real_t a[])
Assign a constant scalar value to an array.
Definition: cs_array.cpp:720
void cs_array_bool_fill_true(cs_lnum_t size, bool a[])
Assign true to all elements of an array. Case of an array of booleans.
Definition: cs_array.cpp:88
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.cpp:881
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.cpp:641
void cs_array_real_padd(cs_lnum_t n_elts, const cs_real_t l_add[], cs_real_t r[])
Add in place an array s.t. r += l_add.
Definition: cs_array.cpp:541
void cs_array_lnum_copy(cs_lnum_t size, const cs_lnum_t src[], cs_lnum_t dest[])
Copy values from an array of cs_lnum_t type to another of the same dimensions.
Definition: cs_array.cpp:170
void cs_array_real_copy(cs_lnum_t size, const cs_real_t src[], cs_real_t dest[])
Copy real values from an array to another of the same dimensions.
Definition: cs_array.cpp:457
void cs_array_int_set_value(cs_lnum_t size, int num, int a[])
Assign the value "num" to all elements of an array. Case of a int array.
Definition: cs_array.cpp:271
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.cpp:567
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[])
Assign a weighted constant scalar value to an array on a selected subset of elements....
Definition: cs_array.cpp:799
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.cpp:985
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.cpp:854
void cs_array_lnum_set_value(cs_lnum_t size, cs_lnum_t num, cs_lnum_t a[])
Assign the value "num" to all elements of an array. Case of a cs_lnum_t array.
Definition: cs_array.cpp:199
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.cpp:682
void cs_array_int_set_value_on_subset(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], int num, int a[])
Assign the value "num" to an array on a selected subset of elements. if elt_ids is null,...
Definition: cs_array.cpp:294
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[])
Assign a weighted constant scalar value to an array. The weight array has the same size as the array ...
Definition: cs_array.cpp:742
void cs_array_copy(cudaStream_t stream, const cs_lnum_t size, const T *src, T *dest)
Copy values from an array to another of the same dimensions.
Definition: cs_array_cuda.h:212
void cs_arrays_set_value(cudaStream_t stream, const cs_lnum_t n_elts, const T *ref_val, Arrays &&... arrays)
Assign values to all elements of multiple arrays. ref_val is input as a pointer or an array.
Definition: cs_array_cuda.h:120
#define BEGIN_C_DECLS
Definition: cs_defs.h:542
double cs_real_t
Floating-point value.
Definition: cs_defs.h:342
#define END_C_DECLS
Definition: cs_defs.h:543
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:335
unsigned short int cs_flag_t
Definition: cs_defs.h:344
@ k
Definition: cs_field_pointer.h:72
static cs_alloc_mode_t cs_check_device_ptr(const void *ptr)
Check if a pointer is associated with a device.
Definition: cs_mem.h:787
@ CS_ALLOC_HOST_DEVICE_SHARED
Definition: cs_mem.h:57
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:113