p4est 2.8.7.456-de8c6
p4est is a software library for parallel adaptive mesh refinement.
Loading...
Searching...
No Matches
p4est.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 P4EST_H
38#define P4EST_H
39
40#ifdef P4EST_TO_P8EST_H
41#error "The include files p4est.h and p4est_to_p8est.h cannot be combined"
42#endif
43
44/* p4est_connectivity.h includes p4est_base.h sc_containers.h */
45#include <p4est_connectivity.h>
46
47SC_EXTERN_C_BEGIN;
48
50#define P4EST_OLD_MAXLEVEL 30 /* in 2D, the maxlevel has always been 30 */
51
53#define P4EST_MAXLEVEL 30
54
56#define P4EST_OLD_QMAXLEVEL 29 /* in 2D, the qmaxlevel has always been 29 */
57
59#define P4EST_QMAXLEVEL 29
60
62#define P4EST_ROOT_LEN ((p4est_qcoord_t) 1 << P4EST_MAXLEVEL)
63
65#define P4EST_QUADRANT_LEN(l) ((p4est_qcoord_t) 1 << (P4EST_MAXLEVEL - (l)))
66
68#define P4EST_QUADRANT_MASK(l) (~(P4EST_QUADRANT_LEN (l) - 1))
69
72#define P4EST_LAST_OFFSET(l) (P4EST_ROOT_LEN - P4EST_QUADRANT_LEN (l))
73
75typedef struct p4est_quadrant
76{
80 int8_t level,
82 int16_t pad16;
93 {
94 void *user_data;
95 long user_long;
101 struct
102 {
104 int owner_rank;
105 }
106 piggy1;
108 struct
109 {
111 p4est_topidx_t from_tree;
112 }
113 piggy2;
115 struct
116 {
118 p4est_locidx_t local_num;
119 }
120 piggy3;
122 }
124}
126
141
147
188
196size_t p4est_memory_used (p4est_t * p4est);
197
206long p4est_revision (p4est_t * p4est);
207
217typedef void (*p4est_init_t) (p4est_t * p4est,
218 p4est_topidx_t which_tree,
219 p4est_quadrant_t * quadrant);
220
227typedef int (*p4est_refine_t) (p4est_t * p4est,
228 p4est_topidx_t which_tree,
229 p4est_quadrant_t * quadrant);
230
237typedef int (*p4est_coarsen_t) (p4est_t * p4est,
238 p4est_topidx_t which_tree,
239 p4est_quadrant_t * quadrants[]);
240
247typedef int (*p4est_weight_t) (p4est_t * p4est,
248 p4est_topidx_t which_tree,
249 p4est_quadrant_t * quadrant);
250
251extern void *P4EST_DATA_UNINITIALIZED;
252
254#define P4EST_QUADRANT_INIT(q) \
255 ((void) memset ((q), -1, sizeof (p4est_quadrant_t)))
256
263void p4est_qcoord_to_vertex (p4est_connectivity_t *
264 connectivity,
265 p4est_topidx_t treeid,
267 p4est_qcoord_t y, double vxyz[3]);
268
289p4est_t *p4est_new (sc_MPI_Comm mpicomm,
290 p4est_connectivity_t * connectivity,
291 size_t data_size,
292 p4est_init_t init_fn, void *user_pointer);
293
298void p4est_destroy (p4est_t * p4est);
299
313p4est_t *p4est_copy (p4est_t * input, int copy_data);
314
328void p4est_reset_data (p4est_t * p4est, size_t data_size,
329 p4est_init_t init_fn,
330 void *user_pointer);
331
348void p4est_refine (p4est_t * p4est,
349 int refine_recursive,
350 p4est_refine_t refine_fn,
351 p4est_init_t init_fn);
352
361void p4est_coarsen (p4est_t * p4est,
362 int coarsen_recursive,
363 p4est_coarsen_t coarsen_fn,
364 p4est_init_t init_fn);
365
374void p4est_balance (p4est_t * p4est,
376 p4est_init_t init_fn);
377
401void p4est_partition (p4est_t * p4est,
402 int allow_for_coarsening,
403 p4est_weight_t weight_fn);
404
411unsigned p4est_checksum (p4est_t * p4est);
412
416unsigned p4est_checksum_partition (p4est_t * p4est);
417
441void p4est_save (const char *filename, p4est_t * p4est,
442 int save_data);
443
472p4est_t *p4est_load (const char *filename, sc_MPI_Comm mpicomm,
473 size_t data_size, int load_data,
474 void *user_pointer,
475 p4est_connectivity_t ** connectivity);
476
482inline p4est_tree_t *
483p4est_tree_array_index (sc_array_t *array, p4est_topidx_t it)
484{
485 P4EST_ASSERT (array->elem_size == sizeof (p4est_tree_t));
486 P4EST_ASSERT (it >= 0 && (size_t) it < array->elem_count);
487
488 return (p4est_tree_t *) (array->array +
489 sizeof (p4est_tree_t) * (size_t) it);
490}
491
493inline p4est_quadrant_t *
494p4est_quadrant_array_index (sc_array_t *array, size_t it)
495{
496 P4EST_ASSERT (array->elem_size == sizeof (p4est_quadrant_t));
497 P4EST_ASSERT (it < array->elem_count);
498
499 return (p4est_quadrant_t *) (array->array + sizeof (p4est_quadrant_t) * it);
500}
501
510inline p4est_quadrant_t *
511p4est_quadrant_array_push_copy (sc_array_t *array,
512 const p4est_quadrant_t *qsrc)
513{
515
516 P4EST_ASSERT (array->elem_size == sizeof (p4est_quadrant_t));
517
518 q = (p4est_quadrant_t *) sc_array_push (array);
519 *q = *qsrc;
520 return q;
521}
522
529inline p4est_quadrant_t *
530p4est_quadrant_array_push (sc_array_t *array)
531{
533
534 P4EST_ASSERT (array->elem_size == sizeof (p4est_quadrant_t));
535
536 q = (p4est_quadrant_t *) sc_array_push (array);
538 return q;
539}
540
542inline p4est_quadrant_t *
543p4est_quadrant_mempool_alloc (sc_mempool_t *mempool)
544{
545 P4EST_ASSERT (mempool->elem_size == sizeof (p4est_quadrant_t));
546
547 return (p4est_quadrant_t *) sc_mempool_alloc (mempool);
548}
549
551inline p4est_quadrant_t *
552p4est_quadrant_list_pop (sc_list_t *list)
553{
554 return (p4est_quadrant_t *) sc_list_pop (list);
555}
556
557SC_EXTERN_C_END;
558
559#endif /* !P4EST_H */
int(* p4est_coarsen_t)(p4est_t *p4est, p4est_topidx_t which_tree, p4est_quadrant_t *quadrants[])
Callback function prototype to decide for coarsening.
Definition p4est.h:237
struct p4est_tree p4est_tree_t
The p4est tree datatype.
void(* p4est_init_t)(p4est_t *p4est, p4est_topidx_t which_tree, p4est_quadrant_t *quadrant)
Callback function prototype to initialize the quadrant's user data.
Definition p4est.h:217
#define P4EST_QUADRANT_INIT(q)
set statically allocated quadrant to defined values
Definition p4est.h:254
#define P4EST_MAXLEVEL
The finest level for representing quadrant midpoint coordinates.
Definition p4est.h:53
int(* p4est_weight_t)(p4est_t *p4est, p4est_topidx_t which_tree, p4est_quadrant_t *quadrant)
Callback function prototype to calculate weights for partitioning.
Definition p4est.h:247
struct p4est p4est_t
The p4est forest datatype.
int(* p4est_refine_t)(p4est_t *p4est, p4est_topidx_t which_tree, p4est_quadrant_t *quadrant)
Callback function prototype to decide for refinement.
Definition p4est.h:227
struct p4est_quadrant p4est_quadrant_t
The 2D quadrant datatype.
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
The connectivity defines the coarse topology of the forest.
p4est_connect_type_t
Characterize a type of adjacency.
Definition p4est_connectivity.h:113
This structure holds the 2D inter-tree connectivity information.
Definition p4est_connectivity.h:190
Data pertaining to selecting, inspecting, and profiling algorithms.
Definition p4est_extended.h:62
The 2D quadrant datatype.
Definition p4est.h:76
int8_t level
level of refinement
Definition p4est.h:80
int16_t pad16
padding
Definition p4est.h:82
union p4est_quadrant::p4est_quadrant_data p
a union of additional data attached to a quadrant
p4est_qcoord_t y
coordinates
Definition p4est.h:78
int8_t pad8
padding
Definition p4est.h:81
The p4est tree datatype.
Definition p4est.h:129
p4est_quadrant_t last_desc
last local descendant
Definition p4est.h:132
p4est_quadrant_t first_desc
first local descendant
Definition p4est.h:131
int8_t maxlevel
highest local quadrant level
Definition p4est.h:138
sc_array_t quadrants
locally stored quadrants
Definition p4est.h:130
p4est_locidx_t quadrants_offset
cumulative sum over earlier trees on this processor (locals only)
Definition p4est.h:133
p4est_locidx_t quadrants_per_level[P4EST_MAXLEVEL+1]
locals only
Definition p4est.h:136
The p4est forest datatype.
Definition p4est.h:150
p4est_topidx_t first_local_tree
0-based index of first local tree, must be -1 for an empty processor
Definition p4est.h:161
p4est_connectivity_t * connectivity
connectivity structure, not owned
Definition p4est.h:177
p4est_locidx_t local_num_quadrants
number of quadrants on all trees on this processor
Definition p4est.h:167
void * user_pointer
convenience pointer for users, never touched by p4est
Definition p4est.h:157
int mpisize
number of MPI processes
Definition p4est.h:152
int mpirank
this process's MPI rank
Definition p4est.h:153
sc_array_t * trees
array of all trees
Definition p4est.h:178
size_t data_size
size of per-quadrant p.user_data (see p4est_quadrant_t::p4est_quadrant_data::user_data)
Definition p4est.h:155
long revision
Gets bumped on mesh change.
Definition p4est.h:160
p4est_inspect_t * inspect
algorithmic switches
Definition p4est.h:185
sc_MPI_Comm mpicomm
MPI communicator.
Definition p4est.h:151
p4est_gloidx_t global_num_quadrants
number of quadrants on all trees on all processors
Definition p4est.h:169
p4est_quadrant_t * global_first_position
first smallest possible quad for each process and 1 beyond
Definition p4est.h:174
int mpicomm_owned
flag if communicator is owned
Definition p4est.h:154
sc_mempool_t * quadrant_pool
memory allocator for temporary quadrants
Definition p4est.h:183
p4est_topidx_t last_local_tree
0-based index of last local tree, must be -2 for an empty processor
Definition p4est.h:164
sc_mempool_t * user_data_pool
memory allocator for user data
Definition p4est.h:180
p4est_gloidx_t * global_first_quadrant
first global quadrant index for each process and 1 beyond
Definition p4est.h:171
Union for quadrant data.
Definition p4est.h:93
struct p4est_quadrant::p4est_quadrant_data::@0 piggy1
of ghost octants, store the tree and owner rank; not part of the API
long user_long
never changed by p4est
Definition p4est.h:95
struct p4est_quadrant::p4est_quadrant_data::@1 piggy2
of transformed octants, store the original tree and the target tree; not part of the API
int user_int
never changed by p4est
Definition p4est.h:96
p4est_topidx_t which_tree
the tree containing the quadrant (used in auxiliary octants such as the ghost octants in p4est_ghost_...
Definition p4est.h:97
struct p4est_quadrant::p4est_quadrant_data::@2 piggy3
of ghost octants, store the tree and index in the owner's numbering; only part of the API in p4est_gh...
void * user_data
never changed by p4est
Definition p4est.h:94