6.3
general 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-2020 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_equation_param.h"
42 #include "cs_field.h"
43 #include "cs_tree.h"
44 
45 /*----------------------------------------------------------------------------*/
46 
48 
49 /*=============================================================================
50  * Macro definitions
51  *============================================================================*/
52 
53 /*============================================================================
54  * Type definitions
55  *============================================================================*/
56 
57 /*----------------------------------------------------------------------------
58  * Structure of variable calculation options
59  * (now an alias of cs_equation_param_t)
60  *----------------------------------------------------------------------------*/
61 
63 
64 /*----------------------------------------------------------------------------
65  * Structure of the solving info
66  *----------------------------------------------------------------------------*/
67 
68 typedef struct {
69  int n_it;
70  double rhs_norm;
71  double res_norm;
72  double derive;
73  double l2residual;
75 
76 /*----------------------------------------------------------------------------
77  * Structure of condensation modelling physical properties
78  *----------------------------------------------------------------------------*/
79 
80 typedef struct {
81  double mol_mas;
82  double cp;
83  double vol_dif;
84  double mu_a;
85  double mu_b;
86  double lambda_a;
87  double lambda_b;
88  double muref; /* ref. viscosity for Sutherland law */
89  double lamref; /* ref. thermal conductivity for Sutherland law */
90  double trefmu; /* ref. temperature for viscosity in Sutherland law */
91  double treflam; /* ref. temperature for conductivity Sutherland law */
92  double smu; /* Sutherland temperature for viscosity */
93  double slam; /* Sutherland temperature for conductivity */
95 
96 /*----------------------------------------------------------------------------
97  * Boundary condition types
98  *----------------------------------------------------------------------------*/
99 
100 enum {
101  CS_INDEF = 1,
102  CS_INLET = 2,
107  CS_ESICF = 7,
108  CS_SSPCF = 8,
109  CS_SOPCF = 9,
110  CS_EPHCF = 10,
111  CS_EQHCF = 11,
112  CS_COUPLED = 12, /* coupled face */
113  CS_COUPLED_FD = 13, /* coupled face with decentered flux */
117 };
118 
119 /*----------------------------------------------------------------------------
120  * flag for computing the drift mass flux:
121  * (for coal classes for instance, only the first
122  * scalar of a class compute the drift flux of the class
123  * and the other scalars use it without recomputing it)
124  *----------------------------------------------------------------------------*/
125 
126 enum {
127  CS_DRIFT_SCALAR_ON = (1 << 0),
135 };
136 
137 /*----------------------------------------------------------------------------
138  * Space discretisation options descriptor
139  *----------------------------------------------------------------------------*/
140 
141 typedef struct {
142 
143  int imvisf; /* face viscosity field interpolation
144  - 1: harmonic
145  - 0: arithmetic (default) */
146 
147  int imrgra; /* type of gradient reconstruction
148  - 0: iterative process
149  - 1: standard least square method
150  - 2: least square method with extended
151  neighborhood
152  - 3: least square method with reduced extended
153  neighborhood
154  - 4: Green-Gauss using least squares face
155  values interpolation */
156 
157  int iflxmw; /* method to compute interior mass flux due to ALE
158  mesh velocity
159  - 1: based on cell center mesh velocity
160  - 0: based on nodes displacement */
161 
163 
164 /*----------------------------------------------------------------------------
165  * Time scheme descriptor
166  *----------------------------------------------------------------------------*/
167 
168 typedef struct {
169 
170  int isto2t; /* time scheme activated for the source
171  terms of turbulent equations */
172 
173  double thetst; /* value of \f$theta\f$ for turbulence */
174 
176 
177 /*----------------------------------------------------------------------------
178  * Inner iterations descriptor
179  *----------------------------------------------------------------------------*/
180 
181 typedef struct {
182 
183  int nterup; /* number of iterations on the pressure-velocity
184  coupling on Navier-Stokes */
185 
186  double epsup; /* relative precision for the convergence test of
187  the iterative process on pressure-velocity
188  coupling */
189 
190  double xnrmu; /* norm of the increment
191  \f$ \vect{u}^{k+1} - \vect{u}^k \f$
192  of the iterative process on pressure-velocity
193  coupling */
194 
195  double xnrmu0; /* norm of \f$ \vect{u}^0 \f$ */
196 
197  int n_buoyant_scal; /* number of buoyant scalars,
198  zero if there is no buoyant scalar */
199 
200 } cs_piso_t;
201 
202 /*----------------------------------------------------------------------------
203  * Auxiliary checkpoint/restart file parameters
204  *----------------------------------------------------------------------------*/
205 
206 typedef struct {
207 
208  int read_auxiliary; /* Activate reading of auxiliary restart file */
209  int write_auxiliary; /* Activate output of auxiliary restart file */
210 
212 
213 /*============================================================================
214  * Static global variables
215  *============================================================================*/
216 
217 /* Pointer to space discretisation options structure */
218 
219 extern const cs_space_disc_t *cs_glob_space_disc;
220 
221 /* Pointer to time scheme options structure */
222 
224 
225 /* Pointer to inner iterations structure */
226 
227 extern const cs_piso_t *cs_glob_piso;
228 
229 /* Pointer to auxiliary checkpoint/restart file parameters */
230 
232 
233 /*============================================================================
234  * Global variables
235  *============================================================================*/
236 
239 extern cs_tree_node_t *cs_glob_tree;
240 
241 /*=============================================================================
242  * Public function prototypes
243  *============================================================================*/
244 
245 /*----------------------------------------------------------------------------*/
256 /*----------------------------------------------------------------------------*/
257 
258 static inline int
259 cs_parameters_iscavr(cs_field_t *f)
260 {
261  int iscvr = 0, f_id = 0;
262  int kscavr = cs_field_key_id("first_moment_id");
263  int keysca = cs_field_key_id("scalar_id");
264 
265  if (kscavr >= 0) {
266  f_id = cs_field_get_key_int(f, kscavr);
267  if (f_id >= 0)
268  iscvr = cs_field_get_key_int(cs_field_by_id(f_id), keysca);
269  }
270 
271  return iscvr;
272 }
273 
274 /*----------------------------------------------------------------------------*/
282 /*----------------------------------------------------------------------------*/
283 
286 
287 /*----------------------------------------------------------------------------*/
295 /*----------------------------------------------------------------------------*/
296 
299 
300 /*----------------------------------------------------------------------------*/
308 /*----------------------------------------------------------------------------*/
309 
310 cs_piso_t *
311 cs_get_glob_piso(void);
312 
313 /*----------------------------------------------------------------------------
314  *!
315  * \brief Count and set number of buoyant scalars.
316  */
317 /*----------------------------------------------------------------------------*/
318 
319 void
321 
322 /*----------------------------------------------------------------------------*/
329 /*----------------------------------------------------------------------------*/
330 
331 void
333 
334 /*----------------------------------------------------------------------------*/
340 /*----------------------------------------------------------------------------*/
341 
342 void
344 
345 /*----------------------------------------------------------------------------*/
351 /*----------------------------------------------------------------------------*/
352 
353 void
355 
356 /*----------------------------------------------------------------------------*/
365 /*----------------------------------------------------------------------------*/
366 
367 void
368 cs_parameters_add_variable(const char *name,
369  int dim);
370 
371 /*----------------------------------------------------------------------------*/
380 /*----------------------------------------------------------------------------*/
381 
382 void
383 cs_parameters_add_variable_variance(const char *name,
384  const char *variable_name);
385 
386 /*----------------------------------------------------------------------------*/
394 /*----------------------------------------------------------------------------*/
395 
396 void
397 cs_parameters_add_property(const char *name,
398  int dim,
399  int location_id);
400 
401 /*----------------------------------------------------------------------------*/
410 /*----------------------------------------------------------------------------*/
411 
412 int
414 
415 /*----------------------------------------------------------------------------*/
424 /*----------------------------------------------------------------------------*/
425 
426 int
428 
429 /*----------------------------------------------------------------------------*/
433 /*----------------------------------------------------------------------------*/
434 
435 void
437 
438 /*----------------------------------------------------------------------------*/
442 /*----------------------------------------------------------------------------*/
443 
444 void
446 
447 /*----------------------------------------------------------------------------*/
455 /*----------------------------------------------------------------------------*/
456 
457 cs_field_t *
459 
460 /*----------------------------------------------------------------------------*/
471 /*----------------------------------------------------------------------------*/
472 
473 cs_field_t *
475 
476 /*----------------------------------------------------------------------------*/
483 /*----------------------------------------------------------------------------*/
484 
487 
488 /*----------------------------------------------------------------------------*/
492 /*----------------------------------------------------------------------------*/
493 
494 void
496 
497 /*----------------------------------------------------------------------------*/
498 
500 
501 #endif /* __CS_PARAMETERS_H__ */
CS_DRIFT_SCALAR_CENTRIFUGALFORCE
@ CS_DRIFT_SCALAR_CENTRIFUGALFORCE
Definition: cs_parameters.h:132
cs_gas_mix_species_prop_t::mu_b
double mu_b
Definition: cs_parameters.h:85
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:1176
cs_parameters_create_added_variables
void cs_parameters_create_added_variables(void)
Create previously added user variables.
Definition: cs_parameters.c:1359
cs_defs.h
cs_gas_mix_species_prop_t::vol_dif
double vol_dif
Definition: cs_parameters.h:83
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:1589
cs_gas_mix_species_prop_t::muref
double muref
Definition: cs_parameters.h:88
cs_piso_t::n_buoyant_scal
int n_buoyant_scal
Definition: cs_parameters.h:197
CS_SOPCF
@ CS_SOPCF
Definition: cs_parameters.h:109
cs_gas_mix_species_prop_t::smu
double smu
Definition: cs_parameters.h:92
CS_EPHCF
@ CS_EPHCF
Definition: cs_parameters.h:110
cs_space_disc_log_setup
void cs_space_disc_log_setup(void)
Print the space discretization structure to setup.log.
Definition: cs_parameters.c:1687
cs_glob_piso
const cs_piso_t * cs_glob_piso
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:1484
cs_time_scheme_t::isto2t
int isto2t
Definition: cs_parameters.h:170
cs_gas_mix_species_prop_t
Definition: cs_parameters.h:80
cs_var_cal_opt_t
cs_equation_param_t cs_var_cal_opt_t
Definition: cs_parameters.h:62
cs_gas_mix_species_prop_t::mu_a
double mu_a
Definition: cs_parameters.h:84
cs_space_disc_t::imvisf
int imvisf
Definition: cs_parameters.h:143
cs_gas_mix_species_prop_t::lambda_a
double lambda_a
Definition: cs_parameters.h:86
cs_glob_space_disc
const cs_space_disc_t * cs_glob_space_disc
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:493
cs_space_disc_t::imrgra
int imrgra
Definition: cs_parameters.h:147
cs_gas_mix_species_prop_t::cp
double cp
Definition: cs_parameters.h:82
CS_FREE_INLET
@ CS_FREE_INLET
Definition: cs_parameters.h:114
CS_SSPCF
@ CS_SSPCF
Definition: cs_parameters.h:108
cs_glob_time_scheme
const cs_time_scheme_t * cs_glob_time_scheme
cs_time_scheme_t::thetst
double thetst
Definition: cs_parameters.h:173
cs_restart_auxiliary_t::write_auxiliary
int write_auxiliary
Definition: cs_parameters.h:209
CS_ESICF
@ CS_ESICF
Definition: cs_parameters.h:107
cs_glob_tree
cs_tree_node_t * cs_glob_tree
CS_DRIFT_SCALAR_ON
@ CS_DRIFT_SCALAR_ON
Definition: cs_parameters.h:127
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:492
cs_solving_info_t::res_norm
double res_norm
Definition: cs_parameters.h:71
cs_piso_t::xnrmu
double xnrmu
Definition: cs_parameters.h:190
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:970
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:1347
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:1675
CS_EQHCF
@ CS_EQHCF
Definition: cs_parameters.h:111
CS_INLET
@ CS_INLET
Definition: cs_parameters.h:102
cs_solving_info_t::l2residual
double l2residual
Definition: cs_parameters.h:73
cs_restart_auxiliary_t
Additional checkpoint/restart files.
Definition: cs_parameters.h:206
CS_OUTLET
@ CS_OUTLET
Definition: cs_parameters.h:103
CS_CONVECTIVE_INLET
@ CS_CONVECTIVE_INLET
Definition: cs_parameters.h:116
cs_parameters_define_field_keys
void cs_parameters_define_field_keys(void)
Define general field keys.
Definition: cs_parameters.c:1041
cs_equation_param_t
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:201
cs_gas_mix_species_prop_t::trefmu
double trefmu
Definition: cs_parameters.h:90
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:1333
CS_DRIFT_SCALAR_ELECTROPHORESIS
@ CS_DRIFT_SCALAR_ELECTROPHORESIS
Definition: cs_parameters.h:131
CS_DRIFT_SCALAR_ZERO_BNDY_FLUX
@ CS_DRIFT_SCALAR_ZERO_BNDY_FLUX
Definition: cs_parameters.h:134
cs_solving_info_t::n_it
int n_it
Definition: cs_parameters.h:69
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:2991
cs_gas_mix_species_prop_t::mol_mas
double mol_mas
Definition: cs_parameters.h:81
cs_gas_mix_species_prop_t::slam
double slam
Definition: cs_parameters.h:93
CS_SMOOTHWALL
@ CS_SMOOTHWALL
Definition: cs_parameters.h:105
cs_time_scheme_t
Time scheme descriptor.
Definition: cs_parameters.h:168
cs_field.h
cs_piso_t
Inner velocity/pressure iteration options descriptor.
Definition: cs_parameters.h:181
CS_DRIFT_SCALAR_TURBOPHORESIS
@ CS_DRIFT_SCALAR_TURBOPHORESIS
Definition: cs_parameters.h:130
cs_get_glob_time_scheme
cs_time_scheme_t * cs_get_glob_time_scheme(void)
Provide access to cs_glob_time_scheme.
Definition: cs_parameters.c:986
cs_solving_info_t::derive
double derive
Definition: cs_parameters.h:72
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:2314
cs_gas_mix_species_prop_t::lamref
double lamref
Definition: cs_parameters.h:89
cs_parameters_read_restart_info
void cs_parameters_read_restart_info(void)
Read general restart info.
Definition: cs_parameters.c:1198
cs_get_glob_piso
cs_piso_t * cs_get_glob_piso(void)
Provide access to cs_glob_piso.
Definition: cs_parameters.c:1002
cs_gas_mix_species_prop_t::lambda_b
double lambda_b
Definition: cs_parameters.h:87
cs_restart_auxiliary_t::read_auxiliary
int read_auxiliary
Definition: cs_parameters.h:208
CS_COUPLED_FD
@ CS_COUPLED_FD
Definition: cs_parameters.h:113
cs_gas_mix_species_prop_t::treflam
double treflam
Definition: cs_parameters.h:91
cs_parameters_set_n_buoyant_scalars
void cs_parameters_set_n_buoyant_scalars(void)
Definition: cs_parameters.c:1014
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:1261
cs_glob_restart_auxiliary
cs_restart_auxiliary_t * cs_glob_restart_auxiliary
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:1220
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:1298
cs_space_disc_t::iflxmw
int iflxmw
Definition: cs_parameters.h:157
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:2497
cs_solving_info_t
Definition: cs_parameters.h:68
CS_DRIFT_SCALAR_ADD_DRIFT_FLUX
@ CS_DRIFT_SCALAR_ADD_DRIFT_FLUX
Definition: cs_parameters.h:128
cs_parameters_create_added_properties
void cs_parameters_create_added_properties(void)
Create previously added user properties.
Definition: cs_parameters.c:1434
CS_DRIFT_SCALAR_IMPOSED_MASS_FLUX
@ CS_DRIFT_SCALAR_IMPOSED_MASS_FLUX
Definition: cs_parameters.h:133
CS_SYMMETRY
@ CS_SYMMETRY
Definition: cs_parameters.h:104
cs_piso_t::nterup
int nterup
Definition: cs_parameters.h:183
CS_COUPLED
@ CS_COUPLED
Definition: cs_parameters.h:112
cs_piso_t::epsup
double epsup
Definition: cs_parameters.h:186
cs_equation_param.h
Structure and routines handling the specific settings related to a cs_equation_t structure.
cs_piso_t::xnrmu0
double xnrmu0
Definition: cs_parameters.h:195
cs_solving_info_t::rhs_norm
double rhs_norm
Definition: cs_parameters.h:70
CS_INDEF
@ CS_INDEF
Definition: cs_parameters.h:101
cs_field_t
Field descriptor.
Definition: cs_field.h:125
CS_DRIFT_SCALAR_THERMOPHORESIS
@ CS_DRIFT_SCALAR_THERMOPHORESIS
Definition: cs_parameters.h:129
cs_space_disc_t
Space discretisation options descriptor.
Definition: cs_parameters.h:141
CS_ROUGHWALL
@ CS_ROUGHWALL
Definition: cs_parameters.h:106
CS_FREE_SURFACE
@ CS_FREE_SURFACE
Definition: cs_parameters.h:115