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-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  * 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 /* Values associated to the different ways to retrieve data */
51 typedef union {
52 
53  cs_flag_t flag; // flag
54  int id; // identification number
55  cs_lnum_t num; // local number
56  cs_real_t val; // value
57  cs_real_2_t couple; // two values
58  cs_real_3_t vect; // vector: 3 values
59  cs_nvec3_t nvec3; // meas + unit vector
60  cs_real_6_t twovects; // two vectors
61  cs_real_33_t tens; // tensor: 9 values
62 
63 } cs_get_t;
64 
65 /* User-defined function */
66 typedef void (cs_user_func_t) (const void *input1,
67  const void *input2,
68  cs_real_t tcur,
69  const cs_real_3_t xyz,
70  cs_get_t *output);
71 
72 typedef union {
73 
74  /* For a definition by value */
75  cs_get_t get;
76 
77  /* For a definition by an analytic function */
79 
80  /* For a definition of the time step by a function */
82 
83  /* For a definition by an user-defined function */
85 
86  /* For a definition by law depending on one scalar variable */
88 
89  /* For a definition by law depending on two scalar variables */
91 
92 } cs_def_t;
93 
94 typedef enum {
95 
105 
107 
108 typedef struct {
109 
110  int ml_id; /* id related to a mesh location */
111  cs_param_def_type_t def_type; /* type of definition */
112  cs_def_t def; /* definition */
113 
114  const void *context; /* If this definition hinges on a related
115  structure. Always shared */
116 
118 
119 /* Dimension of the variable to deal with */
120 typedef enum {
121 
122  CS_PARAM_VAR_SCAL, // scalar variable (dim = 1)
123  CS_PARAM_VAR_VECT, // vector variable (dim = 3)
124  CS_PARAM_VAR_SYMTENS, // symmetric tensor variable (dim = 6)
125  CS_PARAM_VAR_TENS, // tensor variable (dim = 9)
127 
129 
130 /* DISCRETE HODGE OPERATORS */
131 /* ======================== */
132 
133 typedef enum {
134 
135  CS_PARAM_HODGE_TYPE_VPCD, // from primal vertices to dual cells
136  CS_PARAM_HODGE_TYPE_EPFD, // from primal edges to dual faces
137  CS_PARAM_HODGE_TYPE_FPED, // from primal faces to dual edges
138  CS_PARAM_HODGE_TYPE_EDFP, // from dual edges to primal faces
139  CS_PARAM_HODGE_TYPE_CPVD, // from primal cells to dual vertices
140  CS_PARAM_HODGE_TYPE_VC, // primal vertices + primal cells
142 
144 
145 typedef enum {
146 
147  CS_PARAM_HODGE_ALGO_VORONOI, // Under othogonality condition gives a diag. op.
148  CS_PARAM_HODGE_ALGO_WBS, // WBS: Whitney Barycentric Subdivision
149  CS_PARAM_HODGE_ALGO_COST, // COST: COnsistency & STabilization splitting
150  CS_PARAM_HODGE_ALGO_AUTO, /* Switch between the previous algo. according to
151  the type of cell and its property */
153 
155 
156 typedef struct {
157 
158  bool is_unity; /* No associated property. Property is equalt to the unity */
159  bool is_iso; /* Associated property is isotroopic ? */
160  bool inv_pty; /* Definition based on the property or its inverse */
161 
162  cs_param_hodge_type_t type; /* type of discrete Hodge operator */
163  cs_param_hodge_algo_t algo; /* type of algorithm used to build this op. */
164  double coef; /* Value of the stabilization parameter
165  if the COST algo. is used, otherwise 0. */
166 
168 
169 /* TIME SCHEME */
170 /* =========== */
171 
172 /* Type of numerical scheme for the discretization in time */
173 typedef enum {
174 
175  CS_TIME_SCHEME_IMPLICIT, // fully implicit (forward Euler/theta-scheme = 1)
176  CS_TIME_SCHEME_EXPLICIT, // fully explicit (backward Euler/theta-scheme = 0)
177  CS_TIME_SCHEME_CRANKNICO, // Crank-Nicolson (theta-scheme = 0.5)
178  CS_TIME_SCHEME_THETA, // theta-scheme
180 
182 
183 /* Parameters related to time discretization */
184 typedef struct {
185 
186  cs_time_scheme_t scheme; // numerical scheme
187  cs_real_t theta; // used in theta-scheme
188  bool do_lumping; // perform mass lumping ?
189 
190  /* Initial conditions (by default, 0 is set) */
191  int n_ic_definitions; /* 0 -> default settings */
192  cs_param_def_t *ic_definitions; /* list of definitions (mesh location
193  by mesh location) */
194 
196 
197 /* ADVECTION OPERATOR PARAMETRIZATION */
198 /* ================================== */
199 
200 typedef enum {
201 
205 
207 
208 /* Type of weight functions considered */
209 typedef enum {
210 
212  CS_PARAM_ADVECTION_SCHEME_CIP, // Only V+C CDO schemes
217 
219 
220 /* Choice on the type of algo. used to set the argument used in
221  the weight function */
222 typedef enum {
223 
227 
229 
230 /* Set of options for building a contraction operator (also called interior
231  product) which is closely related to the advection operator */
232 typedef struct {
233 
234  cs_param_advection_form_t formulation; // conservative or not
237  cs_quadra_type_t quad_type; // barycentric, higher, highest
238 
240 
241 /* REACTION TERM PARAMETRIZATION */
242 /* ============================= */
243 
244 typedef enum {
245 
248 
250 
251 typedef struct {
252 
253  char *name;
255 
257 
258 /* BOUNDARY CONDITIONS */
259 /* =================== */
260 
261 /* Physic-driven boundary */
262 typedef enum {
263 
269 
271 
272 /* Mathematical boundary conditions */
273 typedef enum {
274 
281 
283 
284 /* Choice between different method to enforce the BCs */
285 typedef enum {
286 
287  CS_PARAM_BC_ENFORCE_STRONG, /* Strong enforcement of the BCs */
288  CS_PARAM_BC_ENFORCE_WEAK_PENA, /* Weak enforcement with a strong
289  penalization coefficient */
290  CS_PARAM_BC_ENFORCE_WEAK_NITSCHE, /* Weak enforcement using Nitsche method */
291  CS_PARAM_BC_ENFORCE_WEAK_SYM, /* Weak enforcement using symmetric Nitsche
292  method */
294 
296 
297 /* Main structure to handle boundary condition */
298 typedef struct {
299 
300  cs_param_bc_type_t default_bc; // BC used by default
301 
302  /* How is defined the BC value (arrays are allocated to n_max_defs) */
304  int n_defs;
305 
308 
309  /* Store the related mesh location (always on boundary faces) */
310  int *ml_ids;
311 
312  /* What is the type of BC associated to this definition: Dirichlet, Neumann,
313  Robin... (from the mathematical viewpoint, the "physical" BCs are handled
314  in the cs_domain_t structure (wall, symmetry, inlet, outlet...)) */
316 
317  /* Advanced parametrization */
318  /* ------------------------ */
319 
320  /* Type of boundary enforcement (only useful for essential BCs) */
322  /* Which algorithm to compute the evaluation
323  (barycentric, higher, highest...) */
325 
326 } cs_param_bc_t;
327 
328 /* ITERATIVE SOLVERS */
329 /* ================= */
330 
331 typedef enum {
332 
333  CS_PARAM_PRECOND_NONE, // No preconditioning
334  CS_PARAM_PRECOND_DIAG, // Diagonal preconditioning (also called Jacobi)
335  CS_PARAM_PRECOND_BJACOB, // Block Jacobi
336  CS_PARAM_PRECOND_POLY1, // Neumann polynomial preconditioning (Order 1)
337  CS_PARAM_PRECOND_SSOR, // Symmetric Successive OverRelaxations
338  CS_PARAM_PRECOND_ILU0, // Incomplete LU factorization
339  CS_PARAM_PRECOND_ICC0, // Incomplete Cholesky factorization
340  CS_PARAM_PRECOND_AMG, // Algebraic MultiGrid
341  CS_PARAM_PRECOND_AS, // Additive Schwarz method
343 
345 
346 /* Type of iterative solver to use to inverse the linear system */
347 typedef enum {
348 
350  CS_PARAM_ITSOL_CG, // Conjuguate Gradient
351  CS_PARAM_ITSOL_BICG, // Bi-Conjuguate gradient
352  CS_PARAM_ITSOL_BICGSTAB2, // Stabilized Bi-Conjuguate gradient
353  CS_PARAM_ITSOL_CR3, // 3-layer conjugate residual
354  CS_PARAM_ITSOL_GMRES, // Generalized Minimal RESidual
355  CS_PARAM_ITSOL_AMG, // Algebraic MultiGrid
357 
359 
360 /* Description of the algorithm used to solve an equation */
361 typedef struct {
362 
363  cs_param_precond_type_t precond; // type of preconditioner
364  cs_param_itsol_type_t solver; // type of solver
365 
366  int n_max_iter; // max. number of iterations
367  double eps; // stopping criterion on accuracy
368 
369  int output_freq; // frequencdy of output into listing
370  bool resid_normalized; /* normalized or not the norm of the
371  residual used for the stopping criterion
372  */
374 
375 /*============================================================================
376  * Global variables
377  *============================================================================*/
378 
379 /*============================================================================
380  * Public function prototypes
381  *============================================================================*/
382 
383 /*----------------------------------------------------------------------------*/
391 /*----------------------------------------------------------------------------*/
392 
393 const char *
395 
396 /*----------------------------------------------------------------------------*/
404 /*----------------------------------------------------------------------------*/
405 
406 const char *
408 
409 /*----------------------------------------------------------------------------*/
417 /*----------------------------------------------------------------------------*/
418 
419 void
421  const cs_get_t get,
422  cs_def_t *def);
423 
424 /*----------------------------------------------------------------------------*/
433 /*----------------------------------------------------------------------------*/
434 
435 void
437  cs_param_var_type_t var_type,
438  const void *val,
439  cs_def_t *def);
440 
441 /*----------------------------------------------------------------------------*/
449 /*----------------------------------------------------------------------------*/
450 
451 void
453  const char *val,
454  cs_get_t *get);
455 
456 /*----------------------------------------------------------------------------*/
464 /*----------------------------------------------------------------------------*/
465 
468 
469 /*----------------------------------------------------------------------------*/
477 /*----------------------------------------------------------------------------*/
478 
479 const char *
481 
482 /*----------------------------------------------------------------------------*/
490 /*----------------------------------------------------------------------------*/
491 
492 const char *
494 
495 /*----------------------------------------------------------------------------*/
503 /*----------------------------------------------------------------------------*/
504 
505 const char *
507 
508 /*----------------------------------------------------------------------------*/
516 /*----------------------------------------------------------------------------*/
517 
518 const char *
520 
521 /*----------------------------------------------------------------------------*/
529 /*----------------------------------------------------------------------------*/
530 
531 const char *
533 
534 /*----------------------------------------------------------------------------*/
542 /*----------------------------------------------------------------------------*/
543 
544 const char *
546 
547 /*----------------------------------------------------------------------------*/
555 /*----------------------------------------------------------------------------*/
556 
557 const char *
559 
560 /*----------------------------------------------------------------------------*/
561 
563 
564 #endif /* __CS_PARAM_H__ */
cs_param_def_type_t * def_types
Definition: cs_param.h:306
int ml_id
Definition: cs_param.h:110
cs_time_scheme_t
Definition: cs_param.h:173
void() cs_analytic_func_t(cs_real_t time, cs_lnum_t n_points, const cs_real_t *xyz, cs_real_t *retval)
Generic analytic function.
Definition: cs_cdo.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:367
Definition: cs_param.h:176
cs_nvec3_t nvec3
Definition: cs_param.h:59
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:204
Definition: cs_param.h:139
cs_param_hodge_algo_t algo
Definition: cs_param.h:163
cs_param_precond_type_t precond
Definition: cs_param.h:363
Definition: cs_param.h:336
cs_real_t cs_real_2_t[2]
vector of 2 floating-point values
Definition: cs_defs.h:308
Definition: cs_param.h:338
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:311
cs_real_t theta
Definition: cs_param.h:187
cs_param_boundary_type_t
Definition: cs_param.h:262
cs_onevar_law_func_t * law1_func
Definition: cs_param.h:87
Definition: cs_param.h:99
Definition: cs_param.h:126
Definition: cs_param.h:124
Definition: cs_param.h:122
Definition: cs_param.h:226
bool inv_pty
Definition: cs_param.h:160
Definition: cs_param.h:350
Definition: cs_param.h:291
Definition: cs_param.h:355
int n_max_defs
Definition: cs_param.h:303
cs_param_advection_scheme_t scheme
Definition: cs_param.h:235
cs_user_func_t * user_func
Definition: cs_param.h:84
cs_param_itsol_type_t solver
Definition: cs_param.h:364
cs_param_advection_scheme_t
Definition: cs_param.h:209
cs_real_33_t tens
Definition: cs_param.h:61
Definition: cs_param.h:333
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:435
Definition: cs_param.h:278
#define BEGIN_C_DECLS
Definition: cs_defs.h:451
Definition: cs_param.h:279
Definition: cs_param.h:123
Definition: cs_param.h:215
Definition: cs_param.h:334
Definition: cs_param.h:147
Definition: cs_param.h:224
Definition: cs_param.h:100
Definition: cs_param.h:349
Definition: cs_param.h:266
const char * cs_param_get_precond_name(cs_param_precond_type_t precond)
Get the name of the preconditioner.
Definition: cs_param.c:572
bool is_unity
Definition: cs_param.h:158
cs_param_advection_weight_t
Definition: cs_param.h:222
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:177
int id
Definition: cs_param.h:54
Definition: cs_param.h:356
Definition: cs_param.h:287
Definition: cs_param.h:352
Definition: cs_param.h:339
Definition: cs_param.h:141
Definition: cs_param.h:135
Definition: cs_param.h:202
cs_param_advection_form_t
Definition: cs_param.h:200
Definition: cs_param.h:225
Definition: cs_param.h:351
Definition: cs_param.h:177
Definition: cs_param.h:51
bool is_iso
Definition: cs_param.h:159
void() cs_onevar_law_func_t(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], const cs_real_t var_values[], const void *law_param, cs_real_t res_array[])
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:196
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
Definition: cs_param.h:138
Definition: cs_param.h:125
Definition: cs_param.h:264
Definition: cs_cdo.h:129
Definition: cs_param.h:140
char * name
Definition: cs_param.h:253
Definition: cs_param.h:247
Definition: cs_param.h:342
Definition: cs_param.h:152
Definition: cs_param.h:232
bool do_lumping
Definition: cs_param.h:188
Definition: cs_param.h:275
cs_def_t def
Definition: cs_param.h:112
cs_timestep_func_t * time_func
Definition: cs_param.h:81
Definition: cs_param.h:101
cs_time_scheme_t scheme
Definition: cs_param.h:186
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:512
cs_param_def_type_t def_type
Definition: cs_param.h:111
Definition: cs_param.h:203
cs_real_2_t couple
Definition: cs_param.h:57
int output_freq
Definition: cs_param.h:369
Definition: cs_param.h:150
int n_max_iter
Definition: cs_param.h:366
cs_twovar_law_func_t * law2_func
Definition: cs_param.h:90
Definition: cs_param.h:103
Definition: cs_param.h:293
cs_quadra_type_t quad_type
Definition: cs_param.h:237
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:400
int n_defs
Definition: cs_param.h:304
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:135
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:496
cs_analytic_func_t * analytic
Definition: cs_param.h:78
cs_param_def_t * ic_definitions
Definition: cs_param.h:192
cs_param_precond_type_t
Definition: cs_param.h:331
cs_param_hodge_type_t type
Definition: cs_param.h:162
Definition: cs_param.h:184
Definition: cs_param.h:335
Definition: cs_param.h:214
Definition: cs_param.h:136
cs_param_itsol_type_t
Definition: cs_param.h:347
void cs_param_set_def_by_value(cs_param_var_type_t var_type, const cs_get_t get, cs_def_t *def)
Set a definition by value.
Definition: cs_param.c:151
cs_param_advection_form_t formulation
Definition: cs_param.h:234
Definition: cs_param.h:267
cs_real_t val
Definition: cs_param.h:56
Definition: cs_param.h:108
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:309
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:66
cs_real_6_t twovects
Definition: cs_param.h:60
cs_param_bc_type_t
Definition: cs_param.h:273
void() cs_twovar_law_func_t(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], const double var1_values[], const double var2_values[], const void *law_param, cs_real_t res_array[])
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:219
cs_param_bc_enforce_t enforcement
Definition: cs_param.h:321
Definition: cs_param.h:265
Definition: cs_param.h:102
Definition: cs_param.h:290
cs_quadra_type_t
Definition: cs_quadrature.h:47
Definition: cs_param.h:96
int * ml_ids
Definition: cs_param.h:310
Definition: cs_param.h:72
Definition: cs_param.h:280
Definition: cs_param.h:337
cs_quadra_type_t quad_type
Definition: cs_param.h:324
cs_param_advection_weight_t weight_criterion
Definition: cs_param.h:236
cs_lnum_t num
Definition: cs_param.h:55
Definition: cs_param.h:175
cs_param_hodge_type_t
Definition: cs_param.h:133
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
Definition: cs_param.h:212
Definition: cs_param.h:178
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:119
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:468
Definition: cs_param.h:246
Definition: cs_param.h:354
Definition: cs_param.h:353
const char * cs_param_get_solver_name(cs_param_itsol_type_t solver)
Get the name of the solver.
Definition: cs_param.c:528
Definition: cs_param.h:149
cs_param_bc_type_t * types
Definition: cs_param.h:315
#define END_C_DECLS
Definition: cs_defs.h:452
cs_def_t * defs
Definition: cs_param.h:307
unsigned short int cs_flag_t
Definition: cs_defs.h:299
Definition: cs_param.h:268
cs_param_bc_type_t default_bc
Definition: cs_param.h:300
const void * context
Definition: cs_param.h:114
Definition: cs_param.h:216
cs_param_reaction_type_t type
Definition: cs_param.h:254
cs_param_var_type_t
Definition: cs_param.h:120
int n_ic_definitions
Definition: cs_param.h:191
Definition: cs_param.h:277
Definition: cs_param.h:104
Definition: cs_param.h:251
bool resid_normalized
Definition: cs_param.h:370
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:315
Definition: cs_param.h:137
Definition: cs_param.h:211
double coef
Definition: cs_param.h:164
Definition: cs_param.h:288
Definition: cs_param.h:276
Definition: cs_param.h:298
Definition: cs_param.h:340
cs_param_reaction_type_t
Definition: cs_param.h:244
cs_param_hodge_algo_t
Definition: cs_param.h:145
Definition: cs_param.h:156
double eps
Definition: cs_param.h:367
cs_flag_t flag
Definition: cs_param.h:53
Definition: cs_param.h:98
cs_param_bc_enforce_t
Definition: cs_param.h:285
Definition: cs_param.h:341
cs_param_def_type_t
Definition: cs_param.h:94
Definition: cs_param.h:179
Definition: cs_param.h:97
Definition: cs_param.h:204
Definition: cs_param.h:361
Definition: cs_param.h:148
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:300
Definition: cs_param.h:213
cs_real_3_t vect
Definition: cs_param.h:58