8.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-2024 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 
70  int n_it;
71  double rhs_norm;
72  double res_norm;
73  double derive;
74  double l2residual;
75 
77 
78 /*----------------------------------------------------------------------------
79  * Boundary condition types
80  *----------------------------------------------------------------------------*/
81 
82 enum {
83 
84  CS_INDEF = 1,
85  CS_INLET = 2,
86  CS_OUTLET = 3,
88 
92  CS_ESICF = 7,
94  CS_SSPCF = 8,
95  CS_SOPCF = 9,
96  CS_EPHCF = 10,
98  CS_EQHCF = 11,
100  CS_COUPLED = 12,
102  CS_FREE_INLET = 14,
105  CS_CONVECTIVE_INLET = 16
108 };
109 
110 /*----------------------------------------------------------------------------
111  * flag for computing the drift mass flux:
112  * (for coal classes for instance, only the first
113  * scalar of a class compute the drift flux of the class
114  * and the other scalars use it without recomputing it)
115  *----------------------------------------------------------------------------*/
116 
117 enum {
118 
119  CS_DRIFT_SCALAR_ON = (1 << 0),
129 
130 };
131 
132 /*----------------------------------------------------------------------------
133  * Space discretisation options descriptor
134  *----------------------------------------------------------------------------*/
135 
136 typedef struct {
137 
138  int imvisf; /* face viscosity field interpolation
139  - 1: harmonic
140  - 0: arithmetic (default) */
141 
142  int imrgra; /* type of gradient reconstruction
143  - 0: iterative process
144  - 1: standard least square method
145  - 2: least square method with extended
146  neighborhood
147  - 3: least square method with reduced extended
148  neighborhood
149  - 4: Green-Gauss using least squares face
150  values interpolation */
151 
152  int iflxmw; /* method to compute interior mass flux due to ALE
153  mesh velocity
154  - 1: based on cell center mesh velocity
155  - 0: based on nodes displacement */
156 
157  int itbrrb; /* accurate treatment of the wall temperature
158  - 1: true
159  - 0: false (default) */
160 
162 
163 /*----------------------------------------------------------------------------
164  * Time scheme descriptor
165  *----------------------------------------------------------------------------*/
166 
167 typedef struct {
168 
169  int time_order; /* global time order of the time stepping */
170 
171  int istmpf; /* time order of the mass flux scheme */
172 
173  int isno2t; /* time scheme activated for the source
174  terms of the momentum, apart from
175  convection and diffusion */
176 
177  int isto2t; /* time scheme activated for the source
178  terms of turbulent equations */
179 
180  double thetsn; /* value of \f$theta_S\f$ for Navier-Stokes
181  source terms */
182 
183  double thetst; /* value of \f$theta\f$ for turbulence
184  explicit source terms */
185 
186  double thetvi; /* value of \f$theta\f$ for total viscosity */
187 
188  double thetcp; /* value of \f$theta\f$ for specific heat */
189 
190  int iccvfg; /* calculation with a fixed velocity field
191  - 1: true (default)
192  - 0: false */
194 
195 /*----------------------------------------------------------------------------
196  * Auxiliary checkpoint/restart file parameters
197  *----------------------------------------------------------------------------*/
198 
199 typedef struct {
200 
201  int read_auxiliary; /* Activate reading of auxiliary restart file */
202  int write_auxiliary; /* Activate output of auxiliary restart file */
203 
205 
206 /*============================================================================
207  * Static global variables
208  *============================================================================*/
209 
210 /* Pointer to space discretisation options structure */
211 
212 extern const cs_space_disc_t *cs_glob_space_disc;
213 
214 /* Pointer to time scheme options structure */
215 
217 
218 /* Pointer to auxiliary checkpoint/restart file parameters */
219 
221 
222 /*============================================================================
223  * Global variables
224  *============================================================================*/
225 
228 extern cs_tree_node_t *cs_glob_tree;
229 
230 /*=============================================================================
231  * Public function prototypes
232  *============================================================================*/
233 
234 /*----------------------------------------------------------------------------*/
245 /*----------------------------------------------------------------------------*/
246 
247 static inline int
249 {
250  int iscvr = 0, f_id = 0;
251  int kscavr = cs_field_key_id("first_moment_id");
252  int keysca = cs_field_key_id("scalar_id");
253 
254  if (kscavr >= 0) {
255  f_id = cs_field_get_key_int(f, kscavr);
256  if (f_id >= 0)
257  iscvr = cs_field_get_key_int(cs_field_by_id(f_id), keysca);
258  }
259 
260  return iscvr;
261 }
262 
263 /*----------------------------------------------------------------------------*/
271 /*----------------------------------------------------------------------------*/
272 
275 
276 /*----------------------------------------------------------------------------*/
284 /*----------------------------------------------------------------------------*/
285 
288 
289 /*----------------------------------------------------------------------------*/
296 /*----------------------------------------------------------------------------*/
297 
298 void
300 
301 /*----------------------------------------------------------------------------*/
308 /*----------------------------------------------------------------------------*/
309 
310 void
312 
313 /*----------------------------------------------------------------------------*/
319 /*----------------------------------------------------------------------------*/
320 
321 void
323 
324 /*----------------------------------------------------------------------------*/
325 /*
326  * \brief Define a user variable.
327  *
328  * Solved variables are always defined on cells.
329  *
330  * \param[in] name name of variable and associated field
331  * \param[in] dim variable dimension
332  */
333 /*----------------------------------------------------------------------------*/
334 
335 void
336 cs_parameters_add_variable(const char *name,
337  int dim);
338 
339 /*----------------------------------------------------------------------------*/
348 /*----------------------------------------------------------------------------*/
349 
350 void
351 cs_parameters_add_variable_variance(const char *name,
352  const char *variable_name);
353 
354 /*----------------------------------------------------------------------------*/
362 /*----------------------------------------------------------------------------*/
363 
364 void
365 cs_parameters_add_property(const char *name,
366  int dim,
367  int location_id);
368 
369 /*----------------------------------------------------------------------------*/
378 /*----------------------------------------------------------------------------*/
379 
380 int
382 
383 /*----------------------------------------------------------------------------*/
392 /*----------------------------------------------------------------------------*/
393 
394 int
396 
397 /*----------------------------------------------------------------------------*/
401 /*----------------------------------------------------------------------------*/
402 
403 void
405 
406 /*----------------------------------------------------------------------------*/
410 /*----------------------------------------------------------------------------*/
411 
412 void
414 
415 /*----------------------------------------------------------------------------*/
419 /*----------------------------------------------------------------------------*/
420 
421 void
423 
424 /*----------------------------------------------------------------------------*/
425 /*
426  * \brief Define a boundary values field for a variable field.
427  *
428  * \param[in, out] f pointer to field structure
429  *
430  * \return pointer to boundary values field, or NULL if not applicable
431  */
432 /*----------------------------------------------------------------------------*/
433 
434 cs_field_t *
436 
437 /*----------------------------------------------------------------------------*/
438 /*
439  * \brief Define a boundary values field for temperature, if applicable.
440  *
441  * When a volume temperature variable field already exists, this amounts
442  * to calling \ref cs_parameters_add_boundary_values for that field.
443  * When such a variable does not exist but we have an Enthalpy variables,
444  * an associated temperature boundary field is returned.
445  *
446  * \return pointer to boundary values field, or NULL if not applicable
447  */
448 /*----------------------------------------------------------------------------*/
449 
450 cs_field_t *
452 
453 /*----------------------------------------------------------------------------*/
459 /*----------------------------------------------------------------------------*/
460 
461 bool
463 
464 /*----------------------------------------------------------------------------*/
468 /*----------------------------------------------------------------------------*/
469 
470 void
472 
473 /*----------------------------------------------------------------------------*/
480 /*----------------------------------------------------------------------------*/
481 
482 void
484 
485 /*----------------------------------------------------------------------------*/
489 /*----------------------------------------------------------------------------*/
490 
491 void
493 
494 /*----------------------------------------------------------------------------*/
501 /*----------------------------------------------------------------------------*/
502 
505 
506 /*----------------------------------------------------------------------------*/
510 /*----------------------------------------------------------------------------*/
511 
512 void
514 
515 /*----------------------------------------------------------------------------*/
519 /*----------------------------------------------------------------------------*/
520 
521 void
523 
524 /*----------------------------------------------------------------------------*/
525 
527 
528 #endif /* __CS_PARAMETERS_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:528
#define END_C_DECLS
Definition: cs_defs.h:529
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:2465
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:3213
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:2719
void cs_parameters_read_restart_info(void)
Read general restart info.
Definition: cs_parameters.c:1188
void cs_parameters_create_added_properties(void)
Create previously added user properties.
Definition: cs_parameters.c:1574
cs_equation_param_t cs_var_cal_opt_t
Definition: cs_parameters.h:62
int cs_parameters_n_added_properties(void)
Return the number of defined user properties not added yet.
Definition: cs_parameters.c:1338
void cs_parameters_output_complete(void)
Complete general output options definitions.
Definition: cs_parameters.c:1979
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:1624
void cs_parameters_define_auxiliary_fields(void)
Create properties definied directly in C.
Definition: cs_parameters.c:1425
void cs_parameters_add_variable(const char *name, int dim)
Define a user variable.
Definition: cs_parameters.c:1211
cs_space_disc_t * cs_get_glob_space_disc(void)
Provide access to cs_glob_space_disc.
Definition: cs_parameters.c:977
void cs_parameters_add_property(const char *name, int dim, int location_id)
Define a user property.
Definition: cs_parameters.c:1289
void cs_parameters_create_added_variables(void)
Create previously added user variables.
Definition: cs_parameters.c:1350
void cs_space_disc_log_setup(void)
Print the space discretization structure to setup.log.
Definition: cs_parameters.c:2145
cs_equation_param_t cs_parameters_equation_param_default(void)
Return a local equation param structure, with default options.
Definition: cs_parameters.c:2059
cs_field_t * cs_parameters_add_boundary_temperature(void)
Define a boundary values field for temperature, if applicable.
Definition: cs_parameters.c:1734
void cs_parameters_set_init_state_on(int idx)
Set init state to 1. This is necessary for fortran mapping and should be changed in the future.
Definition: cs_parameters.c:1008
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:1252
cs_time_scheme_t * cs_get_glob_time_scheme(void)
Provide access to cs_glob_time_scheme.
Definition: cs_parameters.c:993
int cs_parameters_n_added_variables(void)
Return the number of defined user variables not added yet.
Definition: cs_parameters.c:1324
void cs_parameters_define_field_keys(void)
Define general field keys.
Definition: cs_parameters.c:1030
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:248
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:1820
@ CS_DRIFT_SCALAR_ON
Definition: cs_parameters.h:119
@ CS_DRIFT_SCALAR_THERMOPHORESIS
Definition: cs_parameters.h:121
@ CS_DRIFT_SCALAR_IMPOSED_MASS_FLUX
Definition: cs_parameters.h:125
@ CS_DRIFT_SCALAR_NO_MASS_AGGREGATION
Definition: cs_parameters.h:128
@ CS_DRIFT_SCALAR_ADD_DRIFT_FLUX
Definition: cs_parameters.h:120
@ CS_DRIFT_SCALAR_TURBOPHORESIS
Definition: cs_parameters.h:122
@ CS_DRIFT_SCALAR_CENTRIFUGALFORCE
Definition: cs_parameters.h:124
@ CS_DRIFT_SCALAR_ELECTROPHORESIS
Definition: cs_parameters.h:123
@ CS_DRIFT_SCALAR_ZERO_BNDY_FLUX_AT_WALLS
Definition: cs_parameters.h:127
@ CS_DRIFT_SCALAR_ZERO_BNDY_FLUX
Definition: cs_parameters.h:126
const cs_time_scheme_t * cs_glob_time_scheme
void cs_parameters_global_complete(void)
Complete global parameters.
Definition: cs_parameters.c:1872
@ CS_OUTLET
Definition: cs_parameters.h:86
@ CS_COUPLED_FD
Definition: cs_parameters.h:101
@ CS_EPHCF
Definition: cs_parameters.h:96
@ CS_INLET
Definition: cs_parameters.h:85
@ CS_COUPLED
Definition: cs_parameters.h:100
@ CS_ESICF
Definition: cs_parameters.h:92
@ CS_INDEF
Definition: cs_parameters.h:84
@ CS_CONVECTIVE_INLET
Definition: cs_parameters.h:105
@ CS_ROUGHWALL
Definition: cs_parameters.h:90
@ CS_SOPCF
Definition: cs_parameters.h:95
@ CS_SSPCF
Definition: cs_parameters.h:94
@ CS_FREE_INLET
Definition: cs_parameters.h:102
@ CS_EQHCF
Definition: cs_parameters.h:98
@ CS_SMOOTHWALL
Definition: cs_parameters.h:89
@ CS_SYMMETRY
Definition: cs_parameters.h:87
@ CS_FREE_SURFACE
Definition: cs_parameters.h:104
void cs_time_scheme_log_setup(void)
Print the time scheme structure to setup.log.
Definition: cs_parameters.c:2071
void cs_parameters_eqp_complete(void)
Complete general equation parameter definitions.
Definition: cs_parameters.c:1888
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:193
Field descriptor.
Definition: cs_field.h:131
Additional checkpoint/restart files.
Definition: cs_parameters.h:199
int read_auxiliary
Definition: cs_parameters.h:201
int write_auxiliary
Definition: cs_parameters.h:202
Definition: cs_parameters.h:68
int n_it
Definition: cs_parameters.h:70
double rhs_norm
Definition: cs_parameters.h:71
double res_norm
Definition: cs_parameters.h:72
double derive
Definition: cs_parameters.h:73
double l2residual
Definition: cs_parameters.h:74
Space discretisation options descriptor.
Definition: cs_parameters.h:136
int iflxmw
Definition: cs_parameters.h:152
int imrgra
Definition: cs_parameters.h:142
int itbrrb
Definition: cs_parameters.h:157
int imvisf
Definition: cs_parameters.h:138
Time scheme descriptor.
Definition: cs_parameters.h:167
int isno2t
Definition: cs_parameters.h:173
double thetvi
Definition: cs_parameters.h:186
int istmpf
Definition: cs_parameters.h:171
double thetsn
Definition: cs_parameters.h:180
int time_order
Definition: cs_parameters.h:169
int isto2t
Definition: cs_parameters.h:177
int iccvfg
Definition: cs_parameters.h:190
double thetst
Definition: cs_parameters.h:183
double thetcp
Definition: cs_parameters.h:188