p4est  2.8.643-dbc7-dirty
p4est is a software library for parallel adaptive mesh refinement.
p8est_connectivity.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 
32 #ifndef P8EST_CONNECTIVITY_H
33 #define P8EST_CONNECTIVITY_H
34 
35 #include <sc_io.h>
36 #include <p4est_base.h>
37 
38 SC_EXTERN_C_BEGIN;
39 
41 #define P8EST_DIM 3
46 #define P8EST_FACES (2 * P8EST_DIM)
50 #define P8EST_CHILDREN 8
52 #define P8EST_HALF (P8EST_CHILDREN / 2)
54 #define P8EST_EDGES 12
56 #define P8EST_INSUL 27
57 
59 #define P8EST_ONLY_P8_LAND(x) && (x)
60 
62 #define P8EST_ONLY_P8_COMMA(x) , (x)
63 
65 #define P8EST_DIM_POW(a) ((a) * (a) * (a))
66 
67 /* size of face transformation encoding */
68 #define P8EST_FTRANSFORM 9
69 
71 #define P8EST_STRING "p8est"
72 
73 /* Increase this number whenever the on-disk format for
74  * p8est_connectivity, p8est, or any other 3D data structure changes.
75  * The format for reading and writing must be the same.
76  */
77 #define P8EST_ONDISK_FORMAT 0x3000009
78 
89 typedef enum
90 {
91  /* make sure to have different values 2D and 3D */
92  P8EST_CONNECT_SELF = 30,
93  P8EST_CONNECT_FACE = 31,
94  P8EST_CONNECT_EDGE = 32,
95  P8EST_CONNECT_CORNER = 33,
96  P8EST_CONNECT_FULL = P8EST_CONNECT_CORNER
97 }
99 
100 #ifdef P4EST_BACKWARD_DEALII
101 typedef p8est_connect_type_t p8est_balance_type_t;
102 #endif
103 
105 typedef enum
106 {
107  P8EST_CONN_ENCODE_NONE = SC_IO_ENCODE_NONE,
109 }
111 
117 
123 
173 typedef struct p8est_connectivity
174 {
184  double *vertices;
191  char *tree_to_attr;
195  int8_t *tree_to_face;
202  int8_t *edge_to_edge;
211 }
213 
219  conn);
220 
221 typedef struct
222 {
223  p4est_topidx_t ntree;
224  int8_t nedge, naxis[3], nflip, corners;
225 }
227 
228 typedef struct
229 {
230  int8_t iedge;
231  sc_array_t edge_transforms;
232 }
234 
235 typedef struct
236 {
237  p4est_topidx_t ntree;
238  int8_t ncorner;
239 }
241 
242 typedef struct
243 {
244  p4est_topidx_t icorner;
245  sc_array_t corner_transforms;
246 }
248 
250 typedef struct
251 {
254  int8_t index_self;
256  int8_t index_neighbor;
258  int8_t perm[P8EST_DIM];
261  int8_t sign[P8EST_DIM];
263  p4est_qcoord_t origin_self[P8EST_DIM];
265  p4est_qcoord_t origin_neighbor[P8EST_DIM];
268 }
270 
271 /* *INDENT-OFF* */
272 
280  (const p8est_neighbor_transform_t * nt,
281  const p4est_qcoord_t self_coords[P8EST_DIM],
282  p4est_qcoord_t neigh_coords[P8EST_DIM]);
283 
291  (const p8est_neighbor_transform_t * nt,
292  const p4est_qcoord_t neigh_coords[P8EST_DIM],
293  p4est_qcoord_t self_coords[P8EST_DIM]);
294 
295 void p8est_connectivity_get_neighbor_transforms
296  (p8est_connectivity_t *conn,
297  p4est_topidx_t tree_id,
298  p8est_connect_type_t boundary_type,
299  int boundary_index,
300  sc_array_t *neighbor_transform_array);
301 
302 /* *INDENT-ON* */
303 
305 extern const int p8est_face_corners[6][4];
306 
308 extern const int p8est_face_edges[6][4];
309 
311 extern const int p8est_face_dual[6];
312 
313 /* face corners */
314 
316 extern const int p8est_face_permutations[8][4];
317 
319 extern const int p8est_face_permutation_sets[3][4];
320 
323 extern const int p8est_face_permutation_refs[6][6];
324 
325 /* face edges */
326 
328 extern const int p8est_face_edge_permutations[8][4];
329 
331 extern const int p8est_face_edge_permutation_sets[3][4];
332 
334 extern const int p8est_edge_faces[12][2];
335 
337 extern const int p8est_edge_corners[12][2];
338 
341 extern const int p8est_edge_edge_corners[12][8];
342 
345 extern const int p8est_edge_face_corners[12][6][2];
346 
349 extern const int p8est_edge_face_edges[12][6];
350 
352 extern const int p8est_corner_faces[8][3];
353 
355 extern const int p8est_corner_edges[8][3];
356 
359 extern const int p8est_corner_face_corners[8][6];
360 
363 extern const int p8est_corner_edge_corners[8][12];
364 
366 extern const int p8est_child_edge_faces[8][12];
367 
369 extern const int p8est_child_corner_faces[8][8];
370 
372 extern const int p8est_child_corner_edges[8][8];
373 
386  (int c, int f, int nf, int set);
387 
397  (int fc, int f, int nf, int o);
398 
408  (int c, int f, int nf, int o);
409 
419  (int fe, int f, int nf, int o);
420 
430  (int e, int f, int nf, int o);
431 
438  (int ec, int o);
439 
449  (int c, int e, int ne, int o);
450 
462  p4est_topidx_t num_trees,
463  p4est_topidx_t num_edges,
464  p4est_topidx_t num_ett,
465  p4est_topidx_t num_corners,
466  p4est_topidx_t num_ctt);
467 
483  num_vertices,
484  p4est_topidx_t num_trees,
485  p4est_topidx_t num_edges,
486  p4est_topidx_t num_corners,
487  const double *vertices,
488  const p4est_topidx_t * ttv,
489  const p4est_topidx_t * ttt,
490  const int8_t * ttf,
491  const p4est_topidx_t * tte,
492  const p4est_topidx_t *
493  eoff,
494  const p4est_topidx_t * ett,
495  const int8_t * ete,
496  const p4est_topidx_t * ttc,
497  const p4est_topidx_t *
498  coff,
499  const p4est_topidx_t * ctt,
500  const int8_t * ctc);
501 
514  conn_in, int root,
515  sc_MPI_Comm comm);
516 
520  connectivity);
521 
529  size_t bytes_per_tree);
530 
535  connectivity);
536 
542  conn2);
543 
550  sc_io_sink_t * sink);
551 
559  code);
560 
566 int p8est_connectivity_save (const char *filename,
568  connectivity);
569 
575 
583 
590  size_t *bytes);
591 
595 
599 
605 
609 
617  int r_face,
618  int orientation);
619 
624 
629 
634  int periodic_a,
635  int periodic_b,
636  int periodic_c);
637 
644 
651 
667 
682 
694  int num_per_edge);
695 
714 void p8est_expand_face_transform (int iface, int nface,
715  int ftransform[]);
716 
727  connectivity,
728  p4est_topidx_t itree,
729  int iface, int ftransform[]);
730 
737  connectivity,
738  p4est_topidx_t itree,
739  int iedge,
740  p8est_edge_info_t * ei);
741 
748  connectivity,
749  p4est_topidx_t itree,
750  int icorner,
751  p8est_corner_info_t * ci);
752 
763 
770 
786  sc_array_t * perm,
787  int is_current_to_new);
788 
789 #ifdef P4EST_WITH_METIS
790 
813 void p8est_connectivity_reorder (sc_MPI_Comm comm, int k,
814  p8est_connectivity_t * conn,
815  p8est_connect_type_t ctype);
816 
837 sc_array_t *p8est_connectivity_reorder_newid (sc_MPI_Comm comm, int k,
839  conn,
841  ctype,
842  sc_array_t * newid);
843 
844 #endif /* P4EST_WITH_METIS */
845 
862  conn,
863  p4est_topidx_t tree_left,
864  p4est_topidx_t tree_right,
865  int face_left,
866  int face_right,
867  int orientation);
868 
880  conn1,
882  conn2);
883 
885 /*@unused@*/
886 static inline p8est_edge_transform_t *
887 p8est_edge_array_index (sc_array_t * array, size_t it)
888 {
889  P4EST_ASSERT (array->elem_size == sizeof (p8est_edge_transform_t));
890  P4EST_ASSERT (it < array->elem_count);
891 
892  return (p8est_edge_transform_t *) (array->array +
893  sizeof (p8est_edge_transform_t) * it);
894 }
895 
897 /*@unused@*/
898 static inline p8est_corner_transform_t *
899 p8est_corner_array_index (sc_array_t * array, size_t it)
900 {
901  P4EST_ASSERT (array->elem_size == sizeof (p8est_corner_transform_t));
902  P4EST_ASSERT (it < array->elem_count);
903 
904  return
905  (p8est_corner_transform_t *) (array->array +
906  sizeof (p8est_corner_transform_t) * it);
907 }
908 
1009  p4est_topidx_t *
1010  num_vertices,
1011  p4est_topidx_t *
1012  num_trees,
1013  double *vertices,
1014  p4est_topidx_t *
1015  tree_to_vertex);
1016 
1107 
1108 SC_EXTERN_C_END;
1109 
1110 #endif /* !P8EST_CONNECTIVITY_H */
General support types and functions.
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
const int p8est_face_edge_permutation_sets[3][4]
Store the 3 occurring sets of 4 permutations per face.
void p8est_connectivity_permute(p8est_connectivity_t *conn, sc_array_t *perm, int is_current_to_new)
p8est_connectivity_permute Given a permutation perm of the trees in a connectivity conn,...
const char * p8est_connect_type_string(p8est_connect_type_t btype)
Convert the p8est_connect_type_t into a const string.
const int p8est_edge_face_edges[12][6]
Store the face edge numbers 0..3 for the faces touching a tree edge.
void p8est_connectivity_set_attr(p8est_connectivity_t *conn, size_t bytes_per_tree)
Allocate or free the attribute fields in a connectivity.
p8est_connectivity_t * p8est_connectivity_new_periodic(void)
Create a connectivity structure for an all-periodic unit cube.
const int p8est_face_corners[6][4]
Store the corner numbers 0..7 for each tree face.
sc_array_t * p8est_connectivity_deflate(p8est_connectivity_t *conn, p8est_connectivity_encode_t code)
Allocate memory and store the connectivity information there.
const int p8est_face_permutation_sets[3][4]
Store the 3 occurring sets of 4 permutations per face.
void p8est_neighbor_transform_coordinates(const p8est_neighbor_transform_t *nt, const p4est_qcoord_t self_coords[P8EST_DIM], p4est_qcoord_t neigh_coords[P8EST_DIM])
Transform from self's coordinate system to neighbor's coordinate system.
void p8est_neighbor_transform_coordinates_reverse(const p8est_neighbor_transform_t *nt, const p4est_qcoord_t neigh_coords[P8EST_DIM], p4est_qcoord_t self_coords[P8EST_DIM])
Transform from neighbor's coordinate system to self's coordinate system.
const int p8est_face_dual[6]
Store the face numbers in the face neighbor's system.
p8est_connectivity_t * p8est_connectivity_new_twowrap(void)
Create a connectivity structure that contains two cubes where the two far ends are identified periodi...
p8est_connectivity_t * p8est_connectivity_new(p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, p4est_topidx_t num_ett, p4est_topidx_t num_corners, p4est_topidx_t num_ctt)
Allocate a connectivity structure.
p8est_connectivity_t * p8est_connectivity_read_inp(const char *filename)
Create a p4est connectivity from an ABAQUS input file.
p8est_connectivity_t * p8est_connectivity_new_copy(p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_edges, p4est_topidx_t num_corners, const double *vertices, const p4est_topidx_t *ttv, const p4est_topidx_t *ttt, const int8_t *ttf, const p4est_topidx_t *tte, const p4est_topidx_t *eoff, const p4est_topidx_t *ett, const int8_t *ete, const p4est_topidx_t *ttc, const p4est_topidx_t *coff, const p4est_topidx_t *ctt, const int8_t *ctc)
Allocate a connectivity structure and populate from constants.
p4est_topidx_t p8est_find_face_transform(p8est_connectivity_t *connectivity, p4est_topidx_t itree, int iface, int ftransform[])
Fill an array with the axis combination of a face neighbor transform.
p8est_connectivity_t * p8est_connectivity_new_twotrees(int l_face, int r_face, int orientation)
Create a connectivity structure for two trees being rotated w.r.t.
int p8est_connectivity_edge_neighbor_corner(int c, int e, int ne, int o)
Transform a corner across one of the adjacent edges into a neighbor tree.
const int p8est_corner_faces[8][3]
Store the face numbers 0..5 for each tree corner.
const int p8est_face_edges[6][4]
Store the edge numbers 0..12 for each tree face.
p8est_connectivity_t * p8est_connectivity_new_unitcube(void)
Create a connectivity structure for the unit cube.
p8est_connectivity_t * p8est_connectivity_new_byname(const char *name)
Create connectivity structure from predefined catalogue.
p8est_connectivity_t * p8est_connectivity_bcast(p8est_connectivity_t *conn_in, int root, sc_MPI_Comm comm)
Broadcast a connectivity structure that exists only on one process to all.
int p8est_connectivity_is_equal(p8est_connectivity_t *conn1, p8est_connectivity_t *conn2)
Check two connectivity structures for equality.
int p8est_connect_type_int(p8est_connect_type_t btype)
Convert the p8est_connect_type_t into a number.
p8est_connectivity_t * p8est_connectivity_inflate(sc_array_t *buffer)
Create new connectivity from a memory buffer.
size_t p8est_connectivity_memory_used(p8est_connectivity_t *conn)
Calculate memory usage of a connectivity structure.
void p8est_find_corner_transform(p8est_connectivity_t *connectivity, p4est_topidx_t itree, int icorner, p8est_corner_info_t *ci)
Fills an array with information about corner neighbors.
int p8est_connectivity_face_neighbor_corner(int c, int f, int nf, int o)
Transform a corner across one of the adjacent faces into a neighbor tree.
#define P8EST_DIM
The spatial dimension.
Definition: p8est_connectivity.h:41
p8est_connectivity_t * p8est_connectivity_new_twocubes(void)
Create a connectivity structure that contains two cubes.
const int p8est_edge_corners[12][2]
Store the corner numbers 0..8 for each tree edge.
const int p8est_edge_edge_corners[12][8]
Store the edge corner numbers 0..1 for the corners touching a tree edge or -1 if combination is inval...
int p8est_connectivity_read_inp_stream(FILE *stream, p4est_topidx_t *num_vertices, p4est_topidx_t *num_trees, double *vertices, p4est_topidx_t *tree_to_vertex)
Read an ABAQUS input file from a file stream.
const int p8est_child_edge_faces[8][12]
Store the faces for each child and edge, can be -1.
void p8est_expand_face_transform(int iface, int nface, int ftransform[])
Fill an array with the axis combination of a face neighbor transform.
p8est_connectivity_t * p8est_connectivity_source(sc_io_source_t *source)
Read connectivity from a source object.
void p8est_connectivity_destroy(p8est_connectivity_t *connectivity)
Destroy a connectivity structure.
p8est_connectivity_t * p8est_connectivity_new_shell(void)
Create a connectivity structure that builds a spherical shell.
const int p8est_child_corner_faces[8][8]
Store the faces for each child and corner, can be -1.
const int p8est_corner_face_corners[8][6]
Store the face corner numbers for the faces touching a tree corner.
const int p8est_corner_edges[8][3]
Store the edge numbers 0..11 for each tree corner.
p8est_connectivity_t * p8est_connectivity_new_rotwrap(void)
Create a connectivity structure for a mostly periodic unit cube.
void p8est_connectivity_join_faces(p8est_connectivity_t *conn, p4est_topidx_t tree_left, p4est_topidx_t tree_right, int face_left, int face_right, int orientation)
p8est_connectivity_join_faces This function takes an existing valid connectivity conn and modifies it...
int p8est_connectivity_face_neighbor_face_edge(int fe, int f, int nf, int o)
Transform a face-edge across one of the adjacent faces into a neighbor tree.
void p8est_connectivity_reduce(p8est_connectivity_t *conn)
Removes corner and edge information of a connectivity such that enough information is left to run p8e...
p8est_connectivity_t * p8est_connectivity_refine(p8est_connectivity_t *conn, int num_per_edge)
Uniformly refine a connectivity.
const int p8est_child_corner_edges[8][8]
Store the edges for each child and corner, can be -1.
p8est_connectivity_t * p8est_connectivity_new_torus(int nSegments)
Create a connectivity structure that builds a revolution torus.
p8est_connect_type_t
Characterize a type of adjacency.
Definition: p8est_connectivity.h:90
int p8est_connectivity_is_equivalent(p8est_connectivity_t *conn1, p8est_connectivity_t *conn2)
p8est_connectivity_is_equivalent This function compares two connectivities for equivalence: it return...
const int p8est_edge_faces[12][2]
Store the face numbers 0..5 adjacent to each tree edge.
const int p8est_face_permutations[8][4]
Store only the 8 out of 24 possible permutations that occur.
const int p8est_face_edge_permutations[8][4]
Store only the 8 out of 24 possible permutations that occur.
void p8est_connectivity_complete(p8est_connectivity_t *conn)
Internally connect a connectivity based on tree_to_vertex information.
const int p8est_edge_face_corners[12][6][2]
Store the face corner numbers 0..3 for the faces touching a tree edge.
p8est_connectivity_t * p8est_connectivity_new_rotcubes(void)
Create a connectivity structure that contains a few cubes.
int p8est_connectivity_face_neighbor_corner_set(int c, int f, int nf, int set)
Transform a corner across one of the adjacent faces into a neighbor tree.
int p8est_connectivity_is_valid(p8est_connectivity_t *connectivity)
Examine a connectivity structure.
int p8est_connectivity_face_neighbor_edge(int e, int f, int nf, int o)
Transform an edge across one of the adjacent faces into a neighbor tree.
int p8est_connectivity_sink(p8est_connectivity_t *conn, sc_io_sink_t *sink)
Write connectivity to a sink object.
p8est_connectivity_t * p8est_connectivity_new_brick(int m, int n, int p, int periodic_a, int periodic_b, int periodic_c)
An m by n by p array with periodicity in x, y, and z if periodic_a, periodic_b, and periodic_c are tr...
struct p8est_connectivity p8est_connectivity_t
This structure holds the 3D inter-tree connectivity information.
p8est_connectivity_encode_t
Typedef for serialization method.
Definition: p8est_connectivity.h:106
@ P8EST_CONN_ENCODE_LAST
Invalid entry to close the list.
Definition: p8est_connectivity.h:108
p8est_connectivity_t * p8est_connectivity_new_sphere(void)
Create a connectivity structure that builds a solid sphere.
int p8est_connectivity_face_neighbor_face_corner(int fc, int f, int nf, int o)
Transform a face corner across one of the adjacent faces into a neighbor tree.
void p8est_find_edge_transform(p8est_connectivity_t *connectivity, p4est_topidx_t itree, int iedge, p8est_edge_info_t *ei)
Fills an array with information about edge neighbors.
const int p8est_face_permutation_refs[6][6]
For each face combination store the permutation set.
const int p8est_corner_edge_corners[8][12]
Store the edge corner numbers for the edges touching a tree corner.
int p8est_connectivity_edge_neighbor_edge_corner(int ec, int o)
Transform an edge corner across one of the adjacent edges into a neighbor tree.
p8est_connectivity_t * p8est_connectivity_load(const char *filename, size_t *bytes)
Load a connectivity structure from disk.
int p8est_connectivity_save(const char *filename, p8est_connectivity_t *connectivity)
Save a connectivity structure to disk.
sc3_MPI_Comm_t sc_MPI_Comm
This structure holds the 3D inter-tree connectivity information.
Definition: p8est_connectivity.h:174
double * vertices
an array of size (3 * num_vertices)
Definition: p8est_connectivity.h:184
p4est_topidx_t num_corners
the number of corners that help define the topology
Definition: p8est_connectivity.h:181
p4est_topidx_t * tree_to_vertex
embed each tree into for e.g.
Definition: p8est_connectivity.h:186
int8_t * corner_to_corner
list of tree-corners that meet at a corner
Definition: p8est_connectivity.h:209
int8_t * edge_to_edge
list of tree-edges+orientations that meet at an edge (see description)
Definition: p8est_connectivity.h:202
p4est_topidx_t * tree_to_corner
(8 * num_trees) or NULL (see description)
Definition: p8est_connectivity.h:204
p4est_topidx_t * tree_to_edge
(12 * num_trees) or NULL (see description)
Definition: p8est_connectivity.h:197
char * tree_to_attr
not touched by p4est
Definition: p8est_connectivity.h:191
p4est_topidx_t * edge_to_tree
list of trees that meet at an edge
Definition: p8est_connectivity.h:201
p4est_topidx_t * ett_offset
edge to offset in edge_to_tree and edge_to_edge
Definition: p8est_connectivity.h:199
p4est_topidx_t num_vertices
the number of vertices that define the embedding of the forest (not the topology)
Definition: p8est_connectivity.h:175
size_t tree_attr_bytes
bytes per tree in tree_to_attr
Definition: p8est_connectivity.h:190
p4est_topidx_t * corner_to_tree
list of trees that meet at a corner
Definition: p8est_connectivity.h:208
p4est_topidx_t * ctt_offset
corner to offset in corner_to_tree and corner_to_corner
Definition: p8est_connectivity.h:206
int8_t * tree_to_face
(6 * num_trees) face to face+orientation (see description)
Definition: p8est_connectivity.h:195
p4est_topidx_t num_edges
the number of edges that help define the topology
Definition: p8est_connectivity.h:179
p4est_topidx_t * tree_to_tree
(6 * num_trees) neighbors across faces
Definition: p8est_connectivity.h:193
p4est_topidx_t num_trees
the number of trees
Definition: p8est_connectivity.h:178
Definition: p8est_connectivity.h:243
Definition: p8est_connectivity.h:236
Definition: p8est_connectivity.h:229
Definition: p8est_connectivity.h:222
Generic interface for transformations beteen a tree and any of its neighbors.
Definition: p8est_connectivity.h:251
p4est_topidx_t neighbor
neighbor tree index
Definition: p8est_connectivity.h:253
int8_t index_self
index of interface from self's perspective
Definition: p8est_connectivity.h:254
p8est_connect_type_t neighbor_type
type of connection to neighbor
Definition: p8est_connectivity.h:252
int8_t index_neighbor
index of interface from neighbor's perspective
Definition: p8est_connectivity.h:256
size_t elem_size
char * array