programmer's documentation
cs_parameters.h
Go to the documentation of this file.
1 #ifndef __CS_PARAMETERS_H__
2 #define __CS_PARAMETERS_H__
3 
4 /*============================================================================
5  * General parameters management.
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  * Standard C library headers
32  *----------------------------------------------------------------------------*/
33 
34 #include <stdarg.h>
35 
36 /*----------------------------------------------------------------------------
37  * Local headers
38  *----------------------------------------------------------------------------*/
39 
40 #include "cs_defs.h"
41 #include "cs_field.h"
42 #include "cs_tree.h"
43 
44 /*----------------------------------------------------------------------------*/
45 
47 
48 /*=============================================================================
49  * Macro definitions
50  *============================================================================*/
51 
52 /*============================================================================
53  * Type definitions
54  *============================================================================*/
55 
56 /*----------------------------------------------------------------------------
57  * Structure of variable calculation options
58  *----------------------------------------------------------------------------*/
59 
60 typedef struct {
61  int iwarni;
62  int iconv;
63  int istat;
64  int idircl;
65  int ndircl;
66  int idiff;
67  int idifft;
68  int idften;
69  int iswdyn;
70  int ischcv;
71  int ibdtso;
72  int isstpc;
73  int nswrgr;
74  int nswrsm;
75  int imrgra;
76  int imligr;
77  int ircflu;
78  int iwgrec; /* gradient calculation
79  - 0: standard (default)
80  - 1: weighted (could be used with imvisf = 1) */
81  int icoupl; /* internal coupling
82  - -1: not coupled (default)
83  - 1: coupled */
84 
85  double thetav;
86  double blencv;
87  double blend_st;
88  double epsilo;
89  double epsrsm;
90  double epsrgr;
91  double climgr;
92  double extrag;
93  double relaxv;
95 
96 /*----------------------------------------------------------------------------
97  * Structure of the solving info
98  *----------------------------------------------------------------------------*/
99 
100 typedef struct {
101  int n_it;
102  double rhs_norm;
103  double res_norm;
104  double derive;
105  double l2residual;
107 
108 /*----------------------------------------------------------------------------
109  * Structure of condensation modelling physical properties
110  *----------------------------------------------------------------------------*/
111 
112 typedef struct {
113  double mol_mas;
114  double cp;
115  double vol_dif;
116  double mu_a;
117  double mu_b;
118  double lambda_a;
119  double lambda_b;
120  double muref; /* ref. viscosity for Sutherland law */
121  double lamref; /* ref. thermal conductivity for Sutherland law */
122  double trefmu; /* ref. temperature for viscosity in Sutherland law */
123  double treflam; /* ref. temperature for conductivity Sutherland law */
124  double smu; /* Sutherland temperature for viscosity */
125  double slam; /* Sutherland temperature for conductivity */
127 
128 /*----------------------------------------------------------------------------
129  * Boundary condition types
130  *----------------------------------------------------------------------------*/
131 
132 enum {
133  CS_INDEF = 1,
134  CS_INLET = 2,
139  CS_ESICF = 7,
140  CS_SSPCF = 8,
141  CS_SOPCF = 9,
142  CS_EPHCF = 10,
143  CS_EQHCF = 11,
144  CS_COUPLED = 12, /* coupled face */
145  CS_COUPLED_FD = 13, /* coupled face with decentered flux */
149 };
150 
151 /*----------------------------------------------------------------------------
152  * flag for computing the drift mass flux:
153  * (for coal classes for instance, only the first
154  * scalar of a class compute the drift flux of the class
155  * and the other scalars use it without recomputing it)
156  *----------------------------------------------------------------------------*/
157 
158 enum {
159  CS_DRIFT_SCALAR_ON = (1 << 0),
167 };
168 
169 /*----------------------------------------------------------------------------
170  * Space discretisation options descriptor
171  *----------------------------------------------------------------------------*/
172 
173 typedef struct {
174 
175  int imvisf; /* face viscosity field interpolation
176  - 1: harmonic
177  - 0: arithmetic (default) */
178 
179  int imrgra; /* type of gradient reconstruction
180  - 0: iterative process
181  - 1: standard least square method
182  - 2: least square method with extended
183  neighborhood
184  - 3: least square method with reduced extended
185  neighborhood
186  - 4: iterative process initialized by the least
187  square method */
188 
189  double anomax; /* non orthogonality angle of the faces, in radians.
190  For larger angle values, cells with one node
191  on the wall are kept in the extended support of
192  the neighboring cells. */
193 
194  int iflxmw; /* method to compute interior mass flux due to ALE
195  mesh velocity
196  - 1: based on cell center mesh velocity
197  - 0: based on nodes displacement */
198 
200 
201 /*----------------------------------------------------------------------------
202  * PISO descriptor
203  *----------------------------------------------------------------------------*/
204 
205 typedef struct {
206 
207  int nterup; /* number of interations on the pressure-velocity
208  coupling on Navier-Stokes */
209 
210  double epsup; /* relative precision for the convergence test of
211  the iterative process on pressure-velocity
212  coupling */
213 
214  double xnrmu; /* norm of the increment
215  \f$ \vect{u}^{k+1} - \vect{u}^k \f$
216  of the iterative process on pressure-velocity
217  coupling */
218 
219  double xnrmu0; /* norm of \f$ \vect{u}^0 \f$ */
220 
221  int n_buoyant_scal; /* number of buoyant scalars,
222  zero if there is no buoyant scalar */
223 
224 } cs_piso_t;
225 
226 /*============================================================================
227  * Static global variables
228  *============================================================================*/
229 
230 /* Pointer to space discretisation options structure */
231 
232 extern const cs_space_disc_t *cs_glob_space_disc;
233 
234 /* Pointer to PISO options structure */
235 
236 extern const cs_piso_t *cs_glob_piso;
237 
238 /*============================================================================
239  * Global variables
240  *============================================================================*/
241 
244 extern cs_tree_node_t *cs_glob_tree;
245 
246 /*=============================================================================
247  * Public function prototypes
248  *============================================================================*/
249 
250 /*----------------------------------------------------------------------------*/
261 /*----------------------------------------------------------------------------*/
262 
263 static inline int
265 {
266  int iscvr = 0, f_id = 0;
267  int kscavr = cs_field_key_id("first_moment_id");
268  int keysca = cs_field_key_id("scalar_id");
269 
270  if (kscavr >= 0) {
271  f_id = cs_field_get_key_int(f, kscavr);
272  if (f_id >= 0)
273  iscvr = cs_field_get_key_int(cs_field_by_id(f_id), keysca);
274  }
275 
276  return iscvr;
277 }
278 
279 /*----------------------------------------------------------------------------*/
287 /*----------------------------------------------------------------------------*/
288 
291 
292 /*----------------------------------------------------------------------------*/
300 /*----------------------------------------------------------------------------*/
301 
302 cs_piso_t *
303 cs_get_glob_piso(void);
304 
305 /*----------------------------------------------------------------------------
306  *!
307  * \brief Count and set number of buoyant scalars.
308  */
309 /*----------------------------------------------------------------------------*/
310 
311 void
313 
314 /*----------------------------------------------------------------------------*/
321 /*----------------------------------------------------------------------------*/
322 
323 void
325 
326 /*----------------------------------------------------------------------------*/
332 /*----------------------------------------------------------------------------*/
333 
334 void
336 
337 /*----------------------------------------------------------------------------*/
343 /*----------------------------------------------------------------------------*/
344 
345 void
347 
348 /*----------------------------------------------------------------------------*/
357 /*----------------------------------------------------------------------------*/
358 
359 void
360 cs_parameters_add_variable(const char *name,
361  int dim);
362 
363 /*----------------------------------------------------------------------------*/
372 /*----------------------------------------------------------------------------*/
373 
374 void
375 cs_parameters_add_variable_variance(const char *name,
376  const char *variable_name);
377 
378 /*----------------------------------------------------------------------------*/
386 /*----------------------------------------------------------------------------*/
387 
388 void
389 cs_parameters_add_property(const char *name,
390  int dim,
391  int location_id);
392 
393 /*----------------------------------------------------------------------------*/
402 /*----------------------------------------------------------------------------*/
403 
404 int
406 
407 /*----------------------------------------------------------------------------*/
416 /*----------------------------------------------------------------------------*/
417 
418 int
420 
421 /*----------------------------------------------------------------------------*/
425 /*----------------------------------------------------------------------------*/
426 
427 void
429 
430 /*----------------------------------------------------------------------------*/
434 /*----------------------------------------------------------------------------*/
435 
436 void
438 
439 /*----------------------------------------------------------------------------*/
447 /*----------------------------------------------------------------------------*/
448 
449 cs_field_t *
451 
452 /*----------------------------------------------------------------------------*/
463 /*----------------------------------------------------------------------------*/
464 
465 cs_field_t *
467 
468 /*----------------------------------------------------------------------------*/
475 /*----------------------------------------------------------------------------*/
476 
479 
480 /*----------------------------------------------------------------------------*/
484 /*----------------------------------------------------------------------------*/
485 
486 void
488 
489 /*----------------------------------------------------------------------------*/
490 
492 
493 #endif /* __CS_PARAMETERS_H__ */
double climgr
Definition: cs_parameters.h:91
Definition: cs_parameters.h:159
Definition: cs_parameters.h:139
cs_field_t * cs_parameters_add_boundary_values(cs_field_t *f)
Define a boundary values field for a variable field.
Definition: cs_parameters.c:1346
Definition: cs_parameters.h:166
Definition: cs_parameters.h:100
int istat
Definition: cs_parameters.h:63
double mol_mas
Definition: cs_parameters.h:113
Definition: cs_parameters.h:160
double slam
Definition: cs_parameters.h:125
int ischcv
Definition: cs_parameters.h:70
int nswrgr
Definition: cs_parameters.h:73
int imrgra
Definition: cs_parameters.h:179
const cs_space_disc_t * cs_glob_space_disc
Definition: cs_parameters.h:164
int iconv
Definition: cs_parameters.h:62
Definition: cs_parameters.h:136
void cs_parameters_create_added_variables(void)
Create previously added user variables.
Definition: cs_parameters.c:1221
int iflxmw
Definition: cs_parameters.h:194
Field descriptor.
Definition: cs_field.h:124
int nterup
Definition: cs_parameters.h:207
int nswrsm
Definition: cs_parameters.h:74
int imligr
Definition: cs_parameters.h:76
double lambda_a
Definition: cs_parameters.h:118
Definition: cs_parameters.h:148
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:2307
double smu
Definition: cs_parameters.h:124
double lambda_b
Definition: cs_parameters.h:119
void cs_parameters_add_variable(const char *name, int dim)
Solved variables are always defined on cells.
Definition: cs_parameters.c:1082
int idifft
Definition: cs_parameters.h:67
double epsrsm
Definition: cs_parameters.h:89
void cs_parameters_read_restart_info(void)
Read general restart info.
Definition: cs_parameters.c:1060
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
double anomax
Definition: cs_parameters.h:189
void cs_parameters_set_n_buoyant_scalars(void)
Definition: cs_parameters.c:890
void cs_space_disc_log_setup(void)
Print the space discretization structure to setup.log.
Definition: cs_parameters.c:1549
cs_tree_node_t * cs_glob_tree
Definition: cs_parameters.h:163
void cs_parameters_add_variable_variance(const char *name, const char *variable_name)
Define a user variable which is a variance of another variable.
Definition: cs_parameters.c:1123
double trefmu
Definition: cs_parameters.h:122
double blencv
Definition: cs_parameters.h:86
Definition: cs_parameters.h:138
void cs_parameters_add_property(const char *name, int dim, int location_id)
Define a user property.
Definition: cs_parameters.c:1160
Definition: cs_parameters.h:147
int isstpc
Definition: cs_parameters.h:72
cs_space_disc_t * cs_get_glob_space_disc(void)
Provide access to cs_glob_space_disc.
Definition: cs_parameters.c:862
int icoupl
Definition: cs_parameters.h:81
int ndircl
Definition: cs_parameters.h:65
Definition: cs_parameters.h:162
double cp
Definition: cs_parameters.h:114
void cs_parameters_create_added_properties(void)
Create previously added user properties.
Definition: cs_parameters.c:1296
int iwarni
Definition: cs_parameters.h:61
int cs_field_get_key_int(const cs_field_t *f, int key_id)
Return a integer value for a given key associated with a field.
Definition: cs_field.c:2976
Definition: cs_parameters.h:133
int iswdyn
Definition: cs_parameters.h:69
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:2490
Definition: cs_parameters.h:112
Definition: cs_parameters.h:134
int idiff
Definition: cs_parameters.h:66
int idircl
Definition: cs_parameters.h:64
Definition: cs_parameters.h:146
Definition: cs_parameters.h:165
double extrag
Definition: cs_parameters.h:92
double epsilo
Definition: cs_parameters.h:88
double thetav
Definition: cs_parameters.h:85
double blend_st
Definition: cs_parameters.h:87
int imrgra
Definition: cs_parameters.h:75
double epsup
Definition: cs_parameters.h:210
int cs_parameters_n_added_variables(void)
Return the number of defined user variables not added yet.
Definition: cs_parameters.c:1195
double vol_dif
Definition: cs_parameters.h:115
cs_piso_t * cs_get_glob_piso(void)
Provide acces to cs_glob_piso.
Definition: cs_parameters.c:878
void cs_parameters_define_field_key_gas_mix(void)
Define field key for condensation.
Definition: cs_parameters.c:1039
int idften
Definition: cs_parameters.h:68
int n_buoyant_scal
Definition: cs_parameters.h:221
double xnrmu
Definition: cs_parameters.h:214
const cs_piso_t * cs_glob_piso
Definition: cs_parameters.h:137
double mu_a
Definition: cs_parameters.h:116
int n_it
Definition: cs_parameters.h:101
double l2residual
Definition: cs_parameters.h:105
Definition: cs_parameters.h:161
PISO options descriptor.
Definition: cs_parameters.h:205
structure containing the variable calculation options.
Definition: cs_parameters.h:60
static int cs_parameters_iscavr(cs_field_t *f)
For a given field, returns the scalar number of the fluctuating field if given field is a variance...
Definition: cs_parameters.h:264
Definition: cs_parameters.h:140
#define END_C_DECLS
Definition: cs_defs.h:468
int ibdtso
Definition: cs_parameters.h:71
double relaxv
Definition: cs_parameters.h:93
Space discretisation options descriptor.
Definition: cs_parameters.h:173
Definition: cs_parameters.h:145
int cs_parameters_n_added_properties(void)
Return the number of defined user properties not added yet.
Definition: cs_parameters.c:1209
double lamref
Definition: cs_parameters.h:121
int ircflu
Definition: cs_parameters.h:77
Definition: cs_parameters.h:141
Definition: cs_parameters.h:142
double muref
Definition: cs_parameters.h:120
double rhs_norm
Definition: cs_parameters.h:102
void cs_parameters_define_field_keys(void)
Define general field keys.
Definition: cs_parameters.c:917
Definition: cs_parameters.h:143
int iwgrec
Definition: cs_parameters.h:78
Definition: cs_parameters.h:144
Definition: cs_parameters.h:135
int imvisf
Definition: cs_parameters.h:175
double xnrmu0
Definition: cs_parameters.h:219
double treflam
Definition: cs_parameters.h:123
double derive
Definition: cs_parameters.h:104
cs_var_cal_opt_t cs_parameters_var_cal_opt_default(void)
Return a local variable calculation options structure, with default options.
Definition: cs_parameters.c:1537
double epsrgr
Definition: cs_parameters.h:90
double mu_b
Definition: cs_parameters.h:117
cs_field_t * cs_parameters_add_boundary_temperature(void)
Define a boundary values field for temperature, if applicable.
Definition: cs_parameters.c:1451
double res_norm
Definition: cs_parameters.h:103