programmer's documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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-2014 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, /* LSQ followed with iterative */
58  CS_GRADIENT_ITER_OLD, /* Iterative (old)*/
59  CS_GRADIENT_LSQ_OLD, /* Least-squares (old)*/
60  CS_GRADIENT_LSQ_ITER_OLD /* LSQ followed with iterative (old)*/
61 
63 
64 /*============================================================================
65  * Global variables
66  *============================================================================*/
67 
68 /* Short names for gradient types */
69 
70 extern const char *cs_gradient_type_name[];
71 
72 /*============================================================================
73  * Public function prototypes for Fortran API
74  *============================================================================*/
75 
76 /*----------------------------------------------------------------------------
77  * Compute cell gradient of scalar field or component of vector or
78  * tensor field.
79  *----------------------------------------------------------------------------*/
80 
81 void CS_PROCF (cgdcel, CGDCEL)
82 (
83  const cs_int_t *const ivar, /* <-- variable number */
84  const cs_int_t *const imrgra, /* <-- gradient computation mode */
85  const cs_int_t *const ilved, /* <-- 1: interleaved; 0: non-interl. */
86  const cs_int_t *const inc, /* <-- 0 or 1: increment or not */
87  const cs_int_t *const iccocg, /* <-- 1 or 0: recompute COCG or not */
88  const cs_int_t *const n_r_sweeps, /* <-- >1: with reconstruction */
89  const cs_int_t *const idimtr, /* <-- 0, 1, 2: scalar, vector, tensor
90  in case of rotation */
91  const cs_int_t *const iphydp, /* <-- use hydrosatatic pressure */
92  const cs_int_t *const ipond, /* <-- >0: weighted gradient computation*/
93  const cs_int_t *const iwarnp, /* <-- verbosity level */
94  const cs_int_t *const imligp, /* <-- type of clipping */
95  const cs_real_t *const epsrgp, /* <-- precision for iterative gradient
96  calculation */
97  const cs_real_t *const extrap, /* <-- extrapolate gradient at boundary */
98  const cs_real_t *const climgp, /* <-- clipping coefficient */
99  cs_real_3_t f_ext[], /* <-- exterior force generating the
100  hydrostatic pressure */
101  const cs_real_t coefap[], /* <-- boundary condition term */
102  const cs_real_t coefbp[], /* <-- boundary condition term */
103  cs_real_t pvar[], /* <-- gradient's base variable */
104  cs_real_t ktvar[], /* <-- gradient coefficient variable */
105  cs_real_t grdini[] /* <-> gradient (interleaved or not) */
106 );
107 
108 /*----------------------------------------------------------------------------
109  * Compute cell gradient of vector field.
110  *----------------------------------------------------------------------------*/
111 
112 void CS_PROCF (cgdvec, CGDVEC)
113 (
114  const cs_int_t *const ivar,
115  const cs_int_t *const imrgra, /* <-- gradient computation mode */
116  const cs_int_t *const inc, /* <-- 0 or 1: increment or not */
117  const cs_int_t *const n_r_sweeps,/* <-- >1: with reconstruction */
118  const cs_int_t *const iwarnp, /* <-- verbosity level */
119  const cs_int_t *const imligp, /* <-- type of clipping */
120  const cs_real_t *const epsrgp, /* <-- precision for iterative
121  gradient calculation */
122  const cs_real_t *const climgp, /* <-- clipping coefficient */
123  const cs_real_3_t coefav[], /* <-- boundary condition term */
124  const cs_real_33_t coefbv[], /* <-- boundary condition term */
125  cs_real_3_t pvar[], /* <-- gradient's base variable */
126  cs_real_33_t gradv[] /* <-> gradient of the variable
127  (du_i/dx_j : gradv[][i][j]) */
128 );
129 
130 /*=============================================================================
131  * Public function prototypes
132  *============================================================================*/
133 
134 /*----------------------------------------------------------------------------
135  * Initialize gradient computation API.
136  *----------------------------------------------------------------------------*/
137 
138 void
140 
141 /*----------------------------------------------------------------------------
142  * Finalize gradient computation API.
143  *----------------------------------------------------------------------------*/
144 
145 void
147 
148 /*----------------------------------------------------------------------------
149  * Compute cell gradient of scalar field or component of vector or
150  * tensor field.
151  *
152  * parameters:
153  * var_name <-- variable name
154  * gradient_type <-- gradient type
155  * halo_type <-- halo type
156  * inc <-- if 0, solve on increment; 1 otherwise
157  * recompute_cocg <-- should COCG FV quantities be recomputed ?
158  * n_r_sweeps <-- if > 1, number of reconstruction sweeps
159  * tr_dim <-- 2 for tensor with periodicity of rotation,
160  * 0 otherwise
161  * hyd_p_flag <-- flag for hydrostatic pressure
162  * verbosity <-- verbosity level
163  * clip_mode <-- clipping mode
164  * epsilon <-- precision for iterative gradient calculation
165  * extrap <-- boundary gradient extrapolation coefficient
166  * clip_coeff <-- clipping coefficient
167  * f_ext <-- exterior force generating the hydrostatic pressure
168  * bc_coeff_a <-- boundary condition term a
169  * bc_coeff_b <-- boundary condition term b
170  * var <-> gradient's base variable
171  * c_weight <-- weighted gradient coefficient variable,
172  * or NULL
173  * grad --> gradient
174  *----------------------------------------------------------------------------*/
175 
176 void cs_gradient_scalar(const char *var_name,
177  cs_gradient_type_t gradient_type,
178  cs_halo_type_t halo_type,
179  int inc,
180  bool recompute_cocg,
181  int n_r_sweeps,
182  int tr_dim,
183  int hyd_p_flag,
184  int verbosity,
185  int clip_mode,
186  double epsilon,
187  double extrap,
188  double clip_coeff,
189  cs_real_3_t f_ext[],
190  const cs_real_t bc_coeff_a[],
191  const cs_real_t bc_coeff_b[],
192  cs_real_t *restrict var,
193  cs_real_t *restrict c_weight,
194  cs_real_3_t *restrict grad);
195 
196 /*----------------------------------------------------------------------------
197  * Compute cell gradient of a vector field.
198  *
199  * parameters:
200  * var_name <-- variable name
201  * gradient_type <-- gradient type
202  * halo_type <-- halo type
203  * inc <-- if 0, solve on increment; 1 otherwise
204  * n_r_sweeps <-- if > 1, number of reconstruction sweeps
205  * verbosity <-- verbosity level
206  * clip_mode <-- clipping mode
207  * epsilon <-- precision for iterative gradient calculation
208  * clip_coeff <-- clipping coefficient
209  * bc_coeff_a <-- boundary condition term a
210  * bc_coeff_b <-- boundary condition term b
211  * var <-> gradient's base variable
212  * gradv --> gradient (du_i/dx_j : gradv[][i][j])
213  *----------------------------------------------------------------------------*/
214 
215 void 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
239 cs_gradient_type_by_imrgra(int imrgra,
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:60
void cs_gradient_finalize(void)
Finalize gradient computation API.
Definition: cs_gradient.c:4555
void cs_gradient_type_by_imrgra(int imrgra, cs_gradient_type_t *gradient_type, cs_halo_type_t *halo_type)
Definition: cs_gradient.c:5075
#define BEGIN_C_DECLS
Definition: cs_defs.h:405
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:4371
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:4605
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:4489
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:4922
cs_halo_type_t
Definition: cs_halo.h:49
Definition: cs_gradient.h:57
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
Definition: cs_gradient.h:59
#define END_C_DECLS
Definition: cs_defs.h:406
double cs_real_t
Definition: cs_defs.h:296
Definition: cs_gradient.h:56
#define CS_PROCF(x, y)
Definition: cs_defs.h:419
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[]
Definition: cs_gradient.c:117
void cs_gradient_initialize(void)
Initialize gradient computation API.
Definition: cs_gradient.c:4543