t8  UNKNOWN
t8code is a C library to manage a forest of adaptive space-trees of general element classes in parallel.
t8.h
Go to the documentation of this file.
1 /*
2  This file is part of t8code.
3  t8code is a C library to manage a collection (a forest) of multiple
4  connected adaptive space-trees of general element classes in parallel.
5 
6  Copyright (C) 2015 the developers
7 
8  t8code is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  t8code is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with t8code; if not, write to the Free Software Foundation, Inc.,
20  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22 
29 #ifndef T8_H
30 #define T8_H
31 
32 /* include config headers */
33 #include <t8_config.h>
34 #include <sc_config.h>
35 #if (defined(T8_ENABLE_MPI) && !defined(SC_ENABLE_MPI)) || (!defined(T8_ENABLE_MPI) && defined(SC_ENABLE_MPI))
36 #error "MPI configured differently in t8code and libsc"
37 #endif
38 #if (defined(T8_ENABLE_MPIIO) && !defined(SC_ENABLE_MPIIO)) || (!defined(T8_ENABLE_MPIIO) && defined(SC_ENABLE_MPIIO))
39 #error "MPI I/O configured differently in t8code and libsc"
40 #endif
41 
42 /* indirectly also include sc.h */
43 #include <sc_containers.h>
44 
47 #define T8_EXTERN_C_BEGIN() SC_EXTERN_C_BEGIN
48 
51 #define T8_EXTERN_C_END() SC_EXTERN_C_END
52 
53 /* call this after including all headers */
54 T8_EXTERN_C_BEGIN ();
55 
57 #define t8_const _sc_const
58 
60 #define t8_restrict _sc_restrict
61 
63 /* Note that we use the same definition as in sc.h. We are deliberately not using
64  * #define T8_ASSERT SC_ASSERT
65  * since then the assertion would not trigger if sc is not configured in debugging mode.
66  * However, we want it to trigger any time t8code is in debugging mode, independent of sc.
67  */
68 #ifdef T8_ENABLE_DEBUG
69 #define T8_ASSERT(c) SC_CHECK_ABORT ((c), "Assertion '" #c "'")
70 #else
71 #define T8_ASSERT(c) SC_NOOP ()
72 #endif
73 
75 #define T8_ALLOC(t, n) (t *) sc_malloc (t8_get_package_id (), (n) * sizeof (t))
76 
78 #define T8_ALLOC_ZERO(t, n) (t *) sc_calloc (t8_get_package_id (), (size_t) (n), sizeof (t))
79 
81 #define T8_FREE(p) sc_free (t8_get_package_id (), (p))
82 
84 #define T8_REALLOC(p, t, n) (t *) sc_realloc (t8_get_package_id (), (p), (n) * sizeof (t))
85 
87 typedef int32_t t8_locidx_t;
89 #define T8_MPI_LOCIDX sc_MPI_INT
91 #define T8_LOCIDX_ABS(x) ((t8_locidx_t) labs ((long) (x)))
93 #define T8_LOCIDX_MAX INT32_MAX
95 #define t8_compare_locidx(v, w) sc_int32_compare (v, w)
96 
98 typedef int64_t t8_gloidx_t;
100 #define T8_MPI_GLOIDX sc_MPI_LONG_LONG_INT
102 #define T8_GLOIDX_ABS(x) ((t8_gloidx_t) llabs ((long long) (x)))
104 #define t8_compare_gloidx(v, w) sc_int64_compare (v, w)
105 
107 typedef uint64_t t8_linearidx_t;
109 #define T8_MPI_LINEARIDX sc_MPI_UNSIGNED_LONG_LONG
110 
111 #define T8_PADDING_SIZE (sizeof (void *))
114 #define T8_ADD_PADDING(_x) ((T8_PADDING_SIZE - ((_x) % T8_PADDING_SIZE)) % T8_PADDING_SIZE)
115 
117 #define T8_PRECISION_EPS SC_EPS
118 
120 #define T8_1D_TO_1D(nx, i) (i)
121 #define T8_2D_TO_1D(nx, ny, i, j) ((i) * (ny) + (j))
122 #define T8_3D_TO_1D(nx, ny, nz, i, j, k) (((i) * (ny) + (j)) * (nz) + (k))
123 #define T8_4D_TO_1D(nx, ny, nz, nl, i, j, k, l) ((((i) * (ny) + (j)) * (nz) + (k)) * (nl) + (l))
124 
126 typedef enum {
127  T8_MPI_TAG_FIRST = SC_TAG_FIRST,
128  T8_MPI_PARTITION_CMESH = SC_TAG_LAST,
132  T8_MPI_TAG_LAST
133 } t8_MPI_tag_t;
134 
139 int
140 t8_get_package_id (void);
141 
149 void
150 t8_logv (int category, int priority, const char *fmt, va_list ap);
151 
158 void
159 t8_logf (int category, int priority, const char *fmt, ...)
160 #ifndef T8_DOXYGEN
161  __attribute__ ((format (printf, 3, 4)))
162 #endif
163  ;
164 
166 void
167 t8_log_indent_push (void);
168 
170 void
171 t8_log_indent_pop (void);
172 
176 void
177 t8_global_errorf (const char *fmt, ...)
178 #ifndef T8_DOXYGEN
179  __attribute__ ((format (printf, 1, 2)))
180 #endif
181  ;
182 
186 void
187 t8_global_essentialf (const char *fmt, ...)
188 #ifndef T8_DOXYGEN
189  __attribute__ ((format (printf, 1, 2)))
190 #endif
191  ;
192 
196 void
197 t8_global_productionf (const char *fmt, ...)
198 #ifndef T8_DOXYGEN
199  __attribute__ ((format (printf, 1, 2)))
200 #endif
201  ;
202 
206 void
207 t8_global_infof (const char *fmt, ...)
208 #ifndef T8_DOXYGEN
209  __attribute__ ((format (printf, 1, 2)))
210 #endif
211  ;
212 
216 void
217 t8_infof (const char *fmt, ...)
218 #ifndef T8_DOXYGEN
219  __attribute__ ((format (printf, 1, 2)))
220 #endif
221  ;
222 
226 void
227 t8_productionf (const char *fmt, ...)
228 #ifndef T8_DOXYGEN
229  __attribute__ ((format (printf, 1, 2)))
230 #endif
231  ;
232 
238 void
239 t8_debugf (const char *fmt, ...)
240 #ifndef T8_DOXYGEN
241  __attribute__ ((format (printf, 1, 2)))
242 #endif
243  ;
244 
248 void
249 t8_errorf (const char *fmt, ...)
250 #ifndef T8_DOXYGEN
251  __attribute__ ((format (printf, 1, 2)))
252 #endif
253  ;
254 
259 void
260 t8_init (int log_threshold);
261 
266 void *
267 t8_sc_array_index_locidx (const sc_array_t *array, const t8_locidx_t it);
268 
269 /* call this at the end of a header file to match T8_EXTERN_C_BEGIN (). */
270 T8_EXTERN_C_END ();
271 
272 #endif /* !T8_H */
int64_t t8_gloidx_t
A type for global indexing that holds really big numbers.
Definition: t8.h:98
void t8_errorf(const char *fmt,...)
Log a message, no matter what rank, with priority SC_LP_ERROR.
Definition: t8.c:135
void t8_infof(const char *fmt,...)
Log a message, no matter what rank, with priority SC_LP_INFO.
Definition: t8.c:103
void t8_global_productionf(const char *fmt,...)
Log a message on the root rank with priority SC_LP_PRODUCTION.
Definition: t8.c:83
void t8_global_errorf(const char *fmt,...)
Log a message on the root rank with priority SC_LP_ERROR.
Definition: t8.c:63
void t8_logf(int category, int priority, const char *fmt,...)
Logging function parametrized by local/global category and priority.
Definition: t8.c:41
void t8_global_essentialf(const char *fmt,...)
Log a message on the root rank with priority SC_LP_ESSENTIAL.
Definition: t8.c:73
void t8_global_infof(const char *fmt,...)
Log a message on the root rank with priority SC_LP_INFO.
Definition: t8.c:93
int t8_get_package_id(void)
Query the package identity as registered in libsc.
Definition: t8.c:29
void t8_debugf(const char *fmt,...)
Log a message, no matter what rank, with priority SC_LP_DEBUG.
Definition: t8.c:123
void t8_log_indent_push(void)
Add one space to the start of t8's default log format.
Definition: t8.c:51
t8_MPI_tag_t
Communication tags used internal to t8code.
Definition: t8.h:126
@ T8_MPI_PARTITION_CMESH
Used for coarse mesh partitioning.
Definition: t8.h:128
@ T8_MPI_GHOST_FOREST
Used for for ghost layer creation.
Definition: t8.h:130
@ T8_MPI_PARTITION_FOREST
Used for forest partitioning.
Definition: t8.h:129
@ T8_MPI_GHOST_EXC_FOREST
Used for ghost data exchange.
Definition: t8.h:131
void t8_init(int log_threshold)
Register t8code with libsc and print version and variable information.
Definition: t8.c:145
void t8_log_indent_pop(void)
Remove one space from the start of a t8's default log format.
Definition: t8.c:57
void * t8_sc_array_index_locidx(const sc_array_t *array, const t8_locidx_t it)
Return a pointer to an array element indexed by a t8_locidx_t.
Definition: t8.c:162
uint64_t t8_linearidx_t
A type for storing SFC indices.
Definition: t8.h:107
int32_t t8_locidx_t
A type for processor-local indexing.
Definition: t8.h:87
void t8_logv(int category, int priority, const char *fmt, va_list ap)
Logging function parametrized by local/global category and priority.
Definition: t8.c:35
void t8_productionf(const char *fmt,...)
Log a message, no matter what rank, with priority SC_LP_PRODUCTION.
Definition: t8.c:113