9.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-2026 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 "base/cs_defs.h"
42#include "base/cs_field.h"
43#include "base/cs_tree.h"
44
45/*=============================================================================
46 * Macro definitions
47 *============================================================================*/
48
49/*============================================================================
50 * Type definitions
51 *============================================================================*/
52
53/*----------------------------------------------------------------------------
54 * Structure of variable calculation options
55 * (now an alias of cs_equation_param_t)
56 *----------------------------------------------------------------------------*/
57
59
60/*----------------------------------------------------------------------------
61 * Structure of the solving info
62 *----------------------------------------------------------------------------*/
63
64typedef struct {
65
66 int n_it;
67 double rhs_norm;
68 double res_norm;
69 double derive;
70 double l2residual;
71
73
74/*----------------------------------------------------------------------------
75 * Boundary condition types
76 *----------------------------------------------------------------------------*/
77
78#define CS_INDEF CS_UNDEF /* For backward compatibility with 9.0 */
79
80enum {
81
86
90 CS_ESICF = 7,
94 CS_EPHCF = 10,
96 CS_EQHCF = 11,
100 CS_FREE_INLET = 14,
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
115enum {
116
127
129
130/*----------------------------------------------------------------------------
131 * Space discretisation options descriptor
132 *----------------------------------------------------------------------------*/
133
134typedef struct {
135
136 int imvisf; /* face viscosity field interpolation
137 - 1: harmonic
138 - 0: arithmetic (default) */
139
140 int imrgra; /* type of gradient reconstruction
141 - 0: iterative process
142 - 1: standard least square method
143 - 2: least square method with extended
144 neighborhood
145 - 3: least square method with reduced extended
146 neighborhood
147 - 4: Green-Gauss using least squares face
148 values interpolation */
149
150 int iflxmw; /* method to compute interior mass flux due to ALE
151 mesh velocity
152 - 1: based on cell center mesh velocity
153 - 0: based on nodes displacement */
154
155 int itbrrb; /* accurate treatment of the wall temperature
156 - 1: true
157 - 0: false (default) */
158
160
161/*----------------------------------------------------------------------------
162 * Time scheme descriptor
163 *----------------------------------------------------------------------------*/
164
165typedef struct {
166
167 int time_order; /* global time order of the time stepping */
168
169 int istmpf; /* time order of the mass flux scheme */
170
171 int isno2t; /* time scheme activated for the source
172 terms of the momentum, apart from
173 convection and diffusion */
174
175 int isto2t; /* time scheme activated for the source
176 terms of turbulent equations */
177
178 double thetsn; /* value of \f$theta_S\f$ for Navier-Stokes
179 source terms */
180
181 double thetst; /* value of \f$theta\f$ for turbulence
182 explicit source terms */
183
184 double thetvi; /* value of \f$theta\f$ for total viscosity */
185
186 double thetcp; /* value of \f$theta\f$ for specific heat */
187
188 int iccvfg; /* calculation with a fixed velocity field
189 - 1: true (default)
190 - 0: false */
192
193/*----------------------------------------------------------------------------
194 * Auxiliary checkpoint/restart file parameters
195 *----------------------------------------------------------------------------*/
196
197typedef struct {
198
199 int read_auxiliary; /* Activate reading of auxiliary restart file */
200 int write_auxiliary; /* Activate output of auxiliary restart file */
201
203
204/*============================================================================
205 * Static global variables
206 *============================================================================*/
207
208/* Pointer to space discretisation options structure */
209
211
212/* Pointer to time scheme options structure */
213
215
216/* Pointer to auxiliary checkpoint/restart file parameters */
217
219
220/*============================================================================
221 * Global variables
222 *============================================================================*/
223
226extern cs_tree_node_t *cs_glob_tree;
227
228/*=============================================================================
229 * Public function prototypes
230 *============================================================================*/
231
232/*----------------------------------------------------------------------------*/
243/*----------------------------------------------------------------------------*/
244
245inline int
247{
248 int iscvr = 0, f_id = 0;
249 int kscavr = cs_field_key_id("first_moment_id");
250 int keysca = cs_field_key_id("scalar_id");
251
252 if (kscavr >= 0) {
253 f_id = f->get_key_int(kscavr);
254 if (f_id >= 0)
255 iscvr = cs_field_by_id(f_id)->get_key_int(keysca);
256 }
257
258 return iscvr;
259}
260
261/*----------------------------------------------------------------------------*/
269/*----------------------------------------------------------------------------*/
270
273
274/*----------------------------------------------------------------------------*/
282/*----------------------------------------------------------------------------*/
283
286
287/*----------------------------------------------------------------------------*/
294/*----------------------------------------------------------------------------*/
295
296void
298
299/*----------------------------------------------------------------------------*/
306/*----------------------------------------------------------------------------*/
307
308void
310
311/*----------------------------------------------------------------------------*/
317/*----------------------------------------------------------------------------*/
318
319void
321
322/*----------------------------------------------------------------------------*/
323/*
324 * \brief Define a user variable.
325 *
326 * Solved variables are always defined on cells.
327 *
328 * \param[in] name name of variable and associated field
329 * \param[in] dim variable dimension
330 */
331/*----------------------------------------------------------------------------*/
332
333void
334cs_parameters_add_variable(const char *name,
335 int dim);
336
337/*----------------------------------------------------------------------------*/
346/*----------------------------------------------------------------------------*/
347
348void
350 const char *variable_name);
351
352/*----------------------------------------------------------------------------*/
360/*----------------------------------------------------------------------------*/
361
362void
363cs_parameters_add_property(const char *name,
364 int dim,
365 int location_id);
366
367/*----------------------------------------------------------------------------*/
376/*----------------------------------------------------------------------------*/
377
378int
380
381/*----------------------------------------------------------------------------*/
390/*----------------------------------------------------------------------------*/
391
392int
394
395/*----------------------------------------------------------------------------*/
399/*----------------------------------------------------------------------------*/
400
401void
403
404/*----------------------------------------------------------------------------*/
408/*----------------------------------------------------------------------------*/
409
410void
412
413/*----------------------------------------------------------------------------*/
417/*----------------------------------------------------------------------------*/
418
419void
421
422/*----------------------------------------------------------------------------*/
423/*
424 * \brief Add field indexes associated with a new non-user solved scalar
425 * variable, with default options.
426 *
427 * \param[in, out] f field
428 */
429/*----------------------------------------------------------------------------*/
430
431void
433
434/*----------------------------------------------------------------------------*/
435/*
436 * \brief Define a boundary values field for a variable field.
437 *
438 * \param[in, out] f pointer to field structure
439 *
440 * \return pointer to boundary values field, or NULL if not applicable
441 */
442/*----------------------------------------------------------------------------*/
443
446
447/*----------------------------------------------------------------------------*/
448/*
449 * \brief Define a boundary values field for temperature, if applicable.
450 *
451 * When a volume temperature variable field already exists, this amounts
452 * to calling \ref cs_parameters_add_boundary_values for that field.
453 * When such a variable does not exist but we have an Enthalpy variables,
454 * an associated temperature boundary field is returned.
455 *
456 * \return pointer to boundary values field, or NULL if not applicable
457 */
458/*----------------------------------------------------------------------------*/
459
462
463/*----------------------------------------------------------------------------*/
469/*----------------------------------------------------------------------------*/
470
471bool
473
474/*----------------------------------------------------------------------------*/
478/*----------------------------------------------------------------------------*/
479
480void
482
483/*----------------------------------------------------------------------------*/
490/*----------------------------------------------------------------------------*/
491
492void
494
495/*----------------------------------------------------------------------------*/
499/*----------------------------------------------------------------------------*/
500
501void
503
504/*----------------------------------------------------------------------------*/
511/*----------------------------------------------------------------------------*/
512
515
516/*----------------------------------------------------------------------------*/
520/*----------------------------------------------------------------------------*/
521
522void
524
525/*----------------------------------------------------------------------------*/
529/*----------------------------------------------------------------------------*/
530
531void
533
534/*----------------------------------------------------------------------------*/
535
536#endif /* CS_PARAMETERS_H */
Field descriptor.
Definition: cs_field.h:275
int get_key_int(int key_id) const
Return a integer value for a given key associated with a field.
Definition: cs_field.cpp:4507
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.cpp:2412
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.cpp:2728
void cs_parameters_read_restart_info(void)
Read general restart info.
Definition: cs_parameters.cpp:937
void cs_parameters_create_added_properties(void)
Create previously added user properties.
Definition: cs_parameters.cpp:1332
cs_equation_param_t cs_var_cal_opt_t
Definition: cs_parameters.h:58
int cs_parameters_n_added_properties(void)
Return the number of defined user properties not added yet.
Definition: cs_parameters.cpp:1087
void cs_parameters_output_complete(void)
Complete general output options definitions.
Definition: cs_parameters.cpp:2550
void cs_parameters_define_auxiliary_fields(void)
Create properties definied directly in C.
Definition: cs_parameters.cpp:1174
void cs_parameters_add_variable(const char *name, int dim)
Define a user variable.
Definition: cs_parameters.cpp:960
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:246
void cs_parameters_add_property(const char *name, int dim, int location_id)
Define a user property.
Definition: cs_parameters.cpp:1038
cs_field_t * cs_parameters_add_boundary_temperature(void)
Define a boundary values field for temperature, if applicable.
Definition: cs_parameters.cpp:1505
void cs_parameters_create_added_variables(void)
Create previously added user variables.
Definition: cs_parameters.cpp:1099
void cs_space_disc_log_setup(void)
Print the space discretization structure to setup.log.
Definition: cs_parameters.cpp:2716
cs_equation_param_t cs_parameters_equation_param_default(void)
Return a local equation param structure, with default options.
Definition: cs_parameters.cpp:2630
void cs_add_model_field_indexes(cs_field_t *f)
Add field indexes associated with a new non-user solved scalar variable, with default options.
Definition: cs_parameters.cpp:1381
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.cpp:761
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.cpp:1001
@ 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_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
@ CS_UNDEF
Definition: cs_parameters.h:82
int cs_parameters_n_added_variables(void)
Return the number of defined user variables not added yet.
Definition: cs_parameters.cpp:1073
void cs_parameters_define_field_keys(void)
Define general field keys.
Definition: cs_parameters.cpp:779
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.cpp:1589
const cs_time_scheme_t * cs_glob_time_scheme
@ CS_DRIFT_SCALAR_ON
Definition: cs_parameters.h:117
@ CS_DRIFT_SCALAR_THERMOPHORESIS
Definition: cs_parameters.h:119
@ CS_DRIFT_SCALAR_IMPOSED_MASS_FLUX
Definition: cs_parameters.h:123
@ CS_DRIFT_SCALAR_NO_MASS_AGGREGATION
Definition: cs_parameters.h:126
@ CS_DRIFT_SCALAR_ADD_DRIFT_FLUX
Definition: cs_parameters.h:118
@ CS_DRIFT_SCALAR_TURBOPHORESIS
Definition: cs_parameters.h:120
@ CS_DRIFT_SCALAR_CENTRIFUGALFORCE
Definition: cs_parameters.h:122
@ CS_DRIFT_SCALAR_ELECTROPHORESIS
Definition: cs_parameters.h:121
@ CS_DRIFT_SCALAR_ZERO_BNDY_FLUX_AT_WALLS
Definition: cs_parameters.h:125
@ CS_DRIFT_SCALAR_ZERO_BNDY_FLUX
Definition: cs_parameters.h:124
void cs_parameters_global_complete(void)
Complete global parameters.
Definition: cs_parameters.cpp:1641
void cs_time_scheme_log_setup(void)
Print the time scheme structure to setup.log.
Definition: cs_parameters.cpp:2642
cs_time_scheme_t * cs_get_glob_time_scheme(void)
Provide access to cs_glob_time_scheme.
Definition: cs_parameters.cpp:746
cs_space_disc_t * cs_get_glob_space_disc(void)
Provide access to cs_glob_space_disc.
Definition: cs_parameters.cpp:730
cs_field_t * cs_parameters_add_boundary_values(cs_field_t *f)
Define a boundary values field for a variable field.
Definition: cs_parameters.cpp:1399
void cs_parameters_eqp_complete(void)
Complete general equation parameter definitions.
Definition: cs_parameters.cpp:1834
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:190
Additional checkpoint/restart files.
Definition: cs_parameters.h:197
int read_auxiliary
Definition: cs_parameters.h:199
int write_auxiliary
Definition: cs_parameters.h:200
Definition: cs_parameters.h:64
int n_it
Definition: cs_parameters.h:66
double rhs_norm
Definition: cs_parameters.h:67
double res_norm
Definition: cs_parameters.h:68
double derive
Definition: cs_parameters.h:69
double l2residual
Definition: cs_parameters.h:70
Space discretisation options descriptor.
Definition: cs_parameters.h:134
int iflxmw
Definition: cs_parameters.h:150
int imrgra
Definition: cs_parameters.h:140
int itbrrb
Definition: cs_parameters.h:155
int imvisf
Definition: cs_parameters.h:136
Time scheme descriptor.
Definition: cs_parameters.h:165
int isno2t
Definition: cs_parameters.h:171
double thetvi
Definition: cs_parameters.h:184
int istmpf
Definition: cs_parameters.h:169
double thetsn
Definition: cs_parameters.h:178
int time_order
Definition: cs_parameters.h:167
int isto2t
Definition: cs_parameters.h:175
int iccvfg
Definition: cs_parameters.h:188
double thetst
Definition: cs_parameters.h:181
double thetcp
Definition: cs_parameters.h:186