Code_Saturne
CFD tool
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
ecs_def.h
Go to the documentation of this file.
1 #ifndef _ECS_DEF_H_
2 #define _ECS_DEF_H_
3 
4 /*============================================================================
5  * Definitions, global variables, and base functions
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2012 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 #include "cs_config.h"
31 
32 /*
33  * Standard C library headers
34  */
35 
36 /*============================================================================
37  * Definition of C99 type which may not be available with older tools.
38  *============================================================================*/
39 
40 #if HAVE_STDDEF_H
41 # include <stddef.h>
42 #else
43 # include <stdio.h>
44 #endif
45 
46 /*
47  * Usually, stdint.h is included by inttypes.h, but only inttypes.h
48  * may be found on some systems, such as Tru64Unix.
49  */
50 
51 #if HAVE_STDINT_H
52 # include <stdint.h>
53 #elif HAVE_INTTYPES_H
54 # include <inttypes.h>
55 #endif
56 
57 /* _Bool */
58 
59 #if HAVE_STDBOOL_H
60 # include <stdbool.h>
61 #else
62 # ifndef HAVE__BOOL
63 # ifdef __cplusplus
64 typedef bool _Bool;
65 # else
66 # define _Bool signed char;
67 # endif
68 # endif
69 # define bool _Bool
70 # define false 0
71 # define true 1
72 # define __bool_true_false_are_defined 1
73 #endif
74 
75 /* int32_t type */
76 
77 #if !defined(HAVE_INT32_T)
78 # if (SIZEOF_INT == 4)
79 typedef int int32_t;
80 # elif (SIZEOF_SHORT == 4)
81 typedef short int32_t;
82 # else
83 # error
84 # endif
85 #endif
86 
87 /* int64_t type */
88 
89 #if !defined(HAVE_INT64_T)
90 # if (SIZEOF_INT == 8)
91 typedef int int64_t;
92 # elif (SIZEOF_LONG == 8)
93 typedef long int64_t;
94 # elif (HAVE_LONG_LONG == 8) /* SIZEOF_LONG_LONG not generally available */
95 typedef long long int64_t;
96 # else
97 # error
98 # endif
99 #endif
100 
101 /* uint32_t type */
102 
103 #if !defined(HAVE_UINT32_T)
104 # if (SIZEOF_INT == 4)
105 typedef unsigned uint32_t;
106 # elif (SIZEOF_SHORT == 4)
107 typedef unsigned short uint32_t;
108 # else
109 # error
110 # endif
111 #endif
112 
113 /* uint64_t type */
114 
115 #if !defined(HAVE_UINT64_T)
116 # if (SIZEOF_INT == 8)
117 typedef unsigned uint64_t;
118 # elif (SIZEOF_LONG == 8)
119 typedef unsigned long uint64_t;
120 # elif (HAVE_LONG_LONG) /* SIZEOF_LONG_LONG not generally available */
121 typedef unsigned long long uint64_t;
122 # else
123 # error
124 # endif
125 #endif
126 
127 /*-----------------------------------------------------------------------------
128  * Local type definitions
129  *----------------------------------------------------------------------------*/
130 
131 typedef int ecs_int_t; /* Integer */
132 typedef size_t ecs_size_t; /* Index size */
133 typedef double ecs_coord_t; /* Real (floating point) */
134 typedef char ecs_byte_t; /* Byte (untyped memory) */
135 
136 /* Type enumeration */
137 
138 typedef enum {
145 } ecs_type_t;
146 
147 /* Element types */
148 
149 typedef enum {
150 
151  ECS_ELT_TYP_NUL, /* No type */
152 
153  ECS_ELT_TYP_FAC_TRIA, /* Triangle */
154  ECS_ELT_TYP_FAC_QUAD, /* Quadrangle */
155 
156  ECS_ELT_TYP_CEL_TETRA, /* Tetrahedron */
157  ECS_ELT_TYP_CEL_PYRAM, /* Pyramid */
159  ECS_ELT_TYP_CEL_HEXA, /* Hexahedron */
160 
161  ECS_ELT_TYP_FAC_POLY, /* Polygon */
162  ECS_ELT_TYP_CEL_POLY, /* Polyhedron */
163 
165 
166 } ecs_elt_typ_t ;
167 
168 /* Restrict qualifier (standard in C99) */
169 
170 #if defined(__GNUC__)
171 #define restrict __restrict
172 #else
173 #define restrict
174 #endif
175 
176 /*=============================================================================
177  * Macro definitions
178  *============================================================================*/
179 
180 /* Classical macros */
181 
182 #define ECS_ABS(a) ((a) < 0 ? -(a) : (a)) /* Absolute value */
183 #define ECS_MIN(a, b) ((a) > (b) ? (b) : (a)) /* Minimum */
184 #define ECS_MAX(a, b) ((a) < (b) ? (b) : (a)) /* Maximum */
185 
186 /* Directory separator character */
187 
188 #define ECS_PATH_SEP '/'
189 
190 #define ECS_REAL_PRECISION 1.e-13
191 
192 #define ECS_STR_SIZE 80
193 
194 #define ECS_PAS_NUL 0
195 #define ECS_PAS_UNITE 1
196 
197 #define ECS_LNG_AFF_STR 43
198 #define ECS_LNG_AFF_ENT 8
199 #define ECS_LNG_AFF_REE_MANTIS 11
200 #define ECS_LNG_AFF_REE_PRECIS 2
201 
202 #define ECS_FMT_AFF_REE_PARAM "%.15E"
203 
204 /*
205  * Internationalization macros.
206  */
207 
208 #if defined(ENABLE_NLS)
209 
210 #include <libintl.h>
211 #define _(String) gettext(String)
212 #define gettext_noop(String) String
213 #define N_(String) gettext_noop(String)
214 
215 #else
216 
217 #define _(String) String
218 #define N_(String) String
219 #define textdomain(Domain)
220 #define bindtextdomain(Package, Directory)
221 
222 #endif
223 
224 /* Macros for compilation with a C++ compiler */
225 /*--------------------------------------------*/
226 
227 #undef BEGIN_C_DECLS
228 #undef END_C_DECLS
229 
230 #if defined(__cplusplus)
231 # define BEGIN_C_DECLS extern "C" {
232 # define END_C_DECLS }
233 #else
234 # define BEGIN_C_DECLS
235 # define END_C_DECLS
236 #endif
237 
238 /*=============================================================================
239  * Global variable definitions
240  *============================================================================*/
241 
242 extern char ecs_glob_build_date[];
243 
244 extern int ecs_glob_have_cgns; /* CGNS library support*/
245 extern int ecs_glob_cgns_ver_maj;
246 extern int ecs_glob_cgns_ver_min;
247 extern int ecs_glob_cgns_ver_rel;
248 
249 extern int ecs_glob_have_med; /* MED library support */
250 
251 /* Element type determination based on an element's number of vertices,
252  for elements of dimension 2 (faces) or 3 (cells);
253  Beyond 8 vertices, we always have ECS_ELT_TYP_FAC_POLY for faces
254  and ECS_ELT_TYP_FAC_POLY for cells */
255 
256 extern const ecs_elt_typ_t ecs_glob_typ_elt[2][9];
257 
258 /*=============================================================================
259  * Public function prototypes
260  *============================================================================*/
261 
262 /*----------------------------------------------------------------------------
263  * Initialize error handling
264  *----------------------------------------------------------------------------*/
265 
266 void
268 
269 /*----------------------------------------------------------------------------
270  * Exit function.
271  *----------------------------------------------------------------------------*/
272 
273 void
274 ecs_exit(int statut);
275 
276 /*----------------------------------------------------------------------------
277  * Print a warning.
278  *----------------------------------------------------------------------------*/
279 
280 void
281 ecs_warn(void);
282 
283 /*----------------------------------------------------------------------------
284  * Abort on error.
285  *----------------------------------------------------------------------------*/
286 
287 void
288 ecs_error(const char *file_name,
289  const int line_num,
290  const int sys_error_code,
291  const char *format,
292  ...);
293 
294 /*----------------------------------------------------------------------------
295  * Print a string with a given column width.
296  *----------------------------------------------------------------------------*/
297 
298 void
299 ecs_print_padded_str(const char *str,
300  int width);
301 
302 /*----------------------------------------------------------------------------*/
303 
304 #endif /* _ECS_DEF_H_ */
Definition: ecs_def.h:159
int ecs_int_t
Definition: ecs_def.h:131
double ecs_coord_t
Definition: ecs_def.h:133
Definition: ecs_def.h:142
char ecs_byte_t
Definition: ecs_def.h:134
Definition: ecs_def.h:144
int ecs_glob_have_cgns
Definition: ecs_def.h:141
Definition: ecs_def.h:139
int ecs_glob_cgns_ver_rel
Definition: ecs_def.h:156
Definition: ecs_def.h:151
Definition: ecs_def.h:164
void ecs_exit(int statut)
Definition: ecs_def.c:258
const ecs_elt_typ_t ecs_glob_typ_elt[2][9]
Definition: ecs_def.c:82
int ecs_glob_have_med
int ecs_glob_cgns_ver_maj
size_t ecs_size_t
Definition: ecs_def.h:132
Definition: ecs_def.h:140
int ecs_glob_cgns_ver_min
Definition: ecs_def.h:157
Definition: ecs_def.h:143
void ecs_warn(void)
Definition: ecs_def.c:278
ecs_elt_typ_t
Definition: ecs_def.h:149
Definition: ecs_def.h:158
Definition: ecs_def.h:153
void ecs_print_padded_str(const char *str, int width)
Definition: ecs_def.c:328
Definition: ecs_def.h:154
char ecs_glob_build_date[]
Definition: ecs_def.c:59
ecs_type_t
Definition: ecs_def.h:138
Definition: ecs_def.h:161
Definition: ecs_def.h:162
void ecs_error(const char *file_name, const int line_num, const int sys_error_code, const char *format,...)
Definition: ecs_def.c:290
void ecs_init_gestion_erreur(void)
Definition: ecs_def.c:235