7.0
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-2021 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 /*----------------------------------------------------------------------------*/
141 /*----------------------------------------------------------------------------*/
142 
143 cs_real_t
145  const cs_adjacency_t *c2x,
146  const cs_real_t *w_c2x);
147 
148 /*----------------------------------------------------------------------------*/
161 /*----------------------------------------------------------------------------*/
162 
163 cs_real_t
165  const cs_adjacency_t *c2x,
166  const cs_real_t *w_c2x);
167 
168 /*----------------------------------------------------------------------------*/
180 /*----------------------------------------------------------------------------*/
181 
182 cs_real_t
184  const cs_real_t *weight,
185  const cs_real_t *array);
186 
187 /*----------------------------------------------------------------------------*/
201 /*----------------------------------------------------------------------------*/
202 
203 cs_real_t
205  const cs_real_t *ref,
206  const cs_adjacency_t *c2x,
207  const cs_real_t *w_c2x);
208 
209 /*----------------------------------------------------------------------------*/
224 /*----------------------------------------------------------------------------*/
225 
226 cs_real_t
228  const cs_real_t *ref,
229  const cs_adjacency_t *c2x,
230  const cs_real_t *w_c2x);
231 
232 /*----------------------------------------------------------------------------*/
248 /*----------------------------------------------------------------------------*/
249 
250 cs_real_t
252  const cs_real_t *ref,
253  const cs_adjacency_t *c2x,
254  const cs_real_t *w_c2x);
255 
256 /*----------------------------------------------------------------------------*/
266 /*----------------------------------------------------------------------------*/
267 
268 void
270  const cs_xdef_t *def,
271  cs_real_t time_eval,
272  cs_real_t retval[]);
273 
274 /*----------------------------------------------------------------------------*/
284 /*----------------------------------------------------------------------------*/
285 
286 void
288  const cs_xdef_t *def,
289  cs_real_t retval[]);
290 
291 /*----------------------------------------------------------------------------*/
302 /*----------------------------------------------------------------------------*/
303 
304 void
306  const cs_real_t time_eval,
307  const cs_lnum_t n_v_selected,
308  const cs_lnum_t *selected_lst,
309  cs_real_t retval[]);
310 
311 /*----------------------------------------------------------------------------*/
322 /*----------------------------------------------------------------------------*/
323 
324 void
326  const cs_real_t time_eval,
327  const cs_lnum_t n_f_selected,
328  const cs_lnum_t *selected_lst,
329  cs_real_t retval[]);
330 
331 /*----------------------------------------------------------------------------*/
340 /*----------------------------------------------------------------------------*/
341 
342 void
344  const cs_real_t time_eval,
345  cs_real_t retval[]);
346 
347 /*----------------------------------------------------------------------------*/
359 /*----------------------------------------------------------------------------*/
360 
361 void
363  const cs_xdef_t *def,
364  cs_real_t vvals[],
365  cs_real_t wvals[]);
366 
367 /*----------------------------------------------------------------------------*/
377 /*----------------------------------------------------------------------------*/
378 
379 void
381  const cs_lnum_t n_v_selected,
382  const cs_lnum_t *selected_lst,
383  cs_real_t retval[]);
384 
385 /*----------------------------------------------------------------------------*/
395 /*----------------------------------------------------------------------------*/
396 
397 void
399  const cs_lnum_t n_f_selected,
400  const cs_lnum_t *selected_lst,
401  cs_real_t retval[]);
402 
403 /*----------------------------------------------------------------------------*/
411 /*----------------------------------------------------------------------------*/
412 
413 void
415  cs_real_t retval[]);
416 
417 /*----------------------------------------------------------------------------*/
427 /*----------------------------------------------------------------------------*/
428 
429 void
431  const cs_lnum_t n_e_selected,
432  const cs_lnum_t *selected_lst,
433  cs_real_t retval[]);
434 
435 /*----------------------------------------------------------------------------*/
445 /*----------------------------------------------------------------------------*/
446 
447 void
449  const cs_lnum_t n_e_selected,
450  const cs_lnum_t *selected_lst,
451  cs_real_t retval[]);
452 
453 /*----------------------------------------------------------------------------*/
464 /*----------------------------------------------------------------------------*/
465 
466 void
468  const cs_real_t time_eval,
469  const cs_lnum_t n_e_selected,
470  const cs_lnum_t *selected_lst,
471  cs_real_t retval[]);
472 
473 /*----------------------------------------------------------------------------*/
482 /*----------------------------------------------------------------------------*/
483 
484 void
486  const cs_lnum_t n_f_selected,
487  const cs_lnum_t *selected_lst,
488  cs_real_t retval[]);
489 
490 /*----------------------------------------------------------------------------*/
501 /*----------------------------------------------------------------------------*/
502 
503 void
505  const cs_real_t time_eval,
506  const cs_lnum_t n_f_selected,
507  const cs_lnum_t *selected_lst,
508  cs_real_t retval[]);
509 
510 /*----------------------------------------------------------------------------*/
517 /*----------------------------------------------------------------------------*/
518 
519 void
521  cs_real_t retval[]);
522 
523 /*----------------------------------------------------------------------------*/
530 /*----------------------------------------------------------------------------*/
531 
532 void
534  cs_real_t retval[]);
535 
536 /*----------------------------------------------------------------------------*/
545 /*----------------------------------------------------------------------------*/
546 
547 void
549  cs_real_t time_eval,
550  cs_real_t retval[]);
551 
552 /*----------------------------------------------------------------------------*/
562 /*----------------------------------------------------------------------------*/
563 
564 cs_real_t
566  const cs_real_t *array_val);
567 
568 /*============================================================================
569  * Inline public function prototypes
570  *============================================================================*/
571 
572 /*----------------------------------------------------------------------------*/
582 /*----------------------------------------------------------------------------*/
583 
584 static inline void
585 cs_evaluate_average_on_faces(const cs_xdef_t *def,
586  cs_real_t time_eval,
587  const cs_lnum_t n_f_selected,
588  const cs_lnum_t *selected_lst,
589  cs_real_t retval[])
590 {
591  /* Sanity checks */
592  assert(def != NULL);
593 
594  switch (def->type) {
595 
596  case CS_XDEF_BY_VALUE:
598  n_f_selected, selected_lst,
599  retval);
600  break;
601 
604  time_eval,
605  n_f_selected, selected_lst,
606  retval);
607  break;
608 
609  default:
610  bft_error(__FILE__, __LINE__, 0, " %s: Case not handled yet.", __func__);
611 
612  }
613 }
614 
615 /*----------------------------------------------------------------------------*/
623 /*----------------------------------------------------------------------------*/
624 
625 static inline void
626 cs_evaluate_average_on_cells(const cs_xdef_t *def,
627  cs_real_t time_eval,
628  cs_real_t retval[])
629 {
630  /* Sanity checks */
631  assert(def != NULL);
632 
633  switch (def->type) {
634 
635  case CS_XDEF_BY_VALUE:
637  break;
638 
640  cs_evaluate_average_on_cells_by_analytic(def, time_eval, retval);
641  break;
642 
643  case CS_XDEF_BY_ARRAY:
645 
646  default:
647  bft_error(__FILE__, __LINE__, 0, " %s: Case not handled yet.", __func__);
648 
649  }
650 }
651 
652 /*----------------------------------------------------------------------------*/
653 
655 
656 #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:3026
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:3099
cs_real_t cs_evaluate_delta_square_wc2x_norm(const cs_real_t *array, const cs_real_t *ref, const cs_adjacency_t *c2x, const cs_real_t *w_c2x)
Compute the norm of the difference of two arrays scanne by the same cs_adjacency_t structure with the...
Definition: cs_evaluate.c:1807
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:3324
Definition: cs_xdef.h:118
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:2408
Definition: cs_mesh_adjacencies.h:67
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:2717
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:2229
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:2103
#define BEGIN_C_DECLS
Definition: cs_defs.h:495
cs_real_t cs_evaluate_delta_3_square_wc2x_rnorm(const cs_real_t *array, const cs_real_t *ref, const cs_adjacency_t *c2x, const cs_real_t *w_c2x)
Compute the relative norm of the difference of two arrays scanned by the same cs_adjacency_t structur...
Definition: cs_evaluate.c:2004
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:1504
Definition: cs_cdo_connect.h:76
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:2803
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:1453
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:307
Definition: cs_cdo_quantities.h:124
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:2894
cs_real_t cs_evaluate_3_square_weighted_norm(cs_lnum_t size, const cs_real_t *weight, const cs_real_t *array)
Compute the weighted L2-norm of the magnitude of vector-valued array. A weight has to be given as par...
Definition: cs_evaluate.c:1724
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:2360
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:2171
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:2277
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:2460
void cs_evaluate_set_shared_pointers(const cs_cdo_quantities_t *quant, const cs_cdo_connect_t *connect)
Set shared pointers to main domain members.
Definition: cs_evaluate.c:1427
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:2537
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:2630
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:3194
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:301
cs_real_t cs_evaluate_delta_square_wc2x_rnorm(const cs_real_t *array, const cs_real_t *ref, const cs_adjacency_t *c2x, const cs_real_t *w_c2x)
Compute the relative norm of the difference of two arrays scanned by the same cs_adjacency_t structur...
Definition: cs_evaluate.c:1899
cs_real_t cs_evaluate_3_square_wc2x_norm(const cs_real_t *array, const cs_adjacency_t *c2x, const cs_real_t *w_c2x)
Compute the weighted L2-norm of an array. The weight is scanned by a cs_adjacency_t structure...
Definition: cs_evaluate.c:1638
#define END_C_DECLS
Definition: cs_defs.h:496
unsigned short int cs_flag_t
Definition: cs_defs.h:309
cs_real_t cs_evaluate_square_wc2x_norm(const cs_real_t *array, const cs_adjacency_t *c2x, const cs_real_t *w_c2x)
Compute the weighted L2-norm of an array. The weight is scanned by a cs_adjacency_t structure The com...
Definition: cs_evaluate.c:1551
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:3153
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:3255