My Project
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__ */
CS_DRIFT_SCALAR_CENTRIFUGALFORCE
Definition: cs_parameters.h:164
f_id
void const int * f_id
Definition: cs_gui.h:292
cs_gas_mix_species_prop_t::mu_b
double mu_b
Definition: cs_parameters.h:117
cs_parameters_define_field_key_gas_mix
void cs_parameters_define_field_key_gas_mix(void)
Define field key for condensation.
Definition: cs_parameters.c:1039
cs_var_cal_opt_t::idifft
int idifft
Definition: cs_parameters.h:67
cs_parameters_create_added_variables
void cs_parameters_create_added_variables(void)
Create previously added user variables.
Definition: cs_parameters.c:1221
cs_defs.h
cs_gas_mix_species_prop_t::vol_dif
double vol_dif
Definition: cs_parameters.h:115
cs_var_cal_opt_t::ndircl
int ndircl
Definition: cs_parameters.h:65
cs_var_cal_opt_t::ischcv
int ischcv
Definition: cs_parameters.h:70
cs_parameters_add_boundary_temperature
cs_field_t * cs_parameters_add_boundary_temperature(void)
Define a boundary values field for temperature, if applicable.
Definition: cs_parameters.c:1451
cs_gas_mix_species_prop_t::muref
double muref
Definition: cs_parameters.h:120
cs_piso_t::n_buoyant_scal
int n_buoyant_scal
Definition: cs_parameters.h:221
CS_SOPCF
Definition: cs_parameters.h:141
cs_gas_mix_species_prop_t::smu
double smu
Definition: cs_parameters.h:124
CS_EPHCF
Definition: cs_parameters.h:142
cs_space_disc_log_setup
void cs_space_disc_log_setup(void)
Print the space discretization structure to setup.log.
Definition: cs_parameters.c:1549
cs_var_cal_opt_t::nswrsm
int nswrsm
Definition: cs_parameters.h:74
cs_glob_piso
const cs_piso_t * cs_glob_piso
cs_var_cal_opt_t::iconv
int iconv
Definition: cs_parameters.h:62
cs_var_cal_opt_t::epsilo
double epsilo
Definition: cs_parameters.h:88
cs_parameters_add_boundary_values
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
cs_gas_mix_species_prop_t
Definition: cs_parameters.h:112
cs_gas_mix_species_prop_t::mu_a
double mu_a
Definition: cs_parameters.h:116
cs_space_disc_t::imvisf
int imvisf
Definition: cs_parameters.h:175
cs_gas_mix_species_prop_t::lambda_a
double lambda_a
Definition: cs_parameters.h:118
cs_glob_space_disc
const cs_space_disc_t * cs_glob_space_disc
cs_var_cal_opt_t::istat
int istat
Definition: cs_parameters.h:63
cs_var_cal_opt_t::iswdyn
int iswdyn
Definition: cs_parameters.h:69
cs_var_cal_opt_t::epsrsm
double epsrsm
Definition: cs_parameters.h:89
cs_var_cal_opt_t::nswrgr
int nswrgr
Definition: cs_parameters.h:73
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_space_disc_t::imrgra
int imrgra
Definition: cs_parameters.h:179
cs_gas_mix_species_prop_t::cp
double cp
Definition: cs_parameters.h:114
cs_space_disc_t::anomax
double anomax
Definition: cs_parameters.h:189
CS_FREE_INLET
Definition: cs_parameters.h:146
CS_SSPCF
Definition: cs_parameters.h:140
cs_var_cal_opt_t::idften
int idften
Definition: cs_parameters.h:68
CS_ESICF
Definition: cs_parameters.h:139
cs_glob_tree
cs_tree_node_t * cs_glob_tree
CS_DRIFT_SCALAR_ON
Definition: cs_parameters.h:159
cs_var_cal_opt_t::isstpc
int isstpc
Definition: cs_parameters.h:72
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_var_cal_opt_t::iwgrec
int iwgrec
Definition: cs_parameters.h:78
cs_var_cal_opt_t::blend_st
double blend_st
Definition: cs_parameters.h:87
cs_var_cal_opt_t::idiff
int idiff
Definition: cs_parameters.h:66
cs_var_cal_opt_t::imrgra
int imrgra
Definition: cs_parameters.h:75
cs_solving_info_t::res_norm
double res_norm
Definition: cs_parameters.h:103
cs_piso_t::xnrmu
double xnrmu
Definition: cs_parameters.h:214
cs_get_glob_space_disc
cs_space_disc_t * cs_get_glob_space_disc(void)
Provide access to cs_glob_space_disc.
Definition: cs_parameters.c:862
cs_parameters_n_added_properties
int cs_parameters_n_added_properties(void)
Return the number of defined user properties not added yet.
Definition: cs_parameters.c:1209
cs_parameters_var_cal_opt_default
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
CS_EQHCF
Definition: cs_parameters.h:143
CS_INLET
Definition: cs_parameters.h:134
cs_solving_info_t::l2residual
double l2residual
Definition: cs_parameters.h:105
CS_OUTLET
Definition: cs_parameters.h:135
CS_CONVECTIVE_INLET
Definition: cs_parameters.h:148
cs_var_cal_opt_t::ircflu
int ircflu
Definition: cs_parameters.h:77
cs_parameters_define_field_keys
void cs_parameters_define_field_keys(void)
Define general field keys.
Definition: cs_parameters.c:917
cs_gas_mix_species_prop_t::trefmu
double trefmu
Definition: cs_parameters.h:122
cs_parameters_n_added_variables
int cs_parameters_n_added_variables(void)
Return the number of defined user variables not added yet.
Definition: cs_parameters.c:1195
CS_DRIFT_SCALAR_ELECTROPHORESIS
Definition: cs_parameters.h:163
CS_DRIFT_SCALAR_ZERO_BNDY_FLUX
Definition: cs_parameters.h:166
cs_solving_info_t::n_it
int n_it
Definition: cs_parameters.h:101
cs_field_get_key_int
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
cs_var_cal_opt_t::icoupl
int icoupl
Definition: cs_parameters.h:81
cs_gas_mix_species_prop_t::mol_mas
double mol_mas
Definition: cs_parameters.h:113
cs_gas_mix_species_prop_t::slam
double slam
Definition: cs_parameters.h:125
CS_SMOOTHWALL
Definition: cs_parameters.h:137
cs_field.h
cs_piso_t
PISO options descriptor.
Definition: cs_parameters.h:205
CS_DRIFT_SCALAR_TURBOPHORESIS
Definition: cs_parameters.h:162
cs_solving_info_t::derive
double derive
Definition: cs_parameters.h:104
cs_parameters_iscavr
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
cs_field_by_id
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:2307
cs_gas_mix_species_prop_t::lamref
double lamref
Definition: cs_parameters.h:121
cs_parameters_read_restart_info
void cs_parameters_read_restart_info(void)
Read general restart info.
Definition: cs_parameters.c:1060
cs_get_glob_piso
cs_piso_t * cs_get_glob_piso(void)
Provide acces to cs_glob_piso.
Definition: cs_parameters.c:878
cs_var_cal_opt_t::imligr
int imligr
Definition: cs_parameters.h:76
cs_gas_mix_species_prop_t::lambda_b
double lambda_b
Definition: cs_parameters.h:119
cs_var_cal_opt_t::idircl
int idircl
Definition: cs_parameters.h:64
CS_COUPLED_FD
Definition: cs_parameters.h:145
cs_gas_mix_species_prop_t::treflam
double treflam
Definition: cs_parameters.h:123
cs_parameters_set_n_buoyant_scalars
void cs_parameters_set_n_buoyant_scalars(void)
Definition: cs_parameters.c:890
cs_parameters_add_variable_variance
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
cs_var_cal_opt_t::thetav
double thetav
Definition: cs_parameters.h:85
cs_parameters_add_variable
void cs_parameters_add_variable(const char *name, int dim)
Solved variables are always defined on cells.
Definition: cs_parameters.c:1082
cs_parameters_add_property
void cs_parameters_add_property(const char *name, int dim, int location_id)
Define a user property.
Definition: cs_parameters.c:1160
cs_var_cal_opt_t
structure containing the variable calculation options.
Definition: cs_parameters.h:60
cs_space_disc_t::iflxmw
int iflxmw
Definition: cs_parameters.h:194
cs_tree.h
cs_field_key_id
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:2490
cs_solving_info_t
Definition: cs_parameters.h:100
CS_DRIFT_SCALAR_ADD_DRIFT_FLUX
Definition: cs_parameters.h:160
cs_var_cal_opt_t::iwarni
int iwarni
Definition: cs_parameters.h:61
cs_var_cal_opt_t::relaxv
double relaxv
Definition: cs_parameters.h:93
cs_parameters_create_added_properties
void cs_parameters_create_added_properties(void)
Create previously added user properties.
Definition: cs_parameters.c:1296
CS_DRIFT_SCALAR_IMPOSED_MASS_FLUX
Definition: cs_parameters.h:165
CS_SYMMETRY
Definition: cs_parameters.h:136
cs_piso_t::nterup
int nterup
Definition: cs_parameters.h:207
cs_var_cal_opt_t::climgr
double climgr
Definition: cs_parameters.h:91
CS_COUPLED
Definition: cs_parameters.h:144
cs_var_cal_opt_t::blencv
double blencv
Definition: cs_parameters.h:86
cs_piso_t::epsup
double epsup
Definition: cs_parameters.h:210
cs_piso_t::xnrmu0
double xnrmu0
Definition: cs_parameters.h:219
cs_solving_info_t::rhs_norm
double rhs_norm
Definition: cs_parameters.h:102
cs_var_cal_opt_t::extrag
double extrag
Definition: cs_parameters.h:92
CS_INDEF
Definition: cs_parameters.h:133
cs_field_t
Field descriptor.
Definition: cs_field.h:124
cs_var_cal_opt_t::epsrgr
double epsrgr
Definition: cs_parameters.h:90
CS_DRIFT_SCALAR_THERMOPHORESIS
Definition: cs_parameters.h:161
cs_space_disc_t
Space discretisation options descriptor.
Definition: cs_parameters.h:173
cs_var_cal_opt_t::ibdtso
int ibdtso
Definition: cs_parameters.h:71
CS_ROUGHWALL
Definition: cs_parameters.h:138
CS_FREE_SURFACE
Definition: cs_parameters.h:147