File: ecs_def.h

package info (click to toggle)
code-saturne 5.3.2%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 76,868 kB
  • sloc: ansic: 338,582; f90: 118,487; python: 65,227; makefile: 4,429; cpp: 3,826; xml: 3,078; sh: 1,205; lex: 170; yacc: 100
file content (317 lines) | stat: -rw-r--r-- 8,341 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
#ifndef _ECS_DEF_H_
#define _ECS_DEF_H_

/*============================================================================
 * Definitions, global variables, and base functions
 *============================================================================*/

/*
  This file is part of Code_Saturne, a general-purpose CFD tool.

  Copyright (C) 1998-2018 EDF S.A.

  This program is free software; you can redistribute it and/or modify it under
  the terms of the GNU General Public License as published by the Free Software
  Foundation; either version 2 of the License, or (at your option) any later
  version.

  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  details.

  You should have received a copy of the GNU General Public License along with
  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
  Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

/*----------------------------------------------------------------------------*/

#include "cs_config.h"

/*
 * Standard C library headers
 */

/*============================================================================
 * Definition of C99 type which may not be available with older tools.
 *============================================================================*/

#if HAVE_STDDEF_H
# include <stddef.h>
#else
# include <stdio.h>
#endif

/*
 * Usually, stdint.h is included by inttypes.h, but only inttypes.h
 * may be found on some systems, such as Tru64Unix.
 */

#if HAVE_STDINT_H
# include <stdint.h>
#elif HAVE_INTTYPES_H
# include <inttypes.h>
#endif

/* _Bool */

#if HAVE_STDBOOL_H
#  include <stdbool.h>
#else
#  ifndef HAVE__BOOL
#    ifdef __cplusplus
typedef bool _Bool;
#    else
#      define _Bool signed char;
#    endif
#  endif
#  define bool _Bool
#  define false 0
#  define true 1
#  define __bool_true_false_are_defined 1
#endif

/* int32_t type */

#if !defined(HAVE_INT32_T)
#  if (SIZEOF_INT == 4)
typedef int int32_t;
#  elif (SIZEOF_SHORT == 4)
typedef short int32_t;
#  else
#    error
#  endif
#endif

/* int64_t type */

#if !defined(HAVE_INT64_T)
#  if (SIZEOF_INT == 8)
typedef int int64_t;
#  elif (SIZEOF_LONG == 8)
typedef long int64_t;
#  elif (HAVE_LONG_LONG == 8)  /* SIZEOF_LONG_LONG not generally available */
typedef long long int64_t;
#  else
#    error
#  endif
#endif

/* uint32_t type */

#if !defined(HAVE_UINT32_T)
#  if (SIZEOF_INT == 4)
typedef unsigned uint32_t;
#  elif (SIZEOF_SHORT == 4)
typedef unsigned short uint32_t;
#  else
#    error
#  endif
#endif

/* uint64_t type */

#if !defined(HAVE_UINT64_T)
#  if (SIZEOF_INT == 8)
typedef unsigned uint64_t;
#  elif (SIZEOF_LONG == 8)
typedef unsigned long uint64_t;
#  elif (HAVE_LONG_LONG) /* SIZEOF_LONG_LONG not generally available */
typedef unsigned long long uint64_t;
#  else
#    error
#  endif
#endif

/*-----------------------------------------------------------------------------
 * Local type definitions
 *----------------------------------------------------------------------------*/

#if defined(HAVE_LONG_GNUM)
  #if (SIZEOF_LONG == 8)
    typedef long                ecs_int_t;   /* Integer */
    typedef unsigned long       ecs_size_t;  /* Index size */
  #elif (SIZEOF_LONG_LONG == 8)
    typedef long long           ecs_int_t;   /* Integer */
    typedef unsigned long long  ecs_size_t;  /* Index size */
  #else
    #error
  #endif
#else
  typedef int           ecs_int_t;      /* Integer */
  typedef size_t        ecs_size_t;     /* Index size */
#endif

typedef double          ecs_coord_t;    /* Real (floating point) */
typedef char            ecs_byte_t;     /* Byte (untyped memory) */

/* Type enumeration */

typedef enum {
  ECS_TYPE_char,
  ECS_TYPE_ecs_coord_t,
  ECS_TYPE_ecs_int_t,
  ECS_TYPE_ecs_size_t,
  ECS_TYPE_size_t,
  ECS_TYPE_void
} ecs_type_t;

/* Element types */

