programmer's documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
cs_equation_param.h
Go to the documentation of this file.
1 #ifndef __CS_EQUATION_PARAM_H__
2 #define __CS_EQUATION_PARAM_H__
3 
4 /*============================================================================
5  * Header to handle specific settings related to a cs_equation_t structure
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  * Local headers
30  *----------------------------------------------------------------------------*/
31 
32 #include "cs_cdo_bc.h"
33 #include "cs_param.h"
34 #include "cs_property.h"
35 #include "cs_advection_field.h"
36 #include "cs_xdef.h"
37 
38 /*----------------------------------------------------------------------------*/
39 
41 
42 /*============================================================================
43  * Macro definitions
44  *============================================================================*/
45 
46 /* Term flag */
47 #define CS_EQUATION_LOCKED (1 << 0) // 1: modification not allowed
48 #define CS_EQUATION_UNSTEADY (1 << 1) // 2: unsteady term
49 #define CS_EQUATION_CONVECTION (1 << 2) // 4: convection term
50 #define CS_EQUATION_DIFFUSION (1 << 3) // 8: diffusion term
51 #define CS_EQUATION_REACTION (1 << 4) // 16: reaction term
52 
53 /* Extra operations flag */
54 #define CS_EQUATION_POST_PECLET (1 << 0) // 1: Export Peclet number
55 #define CS_EQUATION_POST_UPWIND_COEF (1 << 1) // 2: Export upwinding coef.
56 
57 /*============================================================================
58  * Type definitions
59  *============================================================================*/
60 
61 /* Type of equations managed by the solver */
62 typedef enum {
63 
64  CS_EQUATION_TYPE_USER, // User-defined equation
65  CS_EQUATION_TYPE_GROUNDWATER, // Equation specific to groundwater flows
66  CS_EQUATION_TYPE_PREDEFINED, // General predefined equation
68 
70 
71 /* Type of algorithm to get the solution of an equation */
72 typedef enum {
73 
74  CS_EQUATION_ALGO_CS_ITSOL, /* Used an iterative solver
75  defined by Code_Saturne */
76  CS_EQUATION_ALGO_PETSC_ITSOL, /* Used an iterative solver
77  defined by PETSc */
78  CS_EQUATION_ALGO_UZAWA, // To solve sadle-point system
79  CS_EQUATION_ALGO_NEWTON, // To solve non-linear system
80  CS_EQUATION_ALGO_PICARD, // To solve non-linear system
82 
84 
85 /* Description of the algorithm used to solve an equation */
86 typedef struct {
87 
89 
90  int n_iters;
94 
95  double eps; /* stopping criterion on accuracy */
96 
98 
99 /* Set of parameters to handle an unsteady convection-diffusion-reaction
100  equation with term sources */
101 typedef struct {
102 
103  cs_equation_type_t type; /* predefined, user... */
104  int dim; /* Dimension of the unknown */
105  int verbosity; /* Level of detail for output */
106  int sles_verbosity; /* Level of detail for SLES output */
107 
108  /* Unsteady-Diffusion-Convection-Source term activated or not */
110 
111  /* Post-treatment */
112  cs_flag_t process_flag; /* Type of post-treatment to do */
113 
114  /* Numerical settings */
116  /* Max. degree of the polynomial basis */
118 
119  /* Boundary conditions */
124 
125  /* High-level structure to manage/monitor the resolution of this equation */
128 
129  /* Time-dependent term parameters */
135 
138 
139  /* Diffusion term parameters */
142 
143  /* Advection term parameters */
146 
147  /* Reaction term parameters
148  Belong to the left-hand and/or right-hand side according to the time scheme
149  */
153 
154  /* Parameters of source terms (Belong to the right-hand side) */
157 
159 
160 /*============================================================================
161  * Public function prototypes
162  *============================================================================*/
163 
164 /*----------------------------------------------------------------------------*/
174 /*----------------------------------------------------------------------------*/
175 
178  int dim,
179  cs_param_bc_type_t default_bc);
180 
181 /*----------------------------------------------------------------------------*/
189 /*----------------------------------------------------------------------------*/
190 
193 
194 /*----------------------------------------------------------------------------*/
201 /*----------------------------------------------------------------------------*/
202 
203 void
204 cs_equation_param_summary(const char *eqname,
205  const cs_equation_param_t *eqp);
206 
207 /*----------------------------------------------------------------------------*/
216 /*----------------------------------------------------------------------------*/
217 
218 void
219 cs_equation_param_init_sles(const char *eqname,
220  const cs_equation_param_t *eqp,
221  int field_id);
222 
223 /*----------------------------------------------------------------------------*/
231 /*----------------------------------------------------------------------------*/
232 
233 static inline bool
235 {
236  if (eqp == NULL)
237  return false;
238  if (eqp->flag & CS_EQUATION_DIFFUSION)
239  return true;
240  else
241  return false;
242 }
243 
244 /*----------------------------------------------------------------------------*/
252 /*----------------------------------------------------------------------------*/
253 
254 static inline bool
256 {
257  if (eqp == NULL)
258  return false;
259  if (eqp->flag & CS_EQUATION_CONVECTION)
260  return true;
261  else
262  return false;
263 }
264 
265 /*----------------------------------------------------------------------------*/
273 /*----------------------------------------------------------------------------*/
274 
275 static inline bool
277 {
278  if (eqp == NULL)
279  return false;
280  if (eqp->flag & CS_EQUATION_REACTION)
281  return true;
282  else
283  return false;
284 }
285 
286 /*----------------------------------------------------------------------------*/
294 /*----------------------------------------------------------------------------*/
295 
296 static inline bool
298 {
299  if (eqp == NULL)
300  return false;
301  if (eqp->flag & CS_EQUATION_UNSTEADY)
302  return true;
303  else
304  return false;
305 }
306 
307 /*----------------------------------------------------------------------------*/
315 /*----------------------------------------------------------------------------*/
316 
317 static inline bool
319 {
320  if (eqp == NULL)
321  return false;
322  if (eqp->n_source_terms > 0)
323  return true;
324  else
325  return false;
326 }
327 
328 /*----------------------------------------------------------------------------*/
329 
331 
332 #endif /* __CS_EQUATION_PARAM_H__ */
cs_time_scheme_t
Definition: cs_param.h:93
int n_max_iters
Definition: cs_equation_param.h:91
cs_param_bc_type_t default_bc
Definition: cs_equation_param.h:120
cs_property_t * diffusion_property
Definition: cs_equation_param.h:141
void cs_equation_param_summary(const char *eqname, const cs_equation_param_t *eqp)
Summary of a cs_equation_param_t structure.
Definition: cs_equation_param.c:471
Definition: cs_advection_field.h:61
Definition: cs_equation_param.h:74
cs_adv_field_t * advection_field
Definition: cs_equation_param.h:145
cs_param_hodge_t time_hodge
Definition: cs_equation_param.h:130
int n_bc_desc
Definition: cs_equation_param.h:122
Definition: cs_equation_param.h:101
int n_cumulated_iters
Definition: cs_equation_param.h:92
cs_equation_algo_t algo_info
Definition: cs_equation_param.h:126
cs_equation_type_t type
Definition: cs_equation_param.h:103
cs_time_scheme_t time_scheme
Definition: cs_equation_param.h:132
static bool cs_equation_param_has_time(const cs_equation_param_t *eqp)
Ask if the parameters of the equation needs an unsteady term.
Definition: cs_equation_param.h:297
Definition: cs_equation_param.h:86
#define BEGIN_C_DECLS
Definition: cs_defs.h:453
void cs_equation_param_init_sles(const char *eqname, const cs_equation_param_t *eqp, int field_id)
Initialize SLES structure for the resolution of the linear system according to the settings related t...
Definition: cs_equation_param.c:740
static bool cs_equation_param_has_diffusion(const cs_equation_param_t *eqp)
Ask if the parameters of the equation needs a diffusion term.
Definition: cs_equation_param.h:234
Definition: cs_equation_param.h:79
int n_iters
Definition: cs_equation_param.h:90
cs_equation_param_t * cs_equation_param_create(cs_equation_type_t type, int dim, cs_param_bc_type_t default_bc)
Create a cs_equation_param_t.
Definition: cs_equation_param.c:324
double eps
Definition: cs_equation_param.h:95
int n_ic_desc
Definition: cs_equation_param.h:136
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
#define CS_EQUATION_UNSTEADY
Definition: cs_equation_param.h:48
Definition: cs_param.h:138
cs_space_scheme_t
Definition: cs_cdo.h:138
cs_xdef_t ** source_terms
Definition: cs_equation_param.h:156
cs_equation_param_t * cs_equation_param_free(cs_equation_param_t *eqp)
Free a cs_equation_param_t.
Definition: cs_equation_param.c:415
#define CS_EQUATION_CONVECTION
Definition: cs_equation_param.h:49
cs_space_scheme_t space_scheme
Definition: cs_equation_param.h:115
int n_reaction_terms
Definition: cs_equation_param.h:151
cs_flag_t process_flag
Definition: cs_equation_param.h:112
int dim
Definition: cs_equation_param.h:104
bool do_lumping
Definition: cs_equation_param.h:134
cs_param_advection_t advection_info
Definition: cs_equation_param.h:144
cs_param_bc_enforce_t enforcement
Definition: cs_equation_param.h:121
cs_param_hodge_t diffusion_hodge
Definition: cs_equation_param.h:140
Definition: cs_equation_param.h:81
cs_equation_algo_type_t type
Definition: cs_equation_param.h:88
int n_source_terms
Definition: cs_equation_param.h:155
Definition: cs_xdef.h:72
Definition: cs_equation_param.h:80
int space_poly_degree
Definition: cs_equation_param.h:117
cs_equation_type_t
Definition: cs_equation_param.h:62
cs_param_bc_type_t
Definition: cs_param.h:161
cs_real_t theta
Definition: cs_equation_param.h:133
int verbosity
Definition: cs_equation_param.h:105
cs_property_t ** reaction_properties
Definition: cs_equation_param.h:152
int n_max_cumulated_iters
Definition: cs_equation_param.h:93
int sles_verbosity
Definition: cs_equation_param.h:106
cs_param_itsol_t itsol_info
Definition: cs_equation_param.h:127
Definition: cs_equation_param.h:67
#define END_C_DECLS
Definition: cs_defs.h:454
unsigned short int cs_flag_t
Definition: cs_defs.h:299
cs_param_hodge_t reaction_hodge
Definition: cs_equation_param.h:150
cs_flag_t flag
Definition: cs_equation_param.h:109
Definition: cs_equation_param.h:65
Definition: cs_equation_param.h:64
#define CS_EQUATION_REACTION
Definition: cs_equation_param.h:51
Definition: cs_equation_param.h:66
cs_xdef_t ** bc_desc
Definition: cs_equation_param.h:123
#define CS_EQUATION_DIFFUSION
Definition: cs_equation_param.h:50
Definition: cs_equation_param.h:76
Definition: cs_param.h:76
static bool cs_equation_param_has_reaction(const cs_equation_param_t *eqp)
Ask if the parameters of the equation needs a reaction term.
Definition: cs_equation_param.h:276
static bool cs_equation_param_has_sourceterm(const cs_equation_param_t *eqp)
Ask if the parameters of the equation needs a source term.
Definition: cs_equation_param.h:318
Definition: cs_property.h:62
cs_param_bc_enforce_t
Definition: cs_param.h:173
Definition: cs_equation_param.h:78
cs_equation_algo_type_t
Definition: cs_equation_param.h:72
cs_property_t * time_property
Definition: cs_equation_param.h:131
Definition: cs_param.h:218
static bool cs_equation_param_has_convection(const cs_equation_param_t *eqp)
Ask if the parameters of the equation needs a convection term.
Definition: cs_equation_param.h:255
cs_xdef_t ** ic_desc
Definition: cs_equation_param.h:137