p4est  2.8.643-dbc7-dirty
p4est is a software library for parallel adaptive mesh refinement.
p4est_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 P4EST_EXTENDED_H
41 #define P4EST_EXTENDED_H
42 
43 #include <p4est.h>
44 #include <p4est_mesh.h>
45 #include <p4est_iterate.h>
46 #include <p4est_lnodes.h>
47 #include <p4est_io.h>
48 
49 SC_EXTERN_C_BEGIN;
50 
52 typedef uint64_t p4est_lid_t;
53 
61 /* TODO: Describe the purpose of various switches, counters, and timings. */
63 {
74  size_t balance_A_count_in;
75  size_t balance_A_count_out;
76  size_t balance_comm_sent;
77  size_t balance_comm_nzpeers;
78  size_t balance_B_count_in;
79  size_t balance_B_count_out;
80  size_t balance_zero_sends[2], balance_zero_receives[2];
81  double balance_A;
82  double balance_comm;
83  double balance_B;
84  double balance_ranges;
85  double balance_notify;
88  int use_B;
89 };
90 
110 typedef void (*p4est_replace_t) (p4est_t * p4est,
111  p4est_topidx_t which_tree,
112  int num_outgoing,
113  p4est_quadrant_t * outgoing[],
114  int num_incoming,
115  p4est_quadrant_t * incoming[]);
116 
125  const p4est_lid_t * b);
126 
134  const p4est_lid_t * b);
135 
142 void p4est_lid_init (p4est_lid_t * input, uint64_t high,
143  uint64_t low);
144 
149 
154 
158 void p4est_lid_set_uint64 (p4est_lid_t * input, uint64_t u);
159 
168 int p4est_lid_chk_bit (const p4est_lid_t * input,
169  int bit_number);
170 
178 void p4est_lid_set_bit (p4est_lid_t * input, int bit_number);
179 
187 void p4est_lid_copy (const p4est_lid_t * input,
188  p4est_lid_t * output);
189 
198 void p4est_lid_add (const p4est_lid_t * a,
199  const p4est_lid_t * b,
200  p4est_lid_t * result);
201 
211 void p4est_lid_sub (const p4est_lid_t * a,
212  const p4est_lid_t * b,
213  p4est_lid_t * result);
214 
223  p4est_lid_t * result);
224 
235  const p4est_lid_t * b,
236  p4est_lid_t * result);
237 
248  const p4est_lid_t * b,
249  p4est_lid_t * result);
250 
261 void p4est_lid_shift_right (const p4est_lid_t * input,
262  unsigned shift_count,
263  p4est_lid_t * result);
264 
275 void p4est_lid_shift_left (const p4est_lid_t * input,
276  unsigned shift_count,
277  p4est_lid_t * result);
278 
286  const p4est_lid_t * b);
287 
296  const p4est_lid_t * b);
297 
305  const p4est_lid_t * b);
306 
314  const p4est_lid_t * b);
315 
334  quadrant, int level,
335  p4est_lid_t * id);
336 
345  quadrant, int level,
346  const p4est_lid_t * id);
347 
379  p4est_connectivity_t * connectivity,
380  p4est_locidx_t min_quadrants,
381  int min_level, int fill_uniform,
382  size_t data_size, p4est_init_t init_fn,
383  void *user_pointer);
384 
398  p4est_ghost_t * ghost,
399  int compute_tree_index,
400  int compute_level_lists,
401  p4est_connect_type_t btype);
402 
417 p4est_t *p4est_copy_ext (p4est_t * input, int copy_data,
418  int duplicate_mpicomm);
419 
442  int refine_recursive, int maxlevel,
443  p4est_refine_t refine_fn,
444  p4est_init_t init_fn,
445  p4est_replace_t replace_fn);
446 
468 void p4est_coarsen_ext (p4est_t * p4est, int coarsen_recursive,
469  int callback_orphans,
470  p4est_coarsen_t coarsen_fn,
471  p4est_init_t init_fn,
472  p4est_replace_t replace_fn);
473 
486  p4est_connect_type_t btype,
487  p4est_init_t init_fn,
488  p4est_replace_t replace_fn);
489 
490 void p4est_balance_subtree_ext (p4est_t * p4est,
491  p4est_connect_type_t btype,
492  p4est_topidx_t which_tree,
493  p4est_init_t init_fn,
494  p4est_replace_t replace_fn);
495 
513  int partition_for_coarsening,
514  p4est_weight_t weight_fn);
515 
524  num_quadrants_in_proc);
525 
531  p4est_ghost_t * ghost_layer,
532  void *user_data,
533  p4est_iter_volume_t iter_volume,
534  p4est_iter_face_t iter_face,
535  p4est_iter_corner_t iter_corner,
536  int remote);
537 
555 void p4est_save_ext (const char *filename, p4est_t * p4est,
556  int save_data, int save_partition);
557 
579 p4est_t *p4est_load_ext (const char *filename, sc_MPI_Comm mpicomm,
580  size_t data_size, int load_data,
581  int autopartition, int broadcasthead,
582  void *user_pointer,
583  p4est_connectivity_t ** connectivity);
584 
588 p4est_t *p4est_source_ext (sc_io_source_t * src,
589  sc_MPI_Comm mpicomm, size_t data_size,
590  int load_data, int autopartition,
591  int broadcasthead, void *user_pointer,
592  p4est_connectivity_t ** connectivity);
593 
604  const char *filename,
605  char *user_string,
607  global_num_quadrants,
608  int *errcode);
609 
619  p4est_gloidx_t * gfq,
620  size_t quadrant_size,
621  sc_array_t * quadrant_data,
622  char *user_string,
623  int *errcode);
624 
668  p4est_ghost_t ** ghost,
669  p4est_lnodes_t ** lnodes,
670  p4est_connect_type_t ctype,
671  int overlap,
673  first_local_quad,
674  sc_array_t * out_points_per_dim,
675  sc_array_t * out_cone_sizes,
676  sc_array_t * out_cones,
677  sc_array_t *
678  out_cone_orientations,
679  sc_array_t * out_vertex_coords,
680  sc_array_t * out_children,
681  sc_array_t * out_parents,
682  sc_array_t * out_childids,
683  sc_array_t * out_leaves,
684  sc_array_t * out_remotes,
685  int custom_numbering);
686 
687 SC_EXTERN_C_END;
688 
689 #endif /* !P4EST_EXTENDED_H */
The top-level 2D p4est interface.
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:223
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:203
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:233
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:213
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
p4est_connect_type_t
Characterize a type of adjacency.
Definition: p4est_connectivity.h:88
void p4est_lid_bitwise_and(const p4est_lid_t *a, const p4est_lid_t *b, p4est_lid_t *result)
Calculates the bitwise and of the uint128_t a and the uint128_t b.
void p4est_lid_sub(const p4est_lid_t *a, const p4est_lid_t *b, p4est_lid_t *result)
Substracts the p4est_lid_t b from the p4est_lid_t a.
void p4est_get_plex_data_ext(p4est_t *p4est, p4est_ghost_t **ghost, p4est_lnodes_t **lnodes, p4est_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 p4est_coarsen_ext(p4est_t *p4est, int coarsen_recursive, int callback_orphans, p4est_coarsen_t coarsen_fn, p4est_init_t init_fn, p4est_replace_t replace_fn)
Coarsen a forest.
void p4est_lid_bitwise_and_inplace(p4est_lid_t *a, const p4est_lid_t *b)
Calculates the bitwise and of the uint128_t a and the uint128_t b.
p4est_gloidx_t p4est_partition_ext(p4est_t *p4est, int partition_for_coarsening, p4est_weight_t weight_fn)
Repartition the forest.
void p4est_lid_shift_left(const p4est_lid_t *input, unsigned shift_count, p4est_lid_t *result)
Calculates the bit left shift of uint128_t input by shift_count bits.
int p4est_lid_chk_bit(const p4est_lid_t *input, int bit_number)
Returns the bit_number-th bit of input.
void(* p4est_replace_t)(p4est_t *p4est, p4est_topidx_t which_tree, int num_outgoing, p4est_quadrant_t *outgoing[], int num_incoming, p4est_quadrant_t *incoming[])
Callback function prototype to replace one set of quadrants with another.
Definition: p4est_extended.h:110
void p4est_lid_set_zero(p4est_lid_t *input)
Initializes a linear index to zero.
p4est_t * p4est_load_ext(const char *filename, sc_MPI_Comm mpicomm, size_t data_size, int load_data, int autopartition, int broadcasthead, void *user_pointer, p4est_connectivity_t **connectivity)
Load the complete connectivity/p4est structure from disk.
p4est_file_context_t * p4est_file_read_field_ext(p4est_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.
void p4est_quadrant_set_morton_ext128(p4est_quadrant_t *quadrant, int level, const p4est_lid_t *id)
Set quadrant Morton indices based on linear position given as p4est_lid_t in uniform grid.
void p4est_lid_copy(const p4est_lid_t *input, p4est_lid_t *output)
Copies an initialized p4est_lid_t to a p4est_lid_t.
void p4est_balance_ext(p4est_t *p4est, p4est_connect_type_t btype, p4est_init_t init_fn, p4est_replace_t replace_fn)
2:1 balance the size differences of neighboring elements in a forest.
void p4est_lid_set_one(p4est_lid_t *input)
Initializes a linear index to one.
void p4est_lid_add(const p4est_lid_t *a, const p4est_lid_t *b, p4est_lid_t *result)
Adds the uint128_t b to the uint128_t a.
int p4est_lid_is_equal(const p4est_lid_t *a, const p4est_lid_t *b)
Checks if the p4est_lid_t a and the p4est_lid_t b are equal.
void p4est_lid_init(p4est_lid_t *input, uint64_t high, uint64_t low)
Initializes an unsigned 64 bit integer.
void p4est_lid_add_inplace(p4est_lid_t *a, const p4est_lid_t *b)
Adds the p4est_lid_t b to the p4est_lid_t a.
void p4est_lid_bitwise_or_inplace(p4est_lid_t *a, const p4est_lid_t *b)
Calculates the bitwise or of the uint128_t a and the uint128_t b.
p4est_mesh_t * p4est_mesh_new_ext(p4est_t *p4est, p4est_ghost_t *ghost, int compute_tree_index, int compute_level_lists, p4est_connect_type_t btype)
Create a new mesh.
p4est_file_context_t * p4est_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...
uint64_t p4est_lid_t
A datatype to handle the linear id in 2D.
Definition: p4est_extended.h:52
void p4est_lid_bitwise_or(const p4est_lid_t *a, const p4est_lid_t *b, p4est_lid_t *result)
Calculates the bitwise or of the uint128_t a and b.
void p4est_refine_ext(p4est_t *p4est, int refine_recursive, int maxlevel, p4est_refine_t refine_fn, p4est_init_t init_fn, p4est_replace_t replace_fn)
Refine a forest with a bounded refinement level and a replace option.
p4est_t * p4est_new_ext(sc_MPI_Comm mpicomm, p4est_connectivity_t *connectivity, p4est_locidx_t min_quadrants, int min_level, int fill_uniform, size_t data_size, p4est_init_t init_fn, void *user_pointer)
Create a new forest.
p4est_gloidx_t p4est_partition_for_coarsening(p4est_t *p4est, p4est_locidx_t *num_quadrants_in_proc)
Correct partition to allow one level of coarsening.
int p4est_lid_compare(const p4est_lid_t *a, const p4est_lid_t *b)
Compare the p4est_lid_t a and the p4est_lid_t b.
void p4est_lid_set_bit(p4est_lid_t *input, int bit_number)
Sets the exponent-th bit of a to one.
p4est_t * p4est_copy_ext(p4est_t *input, int copy_data, int duplicate_mpicomm)
Make a deep copy of a p4est.
void p4est_save_ext(const char *filename, p4est_t *p4est, int save_data, int save_partition)
Save the complete connectivity/p4est data to disk.
void p4est_lid_shift_right(const p4est_lid_t *input, unsigned shift_count, p4est_lid_t *result)
Calculates the bit right shift of uint128_t input by shift_count bits.
void p4est_iterate_ext(p4est_t *p4est, p4est_ghost_t *ghost_layer, void *user_data, p4est_iter_volume_t iter_volume, p4est_iter_face_t iter_face, p4est_iter_corner_t iter_corner, int remote)
p4est_iterate_ext adds the option remote: if this is false, then it is the same as p4est_iterate; if ...
void p4est_quadrant_linear_id_ext128(const p4est_quadrant_t *quadrant, int level, p4est_lid_t *id)
Computes the linear position as p4est_lid_t of a quadrant in a uniform grid.
void p4est_lid_set_uint64(p4est_lid_t *input, uint64_t u)
Initializes a linear index to an unsigned 64 bit integer.
void p4est_lid_bitwise_neg(const p4est_lid_t *a, p4est_lid_t *result)
Calculates the bitwise negation of the uint128_t a.
void p4est_lid_sub_inplace(p4est_lid_t *a, const p4est_lid_t *b)
Substracts the uint128_t b from the uint128_t a.
p4est_t * p4est_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, p4est_connectivity_t **connectivity)
The same as p4est_load_ext, but reading the connectivity/p4est from an open sc_io_source_t stream.
Provide functions to serialize/deserialize a forest.
struct p4est_file_context p4est_file_context_t
p4est data file format All p4est data files have 64 bytes file header section at the beginning of the...
Definition: p4est_io.h:178
Iteration over mesh topology via callbacks.
void(* p4est_iter_corner_t)(p4est_iter_corner_info_t *info, void *user_data)
The prototype for a function that p4est_iterate will execute wherever quadrants meet at a conformal c...
Definition: p4est_iterate.h:195
void(* p4est_iter_volume_t)(p4est_iter_volume_info_t *info, void *user_data)
The prototype for a function that p4est_iterate will execute at every quadrant local to the current p...
Definition: p4est_iterate.h:63
void(* p4est_iter_face_t)(p4est_iter_face_info_t *info, void *user_data)
The prototype for a function that p4est_iterate will execute wherever two quadrants share a face: the...
Definition: p4est_iterate.h:139
forest topology in a conventional mesh format
sc3_MPI_Comm_t sc_MPI_Comm
This structure holds the 2D inter-tree connectivity information.
Definition: p4est_connectivity.h:153
quadrants that neighbor the local domain
Definition: p4est_ghost.h:41
Data pertaining to selecting, inspecting, and profiling algorithms.
Definition: p4est_extended.h:63
double balance_notify
time spent in sc_notify
Definition: p4est_extended.h:85
double balance_notify_allgather
time spent in sc_notify_allgather
Definition: p4est_extended.h:87
int balance_max_ranges
If positive and smaller than p4est_num ranges, overrides it.
Definition: p4est_extended.h:73
int use_balance_ranges_notify
If true, call both sc_ranges and sc_notify and verify consistency.
Definition: p4est_extended.h:69
double balance_ranges
time spent in sc_ranges
Definition: p4est_extended.h:84
int use_balance_ranges
Use sc_ranges to determine the asymmetric communication pattern.
Definition: p4est_extended.h:66
int use_balance_verify
Verify sc_ranges and/or sc_notify as applicable.
Definition: p4est_extended.h:71
Store a parallel numbering of Lobatto points of a given degree > 0.
Definition: p4est_lnodes.h:133
This structure contains complete mesh information on a 2:1 balanced forest.
Definition: p4est_mesh.h:101
The 2D quadrant datatype.
Definition: p4est.h:72
The p4est forest datatype.
Definition: p4est.h:136