8.1
general 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 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  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_defs.h"
35 #include "cs_mesh.h"
36 
37 /*----------------------------------------------------------------------------*/
38 
40 
41 /*=============================================================================
42  * Macro definitions
43  *============================================================================*/
44 
45 /*============================================================================
46  * Type definitions
47  *============================================================================*/
48 
49 /*=============================================================================
50  * Public function prototypes
51  *============================================================================*/
52 
53 /*----------------------------------------------------------------------------
54  * Compute sums of an n-dimensional cs_real_t array's components.
55  *
56  * The maximum allowed dimension is 9 (allowing for a rank-2 tensor).
57  * The array is interleaved.
58  *
59  * For arrays of dimension 3, the statistics relative to the norm
60  * are also computed, and added at the end of the statistics arrays
61  * (which must be size dim+1).
62  *
63  * The algorithm here is similar to that used for BLAS, but computes several
64  * quantities simultaneously for better cache behavior.
65  *
66  * Note that for locations with elements shared across ranks
67  * (such as interior faces and vertices), sums may be incorrect as
68  * contributions from multiple ranks may be counted several times.
69  *
70  * parameters:
71  * n_elts <-- number of local elements
72  * v_elt_list <-- optional list of parent elements on which values
73  * are defined, or NULL
74  * dim <-- local array dimension (max: 9)
75  * v <-- pointer to array values
76  * vsum --> resulting sum array (size: dim, or 4 if dim = 3)
77  *----------------------------------------------------------------------------*/
78 
79 void
81  int dim,
82  const cs_lnum_t *v_elt_list,
83  const cs_real_t v[],
84  double vsum[]);
85 
86 /*----------------------------------------------------------------------------*/
113 /*----------------------------------------------------------------------------*/
114 
115 void
117  int dim,
118  const cs_lnum_t *v_elt_list,
119  const cs_lnum_t *w_elt_list,
120  const cs_real_t v[],
121  const cs_real_t w[],
122  double wsum[]);
123 
124 /*----------------------------------------------------------------------------*/
154 /*----------------------------------------------------------------------------*/
155 
156 void
158  int dim,
159  const cs_lnum_t *v_elt_list,
160  const cs_lnum_t *w_elt_list,
161  const cs_real_t v[],
162  const cs_real_t w[],
163  double wsum[],
164  double wtot[]);
165 
166 /*----------------------------------------------------------------------------*/
186 /*----------------------------------------------------------------------------*/
187 
188 void
190  int dim,
191  const cs_lnum_t *v_elt_list,
192  const cs_real_t v[],
193  cs_real_t vmin[],
194  cs_real_t vmax[]);
195 
196 /*----------------------------------------------------------------------------
197  * Compute simple local stats (minima, maxima, sum) of an
198  * n-dimensional cs_real_t array's components.
199  *
200  * The maximum allowed dimension is 9 (allowing for a rank-2 tensor).
201  * The array is interleaved.
202  *
203  * For arrays of dimension 3, the statistics relative to the norm
204  * are also computed, and added at the end of the statistics arrays
205  * (which must be size dim+1).
206  *
207  * The algorithm here is similar to that used for BLAS, but computes several
208  * quantities simultaneously for better cache behavior.
209  *
210  * Note that for locations with elements shared across ranks
211  * (such as interior faces and vertices), sums may be incorrect as
212  * contributions from multiple ranks may be counted several times.
213  *
214  * parameters:
215  * n_elts <-- number of local elements
216  * dim <-- local array dimension (max: 9)
217  * v_elt_list <-- optional list of parent elements on which values
218  * are defined, or NULL
219  * v <-- pointer to array values
220  * vmin --> resulting min array (size: dim, or 4 if dim = 3)
221  * vmax --> resulting max array (size: dim, or 4 if dim = 3)
222  * vsum --> resulting sum array (size: dim, or 4 if dim = 3)
223  *----------------------------------------------------------------------------*/
224 
225 void
227  int dim,
228  const cs_lnum_t *v_elt_list,
229  const cs_real_t v[],
230  double vmin[],
231  double vmax[],
232  double vsum[]);
233 
234 /*----------------------------------------------------------------------------*/
265 /*----------------------------------------------------------------------------*/
266 
267 void
269  int dim,
270  const cs_lnum_t *v_elt_list,
271  const cs_lnum_t *w_elt_list,
272  const cs_real_t v[],
273  const cs_real_t w[],
274  double vmin[],
275  double vmax[],
276  double vsum[],
277  double wsum[]);
278 
279 /*----------------------------------------------------------------------------*/
314 /*----------------------------------------------------------------------------*/
315 
316 void
318  int dim,
319  const cs_lnum_t *v_elt_list,
320  const cs_lnum_t *w_elt_list,
321  const cs_real_t v[],
322  const cs_real_t w[],
323  double vmin[],
324  double vmax[],
325  double vsum[],
326  double wsum[],
327  double asum[],
328  double ssum[],
329  double wssum[]);
330 
331 /*----------------------------------------------------------------------------*/
361 /*----------------------------------------------------------------------------*/
362 
363 void
365  const cs_lnum_t *src2v_idx,
366  const cs_lnum_t *src2v_ids,
367  const cs_lnum_t *filter_list,
368  int dim,
369  cs_lnum_t n_v_elts,
370  const cs_real_t v[],
371  const cs_real_t w[],
372  double vsum[],
373  double asum[],
374  double ssum[]);
375 
376 /*----------------------------------------------------------------------------*/
377 
379 
380 #endif /* __CS_ARRAY_REDUCE_H__ */
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:3610
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:3699
void cs_array_reduce_wsum_components_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 wsum[], double wtot[])
Compute weighted sums of an n-dimensional cs_real_t array's components. Output is both weighted sum a...
Definition: cs_array_reduce.c:3411
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:3267
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:3483
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:3544
void cs_array_reduce_wsum_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 wsum[])
Compute weighted sums of an n-dimensional cs_real_t array's components.
Definition: cs_array_reduce.c:3330
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:3789
#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
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:114