6.2
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  * PISO 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  * Static global variables
204  *============================================================================*/
205 
206 /* Pointer to space discretisation options structure */
207 
208 extern const cs_space_disc_t *cs_glob_space_disc;
209 
210 /* Pointer to time scheme options structure */
211 
213 
214 /* Pointer to PISO options structure */
215 
216 extern const cs_piso_t *cs_glob_piso;
217 
218 /*============================================================================
219  * Global variables
220  *============================================================================*/
221 
224 extern cs_tree_node_t *cs_glob_tree;
225 
226 /*=============================================================================
227  * Public function prototypes
228  *============================================================================*/
229 
230 /*----------------------------------------------------------------------------*/
241 /*----------------------------------------------------------------------------*/
242 
243 static inline int
244 cs_parameters_iscavr(cs_field_t *f)
245 {
246  int iscvr = 0, f_id = 0;
247  int kscavr = cs_field_key_id("first_moment_id");
248  int keysca = cs_field_key_id("scalar_id");
249 
250  if (kscavr >= 0) {
251  f_id = cs_field_get_key_int(f, kscavr);
252  if (f_id >= 0)
253  iscvr = cs_field_get_key_int(cs_field_by_id(f_id), keysca);
254  }
255 
256  return iscvr;
257 }
258 
259 /*----------------------------------------------------------------------------*/
267 /*----------------------------------------------------------------------------*/
268 
271 
272 /*----------------------------------------------------------------------------*/
280 /*----------------------------------------------------------------------------*/
281 
284 
285 /*----------------------------------------------------------------------------*/
293 /*----------------------------------------------------------------------------*/
294 
295 cs_piso_t *
296 cs_get_glob_piso(void);
297 
298 /*----------------------------------------------------------------------------
299  *!
300  * \brief Count and set number of buoyant scalars.
301  */
302 /*----------------------------------------------------------------------------*/
303 
304 void
306 
307 /*----------------------------------------------------------------------------*/
314 /*----------------------------------------------------------------------------*/
315 
316 void
318 
319 /*----------------------------------------------------------------------------*/
325 /*----------------------------------------------------------------------------*/
326 
327 void
329 
330 /*----------------------------------------------------------------------------*/
336 /*----------------------------------------------------------------------------*/
337 
338 void
340 
341 /*----------------------------------------------------------------------------*/
350 /*----------------------------------------------------------------------------*/
351 
352 void
353 cs_parameters_add_variable(const char *name,
354  int dim);
355 
356 /*----------------------------------------------------------------------------*/
365 /*----------------------------------------------------------------------------*/
366 
367 void
368 cs_parameters_add_variable_variance(const char *name,
369  const char *variable_name);
370 
371 /*----------------------------------------------------------------------------*/
379 /*----------------------------------------------------------------------------*/
380 
381 void
382 cs_parameters_add_property(const char *name,
383  int dim,
384  int location_id);
385 
386 /*----------------------------------------------------------------------------*/
395 /*----------------------------------------------------------------------------*/
396 
397 int
399 
400 /*----------------------------------------------------------------------------*/
409 /*----------------------------------------------------------------------------*/
410 
411 int
413 
414 /*----------------------------------------------------------------------------*/
418 /*----------------------------------------------------------------------------*/
419 
420 void
422 
423 /*----------------------------------------------------------------------------*/
427 /*----------------------------------------------------------------------------*/
428 
429 void
431 
432 /*----------------------------------------------------------------------------*/
440 /*----------------------------------------------------------------------------*/
441 
442 cs_field_t *
444 
445 /*----------------------------------------------------------------------------*/
456 /*----------------------------------------------------------------------------*/
457 
458 cs_field_t *
460 
461 /*----------------------------------------------------------------------------*/
468 /*----------------------------------------------------------------------------*/
469 
472 
473 /*----------------------------------------------------------------------------*/
477 /*----------------------------------------------------------------------------*/
478 
479 void
481 
482 /*----------------------------------------------------------------------------*/
483 
485 
486 #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:1438
Definition: cs_parameters.h:134
Definition: cs_parameters.h:68
double mol_mas
Definition: cs_parameters.h:81
Definition: cs_parameters.h:128
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:1313
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:2312
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:943
void cs_parameters_add_variable(const char *name, int dim)
Solved variables are always defined on cells.
Definition: cs_parameters.c:1174
void cs_parameters_read_restart_info(void)
Read general restart info.
Definition: cs_parameters.c:1152
#define BEGIN_C_DECLS
Definition: cs_defs.h:495
void cs_parameters_set_n_buoyant_scalars(void)
Definition: cs_parameters.c:971
void cs_space_disc_log_setup(void)
Print the space discretization structure to setup.log.
Definition: cs_parameters.c:1641
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:1215
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:1252
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:927
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:1388
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:2989
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:2495
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:1287
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:959
void cs_parameters_define_field_key_gas_mix(void)
Define field key for condensation.
Definition: cs_parameters.c:1130
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
PISO 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:1301
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:998
Definition: cs_parameters.h:111
Structure and routines handling the specific settings related to a cs_equation_t structure.
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:1629
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:1543
double res_norm
Definition: cs_parameters.h:71