p4est 2.8.8
p4est is a software library for parallel adaptive mesh refinement.
Loading...
Searching...
No Matches
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
119 connectivity,
120 p4est_topidx_t treeid,
123 p4est_qcoord_t z, double vxyz[3]);
124
128typedef struct p2est_quadrant
129{
131 int8_t level,
133 int16_t pad16;
135 {
136 void *user_data;
140 struct
141 {
143 int owner_rank;
144 }
146 struct
147 {
149 p4est_topidx_t from_tree;
150 }
151 piggy2;
153 struct
154 {
156 p4est_locidx_t local_num;
157 }
158 piggy3;
160 }
162}
164
166typedef struct p6est
167{
168 sc_MPI_Comm mpicomm;
173 size_t data_size;
182 sc_array_t *layers;
184 sc_mempool_t *user_data_pool;
185 /* WARNING: This is NULL if data size
186 * equals zero. */
187 sc_mempool_t *layer_pool;
192}
194
203typedef void (*p6est_init_t) (p6est_t * p6est,
204 p4est_topidx_t which_tree,
205 p4est_quadrant_t * column,
206 p2est_quadrant_t * layer);
207
236typedef void (*p6est_replace_t) (p6est_t * p6est,
237 p4est_topidx_t which_tree,
238 int num_outcolumns,
239 int num_outlayers,
240 p4est_quadrant_t * outcolumns[],
241 p2est_quadrant_t * outlayers[],
242 int num_incolumns,
243 int num_inlayers,
244 p4est_quadrant_t * incolumns[],
245 p2est_quadrant_t * inlayers[]);
246
252 p4est_topidx_t which_tree,
253 p4est_quadrant_t * column);
254
260 p4est_topidx_t which_tree,
261 p4est_quadrant_t * column,
262 p2est_quadrant_t * layer);
263
269 p4est_topidx_t which_tree,
270 p4est_quadrant_t * columns[]);
271
277 p4est_topidx_t which_tree,
278 p4est_quadrant_t * column,
279 p2est_quadrant_t * layers[]);
280
285typedef int (*p6est_weight_t) (p6est_t * p6est,
286 p4est_topidx_t which_tree,
287 p4est_quadrant_t * column,
288 p2est_quadrant_t * layer);
289
290extern void *P2EST_DATA_UNINITIALIZED;
291
293#define P2EST_QUADRANT_INIT(q) \
294 ((void) memset ((q), -1, sizeof (p2est_quadrant_t)))
295
317p6est_t *p6est_new (sc_MPI_Comm mpicomm,
318 p6est_connectivity_t * connectivity,
319 size_t data_size,
320 p6est_init_t init_fn, void *user_pointer);
321
341 double *top_vertices,
342 double height[3], int min_zlevel,
343 size_t data_size,
344 p6est_init_t init_fn,
345 void *user_pointer);
346
352
362p6est_t *p6est_copy (p6est_t * input, int copy_data);
363
376void p6est_reset_data (p6est_t * p6est, size_t data_size,
377 p6est_init_t init_fn,
378 void *user_pointer);
379
399 int refine_recursive,
400 p6est_refine_column_t refine_fn,
401 p6est_init_t init_fn);
402
422 int refine_recursive,
423 p6est_refine_layer_t refine_fn,
424 p6est_init_t init_fn);
425
436 int coarsen_recursive,
437 p6est_coarsen_column_t coarsen_fn,
438 p6est_init_t init_fn);
439
450 int coarsen_recursive,
451 p6est_coarsen_layer_t coarsen_fn,
452 p6est_init_t init_fn);
453
463 p6est_init_t init_fn);
464
465typedef enum
466{
467 P6EST_COMM_PARTITION = 1,
468 P6EST_COMM_GHOST,
469 P6EST_COMM_BALANCE
470}
471p6est_comm_tag_t;
472
487 p6est_weight_t weight_fn);
488void p6est_partition_correct (p6est_t * p6est,
490 num_layers_in_proc);
491void p6est_partition_to_p4est_partition (p6est_t * p6est,
493 num_layers_in_proc,
495 num_columns_in_proc);
496void p4est_partition_to_p6est_partition (p6est_t * p6est,
498 num_columns_in_proc,
500 num_layers_in_proc);
501
502p4est_gloidx_t p6est_partition_for_coarsening (p6est_t * p6est,
504 num_layers_in_proc);
505p4est_gloidx_t p6est_partition_given (p6est_t * p6est,
507 num_layers_in_proc);
508
514
526void p6est_save (const char *filename, p6est_t * p6est,
527 int save_data);
528
547p6est_t *p6est_load (const char *filename, sc_MPI_Comm mpicomm,
548 size_t data_size, int load_data,
549 void *user_pointer,
550 p6est_connectivity_t ** connectivity);
551
553inline p2est_quadrant_t *
554p2est_quadrant_array_index (sc_array_t * array, size_t it)
555{
556 P4EST_ASSERT (array->elem_size == sizeof (p2est_quadrant_t));
557 P4EST_ASSERT (it < array->elem_count);
558
559 return (p2est_quadrant_t *) (array->array + sizeof (p2est_quadrant_t) * it);
560}
561
563inline 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
576inline p2est_quadrant_t *
577p2est_quadrant_mempool_alloc (sc_mempool_t * mempool)
578{
579 P4EST_ASSERT (mempool->elem_size == sizeof (p2est_quadrant_t));
580
581 return (p2est_quadrant_t *) sc_mempool_alloc (mempool);
582}
583
585inline p2est_quadrant_t *
586p2est_quadrant_list_pop (sc_list_t * list)
587{
588 return (p2est_quadrant_t *) sc_list_pop (list);
589}
590
591#define P6EST_COLUMN_GET_RANGE(q,f,l) \
592 do { \
593 *(f) = (size_t) (q)->p.piggy3.local_num; \
594 *(l) = *(f) + (size_t) (q)->p.piggy3.which_tree; \
595 } while (0);
596
597#define P6EST_COLUMN_SET_RANGE(q,f,l) \
598 do { \
599 (q)->p.piggy3.local_num = (p4est_locidx_t) (f); \
600 (q)->p.piggy3.which_tree = (p4est_topidx_t) ((l) - (f)); \
601 } while (0);
602
605inline void
607 p4est_quadrant_t *column,
608 p2est_quadrant_t *layer, p6est_init_t init_fn)
609{
610 if (p6est->data_size > 0) {
611 layer->p.user_data = sc_mempool_alloc (p6est->user_data_pool);
612 }
613 else {
614 layer->p.user_data = NULL;
615 }
616 if (init_fn != NULL) {
617 init_fn (p6est, which_tree, column, layer);
618 }
619}
620
622inline void
624{
625 if (p6est->data_size > 0) {
626 sc_mempool_free (p6est->user_data_pool, layer->p.user_data);
627 }
628 layer->p.user_data = NULL;
629}
630
631void p6est_compress_columns (p6est_t * p6est);
632void p6est_update_offsets (p6est_t * p6est);
633
634SC_EXTERN_C_END;
635
636#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:251
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:203
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.
void p6est_layer_free_data(p6est_t *p6est, p2est_quadrant_t *layer)
Free the user data of a layer.
Definition p6est.h:623
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.
p2est_quadrant_t * p2est_quadrant_list_pop(sc_list_t *list)
Call sc_list pop for a quadrant array.
Definition p6est.h:586
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_layer_init_data(p6est_t *p6est, p4est_topidx_t which_tree, p4est_quadrant_t *column, p2est_quadrant_t *layer, p6est_init_t init_fn)
Alloc the user data of a layer and initialize it, if a init_fn is passed.
Definition p6est.h:606
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:285
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:268
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:236
p2est_quadrant_t * p2est_quadrant_array_push(sc_array_t *array)
Call sc_array_push for a quadrant array.
Definition p6est.h:564
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:259
p2est_quadrant_t * p2est_quadrant_array_index(sc_array_t *array, size_t it)
Return a pointer to a quadrant array element indexed by a size_t.
Definition p6est.h:554
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:276
#define P2EST_QUADRANT_INIT(q)
set statically allocated quadrant to defined values
Definition p6est.h:293
p2est_quadrant_t * p2est_quadrant_mempool_alloc(sc_mempool_t *mempool)
Call sc_mempool_alloc for a mempool creating quadrants.
Definition p6est.h:577
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:120
A 1D quadrant datatype: this is used to encode a "layer" of a column in the 2D+1D AMR scheme.
Definition p6est.h:129
int8_t level
level of refinement
Definition p6est.h:131
union p2est_quadrant::p6est_quadrant_data p
a union of additional data attached to a layer
int16_t pad16
padding
Definition p6est.h:133
int8_t pad8
padding
Definition p6est.h:132
p4est_qcoord_t z
vertical coordinate
Definition p6est.h:130
This structure holds the 2D inter-tree connectivity information.
Definition p4est_connectivity.h:190
The 2D quadrant datatype.
Definition p4est.h:76
The p4est forest datatype.
Definition p4est.h:150
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:167
void * user_pointer
convenience pointer for users, never touched by p4est
Definition p6est.h:175
sc_MPI_Comm mpicomm
MPI communicator.
Definition p6est.h:168
sc_mempool_t * user_data_pool
memory allocator for user data
Definition p6est.h:184
int mpirank
this process's MPI rank
Definition p6est.h:170
p4est_t * columns
2D description of column layout built from connectivity.
Definition p6est.h:178
p6est_connectivity_t * connectivity
topology of sheet, not owned.
Definition p6est.h:177
size_t data_size
size of per-quadrant p.user_data (see p2est_quadrant_t::p2est_quadrant_data::user_data)
Definition p6est.h:173
int mpisize
number of MPI processes
Definition p6est.h:169
p4est_gloidx_t * global_first_layer
first global quadrant index for each process and 1 beyond
Definition p6est.h:189
p4est_qcoord_t root_len
height of the domain
Definition p6est.h:191
int mpicomm_owned
whether this communicator is owned by the forest
Definition p6est.h:171
sc_mempool_t * layer_pool
memory allocator for temporary layers
Definition p6est.h:187
sc_array_t * layers
single array that stores p2est_quadrant_t layers within columns
Definition p6est.h:182
p4est_topidx_t which_tree
the tree containing the quadrant
Definition p6est.h:139
struct p2est_quadrant::p6est_quadrant_data::@12 piggy3
of ghost layers, store the tree and index in the owner's numbering
struct p2est_quadrant::p6est_quadrant_data::@11 piggy2
of transformed layers, store the original tree and the target tree
void * user_data
never changed by p4est
Definition p6est.h:136
long user_long
never changed by p4est
Definition p6est.h:137
int user_int
never changed by p4est
Definition p6est.h:138
struct p2est_quadrant::p6est_quadrant_data::@10 piggy1
of ghost layer, store the tree and owner rank