8.0
general documentation
Loading...
Searching...
No Matches
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"
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
67
68/*----------------------------------------------------------------------------
69 * Gradient limiter mode
70 *----------------------------------------------------------------------------*/
71
84
85/*============================================================================
86 * Global variables
87 *============================================================================*/
88
89/* Short names for gradient types */
90
91extern const char *cs_gradient_type_name[];
92
93/*============================================================================
94 * Public function prototypes for Fortran API
95 *============================================================================*/
96
97/*----------------------------------------------------------------------------
98 * Compute the steady balance due to porous modelling for the pressure
99 * gradient
100 *----------------------------------------------------------------------------*/
101
102void CS_PROCF (grdpor, GRDPOR)
103(
104 const int *const inc /* <-- 0 or 1: increment or not */
105);
106
107/*----------------------------------------------------------------------------
108 * Compute cell gradient of vector field.
109 *----------------------------------------------------------------------------*/
110
111void CS_PROCF (cgdvec, CGDVEC)
112(
113 const int *const f_id, /* <-- field id, or -1 */
114 const int *const imrgra, /* <-- gradient computation mode */
115 const int *const inc, /* <-- 0 or 1: increment or not */
116 const int *const n_r_sweeps,/* <-- >1: with reconstruction */
117 const int *const iwarnp, /* <-- verbosity level */
118 const int *const imligp, /* <-- type of clipping */
119 const cs_real_t *const epsrgp, /* <-- precision for iterative
120 gradient calculation */
121 const cs_real_t *const climgp, /* <-- clipping coefficient */
122 const cs_real_3_t coefav[], /* <-- boundary condition term */
123 const cs_real_33_t coefbv[], /* <-- boundary condition term */
124 cs_real_3_t pvar[], /* <-- gradient's base variable */
125 cs_real_33_t grad[] /* <-> gradient of the variable
126 (du_i/dx_j : gradv[][i][j]) */
127);
128
129/*=============================================================================
130 * Public function prototypes
131 *============================================================================*/
132
133/*----------------------------------------------------------------------------
134 * Initialize gradient computation API.
135 *----------------------------------------------------------------------------*/
136
137void
139
140/*----------------------------------------------------------------------------
141 * Finalize gradient computation API.
142 *----------------------------------------------------------------------------*/
143
144void
146
147/*----------------------------------------------------------------------------*/
154/*----------------------------------------------------------------------------*/
155
156void
158
159/*----------------------------------------------------------------------------*/
185/*----------------------------------------------------------------------------*/
186
187void
188cs_gradient_scalar(const char *var_name,
189 cs_gradient_type_t gradient_type,
190 cs_halo_type_t halo_type,
191 int inc,
192 int n_r_sweeps,
193 int hyd_p_flag,
194 int w_stride,
195 int verbosity,
196 cs_gradient_limit_t clip_mode,
197 double epsilon,
198 double clip_coeff,
199 cs_real_3_t f_ext[],
200 const cs_real_t bc_coeff_a[],
201 const cs_real_t bc_coeff_b[],
202 cs_real_t var[restrict],
203 cs_real_t *restrict c_weight,
204 const cs_internal_coupling_t *cpl,
205 cs_real_t grad[restrict][3]);
206
207/*----------------------------------------------------------------------------*/
229/*----------------------------------------------------------------------------*/
230
231void
232cs_gradient_vector(const char *var_name,
233 cs_gradient_type_t gradient_type,
234 cs_halo_type_t halo_type,
235 int inc,
236 int n_r_sweeps,
237 int verbosity,
238 cs_gradient_limit_t clip_mode,
239 double epsilon,
240 double clip_coeff,
241 const cs_real_t bc_coeff_a[][3],
242 const cs_real_t bc_coeff_b[][3][3],
243 cs_real_t var[restrict][3],
244 cs_real_t *restrict c_weight,
245 const cs_internal_coupling_t *cpl,
246 cs_real_t gradv[restrict][3][3]);
247
248/*----------------------------------------------------------------------------*/
268/*----------------------------------------------------------------------------*/
269
270void
271cs_gradient_tensor(const char *var_name,
272 cs_gradient_type_t gradient_type,
273 cs_halo_type_t halo_type,
274 int inc,
275 int n_r_sweeps,
276 int verbosity,
277 cs_gradient_limit_t clip_mode,
278 double epsilon,
279 double clip_coeff,
280 const cs_real_6_t bc_coeff_a[],
281 const cs_real_66_t bc_coeff_b[],
283 cs_real_63_t *restrict grad);
284
285/*----------------------------------------------------------------------------*/
315/*----------------------------------------------------------------------------*/
316
317void
318cs_gradient_scalar_synced_input(const char *var_name,
319 cs_gradient_type_t gradient_type,
320 cs_halo_type_t halo_type,
321 int inc,
322 int n_r_sweeps,
323 int hyd_p_flag,
324 int w_stride,
325 int verbosity,
326 cs_gradient_limit_t clip_mode,
327 double epsilon,
328 double clip_coeff,
329 cs_real_t f_ext[][3],
330 const cs_real_t bc_coeff_a[],
331 const cs_real_t bc_coeff_b[],
332 const cs_real_t var[restrict],
333 const cs_real_t c_weight[restrict],
334 const cs_internal_coupling_t *cpl,
335 cs_real_t grad[restrict][3]);
336
337/*----------------------------------------------------------------------------*/
363/*----------------------------------------------------------------------------*/
364
365void
366cs_gradient_vector_synced_input(const char *var_name,
367 cs_gradient_type_t gradient_type,
368 cs_halo_type_t halo_type,
369 int inc,
370 int n_r_sweeps,
371 int verbosity,
372 cs_gradient_limit_t clip_mode,
373 double epsilon,
374 double clip_coeff,
375 const cs_real_t bc_coeff_a[][3],
376 const cs_real_t bc_coeff_b[][3][3],
377 const cs_real_t var[restrict][3],
378 const cs_real_t c_weight[restrict],
379 const cs_internal_coupling_t *cpl,
380 cs_real_t grad[restrict][3][3]);
381
382/*----------------------------------------------------------------------------*/
406/*----------------------------------------------------------------------------*/
407
408void
409cs_gradient_tensor_synced_input(const char *var_name,
410 cs_gradient_type_t gradient_type,
411 cs_halo_type_t halo_type,
412 int inc,
413 int n_r_sweeps,
414 int verbosity,
415 cs_gradient_limit_t clip_mode,
416 double epsilon,
417 double clip_coeff,
418 const cs_real_t bc_coeff_a[][6],
419 const cs_real_t bc_coeff_b[][6][6],
420 const cs_real_t var[restrict][6],
421 cs_real_63_t *restrict grad);
422
423/*----------------------------------------------------------------------------*/
446/*----------------------------------------------------------------------------*/
447
448void
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[],
454 const cs_real_t bc_coeff_b[],
455 const cs_real_t var[],
456 const cs_real_t c_weight[],
457 cs_real_t grad[3]);
458
459/*----------------------------------------------------------------------------*/
482/*----------------------------------------------------------------------------*/
483
484void
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[][3],
490 const cs_real_t bc_coeff_b[][3][3],
491 const cs_real_t var[restrict][3],
492 const cs_real_t c_weight[],
493 cs_real_t grad[3][3]);
494
495/*----------------------------------------------------------------------------*/
518/*----------------------------------------------------------------------------*/
519
520void
522 const cs_mesh_quantities_t *fvq,
523 cs_lnum_t c_id,
524 cs_halo_type_t halo_type,
525 const cs_real_t bc_coeff_a[][6],
526 const cs_real_t bc_coeff_b[][6][6],
527 const cs_real_t var[restrict][6],
528 const cs_real_t c_weight[],
529 cs_real_t grad[6][3]);
530
531/*----------------------------------------------------------------------------
532 * Determine gradient type by Fortran "imrgra" value
533 *
534 * parameters:
535 * imrgra <-- Fortran gradient option
536 * gradient_type --> gradient type
537 * halo_type --> halo type
538 *----------------------------------------------------------------------------*/
539
540void
542 cs_gradient_type_t *gradient_type,
543 cs_halo_type_t *halo_type);
544
545/*----------------------------------------------------------------------------*/
552/*----------------------------------------------------------------------------*/
553
554void
556
557/*----------------------------------------------------------------------------*/
558
560
561#endif /* __CS_GRADIENT__ */
#define restrict
Definition cs_defs.h:139
cs_real_t cs_real_66_t[6][6]
6x6 matrix of floating-point values
Definition cs_defs.h:342
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition cs_defs.h:341
#define BEGIN_C_DECLS
Definition cs_defs.h:509
double cs_real_t
Floating-point value.
Definition cs_defs.h:319
#define CS_PROCF(x, y)
Definition cs_defs.h:523
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition cs_defs.h:334
#define END_C_DECLS
Definition cs_defs.h:510
cs_real_t cs_real_63_t[6][3]
Definition cs_defs.h:349
int cs_lnum_t
local mesh entity id
Definition cs_defs.h:313
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition cs_defs.h:332
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.cxx:9098
void grdpor(const int *const inc)
Definition cs_gradient.cxx:9086
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:9686
void cs_gradient_type_by_imrgra(int imrgra, cs_gradient_type_t *gradient_type, cs_halo_type_t *halo_type)
Definition cs_gradient.cxx:10750
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:9479
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:9771
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:10799
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:9581
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:10118
void cs_gradient_finalize(void)
Finalize gradient computation API.
Definition cs_gradient.cxx:9191
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:10443
void cs_gradient_initialize(void)
Initialize gradient computation API.
Definition cs_gradient.cxx:9170
void cs_gradient_free_quantities(void)
Free saved gradient quantities.
Definition cs_gradient.cxx:9226
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:9854
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:9381
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:9270
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:62
Definition cs_mesh_quantities.h:92
Definition cs_mesh.h:85