programmer's documentation
cs_param.h
Go to the documentation of this file.
1 #ifndef __CS_PARAM_H__
2 #define __CS_PARAM_H__
3 
4 /*============================================================================
5  * Manage the definition/setting of a computation
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2016 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  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_mesh.h"
35 #include "cs_cdo.h"
36 #include "cs_quadrature.h"
37 
38 /*----------------------------------------------------------------------------*/
39 
41 
42 /*============================================================================
43  * Macro definitions
44  *============================================================================*/
45 
46 /*============================================================================
47  * Type definitions
48  *============================================================================*/
49 
50 /* User-defined function */
51 typedef void (cs_user_func_t) (const void *input1,
52  const void *input2,
53  cs_real_t tcur,
54  const cs_real_3_t xyz,
55  cs_get_t *output);
56 
57 typedef union {
58 
59  /* For a definition by value */
60  cs_get_t get;
61 
62  /* For a definition by an analytic function */
64 
65  /* For a definition of the time step by a function */
67 
68  /* For a definition by an user-defined function */
70 
71  /* For a definition by law depending on one scalar variable */
73 
74  /* For a definition by law depending on two scalar variables */
76 
77  /* For a definition by law depending on two variables (scalar + vector) */
79 
80 } cs_def_t;
81 
82 typedef enum {
83 
94 
96 
97 typedef struct {
98 
99  char *ml_name; /* name of the related mesh location */
100  cs_param_def_type_t def_type; /* type of definition */
101  cs_def_t def; /* definition */
102 
103  const void *context; /* If this definition hinges on a related
104  structure. Always shared */
105 
107 
108 /* Dimension of the variable to deal with */
109 typedef enum {
110 
111  CS_PARAM_VAR_SCAL, // scalar variable (dim = 1)
112  CS_PARAM_VAR_VECT, // vector variable (dim = 3)
113  CS_PARAM_VAR_SYMTENS, // symmetric tensor variable (dim = 6)
114  CS_PARAM_VAR_TENS, // tensor variable (dim = 9)
116 
118 
119 /* DISCRETE HODGE OPERATORS */
120 /* ======================== */
121 
122 typedef enum {
123 
124  CS_PARAM_HODGE_TYPE_VPCD, // from primal vertices to dual cells
125  CS_PARAM_HODGE_TYPE_EPFD, // from primal edges to dual faces
126  CS_PARAM_HODGE_TYPE_FPED, // from primal faces to dual edges
127  CS_PARAM_HODGE_TYPE_EDFP, // from dual edges to primal faces
128  CS_PARAM_HODGE_TYPE_CPVD, // from primal cells to dual vertices
129  CS_PARAM_HODGE_TYPE_VC, // primal vertices + primal cells
131 
133 
134 typedef enum {
135 
136  CS_PARAM_HODGE_ALGO_VORONOI, // Under othogonality condition gives a diag. op.
137  CS_PARAM_HODGE_ALGO_WBS, // WBS: Whitney Barycentric Subdivision
138  CS_PARAM_HODGE_ALGO_COST, // COST: COnsistency & STabilization splitting
140 
142 
143 typedef struct {
144 
145  bool inv_pty; /* Definition based on the property
146  or its inverse */
147 
148  cs_param_hodge_type_t type; /* type of discrete Hodge operator */
149  cs_param_hodge_algo_t algo; /* type of algorithm used to build this op. */
150  double coef; /* Value of the stabilization parameter
151  if the COST algo. is used, otherwise 0. */
152 
154 
155 /* TIME SCHEME */
156 /* =========== */
157 
158 /* Type of numerical scheme for the discretization in time */
159 typedef enum {
160 
161  CS_TIME_SCHEME_IMPLICIT, // fully implicit (forward Euler/theta-scheme = 1)
162  CS_TIME_SCHEME_EXPLICIT, // fully explicit (backward Euler/theta-scheme = 0)
163  CS_TIME_SCHEME_CRANKNICO, // Crank-Nicolson (theta-scheme = 0.5)
164  CS_TIME_SCHEME_THETA, // theta-scheme
166 
168 
169 /* Parameters related to time discretization */
170 typedef struct {
171 
172  cs_time_scheme_t scheme; // numerical scheme
173  cs_real_t theta; // used in theta-scheme
174  bool do_lumping; // perform mass lumping ?
175 
176  /* Initial conditions (by default, 0 is set) */
177  int n_ic_definitions; /* 0 -> default settings */
178  cs_param_def_t *ic_definitions; /* list of definitions (mesh location
179  by mesh location) */
180 
182 
183 /* ADVECTION OPERATOR PARAMETRIZATION */
184 /* ================================== */
185 
186 typedef enum {
187 
191 
193 
194 /* Type of weight functions considered */
195 typedef enum {
196 
198  CS_PARAM_ADVECTION_SCHEME_CIP, // Only V+C CDO schemes
203 
205 
206 /* Choice on the type of algo. used to set the argument used in
207  the weight function */
208 typedef enum {
209 
213 
215 
216 /* Set of options for building a contraction operator (also called interior
217  product) which is closely related to the advection operator */
218 typedef struct {
219 
220  cs_param_advection_form_t formulation; // conservative or not
223  cs_quadra_type_t quad_type; // barycentric, higher, highest
224 
226 
227 /* REACTION TERM PARAMETRIZATION */
228 /* ============================= */
229 
230 typedef enum {
231 
234 
236 
237 typedef struct {
238 
239  char *name;
241 
243 
244 /* BOUNDARY CONDITIONS */
245 /* =================== */
246 
247 /* Physic-driven boundary */
248 typedef enum {
249 
255 
257 
258 /* Mathematical boundary conditions */
259 typedef enum {
260 
267 
269 
270 /* Choice between different method to enforce the BCs */
271 typedef enum {
272 
273  CS_PARAM_BC_ENFORCE_STRONG, /* Strong enforcement of the BCs */
274  CS_PARAM_BC_ENFORCE_WEAK_PENA, /* Weak enforcement with a strong
275  penalization coefficient */
276  CS_PARAM_BC_ENFORCE_WEAK_NITSCHE, /* Weak enforcement using Nitsche method */
277  CS_PARAM_BC_ENFORCE_WEAK_SYM, /* Weak enforcement using symmetric Nitsche
278  method */
280 
282 
283 /* Definition of the value of a boundary condition (BC)
284  One or two values may be needed according to the type of BC.
285  That's why two coefficients are used in the definition.
286  For Dirichlet or Neumann BC for instance, only one coefficient is used.
287 */
288 
289 typedef struct {
290 
291  int loc_id; // Id related to the list of border faces
292 
293  cs_param_bc_type_t bc_type; // type of mathematical BC
294  cs_param_var_type_t var_type; // type of variable
295  cs_param_def_type_t def_type; // Type of definition for a and b
296 
297 
298  /* Access to the value related to the first coefficient and possibly
299  the second one */
302 
304 
305 typedef struct {
306 
307  cs_param_bc_type_t default_bc; // BC used by default
308  cs_param_bc_enforce_t enforcement; // type of boundary enforcement
309  cs_quadra_type_t quad_type; // barycentric, higher, highest...
310  bool use_subdiv; /* subdivide or not into tetrahedra for
311  evaluating BC values */
312 
313  int n_defs;
315 
316 } cs_param_bc_t;
317 
318 /* ITERATIVE SOLVERS */
319 /* ================= */
320 
321 typedef enum {
322 
323  CS_PARAM_PRECOND_DIAG, // Diagonal preconditioning (also called Jacobi)
324  CS_PARAM_PRECOND_BJACOB, // Block Jacobi
325  CS_PARAM_PRECOND_POLY1, // Neumann polynomial preconditioning (Order 1)
326  CS_PARAM_PRECOND_SSOR, // Symmetric Successive OverRelaxations
327  CS_PARAM_PRECOND_ILU0, // Incomplete LU factorization
328  CS_PARAM_PRECOND_ICC0, // Incomplete Cholesky factorization
329  CS_PARAM_PRECOND_AMG, // Algebraic MultiGrid
330  CS_PARAM_PRECOND_AS, // Additive Schwarz method
332 
334 
335 /* Type of iterative solver to use to inverse the linear system */
336 typedef enum {
337 
338  CS_PARAM_ITSOL_CG, // Conjuguate Gradient
339  CS_PARAM_ITSOL_BICG, // Bi-Conjuguate gradient
340  CS_PARAM_ITSOL_BICGSTAB2, // Stabilized Bi-Conjuguate gradient
341  CS_PARAM_ITSOL_CR3, // 3-layer conjugate residual
342  CS_PARAM_ITSOL_GMRES, // Generalized Minimal RESidual
343  CS_PARAM_ITSOL_AMG, // Algebraic MultiGrid
345 
347 
348 /* Description of the algorithm used to solve an equation */
349 typedef struct {
350 
351  cs_param_precond_type_t precond; // type of preconditioner
352  cs_param_itsol_type_t solver; // type of solver
353 
354  int n_max_iter; // max. number of iterations
355  double eps; // stopping criterion on accuracy
356 
357  int output_freq; // frequencdy of output into listing
358  bool resid_normalized; /* normalized or not the norm of the
359  residual used for the stopping criterion
360  */
362 
363 /*============================================================================
364  * Global variables
365  *============================================================================*/
366 
367 /*============================================================================
368  * Public function prototypes
369  *============================================================================*/
370 
371 /*----------------------------------------------------------------------------*/
379 /*----------------------------------------------------------------------------*/
380 
381 const char *
383 
384 /*----------------------------------------------------------------------------*/
392 /*----------------------------------------------------------------------------*/
393 
394 const char *
396 
397 /*----------------------------------------------------------------------------*/
406 /*----------------------------------------------------------------------------*/
407 
408 void
410  cs_param_var_type_t var_type,
411  const void *val,
412  cs_def_t *def);
413 
414 /*----------------------------------------------------------------------------*/
422 /*----------------------------------------------------------------------------*/
423 
424 void
426  const char *val,
427  cs_get_t *get);
428 
429 /*----------------------------------------------------------------------------*/
437 /*----------------------------------------------------------------------------*/
438 
441 
442 /*----------------------------------------------------------------------------*/
454 /*----------------------------------------------------------------------------*/
455 
456 void
458  int loc_id,
459  cs_param_bc_type_t bc_type,
460  cs_param_var_type_t var_type,
461  cs_param_def_type_t def_type,
462  const void *coef1,
463  const void *coef2);
464 
465 /*----------------------------------------------------------------------------*/
473 /*----------------------------------------------------------------------------*/
474 
475 const char *
477 
478 /*----------------------------------------------------------------------------*/
486 /*----------------------------------------------------------------------------*/
487 
488 const char *
490 
491 /*----------------------------------------------------------------------------*/
499 /*----------------------------------------------------------------------------*/
500 
501 const char *
503 
504 /*----------------------------------------------------------------------------*/
512 /*----------------------------------------------------------------------------*/
513 
514 const char *
516 
517 /*----------------------------------------------------------------------------*/
525 /*----------------------------------------------------------------------------*/
526 
527 const char *
529 
530 /*----------------------------------------------------------------------------*/
538 /*----------------------------------------------------------------------------*/
539 
540 const char *
542 
543 /*----------------------------------------------------------------------------*/
551 /*----------------------------------------------------------------------------*/
552 
553 const char *
555 
556 /*----------------------------------------------------------------------------*/
557 
559 
560 #endif /* __CS_PARAM_H__ */
cs_time_scheme_t
Definition: cs_param.h:159
cs_param_bc_t * cs_param_bc_create(cs_param_bc_type_t default_bc)
Allocate and initialize a new cs_param_bc_t structure.
Definition: cs_param.c:331
Definition: cs_param.h:162
void cs_param_set_def(cs_param_def_type_t def_type, cs_param_var_type_t var_type, const void *val, cs_def_t *def)
Set a cs_def_t structure.
Definition: cs_param.c:168
Definition: cs_param.h:128
cs_param_hodge_algo_t algo
Definition: cs_param.h:149
cs_param_precond_type_t precond
Definition: cs_param.h:351
cs_param_bc_def_t * defs
Definition: cs_param.h:314
Definition: cs_param.h:325
Definition: cs_param.h:327
cs_real_t theta
Definition: cs_param.h:173
cs_param_boundary_type_t
Definition: cs_param.h:248
void( cs_scavec_law_func_t)(double var1_value, const double var2_vect[], const void *law_param, cs_get_t *retval)
Compute the value of a quantity according to a law depending only on two variables (the first one is ...
Definition: cs_cdo.h:228
cs_onevar_law_func_t * law1_func
Definition: cs_param.h:72
Definition: cs_param.h:115
Definition: cs_param.h:113
Definition: cs_param.h:87
Definition: cs_param.h:111
Definition: cs_param.h:212
bool inv_pty
Definition: cs_param.h:145
char * ml_name
Definition: cs_param.h:99
void cs_param_bc_def_set(cs_param_bc_def_t *bcpd, int loc_id, cs_param_bc_type_t bc_type, cs_param_var_type_t var_type, cs_param_def_type_t def_type, const void *coef1, const void *coef2)
Set a cs_param_bc_def_t structure.
Definition: cs_param.c:364
Definition: cs_param.h:338
Definition: cs_param.h:277
cs_def_t def_coef1
Definition: cs_param.h:300
void( cs_twovar_law_func_t)(double var1_value, double var2_value, const void *law_param, cs_get_t *retval)
Compute the value of a quantity according to a law depending only on two variables. This law is described by a set of parameters stored in a structure. result = law(var1_value, var2_value)
Definition: cs_cdo.h:207
Definition: cs_param.h:343
cs_param_var_type_t var_type
Definition: cs_param.h:294
cs_param_advection_scheme_t scheme
Definition: cs_param.h:221
cs_user_func_t * user_func
Definition: cs_param.h:69
cs_param_itsol_type_t solver
Definition: cs_param.h:352
cs_param_advection_scheme_t
Definition: cs_param.h:195
const char * cs_param_get_bc_enforcement_name(cs_param_bc_enforce_t type)
Get the name of the type of enforcement of the boundary condition.
Definition: cs_param.c:434
Definition: cs_param.h:264
#define BEGIN_C_DECLS
Definition: cs_defs.h:448
Definition: cs_param.h:265
Definition: cs_param.h:112
Definition: cs_param.h:201
Definition: cs_param.h:323
Definition: cs_param.h:136
Definition: cs_param.h:210
Definition: cs_param.h:89
Definition: cs_param.h:252
const char * cs_param_get_precond_name(cs_param_precond_type_t precond)
Get the name of the preconditioner.
Definition: cs_param.c:567
cs_scavec_law_func_t * law_scavec_func
Definition: cs_param.h:78
cs_param_advection_weight_t
Definition: cs_param.h:208
Definition: cs_param.h:344
Definition: cs_param.h:273
Definition: cs_param.h:340
Definition: cs_param.h:328
Definition: cs_param.h:130
Definition: cs_param.h:124
Definition: cs_param.h:188
cs_param_advection_form_t
Definition: cs_param.h:186
Definition: cs_param.h:211
Definition: cs_param.h:339
Definition: cs_param.h:88
Definition: cs_param.h:163
Definition: cs_cdo.h:129
Definition: cs_param.h:86
double cs_real_t
Floating-point value.
Definition: cs_defs.h:296
Definition: cs_param.h:127
Definition: cs_param.h:114
Definition: cs_param.h:250
Definition: cs_param.h:129
char * name
Definition: cs_param.h:239
cs_def_t def_coef2
Definition: cs_param.h:301
Definition: cs_param.h:233
Definition: cs_param.h:331
Definition: cs_param.h:139
Definition: cs_param.h:218
int loc_id
Definition: cs_param.h:291
bool do_lumping
Definition: cs_param.h:174
Definition: cs_param.h:261
cs_def_t def
Definition: cs_param.h:101
cs_timestep_func_t * time_func
Definition: cs_param.h:66
Definition: cs_param.h:90
cs_time_scheme_t scheme
Definition: cs_param.h:172
const char * cs_param_hodge_get_type_name(const cs_param_hodge_t h_info)
Get the type of discrete Hodge operator.
Definition: cs_param.c:511
cs_param_def_type_t def_type
Definition: cs_param.h:100
Definition: cs_param.h:189
void( cs_onevar_law_func_t)(double var_value, const void *law_param, cs_get_t *retval)
Compute the value of a quantity according to a law depending only on one variable. This law is described by a set of parameters stored in a structure. result = law(var_value)
Definition: cs_cdo.h:188
int output_freq
Definition: cs_param.h:357
void( cs_analytic_func_t)(cs_real_t time, const cs_real_3_t xyz, cs_get_t *retval)
Generic analytic function.
Definition: cs_cdo.h:154
int n_max_iter
Definition: cs_param.h:354
cs_real_t( cs_timestep_func_t)(int time_iter, double time)
Simple function to define the time step according to the number of iteration already done...
Definition: cs_cdo.h:171
cs_twovar_law_func_t * law2_func
Definition: cs_param.h:75
Definition: cs_param.h:92
Definition: cs_param.h:279
cs_quadra_type_t quad_type
Definition: cs_param.h:223
const char * cs_param_get_bc_name(cs_param_bc_type_t bc)
Get the name of the type of boundary condition.
Definition: cs_param.c:399
int n_defs
Definition: cs_param.h:313
const char * cs_param_get_def_type_name(const cs_param_def_type_t type)
Get the name related to a type of definition.
Definition: cs_param.c:151
const char * cs_param_hodge_get_algo_name(const cs_param_hodge_t h_info)
Get the name of algorithm related to a discrete Hdoge operator.
Definition: cs_param.c:495
cs_analytic_func_t * analytic
Definition: cs_param.h:63
cs_param_def_t * ic_definitions
Definition: cs_param.h:178
cs_param_precond_type_t
Definition: cs_param.h:321
cs_param_hodge_type_t type
Definition: cs_param.h:148
Definition: cs_param.h:170
Definition: cs_param.h:324
Definition: cs_param.h:200
Definition: cs_param.h:125
cs_param_itsol_type_t
Definition: cs_param.h:336
cs_param_advection_form_t formulation
Definition: cs_param.h:220
cs_param_def_type_t def_type
Definition: cs_param.h:295
Definition: cs_param.h:253
Definition: cs_param.h:97
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:308
cs_param_bc_type_t
Definition: cs_param.h:259
cs_param_bc_enforce_t enforcement
Definition: cs_param.h:308
Definition: cs_param.h:251
Definition: cs_param.h:91
Definition: cs_param.h:276
cs_quadra_type_t
Definition: cs_quadrature.h:40
Definition: cs_param.h:84
Definition: cs_param.h:57
Definition: cs_param.h:266
Definition: cs_param.h:326
cs_quadra_type_t quad_type
Definition: cs_param.h:309
cs_param_advection_weight_t weight_criterion
Definition: cs_param.h:222
Definition: cs_param.h:161
void( cs_user_func_t)(const void *input1, const void *input2, cs_real_t tcur, const cs_real_3_t xyz, cs_get_t *output)
Definition: cs_param.h:51
cs_param_hodge_type_t
Definition: cs_param.h:122
Definition: cs_param.h:198
Definition: cs_param.h:164
const char * cs_param_get_var_type_name(const cs_param_var_type_t type)
Get the name related to a type of variable.
Definition: cs_param.c:135
const char * cs_param_reaction_get_type_name(cs_param_reaction_type_t r_info)
Get the name of the type of reaction term.
Definition: cs_param.c:467
Definition: cs_param.h:232
Definition: cs_param.h:342
Definition: cs_param.h:341
const char * cs_param_get_solver_name(cs_param_itsol_type_t solver)
Get the name of the solver.
Definition: cs_param.c:527
Definition: cs_param.h:138
bool use_subdiv
Definition: cs_param.h:310
#define END_C_DECLS
Definition: cs_defs.h:449
Definition: cs_param.h:254
cs_param_bc_type_t default_bc
Definition: cs_param.h:307
const void * context
Definition: cs_param.h:103
Definition: cs_param.h:202
cs_param_reaction_type_t type
Definition: cs_param.h:240
cs_param_var_type_t
Definition: cs_param.h:109
int n_ic_definitions
Definition: cs_param.h:177
Definition: cs_param.h:263
Definition: cs_param.h:93
Definition: cs_param.h:237
bool resid_normalized
Definition: cs_param.h:358
Definition: cs_param.h:289
Definition: cs_param.h:126
Definition: cs_param.h:197
cs_param_bc_type_t bc_type
Definition: cs_param.h:293
double coef
Definition: cs_param.h:150
Definition: cs_param.h:274
Definition: cs_param.h:262
Definition: cs_param.h:305
Definition: cs_param.h:329
cs_param_reaction_type_t
Definition: cs_param.h:230
cs_param_hodge_algo_t
Definition: cs_param.h:134
Definition: cs_param.h:143
double eps
Definition: cs_param.h:355
cs_param_bc_enforce_t
Definition: cs_param.h:271
Definition: cs_param.h:330
cs_param_def_type_t
Definition: cs_param.h:82
Definition: cs_param.h:165
Definition: cs_param.h:85
Definition: cs_param.h:190
Definition: cs_param.h:349
Definition: cs_param.h:137
void cs_param_set_get(cs_param_var_type_t var_type, const char *val, cs_get_t *get)
Set a cs_get_t structure.
Definition: cs_param.c:264
Definition: cs_param.h:199