p4est  2.8.643-dbc7-dirty
p4est is a software library for parallel adaptive mesh refinement.
p8est_extended.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 /********************************************************************
26  * IMPORTANT NOTE *
27  * *
28  * These interfaces are intended for those who like finer control. *
29  * The API offers extended versions of some basic p4est functions. *
30  * The API may change without notice. *
31  ********************************************************************/
32 
40 #ifndef P8EST_EXTENDED_H
41 #define P8EST_EXTENDED_H
42 
43 #include <p8est.h>
44 #include <p8est_mesh.h>
45 #include <p8est_iterate.h>
46 #include <p8est_lnodes.h>
47 #include <sc_uint128.h>
48 #include <p8est_io.h>
49 
50 SC_EXTERN_C_BEGIN;
51 
58 
59 /* Data pertaining to selecting, inspecting, and profiling algorithms.
60  * A pointer to this structure is hooked into the p8est main structure.
61  *
62  * TODO: Describe the purpose of various switches, counters, and timings.
63  *
64  * The balance_ranges and balance_notify* times are collected
65  * whenever an inspect structure is present in p8est.
66  */
68 {
79  size_t balance_A_count_in;
80  size_t balance_A_count_out;
81  size_t balance_comm_sent;
82  size_t balance_comm_nzpeers;
83  size_t balance_B_count_in;
84  size_t balance_B_count_out;
85  size_t balance_zero_sends[2], balance_zero_receives[2];
86  double balance_A;
87  double balance_comm;
88  double balance_B;
89  double balance_ranges;
90  double balance_notify;
93  int use_B;
94 };
95 
115 typedef void (*p8est_replace_t) (p8est_t * p8est,
116  p4est_topidx_t which_tree,
117  int num_outgoing,
118  p8est_quadrant_t * outgoing[],
119  int num_incoming,
120  p8est_quadrant_t * incoming[]);
121 
130  const p8est_lid_t * b);
131 
139  const p8est_lid_t * b);
140 
147 void p8est_lid_init (p8est_lid_t * input, uint64_t high,
148  uint64_t low);
149 
154 
159 
163 void p8est_lid_set_uint64 (p8est_lid_t * input, uint64_t u);
164 
173 int p8est_lid_chk_bit (const p8est_lid_t * input,
174  int bit_number);
175 
183 void p8est_lid_set_bit (p8est_lid_t * input, int bit_number);
184 
192 void p8est_lid_copy (const p8est_lid_t * input,
193  p8est_lid_t * output);
194 
203 void p8est_lid_add (const p8est_lid_t * a,
204  const p8est_lid_t * b,
205  p8est_lid_t * result);
206 
216 void p8est_lid_sub (const p8est_lid_t * a,
217  const p8est_lid_t * b,
218  p8est_lid_t * result);
219 
228  p8est_lid_t * result);
229 
240  const p8est_lid_t * b,
241  p8est_lid_t * result);
242 
253  const p8est_lid_t * b,
254  p8est_lid_t * result);
255 
266 void p8est_lid_shift_right (const p8est_lid_t * input,
267  unsigned shift_count,
268  p8est_lid_t * result);
269 
280 void p8est_lid_shift_left (const p8est_lid_t * input,
281  unsigned shift_count,
282  p8est_lid_t * result);
283 
291  const p8est_lid_t * b);
292 
301  const p8est_lid_t * b);
302 
310  const p8est_lid_t * b);
311 
319  const p8est_lid_t * b);
338  quadrant, int level,
339  p8est_lid_t * id);
340 
349  quadrant, int level,
350  const p8est_lid_t * id);
351 
383  p8est_connectivity_t * connectivity,
384  p4est_locidx_t min_quadrants,
385  int min_level, int fill_uniform,
386  size_t data_size, p8est_init_t init_fn,
387  void *user_pointer);
388 
402  p8est_ghost_t * ghost,
403  int compute_tree_index,
404  int compute_level_lists,
405  p8est_connect_type_t btype);
406 
421 p8est_t *p8est_copy_ext (p8est_t * input, int copy_data,
422  int duplicate_mpicomm);
423 
446  int refine_recursive, int maxlevel,
447  p8est_refine_t refine_fn,
448  p8est_init_t init_fn,
449  p8est_replace_t replace_fn);
450 
472 void p8est_coarsen_ext (p8est_t * p8est, int coarsen_recursive,
473  int callback_orphans,
474  p8est_coarsen_t coarsen_fn,
475  p8est_init_t init_fn,
476  p8est_replace_t replace_fn);
477 
490  p8est_connect_type_t btype,
491  p8est_init_t init_fn,
492  p8est_replace_t replace_fn);
493 
494 void p8est_balance_subtree_ext (p8est_t * p8est,
495  p8est_connect_type_t btype,
496  p4est_topidx_t which_tree,
497  p8est_init_t init_fn,
498  p8est_replace_t replace_fn);
499 
517  int partition_for_coarsening,
518  p8est_weight_t weight_fn);
519 
528  num_quadrants_in_proc);
529 
536  p8est_ghost_t * ghost_layer,
537  void *user_data,
538  p8est_iter_volume_t iter_volume,
539  p8est_iter_face_t iter_face,
540  p8est_iter_edge_t iter_edge,
541  p8est_iter_corner_t iter_corner,
542  int remote);
543 
561 void p8est_save_ext (const char *filename, p8est_t * p8est,
562  int save_data, int save_partition);
563 
585 p8est_t *p8est_load_ext (const char *filename, sc_MPI_Comm mpicomm,
586  size_t data_size, int load_data,
587  int autopartition, int broadcasthead,
588  void *user_pointer,
589  p8est_connectivity_t ** connectivity);
590 
594 p8est_t *p8est_source_ext (sc_io_source_t * src,
595  sc_MPI_Comm mpicomm, size_t data_size,
596  int load_data, int autopartition,
597  int broadcasthead, void *user_pointer,
598  p8est_connectivity_t ** connectivity);
599 
610  const char *filename,
611  char *user_string,
613  global_num_quadrants,
614  int *errcode);
615 
625  p4est_gloidx_t * gfq,
626  size_t quadrant_size,
627  sc_array_t * quadrant_data,
628  char *user_string,
629  int *errcode);
630 
674  p8est_ghost_t ** ghost,
675  p8est_lnodes_t ** lnodes,
676  p8est_connect_type_t ctype,
677  int overlap,
679  first_local_quad,
680  sc_array_t * out_points_per_dim,
681  sc_array_t * out_cone_sizes,
682  sc_array_t * out_cones,
683  sc_array_t *
684  out_cone_orientations,
685  sc_array_t * out_vertex_coords,
686  sc_array_t * out_children,
687  sc_array_t * out_parents,
688  sc_array_t * out_childids,
689  sc_array_t * out_leaves,
690  sc_array_t * out_remotes,
691  int custom_numbering);
692 
693 SC_EXTERN_C_END;
694 
695 #endif /* !P8EST_EXTENDED_H */
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 top-level 3D p8est interface.
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:229
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:219
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:209
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:199
p8est_connect_type_t
Characterize a type of adjacency.
Definition: p8est_connectivity.h:90
void p8est_lid_bitwise_and_inplace(p8est_lid_t *a, const p8est_lid_t *b)
Calculates the bitwise and of the uint128_t a and the uint128_t b.
int p8est_lid_chk_bit(const p8est_lid_t *input, int bit_number)
Returns the bit_number-th bit of input.
void p8est_coarsen_ext(p8est_t *p8est, int coarsen_recursive, int callback_orphans, p8est_coarsen_t coarsen_fn, p8est_init_t init_fn, p8est_replace_t replace_fn)
Coarsen a forest.
void p8est_quadrant_linear_id_ext128(const p8est_quadrant_t *quadrant, int level, p8est_lid_t *id)
Computes the linear position as p8est_lid_t of a quadrant in a uniform grid.
void p8est_refine_ext(p8est_t *p8est, int refine_recursive, int maxlevel, p8est_refine_t refine_fn, p8est_init_t init_fn, p8est_replace_t replace_fn)
Refine a forest with a bounded refinement level and a replace option.
void p8est_get_plex_data_ext(p8est_t *p8est, p8est_ghost_t **ghost, p8est_lnodes_t **lnodes, p8est_connect_type_t ctype, int overlap, p4est_locidx_t *first_local_quad, sc_array_t *out_points_per_dim, sc_array_t *out_cone_sizes, sc_array_t *out_cones, sc_array_t *out_cone_orientations, sc_array_t *out_vertex_coords, sc_array_t *out_children, sc_array_t *out_parents, sc_array_t *out_childids, sc_array_t *out_leaves, sc_array_t *out_remotes, int custom_numbering)
Create the data necessary to create a PETsc DMPLEX representation of a forest, as well as the accompa...
void p8est_lid_bitwise_or_inplace(p8est_lid_t *a, const p8est_lid_t *b)
Calculates the bitwise or of the uint128_t a and the uint128_t b.
p4est_gloidx_t p8est_partition_ext(p8est_t *p8est, int partition_for_coarsening, p8est_weight_t weight_fn)
Repartition the forest.
void p8est_quadrant_set_morton_ext128(p8est_quadrant_t *quadrant, int level, const p8est_lid_t *id)
Set quadrant Morton indices based on linear position given as p8est_lid_t in uniform grid.
void p8est_lid_set_bit(p8est_lid_t *input, int bit_number)
Sets the exponent-th bit of input to one.
void p8est_lid_set_uint64(p8est_lid_t *input, uint64_t u)
Initializes a linear index to an unsigned 64 bit integer.
sc_uint128_t p8est_lid_t
A datatype to handle the linear id in 3D.
Definition: p8est_extended.h:57
int p8est_lid_is_equal(const p8est_lid_t *a, const p8est_lid_t *b)
Checks if the p8est_lid_t a and the p8est_lid_t b are equal.
void p8est_lid_init(p8est_lid_t *input, uint64_t high, uint64_t low)
Initializes a linear index to a given value.
p8est_file_context_t * p8est_file_read_field_ext(p8est_file_context_t *fc, p4est_gloidx_t *gfq, size_t quadrant_size, sc_array_t *quadrant_data, char *user_string, int *errcode)
Read a data field and specify the partition for reading in parallel.
p8est_t * p8est_source_ext(sc_io_source_t *src, sc_MPI_Comm mpicomm, size_t data_size, int load_data, int autopartition, int broadcasthead, void *user_pointer, p8est_connectivity_t **connectivity)
The same as p8est_load_ext, but reading the connectivity/p8est from an open sc_io_source_t stream.
void p8est_lid_bitwise_and(const p8est_lid_t *a, const p8est_lid_t *b, p8est_lid_t *result)
Calculates the bitwise and of the uint128_t a and the uint128_t b.
void p8est_lid_sub(const p8est_lid_t *a, const p8est_lid_t *b, p8est_lid_t *result)
Substracts the p8est_lid_t b from the p8est_lid_t a.
p8est_t * p8est_load_ext(const char *filename, sc_MPI_Comm mpicomm, size_t data_size, int load_data, int autopartition, int broadcasthead, void *user_pointer, p8est_connectivity_t **connectivity)
Load the complete connectivity/p4est structure from disk.
p8est_t * p8est_copy_ext(p8est_t *input, int copy_data, int duplicate_mpicomm)
Make a deep copy of a p8est.
p4est_gloidx_t p8est_partition_for_coarsening(p8est_t *p8est, p4est_locidx_t *num_quadrants_in_proc)
Correct partition to allow one level of coarsening.
void p8est_lid_shift_right(const p8est_lid_t *input, unsigned shift_count, p8est_lid_t *result)
Calculates the bit right shift of uint128_t input by shift_count bits.
void p8est_save_ext(const char *filename, p8est_t *p8est, int save_data, int save_partition)
Save the complete connectivity/p8est data to disk.
void p8est_lid_shift_left(const p8est_lid_t *input, unsigned shift_count, p8est_lid_t *result)
Calculates the bit left shift of uint128_t input by shift_count bits.
p8est_t * p8est_new_ext(sc_MPI_Comm mpicomm, p8est_connectivity_t *connectivity, p4est_locidx_t min_quadrants, int min_level, int fill_uniform, size_t data_size, p8est_init_t init_fn, void *user_pointer)
Create a new forest.
void p8est_iterate_ext(p8est_t *p8est, p8est_ghost_t *ghost_layer, void *user_data, p8est_iter_volume_t iter_volume, p8est_iter_face_t iter_face, p8est_iter_edge_t iter_edge, p8est_iter_corner_t iter_corner, int remote)
p8est_iterate_ext adds the option remote: if this is false, then it is the same as p8est_iterate; if ...
void p8est_lid_add_inplace(p8est_lid_t *a, const p8est_lid_t *b)
Adds the p8est_lid_t b to the p8est_lid_t a.
void p8est_lid_set_zero(p8est_lid_t *input)
Initializes a linear index to zero.
void p8est_lid_set_one(p8est_lid_t *input)
Initializes a linear index to one.
void p8est_lid_copy(const p8est_lid_t *input, p8est_lid_t *output)
Copies an initialized p8est_lid_t to a p8est_lid_t.
void(* p8est_replace_t)(p8est_t *p8est, p4est_topidx_t which_tree, int num_outgoing, p8est_quadrant_t *outgoing[], int num_incoming, p8est_quadrant_t *incoming[])
Callback function prototype to replace one set of quadrants with another.
Definition: p8est_extended.h:115
void p8est_lid_sub_inplace(p8est_lid_t *a, const p8est_lid_t *b)
Substracts the uint128_t b from the uint128_t a.
void p8est_lid_add(const p8est_lid_t *a, const p8est_lid_t *b, p8est_lid_t *result)
Adds the uint128_t b to the uint128_t a.
p8est_mesh_t * p8est_mesh_new_ext(p8est_t *p4est, p8est_ghost_t *ghost, int compute_tree_index, int compute_level_lists, p8est_connect_type_t btype)
Create a new mesh.
void p8est_lid_bitwise_neg(const p8est_lid_t *a, p8est_lid_t *result)
Calculates the bitwise negation of the uint128_t a.
void p8est_balance_ext(p8est_t *p8est, p8est_connect_type_t btype, p8est_init_t init_fn, p8est_replace_t replace_fn)
2:1 balance the size differences of neighboring elements in a forest.
int p8est_lid_compare(const p8est_lid_t *a, const p8est_lid_t *b)
Compare the p8est_lid_t a and the p8est_lid_t b.
p8est_file_context_t * p8est_file_open_read_ext(sc_MPI_Comm mpicomm, const char *filename, char *user_string, p4est_gloidx_t *global_num_quadrants, int *errcode)
Open a file for reading without knowing the p4est that is associated with the mesh-related data in th...
void p8est_lid_bitwise_or(const p8est_lid_t *a, const p8est_lid_t *b, p8est_lid_t *result)
Calculates the bitwise or of the uint128_t a and b.
Provide functions to serialize/deserialize a forest.
struct p8est_file_context p8est_file_context_t
p8est data file format All p4est data files have 64 bytes file header section at the beginning of the...
Definition: p8est_io.h:178
Iteration over mesh topology via callbacks.
void(* p8est_iter_edge_t)(p8est_iter_edge_info_t *info, void *user_data)
The prototype for a function that p8est_iterate will execute wherever the edge is an edge of all quad...
Definition: p8est_iterate.h:218
void(* p8est_iter_corner_t)(p8est_iter_corner_info_t *info, void *user_data)
The prototype for a function that p8est_iterate will execute wherever the corner is a corner for all ...
Definition: p8est_iterate.h:274
void(* p8est_iter_volume_t)(p8est_iter_volume_info_t *info, void *user_data)
The prototype for a function that p8est_iterate() will execute at every quadrant local to the current...
Definition: p8est_iterate.h:63
void(* p8est_iter_face_t)(p8est_iter_face_info_t *info, void *user_data)
The prototype for a function that p8est_iterate() will execute wherever two quadrants share a face: t...
Definition: p8est_iterate.h:137
forest topology in a conventional mesh format
sc3_MPI_Comm_t sc_MPI_Comm
The p4est forest datatype.
Definition: p4est.h:136
This structure holds the 3D inter-tree connectivity information.
Definition: p8est_connectivity.h:174
quadrants that neighbor the local domain
Definition: p8est_ghost.h:41
Definition: p8est_extended.h:68
int use_balance_verify
Verify sc_ranges and/or sc_notify as applicable.
Definition: p8est_extended.h:76
double balance_ranges
time spent in sc_ranges
Definition: p8est_extended.h:89
double balance_notify_allgather
time spent in sc_notify_allgather
Definition: p8est_extended.h:92
int use_balance_ranges_notify
If true, call both sc_ranges and sc_notify and verify consistency.
Definition: p8est_extended.h:74
int use_balance_ranges
Use sc_ranges to determine the asymmetric communication pattern.
Definition: p8est_extended.h:71
double balance_notify
time spent in sc_notify
Definition: p8est_extended.h:90
int balance_max_ranges
If positive and smaller than p8est_num ranges, overrides it.
Definition: p8est_extended.h:78
Store a parallel numbering of Lobatto points of a given degree > 0.
Definition: p8est_lnodes.h:113
This structure contains complete mesh information on a 2:1 balanced forest.
Definition: p8est_mesh.h:135
The 3D quadrant (i.e., octant) datatype.
Definition: p8est.h:68
The p8est forest datatype.
Definition: p8est.h:132