8.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-2023 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,
100  CS_FREE_INLET = 14,
103  CS_CONVECTIVE_INLET = 16
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 istmpf; /* time order of the mass flux scheme */
167 
168  int isno2t; /* time scheme activated for the source
169  terms of the momentum, apart from
170  convection and diffusion */
171 
172  int isto2t; /* time scheme activated for the source
173  terms of turbulent equations */
174 
175  double thetsn; /* value of \f$theta_S\f$ for Navier-Stokes
176  source terms */
177 
178  double thetst; /* value of \f$theta\f$ for turbulence
179  explicit source terms */
180 
181  double thetvi; /* value of \f$theta\f$ for total viscosity */
182 
183  double thetcp; /* value of \f$theta\f$ for specific heat */
184 
185  int iccvfg; /* calculation with a fixed velocity field
186  - 1: true (default)
187  - 0: false */
189 
190 /*----------------------------------------------------------------------------
191  * Auxiliary checkpoint/restart file parameters
192  *----------------------------------------------------------------------------*/
193 
194 typedef struct {
195 
196  int read_auxiliary; /* Activate reading of auxiliary restart file */
197  int write_auxiliary; /* Activate output of auxiliary restart file */
198 
200 
201 /*============================================================================
202  * Static global variables
203  *============================================================================*/
204 
205 /* Pointer to space discretisation options structure */
206 
207 extern const cs_space_disc_t *cs_glob_space_disc;
208 
209 /* Pointer to time scheme options structure */
210 
212 
213 /* Pointer to auxiliary checkpoint/restart file parameters */
214 
216 
217 /*============================================================================
218  * Global variables
219  *============================================================================*/
220 
223 extern cs_tree_node_t *cs_glob_tree;
224 
225 /*=============================================================================
226  * Public function prototypes
227  *============================================================================*/
228 
229 /*----------------------------------------------------------------------------*/
240 /*----------------------------------------------------------------------------*/
241 
242 static inline int
244 {
245  int iscvr = 0, f_id = 0;
246  int kscavr = cs_field_key_id("first_moment_id");
247  int keysca = cs_field_key_id("scalar_id");
248 
249  if (kscavr >= 0) {
250  f_id = cs_field_get_key_int(f, kscavr);
251  if (f_id >= 0)
252  iscvr = cs_field_get_key_int(cs_field_by_id(f_id), keysca);
253  }
254 
255  return iscvr;
256 }
257 
258 /*----------------------------------------------------------------------------*/
266 /*----------------------------------------------------------------------------*/
267 
270 
271 /*----------------------------------------------------------------------------*/
279 /*----------------------------------------------------------------------------*/
280 
283 
284 /*----------------------------------------------------------------------------*/
291 /*----------------------------------------------------------------------------*/
292 
293 void
295 
296 /*----------------------------------------------------------------------------*/
302 /*----------------------------------------------------------------------------*/
303 
304 void
306 
307 /*----------------------------------------------------------------------------*/
316 /*----------------------------------------------------------------------------*/
317 
318 void
319 cs_parameters_add_variable(const char *name,
320  int dim);
321 
322 /*----------------------------------------------------------------------------*/
331 /*----------------------------------------------------------------------------*/
332 
333 void
334 cs_parameters_add_variable_variance(const char *name,
335  const char *variable_name);
336 
337 /*----------------------------------------------------------------------------*/
345 /*----------------------------------------------------------------------------*/
346 
347 void
348 cs_parameters_add_property(const char *name,
349  int dim,
350  int location_id);
351 
352 /*----------------------------------------------------------------------------*/
361 /*----------------------------------------------------------------------------*/
362 
363 int
365 
366 /*----------------------------------------------------------------------------*/
375 /*----------------------------------------------------------------------------*/
376 
377 int
379 
380 /*----------------------------------------------------------------------------*/
384 /*----------------------------------------------------------------------------*/
385 
386 void
388 
389 /*----------------------------------------------------------------------------*/
393 /*----------------------------------------------------------------------------*/
394 
395 void
397 
398 /*----------------------------------------------------------------------------*/
406 /*----------------------------------------------------------------------------*/
407 
408 cs_field_t *
410 
411 /*----------------------------------------------------------------------------*/
422 /*----------------------------------------------------------------------------*/
423 
424 cs_field_t *
426 
427 /*----------------------------------------------------------------------------*/
433 /*----------------------------------------------------------------------------*/
434 
435 bool
437 
438 /*----------------------------------------------------------------------------*/
442 /*----------------------------------------------------------------------------*/
443 
444 void
446 
447 /*----------------------------------------------------------------------------*/
451 /*----------------------------------------------------------------------------*/
452 
453 void
455 
456 /*----------------------------------------------------------------------------*/
460 /*----------------------------------------------------------------------------*/
461 
462 void
464 
465 /*----------------------------------------------------------------------------*/
472 /*----------------------------------------------------------------------------*/
473 
476 
477 /*----------------------------------------------------------------------------*/
481 /*----------------------------------------------------------------------------*/
482 
483 void
485 
486 /*----------------------------------------------------------------------------*/
490 /*----------------------------------------------------------------------------*/
491 
492 void
494 
495 /*----------------------------------------------------------------------------*/
496 
498 
499 #endif /* __CS_PARAMETERS_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:509
#define END_C_DECLS
Definition: cs_defs.h:510
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:2316
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:3064
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:2570
void cs_parameters_read_restart_info(void)
Read general restart info.
Definition: cs_parameters.c:1150
void cs_parameters_create_added_properties(void)
Create previously added user properties.
Definition: cs_parameters.c:1386
cs_equation_param_t cs_var_cal_opt_t
Definition: cs_parameters.h:62
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:1825
int cs_parameters_n_added_properties(void)
Return the number of defined user properties not added yet.
Definition: cs_parameters.c:1299
void cs_parameters_output_complete(void)
Complete general output options definitions.
Definition: cs_parameters.c:1775
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:1436
void cs_parameters_add_variable(const char *name, int dim)
Solved variables are always defined on cells.
Definition: cs_parameters.c:1172
cs_space_disc_t * cs_get_glob_space_disc(void)
Provide access to cs_glob_space_disc.
Definition: cs_parameters.c:962
void cs_parameters_add_property(const char *name, int dim, int location_id)
Define a user property.
Definition: cs_parameters.c:1250
void cs_parameters_create_added_variables(void)
Create previously added user variables.
Definition: cs_parameters.c:1311
void cs_space_disc_log_setup(void)
Print the space discretization structure to setup.log.
Definition: cs_parameters.c:1911
cs_field_t * cs_parameters_add_boundary_temperature(void)
Define a boundary values field for temperature, if applicable.
Definition: cs_parameters.c:1541
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:1213
cs_time_scheme_t * cs_get_glob_time_scheme(void)
Provide access to cs_glob_time_scheme.
Definition: cs_parameters.c:978
@ CS_DRIFT_SCALAR_ON
Definition: cs_parameters.h:116
@ CS_DRIFT_SCALAR_THERMOPHORESIS
Definition: cs_parameters.h:118
@ CS_DRIFT_SCALAR_IMPOSED_MASS_FLUX
Definition: cs_parameters.h:122
@ CS_DRIFT_SCALAR_ADD_DRIFT_FLUX
Definition: cs_parameters.h:117
@ CS_DRIFT_SCALAR_TURBOPHORESIS
Definition: cs_parameters.h:119
@ CS_DRIFT_SCALAR_CENTRIFUGALFORCE
Definition: cs_parameters.h:121
@ CS_DRIFT_SCALAR_ELECTROPHORESIS
Definition: cs_parameters.h:120
@ CS_DRIFT_SCALAR_ZERO_BNDY_FLUX_AT_WALLS
Definition: cs_parameters.h:124
@ CS_DRIFT_SCALAR_ZERO_BNDY_FLUX
Definition: cs_parameters.h:123
int cs_parameters_n_added_variables(void)
Return the number of defined user variables not added yet.
Definition: cs_parameters.c:1285
void cs_parameters_define_field_keys(void)
Define general field keys.
Definition: cs_parameters.c:993
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:243
const cs_space_disc_t * cs_glob_space_disc
bool cs_parameters_need_extended_neighborhood(void)
Check if extended neighborhood is needed.
Definition: cs_parameters.c:1626
const cs_time_scheme_t * cs_glob_time_scheme
void cs_parameters_global_complete(void)
Complete global parameters.
Definition: cs_parameters.c:1678
void cs_time_scheme_log_setup(void)
Print the time scheme structure to setup.log.
Definition: cs_parameters.c:1837
@ CS_OUTLET
Definition: cs_parameters.h:84
@ CS_COUPLED_FD
Definition: cs_parameters.h:99
@ CS_EPHCF
Definition: cs_parameters.h:94
@ CS_INLET
Definition: cs_parameters.h:83
@ CS_COUPLED
Definition: cs_parameters.h:98
@ CS_ESICF
Definition: cs_parameters.h:90
@ CS_INDEF
Definition: cs_parameters.h:82
@ CS_CONVECTIVE_INLET
Definition: cs_parameters.h:103
@ CS_ROUGHWALL
Definition: cs_parameters.h:88
@ CS_SOPCF
Definition: cs_parameters.h:93
@ CS_SSPCF
Definition: cs_parameters.h:92
@ CS_FREE_INLET
Definition: cs_parameters.h:100
@ CS_EQHCF
Definition: cs_parameters.h:96
@ CS_SMOOTHWALL
Definition: cs_parameters.h:87
@ CS_SYMMETRY
Definition: cs_parameters.h:85
@ CS_FREE_SURFACE
Definition: cs_parameters.h:102
void cs_parameters_eqp_complete(void)
Complete general equation parameter definitions.
Definition: cs_parameters.c:1689
cs_restart_auxiliary_t * cs_glob_restart_auxiliary
cs_tree_node_t * cs_glob_tree
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:192
Field descriptor.
Definition: cs_field.h:130
Additional checkpoint/restart files.
Definition: cs_parameters.h:194
int read_auxiliary
Definition: cs_parameters.h:196
int write_auxiliary
Definition: cs_parameters.h:197
Definition: cs_parameters.h:68
int n_it
Definition: cs_parameters.h:69
double rhs_norm
Definition: cs_parameters.h:70
double res_norm
Definition: cs_parameters.h:71
double derive
Definition: cs_parameters.h:72
double l2residual
Definition: cs_parameters.h:73
Space discretisation options descriptor.
Definition: cs_parameters.h:131
int iflxmw
Definition: cs_parameters.h:147
int imrgra
Definition: cs_parameters.h:137
int itbrrb
Definition: cs_parameters.h:152
int imvisf
Definition: cs_parameters.h:133
Time scheme descriptor.
Definition: cs_parameters.h:162
int isno2t
Definition: cs_parameters.h:168
double thetvi
Definition: cs_parameters.h:181
int istmpf
Definition: cs_parameters.h:166
double thetsn
Definition: cs_parameters.h:175
int time_order
Definition: cs_parameters.h:164
int isto2t
Definition: cs_parameters.h:172
int iccvfg
Definition: cs_parameters.h:185
double thetst
Definition: cs_parameters.h:178
double thetcp
Definition: cs_parameters.h:183