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 
43 /*----------------------------------------------------------------------------*/
44 
46 
47 /*=============================================================================
48  * Macro definitions
49  *============================================================================*/
50 
51 /*============================================================================
52  * Type definitions
53  *============================================================================*/
54 
55 /*----------------------------------------------------------------------------
56  * Structure of variable calculation options
57  *----------------------------------------------------------------------------*/
58 
59 typedef struct {
60  int iwarni;
61  int iconv;
62  int istat;
63  int idiff;
64  int idifft;
65  int idften;
66  int iswdyn;
67  int ischcv;
68  int ibdtso;
69  int isstpc;
70  int nswrgr;
71  int nswrsm;
72  int imrgra;
73  int imligr;
74  int ircflu;
75  int iwgrec; /* gradient calculation
76  - 0: standard (default)
77  - 1: weighted (could be used with imvisf = 1) */
78  int icoupl; /* internal coupling
79  - -1: not coupled (default)
80  - 1: coupled */
81 
82  double thetav;
83  double blencv;
84  double blend_st;
85  double epsilo;
86  double epsrsm;
87  double epsrgr;
88  double climgr;
89  double extrag;
90  double relaxv;
92 
93 /*----------------------------------------------------------------------------
94  * Structure of the solving info
95  *----------------------------------------------------------------------------*/
96 
97 typedef struct {
98  int n_it;
99  double rhs_norm;
100  double res_norm;
101  double derive;
102  double l2residual;
104 
105 /*----------------------------------------------------------------------------
106  * Structure of condensation modelling physical properties
107  *----------------------------------------------------------------------------*/
108 
109 typedef struct {
110  double mol_mas;
111  double cp;
112  double vol_dif;
113  double mu_a;
114  double mu_b;
115  double lambda_a;
116  double lambda_b;
117  double muref; /* ref. viscosity for Sutherland law */
118  double lamref; /* ref. thermal conductivity for Sutherland law */
119  double trefmu; /* ref. temperature for viscosity in Sutherland law */
120  double treflam; /* ref. temperature for conductivity Sutherland law */
121  double smu; /* Sutherland temperature for viscosity */
122  double slam; /* Sutherland temperature for conductivity */
124 
125 /*----------------------------------------------------------------------------
126  * Boundary condition types
127  *----------------------------------------------------------------------------*/
128 
129 enum {
130  CS_INDEF = 1,
131  CS_INLET = 2,
136  CS_ESICF = 7,
137  CS_SSPCF = 8,
138  CS_SOPCF = 9,
139  CS_EPHCF = 10,
140  CS_EQHCF = 11,
141  CS_COUPLED = 12, /* coupled face */
142  CS_COUPLED_FD = 13, /* coupled face with decentered flux */
146 };
147 
148 /*----------------------------------------------------------------------------
149  * Space discretisation options descriptor
150  *----------------------------------------------------------------------------*/
151 
152 typedef struct {
153 
154  int imvisf; /* face viscosity field interpolation
155  - 1: harmonic
156  - 0: arithmetic (default) */
157 
158  int imrgra; /* type of gradient reconstruction
159  - 0: iterative process
160  - 1: standard least square method
161  - 2: least square method with extended
162  neighborhood
163  - 3: least square method with reduced extended
164  neighborhood
165  - 4: iterative process initialized by the least
166  square method */
167 
168  double anomax; /* non orthogonality angle of the faces, in radians.
169  For larger angle values, cells with one node
170  on the wall are kept in the extended support of
171  the neighboring cells. */
172 
173  int iflxmw; /* method to compute interior mass flux due to ALE
174  mesh velocity
175  - 1: based on cell center mesh velocity
176  - 0: based on nodes displacement */
177 
179 
180 /*----------------------------------------------------------------------------
181  * PISO descriptor
182  *----------------------------------------------------------------------------*/
183 
184 typedef struct {
185 
186  int nterup; /* number of interations on the pressure-velocity
187  coupling on Navier-Stokes */
188 
189  double epsup; /* relative precision for the convergence test of
190  the iterative process on pressure-velocity
191  coupling */
192 
193  double xnrmu; /* norm of the increment
194  \f$ \vect{u}^{k+1} - \vect{u}^k \f$
195  of the iterative process on pressure-velocity
196  coupling */
197 
198  double xnrmu0; /* norm of \f$ \vect{u}^0 \f$ */
199 
200 } cs_piso_t;
201 
202 /*============================================================================
203  * Static global variables
204  *============================================================================*/
205 
206 /* Pointer to space discretisation options structure */
207 
208 extern const cs_space_disc_t *cs_glob_space_disc;
209 
210 /* Pointer to PISO options structure */
211 
212 extern const cs_piso_t *cs_glob_piso;
213 
214 /*=============================================================================
215  * Public function prototypes
216  *============================================================================*/
217 
218 /*----------------------------------------------------------------------------*/
229 /*----------------------------------------------------------------------------*/
230 
231 static inline int
233 {
234  int iscvr = 0, f_id = 0;
235  int kscavr = cs_field_key_id("first_moment_id");
236  int keysca = cs_field_key_id("scalar_id");
237 
238  if (kscavr >= 0) {
239  f_id = cs_field_get_key_int(f, kscavr);
240  if (f_id >= 0)
241  iscvr = cs_field_get_key_int(cs_field_by_id(f_id), keysca);
242  }
243 
244  return iscvr;
245 }
246 
247 /*----------------------------------------------------------------------------*/
255 /*----------------------------------------------------------------------------*/
256 
259 
260 /*----------------------------------------------------------------------------*/
268 /*----------------------------------------------------------------------------*/
269 
270 cs_piso_t *
271 cs_get_glob_piso(void);
272 
273 /*----------------------------------------------------------------------------*/
280 /*----------------------------------------------------------------------------*/
281 
282 void
284 
285 /*----------------------------------------------------------------------------*/
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 /*----------------------------------------------------------------------------*/
434 /*----------------------------------------------------------------------------*/
435 
438 
439 /*----------------------------------------------------------------------------*/
443 /*----------------------------------------------------------------------------*/
444 
445 void
447 
448 /*----------------------------------------------------------------------------*/
449 
451 
452 #endif /* __CS_PARAMETERS_H__ */
double climgr
Definition: cs_parameters.h:88
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:1228
Definition: cs_parameters.h:97
int istat
Definition: cs_parameters.h:62
double mol_mas
Definition: cs_parameters.h:110
double slam
Definition: cs_parameters.h:122
int ischcv
Definition: cs_parameters.h:67
int nswrgr
Definition: cs_parameters.h:70
int imrgra
Definition: cs_parameters.h:158
const cs_space_disc_t * cs_glob_space_disc
int iconv
Definition: cs_parameters.h:61
void cs_parameters_create_added_variables(void)
Create previously added user variables.
Definition: cs_parameters.c:1103
int iflxmw
Definition: cs_parameters.h:173
Field descriptor.
Definition: cs_field.h:124
int nterup
Definition: cs_parameters.h:186
int nswrsm
Definition: cs_parameters.h:71
int imligr
Definition: cs_parameters.h:73
double lambda_a
Definition: cs_parameters.h:115
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:2236
double smu
Definition: cs_parameters.h:121
double lambda_b
Definition: cs_parameters.h:116
Definition: cs_parameters.h:130
Definition: cs_parameters.h:139
void cs_parameters_add_variable(const char *name, int dim)
Solved variables are always defined on cells.
Definition: cs_parameters.c:979
int idifft
Definition: cs_parameters.h:64
double epsrsm
Definition: cs_parameters.h:86
void cs_parameters_read_restart_info(void)
Read general restart info.
Definition: cs_parameters.c:957
#define BEGIN_C_DECLS
Definition: cs_defs.h:453
double anomax
Definition: cs_parameters.h:168
void cs_space_disc_log_setup(void)
Print the space discretization structure to setup.log.
Definition: cs_parameters.c:1431
Definition: cs_parameters.h:142
Definition: cs_parameters.h:131
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:1015
double trefmu
Definition: cs_parameters.h:119
double blencv
Definition: cs_parameters.h:83
void cs_parameters_add_property(const char *name, int dim, int location_id)
Define a user property.
Definition: cs_parameters.c:1047
int isstpc
Definition: cs_parameters.h:69
cs_space_disc_t * cs_get_glob_space_disc(void)
Provide access to cs_glob_space_disc.
Definition: cs_parameters.c:812
int icoupl
Definition: cs_parameters.h:78
double cp
Definition: cs_parameters.h:111
void cs_parameters_create_added_properties(void)
Create previously added user properties.
Definition: cs_parameters.c:1178
int iwarni
Definition: cs_parameters.h:60
Definition: cs_parameters.h:132
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:2905
Definition: cs_parameters.h:144
int iswdyn
Definition: cs_parameters.h:66
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:2419
Definition: cs_parameters.h:109
Definition: cs_parameters.h:136
Definition: cs_parameters.h:134
int idiff
Definition: cs_parameters.h:63
double extrag
Definition: cs_parameters.h:89
double epsilo
Definition: cs_parameters.h:85
Definition: cs_parameters.h:138
double thetav
Definition: cs_parameters.h:82
double blend_st
Definition: cs_parameters.h:84
int imrgra
Definition: cs_parameters.h:72
Definition: cs_parameters.h:141
double epsup
Definition: cs_parameters.h:189
Definition: cs_parameters.h:133
int cs_parameters_n_added_variables(void)
Return the number of defined user variables not added yet.
Definition: cs_parameters.c:1077
double vol_dif
Definition: cs_parameters.h:112
cs_piso_t * cs_get_glob_piso(void)
Provide acces to cs_glob_piso.
Definition: cs_parameters.c:828
void cs_parameters_define_field_key_gas_mix(void)
Define field key for condensation.
Definition: cs_parameters.c:936
int idften
Definition: cs_parameters.h:65
double xnrmu
Definition: cs_parameters.h:193
const cs_piso_t * cs_glob_piso
double mu_a
Definition: cs_parameters.h:113
int n_it
Definition: cs_parameters.h:98
double l2residual
Definition: cs_parameters.h:102
Definition: cs_parameters.h:137
PISO options descriptor.
Definition: cs_parameters.h:184
structure containing the variable calculation options.
Definition: cs_parameters.h:59
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:232
#define END_C_DECLS
Definition: cs_defs.h:454
int ibdtso
Definition: cs_parameters.h:68
Definition: cs_parameters.h:140
double relaxv
Definition: cs_parameters.h:90
Definition: cs_parameters.h:135
Space discretisation options descriptor.
Definition: cs_parameters.h:152
int cs_parameters_n_added_properties(void)
Return the number of defined user properties not added yet.
Definition: cs_parameters.c:1091
double lamref
Definition: cs_parameters.h:118
int ircflu
Definition: cs_parameters.h:74
double muref
Definition: cs_parameters.h:117
double rhs_norm
Definition: cs_parameters.h:99
void cs_parameters_define_field_keys(void)
Define general field keys.
Definition: cs_parameters.c:843
Definition: cs_parameters.h:143
int iwgrec
Definition: cs_parameters.h:75
Definition: cs_parameters.h:145
int imvisf
Definition: cs_parameters.h:154
double xnrmu0
Definition: cs_parameters.h:198
double treflam
Definition: cs_parameters.h:120
double derive
Definition: cs_parameters.h:101
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:1419
double epsrgr
Definition: cs_parameters.h:87
double mu_b
Definition: cs_parameters.h:114
cs_field_t * cs_parameters_add_boundary_temperature(void)
Define a boundary values field for temperature, if applicable.
Definition: cs_parameters.c:1333
double res_norm
Definition: cs_parameters.h:100