programmer's 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-2018 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_field.h"
42 #include "cs_tree.h"
43 
44 /*----------------------------------------------------------------------------*/
45 
47 
48 /*=============================================================================
49  * Macro definitions
50  *============================================================================*/
51 
52 /*============================================================================
53  * Type definitions
54  *============================================================================*/
55 
56 /*----------------------------------------------------------------------------
57  * Structure of variable calculation options
58  *----------------------------------------------------------------------------*/
59 
60 typedef struct {
61  int iwarni;
62  int iconv;
63  int istat;
64  int idiff;
65  int idifft;
66  int idften;
67  int iswdyn;
68  int ischcv;
69  int ibdtso;
70  int isstpc;
71  int nswrgr;
72  int nswrsm;
73  int imrgra;
74  int imligr;
75  int ircflu;
76  int iwgrec; /* gradient calculation
77  - 0: standard (default)
78  - 1: weighted (could be used with imvisf = 1) */
79  int icoupl; /* internal coupling
80  - -1: not coupled (default)
81  - 1: coupled */
82 
83  double thetav;
84  double blencv;
85  double blend_st;
86  double epsilo;
87  double epsrsm;
88  double epsrgr;
89  double climgr;
90  double extrag;
91  double relaxv;
93 
94 /*----------------------------------------------------------------------------
95  * Structure of the solving info
96  *----------------------------------------------------------------------------*/
97 
98 typedef struct {
99  int n_it;
100  double rhs_norm;
101  double res_norm;
102  double derive;
103  double l2residual;
105 
106 /*----------------------------------------------------------------------------
107  * Structure of condensation modelling physical properties
108  *----------------------------------------------------------------------------*/
109 
110 typedef struct {
111  double mol_mas;
112  double cp;
113  double vol_dif;
114  double mu_a;
115  double mu_b;
116  double lambda_a;
117  double lambda_b;
118  double muref; /* ref. viscosity for Sutherland law */
119  double lamref; /* ref. thermal conductivity for Sutherland law */
120  double trefmu; /* ref. temperature for viscosity in Sutherland law */
121  double treflam; /* ref. temperature for conductivity Sutherland law */
122  double smu; /* Sutherland temperature for viscosity */
123  double slam; /* Sutherland temperature for conductivity */
125 
126 /*----------------------------------------------------------------------------
127  * Boundary condition types
128  *----------------------------------------------------------------------------*/
129 
130 enum {
131  CS_INDEF = 1,
132  CS_INLET = 2,
137  CS_ESICF = 7,
138  CS_SSPCF = 8,
139  CS_SOPCF = 9,
140  CS_EPHCF = 10,
141  CS_EQHCF = 11,
142  CS_COUPLED = 12, /* coupled face */
143  CS_COUPLED_FD = 13, /* coupled face with decentered flux */
147 };
148 
149 /*----------------------------------------------------------------------------
150  * Space discretisation options descriptor
151  *----------------------------------------------------------------------------*/
152 
153 typedef struct {
154 
155  int imvisf; /* face viscosity field interpolation
156  - 1: harmonic
157  - 0: arithmetic (default) */
158 
159  int imrgra; /* type of gradient reconstruction
160  - 0: iterative process
161  - 1: standard least square method
162  - 2: least square method with extended
163  neighborhood
164  - 3: least square method with reduced extended
165  neighborhood
166  - 4: iterative process initialized by the least
167  square method */
168 
169  double anomax; /* non orthogonality angle of the faces, in radians.
170  For larger angle values, cells with one node
171  on the wall are kept in the extended support of
172  the neighboring cells. */
173 
174  int iflxmw; /* method to compute interior mass flux due to ALE
175  mesh velocity
176  - 1: based on cell center mesh velocity
177  - 0: based on nodes displacement */
178 
180 
181 /*----------------------------------------------------------------------------
182  * PISO descriptor
183  *----------------------------------------------------------------------------*/
184 
185 typedef struct {
186 
187  int nterup; /* number of interations on the pressure-velocity
188  coupling on Navier-Stokes */
189 
190  double epsup; /* relative precision for the convergence test of
191  the iterative process on pressure-velocity
192  coupling */
193 
194  double xnrmu; /* norm of the increment
195  \f$ \vect{u}^{k+1} - \vect{u}^k \f$
196  of the iterative process on pressure-velocity
197  coupling */
198 
199  double xnrmu0; /* norm of \f$ \vect{u}^0 \f$ */
200 
201  int n_buoyant_scal; /* number of buoyant scalars,
202  zero if there is no buoyant scalar */
203 
204 } cs_piso_t;
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 PISO options structure */
215 
216 extern const cs_piso_t *cs_glob_piso;
217 
218 /*============================================================================
219  * Global variables
220  *============================================================================*/
221 
224 extern cs_tree_node_t *cs_glob_tree;
225 
226 /*=============================================================================
227  * Public function prototypes
228  *============================================================================*/
229 
230 /*----------------------------------------------------------------------------*/
241 /*----------------------------------------------------------------------------*/
242 
243 static inline int
245 {
246  int iscvr = 0, f_id = 0;
247  int kscavr = cs_field_key_id("first_moment_id");
248  int keysca = cs_field_key_id("scalar_id");
249 
250  if (kscavr >= 0) {
251  f_id = cs_field_get_key_int(f, kscavr);
252  if (f_id >= 0)
253  iscvr = cs_field_get_key_int(cs_field_by_id(f_id), keysca);
254  }
255 
256  return iscvr;
257 }
258 
259 /*----------------------------------------------------------------------------*/
267 /*----------------------------------------------------------------------------*/
268 
271 
272 /*----------------------------------------------------------------------------*/
280 /*----------------------------------------------------------------------------*/
281 
282 cs_piso_t *
283 cs_get_glob_piso(void);
284 
285 /*----------------------------------------------------------------------------
286  *!
287  * \brief Count and set number of buoyant scalars.
288  */
289 /*----------------------------------------------------------------------------*/
290 
291 void
293 
294 /*----------------------------------------------------------------------------*/
301 /*----------------------------------------------------------------------------*/
302 
303 void
305 
306 /*----------------------------------------------------------------------------*/
312 /*----------------------------------------------------------------------------*/
313 
314 void
316 
317 /*----------------------------------------------------------------------------*/
323 /*----------------------------------------------------------------------------*/
324 
325 void
327 
328 /*----------------------------------------------------------------------------*/
337 /*----------------------------------------------------------------------------*/
338 
339 void
340 cs_parameters_add_variable(const char *name,
341  int dim);
342 
343 /*----------------------------------------------------------------------------*/
352 /*----------------------------------------------------------------------------*/
353 
354 void
355 cs_parameters_add_variable_variance(const char *name,
356  const char *variable_name);
357 
358 /*----------------------------------------------------------------------------*/
366 /*----------------------------------------------------------------------------*/
367 
368 void
369 cs_parameters_add_property(const char *name,
370  int dim,
371  int location_id);
372 
373 /*----------------------------------------------------------------------------*/
382 /*----------------------------------------------------------------------------*/
383 
384 int
386 
387 /*----------------------------------------------------------------------------*/
396 /*----------------------------------------------------------------------------*/
397 
398 int
400 
401 /*----------------------------------------------------------------------------*/
405 /*----------------------------------------------------------------------------*/
406 
407 void
409 
410 /*----------------------------------------------------------------------------*/
414 /*----------------------------------------------------------------------------*/
415 
416 void
418 
419 /*----------------------------------------------------------------------------*/
427 /*----------------------------------------------------------------------------*/
428 
429 cs_field_t *
431 
432 /*----------------------------------------------------------------------------*/
443 /*----------------------------------------------------------------------------*/
444 
445 cs_field_t *
447 
448 /*----------------------------------------------------------------------------*/
455 /*----------------------------------------------------------------------------*/
456 
459 
460 /*----------------------------------------------------------------------------*/
464 /*----------------------------------------------------------------------------*/
465 
466 void
468 
469 /*----------------------------------------------------------------------------*/
470 
472 
473 #endif /* __CS_PARAMETERS_H__ */
double climgr
Definition: cs_parameters.h:89
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:1298
Definition: cs_parameters.h:98
int istat
Definition: cs_parameters.h:63
double mol_mas
Definition: cs_parameters.h:111
double slam
Definition: cs_parameters.h:123
int ischcv
Definition: cs_parameters.h:68
int nswrgr
Definition: cs_parameters.h:71
int imrgra
Definition: cs_parameters.h:159
const cs_space_disc_t * cs_glob_space_disc
int iconv
Definition: cs_parameters.h:62
void cs_parameters_create_added_variables(void)
Create previously added user variables.
Definition: cs_parameters.c:1173
int iflxmw
Definition: cs_parameters.h:174
Field descriptor.
Definition: cs_field.h:124
int nterup
Definition: cs_parameters.h:187
int nswrsm
Definition: cs_parameters.h:72
int imligr
Definition: cs_parameters.h:74
double lambda_a
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:2242
double smu
Definition: cs_parameters.h:122
double lambda_b
Definition: cs_parameters.h:117
Definition: cs_parameters.h:131
Definition: cs_parameters.h:140
void cs_parameters_add_variable(const char *name, int dim)
Solved variables are always defined on cells.
Definition: cs_parameters.c:1034
int idifft
Definition: cs_parameters.h:65
double epsrsm
Definition: cs_parameters.h:87
void cs_parameters_read_restart_info(void)
Read general restart info.
Definition: cs_parameters.c:1012
#define BEGIN_C_DECLS
Definition: cs_defs.h:461
double anomax
Definition: cs_parameters.h:169
void cs_parameters_set_n_buoyant_scalars(void)
Definition: cs_parameters.c:868
void cs_space_disc_log_setup(void)
Print the space discretization structure to setup.log.
Definition: cs_parameters.c:1501
cs_tree_node_t * cs_glob_tree
Definition: cs_parameters.h:143
Definition: cs_parameters.h:132
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:1075
double trefmu
Definition: cs_parameters.h:120
double blencv
Definition: cs_parameters.h:84
void cs_parameters_add_property(const char *name, int dim, int location_id)
Define a user property.
Definition: cs_parameters.c:1112
int isstpc
Definition: cs_parameters.h:70
cs_space_disc_t * cs_get_glob_space_disc(void)
Provide access to cs_glob_space_disc.
Definition: cs_parameters.c:840
int icoupl
Definition: cs_parameters.h:79
double cp
Definition: cs_parameters.h:112
void cs_parameters_create_added_properties(void)
Create previously added user properties.
Definition: cs_parameters.c:1248
int iwarni
Definition: cs_parameters.h:61
Definition: cs_parameters.h:133
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:2911
Definition: cs_parameters.h:145
int iswdyn
Definition: cs_parameters.h:67
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:2425
Definition: cs_parameters.h:110
Definition: cs_parameters.h:137
Definition: cs_parameters.h:135
int idiff
Definition: cs_parameters.h:64
double extrag
Definition: cs_parameters.h:90
double epsilo
Definition: cs_parameters.h:86
Definition: cs_parameters.h:139
double thetav
Definition: cs_parameters.h:83
double blend_st
Definition: cs_parameters.h:85
int imrgra
Definition: cs_parameters.h:73
Definition: cs_parameters.h:142
double epsup
Definition: cs_parameters.h:190
Definition: cs_parameters.h:134
int cs_parameters_n_added_variables(void)
Return the number of defined user variables not added yet.
Definition: cs_parameters.c:1147
double vol_dif
Definition: cs_parameters.h:113
cs_piso_t * cs_get_glob_piso(void)
Provide acces to cs_glob_piso.
Definition: cs_parameters.c:856
void cs_parameters_define_field_key_gas_mix(void)
Define field key for condensation.
Definition: cs_parameters.c:991
int idften
Definition: cs_parameters.h:66
int n_buoyant_scal
Definition: cs_parameters.h:201
double xnrmu
Definition: cs_parameters.h:194
const cs_piso_t * cs_glob_piso
double mu_a
Definition: cs_parameters.h:114
int n_it
Definition: cs_parameters.h:99
double l2residual
Definition: cs_parameters.h:103
Definition: cs_parameters.h:138
PISO options descriptor.
Definition: cs_parameters.h:185
structure containing the variable calculation options.
Definition: cs_parameters.h:60
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:244
#define END_C_DECLS
Definition: cs_defs.h:462
int ibdtso
Definition: cs_parameters.h:69
Definition: cs_parameters.h:141
double relaxv
Definition: cs_parameters.h:91
Definition: cs_parameters.h:136
Space discretisation options descriptor.
Definition: cs_parameters.h:153
int cs_parameters_n_added_properties(void)
Return the number of defined user properties not added yet.
Definition: cs_parameters.c:1161
double lamref
Definition: cs_parameters.h:119
int ircflu
Definition: cs_parameters.h:75
double muref
Definition: cs_parameters.h:118
double rhs_norm
Definition: cs_parameters.h:100
void cs_parameters_define_field_keys(void)
Define general field keys.
Definition: cs_parameters.c:895
Definition: cs_parameters.h:144
int iwgrec
Definition: cs_parameters.h:76
Definition: cs_parameters.h:146
int imvisf
Definition: cs_parameters.h:155
double xnrmu0
Definition: cs_parameters.h:199
double treflam
Definition: cs_parameters.h:121
double derive
Definition: cs_parameters.h:102
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:1489
double epsrgr
Definition: cs_parameters.h:88
double mu_b
Definition: cs_parameters.h:115
cs_field_t * cs_parameters_add_boundary_temperature(void)
Define a boundary values field for temperature, if applicable.
Definition: cs_parameters.c:1403
double res_norm
Definition: cs_parameters.h:101