p4est  1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
p4est_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 P4EST_CONNECTIVITY_H
32 #define P4EST_CONNECTIVITY_H
33 
34 #ifdef P4_TO_P8
35 #error "Including a p4est header with P4_TO_P8 defined"
36 #endif
37 
38 #include <sc_io.h>
39 #include <p4est_base.h>
40 
41 SC_EXTERN_C_BEGIN;
42 
44 #define P4EST_DIM 2
45 
46 #define P4EST_FACES (2 * P4EST_DIM)
47 
50 #define P4EST_CHILDREN 4
51 
52 #define P4EST_HALF (P4EST_CHILDREN / 2)
53 
54 #define P4EST_INSUL 9
55 
56 /* size of face transformation encoding */
57 #define P4EST_FTRANSFORM 9
58 
60 #define P4EST_STRING "p4est"
61 
62 /* Increase this number whenever the on-disk format for
63  * p4est_connectivity, p4est, or any other 2D data structure changes.
64  * The format for reading and writing must be the same.
65  */
66 #define P4EST_ONDISK_FORMAT 0x2000009
67 
77 typedef enum
78 {
79  /* make sure to have different values 2D and 3D */
80  P4EST_CONNECT_FACE = 21,
81  P4EST_CONNECT_CORNER = 22,
82  P4EST_CONNECT_FULL = P4EST_CONNECT_CORNER
83 }
85 
86 #ifdef P4EST_BACKWARD_DEALII
87 typedef p4est_connect_type_t p4est_balance_type_t;
88 #endif
89 
91 typedef enum
92 {
93  P4EST_CONN_ENCODE_NONE = SC_IO_ENCODE_NONE,
95 }
97 
103 
109 
139 typedef struct p4est_connectivity
140 {
147  double *vertices;
154  char *tree_to_attr;
158  int8_t *tree_to_face;
168 }
170 
176  conn);
177 
178 typedef struct
179 {
180  p4est_topidx_t ntree;
181  int8_t ncorner;
182 }
184 
185 typedef struct
186 {
187  p4est_topidx_t icorner;
188  sc_array_t corner_transforms;
189 }
191 
193 extern const int p4est_face_corners[4][2];
194 
196 extern const int p4est_face_dual[4];
197 
199 extern const int p4est_corner_faces[4][2];
200 
202 extern const int p4est_corner_face_corners[4][4];
203 
205 extern const int p4est_child_corner_faces[4][4];
206 
215  (int c, int f, int nf, int o);
216 
226  p4est_topidx_t num_trees,
227  p4est_topidx_t num_corners,
228  p4est_topidx_t num_ctt);
229 
239  num_vertices,
240  p4est_topidx_t num_trees,
241  p4est_topidx_t num_corners,
242  const double *vertices,
243  const p4est_topidx_t * ttv,
244  const p4est_topidx_t * ttt,
245  const int8_t * ttf,
246  const p4est_topidx_t * ttc,
247  const p4est_topidx_t *
248  coff,
249  const p4est_topidx_t * ctt,
250  const int8_t * ctc);
251 
255  connectivity);
256 
264  size_t bytes_per_tree);
265 
270  connectivity);
271 
277  conn2);
278 
285  sc_io_sink_t * sink);
286 
294  code);
295 
301 int p4est_connectivity_save (const char *filename,
303  connectivity);
304 
309 p4est_connectivity_t *p4est_connectivity_source (sc_io_source_t * source);
310 
316 
322 p4est_connectivity_t *p4est_connectivity_load (const char *filename,
323  size_t * bytes);
324 
328 
332 
337 
341 
345 
349 
353 
361 
368 
373  int periodic_a,
374  int periodic_b);
375 
391 
411 void p4est_expand_face_transform (int iface, int nface,
412  int ftransform[]);
413 
425  connectivity,
426  p4est_topidx_t itree,
427  int iface, int ftransform[]);
428 
435  connectivity,
436  p4est_topidx_t itree,
437  int icorner,
438  p4est_corner_info_t * ci);
439 
450 
457 
473  sc_array_t * perm,
474  int is_current_to_new);
475 #ifdef P4EST_WITH_METIS
476 
499 void p4est_connectivity_reorder (MPI_Comm comm, int k,
500  p4est_connectivity_t * conn,
501  p4est_connect_type_t ctype);
502 
503 #endif /* P4EST_WITH_METIS */
504 
521  conn,
522  p4est_topidx_t tree_left,
523  p4est_topidx_t tree_right,
524  int face_left,
525  int face_right,
526  int orientation);
527 
539  conn1,
541  conn2);
542 
544 /*@unused@*/
545 static inline p4est_corner_transform_t *
547 {
548  P4EST_ASSERT (array->elem_size == sizeof (p4est_corner_transform_t));
549  P4EST_ASSERT (it < array->elem_count);
550 
551  return
552  (p4est_corner_transform_t *) (array->array +
553  sizeof (p4est_corner_transform_t) * it);
554 }
555 
636 int p4est_connectivity_read_inp_stream (FILE * stream,
638  num_vertices,
640  num_trees,
641  double *vertices,
643  tree_to_vertex);
644 
717 p4est_connectivity_t *p4est_connectivity_read_inp (const char *filename);
718 
719 SC_EXTERN_C_END;
720 
721 #endif /* !P4EST_CONNECTIVITY_H */
char * tree_to_attr
not touched by p4est
Definition: p4est_connectivity.h:154
int8_t * tree_to_face
(4 * num_trees) face to face+orientation (see description)
Definition: p4est_connectivity.h:158
void p4est_connectivity_permute(p4est_connectivity_t *conn, sc_array_t *perm, int is_current_to_new)
p4est_connectivity_permute Given a permutation perm of the trees in a connectivity conn...
Definition: p4est_connectivity.c:2918
sc_array_t * p4est_connectivity_deflate(p4est_connectivity_t *conn, p4est_connectivity_encode_t code)
Allocate memory and store the connectivity information there.
Definition: p4est_connectivity.c:771
int p4est_connectivity_is_equivalent(p4est_connectivity_t *conn1, p4est_connectivity_t *conn2)
p4est_connectivity_is_equivalent This function compares two connectivities for equivalence: it return...
Definition: p4est_connectivity.c:3760
p4est_connectivity_t * p4est_connectivity_new_disk(void)
Create a connectivity structure for a five-tree flat spherical disk.
Definition: p4est_connectivity.c:1433
p4est_connectivity_t * p4est_connectivity_new_star(void)
Create a connectivity structure for a six-tree star.
Definition: p4est_connectivity.c:1318
p4est_topidx_t * tree_to_vertex
embed each tree into for e.g.
Definition: p4est_connectivity.h:149
p4est_connectivity_t * p4est_connectivity_new_brick(int mi, int ni, int periodic_a, int periodic_b)
An m by n array with periodicity in x and y if periodic_a and periodic_b are true, respectively.
Definition: p4est_connectivity.c:1576
p4est_connectivity_t * p4est_connectivity_new_copy(p4est_topidx_t num_vertices, p4est_topidx_t num_trees, 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 *ttc, const p4est_topidx_t *coff, const p4est_topidx_t *ctt, const int8_t *ctc)
Allocate a connectivity structure and populate from constants.
Definition: p4est_connectivity.c:115
p4est_connectivity_t * p4est_connectivity_new_periodic(void)
Create a connectivity structure for an all-periodic unit square.
Definition: p4est_connectivity.c:1117
const int p4est_child_corner_faces[4][4]
Store the faces for each child and corner, can be -1.
Definition: p4est_connectivity.c:55
p4est_connectivity_t * p4est_connectivity_new_rotwrap(void)
Create a connectivity structure for a periodic unit square.
Definition: p4est_connectivity.c:1158
char * array
linear array to store elements
Definition: sc_containers.h:104
p4est_connectivity_t * p4est_connectivity_new_unitsquare(void)
Create a connectivity structure for the unit square.
Definition: p4est_connectivity.c:1089
p4est_connectivity_t * p4est_connectivity_new_corner(void)
Create a connectivity structure for a three-tree mesh around a corner.
Definition: p4est_connectivity.c:1199
const int p4est_corner_faces[4][2]
Store the face numbers 0..3 for each tree corner.
Definition: p4est_connectivity.c:44
size_t elem_size
size of a single element
Definition: sc_containers.h:95
int p4est_connectivity_is_valid(p4est_connectivity_t *connectivity)
Examine a connectivity structure.
Definition: p4est_connectivity.c:289
void p4est_connectivity_join_faces(p4est_connectivity_t *conn, p4est_topidx_t tree_left, p4est_topidx_t tree_right, int face_left, int face_right, int orientation)
p4est_connectivity_join_faces This function takes an existing valid connectivity conn and modifies it...
Definition: p4est_connectivity.c:3652
Definition: p4est_connectivity.h:185
p4est_topidx_t * corner_to_tree
list of trees that meet at a corner
Definition: p4est_connectivity.h:165
p4est_connectivity_t * p4est_connectivity_source(sc_io_source_t *source)
Read connectivity from a source object.
Definition: p4est_connectivity.c:814
p4est_topidx_t num_corners
the number of corners that help define topology
Definition: p4est_connectivity.h:145
void p4est_connectivity_destroy(p4est_connectivity_t *connectivity)
Destroy a connectivity structure.
Definition: p4est_connectivity.c:248
Invalid entry to close the list.
Definition: p4est_connectivity.h:94
void p4est_connectivity_set_attr(p4est_connectivity_t *conn, size_t bytes_per_tree)
Allocate or free the attribute fields in a connectivity.
Definition: p4est_connectivity.c:274
int p4est_connectivity_sink(p4est_connectivity_t *conn, sc_io_sink_t *sink)
Write connectivity to a sink object.
Definition: p4est_connectivity.c:663
void p4est_connectivity_complete(p4est_connectivity_t *conn)
Internally connect a connectivity based on tree_to_vertex information.
Definition: p4est_connectivity.c:2457
int p4est_connect_type_int(p4est_connect_type_t btype)
Convert the p4est_connect_type_t into a number.
Definition: p4est_connectivity.c:3880
void p4est_connectivity_reduce(p4est_connectivity_t *conn)
Removes corner information of a connectivity such that enough information is left to run p4est_connec...
Definition: p4est_connectivity.c:2894
int8_t * corner_to_corner
list of tree-corners that meet at a corner
Definition: p4est_connectivity.h:166
p4est_topidx_t p4est_find_face_transform(p4est_connectivity_t *connectivity, p4est_topidx_t itree, int iface, int ftransform[])
Fill an array with the axis combinations of a tree neighbor transform.
Definition: p4est_connectivity.c:2227
size_t tree_attr_bytes
bytes per tree in tree_to_attr
Definition: p4est_connectivity.h:153
const int p4est_face_dual[4]
Store the face numbers in the face neighbor's system.
Definition: p4est_connectivity.c:42
p4est_topidx_t * ctt_offset
corner to offset in corner_to_tree and corner_to_corner
Definition: p4est_connectivity.h:163
p4est_connectivity_t * p4est_connectivity_new_pillow(void)
Create a connectivity structure for two trees on top of each other.
Definition: p4est_connectivity.c:1243
This structure holds the 2D inter-tree connectivity information.
Definition: p4est_connectivity.h:139
const int p4est_corner_face_corners[4][4]
Store the face corner numbers for the faces touching a tree corner.
Definition: p4est_connectivity.c:49
p4est_connectivity_t * p4est_connectivity_new(p4est_topidx_t num_vertices, p4est_topidx_t num_trees, p4est_topidx_t num_corners, p4est_topidx_t num_ctt)
Allocate a connectivity structure.
Definition: p4est_connectivity.c:188
double * vertices
an array of size (3 * num_vertices)
Definition: p4est_connectivity.h:147
p4est_connectivity_t * p4est_connectivity_new_cubed(void)
Create a connectivity structure for the six sides of a unit cube.
Definition: p4est_connectivity.c:1386
The sc_array object provides a large array of equal-size elements.
Definition: sc_containers.h:92
p4est_topidx_t num_vertices
the number of vertices that define the embedding of the forest (not the topology) ...
Definition: p4est_connectivity.h:141
p4est_connect_type_t
Characterize a type of adjacency.
Definition: p4est_connectivity.h:77
const int p4est_face_corners[4][2]
Store the corner numbers 0..4 for each tree face.
Definition: p4est_connectivity.c:37
p4est_connectivity_t * p4est_connectivity_new_byname(const char *name)
Create connectivity structure from predefined catalogue.
Definition: p4est_connectivity.c:2008
int p4est_connectivity_save(const char *filename, p4est_connectivity_t *connectivity)
Save a connectivity structure to disk.
Definition: p4est_connectivity.c:795
General support types and functions.
int p4est_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.
Definition: p4est_connectivity.c:3952
void p4est_find_corner_transform(p4est_connectivity_t *connectivity, p4est_topidx_t itree, int icorner, p4est_corner_info_t *ci)
Fills an array with information about corner neighbors.
Definition: p4est_connectivity.c:2406
int32_t p4est_topidx_t
Typedef for counting topological entities (trees, tree vertices).
Definition: p4est_base.h:63
p4est_topidx_t * tree_to_corner
(4 * num_trees) or NULL (see description)
Definition: p4est_connectivity.h:161
Definition: p4est_connectivity.h:178
p4est_topidx_t * tree_to_tree
(4 * num_trees) neighbors across faces
Definition: p4est_connectivity.h:156
const char * p4est_connect_type_string(p4est_connect_type_t btype)
Convert the p4est_connect_type_t into a const string.
Definition: p4est_connectivity.c:3893
p4est_connectivity_t * p4est_connectivity_load(const char *filename, size_t *bytes)
Load a connectivity structure from disk.
Definition: p4est_connectivity.c:1056
p4est_connectivity_t * p4est_connectivity_inflate(sc_array_t *buffer)
Create new connectivity from a memory buffer.
Definition: p4est_connectivity.c:1036
static p4est_corner_transform_t * p4est_corner_array_index(sc_array_t *array, size_t it)
Return a pointer to a p4est_corner_transform_t array element.
Definition: p4est_connectivity.h:546
p4est_topidx_t num_trees
the number of trees
Definition: p4est_connectivity.h:144
p4est_connectivity_t * p4est_connectivity_new_moebius(void)
Create a connectivity structure for a five-tree moebius band.
Definition: p4est_connectivity.c:1271
p4est_connectivity_t * p4est_connectivity_read_inp(const char *filename)
Create a p4est connectivity from an ABAQUS input file.
Definition: p4est_connectivity.c:4089
void p4est_expand_face_transform(int iface, int nface, int ftransform[])
Fill an array with the axis combination of a face neighbor transform.
Definition: p4est_connectivity.c:2217
int p4est_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.
Definition: p4est_connectivity.c:65
size_t p4est_connectivity_memory_used(p4est_connectivity_t *conn)
Calculate memory usage of a connectivity structure.
Definition: p4est_connectivity.c:94
int p4est_connectivity_is_equal(p4est_connectivity_t *conn1, p4est_connectivity_t *conn2)
Check two connectivity structures for equality.
Definition: p4est_connectivity.c:562
p4est_connectivity_encode_t
Typedef for serialization method.
Definition: p4est_connectivity.h:91