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-2018 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 #if defined(HAVE_MPI)
36 #include <mpi.h>
37 #endif
38 
39 /*----------------------------------------------------------------------------
40  * Local headers
41  *----------------------------------------------------------------------------*/
42 
43 #include "cs_defs.h"
44 #include "cs_mesh.h"
45 
46 /*----------------------------------------------------------------------------*/
47 
49 
50 /*=============================================================================
51  * Macro definitions
52  *============================================================================*/
53 
54 /*============================================================================
55  * Type definitions
56  *============================================================================*/
57 
58 /*=============================================================================
59  * Public function prototypes
60  *============================================================================*/
61 
62 /*----------------------------------------------------------------------------
63  * Compute sums of an n-dimensional cs_real_t array's components.
64  *
65  * The maximum allowed dimension is 9 (allowing for a rank-2 tensor).
66  * The array is interleaved.
67  *
68  * For arrays of dimension 3, the statistics relative to the norm
69  * are also computed, and added at the end of the statistics arrays
70  * (which must be size dim+1).
71  *
72  * The algorithm here is similar to that used for BLAS, but computes several
73  * quantities simultaneously for better cache behavior.
74  *
75  * Note that for locations with elements shared across ranks
76  * (such as interior faces and vertices), sums may be incorrect as
77  * contributions from multiple ranks may be counted several times.
78  *
79  * parameters:
80  * n_elts <-- number of local elements
81  * v_elt_list <-- optional list of parent elements on which values
82  * are defined, or NULL
83  * dim <-- local array dimension (max: 9)
84  * v <-- pointer to array values
85  * vsum --> resulting sum array (size: dim, or 4 if dim = 3)
86  *----------------------------------------------------------------------------*/
87 
88 void
90  int dim,
91  const cs_lnum_t *v_elt_list,
92  const cs_real_t v[],
93  double vsum[]);
94 
95 /*----------------------------------------------------------------------------*/
115 /*----------------------------------------------------------------------------*/
116 
117 void
119  int dim,
120  const cs_lnum_t *v_elt_list,
121  const cs_real_t v[],
122  cs_real_t vmin[],
123  cs_real_t vmax[]);
124 
125 /*----------------------------------------------------------------------------
126  * Compute simple local stats (minima, maxima, sum) of an
127  * n-dimensional cs_real_t array's components.
128  *
129  * The maximum allowed dimension is 9 (allowing for a rank-2 tensor).
130  * The array is interleaved.
131  *
132  * For arrays of dimension 3, the statistics relative to the norm
133  * are also computed, and added at the end of the statistics arrays
134  * (which must be size dim+1).
135  *
136  * The algorithm here is similar to that used for BLAS, but computes several
137  * quantities simultaneously for better cache behavior.
138  *
139  * Note that for locations with elements shared across ranks
140  * (such as interior faces and vertices), sums may be incorrect as
141  * contributions from multiple ranks may be counted several times.
142  *
143  * parameters:
144  * n_elts <-- number of local elements
145  * dim <-- local array dimension (max: 9)
146  * v_elt_list <-- optional list of parent elements on which values
147  * are defined, or NULL
148  * v <-- pointer to array values
149  * vmin --> resulting min array (size: dim, or 4 if dim = 3)
150  * vmax --> resulting max array (size: dim, or 4 if dim = 3)
151  * vsum --> resulting sum array (size: dim, or 4 if dim = 3)
152  *----------------------------------------------------------------------------*/
153 
154 void
156  int dim,
157  const cs_lnum_t *v_elt_list,
158  const cs_real_t v[],
159  double vmin[],
160  double vmax[],
161  double vsum[]);
162 
163 /*----------------------------------------------------------------------------*/
194 /*----------------------------------------------------------------------------*/
195 
196 void
198  int dim,
199  const cs_lnum_t *v_elt_list,
200  const cs_lnum_t *w_elt_list,
201  const cs_real_t v[],
202  const cs_real_t w[],
203  double vmin[],
204  double vmax[],
205  double vsum[],
206  double wsum[]);
207 
208 /*----------------------------------------------------------------------------*/
243 /*----------------------------------------------------------------------------*/
244 
245 void
247  int dim,
248  const cs_lnum_t *v_elt_list,
249  const cs_lnum_t *w_elt_list,
250  const cs_real_t v[],
251  const cs_real_t w[],
252  double vmin[],
253  double vmax[],
254  double vsum[],
255  double wsum[],
256  double asum[],
257  double ssum[],
258  double wssum[]);
259 
260 /*----------------------------------------------------------------------------*/
290 /*----------------------------------------------------------------------------*/
291 
292 void
294  const cs_lnum_t *src2v_idx,
295  const cs_lnum_t *src2v_ids,
296  const cs_lnum_t *filter_list,
297  int dim,
298  cs_lnum_t n_v_elts,
299  const cs_real_t v[],
300  const cs_real_t w[],
301  double vsum[],
302  double asum[],
303  double ssum[]);
304 
305 /*----------------------------------------------------------------------------*/
306 
308 
309 #endif /* __CS_ARRAY_REDUCE_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:451
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&#39;s ...
Definition: cs_array_reduce.c:3018
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:3107
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&#39;s components.
Definition: cs_array_reduce.c:2889
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
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&#39;s components...
Definition: cs_array_reduce.c:2951
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:114
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&#39;s components.
Definition: cs_array_reduce.c:2831
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
#define END_C_DECLS
Definition: cs_defs.h:452
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&#39;s components The wei...
Definition: cs_array_reduce.c:3197