7.0
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-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_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 
65 
66 /*----------------------------------------------------------------------------
67  * Gradient limiter mode
68  *----------------------------------------------------------------------------*/
69 
70 typedef enum {
71 
82 
83 /*============================================================================
84  * Global variables
85  *============================================================================*/
86 
87 /* Short names for gradient types */
88 
89 extern const char *cs_gradient_type_name[];
90 
91 /*============================================================================
92  * Public function prototypes for Fortran API
93  *============================================================================*/
94 
95 /*----------------------------------------------------------------------------
96  * Compute the steady balance due to porous modelling for the pressure
97  * gradient
98  *----------------------------------------------------------------------------*/
99 
100 void CS_PROCF (grdpor, GRDPOR)
101 (
102  const int *const inc /* <-- 0 or 1: increment or not */
103 );
104 
105 /*----------------------------------------------------------------------------
106  * Compute cell gradient of vector field.
107  *----------------------------------------------------------------------------*/
108 
109 void CS_PROCF (cgdvec, CGDVEC)
110 (
111  const int *const f_id, /* <-- field id, or -1 */
112  const int *const imrgra, /* <-- gradient computation mode */
113  const int *const inc, /* <-- 0 or 1: increment or not */
114  const int *const n_r_sweeps,/* <-- >1: with reconstruction */
115  const int *const iwarnp, /* <-- verbosity level */
116  const int *const imligp, /* <-- type of clipping */
117  const cs_real_t *const epsrgp, /* <-- precision for iterative
118  gradient calculation */
119  const cs_real_t *const climgp, /* <-- clipping coefficient */
120  const cs_real_3_t coefav[], /* <-- boundary condition term */
121  const cs_real_33_t coefbv[], /* <-- boundary condition term */
122  cs_real_3_t pvar[], /* <-- gradient's base variable */
123  cs_real_33_t grad[] /* <-> gradient of the variable
124  (du_i/dx_j : gradv[][i][j]) */
125 );
126 
127 /*=============================================================================
128  * Public function prototypes
129  *============================================================================*/
130 
131 /*----------------------------------------------------------------------------
132  * Initialize gradient computation API.
133  *----------------------------------------------------------------------------*/
134 
135 void
137 
138 /*----------------------------------------------------------------------------
139  * Finalize gradient computation API.
140  *----------------------------------------------------------------------------*/
141 
142 void
144 
145 /*----------------------------------------------------------------------------*/
152 /*----------------------------------------------------------------------------*/
153 
154 void
156 
157 /*----------------------------------------------------------------------------*/
186 /*----------------------------------------------------------------------------*/
187 
188 void
189 cs_gradient_scalar(const char *var_name,
190  cs_gradient_type_t gradient_type,
191  cs_halo_type_t halo_type,
192  int inc,
193  bool recompute_cocg,
194  int n_r_sweeps,
195  int tr_dim,
196  int hyd_p_flag,
197  int w_stride,
198  int verbosity,
199  cs_gradient_limit_t clip_mode,
200  double epsilon,
201  double clip_coeff,
202  cs_real_3_t f_ext[],
203  const cs_real_t bc_coeff_a[],
204  const cs_real_t bc_coeff_b[],
205  cs_real_t var[restrict],
206  cs_real_t *restrict c_weight,
207  const cs_internal_coupling_t *cpl,
208  cs_real_t grad[restrict][3]);
209 
210 /*----------------------------------------------------------------------------*/
232 /*----------------------------------------------------------------------------*/
233 
234 void
235 cs_gradient_vector(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_t bc_coeff_a[][3],
245  const cs_real_t bc_coeff_b[][3][3],
246  cs_real_t var[restrict][3],
247  cs_real_t *restrict c_weight,
248  const cs_internal_coupling_t *cpl,
249  cs_real_t gradv[restrict][3][3]);
250 
251 /*----------------------------------------------------------------------------*/
271 /*----------------------------------------------------------------------------*/
272 
273 void
274 cs_gradient_tensor(const char *var_name,
275  cs_gradient_type_t gradient_type,
276  cs_halo_type_t halo_type,
277  int inc,
278  int n_r_sweeps,
279  int verbosity,
280  cs_gradient_limit_t clip_mode,
281  double epsilon,
282  double clip_coeff,
283  const cs_real_6_t bc_coeff_a[],
284  const cs_real_66_t bc_coeff_b[],
285  cs_real_6_t *restrict var,
286  cs_real_63_t *restrict grad);
287 
288 /*----------------------------------------------------------------------------*/
321 /*----------------------------------------------------------------------------*/
322 
323 void
324 cs_gradient_scalar_synced_input(const char *var_name,
325  cs_gradient_type_t gradient_type,
326  cs_halo_type_t halo_type,
327  int inc,
328  bool recompute_cocg,
329  int n_r_sweeps,
330  int tr_dim,
331  int hyd_p_flag,
332  int w_stride,
333  int verbosity,
334  cs_gradient_limit_t clip_mode,
335  double epsilon,
336  double clip_coeff,
337  cs_real_t f_ext[][3],
338  const cs_real_t bc_coeff_a[],
339  const cs_real_t bc_coeff_b[],
340  const cs_real_t var[restrict],
341  const cs_real_t c_weight[restrict],
342  const cs_internal_coupling_t *cpl,
343  cs_real_t grad[restrict][3]);
344 
345 /*----------------------------------------------------------------------------*/
371 /*----------------------------------------------------------------------------*/
372 
373 void
374 cs_gradient_vector_synced_input(const char *var_name,
375  cs_gradient_type_t gradient_type,
376  cs_halo_type_t halo_type,
377  int inc,
378  int n_r_sweeps,
379  int verbosity,
380  cs_gradient_limit_t clip_mode,
381  double epsilon,
382  double clip_coeff,
383  const cs_real_t bc_coeff_a[][3],
384  const cs_real_t bc_coeff_b[][3][3],
385  const cs_real_t var[restrict][3],
386  const cs_real_t c_weight[restrict],
387  const cs_internal_coupling_t *cpl,
388  cs_real_t grad[restrict][3][3]);
389 
390 /*----------------------------------------------------------------------------*/
414 /*----------------------------------------------------------------------------*/
415 
416 void
417 cs_gradient_tensor_synced_input(const char *var_name,
418  cs_gradient_type_t gradient_type,
419  cs_halo_type_t halo_type,
420  int inc,
421  int n_r_sweeps,
422  int verbosity,
423  cs_gradient_limit_t clip_mode,
424  double epsilon,
425  double clip_coeff,
426  const cs_real_t bc_coeff_a[][6],
427  const cs_real_t bc_coeff_b[][6][6],
428  const cs_real_t var[restrict][6],
429  cs_real_63_t *restrict grad);
430 
431 /*----------------------------------------------------------------------------*/
454 /*----------------------------------------------------------------------------*/
455 
456 void
458  const cs_mesh_quantities_t *fvq,
459  cs_lnum_t c_id,
460  cs_halo_type_t halo_type,
461  const cs_real_t bc_coeff_a[],
462  const cs_real_t bc_coeff_b[],
463  const cs_real_t var[],
464  const cs_real_t c_weight[],
465  cs_real_t grad[3]);
466 
467 /*----------------------------------------------------------------------------*/
490 /*----------------------------------------------------------------------------*/
491 
492 void
494  const cs_mesh_quantities_t *fvq,
495  cs_lnum_t c_id,
496  cs_halo_type_t halo_type,
497  const cs_real_t bc_coeff_a[][3],
498  const cs_real_t bc_coeff_b[][3][3],
499  const cs_real_t var[restrict][3],
500  const cs_real_t c_weight[],
501  cs_real_t grad[3][3]);
502 
503 /*----------------------------------------------------------------------------*/
526 /*----------------------------------------------------------------------------*/
527 
528 void
530  const cs_mesh_quantities_t *fvq,
531  cs_lnum_t c_id,
532  cs_halo_type_t halo_type,
533  const cs_real_t bc_coeff_a[][6],
534  const cs_real_t bc_coeff_b[][6][6],
535  const cs_real_t var[restrict][6],
536  const cs_real_t c_weight[],
537  cs_real_t grad[6][3]);
538 
539 /*----------------------------------------------------------------------------
540  * Determine gradient type by Fortran "imrgra" value
541  *
542  * parameters:
543  * imrgra <-- Fortran gradient option
544  * gradient_type --> gradient type
545  * halo_type --> halo type
546  *----------------------------------------------------------------------------*/
547 
548 void
550  cs_gradient_type_t *gradient_type,
551  cs_halo_type_t *halo_type);
552 
553 /*----------------------------------------------------------------------------*/
554 
556 
557 #endif /* __CS_GRADIENT__ */
void cs_gradient_scalar(const char *var_name, cs_gradient_type_t gradient_type, cs_halo_type_t halo_type, int inc, bool recompute_cocg, int n_r_sweeps, int tr_dim, 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.c:8913
#define restrict
Definition: cs_defs.h:127
void cs_gradient_free_quantities(void)
Free saved gradient quantities.
Definition: cs_gradient.c:8866
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:322
Definition: cs_gradient.h:72
void cs_gradient_finalize(void)
Finalize gradient computation API.
Definition: cs_gradient.c:8831
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.c:9129
Definition: cs_gradient.h:73
cs_real_t cs_real_66_t[6][6]
6x6 matrix of floating-point values
Definition: cs_defs.h:328
void cs_gradient_scalar_synced_input(const char *var_name, cs_gradient_type_t gradient_type, cs_halo_type_t halo_type, int inc, bool recompute_cocg, int n_r_sweeps, int tr_dim, 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.c:9235
void cs_gradient_type_by_imrgra(int imrgra, cs_gradient_type_t *gradient_type, cs_halo_type_t *halo_type)
Definition: cs_gradient.c:10345
Definition: cs_internal_coupling.h:63
#define BEGIN_C_DECLS
Definition: cs_defs.h:495
Definition: cs_gradient.h:76
cs_gradient_limit_t
Definition: cs_gradient.h:70
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.c:9425
double cs_real_t
Floating-point value.
Definition: cs_defs.h:307
Definition: cs_mesh.h:84
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.c:9509
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.c:9763
Definition: cs_gradient.h:58
Definition: cs_gradient.h:62
Definition: cs_gradient.h:60
void grdpor(const int *const inc)
Definition: cs_gradient.c:8556
Definition: cs_mesh_quantities.h:89
cs_halo_type_t
Definition: cs_halo.h:50
cs_gradient_type_t
Definition: cs_gradient.h:56
void cgdvec(const int *const f_id, const int *const imrgra, const int *const inc, const int *const n_r_sweeps, const int *const iwarnp, const int *const imligp, const cs_real_t *const epsrgp, const cs_real_t *const climgp, const cs_real_3_t coefav[], const cs_real_33_t coefbv[], cs_real_3_t pvar[], cs_real_33_t grad[])
Definition: cs_gradient.c:8738
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:320
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:301
#define END_C_DECLS
Definition: cs_defs.h:496
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.c:10063
Definition: cs_gradient.h:59
#define CS_PROCF(x, y)
Definition: cs_defs.h:509
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:327
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.c:9031
cs_real_t cs_real_63_t[6][3]
Definition: cs_defs.h:335
const char * cs_gradient_type_name[]
void cs_gradient_initialize(void)
Initialize gradient computation API.
Definition: cs_gradient.c:8810
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.c:9340
integer(c_int), pointer, save imrgra
type of gradient reconstruction
Definition: optcal.f90:251