My Project
programmer's documentation
cs_array_reduce.h
Go to the documentation of this file.
1 #ifndef __CS_ARRAY_REDUCE_H__
2 #define __CS_ARRAY_REDUCE_H__
3 
4 /*============================================================================
5  * Common array reduction operations.
6  *============================================================================*/
7 
8 /*
9  This file is part of the Code_Saturne Kernel, element of the
10  Code_Saturne CFD tool.
11 
12  Copyright (C) 1998-2019 EDF S.A., France
13 
14  contact: saturne-support@edf.fr
15 
16  The Code_Saturne Kernel is free software; you can redistribute it
17  and/or modify it under the terms of the GNU General Public License
18  as published by the Free Software Foundation; either version 2 of
19  the License, or (at your option) any later version.
20 
21  The Code_Saturne Kernel is distributed in the hope that it will be
22  useful, but WITHOUT ANY WARRANTY; without even the implied warranty
23  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  GNU General Public License for more details.
25 
26  You should have received a copy of the GNU General Public License
27  along with the Code_Saturne Kernel; if not, write to the
28  Free Software Foundation, Inc.,
29  51 Franklin St, Fifth Floor,
30  Boston, MA 02110-1301 USA
31 */
32 
33 /*----------------------------------------------------------------------------*/
34 
35 /*----------------------------------------------------------------------------
36  * Local headers
37  *----------------------------------------------------------------------------*/
38 
39 #include "cs_defs.h"
40 #include "cs_mesh.h"
41 
42 /*----------------------------------------------------------------------------*/
43 
45 
46 /*=============================================================================
47  * Macro definitions
48  *============================================================================*/
49 
50 /*============================================================================
51  * Type definitions
52  *============================================================================*/
53 
54 /*=============================================================================
55  * Public function prototypes
56  *============================================================================*/
57 
58 /*----------------------------------------------------------------------------
59  * Compute sums of an n-dimensional cs_real_t array's components.
60  *
61  * The maximum allowed dimension is 9 (allowing for a rank-2 tensor).
62  * The array is interleaved.
63  *
64  * For arrays of dimension 3, the statistics relative to the norm
65  * are also computed, and added at the end of the statistics arrays
66  * (which must be size dim+1).
67  *
68  * The algorithm here is similar to that used for BLAS, but computes several
69  * quantities simultaneously for better cache behavior.
70  *
71  * Note that for locations with elements shared across ranks
72  * (such as interior faces and vertices), sums may be incorrect as
73  * contributions from multiple ranks may be counted several times.
74  *
75  * parameters:
76  * n_elts <-- number of local elements
77  * v_elt_list <-- optional list of parent elements on which values
78  * are defined, or NULL
79  * dim <-- local array dimension (max: 9)
80  * v <-- pointer to array values
81  * vsum --> resulting sum array (size: dim, or 4 if dim = 3)
82  *----------------------------------------------------------------------------*/
83 
84 void
86  int dim,
87  const cs_lnum_t *v_elt_list,
88  const cs_real_t v[],
89  double vsum[]);
90 
91 /*----------------------------------------------------------------------------*/
111 /*----------------------------------------------------------------------------*/
112 
113 void
115  int dim,
116  const cs_lnum_t *v_elt_list,
117  const cs_real_t v[],
118  cs_real_t vmin[],
119  cs_real_t vmax[]);
120 
121 /*----------------------------------------------------------------------------
122  * Compute simple local stats (minima, maxima, sum) of an
123  * n-dimensional cs_real_t array's components.
124  *
125  * The maximum allowed dimension is 9 (allowing for a rank-2 tensor).
126  * The array is interleaved.
127  *
128  * For arrays of dimension 3, the statistics relative to the norm
129  * are also computed, and added at the end of the statistics arrays
130  * (which must be size dim+1).
131  *
132  * The algorithm here is similar to that used for BLAS, but computes several
133  * quantities simultaneously for better cache behavior.
134  *
135  * Note that for locations with elements shared across ranks
136  * (such as interior faces and vertices), sums may be incorrect as
137  * contributions from multiple ranks may be counted several times.
138  *
139  * parameters:
140  * n_elts <-- number of local elements
141  * dim <-- local array dimension (max: 9)
142  * v_elt_list <-- optional list of parent elements on which values
143  * are defined, or NULL
144  * v <-- pointer to array values
145  * vmin --> resulting min array (size: dim, or 4 if dim = 3)
146  * vmax --> resulting max array (size: dim, or 4 if dim = 3)
147  * vsum --> resulting sum array (size: dim, or 4 if dim = 3)
148  *----------------------------------------------------------------------------*/
149 
150 void
152  int dim,
153  const cs_lnum_t *v_elt_list,
154  const cs_real_t v[],
155  double vmin[],
156  double vmax[],
157  double vsum[]);
158 
159 /*----------------------------------------------------------------------------*/
190 /*----------------------------------------------------------------------------*/
191 
192 void
194  int dim,
195  const cs_lnum_t *v_elt_list,
196  const cs_lnum_t *w_elt_list,
197  const cs_real_t v[],
198  const cs_real_t w[],
199  double vmin[],
200  double vmax[],
201  double vsum[],
202  double wsum[]);
203 
204 /*----------------------------------------------------------------------------*/
239 /*----------------------------------------------------------------------------*/
240 
241 void
243  int dim,
244  const cs_lnum_t *v_elt_list,
245  const cs_lnum_t *w_elt_list,
246  const cs_real_t v[],
247  const cs_real_t w[],
248  double vmin[],
249  double vmax[],
250  double vsum[],
251  double wsum[],
252  double asum[],
253  double ssum[],
254  double wssum[]);
255 
256 /*----------------------------------------------------------------------------*/
286 /*----------------------------------------------------------------------------*/
287 
288 void
290  const cs_lnum_t *src2v_idx,
291  const cs_lnum_t *src2v_ids,
292  const cs_lnum_t *filter_list,
293  int dim,
294  cs_lnum_t n_v_elts,
295  const cs_real_t v[],
296  const cs_real_t w[],
297  double vsum[],
298  double asum[],
299  double ssum[]);
300 
301 /*----------------------------------------------------------------------------*/
302 
304 
305 #endif /* __CS_ARRAY_REDUCE_H__ */
cs_array_reduce_minmax_l
void cs_array_reduce_minmax_l(cs_lnum_t n_elts, int dim, const cs_lnum_t *v_elt_list, const cs_real_t v[], cs_real_t vmin[], cs_real_t vmax[])
Compute sums of an n-dimensional cs_real_t array's components.
Definition: cs_array_reduce.c:2881
cs_defs.h
cs_array_reduce_simple_stats_l_w
void cs_array_reduce_simple_stats_l_w(cs_lnum_t n_elts, int dim, const cs_lnum_t *v_elt_list, const cs_lnum_t *w_elt_list, const cs_real_t v[], const cs_real_t w[], double vmin[], double vmax[], double vsum[], double wsum[])
Compute simple local stats (minima, maxima, sum, weighted sum) of an n-dimensional cs_real_t array's ...
Definition: cs_array_reduce.c:3010
cs_array_reduce_simple_norms_l
void cs_array_reduce_simple_norms_l(cs_lnum_t n_elts, int dim, const cs_lnum_t *v_elt_list, const cs_lnum_t *w_elt_list, const cs_real_t v[], const cs_real_t w[], double vmin[], double vmax[], double vsum[], double wsum[], double asum[], double ssum[], double wssum[])
Compute simple local stats and norms (minima, maxima, sum, weighted sum, sum of absolute values,...
Definition: cs_array_reduce.c:3099
cs_array_reduce_simple_stats_l
void cs_array_reduce_simple_stats_l(cs_lnum_t n_elts, int dim, const cs_lnum_t *v_elt_list, const cs_real_t v[], double vmin[], double vmax[], double vsum[])
Compute simple local stats (minima, maxima, sum) of an n-dimensional cs_real_t array's components.
Definition: cs_array_reduce.c:2943
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_array_reduce_sum_l
void cs_array_reduce_sum_l(cs_lnum_t n_elts, int dim, const cs_lnum_t *v_elt_list, const cs_real_t v[], double vsum[])
Compute sums of an n-dimensional cs_real_t array's components.
Definition: cs_array_reduce.c:2823
atimbr::v
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:114
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
cs_array_scatter_reduce_norms_l
void cs_array_scatter_reduce_norms_l(cs_lnum_t n_src_elts, const cs_lnum_t *src2v_idx, const cs_lnum_t *src2v_ids, const cs_lnum_t *filter_list, int dim, cs_lnum_t n_v_elts, const cs_real_t v[], const cs_real_t w[], double vsum[], double asum[], double ssum[])
Compute simple local weighted norms (l1, l2) of an n-dimensional cs_real_t array's components The wei...
Definition: cs_array_reduce.c:3189
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_mesh.h
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298