7.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-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 /*----------------------------------------------------------------------------*/
185 /*----------------------------------------------------------------------------*/
186 
187 void
188 cs_gradient_scalar(const char *var_name,
189  cs_gradient_type_t gradient_type,
190  cs_halo_type_t halo_type,
191  int inc,
192  bool recompute_cocg,
193  int n_r_sweeps,
194  int tr_dim,
195  int hyd_p_flag,
196  int w_stride,
197  int verbosity,
198  cs_gradient_limit_t clip_mode,
199  double epsilon,
200  double clip_coeff,
201  cs_real_3_t f_ext[],
202  const cs_real_t bc_coeff_a[],
203  const cs_real_t bc_coeff_b[],
204  cs_real_t var[restrict],
205  cs_real_t *restrict c_weight,
206  const cs_internal_coupling_t *cpl,
207  cs_real_t grad[restrict][3]);
208 
209 /*----------------------------------------------------------------------------*/
231 /*----------------------------------------------------------------------------*/
232 
233 void
234 cs_gradient_vector(const char *var_name,
235  cs_gradient_type_t gradient_type,
236  cs_halo_type_t halo_type,
237  int inc,
238  int n_r_sweeps,
239  int verbosity,
240  cs_gradient_limit_t clip_mode,
241  double epsilon,
242  double clip_coeff,
243  const cs_real_t bc_coeff_a[][3],
244  const cs_real_t bc_coeff_b[][3][3],
245  cs_real_t var[restrict][3],
246  cs_real_t *restrict c_weight,
247  const cs_internal_coupling_t *cpl,
248  cs_real_t gradv[restrict][3][3]);
249 
250 /*----------------------------------------------------------------------------*/
270 /*----------------------------------------------------------------------------*/
271 
272 void
273 cs_gradient_tensor(const char *var_name,
274  cs_gradient_type_t gradient_type,
275  cs_halo_type_t halo_type,
276  int inc,
277  int n_r_sweeps,
278  int verbosity,
279  cs_gradient_limit_t clip_mode,
280  double epsilon,
281  double clip_coeff,
282  const cs_real_6_t bc_coeff_a[],
283  const cs_real_66_t bc_coeff_b[],
284  cs_real_6_t *restrict var,
285  cs_real_63_t *restrict grad);
286 
287 /*----------------------------------------------------------------------------*/
318 /*----------------------------------------------------------------------------*/
319 
320 void
321 cs_gradient_scalar_synced_input(const char *var_name,
322  cs_gradient_type_t gradient_type,
323  cs_halo_type_t halo_type,
324  int inc,
325  bool recompute_cocg,
326  int n_r_sweeps,
327  int hyd_p_flag,
328  int w_stride,
329  int verbosity,
330  cs_gradient_limit_t clip_mode,
331  double epsilon,
332  double clip_coeff,
333  cs_real_t f_ext[][3],
334  const cs_real_t bc_coeff_a[],
335  const cs_real_t bc_coeff_b[],
336  const cs_real_t var[restrict],
337  const cs_real_t c_weight[restrict],
338  const cs_internal_coupling_t *cpl,
339  cs_real_t grad[restrict][3]);
340 
341 /*----------------------------------------------------------------------------*/
367 /*----------------------------------------------------------------------------*/
368 
369 void
370 cs_gradient_vector_synced_input(const char *var_name,
371  cs_gradient_type_t gradient_type,
372  cs_halo_type_t halo_type,
373  int inc,
374  int n_r_sweeps,
375  int verbosity,
376  cs_gradient_limit_t clip_mode,
377  double epsilon,
378  double clip_coeff,
379  const cs_real_t bc_coeff_a[][3],
380  const cs_real_t bc_coeff_b[][3][3],
381  const cs_real_t var[restrict][3],
382  const cs_real_t c_weight[restrict],
383  const cs_internal_coupling_t *cpl,
384  cs_real_t grad[restrict][3][3]);
385 
386 /*----------------------------------------------------------------------------*/
410 /*----------------------------------------------------------------------------*/
411 
412 void
413 cs_gradient_tensor_synced_input(const char *var_name,
414  cs_gradient_type_t gradient_type,
415  cs_halo_type_t halo_type,
416  int inc,
417  int n_r_sweeps,
418  int verbosity,
419  cs_gradient_limit_t clip_mode,
420  double epsilon,
421  double clip_coeff,
422  const cs_real_t bc_coeff_a[][6],
423  const cs_real_t bc_coeff_b[][6][6],
424  const cs_real_t var[restrict][6],
425  cs_real_63_t *restrict grad);
426 
427 /*----------------------------------------------------------------------------*/
450 /*----------------------------------------------------------------------------*/
451 
452 void
454  const cs_mesh_quantities_t *fvq,
455  cs_lnum_t c_id,
456  cs_halo_type_t halo_type,
457  const cs_real_t bc_coeff_a[],
458  const cs_real_t bc_coeff_b[],
459  const cs_real_t var[],
460  const cs_real_t c_weight[],
461  cs_real_t grad[3]);
462 
463 /*----------------------------------------------------------------------------*/
486 /*----------------------------------------------------------------------------*/
487 
488 void
490  const cs_mesh_quantities_t *fvq,
491  cs_lnum_t c_id,
492  cs_halo_type_t halo_type,
493  const cs_real_t bc_coeff_a[][3],
494  const cs_real_t bc_coeff_b[][3][3],
495  const cs_real_t var[restrict][3],
496  const cs_real_t c_weight[],
497  cs_real_t grad[3][3]);
498 
499 /*----------------------------------------------------------------------------*/
522 /*----------------------------------------------------------------------------*/
523 
524 void
526  const cs_mesh_quantities_t *fvq,
527  cs_lnum_t c_id,
528  cs_halo_type_t halo_type,
529  const cs_real_t bc_coeff_a[][6],
530  const cs_real_t bc_coeff_b[][6][6],
531  const cs_real_t var[restrict][6],
532  const cs_real_t c_weight[],
533  cs_real_t grad[6][3]);
534 
535 /*----------------------------------------------------------------------------
536  * Determine gradient type by Fortran "imrgra" value
537  *
538  * parameters:
539  * imrgra <-- Fortran gradient option
540  * gradient_type --> gradient type
541  * halo_type --> halo type
542  *----------------------------------------------------------------------------*/
543 
544 void
546  cs_gradient_type_t *gradient_type,
547  cs_halo_type_t *halo_type);
548 
549 /*----------------------------------------------------------------------------*/
556 /*----------------------------------------------------------------------------*/
557 
558 void
560 
561 /*----------------------------------------------------------------------------*/
562 
564 
565 #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:8721
#define restrict
Definition: cs_defs.h:142
void cs_gradient_free_quantities(void)
Free saved gradient quantities.
Definition: cs_gradient.c:8675
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:337
Definition: cs_gradient.h:72
void cs_gradient_finalize(void)
Finalize gradient computation API.
Definition: cs_gradient.c:8640
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:8934
Definition: cs_gradient.h:73
cs_real_t cs_real_66_t[6][6]
6x6 matrix of floating-point values
Definition: cs_defs.h:343
void cs_gradient_type_by_imrgra(int imrgra, cs_gradient_type_t *gradient_type, cs_halo_type_t *halo_type)
Definition: cs_gradient.c:10146
Definition: cs_internal_coupling.h:63
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
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:9226
double cs_real_t
Floating-point value.
Definition: cs_defs.h:322
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 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:9038
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:9310
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:9564
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:8535
Definition: cs_mesh_quantities.h:89
cs_halo_type_t
Definition: cs_halo.h:56
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:8547
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:335
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:316
void cs_gradient_porosity_balance(int inc)
compute the steady balance due to porous modelling for the pressure gradient.
Definition: cs_gradient.c:10192
#define END_C_DECLS
Definition: cs_defs.h:511
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:9864
Definition: cs_gradient.h:59
#define CS_PROCF(x, y)
Definition: cs_defs.h:524
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:342
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:8836
cs_real_t cs_real_63_t[6][3]
Definition: cs_defs.h:350
const char * cs_gradient_type_name[]
void cs_gradient_initialize(void)
Initialize gradient computation API.
Definition: cs_gradient.c:8619
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:9141
integer(c_int), pointer, save imrgra
type of gradient reconstruction
Definition: optcal.f90:260