typedef enum {

  ECS_ELT_TYP_NUL,         /*  No type */

  ECS_ELT_TYP_FAC_TRIA,    /*  Triangle */
  ECS_ELT_TYP_FAC_QUAD,    /*  Quadrangle */

  ECS_ELT_TYP_CEL_TETRA,   /*  Tetrahedron */
  ECS_ELT_TYP_CEL_PYRAM,   /*  Pyramid */
  ECS_ELT_TYP_CEL_PRISM,   /*  Prism */
  ECS_ELT_TYP_CEL_HEXA,    /*  Hexahedron */

  ECS_ELT_TYP_FAC_POLY,    /*  Polygon */
  ECS_ELT_TYP_CEL_POLY,    /*  Polyhedron */

  ECS_ELT_TYP_FIN

} ecs_elt_typ_t ;

/* Restrict qualifier (standard in C99) */

#if defined(__GNUC__)
#define restrict __restrict
#else
#define restrict
#endif

/*=============================================================================
 * Macro definitions
 *============================================================================*/

/* Classical macros */

#define ECS_ABS(a)     ((a) <  0  ? -(a) : (a))  /* Absolute value */
#define ECS_MIN(a, b)  ((a) > (b) ?  (b) : (a))  /* Minimum */
#define ECS_MAX(a, b)  ((a) < (b) ?  (b) : (a))  /* Maximum */

/* Directory separator character */

#define ECS_PATH_SEP             '/'

#define ECS_REAL_PRECISION    1.e-13

#define ECS_STR_SIZE       80

#define ECS_PAS_NUL         0
#define ECS_PAS_UNITE       1

#define ECS_LNG_AFF_STR           43
#define ECS_LNG_AFF_ENT            8
#define ECS_LNG_AFF_REE_MANTIS    11
#define ECS_LNG_AFF_REE_PRECIS     2

#define ECS_FMT_AFF_REE_PARAM     "%.15E"

/*
 * Internationalization macros.
 */

#if defined(ENABLE_NLS)

#include <libintl.h>
#define _(String) gettext(String)
#define gettext_noop(String) String
#define N_(String) gettext_noop(String)

#else

#define _(String) String
#define N_(String) String
#define textdomain(Domain)
#define bindtextdomain(Package, Directory)

#endif

/* Macros for compilation with a C++ compiler */
/*--------------------------------------------*/

#undef BEGIN_C_DECLS
#undef   END_C_DECLS

#if defined(__cplusplus)
#  define BEGIN_C_DECLS  extern "C" {
#  define   END_C_DECLS  }
#else
#  define BEGIN_C_DECLS
#  define   END_C_DECLS
#endif

/*=============================================================================
 * Global variable definitions
 *============================================================================*/

extern char      ecs_glob_build_date[];

extern int       ecs_glob_have_cgns;    /* CGNS library support*/
extern int       ecs_glob_cgns_ver_maj;
extern int       ecs_glob_cgns_ver_min;
extern int       ecs_glob_cgns_ver_rel;

extern int       ecs_glob_have_med;     /* MED library support */

/* Element type determination based on an element's number of vertices,
   for elements of dimension 2 (faces) or 3 (cells);
   Beyond 8 vertices, we always have ECS_ELT_TYP_FAC_POLY for faces
   and ECS_ELT_TYP_FAC_POLY for cells */

extern  const ecs_elt_typ_t  ecs_glob_typ_elt[2][9];

/*=============================================================================
 * Public function prototypes
 *============================================================================*/

/*----------------------------------------------------------------------------
 * Initialize error handling
 *----------------------------------------------------------------------------*/

void
ecs_init_gestion_erreur(void);

/*----------------------------------------------------------------------------
 * Exit function.
 *----------------------------------------------------------------------------*/

void
ecs_exit(int  statut);

/*----------------------------------------------------------------------------
 * Print a warning.
 *----------------------------------------------------------------------------*/

void
ecs_warn(void);

/*----------------------------------------------------------------------------
 * Abort on error.
 *----------------------------------------------------------------------------*/

void
ecs_error(const char  *file_name,
          const int    line_num,
          const int    sys_error_code,
          const char  *format,
          ...);

/*----------------------------------------------------------------------------
 * Print a string with a given column width.
 *----------------------------------------------------------------------------*/

void
ecs_print_padded_str(const char  *str,
                     int          width);

/*----------------------------------------------------------------------------*/

#endif /* _ECS_DEF_H_ */