programmer's 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-2015 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 
37 /*----------------------------------------------------------------------------*/
38 
40 
41 /*=============================================================================
42  * Local Macro definitions
43  *============================================================================*/
44 
45 /*============================================================================
46  * Type definition
47  *============================================================================*/
48 
49 /*----------------------------------------------------------------------------
50  * Gradient reconstruction method
51  *----------------------------------------------------------------------------*/
52 
53 typedef enum {
54 
55  CS_GRADIENT_ITER, /* Iterative */
56  CS_GRADIENT_LSQ, /* Least-squares */
57  CS_GRADIENT_LSQ_ITER_OLD, /* LSQ followed by iterative (old) */
58  CS_GRADIENT_ITER_OLD /* Iterative (old) */
59 
61 
62 /*============================================================================
63  * Global variables
64  *============================================================================*/
65 
66 /* Short names for gradient types */
67 
68 extern const char *cs_gradient_type_name[];
69 
70 /*============================================================================
71  * Public function prototypes for Fortran API
72  *============================================================================*/
73 
74 /*----------------------------------------------------------------------------
75  * Compute cell gradient of scalar field or component of vector or
76  * tensor field.
77  *----------------------------------------------------------------------------*/
78 
79 void CS_PROCF (cgdcel, CGDCEL)
80 (
81  const cs_int_t *const f_id, /* <-- field id, or -1 */
82  const cs_int_t *const imrgra, /* <-- gradient computation mode */
83  const cs_int_t *const inc, /* <-- 0 or 1: increment or not */
84  const cs_int_t *const iccocg, /* <-- 1 or 0: recompute COCG or not */
85  const cs_int_t *const n_r_sweeps, /* <-- >1: with reconstruction */
86  const cs_int_t *const idimtr, /* <-- 0, 1, 2: scalar, vector, tensor
87  in case of rotation */
88  const cs_int_t *const iphydp, /* <-- use hydrosatatic pressure */
89  const cs_int_t *const ipond, /* <-- >0: weighted gradient computation*/
90  const cs_int_t *const iwarnp, /* <-- verbosity level */
91  const cs_int_t *const imligp, /* <-- type of clipping */
92  const cs_real_t *const epsrgp, /* <-- precision for iterative gradient
93  calculation */
94  const cs_real_t *const extrap, /* <-- extrapolate gradient at boundary */
95  const cs_real_t *const climgp, /* <-- clipping coefficient */
96  cs_real_3_t f_ext[], /* <-- exterior force generating the
97  hydrostatic pressure */
98  const cs_real_t coefap[], /* <-- boundary condition term */
99  const cs_real_t coefbp[], /* <-- boundary condition term */
100  cs_real_t pvar[], /* <-- gradient's base variable */
101  cs_real_t ktvar[], /* <-- gradient coefficient variable */
102  cs_real_3_t grad[] /* <-> gradient */
103 );
104 
105 /*----------------------------------------------------------------------------
106  * Compute cell gradient of vector field.
107  *----------------------------------------------------------------------------*/
108 
109 void CS_PROCF (cgdvec, CGDVEC)
110 (
111  const cs_int_t *const f_id, /* <-- field id, or -1 */
112  const cs_int_t *const imrgra, /* <-- gradient computation mode */
113  const cs_int_t *const inc, /* <-- 0 or 1: increment or not */
114  const cs_int_t *const n_r_sweeps,/* <-- >1: with reconstruction */
115  const cs_int_t *const iwarnp, /* <-- verbosity level */
116  const cs_int_t *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 gradv[] /* <-> 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 /*----------------------------------------------------------------------------
146  * Compute cell gradient of scalar field or component of vector or
147  * tensor field.
148  *
149  * parameters:
150  * var_name <-- variable name
151  * gradient_type <-- gradient type
152  * halo_type <-- halo type
153  * inc <-- if 0, solve on increment; 1 otherwise
154  * recompute_cocg <-- should COCG FV quantities be recomputed ?
155  * n_r_sweeps <-- if > 1, number of reconstruction sweeps
156  * tr_dim <-- 2 for tensor with periodicity of rotation,
157  * 0 otherwise
158  * hyd_p_flag <-- flag for hydrostatic pressure
159  * verbosity <-- verbosity level
160  * clip_mode <-- clipping mode
161  * epsilon <-- precision for iterative gradient calculation
162  * extrap <-- boundary gradient extrapolation coefficient
163  * clip_coeff <-- clipping coefficient
164  * f_ext <-- exterior force generating the hydrostatic pressure
165  * bc_coeff_a <-- boundary condition term a
166  * bc_coeff_b <-- boundary condition term b
167  * var <-> gradient's base variable
168  * c_weight <-- weighted gradient coefficient variable,
169  * or NULL
170  * grad --> gradient
171  *----------------------------------------------------------------------------*/
172 
173 void
174 cs_gradient_scalar(const char *var_name,
175  cs_gradient_type_t gradient_type,
176  cs_halo_type_t halo_type,
177  int inc,
178  bool recompute_cocg,
179  int n_r_sweeps,
180  int tr_dim,
181  int hyd_p_flag,
182  int verbosity,
183  int clip_mode,
184  double epsilon,
185  double extrap,
186  double clip_coeff,
187  cs_real_3_t f_ext[],
188  const cs_real_t bc_coeff_a[],
189  const cs_real_t bc_coeff_b[],
190  cs_real_t *restrict var,
191  cs_real_t *restrict c_weight,
192  cs_real_3_t *restrict grad);
193 
194 /*----------------------------------------------------------------------------
195  * Compute cell gradient of a vector field.
196  *
197  * parameters:
198  * var_name <-- variable name
199  * gradient_type <-- gradient type
200  * halo_type <-- halo type
201  * inc <-- if 0, solve on increment; 1 otherwise
202  * n_r_sweeps <-- if > 1, number of reconstruction sweeps
203  * verbosity <-- verbosity level
204  * clip_mode <-- clipping mode
205  * epsilon <-- precision for iterative gradient calculation
206  * clip_coeff <-- clipping coefficient
207  * bc_coeff_a <-- boundary condition term a
208  * bc_coeff_b <-- boundary condition term b
209  * var <-> gradient's base variable
210  * gradv --> gradient (du_i/dx_j : gradv[][i][j])
211  *----------------------------------------------------------------------------*/
212 
213 void
214 cs_gradient_vector(const char *var_name,
215  cs_gradient_type_t gradient_type,
216  cs_halo_type_t halo_type,
217  int inc,
218  int n_r_sweeps,
219  int verbosity,
220  int clip_mode,
221  double epsilon,
222  double clip_coeff,
223  const cs_real_3_t bc_coeff_a[],
224  const cs_real_33_t bc_coeff_b[],
225  cs_real_3_t *restrict var,
226  cs_real_33_t *restrict gradv);
227 
228 /*----------------------------------------------------------------------------
229  * Determine gradient type by Fortran "imrgra" value
230  *
231  * parameters:
232  * imrgra <-- Fortran gradient option
233  * gradient_type --> gradient type
234  * halo_type --> halo type
235  *----------------------------------------------------------------------------*/
236 
237 void
239  cs_gradient_type_t *gradient_type,
240  cs_halo_type_t *halo_type);
241 
242 /*----------------------------------------------------------------------------*/
243 
245 
246 #endif /* __CS_GRADIENT__ */
Definition: cs_gradient.h:55
#define restrict
Definition: cs_defs.h:122
Definition: cs_gradient.h:57
void cs_gradient_finalize(void)
Finalize gradient computation API.
Definition: cs_gradient.c:4177
void cs_gradient_type_by_imrgra(int imrgra, cs_gradient_type_t *gradient_type, cs_halo_type_t *halo_type)
Definition: cs_gradient.c:4626
#define BEGIN_C_DECLS
Definition: cs_defs.h:419
int cs_int_t
Fortran-compatible integer.
Definition: cs_defs.h:295
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 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_real_3_t *restrict grad)
Compute cell gradient of scalar field or component of vector or tensor field.
Definition: cs_gradient.c:4228
Definition: cs_gradient.h:58
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_33_t *restrict gradv)
Compute cell gradient of vector field.
Definition: cs_gradient.c:4475
cs_halo_type_t
Definition: cs_halo.h:49
cs_gradient_type_t
Definition: cs_gradient.h:53
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:307
#define END_C_DECLS
Definition: cs_defs.h:420
double cs_real_t
Definition: cs_defs.h:296
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:4100
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:4020
Definition: cs_gradient.h:56
#define CS_PROCF(x, y)
Definition: cs_defs.h:443
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:311
const char * cs_gradient_type_name[]
void cs_gradient_initialize(void)
Initialize gradient computation API.
Definition: cs_gradient.c:4158
integer(c_int), pointer, save imrgra
type of gradient reconstruction
Definition: optcal.f90:276