p4est 2.8.5.190-3fcf-dirty
p4est is a software library for parallel adaptive mesh refinement.
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 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
58#ifndef P4EST_CONNECTIVITY_H
59#define P4EST_CONNECTIVITY_H
60
61#ifdef P4_TO_P8
62#error "Including a p4est header with P4_TO_P8 defined"
63#endif
64
65#include <sc_io.h>
66#include <p4est_base.h>
67
68SC_EXTERN_C_BEGIN;
69
71#define P4EST_DIM 2
73#define P4EST_FACES (2 * P4EST_DIM)
75#define P4EST_CHILDREN 4
77#define P4EST_HALF (P4EST_CHILDREN / 2)
79#define P4EST_INSUL 9
80
82#define P4EST_ONLY_P8_LAND(x)
83
85#define P4EST_ONLY_P8_COMMA(x)
86
88#define P4EST_DIM_POW(a) ((a) * (a))
89
91#define P4EST_FTRANSFORM 9
92
94#define P4EST_STRING "p4est"
95
101#define P4EST_ONDISK_FORMAT 0x2000009
102
112typedef enum
113{
114 /* make sure to have different values 2D and 3D */
115 P4EST_CONNECT_SELF = 20,
116 P4EST_CONNECT_FACE = 21,
117 P4EST_CONNECT_CORNER = 22,
118 P4EST_CONNECT_FULL = P4EST_CONNECT_CORNER
119}
121
122#ifdef P4EST_BACKWARD_DEALII
123typedef p4est_connect_type_t p4est_balance_type_t;
124#endif
125
127typedef enum
128{
129 P4EST_CONN_ENCODE_NONE = SC_IO_ENCODE_NONE,
133
139
145
188typedef struct p4est_connectivity
189{
196 double *vertices;
207 int8_t *tree_to_face;
217}
219
225 conn);
226
228typedef struct
229{
231 int8_t ncorner;
232}
234
236typedef struct
237{
239 sc_array_t corner_transforms;
241}
243
245typedef struct
246{
249 int8_t index_self;
253 int8_t perm[P4EST_DIM];
256 int8_t sign[P4EST_DIM];
260 p4est_qcoord_t origin_neighbor[P4EST_DIM];
263}
265
266/* *INDENT-OFF* */
267
275 (const p4est_neighbor_transform_t * nt,
276 const p4est_qcoord_t self_coords[P4EST_DIM],
277 p4est_qcoord_t neigh_coords[P4EST_DIM]);
278
286 (const p4est_neighbor_transform_t * nt,
287 const p4est_qcoord_t neigh_coords[P4EST_DIM],
288 p4est_qcoord_t self_coords[P4EST_DIM]);
289
301 p4est_topidx_t tree_id,
302 p4est_connect_type_t boundary_type,
303 int boundary_index,
304 sc_array_t *neighbor_transform_array);
305
306/* *INDENT-ON* */
307
309extern const int p4est_face_corners[4][2];
310
312extern const int p4est_face_dual[4];
313
315extern const int p4est_corner_faces[4][2];
316
318extern const int p4est_corner_face_corners[4][4];
319
321extern const int p4est_child_corner_faces[4][4];
322
332 (int fc, int f, int nf, int o);
333
343 (int c, int f, int nf, int o);
344
354 p4est_topidx_t num_trees,
355 p4est_topidx_t num_corners,
356 p4est_topidx_t num_ctt);
357
376 num_vertices,
377 p4est_topidx_t num_trees,
378 p4est_topidx_t num_corners,
379 const double *vertices,
380 const p4est_topidx_t * ttv,
381 const p4est_topidx_t * ttt,
382 const int8_t * ttf,
383 const p4est_topidx_t * ttc,
384 const p4est_topidx_t *
385 coff,
386 const p4est_topidx_t * ctt,
387 const int8_t * ctc);
388
401 conn_in, int root,
402 sc_MPI_Comm comm);
403
407 connectivity);
408
416 size_t bytes_per_tree);
417
422 connectivity);
423
429 conn2);
430
437 sc_io_sink_t * sink);
438
446 code);
447
453int p4est_connectivity_save (const char *filename,
455 connectivity);
456
462
470
477 size_t *bytes);
478
482
486
491
499
504
512 int r_face,
513 int orientation);
514
518
522
526
530
541
548
576 int periodic_b);
577
607
612
619
633
639 int periodic_a,
640 int periodic_b);
641
657
669 int num_per_edge);
670
690void p4est_expand_face_transform (int iface, int nface,
691 int ftransform[]);
692
705 connectivity,
706 p4est_topidx_t itree,
707 int iface, int ftransform[]);
708
716 connectivity,
717 p4est_topidx_t itree,
718 int icorner,
720
731
738
754 sc_array_t * perm,
755 int is_current_to_new);
756#ifdef P4EST_WITH_METIS
757
783void p4est_connectivity_reorder (sc_MPI_Comm comm, int k,
786
810sc_array_t *p4est_connectivity_reorder_newid (sc_MPI_Comm comm, int k,
812 conn,
814 ctype,
815 sc_array_t * newid);
816
817#endif /* P4EST_WITH_METIS */
818
835 conn,
836 p4est_topidx_t tree_left,
837 p4est_topidx_t tree_right,
838 int face_left,
839 int face_right,
840 int orientation);
841
853 conn1,
855 conn2);
856
858/*@unused@*/
859static inline p4est_corner_transform_t *
860p4est_corner_array_index (sc_array_t * array, size_t it)
861{
862 P4EST_ASSERT (array->elem_size == sizeof (p4est_corner_transform_t));
863 P4EST_ASSERT (it < array->elem_count);
864
865 return
866 (p4est_corner_transform_t *) (array->array +
867 sizeof (p4est_corner_transform_t) * it);
868}
869
952 num_vertices,
954 num_trees,
955 double *vertices,
957 tree_to_vertex);
958
1032
1033SC_EXTERN_C_END;
1034
1035#endif /* !P4EST_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
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.
p4est_connectivity_t * p4est_connectivity_new_drop(void)
Create a connectivity structure for a five-trees geometry with a hole.
sc_array_t * p4est_connectivity_reorder_newid(sc_MPI_Comm comm, int k, p4est_connectivity_t *conn, p4est_connect_type_t ctype, sc_array_t *newid)
Reorder a connectivity using METIS.
void p4est_neighbor_transform_coordinates_reverse(const p4est_neighbor_transform_t *nt, const p4est_qcoord_t neigh_coords[P4EST_DIM], p4est_qcoord_t self_coords[P4EST_DIM])
Transform from neighbor's coordinate system to self's coordinate system.
p4est_connectivity_t * p4est_connectivity_new_corner(void)
Create a connectivity structure for a three-tree mesh around a corner.
p4est_connectivity_t * p4est_connectivity_read_inp(const char *filename)
Create a p4est connectivity from an ABAQUS input file.
p4est_connectivity_t * p4est_connectivity_new_cubed(void)
Create a connectivity structure for the six sides of a unit cube.
void p4est_connectivity_complete(p4est_connectivity_t *conn)
Internally connect a connectivity based on tree_to_vertex information.
void p4est_connectivity_set_attr(p4est_connectivity_t *conn, size_t bytes_per_tree)
Allocate or free the attribute fields in a connectivity.
void p4est_connectivity_destroy(p4est_connectivity_t *connectivity)
Destroy a connectivity structure.
p4est_connectivity_t * p4est_connectivity_new_twotrees(int l_face, int r_face, int orientation)
Create a connectivity structure for two trees being rotated w.r.t.
size_t p4est_connectivity_memory_used(p4est_connectivity_t *conn)
Calculate memory usage of a connectivity structure.
p4est_connectivity_t * p4est_connectivity_new_disk(int periodic_a, int periodic_b)
Create a connectivity structure for a five-tree flat spherical disk.
int p4est_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.
#define P4EST_DIM
The spatial dimension.
Definition: p4est_connectivity.h:71
p4est_connectivity_t * p4est_connectivity_load(const char *filename, size_t *bytes)
Load a connectivity structure from disk.
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.
p4est_connectivity_t * p4est_connectivity_new_unitsquare(void)
Create a connectivity structure for the unit square.
p4est_connectivity_t * p4est_connectivity_new_disk2d(void)
Create a connectivity structure that maps a 2d disk.
p4est_connectivity_t * p4est_connectivity_new_shell2d(void)
Create a connectivity structure that builds a 2d spherical shell.
int p4est_connectivity_is_valid(p4est_connectivity_t *connectivity)
Examine a connectivity structure.
p4est_connectivity_t * p4est_connectivity_new_rotwrap(void)
Create a connectivity structure for a periodic unit square.
p4est_connectivity_t * p4est_connectivity_new_brick(int mi, int ni, int periodic_a, int periodic_b)
A rectangular m by n array of trees with configurable periodicity.
p4est_connectivity_t * p4est_connectivity_new_circle(void)
Create a connectivity structure for an donut-like circle.
const int p4est_corner_faces[4][2]
Store the face numbers 0..3 for each tree corner.
const int p4est_face_corners[4][2]
Store the corner numbers 0..4 for each tree face.
const int p4est_corner_face_corners[4][4]
Store the face corner numbers for the faces touching a tree corner.
p4est_connectivity_t * p4est_connectivity_new_pillow(void)
Create a connectivity structure for two trees on top of each other.
const char * p4est_connect_type_string(p4est_connect_type_t btype)
Convert the p4est_connect_type_t into a const string.
p4est_connectivity_t * p4est_connectivity_bcast(p4est_connectivity_t *conn_in, int root, sc_MPI_Comm comm)
Broadcast a connectivity structure that exists only on one process to all.
p4est_connectivity_t * p4est_connectivity_source(sc_io_source_t *source)
Read connectivity from a source object.
void p4est_neighbor_transform_coordinates(const p4est_neighbor_transform_t *nt, const p4est_qcoord_t self_coords[P4EST_DIM], p4est_qcoord_t neigh_coords[P4EST_DIM])
Transform from self's coordinate system to neighbor's coordinate system.
void p4est_connectivity_reorder(sc_MPI_Comm comm, int k, p4est_connectivity_t *conn, p4est_connect_type_t ctype)
Reorder a connectivity using METIS.
void p4est_connectivity_reduce(p4est_connectivity_t *conn)
Removes corner information of a connectivity such that enough information is left to run p4est_connec...
p4est_connectivity_t * p4est_connectivity_refine(p4est_connectivity_t *conn, int num_per_edge)
Uniformly refine a connectivity.
p4est_connectivity_encode_t
Typedef for serialization method.
Definition: p4est_connectivity.h:128
@ P4EST_CONN_ENCODE_LAST
Invalid entry to close the list.
Definition: p4est_connectivity.h:130
p4est_connectivity_t * p4est_connectivity_new_icosahedron(void)
Create a connectivity for mapping the sphere using an icosahedron.
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...
p4est_connectivity_t * p4est_connectivity_new_bowtie(void)
Create a connectivity structure that maps a 2d bowtie structure.
struct p4est_connectivity p4est_connectivity_t
This structure holds the 2D inter-tree connectivity information.
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...
p4est_connectivity_t * p4est_connectivity_new_star(void)
Create a connectivity structure for a six-tree star.
void p4est_connectivity_get_neighbor_transforms(p4est_connectivity_t *conn, p4est_topidx_t tree_id, p4est_connect_type_t boundary_type, int boundary_index, sc_array_t *neighbor_transform_array)
Fill an array with the neighbor transforms based on a specific boundary type.
int p4est_connect_type_int(p4est_connect_type_t btype)
Convert the p4est_connect_type_t into a number.
p4est_connectivity_t * p4est_connectivity_new_disk_nonperiodic(void)
Create a connectivity structure for a five-tree flat spherical disk.
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.
p4est_connectivity_t * p4est_connectivity_new_byname(const char *name)
Create connectivity structure from predefined catalogue.
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.
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.
p4est_connectivity_t * p4est_connectivity_inflate(sc_array_t *buffer)
Create new connectivity from a memory buffer.
int p4est_connectivity_is_equal(p4est_connectivity_t *conn1, p4est_connectivity_t *conn2)
Check two connectivity structures for equality.
p4est_connect_type_t
Characterize a type of adjacency.
Definition: p4est_connectivity.h:113
const int p4est_face_dual[4]
Store the face numbers in the face neighbor's system.
p4est_connectivity_t * p4est_connectivity_new_moebius(void)
Create a connectivity structure for a five-tree moebius band.
int p4est_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.
const int p4est_child_corner_faces[4][4]
Store the faces for each child and corner, can be -1.
void p4est_expand_face_transform(int iface, int nface, int ftransform[])
Fill an array with the axis combination of a face neighbor transform.
sc_array_t * p4est_connectivity_deflate(p4est_connectivity_t *conn, p4est_connectivity_encode_t code)
Allocate memory and store the connectivity information there.
p4est_connectivity_t * p4est_connectivity_new_periodic(void)
Create a connectivity structure for an all-periodic unit square.
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,...
int p4est_connectivity_save(const char *filename, p4est_connectivity_t *connectivity)
Save a connectivity structure to disk.
int p4est_connectivity_sink(p4est_connectivity_t *conn, sc_io_sink_t *sink)
Write connectivity to a sink object.
This structure holds the 2D inter-tree connectivity information.
Definition: p4est_connectivity.h:189
p4est_topidx_t num_vertices
the number of vertices that define the embedding of the forest (not the topology)
Definition: p4est_connectivity.h:190
p4est_topidx_t num_trees
the number of trees
Definition: p4est_connectivity.h:193
int8_t * tree_to_face
(4 * num_trees) face to face+orientation (see description)
Definition: p4est_connectivity.h:207
p4est_topidx_t * ctt_offset
corner to offset in corner_to_tree and corner_to_corner
Definition: p4est_connectivity.h:212
p4est_topidx_t num_corners
the number of corners that help define topology
Definition: p4est_connectivity.h:194
int8_t * corner_to_corner
list of tree-corners that meet at a corner
Definition: p4est_connectivity.h:215
p4est_topidx_t * tree_to_vertex
embed each tree into for e.g.
Definition: p4est_connectivity.h:198
p4est_topidx_t * tree_to_tree
(4 * num_trees) neighbors across faces
Definition: p4est_connectivity.h:205
char * tree_to_attr
not touched by p4est
Definition: p4est_connectivity.h:203
p4est_topidx_t * tree_to_corner
(4 * num_trees) or NULL (see description)
Definition: p4est_connectivity.h:210
p4est_topidx_t * corner_to_tree
list of trees that meet at a corner
Definition: p4est_connectivity.h:214
double * vertices
an array of size (3 * num_vertices)
Definition: p4est_connectivity.h:196
size_t tree_attr_bytes
bytes per tree in tree_to_attr
Definition: p4est_connectivity.h:202
Information about the neighbors of a corner.
Definition: p4est_connectivity.h:237
p4est_topidx_t icorner
The number of the originating corner.
Definition: p4est_connectivity.h:238
sc_array_t corner_transforms
The array of neighbors of the originating corner.
Definition: p4est_connectivity.h:239
Generic interface for transformations between a tree and any of its corner.
Definition: p4est_connectivity.h:229
p4est_topidx_t ntree
The number of the tree.
Definition: p4est_connectivity.h:230
int8_t ncorner
The number of the corner.
Definition: p4est_connectivity.h:231
Generic interface for transformations between a tree and any of its neighbors.
Definition: p4est_connectivity.h:246
int8_t index_self
index of interface from self's perspective
Definition: p4est_connectivity.h:249
p4est_topidx_t neighbor
neighbor tree index
Definition: p4est_connectivity.h:248
int8_t index_neighbor
index of interface from neighbor's perspective
Definition: p4est_connectivity.h:251
p4est_connect_type_t neighbor_type
type of connection to neighbor
Definition: p4est_connectivity.h:247