7.0
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-2021 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),
136 };
137 
138 /*----------------------------------------------------------------------------
139  * Space discretisation options descriptor
140  *----------------------------------------------------------------------------*/
141 
142 typedef struct {
143 
144  int imvisf; /* face viscosity field interpolation
145  - 1: harmonic
146  - 0: arithmetic (default) */
147 
148  int imrgra; /* type of gradient reconstruction
149  - 0: iterative process
150  - 1: standard least square method
151  - 2: least square method with extended
152  neighborhood
153  - 3: least square method with reduced extended
154  neighborhood
155  - 4: Green-Gauss using least squares face
156  values interpolation */
157 
158  int iflxmw; /* method to compute interior mass flux due to ALE
159  mesh velocity
160  - 1: based on cell center mesh velocity
161  - 0: based on nodes displacement */
162 
163  int itbrrb; /* accurate treatment of the wall temperature
164  - 1: true
165  - 0: false (default) */
166 
168 
169 /*----------------------------------------------------------------------------
170  * Time scheme descriptor
171  *----------------------------------------------------------------------------*/
172 
173 typedef struct {
174 
175  int time_order; /* Global time order of the time stepping */
176 
177  int isto2t; /* time scheme activated for the source
178  terms of turbulent equations */
179 
180  double thetst; /* value of \f$theta\f$ for turbulence */
181 
182  int iccvfg; /* calculation with a fixed velocity field
183  - 1: true (default)
184  - 0: false */
186 
187 /*----------------------------------------------------------------------------
188  * Auxiliary checkpoint/restart file parameters
189  *----------------------------------------------------------------------------*/
190 
191 typedef struct {
192 
193  int read_auxiliary; /* Activate reading of auxiliary restart file */
194  int write_auxiliary; /* Activate output of auxiliary restart file */
195 
197 
198 /*============================================================================
199  * Static global variables
200  *============================================================================*/
201 
202 /* Pointer to space discretisation options structure */
203 
204 extern const cs_space_disc_t *cs_glob_space_disc;
205 
206 /* Pointer to time scheme options structure */
207 
209 
210 /* Pointer to auxiliary checkpoint/restart file parameters */
211 
213 
214 /*============================================================================
215  * Global variables
216  *============================================================================*/
217 
220 extern cs_tree_node_t *cs_glob_tree;
221 
222 /*=============================================================================
223  * Public function prototypes
224  *============================================================================*/
225 
226 /*----------------------------------------------------------------------------*/
237 /*----------------------------------------------------------------------------*/
238 
239 static inline int
240 cs_parameters_iscavr(cs_field_t *f)
241 {
242  int iscvr = 0, f_id = 0;
243  int kscavr = cs_field_key_id("first_moment_id");
244  int keysca = cs_field_key_id("scalar_id");
245 
246  if (kscavr >= 0) {
247  f_id = cs_field_get_key_int(f, kscavr);
248  if (f_id >= 0)
249  iscvr = cs_field_get_key_int(cs_field_by_id(f_id), keysca);
250  }
251 
252  return iscvr;
253 }
254 
255 /*----------------------------------------------------------------------------*/
263 /*----------------------------------------------------------------------------*/
264 
267 
268 /*----------------------------------------------------------------------------*/
276 /*----------------------------------------------------------------------------*/
277 
280 
281 /*----------------------------------------------------------------------------*/
288 /*----------------------------------------------------------------------------*/
289 
290 void
292 
293 /*----------------------------------------------------------------------------*/
299 /*----------------------------------------------------------------------------*/
300 
301 void
303 
304 /*----------------------------------------------------------------------------*/
310 /*----------------------------------------------------------------------------*/
311 
312 void
314 
315 /*----------------------------------------------------------------------------*/
324 /*----------------------------------------------------------------------------*/
325 
326 void
327 cs_parameters_add_variable(const char *name,
328  int dim);
329 
330 /*----------------------------------------------------------------------------*/
339 /*----------------------------------------------------------------------------*/
340 
341 void
342 cs_parameters_add_variable_variance(const char *name,
343  const char *variable_name);
344 
345 /*----------------------------------------------------------------------------*/
353 /*----------------------------------------------------------------------------*/
354 
355 void
356 cs_parameters_add_property(const char *name,
357  int dim,
358  int location_id);
359 
360 /*----------------------------------------------------------------------------*/
369 /*----------------------------------------------------------------------------*/
370 
371 int
373 
374 /*----------------------------------------------------------------------------*/
383 /*----------------------------------------------------------------------------*/
384 
385 int
387 
388 /*----------------------------------------------------------------------------*/
392 /*----------------------------------------------------------------------------*/
393 
394 void
396 
397 /*----------------------------------------------------------------------------*/
401 /*----------------------------------------------------------------------------*/
402 
403 void
405 
406 /*----------------------------------------------------------------------------*/
414 /*----------------------------------------------------------------------------*/
415 
416 cs_field_t *
418 
419 /*----------------------------------------------------------------------------*/
430 /*----------------------------------------------------------------------------*/
431 
432 cs_field_t *
434 
435 /*----------------------------------------------------------------------------*/
442 /*----------------------------------------------------------------------------*/
443 
446 
447 /*----------------------------------------------------------------------------*/
451 /*----------------------------------------------------------------------------*/
452 
453 void
455 
456 /*----------------------------------------------------------------------------*/
460 /*----------------------------------------------------------------------------*/
461 
462 void
464 
465 /*----------------------------------------------------------------------------*/
466 
468 
469 #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:1401
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:193
double slam
Definition: cs_parameters.h:93
double thetst
Definition: cs_parameters.h:180
int imrgra
Definition: cs_parameters.h:148
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:1276
Definition: cs_parameters.h:135
int iflxmw
Definition: cs_parameters.h:158
Field descriptor.
Definition: cs_field.h:125
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources...
Definition: cs_equation_param.h:202
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:943
void cs_parameters_add_variable(const char *name, int dim)
Solved variables are always defined on cells.
Definition: cs_parameters.c:1137
void cs_parameters_read_restart_info(void)
Read general restart info.
Definition: cs_parameters.c:1115
#define BEGIN_C_DECLS
Definition: cs_defs.h:495
void cs_space_disc_log_setup(void)
Print the space discretization structure to setup.log.
Definition: cs_parameters.c:1630
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:1178
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:1215
Additional checkpoint/restart files.
Definition: cs_parameters.h:191
Definition: cs_parameters.h:115
int time_order
Definition: cs_parameters.h:175
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:1351
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
int iccvfg
Definition: cs_parameters.h:182
int itbrrb
Definition: cs_parameters.h:163
Definition: cs_parameters.h:114
Definition: cs_parameters.h:133
int cs_parameters_n_added_variables(void)
Return the number of defined user variables not added yet.
Definition: cs_parameters.c:1250
double vol_dif
Definition: cs_parameters.h:83
void cs_parameters_define_field_key_gas_mix(void)
Define field key for condensation.
Definition: cs_parameters.c:1093
Time scheme descriptor.
Definition: cs_parameters.h:173
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
void cs_time_scheme_log_setup(void)
Print the time scheme structure to setup.log.
Definition: cs_parameters.c:1604
Definition: cs_parameters.h:108
#define END_C_DECLS
Definition: cs_defs.h:496
Space discretisation options descriptor.
Definition: cs_parameters.h:142
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:1264
double lamref
Definition: cs_parameters.h:89
int isto2t
Definition: cs_parameters.h:177
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:958
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:194
Definition: cs_parameters.h:112
Definition: cs_parameters.h:103
int imvisf
Definition: cs_parameters.h:144
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:1592
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:1506
double res_norm
Definition: cs_parameters.h:71