p4est 2.8.8
p4est is a software library for parallel adaptive mesh refinement.
Loading...
Searching...
No Matches
p8est.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
37#ifndef P8EST_H
38#define P8EST_H
39
40/* p8est_connectivity.h includes p4est_base.h sc_containers.h */
41#include <p8est_connectivity.h>
42
43SC_EXTERN_C_BEGIN;
44
46#define P8EST_OLD_MAXLEVEL 19 /* old means prior to mid-2020 */
47
49#define P8EST_MAXLEVEL 30
50
52#define P8EST_OLD_QMAXLEVEL 18 /* old means prior to mid-2020 */
53
55#define P8EST_QMAXLEVEL 29
56
58#define P8EST_ROOT_LEN ((p4est_qcoord_t) 1 << P8EST_MAXLEVEL)
59
61#define P8EST_QUADRANT_LEN(l) ((p4est_qcoord_t) 1 << (P8EST_MAXLEVEL - (l)))
62
64#define P8EST_QUADRANT_MASK(l) (~(P8EST_QUADRANT_LEN (l) - 1))
65
68#define P8EST_LAST_OFFSET(l) (P8EST_ROOT_LEN - P8EST_QUADRANT_LEN (l))
69
71typedef struct p8est_quadrant
72{
76 int8_t level,
78 int16_t pad16;
89 {
90 void *user_data;
91 long user_long;
97 struct
98 {
100 int owner_rank;
101 }
102 piggy1;
104 struct
105 {
107 p4est_topidx_t from_tree;
108 }
109 piggy2;
111 struct
112 {
114 p4est_locidx_t local_num;
115 }
116 piggy3;
118 }
120}
122
137
143
184
193
203
213typedef void (*p8est_init_t) (p8est_t * p8est,
214 p4est_topidx_t which_tree,
215 p8est_quadrant_t * quadrant);
216
223typedef int (*p8est_refine_t) (p8est_t * p8est,
224 p4est_topidx_t which_tree,
225 p8est_quadrant_t * quadrant);
226
233typedef int (*p8est_coarsen_t) (p8est_t * p8est,
234 p4est_topidx_t which_tree,
235 p8est_quadrant_t * quadrants[]);
236
243typedef int (*p8est_weight_t) (p8est_t * p8est,
244 p4est_topidx_t which_tree,
245 p8est_quadrant_t * quadrant);
246
247extern void *P8EST_DATA_UNINITIALIZED;
248
250#define P8EST_QUADRANT_INIT(q) \
251 ((void) memset ((q), -1, sizeof (p8est_quadrant_t)))
252
260 connectivity,
261 p4est_topidx_t treeid,
264 p4est_qcoord_t z, double vxyz[3]);
265
286p8est_t *p8est_new (sc_MPI_Comm mpicomm,
287 p8est_connectivity_t * connectivity,
288 size_t data_size,
289 p8est_init_t init_fn, void *user_pointer);
290
296
310p8est_t *p8est_copy (p8est_t * input, int copy_data);
311
325void p8est_reset_data (p8est_t * p8est, size_t data_size,
326 p8est_init_t init_fn,
327 void *user_pointer);
328
346 int refine_recursive,
347 p8est_refine_t refine_fn,
348 p8est_init_t init_fn);
349
359 int coarsen_recursive,
360 p8est_coarsen_t coarsen_fn,
361 p8est_init_t init_fn);
362
376 p8est_init_t init_fn);
377
402 int allow_for_coarsening,
403 p8est_weight_t weight_fn);
404
412
417
441void p8est_save (const char *filename, p8est_t * p8est,
442 int save_data);
443
472p8est_t *p8est_load (const char *filename, sc_MPI_Comm mpicomm,
473 size_t data_size, int load_data,
474 void *user_pointer,
475 p8est_connectivity_t ** connectivity);
476
482inline p8est_tree_t *
484{
485 P4EST_ASSERT (array->elem_size == sizeof (p8est_tree_t));
486 P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
487
488 return (p8est_tree_t *) (array->array +
489 sizeof (p8est_tree_t) * (size_t) it);
490}
491
493inline p8est_quadrant_t *
494p8est_quadrant_array_index (sc_array_t * array, size_t it)
495{
496 P4EST_ASSERT (array->elem_size == sizeof (p8est_quadrant_t));
497 P4EST_ASSERT (it < array->elem_count);
498
499 return (p8est_quadrant_t *) (array->array + sizeof (p8est_quadrant_t) * it);
500}
501
510inline p8est_quadrant_t *
512 const p8est_quadrant_t *qsrc)
513{
515
516 P4EST_ASSERT (array->elem_size == sizeof (p8est_quadrant_t));
517
518 q = (p8est_quadrant_t *) sc_array_push (array);
519 *q = *qsrc;
520 return q;
521}
522
529inline p8est_quadrant_t *
530p8est_quadrant_array_push (sc_array_t * array)
531{
533
534 P4EST_ASSERT (array->elem_size == sizeof (p8est_quadrant_t));
535
536 q = (p8est_quadrant_t *) sc_array_push (array);
538 return q;
539}
540
542inline p8est_quadrant_t *
543p8est_quadrant_mempool_alloc (sc_mempool_t * mempool)
544{
545 P4EST_ASSERT (mempool->elem_size == sizeof (p8est_quadrant_t));
546
547 return (p8est_quadrant_t *) sc_mempool_alloc (mempool);
548}
549
551inline p8est_quadrant_t *
552p8est_quadrant_list_pop (sc_list_t * list)
553{
554 return (p8est_quadrant_t *) sc_list_pop (list);
555}
556
557SC_EXTERN_C_END;
558
559#endif /* !P8EST_H */
int32_t p4est_qcoord_t
Typedef for quadrant coordinates.
Definition p4est_base.h:81
int32_t p4est_topidx_t
Typedef for counting topological entities (trees, tree vertices).
Definition p4est_base.h:93
int32_t p4est_locidx_t
Typedef for processor-local indexing of quadrants and nodes.
Definition p4est_base.h:106
int64_t p4est_gloidx_t
Typedef for globally unique indexing of quadrants.
Definition p4est_base.h:118
int(* p8est_weight_t)(p8est_t *p8est, p4est_topidx_t which_tree, p8est_quadrant_t *quadrant)
Callback function prototype to calculate weights for partitioning.
Definition p8est.h:243
p8est_quadrant_t * p8est_quadrant_array_push(sc_array_t *array)
Call sc_array_push for a quadrant array and fully initialize memory.
Definition p8est.h:530
int(* p8est_coarsen_t)(p8est_t *p8est, p4est_topidx_t which_tree, p8est_quadrant_t *quadrants[])
Callback function prototype to decide for coarsening.
Definition p8est.h:233
int(* p8est_refine_t)(p8est_t *p8est, p4est_topidx_t which_tree, p8est_quadrant_t *quadrant)
Callback function prototype to decide for refinement.
Definition p8est.h:223
void p8est_qcoord_to_vertex(p8est_connectivity_t *connectivity, p4est_topidx_t treeid, p4est_qcoord_t x, p4est_qcoord_t y, p4est_qcoord_t z, double vxyz[3])
Transform a quadrant coordinate into the space spanned by tree vertices.
#define P8EST_MAXLEVEL
The finest level for representing quadrant midpoint coordinates.
Definition p8est.h:49
p8est_quadrant_t * p8est_quadrant_list_pop(sc_list_t *list)
Call sc_list pop for a quadrant array.
Definition p8est.h:552
long p8est_revision(p8est_t *p8est)
Return the revision counter of the forest.
p8est_quadrant_t * p8est_quadrant_array_push_copy(sc_array_t *array, const p8est_quadrant_t *qsrc)
Push the copy of a fully initialized quadrant onto a quadrant array.
Definition p8est.h:511
void p8est_refine(p8est_t *p8est, int refine_recursive, p8est_refine_t refine_fn, p8est_init_t init_fn)
Refine a forest.
p8est_t * p8est_load(const char *filename, sc_MPI_Comm mpicomm, size_t data_size, int load_data, void *user_pointer, p8est_connectivity_t **connectivity)
Load the complete connectivity/p8est structure from disk.
void p8est_partition(p8est_t *p8est, int allow_for_coarsening, p8est_weight_t weight_fn)
Equally partition the forest.
unsigned p8est_checksum_partition(p8est_t *p8est)
Compute a partition-dependent checksum for a forest.
void p8est_coarsen(p8est_t *p8est, int coarsen_recursive, p8est_coarsen_t coarsen_fn, p8est_init_t init_fn)
Coarsen a forest.
struct p8est p8est_t
The p8est forest datatype.
#define P8EST_QUADRANT_INIT(q)
set statically allocated quadrant to defined values
Definition p8est.h:250
struct p8est_tree p8est_tree_t
The p8est tree datatype.
p8est_quadrant_t * p8est_quadrant_mempool_alloc(sc_mempool_t *mempool)
Call sc_mempool_alloc for a mempool creating quadrants.
Definition p8est.h:543
void p8est_destroy(p8est_t *p8est)
Destroy a p8est.
p8est_quadrant_t * p8est_quadrant_array_index(sc_array_t *array, size_t it)
Return a pointer to a quadrant array element indexed by a size_t.
Definition p8est.h:494
void p8est_save(const char *filename, p8est_t *p8est, int save_data)
Save the complete connectivity/p8est data to disk.
void p8est_reset_data(p8est_t *p8est, size_t data_size, p8est_init_t init_fn, void *user_pointer)
Reset user pointer and element data.
p8est_tree_t * p8est_tree_array_index(sc_array_t *array, p4est_topidx_t it)
Return a pointer to an array element indexed by a p4est_topidx_t.
Definition p8est.h:483
void p8est_balance(p8est_t *p8est, p8est_connect_type_t btype, p8est_init_t init_fn)
2:1 balance the size differences of neighboring elements in a forest.
void(* p8est_init_t)(p8est_t *p8est, p4est_topidx_t which_tree, p8est_quadrant_t *quadrant)
Callback function prototype to initialize the quadrant's user data.
Definition p8est.h:213
p8est_t * p8est_copy(p8est_t *input, int copy_data)
Make a deep copy of a p8est.
size_t p8est_memory_used(p8est_t *p8est)
Calculate local memory usage of a forest structure.
p8est_t * p8est_new(sc_MPI_Comm mpicomm, p8est_connectivity_t *connectivity, size_t data_size, p8est_init_t init_fn, void *user_pointer)
Create a new forest with an initial coarse mesh.
unsigned p8est_checksum(p8est_t *p8est)
Compute the checksum for a forest.
struct p8est_quadrant p8est_quadrant_t
The 3D quadrant (i.e., octant) datatype.
The connectivity defines the coarse topology of the forest.
p8est_connect_type_t
Characterize a type of adjacency.
Definition p8est_connectivity.h:120
This structure holds the 3D inter-tree connectivity information.
Definition p8est_connectivity.h:216
Definition p8est_extended.h:67
The 3D quadrant (i.e., octant) datatype.
Definition p8est.h:72
int8_t level
level of refinement
Definition p8est.h:76
union p8est_quadrant::p8est_quadrant_data p
a union of additional data attached to a quadrant
int16_t pad16
padding
Definition p8est.h:78
p4est_qcoord_t z
coordinates
Definition p8est.h:74
int8_t pad8
padding
Definition p8est.h:77
The p8est tree datatype.
Definition p8est.h:125
p8est_quadrant_t first_desc
first local descendant
Definition p8est.h:127
int8_t maxlevel
highest local quadrant level
Definition p8est.h:134
p4est_locidx_t quadrants_per_level[P8EST_MAXLEVEL+1]
locals only
Definition p8est.h:132
sc_array_t quadrants
locally stored quadrants
Definition p8est.h:126
p8est_quadrant_t last_desc
last local descendant
Definition p8est.h:128
p4est_locidx_t quadrants_offset
cumulative sum over earlier trees on this processor (locals only)
Definition p8est.h:129
The p8est forest datatype.
Definition p8est.h:146
p4est_gloidx_t global_num_quadrants
number of quadrants on all trees on all processors
Definition p8est.h:165
size_t data_size
size of per-quadrant p.user_data (see p8est_quadrant_t::p8est_quadrant_data::user_data)
Definition p8est.h:151
p4est_topidx_t last_local_tree
0-based index of last local tree, must be -2 for an empty processor
Definition p8est.h:160
sc_array_t * trees
array of all trees
Definition p8est.h:174
p4est_gloidx_t * global_first_quadrant
first global quadrant index for each process and 1 beyond
Definition p8est.h:167
p4est_topidx_t first_local_tree
0-based index of first local tree, must be -1 for an empty processor
Definition p8est.h:157
sc_MPI_Comm mpicomm
MPI communicator.
Definition p8est.h:147
p4est_locidx_t local_num_quadrants
number of quadrants on all trees on this processor
Definition p8est.h:163
p8est_inspect_t * inspect
algorithmic switches
Definition p8est.h:181
sc_mempool_t * quadrant_pool
memory allocator for temporary quadrants
Definition p8est.h:179
sc_mempool_t * user_data_pool
memory allocator for user data
Definition p8est.h:176
int mpicomm_owned
flag if communicator is owned
Definition p8est.h:150
int mpisize
number of MPI processes
Definition p8est.h:148
void * user_pointer
convenience pointer for users, never touched by p4est
Definition p8est.h:153
p8est_quadrant_t * global_first_position
first smallest possible quad for each process and 1 beyond
Definition p8est.h:170
int mpirank
this process's MPI rank
Definition p8est.h:149
long revision
Gets bumped on mesh change.
Definition p8est.h:156
p8est_connectivity_t * connectivity
connectivity structure, not owned
Definition p8est.h:173
Union for quadrant data.
Definition p8est.h:89
int user_int
never changed by p4est
Definition p8est.h:92
void * user_data
never changed by p4est
Definition p8est.h:90
struct p8est_quadrant::p8est_quadrant_data::@13 piggy1
of ghost octants, store the tree and owner rank; not part of the API
long user_long
never changed by p4est
Definition p8est.h:91
struct p8est_quadrant::p8est_quadrant_data::@15 piggy3
of ghost octants, store the tree and index in the owner's numbering; only part of the API in p8est_gh...
struct p8est_quadrant::p8est_quadrant_data::@14 piggy2
of transformed octants, store the original tree and the target tree; not part of the API
p4est_topidx_t which_tree
the tree containing the quadrant (used in auxiliary octants such as the ghost octants in p4est_ghost_...
Definition p8est.h:93