My Project
programmer's 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-2019 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
38/*----------------------------------------------------------------------------*/
39
41
42/*=============================================================================
43 * Local Macro definitions
44 *============================================================================*/
45
46/*============================================================================
47 * Type definition
48 *============================================================================*/
49
50/*----------------------------------------------------------------------------
51 * Gradient reconstruction method
52 *----------------------------------------------------------------------------*/
53
54typedef enum {
55
56 CS_GRADIENT_ITER, /* Iterative */
57 CS_GRADIENT_LSQ, /* Least-squares */
58 CS_GRADIENT_LSQ_ITER, /* conservative gradient reconstructed
59 with LSQ */
60 CS_GRADIENT_ITER_OLD /* Iterative (old) */
61
63
64/*============================================================================
65 * Global variables
66 *============================================================================*/
67
68/* Short names for gradient types */
69
70extern const char *cs_gradient_type_name[];
71
72/*============================================================================
73 * Public function prototypes for Fortran API
74 *============================================================================*/
75/*----------------------------------------------------------------------------
76 * Compute the steady balance due to porous modelling for the pressure
77 * gradient
78 *----------------------------------------------------------------------------*/
79
80void CS_PROCF (grdpor, GRDPOR)
81(
82 const cs_int_t *const inc /* <-- 0 or 1: increment or not */
83);
84
85/*----------------------------------------------------------------------------
86 * Compute cell gradient of scalar field or component of vector or
87 * tensor field.
88 *----------------------------------------------------------------------------*/
89
90void CS_PROCF (cgdcel, CGDCEL)
91(
92 const cs_int_t *const f_id, /* <-- field id, or -1 */
93 const cs_int_t *const imrgra, /* <-- gradient computation mode */
94 const cs_int_t *const inc, /* <-- 0 or 1: increment or not */
95 const cs_int_t *const iccocg, /* <-- 1 or 0: recompute COCG or not */
96 const cs_int_t *const n_r_sweeps, /* <-- >1: with reconstruction */
97 const cs_int_t *const idimtr, /* <-- 0, 1, 2: scalar, vector, tensor
98 in case of rotation */
99 const cs_int_t *const iphydp, /* <-- use hydrosatatic pressure */
100 const cs_int_t *const ipond, /* <-- >0: weighted gradient computation*/
101 const cs_int_t *const iwarnp, /* <-- verbosity level */
102 const cs_int_t *const imligp, /* <-- type of clipping */
103 const cs_real_t *const epsrgp, /* <-- precision for iterative gradient
104 calculation */
105 const cs_real_t *const extrap, /* <-- extrapolate gradient at boundary */
106 const cs_real_t *const climgp, /* <-- clipping coefficient */
107 cs_real_3_t f_ext[], /* <-- exterior force generating the
108 hydrostatic pressure */
109 const cs_real_t coefap[], /* <-- boundary condition term */
110 const cs_real_t coefbp[], /* <-- boundary condition term */
111 cs_real_t pvar[], /* <-- gradient's base variable */
112 cs_real_t ktvar[], /* <-- gradient coefficient variable */
113 cs_real_3_t grad[] /* <-> gradient */
114);
115
116/*----------------------------------------------------------------------------
117 * Compute cell gradient of vector field.
118 *----------------------------------------------------------------------------*/
119
120void CS_PROCF (cgdvec, CGDVEC)
121(
122 const cs_int_t *const f_id, /* <-- field id, or -1 */
123 const cs_int_t *const imrgra, /* <-- gradient computation mode */
124 const cs_int_t *const inc, /* <-- 0 or 1: increment or not */
125 const cs_int_t *const n_r_sweeps,/* <-- >1: with reconstruction */
126 const cs_int_t *const iwarnp, /* <-- verbosity level */
127 const cs_int_t *const imligp, /* <-- type of clipping */
128 const cs_real_t *const epsrgp, /* <-- precision for iterative
129 gradient calculation */
130 const cs_real_t *const climgp, /* <-- clipping coefficient */
131 const cs_real_3_t coefav[], /* <-- boundary condition term */
132 const cs_real_33_t coefbv[], /* <-- boundary condition term */
133 cs_real_3_t pvar[], /* <-- gradient's base variable */
134 cs_real_33_t gradv[] /* <-> gradient of the variable
135 (du_i/dx_j : gradv[][i][j]) */
136);
137
138/*----------------------------------------------------------------------------
139 * Compute cell gradient of tensor field.
140 *----------------------------------------------------------------------------*/
141
142void CS_PROCF (cgdts, CGDTS)
143(
144 const cs_int_t *const f_id,
145 const cs_int_t *const imrgra, /* <-- gradient computation mode */
146 const cs_int_t *const inc, /* <-- 0 or 1: increment or not */
147 const cs_int_t *const n_r_sweeps, /* <-- >1: with reconstruction */
148 const cs_int_t *const iwarnp, /* <-- verbosity level */
149 const cs_int_t *const imligp, /* <-- type of clipping */
150 const cs_real_t *const epsrgp, /* <-- precision for iterative
151 gradient calculation */
152 const cs_real_t *const climgp, /* <-- clipping coefficient */
153 const cs_real_6_t coefav[], /* <-- boundary condition term */
154 const cs_real_66_t coefbv[], /* <-- boundary condition term */
155
156 cs_real_6_t pvar[], /* <-- gradient's base variable */
157 cs_real_63_t grad[] /* <-> gradient of the variable
158 (du_i/dx_j : gradv[][i][j]) */
159);
160
161/*=============================================================================
162 * Public function prototypes
163 *============================================================================*/
164
165/*----------------------------------------------------------------------------
166 * Initialize gradient computation API.
167 *----------------------------------------------------------------------------*/
168
169void
171
172/*----------------------------------------------------------------------------
173 * Finalize gradient computation API.
174 *----------------------------------------------------------------------------*/
175
176void
178
179/*----------------------------------------------------------------------------
180 * Compute cell gradient of scalar field or component of vector or
181 * tensor field.
182 *
183 * parameters:
184 * var_name <-- variable name
185 * gradient_type <-- gradient type
186 * halo_type <-- halo type
187 * inc <-- if 0, solve on increment; 1 otherwise
188 * recompute_cocg <-- should COCG FV quantities be recomputed ?
189 * n_r_sweeps <-- if > 1, number of reconstruction sweeps
190 * tr_dim <-- 2 for tensor with periodicity of rotation,
191 * 0 otherwise
192 * hyd_p_flag <-- flag for hydrostatic pressure
193 * w_stride <-- stride for weighting coefficient
194 * verbosity <-- verbosity level
195 * clip_mode <-- clipping mode
196 * epsilon <-- precision for iterative gradient calculation
197 * extrap <-- boundary gradient extrapolation coefficient
198 * clip_coeff <-- clipping coefficient
199 * f_ext <-- exterior force generating the hydrostatic pressure
200 * bc_coeff_a <-- boundary condition term a
201 * bc_coeff_b <-- boundary condition term b
202 * var <-> gradient's base variable
203 * c_weight <-> weighted gradient coefficient variable, or NULL
204 * cpl <-> structure associated with internal coupling, or NULL
205 * grad --> gradient
206 *----------------------------------------------------------------------------*/
207
208void
209cs_gradient_scalar(const char *var_name,
210 cs_gradient_type_t gradient_type,
211 cs_halo_type_t halo_type,
212 int inc,
213 bool recompute_cocg,
214 int n_r_sweeps,
215 int tr_dim,
216 int hyd_p_flag,
217 int w_stride,
218 int verbosity,
219 int clip_mode,
220 double epsilon,
221 double extrap,
222 double clip_coeff,
223 cs_real_3_t f_ext[],
224 const cs_real_t bc_coeff_a[],
225 const cs_real_t bc_coeff_b[],
226 cs_real_t *restrict var,
227 cs_real_t *restrict c_weight,
229 cs_real_3_t *restrict grad);
230
231/*----------------------------------------------------------------------------*/
254/*----------------------------------------------------------------------------*/
255
256void
257cs_gradient_vector(const char *var_name,
258 cs_gradient_type_t gradient_type,
259 cs_halo_type_t halo_type,
260 int inc,
261 int n_r_sweeps,
262 int verbosity,
263 int clip_mode,
264 double epsilon,
265 double clip_coeff,
266 const cs_real_3_t bc_coeff_a[],
267 const cs_real_33_t bc_coeff_b[],
269 cs_real_t *restrict c_weight,
271 cs_real_33_t *restrict gradv);
272
273/*----------------------------------------------------------------------------*/
292/*----------------------------------------------------------------------------*/
293
294void
295cs_gradient_tensor(const char *var_name,
296 cs_gradient_type_t gradient_type,
297 cs_halo_type_t halo_type,
298 int inc,
299 int n_r_sweeps,
300 int verbosity,
301 int clip_mode,
302 double epsilon,
303 double clip_coeff,
304 const cs_real_6_t bc_coeff_a[],
305 const cs_real_66_t bc_coeff_b[],
307 cs_real_63_t *restrict grad);
308
309/*----------------------------------------------------------------------------*/
344/*----------------------------------------------------------------------------*/
345
346void
347cs_gradient_scalar_synced_input(const char *var_name,
348 cs_gradient_type_t gradient_type,
349 cs_halo_type_t halo_type,
350 int inc,
351 bool recompute_cocg,
352 int n_r_sweeps,
353 int tr_dim,
354 int hyd_p_flag,
355 int w_stride,
356 int verbosity,
357 int clip_mode,
358 double epsilon,
359 double extrap,
360 double clip_coeff,
361 cs_real_t f_ext[][3],
362 const cs_real_t bc_coeff_a[],
363 const cs_real_t bc_coeff_b[],
364 const cs_real_t var[restrict],
365 const cs_real_t c_weight[restrict],
366 const cs_internal_coupling_t *cpl,
367 cs_real_t grad[restrict][3]);
368
369/*----------------------------------------------------------------------------*/
396/*----------------------------------------------------------------------------*/
397
398void
399cs_gradient_vector_synced_input(const char *var_name,
400 cs_gradient_type_t gradient_type,
401 cs_halo_type_t halo_type,
402 int inc,
403 int n_r_sweeps,
404 int verbosity,
405 int clip_mode,
406 double epsilon,
407 double clip_coeff,
408 const cs_real_t bc_coeff_a[][3],
409 const cs_real_t bc_coeff_b[][3][3],
410 const cs_real_t var[restrict][3],
411 const cs_real_t c_weight[restrict],
412 const cs_internal_coupling_t *cpl,
413 cs_real_33_t *restrict gradv);
414
415/*----------------------------------------------------------------------------*/
434/*----------------------------------------------------------------------------*/
435
436void
437cs_gradient_tensor_synced_input(const char *var_name,
438 cs_gradient_type_t gradient_type,
439 cs_halo_type_t halo_type,
440 int inc,
441 int n_r_sweeps,
442 int verbosity,
443 int clip_mode,
444 double epsilon,
445 double clip_coeff,
446 const cs_real_t bc_coeff_a[][6],
447 const cs_real_t bc_coeff_b[][6][6],
448 const cs_real_t var[restrict][6],
449 cs_real_63_t *restrict grad);
450
451/*----------------------------------------------------------------------------
452 * Determine gradient type by Fortran "imrgra" value
453 *
454 * parameters:
455 * imrgra <-- Fortran gradient option
456 * gradient_type --> gradient type
457 * halo_type --> halo type
458 *----------------------------------------------------------------------------*/
459
460void
462 cs_gradient_type_t *gradient_type,
463 cs_halo_type_t *halo_type);
464
465/*----------------------------------------------------------------------------*/
466
468
469#endif /* __CS_GRADIENT__ */
#define restrict
Definition cs_defs.h:127
#define BEGIN_C_DECLS
Definition cs_defs.h:467
double cs_real_t
Floating-point value.
Definition cs_defs.h:302
int cs_int_t
Fortran-compatible integer.
Definition cs_defs.h:301
#define CS_PROCF(x, y)
Definition cs_defs.h:481
cs_real_t cs_real_66_t[6][6]
6x6 matrix of floating-point values
Definition cs_defs.h:322
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition cs_defs.h:315
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition cs_defs.h:317
#define END_C_DECLS
Definition cs_defs.h:468
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition cs_defs.h:321
cs_real_t cs_real_63_t[6][3]
Definition cs_defs.h:327
void cgdcel(const cs_int_t *const f_id, const cs_int_t *const imrgra, const cs_int_t *const inc, const cs_int_t *const iccocg, const cs_int_t *const n_r_sweeps, const cs_int_t *const idimtr, const cs_int_t *const iphydp, const cs_int_t *const ipond, const cs_int_t *const iwarnp, const cs_int_t *const imligp, const cs_real_t *const epsrgp, const cs_real_t *const extrap, const cs_real_t *const climgp, cs_real_3_t f_ext[], const cs_real_t coefap[], const cs_real_t coefbp[], cs_real_t pvar[], cs_real_t ktvar[], cs_real_3_t grad[])
Definition cs_gradient.c:7131
void grdpor(const cs_int_t *const inc)
Definition cs_gradient.c:6951
void cgdvec(const cs_int_t *const f_id, const cs_int_t *const imrgra, const cs_int_t *const inc, const cs_int_t *const n_r_sweeps, const cs_int_t *const iwarnp, const cs_int_t *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 gradv[])
Definition cs_gradient.c:7220
void cs_gradient_type_by_imrgra(int imrgra, cs_gradient_type_t *gradient_type, cs_halo_type_t *halo_type)
Definition cs_gradient.c:8000
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, int 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:7936
void cgdts(const cs_int_t *const f_id, const cs_int_t *const imrgra, const cs_int_t *const inc, const cs_int_t *const n_r_sweeps, const cs_int_t *const iwarnp, const cs_int_t *const imligp, const cs_real_t *const epsrgp, const cs_real_t *const climgp, const cs_real_6_t coefav[], const cs_real_66_t coefbv[], cs_real_6_t pvar[], cs_real_63_t grad[])
Definition cs_gradient.c:7286
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, int 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_33_t *restrict gradv)
Compute cell gradient of vector field.
Definition cs_gradient.c:7856
cs_gradient_type_t
Definition cs_gradient.h:54
@ CS_GRADIENT_ITER_OLD
Definition cs_gradient.h:60
@ CS_GRADIENT_LSQ
Definition cs_gradient.h:57
@ CS_GRADIENT_LSQ_ITER
Definition cs_gradient.h:58
@ CS_GRADIENT_ITER
Definition cs_gradient.h:56
const char * cs_gradient_type_name[]
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, int clip_mode, double epsilon, double clip_coeff, const cs_real_3_t bc_coeff_a[], const cs_real_33_t bc_coeff_b[], cs_real_3_t *restrict var, cs_real_t *restrict c_weight, cs_internal_coupling_t *cpl, cs_real_33_t *restrict gradv)
Compute cell gradient of vector field.
Definition cs_gradient.c:7547
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, int clip_mode, double epsilon, double extrap, 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:7748
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, int 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:7644
void cs_gradient_finalize(void)
Finalize gradient computation API.
Definition cs_gradient.c:7366
void cs_gradient_initialize(void)
Initialize gradient computation API.
Definition cs_gradient.c:7345
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, int clip_mode, double epsilon, double extrap, 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 *restrict var, cs_real_t *restrict c_weight, cs_internal_coupling_t *cpl, cs_real_3_t *restrict grad)
Compute cell gradient of scalar field or component of vector or tensor field.
Definition cs_gradient.c:7425
cs_halo_type_t
Definition cs_halo.h:50
integer(c_int), pointer, save imrgra
type of gradient reconstruction
Definition optcal.f90:286
Definition cs_internal_coupling.h:62