p4est  1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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  Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac
8 
9  p4est is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13 
14  p4est is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with p4est; if not, write to the Free Software Foundation, Inc.,
21  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 */
23 
31 #ifndef P8EST_CONNECTIVITY_H
32 #define P8EST_CONNECTIVITY_H
33 
34 #include <sc_io.h>
35 #include <p4est_base.h>
36 
37 SC_EXTERN_C_BEGIN;
38 
40 #define P8EST_DIM 3
41 
45 #define P8EST_FACES (2 * P8EST_DIM)
46 
49 #define P8EST_CHILDREN 8
50 
51 #define P8EST_HALF (P8EST_CHILDREN / 2)
52 
53 #define P8EST_EDGES 12
54 
55 #define P8EST_INSUL 27
56 
57 /* size of face transformation encoding */
58 #define P8EST_FTRANSFORM 9
59 
61 #define P8EST_STRING "p8est"
62 
63 /* Increase this number whenever the on-disk format for
64  * p8est_connectivity, p8est, or any other 3D data structure changes.
65  * The format for reading and writing must be the same.
66  */
67 #define P8EST_ONDISK_FORMAT 0x3000009
68 
79 typedef enum
80 {
81  /* make sure to have different values 2D and 3D */
82  P8EST_CONNECT_FACE = 31,
83  P8EST_CONNECT_EDGE = 32,
84  P8EST_CONNECT_CORNER = 33,
85  P8EST_CONNECT_FULL = P8EST_CONNECT_CORNER
86 }
88 
89 #ifdef P4EST_BACKWARD_DEALII
90 typedef p8est_connect_type_t p8est_balance_type_t;
91 #endif
92 
94 typedef enum
95 {
96  P8EST_CONN_ENCODE_NONE = SC_IO_ENCODE_NONE,
98 }
100 
106 
112 
158 typedef struct p8est_connectivity
159 {
169  double *vertices;
176  char *tree_to_attr;
180  int8_t *tree_to_face;
187  int8_t *edge_to_edge;
196 }
198 
204  conn);
205 
206 typedef struct
207 {
208  p4est_topidx_t ntree;
209  int8_t nedge, naxis[3], nflip, corners;
210 }
212 
213 typedef struct
214 {
215  int8_t iedge;
216  sc_array_t edge_transforms;
217 }
219 
220 typedef struct
221 {
222  p4est_topidx_t ntree;
223  int8_t ncorner;
224 }
226 
227 typedef struct
228 {
229  p4est_topidx_t icorner;
230  sc_array_t corner_transforms;
231 }
233 
235 extern const int p8est_face_corners[6][4];
236 
238 extern const int p8est_face_edges[6][4];
239 
241 extern const int p8est_face_dual[6];
242 
244 extern const int p8est_face_permutations[8][4];
245 
247 extern const int p8est_face_permutation_sets[3][4];
248 
252 extern const int p8est_face_permutation_refs[6][6];
253 
255 extern const int p8est_edge_faces[12][2];
256 
258 extern const int p8est_edge_corners[12][2];
259 
261 extern const int p8est_edge_face_corners[12][6][2];
262 
264 extern const int p8est_corner_faces[8][3];
265 
267 extern const int p8est_corner_edges[8][3];
268 
270 extern const int p8est_corner_face_corners[8][6];
271 
273 extern const int p8est_child_edge_faces[8][12];
274 
276 extern const int p8est_child_corner_faces[8][8];
277 
279 extern const int p8est_child_corner_edges[8][8];
280 
293  (int c, int f, int nf, int set);
294 
303  (int c, int f, int nf, int o);
304 
316  p4est_topidx_t num_trees,
317  p4est_topidx_t num_edges,
318  p4est_topidx_t num_ett,
319  p4est_topidx_t num_corners,
320  p4est_topidx_t num_ctt);
321 
333  num_vertices,
334  p4est_topidx_t num_trees,
335  p4est_topidx_t num_edges,
336  p4est_topidx_t num_corners,
337  const double *vertices,
338  const p4est_topidx_t * ttv,
339  const p4est_topidx_t * ttt,
340  const int8_t * ttf,
341  const p4est_topidx_t * tte,
342  const p4est_topidx_t *
343  eoff,
344  const p4est_topidx_t * ett,
345  const int8_t * ete,
346  const p4est_topidx_t * ttc,
347  const p4est_topidx_t *
348  coff,
349  const p4est_topidx_t * ctt,
350  const int8_t * ctc);
351 
355  connectivity);
356 
364  size_t bytes_per_tree);
365 
370  connectivity);
371 
377  conn2);
378 
385  sc_io_sink_t * sink);
386 
394  code);
395 
401 int p8est_connectivity_save (const char *filename,
403  connectivity);
404 
409 p8est_connectivity_t *p8est_connectivity_source (sc_io_source_t * source);
410 
416 
422 p8est_connectivity_t *p8est_connectivity_load (const char *filename,
423  size_t * bytes);
424 
428 
432 
438 
442 
447 
452 
457  int periodic_a,
458  int periodic_b,
459  int periodic_c);
460 
467 
474 
489 
508 void p8est_expand_face_transform (int iface, int nface,
509  int ftransform[]);
510 
521  connectivity,
522  p4est_topidx_t itree,
523  int iface, int ftransform[]);
524 
531  connectivity,
532  p4est_topidx_t itree,
533  int iedge,
534  p8est_edge_info_t * ei);
535 
542  connectivity,
543  p4est_topidx_t itree,
544  int icorner,
545  p8est_corner_info_t * ci);
546 
557 
564 
580  sc_array_t * perm,
581  int is_current_to_new);
582 
583 #ifdef P4EST_WITH_METIS
584 
607 void p8est_connectivity_reorder (MPI_Comm comm, int k,
608  p8est_connectivity_t * conn,
609  p8est_connect_type_t ctype);
610 
611 #endif /* P4EST_WITH_METIS */
612 
629  conn,
630  p4est_topidx_t tree_left,
631  p4est_topidx_t tree_right,
632  int face_left,
633  int face_right,
634  int orientation);
635 
647  conn1,
649  conn2);
650 
652 /*@unused@*/
653 static inline p8est_edge_transform_t *
654 p8est_edge_array_index (sc_array_t * array, size_t it)
655 {
656  P4EST_ASSERT (array->elem_size == sizeof (p8est_edge_transform_t));
657  P4EST_ASSERT (it < array->elem_count);
658 
659  return (p8est_edge_transform_t *) (array->array +
660  sizeof (p8est_edge_transform_t) * it);
661 }
662 
664 /*@unused@*/
665 static inline p8est_corner_transform_t *
667 {
668  P4EST_ASSERT (array->elem_size == sizeof (p8est_corner_transform_t));
669  P4EST_ASSERT (it < array->elem_count);
670 
671  return
672  (p8est_corner_transform_t *) (array->array +
673  sizeof (p8est_corner_transform_t) * it);
674 }
675 
775 int p8est_connectivity_read_inp_stream (FILE * stream,
777  num_vertices,
779  num_trees,
780  double *vertices,
782  tree_to_vertex);
783 
873 p8est_connectivity_t *p8est_connectivity_read_inp (const char *filename);
874 
875 SC_EXTERN_C_END;
876 
877 #endif /* !P8EST_CONNECTIVITY_H */
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...
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_corner_set(int c, int f, int nf, int set)
Transform a corner across one of the adjacent faces into a neighbor tree.
Definition: p8est_connectivity.c:163
const int p8est_face_permutation_sets[3][4]
Store the 3 occurring sets of 4 permutations per face.
Definition: p8est_connectivity.c:53
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...
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_unitcube(void)
Create a connectivity structure for the unit cube.
Definition: p8est_connectivity.c:181
p4est_topidx_t * edge_to_tree
list of trees that meet at an edge
Definition: p8est_connectivity.h:186
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.
p8est_connectivity_t * p8est_connectivity_new_rotcubes(void)
Create a connectivity structure that contains a few cubes.
Definition: p8est_connectivity.c:419
p8est_connectivity_t * p8est_connectivity_new_periodic(void)
Create a connectivity structure for an all-periodic unit cube.
Definition: p8est_connectivity.c:215
int p8est_connect_type_int(p8est_connect_type_t btype)
Convert the p8est_connect_type_t into a number.
Definition: p8est_connectivity.c:1034
p8est_connectivity_t * p8est_connectivity_new_rotwrap(void)
Create a connectivity structure for a mostly periodic unit cube.
Definition: p8est_connectivity.c:276
const char * p8est_connect_type_string(p8est_connect_type_t btype)
Convert the p8est_connect_type_t into a const string.
Definition: p8est_connectivity.c:1049
p4est_topidx_t num_vertices
the number of vertices that define the embedding of the forest (not the topology) ...
Definition: p8est_connectivity.h:160
size_t p8est_connectivity_memory_used(p8est_connectivity_t *conn)
Calculate memory usage of a connectivity structure.
const int p8est_face_edges[6][4]
Store the face numbers 0..12 for each tree face.
Definition: p8est_connectivity.c:36
const int p8est_edge_faces[12][2]
Store the face numbers 0..5 for each tree edge.
Definition: p8est_connectivity.c:65
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.
char * array
linear array to store elements
Definition: sc_containers.h:104
Definition: p8est_connectivity.h:206
size_t elem_size
size of a single element
Definition: sc_containers.h:95
p8est_connect_type_t
Characterize a type of adjacency.
Definition: p8est_connectivity.h:79
p4est_topidx_t * tree_to_vertex
embed each tree into for e.g.
Definition: p8est_connectivity.h:171
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_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.
Invalid entry to close the list.
Definition: p8est_connectivity.h:97
Definition: p8est_connectivity.h:213
p8est_connectivity_t * p8est_connectivity_inflate(sc_array_t *buffer)
Create new connectivity from a memory buffer.
p4est_topidx_t * tree_to_corner
(8 * num_trees) or NULL (see description)
Definition: p8est_connectivity.h:189
Definition: p8est_connectivity.h:227
const int p8est_child_corner_faces[8][8]
Store the faces for each child and corner, can be -1.
Definition: p8est_connectivity.c:142
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...
static p8est_corner_transform_t * p8est_corner_array_index(sc_array_t *array, size_t it)
Return a pointer to a p8est_corner_transform_t array element.
Definition: p8est_connectivity.h:666
const int p8est_corner_edges[8][3]
Store the edge numbers 0..11 for each tree corner.
Definition: p8est_connectivity.c:114
int8_t * corner_to_corner
list of tree-corners that meet at a corner
Definition: p8est_connectivity.h:194
sc_array_t * p8est_connectivity_deflate(p8est_connectivity_t *conn, p8est_connectivity_encode_t code)
Allocate memory and store the connectivity information there.
p4est_topidx_t * corner_to_tree
list of trees that meet at a corner
Definition: p8est_connectivity.h:193
int8_t * edge_to_edge
list of tree-edges+orientations that meet at an edge (see description)
Definition: p8est_connectivity.h:187
const int p8est_edge_corners[12][2]
Store the corner numbers 0..8 for each tree edge.
Definition: p8est_connectivity.c:78
const int p8est_child_edge_faces[8][12]
Store the faces for each child and edge, can be -1.
Definition: p8est_connectivity.c:133
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_new_twowrap(void)
Create a connectivity structure that contains two cubes where the two far ends are identified periodi...
Definition: p8est_connectivity.c:378
p4est_topidx_t num_trees
the number of trees
Definition: p8est_connectivity.h:163
const int p8est_face_permutations[8][4]
Store only the 8 out of 24 possible permutations that occur.
Definition: p8est_connectivity.c:44
const int p8est_corner_faces[8][3]
Store the face numbers 0..5 for each tree corner.
Definition: p8est_connectivity.c:105
const int p8est_edge_face_corners[12][6][2]
Store the face corner numbers for the faces touching a tree edge.
Definition: p8est_connectivity.c:91
This structure holds the 3D inter-tree connectivity information.
Definition: p8est_connectivity.h:158
p8est_connectivity_t * p8est_connectivity_load(const char *filename, size_t *bytes)
Load a connectivity structure from disk.
p8est_connectivity_t * p8est_connectivity_new_sphere(void)
Create a connectivity structure that builds a solid sphere.
Definition: p8est_connectivity.c:703
void p8est_expand_face_transform(int iface, int nface, int ftransform[])
Fill an array with the axis combination of a face neighbor transform.
void p8est_connectivity_destroy(p8est_connectivity_t *connectivity)
Destroy a connectivity structure.
const int p8est_face_permutation_refs[6][6]
For each face combination store the permutation set.
Definition: p8est_connectivity.c:57
double * vertices
an array of size (3 * num_vertices)
Definition: p8est_connectivity.h:169
const int p8est_corner_face_corners[8][6]
Store the face corner numbers for the faces touching a tree corner.
Definition: p8est_connectivity.c:123
p8est_connectivity_t * p8est_connectivity_new_shell(void)
Create a connectivity structure that builds a spherical shell.
Definition: p8est_connectivity.c:515
p8est_connectivity_encode_t
Typedef for serialization method.
Definition: p8est_connectivity.h:94
p8est_connectivity_t * p8est_connectivity_read_inp(const char *filename)
Create a p4est connectivity from an ABAQUS input file.
The sc_array object provides a large array of equal-size elements.
Definition: sc_containers.h:92
p4est_topidx_t * ctt_offset
corner to offset in corner_to_tree and corner_to_corner
Definition: p8est_connectivity.h:191
General support types and functions.
int32_t p4est_topidx_t
Typedef for counting topological entities (trees, tree vertices).
Definition: p4est_base.h:63
p4est_topidx_t num_edges
the number of edges that help define the topology
Definition: p8est_connectivity.h:164
char * tree_to_attr
not touched by p4est
Definition: p8est_connectivity.h:176
const int p8est_child_corner_edges[8][8]
Store the edges for each child and corner, can be -1.
Definition: p8est_connectivity.c:151
int p8est_connectivity_is_equal(p8est_connectivity_t *conn1, p8est_connectivity_t *conn2)
Check two connectivity structures for equality.
size_t tree_attr_bytes
bytes per tree in tree_to_attr
Definition: p8est_connectivity.h:175
p4est_topidx_t * tree_to_edge
(12 * num_trees) or NULL (see description)
Definition: p8est_connectivity.h:182
const int p8est_face_corners[6][4]
Store the corner numbers 0..7 for each tree face.
Definition: p8est_connectivity.c:29
p8est_connectivity_t * p8est_connectivity_new_byname(const char *name)
Create connectivity structure from predefined catalogue.
int p8est_connectivity_is_valid(p8est_connectivity_t *connectivity)
Examine a connectivity structure.
static p8est_edge_transform_t * p8est_edge_array_index(sc_array_t *array, size_t it)
Return a pointer to a p8est_edge_transform_t array element.
Definition: p8est_connectivity.h:654
p4est_topidx_t num_corners
the number of corners that help define the topology
Definition: p8est_connectivity.h:166
int p8est_connectivity_face_neighbor_corner_orientation(int c, int f, int nf, int o)
Transform a corner across one of the adjacent faces into a neighbor tree.
p4est_topidx_t * ett_offset
edge to offset in edge_to_tree and edge_to_edge
Definition: p8est_connectivity.h:184
int p8est_connectivity_save(const char *filename, p8est_connectivity_t *connectivity)
Save a connectivity structure to disk.
void p8est_connectivity_complete(p8est_connectivity_t *conn)
Internally connect a connectivity based on tree_to_vertex information.
int p8est_connectivity_sink(p8est_connectivity_t *conn, sc_io_sink_t *sink)
Write connectivity to a sink object.
p8est_connectivity_t * p8est_connectivity_source(sc_io_source_t *source)
Read connectivity from a source object.
void p8est_connectivity_set_attr(p8est_connectivity_t *conn, size_t bytes_per_tree)
Allocate or free the attribute fields in a connectivity.
p4est_topidx_t * tree_to_tree
(6 * num_trees) neighbors across faces
Definition: p8est_connectivity.h:178
Definition: p8est_connectivity.h:220
int8_t * tree_to_face
(4 * num_trees) face to face+orientation (see description)
Definition: p8est_connectivity.h:180
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...
p8est_connectivity_t * p8est_connectivity_new_twocubes(void)
Create a connectivity structure that contains two cubes.
Definition: p8est_connectivity.c:337
const int p8est_face_dual[6]
Store the face numbers in the face neighbor's system.
Definition: p8est_connectivity.c:43