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-2021 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
47 BEGIN_C_DECLS
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
62 typedef cs_equation_param_t cs_var_cal_opt_t;
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;
74 } cs_solving_info_t;
75
76 /*----------------------------------------------------------------------------
77 * Boundary condition types
78 *----------------------------------------------------------------------------*/
79
80 enum {
81 CS_INDEF = 1,
82 CS_INLET = 2,
83 CS_OUTLET = 3,
84 CS_SYMMETRY = 4,
85 CS_SMOOTHWALL = 5,
86 CS_ROUGHWALL = 6,
87 CS_ESICF = 7,
88 CS_SSPCF = 8,
89 CS_SOPCF = 9,
90 CS_EPHCF = 10,
91 CS_EQHCF = 11,
92 CS_COUPLED = 12, /* coupled face */
93 CS_COUPLED_FD = 13, /* coupled face with decentered flux */
94 CS_FREE_INLET = 14,
95 CS_FREE_SURFACE = 15,
96 CS_CONVECTIVE_INLET = 16
97 };
98
99 /*----------------------------------------------------------------------------
100 * flag for computing the drift mass flux:
101 * (for coal classes for instance, only the first
102 * scalar of a class compute the drift flux of the class
103 * and the other scalars use it without recomputing it)
104 *----------------------------------------------------------------------------*/
105
106 enum {
107 CS_DRIFT_SCALAR_ON = (1 << 0),
108 CS_DRIFT_SCALAR_ADD_DRIFT_FLUX = (1 << 1),
109 CS_DRIFT_SCALAR_THERMOPHORESIS = (1 << 2),
110 CS_DRIFT_SCALAR_TURBOPHORESIS = (1 << 3),
111 CS_DRIFT_SCALAR_ELECTROPHORESIS = (1 << 4),
112 CS_DRIFT_SCALAR_CENTRIFUGALFORCE = (1 << 5),
113 CS_DRIFT_SCALAR_IMPOSED_MASS_FLUX = (1 << 6),
114 CS_DRIFT_SCALAR_ZERO_BNDY_FLUX = (1 << 7),
115 CS_DRIFT_SCALAR_ZERO_BNDY_FLUX_AT_WALLS = (1 << 8)
116 };
117
118 /*----------------------------------------------------------------------------
119 * Space discretisation options descriptor
120 *----------------------------------------------------------------------------*/
121
122 typedef struct {
123
124 int imvisf; /* face viscosity field interpolation
125 - 1: harmonic
126 - 0: arithmetic (default) */
127
128 int imrgra; /* type of gradient reconstruction
129 - 0: iterative process
130 - 1: standard least square method
131 - 2: least square method with extended
132 neighborhood
133 - 3: least square method with reduced extended
134 neighborhood
135 - 4: Green-Gauss using least squares face
136 values interpolation */
137
138 int iflxmw; /* method to compute interior mass flux due to ALE
139 mesh velocity
140 - 1: based on cell center mesh velocity
141 - 0: based on nodes displacement */
142
143 int itbrrb; /* accurate treatment of the wall temperature
144 - 1: true
145 - 0: false (default) */
146
147 } cs_space_disc_t;
148
149 /*----------------------------------------------------------------------------
150 * Time scheme descriptor
151 *----------------------------------------------------------------------------*/
152
153 typedef struct {
154
155 int time_order; /* Global time order of the time stepping */
156
157 int isto2t; /* time scheme activated for the source
158 terms of turbulent equations */
159
160 double thetst; /* value of \f$theta\f$ for turbulence */
161
162 int iccvfg; /* calculation with a fixed velocity field
163 - 1: true (default)
164 - 0: false */
165 } cs_time_scheme_t;
166
167 /*----------------------------------------------------------------------------
168 * Auxiliary checkpoint/restart file parameters
169 *----------------------------------------------------------------------------*/
170
171 typedef struct {
172
173 int read_auxiliary; /* Activate reading of auxiliary restart file */
174 int write_auxiliary; /* Activate output of auxiliary restart file */
175
176 } cs_restart_auxiliary_t;
177
178 /*============================================================================
179 * Static global variables
180 *============================================================================*/
181
182 /* Pointer to space discretisation options structure */
183
184 extern const cs_space_disc_t *cs_glob_space_disc;
185
186 /* Pointer to time scheme options structure */
187
188 extern const cs_time_scheme_t *cs_glob_time_scheme;
189
190 /* Pointer to auxiliary checkpoint/restart file parameters */
191
192 extern cs_restart_auxiliary_t *cs_glob_restart_auxiliary;
193
194 /*============================================================================
195 * Global variables
196 *============================================================================*/
197
198 /*! Global parameters tree structure */
199
200 extern cs_tree_node_t *cs_glob_tree;
201
202 /*=============================================================================
203 * Public function prototypes
204 *============================================================================*/
205
206 /*----------------------------------------------------------------------------*/
207 /*!
208 * \brief For a given field, returns the scalar number of the fluctuating field
209 * if given field is a variance.
210 *
211 * \param[in] f field
212 *
213 * \return if f is a variance: scalar number of fluctuating field
214 * else if f is not a variance: 0
215 * else if f is the variance of a field that is not a scalar: -1
216 */
217 /*----------------------------------------------------------------------------*/
218
219 static inline int
cs_parameters_iscavr(cs_field_t * f)220 cs_parameters_iscavr(cs_field_t *f)
221 {
222 int iscvr = 0, f_id = 0;
223 int kscavr = cs_field_key_id("first_moment_id");
224 int keysca = cs_field_key_id("scalar_id");
225
226 if (kscavr >= 0) {
227 f_id = cs_field_get_key_int(f, kscavr);
228 if (f_id >= 0)
229 iscvr = cs_field_get_key_int(cs_field_by_id(f_id), keysca);
230 }
231
232 return iscvr;
233 }
234
235 /*----------------------------------------------------------------------------*/
236 /*!
237 * \brief Provide access to cs_glob_space_disc
238 *
239 * needed to initialize structure in GUI and user C functions.
240 *
241 * \return space discretization description structure
242 */
243 /*----------------------------------------------------------------------------*/
244
245 cs_space_disc_t *
246 cs_get_glob_space_disc(void);
247
248 /*----------------------------------------------------------------------------*/
249 /*!
250 * \brief Provide access to cs_glob_time_scheme
251 *
252 * needed to initialize structure with GUI and user C functions.
253 *
254 * \return time scheme information structure
255 */
256 /*----------------------------------------------------------------------------*/
257
258 cs_time_scheme_t *
259 cs_get_glob_time_scheme(void);
260
261 /*----------------------------------------------------------------------------*/
262 /*!
263 * \brief Define general field keys.
264 *
265 * A recommended practice for different submodules would be to use
266 * "cs_<module>_key_init() functions to define keys specific to those modules.
267 */
268 /*----------------------------------------------------------------------------*/
269
270 void
271 cs_parameters_define_field_keys(void);
272
273 /*----------------------------------------------------------------------------*/
274 /*!
275 * \brief Read general restart info.
276 *
277 * This updates the previous time step info.
278 */
279 /*----------------------------------------------------------------------------*/
280
281 void
282 cs_parameters_read_restart_info(void);
283
284 /*----------------------------------------------------------------------------*/
285 /*!
286 * Define a user variable.
287 *
288 * \brief Solved variables are always defined on cells.
289 *
290 * \param[in] name name of variable and associated field
291 * \param[in] dim variable dimension
292 */
293 /*----------------------------------------------------------------------------*/
294
295 void
296 cs_parameters_add_variable(const char *name,
297 int dim);
298
299 /*----------------------------------------------------------------------------*/
300 /*!
301 * \brief Define a user variable which is a variance of another variable.
302 *
303 * Only variances of thermal or user-defined variables are currently handled.
304 *
305 * \param[in] name name of variance and associated field
306 * \param[in] variable_name name of associated variable
307 */
308 /*----------------------------------------------------------------------------*/
309
310 void
311 cs_parameters_add_variable_variance(const char *name,
312 const char *variable_name);
313
314 /*----------------------------------------------------------------------------*/
315 /*!
316 * \brief Define a user property.
317 *
318 * \param[in] name name of property and associated field
319 * \param[in] dim property dimension
320 * \param[in] location_id id of associated mesh location
321 */
322 /*----------------------------------------------------------------------------*/
323
324 void
325 cs_parameters_add_property(const char *name,
326 int dim,
327 int location_id);
328
329 /*----------------------------------------------------------------------------*/
330 /*!
331 * \brief Return the number of defined user variables not added yet.
332 *
333 * This number is reset to 0 when cs_parameters_create_added_variables()
334 * is called.
335 *
336 * \return number of defined user variables
337 */
338 /*----------------------------------------------------------------------------*/
339
340 int
341 cs_parameters_n_added_variables(void);
342
343 /*----------------------------------------------------------------------------*/
344 /*!
345 * \brief Return the number of defined user properties not added yet.
346 *
347 * This number is reset to 0 when cs_parameters_create_added_properties()
348 * is called.
349 *
350 * \return number of defined user properties
351 */
352 /*----------------------------------------------------------------------------*/
353
354 int
355 cs_parameters_n_added_properties(void);
356
357 /*----------------------------------------------------------------------------*/
358 /*!
359 * \brief Create previously added user variables.
360 */
361 /*----------------------------------------------------------------------------*/
362
363 void
364 cs_parameters_create_added_variables(void);
365
366 /*----------------------------------------------------------------------------*/
367 /*!
368 * \brief Create previously added user properties.
369 */
370 /*----------------------------------------------------------------------------*/
371
372 void
373 cs_parameters_create_added_properties(void);
374
375 /*----------------------------------------------------------------------------*/
376 /*!
377 * \brief Define a boundary values field for a variable field.
378 *
379 * \param[in] f pointer to field structure
380 *
381 * \return pointer to boundary values field, or NULL if not applicable
382 */
383 /*----------------------------------------------------------------------------*/
384
385 cs_field_t *
386 cs_parameters_add_boundary_values(cs_field_t *f);
387
388 /*----------------------------------------------------------------------------*/
389 /*!
390 * \brief Define a boundary values field for temperature, if applicable.
391 *
392 * When a volume temperature variable field already exists, this amounts
393 * to calling \ref cs_parameters_add_boundary_values for that field.
394 * When such a variable does not exist but we have an Enthalpy variables,
395 * an associated temperature boundary field is returned.
396 *
397 * \return pointer to boundary values field, or NULL if not applicable
398 */
399 /*----------------------------------------------------------------------------*/
400
401 cs_field_t *
402 cs_parameters_add_boundary_temperature(void);
403
404 /*----------------------------------------------------------------------------*/
405 /*!
406 * \brief Complete general equation parameter definitions.
407 */
408 /*----------------------------------------------------------------------------*/
409
410 void
411 cs_parameters_eqp_complete(void);
412
413 /*----------------------------------------------------------------------------*/
414 /*!
415 * \brief Complete general output options definitions.
416 */
417 /*----------------------------------------------------------------------------*/
418
419 void
420 cs_parameters_output_complete(void);
421
422 /*----------------------------------------------------------------------------*/
423 /*!
424 * \brief Return a local variable calculation options structure,
425 * with default options.
426 *
427 * \return variable calculations options structure
428 */
429 /*----------------------------------------------------------------------------*/
430
431 cs_var_cal_opt_t
432 cs_parameters_var_cal_opt_default(void);
433
434 /*----------------------------------------------------------------------------*/
435 /*!
436 * \brief Print the time scheme structure to setup.log.
437 */
438 /*----------------------------------------------------------------------------*/
439
440 void
441 cs_time_scheme_log_setup(void);
442
443 /*----------------------------------------------------------------------------*/
444 /*!
445 * \brief Print the space discretization structure to setup.log.
446 */
447 /*----------------------------------------------------------------------------*/
448
449 void
450 cs_space_disc_log_setup(void);
451
452 /*----------------------------------------------------------------------------*/
453
454 END_C_DECLS
455
456 #endif /* __CS_PARAMETERS_H__ */
457