8.3
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-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 * Local headers
32 *----------------------------------------------------------------------------*/
33
34#include "cs_defs.h"
35#include "cs_mesh.h"
36
37/*----------------------------------------------------------------------------*/
38
39/*=============================================================================
40 * Macro definitions
41 *============================================================================*/
42
43/*============================================================================
44 * Type definitions
45 *============================================================================*/
46
47/*=============================================================================
48 * Public function prototypes
49 *============================================================================*/
50
51#ifdef __cplusplus
52
53/*----------------------------------------------------------------------------*/
54/*
55 * \brief Compute the min./max. of a 1-dimensional array.
56 *
57 * \param[in] n local number of elements
58 * \param[in] v pointer to values (size: n)
59 * \param[out] vmin minimum value
60 * \param[out] vmax maximum value
61 */
62/*----------------------------------------------------------------------------*/
63
64void
66 const cs_real_t v[],
67 cs_real_t &vmin,
68 cs_real_t &vmax);
69
70#endif // __cplusplus
71
72/*----------------------------------------------------------------------------*/
73
75
76/*----------------------------------------------------------------------------
77 * Compute sums of an n-dimensional cs_real_t array's components.
78 *
79 * The maximum allowed dimension is 9 (allowing for a rank-2 tensor).
80 * The array is interleaved.
81 *
82 * For arrays of dimension 3, the statistics relative to the norm
83 * are also computed, and added at the end of the statistics arrays
84 * (which must be size dim+1).
85 *
86 * The algorithm here is similar to that used for BLAS, but computes several
87 * quantities simultaneously for better cache behavior.
88 *
89 * Note that for locations with elements shared across ranks
90 * (such as interior faces and vertices), sums may be incorrect as
91 * contributions from multiple ranks may be counted several times.
92 *
93 * parameters:
94 * n_elts <-- number of local elements
95 * v_elt_list <-- optional list of parent elements on which values
96 * are defined, or NULL
97 * dim <-- local array dimension (max: 9)
98 * v <-- pointer to array values
99 * vsum --> resulting sum array (size: dim, or 4 if dim = 3)
100 *----------------------------------------------------------------------------*/
101
102void
104 int dim,
105 const cs_lnum_t *v_elt_list,
106 const cs_real_t v[],
107 double vsum[]);
108
109/*----------------------------------------------------------------------------*/
136/*----------------------------------------------------------------------------*/
137
138void
140 int dim,
141 const cs_lnum_t *v_elt_list,
142 const cs_lnum_t *w_elt_list,
143 const cs_real_t v[],
144 const cs_real_t w[],
145 double wsum[]);
146
147/*----------------------------------------------------------------------------*/
177/*----------------------------------------------------------------------------*/
178
179void
181 int dim,
182 const cs_lnum_t *v_elt_list,
183 const cs_lnum_t *w_elt_list,
184 const cs_real_t v[],
185 const cs_real_t w[],
186 double wsum[],
187 double wtot[]);
188
189/*----------------------------------------------------------------------------*/
209/*----------------------------------------------------------------------------*/
210
211void
213 int dim,
214 const cs_lnum_t *v_elt_list,
215 const cs_real_t v[],
216 cs_real_t vmin[],
217 cs_real_t vmax[]);
218
219/*----------------------------------------------------------------------------
220 * Compute simple local stats (minima, maxima, sum) of an
221 * n-dimensional cs_real_t array's components.
222 *
223 * The maximum allowed dimension is 9 (allowing for a rank-2 tensor).
224 * The array is interleaved.
225 *
226 * For arrays of dimension 3, the statistics relative to the norm
227 * are also computed, and added at the end of the statistics arrays
228 * (which must be size dim+1).
229 *
230 * The algorithm here is similar to that used for BLAS, but computes several
231 * quantities simultaneously for better cache behavior.
232 *
233 * Note that for locations with elements shared across ranks
234 * (such as interior faces and vertices), sums may be incorrect as
235 * contributions from multiple ranks may be counted several times.
236 *
237 * parameters:
238 * n_elts <-- number of local elements
239 * dim <-- local array dimension (max: 9)
240 * v_elt_list <-- optional list of parent elements on which values
241 * are defined, or NULL
242 * v <-- pointer to array values
243 * vmin --> resulting min array (size: dim, or 4 if dim = 3)
244 * vmax --> resulting max array (size: dim, or 4 if dim = 3)
245 * vsum --> resulting sum array (size: dim, or 4 if dim = 3)
246 *----------------------------------------------------------------------------*/
247
248void
250 int dim,
251 const cs_lnum_t *v_elt_list,
252 const cs_real_t v[],
253 double vmin[],
254 double vmax[],
255 double vsum[]);
256
257/*----------------------------------------------------------------------------*/
288/*----------------------------------------------------------------------------*/
289
290void
292 int dim,
293 const cs_lnum_t *v_elt_list,
294 const cs_lnum_t *w_elt_list,
295 const cs_real_t v[],
296 const cs_real_t w[],
297 double vmin[],
298 double vmax[],
299 double vsum[],
300 double wsum[]);
301
302/*----------------------------------------------------------------------------*/
337/*----------------------------------------------------------------------------*/
338
339void
341 int dim,
342 const cs_lnum_t *v_elt_list,
343 const cs_lnum_t *w_elt_list,
344 const cs_real_t v[],
345 const cs_real_t w[],
346 double vmin[],
347 double vmax[],
348 double vsum[],
349 double wsum[],
350 double asum[],
351 double ssum[],
352 double wssum[]);
353
354/*----------------------------------------------------------------------------*/
384/*----------------------------------------------------------------------------*/
385
386void
388 const cs_lnum_t *src2v_idx,
389 const cs_lnum_t *src2v_ids,
390 const cs_lnum_t *filter_list,
391 int dim,
392 cs_lnum_t n_v_elts,
393 const cs_real_t v[],
394 const cs_real_t w[],
395 double vsum[],
396 double asum[],
397 double ssum[]);
398
399/*----------------------------------------------------------------------------*/
400
402
403#endif /* __CS_ARRAY_REDUCE_H__ */
void cs_array_reduce_minmax(cs_lnum_t n, const cs_real_t v[], cs_real_t &vmin, cs_real_t &vmax)
Compute the min./max. of a 1-dimensional array.
Definition: cs_array_reduce.cpp:3204
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.cpp:3611
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.cpp:3700
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.cpp:3412
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.cpp:3268
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.cpp:3484
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.cpp:3545
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.cpp:3331
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.cpp:3790
#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
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:113