7.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-2022 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  * Boundary condition types
78  *----------------------------------------------------------------------------*/
79 
80 enum {
81 
82  CS_INDEF = 1,
83  CS_INLET = 2,
84  CS_OUTLET = 3,
86 
90  CS_ESICF = 7,
92  CS_SSPCF = 8,
93  CS_SOPCF = 9,
94  CS_EPHCF = 10,
96  CS_EQHCF = 11,
98  CS_COUPLED = 12,
106 };
107 
108 /*----------------------------------------------------------------------------
109  * flag for computing the drift mass flux:
110  * (for coal classes for instance, only the first
111  * scalar of a class compute the drift flux of the class
112  * and the other scalars use it without recomputing it)
113  *----------------------------------------------------------------------------*/
114 
115 enum {
116  CS_DRIFT_SCALAR_ON = (1 << 0),
125 };
126 
127 /*----------------------------------------------------------------------------
128  * Space discretisation options descriptor
129  *----------------------------------------------------------------------------*/
130 
131 typedef struct {
132 
133  int imvisf; /* face viscosity field interpolation
134  - 1: harmonic
135  - 0: arithmetic (default) */
136 
137  int imrgra; /* type of gradient reconstruction
138  - 0: iterative process
139  - 1: standard least square method
140  - 2: least square method with extended
141  neighborhood
142  - 3: least square method with reduced extended
143  neighborhood
144  - 4: Green-Gauss using least squares face
145  values interpolation */
146 
147  int iflxmw; /* method to compute interior mass flux due to ALE
148  mesh velocity
149  - 1: based on cell center mesh velocity
150  - 0: based on nodes displacement */
151 
152  int itbrrb; /* accurate treatment of the wall temperature
153  - 1: true
154  - 0: false (default) */
155 
157 
158 /*----------------------------------------------------------------------------
159  * Time scheme descriptor
160  *----------------------------------------------------------------------------*/
161 
162 typedef struct {
163 
164  int time_order; /* Global time order of the time stepping */
165 
166  int isto2t; /* time scheme activated for the source
167  terms of turbulent equations */
168 
169  double thetst; /* value of \f$theta\f$ for turbulence */
170 
171  int iccvfg; /* calculation with a fixed velocity field
172  - 1: true (default)
173  - 0: false */
175 
176 /*----------------------------------------------------------------------------
177  * Auxiliary checkpoint/restart file parameters
178  *----------------------------------------------------------------------------*/
179 
180 typedef struct {
181 
182  int read_auxiliary; /* Activate reading of auxiliary restart file */
183  int write_auxiliary; /* Activate output of auxiliary restart file */
184 
186 
187 /*============================================================================
188  * Static global variables
189  *============================================================================*/
190 
191 /* Pointer to space discretisation options structure */
192 
193 extern const cs_space_disc_t *cs_glob_space_disc;
194 
195 /* Pointer to time scheme options structure */
196 
198 
199 /* Pointer to auxiliary checkpoint/restart file parameters */
200 
202 
203 /*============================================================================
204  * Global variables
205  *============================================================================*/
206 
209 extern cs_tree_node_t *cs_glob_tree;
210 
211 /*=============================================================================
212  * Public function prototypes
213  *============================================================================*/
214 
215 /*----------------------------------------------------------------------------*/
226 /*----------------------------------------------------------------------------*/
227 
228 static inline int
230 {
231  int iscvr = 0, f_id = 0;
232  int kscavr = cs_field_key_id("first_moment_id");
233  int keysca = cs_field_key_id("scalar_id");
234 
235  if (kscavr >= 0) {
236  f_id = cs_field_get_key_int(f, kscavr);
237  if (f_id >= 0)
238  iscvr = cs_field_get_key_int(cs_field_by_id(f_id), keysca);
239  }
240 
241  return iscvr;
242 }
243 
244 /*----------------------------------------------------------------------------*/
252 /*----------------------------------------------------------------------------*/
253 
256 
257 /*----------------------------------------------------------------------------*/
265 /*----------------------------------------------------------------------------*/
266 
269 
270 /*----------------------------------------------------------------------------*/
277 /*----------------------------------------------------------------------------*/
278 
279 void
281 
282 /*----------------------------------------------------------------------------*/
288 /*----------------------------------------------------------------------------*/
289 
290 void
292 
293 /*----------------------------------------------------------------------------*/
302 /*----------------------------------------------------------------------------*/
303 
304 void
305 cs_parameters_add_variable(const char *name,
306  int dim);
307 
308 /*----------------------------------------------------------------------------*/
317 /*----------------------------------------------------------------------------*/
318 
319 void
320 cs_parameters_add_variable_variance(const char *name,
321  const char *variable_name);
322 
323 /*----------------------------------------------------------------------------*/
331 /*----------------------------------------------------------------------------*/
332 
333 void
334 cs_parameters_add_property(const char *name,
335  int dim,
336  int location_id);
337 
338 /*----------------------------------------------------------------------------*/
347 /*----------------------------------------------------------------------------*/
348 
349 int
351 
352 /*----------------------------------------------------------------------------*/
361 /*----------------------------------------------------------------------------*/
362 
363 int
365 
366 /*----------------------------------------------------------------------------*/
370 /*----------------------------------------------------------------------------*/
371 
372 void
374 
375 /*----------------------------------------------------------------------------*/
379 /*----------------------------------------------------------------------------*/
380 
381 void
383 
384 /*----------------------------------------------------------------------------*/
392 /*----------------------------------------------------------------------------*/
393 
394 cs_field_t *
396 
397 /*----------------------------------------------------------------------------*/
408 /*----------------------------------------------------------------------------*/
409 
410 cs_field_t *
412 
413 /*----------------------------------------------------------------------------*/
419 /*----------------------------------------------------------------------------*/
420 
421 bool
423 
424 /*----------------------------------------------------------------------------*/
428 /*----------------------------------------------------------------------------*/
429 
430 void
432 
433 /*----------------------------------------------------------------------------*/
437 /*----------------------------------------------------------------------------*/
438 
439 void
441 
442 /*----------------------------------------------------------------------------*/
449 /*----------------------------------------------------------------------------*/
450 
453 
454 /*----------------------------------------------------------------------------*/
458 /*----------------------------------------------------------------------------*/
459 
460 void
462 
463 /*----------------------------------------------------------------------------*/
467 /*----------------------------------------------------------------------------*/
468 
469 void
471 
472 /*----------------------------------------------------------------------------*/
473 
475 
476 #endif /* __CS_PARAMETERS_H__ */
Definition: cs_parameters.h:116
void cs_parameters_eqp_complete(void)
Complete general equation parameter definitions.
Definition: cs_parameters.c:1563
Definition: cs_parameters.h:90
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:1321
Definition: cs_parameters.h:123
Definition: cs_parameters.h:68
Definition: cs_parameters.h:117
int read_auxiliary
Definition: cs_parameters.h:182
double thetst
Definition: cs_parameters.h:169
int imrgra
Definition: cs_parameters.h:137
const cs_space_disc_t * cs_glob_space_disc
Definition: cs_parameters.h:121
Definition: cs_parameters.h:85
void cs_parameters_create_added_variables(void)
Create previously added user variables.
Definition: cs_parameters.c:1196
Definition: cs_parameters.h:124
int iflxmw
Definition: cs_parameters.h:147
Field descriptor.
Definition: cs_field.h:130
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources...
Definition: cs_equation_param.h:186
Definition: cs_parameters.h:103
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:2310
cs_time_scheme_t * cs_get_glob_time_scheme(void)
Provide access to cs_glob_time_scheme.
Definition: cs_parameters.c:866
void cs_parameters_add_variable(const char *name, int dim)
Solved variables are always defined on cells.
Definition: cs_parameters.c:1057
void cs_parameters_read_restart_info(void)
Read general restart info.
Definition: cs_parameters.c:1035
#define BEGIN_C_DECLS
Definition: cs_defs.h:512
void cs_space_disc_log_setup(void)
Print the space discretization structure to setup.log.
Definition: cs_parameters.c:1678
cs_tree_node_t * cs_glob_tree
Definition: cs_parameters.h:120
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:1098
bool cs_parameters_need_extended_neighborhood(void)
Check if extended neighborhood is needed.
Definition: cs_parameters.c:1511
cs_restart_auxiliary_t * cs_glob_restart_auxiliary
Definition: cs_parameters.h:88
void cs_parameters_add_property(const char *name, int dim, int location_id)
Define a user property.
Definition: cs_parameters.c:1135
Additional checkpoint/restart files.
Definition: cs_parameters.h:180
Definition: cs_parameters.h:102
int time_order
Definition: cs_parameters.h:164
cs_space_disc_t * cs_get_glob_space_disc(void)
Provide access to cs_glob_space_disc.
Definition: cs_parameters.c:850
Definition: cs_parameters.h:119
void cs_parameters_create_added_properties(void)
Create previously added user properties.
Definition: cs_parameters.c:1271
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:3058
Definition: cs_parameters.h:82
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:2564
Definition: cs_parameters.h:83
int iccvfg
Definition: cs_parameters.h:171
int itbrrb
Definition: cs_parameters.h:152
Definition: cs_parameters.h:100
Definition: cs_parameters.h:122
int cs_parameters_n_added_variables(void)
Return the number of defined user variables not added yet.
Definition: cs_parameters.c:1170
Time scheme descriptor.
Definition: cs_parameters.h:162
Definition: cs_parameters.h:87
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:118
void cs_time_scheme_log_setup(void)
Print the time scheme structure to setup.log.
Definition: cs_parameters.c:1652
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:229
Definition: cs_parameters.h:92
#define END_C_DECLS
Definition: cs_defs.h:513
Space discretisation options descriptor.
Definition: cs_parameters.h:131
Definition: cs_parameters.h:99
int cs_parameters_n_added_properties(void)
Return the number of defined user properties not added yet.
Definition: cs_parameters.c:1184
int isto2t
Definition: cs_parameters.h:166
Definition: cs_parameters.h:93
Definition: cs_parameters.h:94
double rhs_norm
Definition: cs_parameters.h:70
void cs_parameters_define_field_keys(void)
Define general field keys.
Definition: cs_parameters.c:881
Definition: cs_parameters.h:96
int write_auxiliary
Definition: cs_parameters.h:183
Definition: cs_parameters.h:98
Definition: cs_parameters.h:84
int imvisf
Definition: cs_parameters.h:133
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:1640
void cs_parameters_output_complete(void)
Complete general output options definitions.
Definition: cs_parameters.c:1590
cs_field_t * cs_parameters_add_boundary_temperature(void)
Define a boundary values field for temperature, if applicable.
Definition: cs_parameters.c:1426
double res_norm
Definition: cs_parameters.h:71