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-2016 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 ivar, /* <-- variable number */
82  const cs_int_t *const imrgra, /* <-- gradient computation mode */
83  const cs_int_t *const ilved, /* <-- 1: interleaved; 0: non-interl. */
84  const cs_int_t *const inc, /* <-- 0 or 1: increment or not */
85  const cs_int_t *const iccocg, /* <-- 1 or 0: recompute COCG or not */
86  const cs_int_t *const n_r_sweeps, /* <-- >1: with reconstruction */
87  const cs_int_t *const idimtr, /* <-- 0, 1, 2: scalar, vector, tensor
88  in case of rotation */
89  const cs_int_t *const iphydp, /* <-- use hydrosatatic pressure */
90  const cs_int_t *const ipond, /* <-- >0: weighted gradient computation*/
91  const cs_int_t *const iwarnp, /* <-- verbosity level */
92  const cs_int_t *const imligp, /* <-- type of clipping */
93  const cs_real_t *const epsrgp, /* <-- precision for iterative gradient
94  calculation */
95  const cs_real_t *const extrap, /* <-- extrapolate gradient at boundary */
96  const cs_real_t *const climgp, /* <-- clipping coefficient */
97  cs_real_3_t f_ext[], /* <-- exterior force generating the
98  hydrostatic pressure */
99  const cs_real_t coefap[], /* <-- boundary condition term */
100  const cs_real_t coefbp[], /* <-- boundary condition term */
101  cs_real_t pvar[], /* <-- gradient's base variable */
102  cs_real_t ktvar[], /* <-- gradient coefficient variable */
103  cs_real_t grdini[] /* <-> gradient (interleaved or not) */
104 );
105 
106 /*----------------------------------------------------------------------------
107  * Compute cell gradient of vector field.
108  *----------------------------------------------------------------------------*/
109 
110 void CS_PROCF (cgdvec, CGDVEC)
111 (
112  const cs_int_t *const ivar,
113  const cs_int_t *const imrgra, /* <-- gradient computation mode */
114  const cs_int_t *const inc, /* <-- 0 or 1: increment or not */
115  const cs_int_t *const n_r_sweeps,/* <-- >1: with reconstruction */
116  const cs_int_t *const iwarnp, /* <-- verbosity level */
117  const cs_int_t *const imligp, /* <-- type of clipping */
118  const cs_real_t *const epsrgp, /* <-- precision for iterative
119  gradient calculation */
120  const cs_real_t *const climgp, /* <-- clipping coefficient */
121  const cs_real_3_t coefav[], /* <-- boundary condition term */
122  const cs_real_33_t coefbv[], /* <-- boundary condition term */
123  cs_real_3_t pvar[], /* <-- gradient's base variable */
124  cs_real_33_t gradv[] /* <-> gradient of the variable
125  (du_i/dx_j : gradv[][i][j]) */
126 );
127 
128 /*=============================================================================
129  * Public function prototypes
130  *============================================================================*/
131 
132 /*----------------------------------------------------------------------------
133  * Initialize gradient computation API.
134  *----------------------------------------------------------------------------*/
135 
136 void
138 
139 /*----------------------------------------------------------------------------
140  * Finalize gradient computation API.
141  *----------------------------------------------------------------------------*/
142 
143 void
145 
146 /*----------------------------------------------------------------------------
147  * Compute cell gradient of scalar field or component of vector or
148  * tensor field.
149  *
150  * parameters:
151  * var_name <-- variable name
152  * gradient_type <-- gradient type
153  * halo_type <-- halo type
154  * inc <-- if 0, solve on increment; 1 otherwise
155  * recompute_cocg <-- should COCG FV quantities be recomputed ?
156  * n_r_sweeps <-- if > 1, number of reconstruction sweeps
157  * tr_dim <-- 2 for tensor with periodicity of rotation,
158  * 0 otherwise
159  * hyd_p_flag <-- flag for hydrostatic pressure
160  * verbosity <-- verbosity level
161  * clip_mode <-- clipping mode
162  * epsilon <-- precision for iterative gradient calculation
163  * extrap <-- boundary gradient extrapolation coefficient
164  * clip_coeff <-- clipping coefficient
165  * f_ext <-- exterior force generating the hydrostatic pressure
166  * bc_coeff_a <-- boundary condition term a
167  * bc_coeff_b <-- boundary condition term b
168  * var <-> gradient's base variable
169  * c_weight <-- weighted gradient coefficient variable,
170  * or NULL
171  * grad --> gradient
172  *----------------------------------------------------------------------------*/
173 
174 void
175 cs_gradient_scalar(const char *var_name,
176  cs_gradient_type_t gradient_type,
177  cs_halo_type_t halo_type,
178  int inc,
179  bool recompute_cocg,
180  int n_r_sweeps,
181  int tr_dim,
182  int hyd_p_flag,
183  int verbosity,
184  int clip_mode,
185  double epsilon,
186  double extrap,
187  double clip_coeff,
188  cs_real_3_t f_ext[],
189  const cs_real_t bc_coeff_a[],
190  const cs_real_t bc_coeff_b[],
191  cs_real_t *restrict var,
192  cs_real_t *restrict c_weight,
193  cs_real_3_t *restrict grad);
194 
195 /*----------------------------------------------------------------------------
196  * Compute cell gradient of a vector field.
197  *
198  * parameters:
199  * var_name <-- variable name
200  * gradient_type <-- gradient type
201  * halo_type <-- halo type
202  * inc <-- if 0, solve on increment; 1 otherwise
203  * n_r_sweeps <-- if > 1, number of reconstruction sweeps
204  * verbosity <-- verbosity level
205  * clip_mode <-- clipping mode
206  * epsilon <-- precision for iterative gradient calculation
207  * clip_coeff <-- clipping coefficient
208  * bc_coeff_a <-- boundary condition term a
209  * bc_coeff_b <-- boundary condition term b
210  * var <-> gradient's base variable
211  * gradv --> gradient (du_i/dx_j : gradv[][i][j])
212  *----------------------------------------------------------------------------*/
213 
214 void
215 cs_gradient_vector(const char *var_name,
216  cs_gradient_type_t gradient_type,
217  cs_halo_type_t halo_type,
218  int inc,
219  int n_r_sweeps,
220  int verbosity,
221  int clip_mode,
222  double epsilon,
223  double clip_coeff,
224  const cs_real_3_t bc_coeff_a[],
225  const cs_real_33_t bc_coeff_b[],
226  cs_real_3_t *restrict var,
227  cs_real_33_t *restrict gradv);
228 
229 /*----------------------------------------------------------------------------
230  * Determine gradient type by Fortran "imrgra" value
231  *
232  * parameters:
233  * imrgra <-- Fortran gradient option
234  * gradient_type --> gradient type
235  * halo_type --> halo type
236  *----------------------------------------------------------------------------*/
237 
238 void
240  cs_gradient_type_t *gradient_type,
241  cs_halo_type_t *halo_type);
242 
243 /*----------------------------------------------------------------------------*/
244 
246 
247 #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:4207
void cs_gradient_type_by_imrgra(int imrgra, cs_gradient_type_t *gradient_type, cs_halo_type_t *halo_type)
Definition: cs_gradient.c:4652
#define BEGIN_C_DECLS
Definition: cs_defs.h:419
int cs_int_t
Fortran-compatible integer.
Definition: cs_defs.h:295
void cgdcel(const cs_int_t *const ivar, const cs_int_t *const imrgra, const cs_int_t *const ilved, 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_t grdini[])
Definition: cs_gradient.c:4031
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:4258
Definition: cs_gradient.h:58
void cgdvec(const cs_int_t *const ivar, 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:4141
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:4501
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
Definition: cs_gradient.h:56
#define CS_PROCF(x, y)
Definition: cs_defs.h:433
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:4195
integer(c_int), pointer, save imrgra
type of gradient reconstruction
Definition: optcal.f90:276