programmer's documentation
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-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  * Local headers
30  *----------------------------------------------------------------------------*/
31 
32 #include "cs_param.h"
33 #include "cs_property.h"
34 #include "cs_advection_field.h"
35 #include "cs_source_term.h"
36 
37 /*----------------------------------------------------------------------------*/
38 
40 
41 /*============================================================================
42  * Macro definitions
43  *============================================================================*/
44 
45 /* Term flag */
46 #define CS_EQUATION_LOCKED (1 << 0) // 1: modification not allowed
47 #define CS_EQUATION_UNSTEADY (1 << 1) // 2: unsteady term
48 #define CS_EQUATION_CONVECTION (1 << 2) // 4: convection term
49 #define CS_EQUATION_DIFFUSION (1 << 3) // 8: diffusion term
50 #define CS_EQUATION_REACTION (1 << 4) // 16: reaction term
51 
52 /* Extra operations flag */
53 #define CS_EQUATION_POST_PECLET (1 << 0) // 1: Export Peclet number
54 #define CS_EQUATION_POST_COURANT (1 << 1) // 2: Export Courant number
55 #define CS_EQUATION_POST_FOURIER (1 << 2) // 4: Export Fourier number
56 #define CS_EQUATION_POST_UPWIND_COEF (1 << 3) // 8: Export upwinding co ef.
57 
58 /*============================================================================
59  * Type definitions
60  *============================================================================*/
61 
62 /* Type of equations managed by the solver */
63 typedef enum {
64 
65  CS_EQUATION_TYPE_USER, // User-defined equation
66  CS_EQUATION_TYPE_GROUNDWATER, // Equation specific to groundwater flows
67  CS_EQUATION_TYPE_PREDEFINED, // General predefined equation
69 
71 
72 /* Type of algorithm to get the solution of an equation */
73 typedef enum {
74 
75  CS_EQUATION_ALGO_CS_ITSOL, /* Used an iterative solver
76  defined by Code_Saturne */
77  CS_EQUATION_ALGO_PETSC_ITSOL, /* Used an iterative solver
78  defined by PETSc */
79  CS_EQUATION_ALGO_UZAWA, // To solve sadle-point system
80  CS_EQUATION_ALGO_NEWTON, // To solve non-linear system
81  CS_EQUATION_ALGO_PICARD, // To solve non-linear system
83 
85 
86 /* Description of the algorithm used to solve an equation */
87 typedef struct {
88 
90 
91  int n_iters;
95 
96  double eps; /* stopping criterion on accuracy */
97 
99 
100 /* Set of parameters to handle an unsteady convection-diffusion-reaction
101  equation with term sources */
102 typedef struct {
103 
104  cs_equation_type_t type; /* predefined, user... */
105  cs_param_var_type_t var_type; /* scalar, vector, tensor... */
106  int verbosity; /* Level of detail to output */
107  int sles_verbosity; /* Level of detail to output for SLES */
108 
109  /* Unsteady-Diffusion-Convection-Source term activated or not */
111 
112  /* Post-treatment */
113  cs_flag_t process_flag; /* Type of post-treatment to do */
114 
115  /* Numerical settings */
117 
118  /* Boundary conditions */
120 
121  /* High-level structure to manage/monitor the resolution of this equation */
124 
125  /* Unsteady term parametrization */
128  cs_property_t *time_property;
129 
130  /* Diffusion term parametrization */
132  cs_property_t *diffusion_property;
133 
134  /* Advection term parametrization */
136  cs_adv_field_t *advection_field;
137 
138  /* Reaction term parametrization (Belong to the left-hand side) */
141  cs_property_t **reaction_properties;
143 
144  /* Parametrization of source terms (Belong to the right-hand side) */
146  cs_source_term_t **source_terms;
147 
149 
150 /*============================================================================
151  * Public function prototypes
152  *============================================================================*/
153 
154 /*----------------------------------------------------------------------------*/
164 /*----------------------------------------------------------------------------*/
165 
168  cs_param_var_type_t var_type,
169  cs_param_bc_type_t default_bc);
170 
171 /*----------------------------------------------------------------------------*/
179 /*----------------------------------------------------------------------------*/
180 
183 
184 /*----------------------------------------------------------------------------*/
191 /*----------------------------------------------------------------------------*/
192 
193 void
194 cs_equation_param_summary(const char *eqname,
195  const cs_equation_param_t *eqp);
196 
197 /*----------------------------------------------------------------------------*/
206 /*----------------------------------------------------------------------------*/
207 
208 void
209 cs_equation_param_init_sles(const char *eqname,
210  const cs_equation_param_t *eqp,
211  int field_id);
212 
213 /*----------------------------------------------------------------------------*/
214 
216 
217 #endif /* __CS_EQUATION_PARAM_H__ */
cs_param_reaction_t * reaction_info
Definition: cs_equation_param.h:142
int n_max_iters
Definition: cs_equation_param.h:92
cs_property_t * diffusion_property
Definition: cs_equation_param.h:132
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:466
Definition: cs_equation_param.h:75
cs_adv_field_t * advection_field
Definition: cs_equation_param.h:136
cs_source_term_t ** source_terms
Definition: cs_equation_param.h:146
cs_param_hodge_t time_hodge
Definition: cs_equation_param.h:127
Definition: cs_equation_param.h:102
int n_cumulated_iters
Definition: cs_equation_param.h:93
cs_param_var_type_t var_type
Definition: cs_equation_param.h:105
cs_equation_algo_t algo_info
Definition: cs_equation_param.h:122
cs_equation_type_t type
Definition: cs_equation_param.h:104
Definition: cs_equation_param.h:87
#define BEGIN_C_DECLS
Definition: cs_defs.h:448
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:710
Definition: cs_equation_param.h:80
int n_iters
Definition: cs_equation_param.h:91
double eps
Definition: cs_equation_param.h:96
Definition: cs_param.h:218
cs_space_scheme_t
Definition: cs_cdo.h:99
cs_equation_param_t * cs_equation_param_free(cs_equation_param_t *eqp)
Free a cs_equation_param_t.
Definition: cs_equation_param.c:410
cs_space_scheme_t space_scheme
Definition: cs_equation_param.h:116
int n_reaction_terms
Definition: cs_equation_param.h:140
cs_flag_t process_flag
Definition: cs_equation_param.h:113
cs_param_advection_t advection_info
Definition: cs_equation_param.h:135
cs_param_hodge_t diffusion_hodge
Definition: cs_equation_param.h:131
Definition: cs_param.h:170
cs_equation_param_t * cs_equation_param_create(cs_equation_type_t type, cs_param_var_type_t var_type, cs_param_bc_type_t default_bc)
Create a cs_equation_param_t.
Definition: cs_equation_param.c:328
Definition: cs_equation_param.h:82
cs_equation_algo_type_t type
Definition: cs_equation_param.h:89
int n_source_terms
Definition: cs_equation_param.h:145
Definition: cs_equation_param.h:81
cs_equation_type_t
Definition: cs_equation_param.h:63
cs_param_bc_type_t
Definition: cs_param.h:259
int verbosity
Definition: cs_equation_param.h:106
cs_property_t ** reaction_properties
Definition: cs_equation_param.h:141
int n_max_cumulated_iters
Definition: cs_equation_param.h:94
cs_param_bc_t * bc
Definition: cs_equation_param.h:119
int sles_verbosity
Definition: cs_equation_param.h:107
cs_param_itsol_t itsol_info
Definition: cs_equation_param.h:123
Definition: cs_equation_param.h:68
#define END_C_DECLS
Definition: cs_defs.h:449
unsigned short int cs_flag_t
Definition: cs_defs.h:298
cs_param_var_type_t
Definition: cs_param.h:109
cs_param_hodge_t reaction_hodge
Definition: cs_equation_param.h:139
Definition: cs_param.h:237
cs_flag_t flag
Definition: cs_equation_param.h:110
Definition: cs_equation_param.h:66
Definition: cs_equation_param.h:65
cs_param_time_t time_info
Definition: cs_equation_param.h:126
Definition: cs_equation_param.h:67
Definition: cs_param.h:305
Definition: cs_equation_param.h:77
Definition: cs_param.h:143
Definition: cs_equation_param.h:79
cs_equation_algo_type_t
Definition: cs_equation_param.h:73
cs_property_t * time_property
Definition: cs_equation_param.h:128
Definition: cs_param.h:349