p4est 2.8.5.190-3fcf-dirty
p4est is a software library for parallel adaptive mesh refinement.
p4est_base.h
Go to the documentation of this file.
1/*
2 This file is part of p4est.
3 p4est is a C library to manage a collection (a forest) of multiple
4 connected adaptive quadtrees or octrees in parallel.
5
6 Copyright (C) 2010 The University of Texas System
7 Additional copyright (C) 2011 individual authors
8 Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac
9
10 p4est is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 p4est is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with p4est; if not, write to the Free Software Foundation, Inc.,
22 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23*/
24
30#ifndef P4EST_BASE_H
31#define P4EST_BASE_H
32
33/* include config headers */
34#include <p4est_config.h>
35#include <sc_config.h>
36#if \
37 (defined (P4EST_ENABLE_MPI) && !defined (SC_ENABLE_MPI)) || \
38 (!defined (P4EST_ENABLE_MPI) && defined (SC_ENABLE_MPI))
39#error "MPI configured differently in p4est and libsc"
40#endif
41#if \
42 (defined (P4EST_ENABLE_MPIIO) && !defined (SC_ENABLE_MPIIO)) || \
43 (!defined (P4EST_ENABLE_MPIIO) && defined (SC_ENABLE_MPIIO))
44#error "MPI I/O configured differently in p4est and libsc"
45#endif
46
47/* indirectly also include sc.h */
48#include <sc_containers.h>
49#define _p4est_const _sc_const
50
51/*--------------------------------------------------------------------*/
52/*------------------------ QUERY API CHANGES -------------------------*/
53/*---- definitions to allow user code to query the p4est library -----*/
54
56#define P4EST_COMM_TRANSFER_NULL
57
60#define P4EST_CONN_DISK_PERIODIC
61
63#define P4EST_CONN_REORDER_NEWID
64
71#define P4EST_SEARCH_LOCAL
72
74#define P4EST_VTK_CELL_DATAV
75
76/*--------------------------------------------------------------------*/
77
78SC_EXTERN_C_BEGIN;
79
81typedef int32_t p4est_qcoord_t;
82#define p4est_qcoord_compare sc_int32_compare
83#define P4EST_QCOORD_BITS 32
84#define P4EST_MPI_QCOORD sc_MPI_INT
85#define P4EST_VTK_QCOORD "Int32"
86#define P4EST_F90_QCOORD INTEGER(KIND=C_INT32_T)
87#define P4EST_QCOORD_MIN INT32_MIN
88#define P4EST_QCOORD_MAX INT32_MAX
89#define P4EST_QCOORD_1 ((p4est_qcoord_t) 1)
90#define P4EST_QCOORD_ABS(x) ((p4est_qcoord_t) labs ((long) (x)))
91
93typedef int32_t p4est_topidx_t;
94#define p4est_topidx_compare sc_int32_compare
95#define P4EST_TOPIDX_BITS 32
96#define P4EST_MPI_TOPIDX sc_MPI_INT
97#define P4EST_VTK_TOPIDX "Int32"
98#define P4EST_F90_TOPIDX INTEGER(KIND=C_INT32_T)
99#define P4EST_TOPIDX_MIN INT32_MIN
100#define P4EST_TOPIDX_MAX INT32_MAX
101#define P4EST_TOPIDX_FITS_32 1
102#define P4EST_TOPIDX_1 ((p4est_topidx_t) 1)
103#define P4EST_TOPIDX_ABS(x) ((p4est_topidx_t) labs ((long) (x)))
104
106typedef int32_t p4est_locidx_t;
107#define p4est_locidx_compare sc_int32_compare
108#define P4EST_LOCIDX_BITS 32
109#define P4EST_MPI_LOCIDX sc_MPI_INT
110#define P4EST_VTK_LOCIDX "Int32"
111#define P4EST_F90_LOCIDX INTEGER(KIND=C_INT32_T)
112#define P4EST_LOCIDX_MIN INT32_MIN
113#define P4EST_LOCIDX_MAX INT32_MAX
114#define P4EST_LOCIDX_1 ((p4est_locidx_t) 1)
115#define P4EST_LOCIDX_ABS(x) ((p4est_locidx_t) labs ((long) (x)))
116
118typedef int64_t p4est_gloidx_t;
119#define p4est_gloidx_compare sc_int64_compare
120#define P4EST_GLOIDX_BITS 64
121#define P4EST_MPI_GLOIDX sc_MPI_LONG_LONG_INT
122#define P4EST_VTK_GLOIDX "Int64"
123#define P4EST_F90_GLOIDX INTEGER(KIND=C_INT64_T)
124#define P4EST_GLOIDX_MIN INT64_MIN
125#define P4EST_GLOIDX_MAX INT64_MAX
126#define P4EST_GLOIDX_1 ((p4est_gloidx_t) 1)
127#define P4EST_GLOIDX_ABS(x) ((p4est_gloidx_t) llabs ((long long) (x)))
128
130typedef enum p4est_comm_tag
131{
132 P4EST_COMM_TAG_FIRST = SC_TAG_FIRST,
133 P4EST_COMM_COUNT_PERTREE = SC_TAG_LAST,
134 P4EST_COMM_BALANCE_FIRST_COUNT,
135 P4EST_COMM_BALANCE_FIRST_LOAD,
136 P4EST_COMM_BALANCE_SECOND_COUNT,
137 P4EST_COMM_BALANCE_SECOND_LOAD,
138 P4EST_COMM_PARTITION_GIVEN,
139 P4EST_COMM_PARTITION_WEIGHTED_LOW,
140 P4EST_COMM_PARTITION_WEIGHTED_HIGH,
141 P4EST_COMM_PARTITION_CORRECTION,
142 P4EST_COMM_GHOST_COUNT,
143 P4EST_COMM_GHOST_LOAD,
144 P4EST_COMM_GHOST_EXCHANGE,
145 P4EST_COMM_GHOST_EXPAND_COUNT,
146 P4EST_COMM_GHOST_EXPAND_LOAD,
147 P4EST_COMM_GHOST_SUPPORT_COUNT,
148 P4EST_COMM_GHOST_SUPPORT_LOAD,
149 P4EST_COMM_GHOST_CHECKSUM,
150 P4EST_COMM_NODES_QUERY,
151 P4EST_COMM_NODES_REPLY,
152 P4EST_COMM_SAVE,
153 P4EST_COMM_LNODES_TEST,
154 P4EST_COMM_LNODES_PASS,
155 P4EST_COMM_LNODES_OWNED,
156 P4EST_COMM_LNODES_ALL,
157 P4EST_COMM_TAG_LAST
158}
160
161/* some error checking possibly specific to p4est */
162#ifdef P4EST_ENABLE_DEBUG
163#define P4EST_ASSERT(c) SC_CHECK_ABORT ((c), "Assertion '" #c "'")
164#define P4EST_EXECUTE_ASSERT_FALSE(expression) \
165 do { int _p4est_i = (int) (expression); \
166 SC_CHECK_ABORT (!_p4est_i, "Expected false: '" #expression "'"); \
167 } while (0)
168#define P4EST_EXECUTE_ASSERT_TRUE(expression) \
169 do { int _p4est_i = (int) (expression); \
170 SC_CHECK_ABORT (_p4est_i, "Expected true: '" #expression "'"); \
171 } while (0)
172#define P4EST_EXECUTE_ASSERT_INT(expression,ival) \
173 do { int _p4est_i = (int) (expression); \
174 SC_CHECK_ABORT ((ival) == _p4est_i, \
175 "Expected '" #ival "': '" #expression "'"); \
176 } while (0)
177#define P4EST_EXECUTE_ASSERT_TOPIDX(expression,tval) \
178 do { p4est_topidx_t _p4est_t = (p4est_topidx_t) (expression); \
179 SC_CHECK_ABORT ((tval) == _p4est_t, \
180 "Expected '" #tval "': '" #expression "'"); \
181 } while (0)
182#define P4EST_DEBUG_EXECUTE(expression) \
183 do { (void) (expression); } while (0)
184#else
185#define P4EST_ASSERT(c) SC_NOOP ()
186#define P4EST_EXECUTE_ASSERT_FALSE(expression) \
187 do { (void) (expression); } while (0)
188#define P4EST_EXECUTE_ASSERT_TRUE(expression) \
189 do { (void) (expression); } while (0)
190#define P4EST_EXECUTE_ASSERT_INT(expression,ival) \
191 do { (void) (expression); } while (0)
192#define P4EST_EXECUTE_ASSERT_TOPIDX(expression,tval) \
193 do { (void) (expression); } while (0)
194#define P4EST_DEBUG_EXECUTE(expression) SC_NOOP ()
195#endif
196
197/* macros for memory allocation, will abort if out of memory */
199#define P4EST_ALLOC(t,n) (t *) sc_malloc (p4est_package_id, \
200 (n) * sizeof(t))
202#define P4EST_ALLOC_ZERO(t,n) (t *) sc_calloc (p4est_package_id, \
203 (size_t) (n), sizeof(t))
205#define P4EST_REALLOC(p,t,n) (t *) sc_realloc (p4est_package_id, \
206 (p), (n) * sizeof(t))
208#define P4EST_STRDUP(s) sc_strdup (p4est_package_id, (s))
210#define P4EST_FREE(p) sc_free (p4est_package_id, (p))
211
212/* log helper macros */
213#define P4EST_GLOBAL_LOG(p,s) \
214 SC_GEN_LOG (p4est_package_id, SC_LC_GLOBAL, (p), (s))
215#define P4EST_LOG(p,s) \
216 SC_GEN_LOG (p4est_package_id, SC_LC_NORMAL, (p), (s))
217void P4EST_GLOBAL_LOGF (int priority, const char *fmt, ...)
218 __attribute__ ((format (printf, 2, 3)));
219void P4EST_LOGF (int priority, const char *fmt, ...)
220 __attribute__ ((format (printf, 2, 3)));
221#ifndef __cplusplus
222#define P4EST_GLOBAL_LOGF(p,f,...) \
223 SC_GEN_LOGF (p4est_package_id, SC_LC_GLOBAL, (p), (f), __VA_ARGS__)
224#define P4EST_LOGF(p,f,...) \
225 SC_GEN_LOGF (p4est_package_id, SC_LC_NORMAL, (p), (f), __VA_ARGS__)
226#endif
227
228/* convenience global log macros will only print if identifier <= 0 */
229#define P4EST_GLOBAL_TRACE(s) P4EST_GLOBAL_LOG (SC_LP_TRACE, (s))
230#define P4EST_GLOBAL_LDEBUG(s) P4EST_GLOBAL_LOG (SC_LP_DEBUG, (s))
231#define P4EST_GLOBAL_VERBOSE(s) P4EST_GLOBAL_LOG (SC_LP_VERBOSE, (s))
232#define P4EST_GLOBAL_INFO(s) P4EST_GLOBAL_LOG (SC_LP_INFO, (s))
233#define P4EST_GLOBAL_STATISTICS(s) P4EST_GLOBAL_LOG (SC_LP_STATISTICS, (s))
234#define P4EST_GLOBAL_PRODUCTION(s) P4EST_GLOBAL_LOG (SC_LP_PRODUCTION, (s))
235#define P4EST_GLOBAL_ESSENTIAL(s) P4EST_GLOBAL_LOG (SC_LP_ESSENTIAL, (s))
236#define P4EST_GLOBAL_LERROR(s) P4EST_GLOBAL_LOG (SC_LP_ERROR, (s))
237void P4EST_GLOBAL_TRACEF (const char *fmt, ...)
238 __attribute__ ((format (printf, 1, 2)));
239void P4EST_GLOBAL_LDEBUGF (const char *fmt, ...)
240 __attribute__ ((format (printf, 1, 2)));
241void P4EST_GLOBAL_VERBOSEF (const char *fmt, ...)
242 __attribute__ ((format (printf, 1, 2)));
243void P4EST_GLOBAL_INFOF (const char *fmt, ...)
244 __attribute__ ((format (printf, 1, 2)));
245void P4EST_GLOBAL_STATISTICSF (const char *fmt, ...)
246 __attribute__ ((format (printf, 1, 2)));
247void P4EST_GLOBAL_PRODUCTIONF (const char *fmt, ...)
248 __attribute__ ((format (printf, 1, 2)));
249void P4EST_GLOBAL_ESSENTIALF (const char *fmt, ...)
250 __attribute__ ((format (printf, 1, 2)));
251void P4EST_GLOBAL_LERRORF (const char *fmt, ...)
252 __attribute__ ((format (printf, 1, 2)));
253#ifndef __cplusplus
254#define P4EST_GLOBAL_TRACEF(f,...) \
255 P4EST_GLOBAL_LOGF (SC_LP_TRACE, (f), __VA_ARGS__)
256#define P4EST_GLOBAL_LDEBUGF(f,...) \
257 P4EST_GLOBAL_LOGF (SC_LP_DEBUG, (f), __VA_ARGS__)
258#define P4EST_GLOBAL_VERBOSEF(f,...) \
259 P4EST_GLOBAL_LOGF (SC_LP_VERBOSE, (f), __VA_ARGS__)
260#define P4EST_GLOBAL_INFOF(f,...) \
261 P4EST_GLOBAL_LOGF (SC_LP_INFO, (f), __VA_ARGS__)
262#define P4EST_GLOBAL_STATISTICSF(f,...) \
263 P4EST_GLOBAL_LOGF (SC_LP_STATISTICS, (f), __VA_ARGS__)
264#define P4EST_GLOBAL_PRODUCTIONF(f,...) \
265 P4EST_GLOBAL_LOGF (SC_LP_PRODUCTION, (f), __VA_ARGS__)
266#define P4EST_GLOBAL_ESSENTIALF(f,...) \
267 P4EST_GLOBAL_LOGF (SC_LP_ESSENTIAL, (f), __VA_ARGS__)
268#define P4EST_GLOBAL_LERRORF(f,...) \
269 P4EST_GLOBAL_LOGF (SC_LP_ERROR, (f), __VA_ARGS__)
270#endif
271#define P4EST_GLOBAL_NOTICE P4EST_GLOBAL_STATISTICS
272#define P4EST_GLOBAL_NOTICEF P4EST_GLOBAL_STATISTICSF
273
274/* convenience log macros that are active on every processor */
275#define P4EST_TRACE(s) P4EST_LOG (SC_LP_TRACE, (s))
276#define P4EST_LDEBUG(s) P4EST_LOG (SC_LP_DEBUG, (s))
277#define P4EST_VERBOSE(s) P4EST_LOG (SC_LP_VERBOSE, (s))
278#define P4EST_INFO(s) P4EST_LOG (SC_LP_INFO, (s))
279#define P4EST_STATISTICS(s) P4EST_LOG (SC_LP_STATISTICS, (s))
280#define P4EST_PRODUCTION(s) P4EST_LOG (SC_LP_PRODUCTION, (s))
281#define P4EST_ESSENTIAL(s) P4EST_LOG (SC_LP_ESSENTIAL, (s))
282#define P4EST_LERROR(s) P4EST_LOG (SC_LP_ERROR, (s))
283void P4EST_TRACEF (const char *fmt, ...)
284 __attribute__ ((format (printf, 1, 2)));
285void P4EST_LDEBUGF (const char *fmt, ...)
286 __attribute__ ((format (printf, 1, 2)));
287void P4EST_VERBOSEF (const char *fmt, ...)
288 __attribute__ ((format (printf, 1, 2)));
289void P4EST_INFOF (const char *fmt, ...)
290 __attribute__ ((format (printf, 1, 2)));
291void P4EST_STATISTICSF (const char *fmt, ...)
292 __attribute__ ((format (printf, 1, 2)));
293void P4EST_PRODUCTIONF (const char *fmt, ...)
294 __attribute__ ((format (printf, 1, 2)));
295void P4EST_ESSENTIALF (const char *fmt, ...)
296 __attribute__ ((format (printf, 1, 2)));
297void P4EST_LERRORF (const char *fmt, ...)
298 __attribute__ ((format (printf, 1, 2)));
299#ifndef __cplusplus
300#define P4EST_TRACEF(f,...) \
301 P4EST_LOGF (SC_LP_TRACE, (f), __VA_ARGS__)
302#define P4EST_LDEBUGF(f,...) \
303 P4EST_LOGF (SC_LP_DEBUG, (f), __VA_ARGS__)
304#define P4EST_VERBOSEF(f,...) \
305 P4EST_LOGF (SC_LP_VERBOSE, (f), __VA_ARGS__)
306#define P4EST_INFOF(f,...) \
307 P4EST_LOGF (SC_LP_INFO, (f), __VA_ARGS__)
308#define P4EST_STATISTICSF(f,...) \
309 P4EST_LOGF (SC_LP_STATISTICS, (f), __VA_ARGS__)
310#define P4EST_PRODUCTIONF(f,...) \
311 P4EST_LOGF (SC_LP_PRODUCTION, (f), __VA_ARGS__)
312#define P4EST_ESSENTIALF(f,...) \
313 P4EST_LOGF (SC_LP_ESSENTIAL, (f), __VA_ARGS__)
314#define P4EST_LERRORF(f,...) \
315 P4EST_LOGF (SC_LP_ERROR, (f), __VA_ARGS__)
316#endif
317#define P4EST_NOTICE P4EST_STATISTICS
318#define P4EST_NOTICEF P4EST_STATISTICSF
319
320/* extern declarations */
322extern int p4est_package_id;
323
324static inline void
325p4est_log_indent_push (void)
326{
327 sc_log_indent_push_count (p4est_package_id, 1);
328}
329
330static inline void
331p4est_log_indent_pop (void)
332{
333 sc_log_indent_pop_count (p4est_package_id, 1);
334}
335
345void p4est_init (sc_log_handler_t log_handler,
346 int log_threshold);
347
360
366
371/*@unused@*/
372static inline unsigned
373p4est_topidx_hash2 (const p4est_topidx_t * tt)
374{
375 uint32_t a, b, c;
376
377#if (P4EST_TOPIDX_FITS_32)
378 a = (uint32_t) tt[0];
379 b = (uint32_t) tt[1];
380 c = 0;
381#else
382 a = (uint32_t) (tt[0] && 0xFFFFFFFF);
383 b = (uint32_t) (tt[0] >> 32);
384 c = (uint32_t) (tt[1] && 0xFFFFFFFF);
385 sc_hash_mix (a, b, c);
386 a += (uint32_t) (tt[1] >> 32);
387#endif
388 sc_hash_final (a, b, c);
389
390 return (unsigned) c;
391}
392
397/*@unused@*/
398static inline unsigned
399p4est_topidx_hash3 (const p4est_topidx_t * tt)
400{
401 uint32_t a, b, c;
402
403#if (P4EST_TOPIDX_FITS_32)
404 a = (uint32_t) tt[0];
405 b = (uint32_t) tt[1];
406 c = (uint32_t) tt[2];
407#else
408 a = (uint32_t) (tt[0] && 0xFFFFFFFF);
409 b = (uint32_t) (tt[0] >> 32);
410 c = (uint32_t) (tt[1] && 0xFFFFFFFF);
411 sc_hash_mix (a, b, c);
412 a += (uint32_t) (tt[1] >> 32);
413 b += (uint32_t) (tt[2] && 0xFFFFFFFF);
414 c += (uint32_t) (tt[2] >> 32);
415#endif
416 sc_hash_final (a, b, c);
417
418 return (unsigned) c;
419}
420
425/*@unused@*/
426static inline unsigned
427p4est_topidx_hash4 (const p4est_topidx_t * tt)
428{
429 uint32_t a, b, c;
430
431#if (P4EST_TOPIDX_FITS_32)
432 a = (uint32_t) tt[0];
433 b = (uint32_t) tt[1];
434 c = (uint32_t) tt[2];
435 sc_hash_mix (a, b, c);
436 a += (uint32_t) tt[3];
437#else
438 a = (uint32_t) (tt[0] && 0xFFFFFFFF);
439 b = (uint32_t) (tt[0] >> 32);
440 c = (uint32_t) (tt[1] && 0xFFFFFFFF);
441 sc_hash_mix (a, b, c);
442 a += (uint32_t) (tt[1] >> 32);
443 b += (uint32_t) (tt[2] && 0xFFFFFFFF);
444 c += (uint32_t) (tt[2] >> 32);
445 sc_hash_mix (a, b, c);
446 a += (uint32_t) (tt[3] && 0xFFFFFFFF);
447 b += (uint32_t) (tt[3] >> 32);
448#endif
449 sc_hash_final (a, b, c);
450
451 return (unsigned) c;
452}
453
454/*@unused@*/
455static inline int
456p4est_topidx_is_sorted (p4est_topidx_t * t, int length)
457{
458 int i;
459
460 for (i = 1; i < length; ++i) {
461 if (t[i - 1] > t[i]) {
462 return 0;
463 }
464 }
465 return 1;
466}
467
468/*@unused@*/
469static inline void
470p4est_topidx_bsort (p4est_topidx_t * t, int length)
471{
472 int i, j;
473 p4est_topidx_t tswap;
474
475 /* go through all elements except the last */
476 for (i = length - 1; i > 0; --i) {
477 /* bubble up the first element until before position i */
478 for (j = 0; j < i; ++j) {
479 if (t[j] > t[j + 1]) {
480 tswap = t[j + 1];
481 t[j + 1] = t[j];
482 t[j] = tswap;
483 }
484 }
485 }
486 P4EST_ASSERT (p4est_topidx_is_sorted (t, length));
487}
488
489/*@unused@*/
490static inline uint64_t
491p4est_partition_cut_uint64 (uint64_t global_num, int p, int num_procs)
492{
493 uint64_t result;
494
495 /* In theory, a double * double product should never overflow
496 due to the 15-bit exponent used internally on x87 and above.
497 Also in theory, 80-bit floats should be used internally,
498 and multiply/divide associativity goes left-to-right.
499 Still checking for funny stuff just to be sure. */
500
501 P4EST_ASSERT (0 <= p && p <= num_procs);
502
503 if (p == num_procs) {
504 /* prevent roundoff error and division by zero */
505 return global_num;
506 }
507
508 result = (uint64_t)
509 (((long double) global_num * (double) p) / (double) num_procs);
510
511 P4EST_ASSERT (result <= global_num);
512
513 return result;
514}
515
516/*@unused@*/
517static inline p4est_gloidx_t
518p4est_partition_cut_gloidx (p4est_gloidx_t global_num, int p, int num_procs)
519{
520 p4est_gloidx_t result;
521
522 /* In theory, a double * double product should never overflow
523 due to the 15-bit exponent used internally on x87 and above.
524 Also in theory, 80-bit floats should be used internally,
525 and multiply/divide associativity goes left-to-right.
526 Still checking for funny stuff just to be sure. */
527
528 P4EST_ASSERT (global_num >= 0);
529 P4EST_ASSERT (0 <= p && p <= num_procs);
530
531 if (p == num_procs) {
532 /* prevent roundoff error and division by zero */
533 return global_num;
534 }
535
536 result = (p4est_gloidx_t)
537 (((long double) global_num * (double) p) / (double) num_procs);
538
539 P4EST_ASSERT (0 <= result && result <= global_num);
540
541 return result;
542}
543
552const char *p4est_version (void);
553
559
565
566SC_EXTERN_C_END;
567
568#endif /* !P4EST_BASE_H */
int32_t p4est_qcoord_t
Typedef for quadrant coordinates.
Definition: p4est_base.h:81
enum p4est_comm_tag p4est_comm_tag_t
Tags for MPI messages.
int p4est_version_major(void)
Return the major version of p4est.
int p4est_package_id
the libsc package id for p4est (set in p4est_init())
int32_t p4est_topidx_t
Typedef for counting topological entities (trees, tree vertices).
Definition: p4est_base.h:93
int p4est_get_package_id(void)
Query the package identity as registered in libsc.
const char * p4est_version(void)
Return the full version of p4est.
p4est_comm_tag
Tags for MPI messages.
Definition: p4est_base.h:131
int32_t p4est_locidx_t
Typedef for processor-local indexing of quadrants and nodes.
Definition: p4est_base.h:106
void p4est_init(sc_log_handler_t log_handler, int log_threshold)
Registers p4est with the SC Library and sets the logging behavior.
int p4est_version_minor(void)
Return the minor version of p4est.
int64_t p4est_gloidx_t
Typedef for globally unique indexing of quadrants.
Definition: p4est_base.h:118
int p4est_is_initialized(void)
Return whether p4est has been initialized or not.