p4est 2.8.6
p4est is a software library for parallel adaptive mesh refinement.
p6est.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
25#ifndef P6EST_H
26#define P6EST_H
27
53/* 2+1D refinement is based on the 2D p4est datatypes */
54#include <p4est.h>
55/* We need p8est_connect_type_t typedef from p8est_connectivity */
56#include <p8est_connectivity.h>
57
58SC_EXTERN_C_BEGIN;
59
64typedef struct p6est_connectivity
65{
69 double *top_vertices;
73 double height[3];
76}
78
93 double *top_vertices,
94 double height[3]);
95
98
106 p4est_topidx_t which_tree,
107 double vertices[24]);
108
117 connectivity,
118 p4est_topidx_t treeid,
121 p4est_qcoord_t z, double vxyz[3]);
122
126typedef struct p2est_quadrant
127{
129 int8_t level,
131 int16_t pad16;
133 {
134 void *user_data;
138 struct
139 {
141 int owner_rank;
142 }
144 struct
145 {
147 p4est_topidx_t from_tree;
148 }
149 piggy2;
151 struct
152 {
154 p4est_locidx_t local_num;
155 }
156 piggy3;
158 }
160}
162
164typedef struct p6est
165{
166 sc_MPI_Comm mpicomm;
171 size_t data_size;
180 sc_array_t *layers;
182 sc_mempool_t *user_data_pool;
183 /* WARNING: This is NULL if data size
184 * equals zero. */
185 sc_mempool_t *layer_pool;
190}
192
201typedef void (*p6est_init_t) (p6est_t * p6est,
202 p4est_topidx_t which_tree,
203 p4est_quadrant_t * column,
204 p2est_quadrant_t * layer);
205
234typedef void (*p6est_replace_t) (p6est_t * p6est,
235 p4est_topidx_t which_tree,
236 int num_outcolumns,
237 int num_outlayers,
238 p4est_quadrant_t * outcolumns[],
239 p2est_quadrant_t * outlayers[],
240 int num_incolumns,
241 int num_inlayers,
242 p4est_quadrant_t * incolumns[],
243 p2est_quadrant_t * inlayers[]);
244
250 p4est_topidx_t which_tree,
251 p4est_quadrant_t * column);
252
258 p4est_topidx_t which_tree,
259 p4est_quadrant_t * column,
260 p2est_quadrant_t * layer);
261
267 p4est_topidx_t which_tree,
268 p4est_quadrant_t * columns[]);
269
275 p4est_topidx_t which_tree,
276 p4est_quadrant_t * column,
277 p2est_quadrant_t * layers[]);
278
283typedef int (*p6est_weight_t) (p6est_t * p6est,
284 p4est_topidx_t which_tree,
285 p4est_quadrant_t * column,
286 p2est_quadrant_t * layer);
287
288extern void *P2EST_DATA_UNINITIALIZED;
289
291#define P2EST_QUADRANT_INIT(q) \
292 ((void) memset ((q), -1, sizeof (p2est_quadrant_t)))
293
315p6est_t *p6est_new (sc_MPI_Comm mpicomm,
316 p6est_connectivity_t * connectivity,
317 size_t data_size,
318 p6est_init_t init_fn, void *user_pointer);
319
339 double *top_vertices,
340 double height[3], int min_zlevel,
341 size_t data_size,
342 p6est_init_t init_fn,
343 void *user_pointer);
344
350
360p6est_t *p6est_copy (p6est_t * input, int copy_data);
361
374void p6est_reset_data (p6est_t * p6est, size_t data_size,
375 p6est_init_t init_fn,
376 void *user_pointer);
377
397 int refine_recursive,
398 p6est_refine_column_t refine_fn,
399 p6est_init_t init_fn);
400
420 int refine_recursive,
421 p6est_refine_layer_t refine_fn,
422 p6est_init_t init_fn);
423
434 int coarsen_recursive,
435 p6est_coarsen_column_t coarsen_fn,
436 p6est_init_t init_fn);
437
448 int coarsen_recursive,
449 p6est_coarsen_layer_t coarsen_fn,
450 p6est_init_t init_fn);
451
461 p6est_init_t init_fn);
462
463typedef enum
464{
465 P6EST_COMM_PARTITION = 1,
466 P6EST_COMM_GHOST,
467 P6EST_COMM_BALANCE
468}
469p6est_comm_tag_t;
470
485 p6est_weight_t weight_fn);
486void p6est_partition_correct (p6est_t * p6est,
488 num_layers_in_proc);
489void p6est_partition_to_p4est_partition (p6est_t * p6est,
491 num_layers_in_proc,
493 num_columns_in_proc);
494void p4est_partition_to_p6est_partition (p6est_t * p6est,
496 num_columns_in_proc,
498 num_layers_in_proc);
499
500p4est_gloidx_t p6est_partition_for_coarsening (p6est_t * p6est,
502 num_layers_in_proc);
503p4est_gloidx_t p6est_partition_given (p6est_t * p6est,
505 num_layers_in_proc);
506
512
524void p6est_save (const char *filename, p6est_t * p6est,
525 int save_data);
526
545p6est_t *p6est_load (const char *filename, sc_MPI_Comm mpicomm,
546 size_t data_size, int load_data,
547 void *user_pointer,
548 p6est_connectivity_t ** connectivity);
549
551/*@unused@*/
552static inline p2est_quadrant_t *
553p2est_quadrant_array_index (sc_array_t * array, size_t it)
554{
555 P4EST_ASSERT (array->elem_size == sizeof (p2est_quadrant_t));
556 P4EST_ASSERT (it < array->elem_count);
557
558 return (p2est_quadrant_t *) (array->array + sizeof (p2est_quadrant_t) * it);
559}
560
562/*@unused@*/
563static inline p2est_quadrant_t *
564p2est_quadrant_array_push (sc_array_t * array)
565{
567
568 P4EST_ASSERT (array->elem_size == sizeof (p2est_quadrant_t));
569
570 q = (p2est_quadrant_t *) sc_array_push (array);
572 return q;
573}
574
576/*@unused@*/
577static inline p2est_quadrant_t *
578p2est_quadrant_mempool_alloc (sc_mempool_t * mempool)
579{
580 P4EST_ASSERT (mempool->elem_size == sizeof (p2est_quadrant_t));
581
582 return (p2est_quadrant_t *) sc_mempool_alloc (mempool);
583}
584
586/*@unused@*/
587static inline p2est_quadrant_t *
588p2est_quadrant_list_pop (sc_list_t * list)
589{
590 return (p2est_quadrant_t *) sc_list_pop (list);
591}
592
593#define P6EST_COLUMN_GET_RANGE(q,f,l) \
594 do { \
595 *(f) = (size_t) (q)->p.piggy3.local_num; \
596 *(l) = *(f) + (size_t) (q)->p.piggy3.which_tree; \
597 } while (0);
598
599#define P6EST_COLUMN_SET_RANGE(q,f,l) \
600 do { \
601 (q)->p.piggy3.local_num = (p4est_locidx_t) (f); \
602 (q)->p.piggy3.which_tree = (p4est_topidx_t) ((l) - (f)); \
603 } while (0);
604
605/*@unused@*/
606static inline void
607p6est_layer_init_data (p6est_t * p6est, p4est_topidx_t which_tree,
608 p4est_quadrant_t * column,
609 p2est_quadrant_t * layer, p6est_init_t init_fn)
610{
611 if (p6est->data_size > 0) {
612 layer->p.user_data = sc_mempool_alloc (p6est->user_data_pool);
613 }
614 else {
615 layer->p.user_data = NULL;
616 }
617 if (init_fn != NULL) {
618 init_fn (p6est, which_tree, column, layer);
619 }
620}
621
622/*@unused@*/
623static inline void
624p6est_layer_free_data (p6est_t * p6est, p2est_quadrant_t * layer)
625{
626 if (p6est->data_size > 0) {
627 sc_mempool_free (p6est->user_data_pool, layer->p.user_data);
628 }
629 layer->p.user_data = NULL;
630}
631
632void p6est_compress_columns (p6est_t * p6est);
633void p6est_update_offsets (p6est_t * p6est);
634
635SC_EXTERN_C_END;
636
637#endif /* !P6EST_H */
The top-level 2D p4est interface.
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(* p6est_refine_column_t)(p6est_t *p6est, p4est_topidx_t which_tree, p4est_quadrant_t *column)
Callback function prototype to decide whether to horizontally refine a column, i.e....
Definition: p6est.h:249
void(* p6est_init_t)(p6est_t *p6est, p4est_topidx_t which_tree, p4est_quadrant_t *column, p2est_quadrant_t *layer)
Callback function prototype to initialize the layers's user data.
Definition: p6est.h:201
p6est_t * p6est_new_from_p4est(p4est_t *p4est, double *top_vertices, double height[3], int min_zlevel, size_t data_size, p6est_init_t init_fn, void *user_pointer)
Create a new forest from an already created p4est that represents columns.
void p6est_balance(p6est_t *p6est, p8est_connect_type_t btype, p6est_init_t init_fn)
Balance a forest.
struct p6est_connectivity p6est_connectivity_t
This structure holds the 2D+1D inter-tree connectivity information.
void p6est_connectivity_destroy(p6est_connectivity_t *conn)
Destroy a p6est_connectivity structure.
struct p2est_quadrant p2est_quadrant_t
A 1D quadrant datatype: this is used to encode a "layer" of a column in the 2D+1D AMR scheme.
p4est_gloidx_t p6est_partition(p6est_t *p6est, p6est_weight_t weight_fn)
Equally partition the forest.
void p6est_tree_get_vertices(p6est_connectivity_t *conn, p4est_topidx_t which_tree, double vertices[24])
Get the vertices of the corners of a tree.
struct p6est p6est_t
The p6est forest datatype.
void p6est_destroy(p6est_t *p6est)
Destroy a p6est.
void p6est_refine_layers(p6est_t *p6est, int refine_recursive, p6est_refine_layer_t refine_fn, p6est_init_t init_fn)
Refine the layers within the columns of a sheet.
p6est_t * p6est_new(sc_MPI_Comm mpicomm, p6est_connectivity_t *connectivity, size_t data_size, p6est_init_t init_fn, void *user_pointer)
Create a new forest.
p6est_t * p6est_copy(p6est_t *input, int copy_data)
Make a deep copy of a p6est.
p6est_t * p6est_load(const char *filename, sc_MPI_Comm mpicomm, size_t data_size, int load_data, void *user_pointer, p6est_connectivity_t **connectivity)
Load the complete connectivity/p6est structure from disk.
void p6est_save(const char *filename, p6est_t *p6est, int save_data)
Save the complete connectivity/p6est data to disk.
p6est_connectivity_t * p6est_connectivity_new(p4est_connectivity_t *conn4, double *top_vertices, double height[3])
Create a p6est_connectivity_t from a p4est_connectivity_t.
int(* p6est_weight_t)(p6est_t *p6est, p4est_topidx_t which_tree, p4est_quadrant_t *column, p2est_quadrant_t *layer)
Callback function prototype to calculate weights for partitioning.
Definition: p6est.h:283
void p6est_coarsen_columns(p6est_t *p6est, int coarsen_recursive, p6est_coarsen_column_t coarsen_fn, p6est_init_t init_fn)
Coarsen the columns of a sheet.
int(* p6est_coarsen_column_t)(p6est_t *p6est, p4est_topidx_t which_tree, p4est_quadrant_t *columns[])
Callback function prototype to decide for horizontal coarsening.
Definition: p6est.h:266
void(* p6est_replace_t)(p6est_t *p6est, p4est_topidx_t which_tree, int num_outcolumns, int num_outlayers, p4est_quadrant_t *outcolumns[], p2est_quadrant_t *outlayers[], int num_incolumns, int num_inlayers, p4est_quadrant_t *incolumns[], p2est_quadrant_t *inlayers[])
Callback function prototype to transfer information from outgoing layers to incoming layers.
Definition: p6est.h:234
unsigned p6est_checksum(p6est_t *p6est)
Compute the checksum for a forest.
void p6est_coarsen_layers(p6est_t *p6est, int coarsen_recursive, p6est_coarsen_layer_t coarsen_fn, p6est_init_t init_fn)
Coarsen the layers of a sheet.
void p6est_reset_data(p6est_t *p6est, size_t data_size, p6est_init_t init_fn, void *user_pointer)
Reset user pointer and element data.
void p6est_refine_columns(p6est_t *p6est, int refine_recursive, p6est_refine_column_t refine_fn, p6est_init_t init_fn)
Refine the columns of a sheet.
int(* p6est_refine_layer_t)(p6est_t *p6est, p4est_topidx_t which_tree, p4est_quadrant_t *column, p2est_quadrant_t *layer)
Callback function prototype to decide whether to vertically refine a layer.
Definition: p6est.h:257
int(* p6est_coarsen_layer_t)(p6est_t *p6est, p4est_topidx_t which_tree, p4est_quadrant_t *column, p2est_quadrant_t *layers[])
Callback function prototype to decide for vertical coarsening.
Definition: p6est.h:274
#define P2EST_QUADRANT_INIT(q)
set statically allocated quadrant to defined values
Definition: p6est.h:291
void p6est_qcoord_to_vertex(p6est_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.
The connectivity defines the coarse topology of the forest.
p8est_connect_type_t
Characterize a type of adjacency.
Definition: p8est_connectivity.h:119
A 1D quadrant datatype: this is used to encode a "layer" of a column in the 2D+1D AMR scheme.
Definition: p6est.h:127
int8_t level
level of refinement
Definition: p6est.h:129
union p2est_quadrant::p6est_quadrant_data p
a union of additional data attached to a layer
int16_t pad16
padding
Definition: p6est.h:131
int8_t pad8
padding
Definition: p6est.h:130
p4est_qcoord_t z
vertical coordinate
Definition: p6est.h:128
This structure holds the 2D inter-tree connectivity information.
Definition: p4est_connectivity.h:190
The 2D quadrant datatype.
Definition: p4est.h:72
The p4est forest datatype.
Definition: p4est.h:136
This structure holds the 2D+1D inter-tree connectivity information.
Definition: p6est.h:65
p4est_connectivity_t * conn4
the 2D connecitvity; owned; vertices interpreted as the vertices of the bottom of the sheet
Definition: p6est.h:66
double * top_vertices
if NULL, uniform vertical profile, otherwise the vertices of the top of the sheet: should be the same...
Definition: p6est.h:69
double height[3]
if top_vertices == NULL, this gives the offset from the bottom of the sheet to the top
Definition: p6est.h:73
The p6est forest datatype.
Definition: p6est.h:165
void * user_pointer
convenience pointer for users, never touched by p4est
Definition: p6est.h:173
sc_MPI_Comm mpicomm
MPI communicator.
Definition: p6est.h:166
sc_mempool_t * user_data_pool
memory allocator for user data
Definition: p6est.h:182
int mpirank
this process's MPI rank
Definition: p6est.h:168
p4est_t * columns
2D description of column layout built from connectivity.
Definition: p6est.h:176
p6est_connectivity_t * connectivity
topology of sheet, not owned.
Definition: p6est.h:175
size_t data_size
size of per-quadrant p.user_data (see p2est_quadrant_t::p2est_quadrant_data::user_data)
Definition: p6est.h:171
int mpisize
number of MPI processes
Definition: p6est.h:167
p4est_gloidx_t * global_first_layer
first global quadrant index for each process and 1 beyond
Definition: p6est.h:187
p4est_qcoord_t root_len
height of the domain
Definition: p6est.h:189
int mpicomm_owned
whether this communicator is owned by the forest
Definition: p6est.h:169
sc_mempool_t * layer_pool
memory allocator for temporary layers
Definition: p6est.h:185
sc_array_t * layers
single array that stores p2est_quadrant_t layers within columns
Definition: p6est.h:180
struct p2est_quadrant::p6est_quadrant_data::@14 piggy3
of ghost layers, store the tree and index in the owner's numbering
p4est_topidx_t which_tree
the tree containing the quadrant
Definition: p6est.h:137
struct p2est_quadrant::p6est_quadrant_data::@13 piggy2
of transformed layers, store the original tree and the target tree
struct p2est_quadrant::p6est_quadrant_data::@12 piggy1
of ghost layer, store the tree and owner rank
void * user_data
never changed by p4est
Definition: p6est.h:134
long user_long
never changed by p4est
Definition: p6est.h:135
int user_int
never changed by p4est
Definition: p6est.h:136