8.2
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-2024 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 /*----------------------------------------------------------------------------*/
148 /*----------------------------------------------------------------------------*/
149 
150 void
151 cs_gradient_scalar(const char *var_name,
152  cs_gradient_type_t gradient_type,
153  cs_halo_type_t halo_type,
154  int inc,
155  int n_r_sweeps,
156  int hyd_p_flag,
157  int w_stride,
158  int verbosity,
159  cs_gradient_limit_t clip_mode,
160  double epsilon,
161  double clip_coeff,
162  cs_real_3_t f_ext[],
163  const cs_field_bc_coeffs_t *bc_coeffs,
164  cs_real_t var[restrict],
165  cs_real_t *restrict c_weight,
166  const cs_internal_coupling_t *cpl,
167  cs_real_t grad[restrict][3]);
168 
169 /*----------------------------------------------------------------------------*/
190 /*----------------------------------------------------------------------------*/
191 
192 void
193 cs_gradient_vector(const char *var_name,
194  cs_gradient_type_t gradient_type,
195  cs_halo_type_t halo_type,
196  int inc,
197  int n_r_sweeps,
198  int verbosity,
199  cs_gradient_limit_t clip_mode,
200  double epsilon,
201  double clip_coeff,
202  const cs_field_bc_coeffs_t *bc_coeffs_v,
203  cs_real_t var[restrict][3],
204  cs_real_t *restrict c_weight,
205  const cs_internal_coupling_t *cpl,
206  cs_real_t gradv[restrict][3][3]);
207 
208 /*----------------------------------------------------------------------------*/
227 /*----------------------------------------------------------------------------*/
228 
229 void
230 cs_gradient_tensor(const char *var_name,
231  cs_gradient_type_t gradient_type,
232  cs_halo_type_t halo_type,
233  int inc,
234  int n_r_sweeps,
235  int verbosity,
236  cs_gradient_limit_t clip_mode,
237  double epsilon,
238  double clip_coeff,
239  const cs_field_bc_coeffs_t *bc_coeffs_ts,
240  cs_real_6_t *restrict var,
241  cs_real_63_t *restrict grad);
242 
243 /*----------------------------------------------------------------------------*/
272 /*----------------------------------------------------------------------------*/
273 
274 void
275 cs_gradient_scalar_synced_input(const char *var_name,
276  cs_gradient_type_t gradient_type,
277  cs_halo_type_t halo_type,
278  int inc,
279  int n_r_sweeps,
280  int hyd_p_flag,
281  int w_stride,
282  int verbosity,
283  cs_gradient_limit_t clip_mode,
284  double epsilon,
285  double clip_coeff,
286  cs_real_t f_ext[][3],
287  const cs_field_bc_coeffs_t *bc_coeffs,
288  const cs_real_t var[restrict],
289  const cs_real_t c_weight[restrict],
290  const cs_internal_coupling_t *cpl,
291  cs_real_t grad[restrict][3]);
292 
293 /*----------------------------------------------------------------------------*/
318 /*----------------------------------------------------------------------------*/
319 
320 void
321 cs_gradient_vector_synced_input(const char *var_name,
322  cs_gradient_type_t gradient_type,
323  cs_halo_type_t halo_type,
324  int inc,
325  int n_r_sweeps,
326  int verbosity,
327  cs_gradient_limit_t clip_mode,
328  double epsilon,
329  double clip_coeff,
330  const cs_field_bc_coeffs_t *bc_coeffs_v,
331  const cs_real_t var[restrict][3],
332  const cs_real_t c_weight[restrict],
333  const cs_internal_coupling_t *cpl,
334  cs_real_t grad[restrict][3][3]);
335 
336 /*----------------------------------------------------------------------------*/
359 /*----------------------------------------------------------------------------*/
360 
361 void
362 cs_gradient_tensor_synced_input(const char *var_name,
363  cs_gradient_type_t gradient_type,
364  cs_halo_type_t halo_type,
365  int inc,
366  int n_r_sweeps,
367  int verbosity,
368  cs_gradient_limit_t clip_mode,
369  double epsilon,
370  double clip_coeff,
371  const cs_field_bc_coeffs_t *bc_coeffs_ts,
372  const cs_real_t var[restrict][6],
373  cs_real_63_t *restrict grad);
374 
375 /*----------------------------------------------------------------------------*/
397 /*----------------------------------------------------------------------------*/
398 
399 void
401  const cs_mesh_quantities_t *fvq,
402  cs_lnum_t c_id,
403  cs_halo_type_t halo_type,
404  const cs_field_bc_coeffs_t *bc_coeffs,
405  const cs_real_t var[],
406  const cs_real_t c_weight[],
407  cs_real_t grad[3]);
408 
409 /*----------------------------------------------------------------------------*/
431 /*----------------------------------------------------------------------------*/
432 
433 void
435  const cs_mesh_quantities_t *fvq,
436  cs_lnum_t c_id,
437  cs_halo_type_t halo_type,
438  const cs_field_bc_coeffs_t *bc_coeffs_v,
439  const cs_real_t var[restrict][3],
440  const cs_real_t c_weight[],
441  cs_real_t grad[3][3]);
442 
443 /*----------------------------------------------------------------------------*/
465 /*----------------------------------------------------------------------------*/
466 
467 void
469  const cs_mesh_quantities_t *fvq,
470  cs_lnum_t c_id,
471  cs_halo_type_t halo_type,
472  const cs_field_bc_coeffs_t *bc_coeffs_ts,
473  const cs_real_t var[restrict][6],
474  const cs_real_t c_weight[],
475  cs_real_t grad[6][3]);
476 
477 /*----------------------------------------------------------------------------
478  * Determine gradient type by Fortran "imrgra" value
479  *
480  * parameters:
481  * imrgra <-- Fortran gradient option
482  * gradient_type --> gradient type
483  * halo_type --> halo type
484  *----------------------------------------------------------------------------*/
485 
486 void
488  cs_gradient_type_t *gradient_type,
489  cs_halo_type_t *halo_type);
490 
491 /*----------------------------------------------------------------------------*/
498 /*----------------------------------------------------------------------------*/
499 
500 void
502 
503 /*----------------------------------------------------------------------------*/
504 
506 
507 #endif /* __CS_GRADIENT__ */
#define restrict
Definition: cs_defs.h:141
#define BEGIN_C_DECLS
Definition: cs_defs.h:528
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:347
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:349
#define END_C_DECLS
Definition: cs_defs.h:529
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
cs_real_t cs_real_63_t[6][3]
Definition: cs_defs.h:364
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_field_bc_coeffs_t *bc_coeffs_v, 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.cpp:10077
void cs_gradient_type_by_imrgra(int imrgra, cs_gradient_type_t *gradient_type, cs_halo_type_t *halo_type)
Definition: cs_gradient.cpp:10871
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_field_bc_coeffs_t *bc_coeffs, 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.cpp:10529
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_field_bc_coeffs_t *bc_coeffs, 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.cpp:10268
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_field_bc_coeffs_t *bc_coeffs, 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.cpp:9969
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.cpp:10920
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_field_bc_coeffs_t *bc_coeffs_ts, cs_real_6_t *restrict var, cs_real_63_t *restrict grad)
Compute cell gradient of tensor.
Definition: cs_gradient.cpp:10172
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_field_bc_coeffs_t *bc_coeffs_v, 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.cpp:10798
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_field_bc_coeffs_t *bc_coeffs_ts, const cs_real_t var[restrict][6], cs_real_63_t *restrict grad)
Compute cell gradient of tensor.
Definition: cs_gradient.cpp:10452
void cs_gradient_finalize(void)
Finalize gradient computation API.
Definition: cs_gradient.cpp:9891
void cs_gradient_initialize(void)
Initialize gradient computation API.
Definition: cs_gradient.cpp:9862
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_field_bc_coeffs_t *bc_coeffs_ts, 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.cpp:10842
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_field_bc_coeffs_t *bc_coeffs_v, 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.cpp:10370
void cs_gradient_free_quantities(void)
Free saved gradient quantities.
Definition: cs_gradient.cpp:9926
cs_halo_type_t
Definition: cs_halo.h:56
integer(c_int), pointer, save imrgra
type of gradient reconstruction
Definition: optcal.f90:137
Field boundary condition descriptor (for variables)
Definition: cs_field.h:104
Definition: cs_internal_coupling.h:63
Definition: cs_mesh_quantities.h:92
Definition: cs_mesh.h:85