7.2
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-2022 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 /*----------------------------------------------------------------------------*/
106 /*----------------------------------------------------------------------------*/
107 
108 void
110  int dim,
111  const cs_lnum_t *v_elt_list,
112  const cs_real_t v[],
113  cs_real_t vmin[],
114  cs_real_t vmax[]);
115 
116 /*----------------------------------------------------------------------------
117  * Compute simple local stats (minima, maxima, sum) of an
118  * n-dimensional cs_real_t array's components.
119  *
120  * The maximum allowed dimension is 9 (allowing for a rank-2 tensor).
121  * The array is interleaved.
122  *
123  * For arrays of dimension 3, the statistics relative to the norm
124  * are also computed, and added at the end of the statistics arrays
125  * (which must be size dim+1).
126  *
127  * The algorithm here is similar to that used for BLAS, but computes several
128  * quantities simultaneously for better cache behavior.
129  *
130  * Note that for locations with elements shared across ranks
131  * (such as interior faces and vertices), sums may be incorrect as
132  * contributions from multiple ranks may be counted several times.
133  *
134  * parameters:
135  * n_elts <-- number of local elements
136  * dim <-- local array dimension (max: 9)
137  * v_elt_list <-- optional list of parent elements on which values
138  * are defined, or NULL
139  * v <-- pointer to array values
140  * vmin --> resulting min array (size: dim, or 4 if dim = 3)
141  * vmax --> resulting max array (size: dim, or 4 if dim = 3)
142  * vsum --> resulting sum array (size: dim, or 4 if dim = 3)
143  *----------------------------------------------------------------------------*/
144 
145 void
147  int dim,
148  const cs_lnum_t *v_elt_list,
149  const cs_real_t v[],
150  double vmin[],
151  double vmax[],
152  double vsum[]);
153 
154 /*----------------------------------------------------------------------------*/
185 /*----------------------------------------------------------------------------*/
186 
187 void
189  int dim,
190  const cs_lnum_t *v_elt_list,
191  const cs_lnum_t *w_elt_list,
192  const cs_real_t v[],
193  const cs_real_t w[],
194  double vmin[],
195  double vmax[],
196  double vsum[],
197  double wsum[]);
198 
199 /*----------------------------------------------------------------------------*/
234 /*----------------------------------------------------------------------------*/
235 
236 void
238  int dim,
239  const cs_lnum_t *v_elt_list,
240  const cs_lnum_t *w_elt_list,
241  const cs_real_t v[],
242  const cs_real_t w[],
243  double vmin[],
244  double vmax[],
245  double vsum[],
246  double wsum[],
247  double asum[],
248  double ssum[],
249  double wssum[]);
250 
251 /*----------------------------------------------------------------------------*/
281 /*----------------------------------------------------------------------------*/
282 
283 void
285  const cs_lnum_t *src2v_idx,
286  const cs_lnum_t *src2v_ids,
287  const cs_lnum_t *filter_list,
288  int dim,
289  cs_lnum_t n_v_elts,
290  const cs_real_t v[],
291  const cs_real_t w[],
292  double vsum[],
293  double asum[],
294  double ssum[]);
295 
296 /*----------------------------------------------------------------------------*/
297 
299 
300 #endif /* __CS_ARRAY_REDUCE_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
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:2978
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:3067
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:2849
double cs_real_t
Floating-point value.
Definition: cs_defs.h:322
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:2911
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:2791
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:316
#define END_C_DECLS
Definition: cs_defs.h:511
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:3157