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__ */
Definition: cs_parameters.h:127
Definition: cs_parameters.h:107
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
Definition: cs_parameters.h:134
Definition: cs_parameters.h:68
double mol_mas
Definition: cs_parameters.h:81
Definition: cs_parameters.h:128
int read_auxiliary
Definition: cs_parameters.h:208
double slam
Definition: cs_parameters.h:93
double thetst
Definition: cs_parameters.h:173
int imrgra
Definition: cs_parameters.h:147
const cs_space_disc_t * cs_glob_space_disc
Definition: cs_parameters.h:132
Definition: cs_parameters.h:104
void cs_parameters_create_added_variables(void)
Create previously added user variables.
Definition: cs_parameters.c:1359
int iflxmw
Definition: cs_parameters.h:157
Field descriptor.
Definition: cs_field.h:125
int nterup
Definition: cs_parameters.h:183
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources...
Definition: cs_equation_param.h:201
double lambda_a
Definition: cs_parameters.h:86
Definition: cs_parameters.h:116
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:2314
double smu
Definition: cs_parameters.h:92
double lambda_b
Definition: cs_parameters.h:87
cs_time_scheme_t * cs_get_glob_time_scheme(void)
Provide access to cs_glob_time_scheme.
Definition: cs_parameters.c:986
void cs_parameters_add_variable(const char *name, int dim)
Solved variables are always defined on cells.
Definition: cs_parameters.c:1220
void cs_parameters_read_restart_info(void)
Read general restart info.
Definition: cs_parameters.c:1198
#define BEGIN_C_DECLS
Definition: cs_defs.h:495
void cs_parameters_set_n_buoyant_scalars(void)
Definition: cs_parameters.c:1014
void cs_space_disc_log_setup(void)
Print the space discretization structure to setup.log.
Definition: cs_parameters.c:1687
cs_tree_node_t * cs_glob_tree
Definition: cs_parameters.h:131
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_restart_auxiliary_t * cs_glob_restart_auxiliary
double trefmu
Definition: cs_parameters.h:90
Definition: cs_parameters.h:106
void cs_parameters_add_property(const char *name, int dim, int location_id)
Define a user property.
Definition: cs_parameters.c:1298
Additional checkpoint/restart files.
Definition: cs_parameters.h:206
Definition: cs_parameters.h:115
cs_space_disc_t * cs_get_glob_space_disc(void)
Provide access to cs_glob_space_disc.
Definition: cs_parameters.c:970
Definition: cs_parameters.h:130
double cp
Definition: cs_parameters.h:82
void cs_parameters_create_added_properties(void)
Create previously added user properties.
Definition: cs_parameters.c:1434
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
Definition: cs_parameters.h:101
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:2497
Definition: cs_parameters.h:80
Definition: cs_parameters.h:102
Definition: cs_parameters.h:114
Definition: cs_parameters.h:133
double epsup
Definition: cs_parameters.h:186
int cs_parameters_n_added_variables(void)
Return the number of defined user variables not added yet.
Definition: cs_parameters.c:1333
double vol_dif
Definition: cs_parameters.h:83
cs_piso_t * cs_get_glob_piso(void)
Provide access to cs_glob_piso.
Definition: cs_parameters.c:1002
void cs_parameters_define_field_key_gas_mix(void)
Define field key for condensation.
Definition: cs_parameters.c:1176
Time scheme descriptor.
Definition: cs_parameters.h:168
int n_buoyant_scal
Definition: cs_parameters.h:197
double xnrmu
Definition: cs_parameters.h:190
const cs_piso_t * cs_glob_piso
Definition: cs_parameters.h:105
double mu_a
Definition: cs_parameters.h:84
int n_it
Definition: cs_parameters.h:69
cs_equation_param_t cs_var_cal_opt_t
Definition: cs_parameters.h:62
const cs_time_scheme_t * cs_glob_time_scheme
double l2residual
Definition: cs_parameters.h:73
Definition: cs_parameters.h:129
Inner velocity/pressure iteration options descriptor.
Definition: cs_parameters.h:181
Definition: cs_parameters.h:108
#define END_C_DECLS
Definition: cs_defs.h:496
Space discretisation options descriptor.
Definition: cs_parameters.h:141
Definition: cs_parameters.h:113
int cs_parameters_n_added_properties(void)
Return the number of defined user properties not added yet.
Definition: cs_parameters.c:1347
double lamref
Definition: cs_parameters.h:89
int isto2t
Definition: cs_parameters.h:170
Definition: cs_parameters.h:109
Definition: cs_parameters.h:110
double muref
Definition: cs_parameters.h:88
double rhs_norm
Definition: cs_parameters.h:70
void cs_parameters_define_field_keys(void)
Define general field keys.
Definition: cs_parameters.c:1041
Definition: cs_parameters.h:111
Structure and routines handling the specific settings related to a cs_equation_t structure.
int write_auxiliary
Definition: cs_parameters.h:209
Definition: cs_parameters.h:112
Definition: cs_parameters.h:103
int imvisf
Definition: cs_parameters.h:143
double xnrmu0
Definition: cs_parameters.h:195
double treflam
Definition: cs_parameters.h:91
double derive
Definition: cs_parameters.h:72
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
double mu_b
Definition: cs_parameters.h:85
cs_field_t * cs_parameters_add_boundary_temperature(void)
Define a boundary values field for temperature, if applicable.
Definition: cs_parameters.c:1589
double res_norm
Definition: cs_parameters.h:71