8.1
general documentation
cs_gradient.h
Go to the documentation of this file.
1 #ifndef __CS_GRADIENT_H__
2 #define __CS_GRADIENT_H__
3 
4 /*============================================================================
5  * Gradient reconstruction.
6  *============================================================================*/
7 
8 /*
9  This file is part of code_saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2023 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_halo.h"
36 #include "cs_internal_coupling.h"
37 #include "cs_mesh.h"
38 #include "cs_mesh_quantities.h"
39 
40 /*----------------------------------------------------------------------------*/
41 
43 
44 /*=============================================================================
45  * Local Macro definitions
46  *============================================================================*/
47 
48 /*============================================================================
49  * Type definition
50  *============================================================================*/
51 
52 /*----------------------------------------------------------------------------
53  * Gradient reconstruction method
54  *----------------------------------------------------------------------------*/
55 
56 typedef enum {
57 
67 
68 /*----------------------------------------------------------------------------
69  * Gradient limiter mode
70  *----------------------------------------------------------------------------*/
71 
72 typedef enum {
73 
84 
85 /*============================================================================
86  * Global variables
87  *============================================================================*/
88 
89 /* Short names for gradient types */
90 
91 extern const char *cs_gradient_type_name[];
92 
93 /*=============================================================================
94  * Public function prototypes
95  *============================================================================*/
96 
97 /*----------------------------------------------------------------------------
98  * Initialize gradient computation API.
99  *----------------------------------------------------------------------------*/
100 
101 void
103 
104 /*----------------------------------------------------------------------------
105  * Finalize gradient computation API.
106  *----------------------------------------------------------------------------*/
107 
108 void
110 
111 /*----------------------------------------------------------------------------*/
118 /*----------------------------------------------------------------------------*/
119 
120 void
122 
123 /*----------------------------------------------------------------------------*/
149 /*----------------------------------------------------------------------------*/
150 
151 void
152 cs_gradient_scalar(const char *var_name,
153  cs_gradient_type_t gradient_type,
154  cs_halo_type_t halo_type,
155  int inc,
156  int n_r_sweeps,
157  int hyd_p_flag,
158  int w_stride,
159  int verbosity,
160  cs_gradient_limit_t clip_mode,
161  double epsilon,
162  double clip_coeff,
163  cs_real_3_t f_ext[],
164  const cs_real_t bc_coeff_a[],
165  const cs_real_t bc_coeff_b[],
166  cs_real_t var[restrict],
167  cs_real_t *restrict c_weight,
168  const cs_internal_coupling_t *cpl,
169  cs_real_t grad[restrict][3]);
170 
171 /*----------------------------------------------------------------------------*/
193 /*----------------------------------------------------------------------------*/
194 
195 void
196 cs_gradient_vector(const char *var_name,
197  cs_gradient_type_t gradient_type,
198  cs_halo_type_t halo_type,
199  int inc,
200  int n_r_sweeps,
201  int verbosity,
202  cs_gradient_limit_t clip_mode,
203  double epsilon,
204  double clip_coeff,
205  const cs_real_t bc_coeff_a[][3],
206  const cs_real_t bc_coeff_b[][3][3],
207  cs_real_t var[restrict][3],
208  cs_real_t *restrict c_weight,
209  const cs_internal_coupling_t *cpl,
210  cs_real_t gradv[restrict][3][3]);
211 
212 /*----------------------------------------------------------------------------*/
232 /*----------------------------------------------------------------------------*/
233 
234 void
235 cs_gradient_tensor(const char *var_name,
236  cs_gradient_type_t gradient_type,
237  cs_halo_type_t halo_type,
238  int inc,
239  int n_r_sweeps,
240  int verbosity,
241  cs_gradient_limit_t clip_mode,
242  double epsilon,
243  double clip_coeff,
244  const cs_real_6_t bc_coeff_a[],
245  const cs_real_66_t bc_coeff_b[],
246  cs_real_6_t *restrict var,
247  cs_real_63_t *restrict grad);
248 
249 /*----------------------------------------------------------------------------*/
279 /*----------------------------------------------------------------------------*/
280 
281 void
282 cs_gradient_scalar_synced_input(const char *var_name,
283  cs_gradient_type_t gradient_type,
284  cs_halo_type_t halo_type,
285  int inc,
286  int n_r_sweeps,
287  int hyd_p_flag,
288  int w_stride,
289  int verbosity,
290  cs_gradient_limit_t clip_mode,
291  double epsilon,
292  double clip_coeff,
293  cs_real_t f_ext[][3],
294  const cs_real_t bc_coeff_a[],
295  const cs_real_t bc_coeff_b[],
296  const cs_real_t var[restrict],
297  const cs_real_t c_weight[restrict],
298  const cs_internal_coupling_t *cpl,
299  cs_real_t grad[restrict][3]);
300 
301 /*----------------------------------------------------------------------------*/
327 /*----------------------------------------------------------------------------*/
328 
329 void
330 cs_gradient_vector_synced_input(const char *var_name,
331  cs_gradient_type_t gradient_type,
332  cs_halo_type_t halo_type,
333  int inc,
334  int n_r_sweeps,
335  int verbosity,
336  cs_gradient_limit_t clip_mode,
337  double epsilon,
338  double clip_coeff,
339  const cs_real_t bc_coeff_a[][3],
340  const cs_real_t bc_coeff_b[][3][3],
341  const cs_real_t var[restrict][3],
342  const cs_real_t c_weight[restrict],
343  const cs_internal_coupling_t *cpl,
344  cs_real_t grad[restrict][3][3]);
345 
346 /*----------------------------------------------------------------------------*/
370 /*----------------------------------------------------------------------------*/
371 
372 void
373 cs_gradient_tensor_synced_input(const char *var_name,
374  cs_gradient_type_t gradient_type,
375  cs_halo_type_t halo_type,
376  int inc,
377  int n_r_sweeps,
378  int verbosity,
379  cs_gradient_limit_t clip_mode,
380  double epsilon,
381  double clip_coeff,
382  const cs_real_t bc_coeff_a[][6],
383  const cs_real_t bc_coeff_b[][6][6],
384  const cs_real_t var[restrict][6],
385  cs_real_63_t *restrict grad);
386 
387 /*----------------------------------------------------------------------------*/
410 /*----------------------------------------------------------------------------*/
411 
412 void
414  const cs_mesh_quantities_t *fvq,
415  cs_lnum_t c_id,
416  cs_halo_type_t halo_type,
417  const cs_real_t bc_coeff_a[],
418  const cs_real_t bc_coeff_b[],
419  const cs_real_t var[],
420  const cs_real_t c_weight[],
421  cs_real_t grad[3]);
422 
423 /*----------------------------------------------------------------------------*/
446 /*----------------------------------------------------------------------------*/
447 
448 void
450  const cs_mesh_quantities_t *fvq,
451  cs_lnum_t c_id,
452  cs_halo_type_t halo_type,
453  const cs_real_t bc_coeff_a[][3],
454  const cs_real_t bc_coeff_b[][3][3],
455  const cs_real_t var[restrict][3],
456  const cs_real_t c_weight[],
457  cs_real_t grad[3][3]);
458 
459 /*----------------------------------------------------------------------------*/
482 /*----------------------------------------------------------------------------*/
483 
484 void
486  const cs_mesh_quantities_t *fvq,
487  cs_lnum_t c_id,
488  cs_halo_type_t halo_type,
489  const cs_real_t bc_coeff_a[][6],
490  const cs_real_t bc_coeff_b[][6][6],
491  const cs_real_t var[restrict][6],
492  const cs_real_t c_weight[],
493  cs_real_t grad[6][3]);
494 
495 /*----------------------------------------------------------------------------
496  * Determine gradient type by Fortran "imrgra" value
497  *
498  * parameters:
499  * imrgra <-- Fortran gradient option
500  * gradient_type --> gradient type
501  * halo_type --> halo type
502  *----------------------------------------------------------------------------*/
503 
504 void
506  cs_gradient_type_t *gradient_type,
507  cs_halo_type_t *halo_type);
508 
509 /*----------------------------------------------------------------------------*/
516 /*----------------------------------------------------------------------------*/
517 
518 void
520 
521 /*----------------------------------------------------------------------------*/
522 
524 
525 #endif /* __CS_GRADIENT__ */
#define restrict
Definition: cs_defs.h:139
#define BEGIN_C_DECLS
Definition: cs_defs.h:514
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
cs_real_t cs_real_66_t[6][6]
6x6 matrix of floating-point values
Definition: cs_defs.h:344
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:334
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:336
#define END_C_DECLS
Definition: cs_defs.h:515
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:313
cs_real_t cs_real_63_t[6][3]
Definition: cs_defs.h:351
void cs_gradient_vector_synced_input(const char *var_name, cs_gradient_type_t gradient_type, cs_halo_type_t halo_type, int inc, int n_r_sweeps, int verbosity, cs_gradient_limit_t clip_mode, double epsilon, double clip_coeff, const cs_real_t bc_coeff_a[][3], const cs_real_t bc_coeff_b[][3][3], const cs_real_t var[restrict][3], const cs_real_t c_weight[restrict], const cs_internal_coupling_t *cpl, cs_real_t grad[restrict][3][3])
Compute cell gradient of vector field.
Definition: cs_gradient.cxx:10370
void cs_gradient_type_by_imrgra(int imrgra, cs_gradient_type_t *gradient_type, cs_halo_type_t *halo_type)
Definition: cs_gradient.cxx:10881
void cs_gradient_tensor(const char *var_name, cs_gradient_type_t gradient_type, cs_halo_type_t halo_type, int inc, int n_r_sweeps, int verbosity, cs_gradient_limit_t clip_mode, double epsilon, double clip_coeff, const cs_real_6_t bc_coeff_a[], const cs_real_66_t bc_coeff_b[], cs_real_6_t *restrict var, cs_real_63_t *restrict grad)
Compute cell gradient of tensor.
Definition: cs_gradient.cxx:10162
void cs_gradient_tensor_synced_input(const char *var_name, cs_gradient_type_t gradient_type, cs_halo_type_t halo_type, int inc, int n_r_sweeps, int verbosity, cs_gradient_limit_t clip_mode, double epsilon, double clip_coeff, const cs_real_t bc_coeff_a[][6], const cs_real_t bc_coeff_b[][6][6], const cs_real_t var[restrict][6], cs_real_63_t *restrict grad)
Compute cell gradient of tensor.
Definition: cs_gradient.cxx:10455
cs_gradient_type_t
Definition: cs_gradient.h:56
@ CS_GRADIENT_LSQ
Definition: cs_gradient.h:59
@ CS_GRADIENT_GREEN_LSQ
Definition: cs_gradient.h:60
@ CS_GRADIENT_GREEN_R
Definition: cs_gradient.h:64
@ CS_GRADIENT_GREEN_ITER
Definition: cs_gradient.h:58
@ CS_GRADIENT_GREEN_VTX
Definition: cs_gradient.h:62
const char * cs_gradient_type_name[]
cs_gradient_limit_t
Definition: cs_gradient.h:72
@ CS_GRADIENT_LIMIT_CELL
Definition: cs_gradient.h:75
@ CS_GRADIENT_LIMIT_NONE
Definition: cs_gradient.h:74
@ CS_GRADIENT_LIMIT_FACE
Definition: cs_gradient.h:78
void cs_gradient_porosity_balance(int inc)
compute the steady balance due to porous modelling for the pressure gradient.
Definition: cs_gradient.cxx:10930
void cs_gradient_scalar_synced_input(const char *var_name, cs_gradient_type_t gradient_type, cs_halo_type_t halo_type, int inc, int n_r_sweeps, int hyd_p_flag, int w_stride, int verbosity, cs_gradient_limit_t clip_mode, double epsilon, double clip_coeff, cs_real_t f_ext[][3], const cs_real_t bc_coeff_a[], const cs_real_t bc_coeff_b[], const cs_real_t var[restrict], const cs_real_t c_weight[restrict], const cs_internal_coupling_t *cpl, cs_real_t grad[restrict][3])
Compute cell gradient of scalar field or component of vector or tensor field.
Definition: cs_gradient.cxx:10265
void cs_gradient_vector_cell(const cs_mesh_t *m, const cs_mesh_quantities_t *fvq, cs_lnum_t c_id, cs_halo_type_t halo_type, const cs_real_t bc_coeff_a[][3], const cs_real_t bc_coeff_b[][3][3], const cs_real_t var[restrict][3], const cs_real_t c_weight[], cs_real_t grad[3][3])
Compute the gradient of a vector field at a given cell using least-squares reconstruction.
Definition: cs_gradient.cxx:10803
void cs_gradient_finalize(void)
Finalize gradient computation API.
Definition: cs_gradient.cxx:9874
void cs_gradient_tensor_cell(const cs_mesh_t *m, const cs_mesh_quantities_t *fvq, cs_lnum_t c_id, cs_halo_type_t halo_type, const cs_real_t bc_coeff_a[][6], const cs_real_t bc_coeff_b[][6][6], const cs_real_t var[restrict][6], const cs_real_t c_weight[], cs_real_t grad[6][3])
Compute the gradient of a tensor field at a given cell using least-squares reconstruction.
Definition: cs_gradient.cxx:10850
void cs_gradient_initialize(void)
Initialize gradient computation API.
Definition: cs_gradient.cxx:9845
void cs_gradient_free_quantities(void)
Free saved gradient quantities.
Definition: cs_gradient.cxx:9909
void cs_gradient_scalar_cell(const cs_mesh_t *m, const cs_mesh_quantities_t *fvq, cs_lnum_t c_id, cs_halo_type_t halo_type, const cs_real_t bc_coeff_a[], const cs_real_t bc_coeff_b[], const cs_real_t var[], const cs_real_t c_weight[], cs_real_t grad[3])
Compute the gradient of a scalar field at a given cell using least-squares reconstruction.
Definition: cs_gradient.cxx:10539
void cs_gradient_vector(const char *var_name, cs_gradient_type_t gradient_type, cs_halo_type_t halo_type, int inc, int n_r_sweeps, int verbosity, cs_gradient_limit_t clip_mode, double epsilon, double clip_coeff, const cs_real_t bc_coeff_a[][3], const cs_real_t bc_coeff_b[][3][3], cs_real_t var[restrict][3], cs_real_t *restrict c_weight, const cs_internal_coupling_t *cpl, cs_real_t gradv[restrict][3][3])
Compute cell gradient of vector field.
Definition: cs_gradient.cxx:10064
void cs_gradient_scalar(const char *var_name, cs_gradient_type_t gradient_type, cs_halo_type_t halo_type, int inc, int n_r_sweeps, int hyd_p_flag, int w_stride, int verbosity, cs_gradient_limit_t clip_mode, double epsilon, double clip_coeff, cs_real_3_t f_ext[], const cs_real_t bc_coeff_a[], const cs_real_t bc_coeff_b[], cs_real_t var[restrict], cs_real_t *restrict c_weight, const cs_internal_coupling_t *cpl, cs_real_t grad[restrict][3])
Compute cell gradient of scalar field or component of vector or tensor field.
Definition: cs_gradient.cxx:9953
cs_halo_type_t
Definition: cs_halo.h:56
integer(c_int), pointer, save imrgra
type of gradient reconstruction
Definition: optcal.f90:137
Definition: cs_internal_coupling.h:63
Definition: cs_mesh_quantities.h:92
Definition: cs_mesh.h:85