7.2
general documentation
cs_evaluate.h
Go to the documentation of this file.
1 #ifndef __CS_EVALUATE_H__
2 #define __CS_EVALUATE_H__
3 
4 /*============================================================================
5  * Functions and structures to deal with evaluation of quantities
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_base.h"
35 #include "cs_cdo_connect.h"
36 #include "cs_cdo_local.h"
37 #include "cs_cdo_quantities.h"
38 #include "cs_xdef.h"
39 
40 /*----------------------------------------------------------------------------*/
41 
43 
44 /*============================================================================
45  * Macro definitions
46  *============================================================================*/
47 
48 /*============================================================================
49  * Type definitions
50  *============================================================================*/
51 
52 /*============================================================================
53  * Public function prototypes
54  *============================================================================*/
55 
56 /*----------------------------------------------------------------------------*/
63 /*----------------------------------------------------------------------------*/
64 
65 void
67  const cs_cdo_connect_t *connect);
68 
69 /*----------------------------------------------------------------------------*/
84 /*----------------------------------------------------------------------------*/
85 
86 void
88  cs_lnum_t n_x,
89  const cs_real_t *array,
90  const cs_real_t *w_x,
91  cs_real_t *min,
92  cs_real_t *max,
93  cs_real_t *wsum,
94  cs_real_t *asum,
95  cs_real_t *ssum);
96 
97 /*----------------------------------------------------------------------------*/
115 /*----------------------------------------------------------------------------*/
116 
117 void
119  cs_lnum_t n_x,
120  const cs_real_t *array,
121  const cs_adjacency_t *c2x,
122  const cs_real_t *w_x,
123  cs_real_t *min,
124  cs_real_t *max,
125  cs_real_t *wsum,
126  cs_real_t *asum,
127  cs_real_t *ssum);
128 
129 /*----------------------------------------------------------------------------*/
139 /*----------------------------------------------------------------------------*/
140 
141 void
143  const cs_xdef_t *def,
144  cs_real_t retval[]);
145 
146 /*----------------------------------------------------------------------------*/
156 /*----------------------------------------------------------------------------*/
157 
158 void
160  const cs_xdef_t *def,
161  cs_real_t time_eval,
162  cs_real_t retval[]);
163 
164 /*----------------------------------------------------------------------------*/
174 /*----------------------------------------------------------------------------*/
175 
176 void
178  const cs_lnum_t n_v_selected,
179  const cs_lnum_t *selected_lst,
180  cs_real_t retval[]);
181 
182 /*----------------------------------------------------------------------------*/
193 /*----------------------------------------------------------------------------*/
194 
195 void
197  const cs_real_t time_eval,
198  const cs_lnum_t n_v_selected,
199  const cs_lnum_t *selected_lst,
200  cs_real_t retval[]);
201 
202 /*----------------------------------------------------------------------------*/
212 /*----------------------------------------------------------------------------*/
213 
214 void
216  const cs_lnum_t n_v_selected,
217  const cs_lnum_t *selected_lst,
218  cs_real_t retval[]);
219 
220 /*----------------------------------------------------------------------------*/
230 /*----------------------------------------------------------------------------*/
231 
232 void
234  const cs_lnum_t n_f_selected,
235  const cs_lnum_t *selected_lst,
236  cs_real_t retval[]);
237 
238 /*----------------------------------------------------------------------------*/
249 /*----------------------------------------------------------------------------*/
250 
251 void
253  const cs_real_t time_eval,
254  const cs_lnum_t n_f_selected,
255  const cs_lnum_t *selected_lst,
256  cs_real_t retval[]);
257 
258 /*----------------------------------------------------------------------------*/
266 /*----------------------------------------------------------------------------*/
267 
268 void
270  cs_real_t retval[]);
271 
272 /*----------------------------------------------------------------------------*/
281 /*----------------------------------------------------------------------------*/
282 
283 void
285  const cs_real_t time_eval,
286  cs_real_t retval[]);
287 
288 /*----------------------------------------------------------------------------*/
296 /*----------------------------------------------------------------------------*/
297 
298 void
300  cs_real_t retval[]);
301 
302 /*----------------------------------------------------------------------------*/
314 /*----------------------------------------------------------------------------*/
315 
316 void
318  const cs_xdef_t *def,
319  cs_real_t vvals[],
320  cs_real_t wvals[]);
321 
322 /*----------------------------------------------------------------------------*/
332 /*----------------------------------------------------------------------------*/
333 
334 void
336  const cs_lnum_t n_e_selected,
337  const cs_lnum_t *selected_lst,
338  cs_real_t retval[]);
339 
340 /*----------------------------------------------------------------------------*/
350 /*----------------------------------------------------------------------------*/
351 
352 void
354  const cs_lnum_t n_e_selected,
355  const cs_lnum_t *selected_lst,
356  cs_real_t retval[]);
357 
358 /*----------------------------------------------------------------------------*/
369 /*----------------------------------------------------------------------------*/
370 
371 void
373  const cs_real_t time_eval,
374  const cs_lnum_t n_e_selected,
375  const cs_lnum_t *selected_lst,
376  cs_real_t retval[]);
377 
378 /*----------------------------------------------------------------------------*/
387 /*----------------------------------------------------------------------------*/
388 
389 void
391  const cs_lnum_t n_f_selected,
392  const cs_lnum_t *selected_lst,
393  cs_real_t retval[]);
394 
395 /*----------------------------------------------------------------------------*/
406 /*----------------------------------------------------------------------------*/
407 
408 void
410  const cs_real_t time_eval,
411  const cs_lnum_t n_f_selected,
412  const cs_lnum_t *selected_lst,
413  cs_real_t retval[]);
414 
415 /*----------------------------------------------------------------------------*/
422 /*----------------------------------------------------------------------------*/
423 
424 void
426  cs_real_t retval[]);
427 
428 /*----------------------------------------------------------------------------*/
435 /*----------------------------------------------------------------------------*/
436 
437 void
439  cs_real_t retval[]);
440 
441 /*----------------------------------------------------------------------------*/
450 /*----------------------------------------------------------------------------*/
451 
452 void
454  cs_real_t time_eval,
455  cs_real_t retval[]);
456 
457 /*----------------------------------------------------------------------------*/
467 /*----------------------------------------------------------------------------*/
468 
469 cs_real_t
471  const cs_real_t *array_val);
472 
473 /*============================================================================
474  * Inline public function prototypes
475  *============================================================================*/
476 
477 /*----------------------------------------------------------------------------*/
487 /*----------------------------------------------------------------------------*/
488 
489 static inline void
491  cs_real_t time_eval,
492  const cs_lnum_t n_f_selected,
493  const cs_lnum_t *selected_lst,
494  cs_real_t retval[])
495 {
496  /* Sanity checks */
497  assert(def != NULL);
498 
499  switch (def->type) {
500 
501  case CS_XDEF_BY_VALUE:
503  n_f_selected, selected_lst,
504  retval);
505  break;
506 
509  time_eval,
510  n_f_selected, selected_lst,
511  retval);
512  break;
513 
514  default:
515  bft_error(__FILE__, __LINE__, 0, " %s: Case not handled yet.", __func__);
516 
517  }
518 }
519 
520 /*----------------------------------------------------------------------------*/
528 /*----------------------------------------------------------------------------*/
529 
530 static inline void
532  cs_real_t time_eval,
533  cs_real_t retval[])
534 {
535  /* Sanity checks */
536  assert(def != NULL);
537 
538  switch (def->type) {
539 
540  case CS_XDEF_BY_VALUE:
542  break;
543 
545  cs_evaluate_average_on_cells_by_analytic(def, time_eval, retval);
546  break;
547 
548  case CS_XDEF_BY_ARRAY:
550 
551  default:
552  bft_error(__FILE__, __LINE__, 0, " %s: Case not handled yet.", __func__);
553 
554  }
555 }
556 
557 /*----------------------------------------------------------------------------*/
558 
560 
561 #endif /* __CS_EVALUATE_H__ */
void cs_evaluate_average_on_faces_by_value(const cs_xdef_t *def, const cs_lnum_t n_f_selected, const cs_lnum_t *selected_lst, cs_real_t retval[])
Evaluate the average of a function on the faces.
Definition: cs_evaluate.c:2563
void cs_evaluate_average_on_faces_by_analytic(const cs_xdef_t *def, const cs_real_t time_eval, const cs_lnum_t n_f_selected, const cs_lnum_t *selected_lst, cs_real_t retval[])
Evaluate the average of a function on the faces. Warning: retval has to be initialize before calling ...
Definition: cs_evaluate.c:2634
cs_real_t cs_evaluate_scal_domain_integral_by_array(cs_flag_t array_loc, const cs_real_t *array_val)
Evaluate the integral over the full computational domain of a quantity defined by an array...
Definition: cs_evaluate.c:2853
Definition: cs_xdef.h:118
static void cs_evaluate_average_on_cells(const cs_xdef_t *def, cs_real_t time_eval, cs_real_t retval[])
Evaluate the average of a function on the cells.
Definition: cs_evaluate.h:531
void cs_evaluate_potential_at_vertices_by_dof_func(const cs_xdef_t *def, const cs_lnum_t n_v_selected, const cs_lnum_t *selected_lst, cs_real_t retval[])
Evaluate the quantity attached to a potential field at vertices when the definition relies on a DoF f...
Definition: cs_evaluate.c:1809
void cs_evaluate_potential_by_qov(cs_flag_t dof_flag, const cs_xdef_t *def, cs_real_t vvals[], cs_real_t wvals[])
Define a value to each DoF in the case of a potential field in order to put a given quantity inside t...
Definition: cs_evaluate.c:2206
Definition: cs_mesh_adjacencies.h:68
void cs_evaluate_circulation_along_edges_by_value(const cs_xdef_t *def, const cs_lnum_t n_e_selected, const cs_lnum_t *selected_lst, cs_real_t retval[])
Evaluate the circulation along a selection of (primal) edges. Circulation is defined thanks to a cons...
Definition: cs_evaluate.c:2259
void cs_evaluate_potential_at_vertices_by_analytic(const cs_xdef_t *def, const cs_real_t time_eval, const cs_lnum_t n_v_selected, const cs_lnum_t *selected_lst, cs_real_t retval[])
Evaluate the quantity attached to a potential field at vertices when the definition relies on an anal...
Definition: cs_evaluate.c:1762
void cs_evaluate_density_by_analytic(cs_flag_t dof_flag, const cs_xdef_t *def, cs_real_t time_eval, cs_real_t retval[])
Compute the value related to each DoF in the case of a density field The value defined by the analyti...
Definition: cs_evaluate.c:1614
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
static void cs_evaluate_average_on_faces(const cs_xdef_t *def, cs_real_t time_eval, const cs_lnum_t n_f_selected, const cs_lnum_t *selected_lst, cs_real_t retval[])
Evaluate the average of a function on the faces.
Definition: cs_evaluate.h:490
void cs_evaluate_scatter_array_reduction(int dim, cs_lnum_t n_x, const cs_real_t *array, const cs_adjacency_t *c2x, const cs_real_t *w_x, cs_real_t *min, cs_real_t *max, cs_real_t *wsum, cs_real_t *asum, cs_real_t *ssum)
Compute reduced quantities for an array attached to either vertex, face or edge DoFs The weight to ap...
Definition: cs_evaluate.c:1509
Definition: cs_cdo_connect.h:61
void cs_evaluate_circulation_along_edges_by_array(const cs_xdef_t *def, const cs_lnum_t n_e_selected, const cs_lnum_t *selected_lst, cs_real_t retval[])
Evaluate the circulation along a selection of (primal) edges. Circulation is defined thanks to an arr...
Definition: cs_evaluate.c:2343
Definition: cs_xdef.h:111
void cs_evaluate_array_reduction(int dim, cs_lnum_t n_x, const cs_real_t *array, const cs_real_t *w_x, cs_real_t *min, cs_real_t *max, cs_real_t *wsum, cs_real_t *asum, cs_real_t *ssum)
Compute reduced quantities for an array of size equal to dim * n_x The computed quantities are synchr...
Definition: cs_evaluate.c:1456
void bft_error(const char *const file_name, const int line_num, const int sys_error_code, const char *const format,...)
Calls the error handler (set by bft_error_handler_set() or default).
Definition: bft_error.c:193
double cs_real_t
Floating-point value.
Definition: cs_defs.h:322
Definition: cs_cdo_quantities.h:132
void cs_evaluate_circulation_along_edges_by_analytic(const cs_xdef_t *def, const cs_real_t time_eval, const cs_lnum_t n_e_selected, const cs_lnum_t *selected_lst, cs_real_t retval[])
Evaluate the circulation along a selection of (primal) edges. Circulation is defined by an analytical...
Definition: cs_evaluate.c:2432
cs_xdef_type_t type
Definition: cs_xdef.h:189
void cs_evaluate_potential_at_cells_by_analytic(const cs_xdef_t *def, const cs_real_t time_eval, cs_real_t retval[])
Evaluate the quantity attached to a potential field at cell centers when the definition relies on an ...
Definition: cs_evaluate.c:2116
void cs_evaluate_density_by_value(cs_flag_t dof_flag, const cs_xdef_t *def, cs_real_t retval[])
Evaluate the quantity defined by a value in the case of a density field for all the degrees of freedo...
Definition: cs_evaluate.c:1557
void cs_evaluate_potential_at_faces_by_analytic(const cs_xdef_t *def, const cs_real_t time_eval, const cs_lnum_t n_f_selected, const cs_lnum_t *selected_lst, cs_real_t retval[])
Evaluate the quantity attached to a potential field at face centers when the definition relies on an ...
Definition: cs_evaluate.c:1946
void cs_evaluate_potential_at_vertices_by_value(const cs_xdef_t *def, const cs_lnum_t n_v_selected, const cs_lnum_t *selected_lst, cs_real_t retval[])
Evaluate a potential field at vertices from a definition by a constant value.
Definition: cs_evaluate.c:1682
Definition: cs_xdef.h:110
void cs_evaluate_potential_at_faces_by_value(const cs_xdef_t *def, const cs_lnum_t n_f_selected, const cs_lnum_t *selected_lst, cs_real_t retval[])
Evaluate a potential field atface centers from a definition by a constant value.
Definition: cs_evaluate.c:1852
void cs_evaluate_potential_at_cells_by_value(const cs_xdef_t *def, cs_real_t retval[])
Evaluate a potential field at cell centers from a definition by value.
Definition: cs_evaluate.c:2031
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:154
void cs_evaluate_average_on_cells_by_array(const cs_xdef_t *def, cs_real_t retval[])
Evaluate the average of a function on the cells.
Definition: cs_evaluate.c:2726
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:316
void cs_evaluate_potential_at_cells_by_dof_func(const cs_xdef_t *def, cs_real_t retval[])
Evaluate the quantity attached to a potential field at cells when the definition relies on a DoF func...
Definition: cs_evaluate.c:2159
#define END_C_DECLS
Definition: cs_defs.h:511
unsigned short int cs_flag_t
Definition: cs_defs.h:324
void cs_evaluate_average_on_cells_by_value(const cs_xdef_t *def, cs_real_t retval[])
Evaluate the average of a function on the cells.
Definition: cs_evaluate.c:2686
void cs_evaluate_init_sharing(const cs_cdo_quantities_t *quant, const cs_cdo_connect_t *connect)
Set shared pointers to main domain members.
Definition: cs_evaluate.c:1429
void cs_evaluate_average_on_cells_by_analytic(const cs_xdef_t *def, cs_real_t time_eval, cs_real_t retval[])
Evaluate the average of a function on the cells Warning: retval has to be initialize before calling t...
Definition: cs_evaluate.c:2785