p4est
1.0
|
00001 /* 00002 This file is part of p4est. 00003 p4est is a C library to manage a collection (a forest) of multiple 00004 connected adaptive quadtrees or octrees in parallel. 00005 00006 Copyright (C) 2010 The University of Texas System 00007 Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac 00008 00009 p4est is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 2 of the License, or 00012 (at your option) any later version. 00013 00014 p4est is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with p4est; if not, write to the Free Software Foundation, Inc., 00021 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00022 */ 00023 00031 #ifndef P8EST_CONNECTIVITY_H 00032 #define P8EST_CONNECTIVITY_H 00033 00034 #include <sc_io.h> 00035 #include <p4est_base.h> 00036 00037 SC_EXTERN_C_BEGIN; 00038 00040 #define P8EST_DIM 3 00041 00045 #define P8EST_FACES (2 * P8EST_DIM) 00046 00049 #define P8EST_CHILDREN 8 00050 00051 #define P8EST_HALF (P8EST_CHILDREN / 2) 00052 00053 #define P8EST_EDGES 12 00054 00055 #define P8EST_INSUL 27 00056 00057 /* size of face transformation encoding */ 00058 #define P8EST_FTRANSFORM 9 00059 00061 #define P8EST_STRING "p8est" 00062 00063 /* Increase this number whenever the on-disk format for 00064 * p8est_connectivity, p8est, or any other 3D data structure changes. 00065 * The format for reading and writing must be the same. 00066 */ 00067 #define P8EST_ONDISK_FORMAT 0x3000009 00068 00079 typedef enum 00080 { 00081 /* make sure to have different values 2D and 3D */ 00082 P8EST_CONNECT_FACE = 31, 00083 P8EST_CONNECT_EDGE = 32, 00084 P8EST_CONNECT_CORNER = 33, 00085 P8EST_CONNECT_FULL = P8EST_CONNECT_CORNER 00086 } 00087 p8est_connect_type_t; 00088 00090 typedef enum 00091 { 00092 P8EST_CONN_ENCODE_NONE = SC_IO_ENCODE_NONE, 00093 P8EST_CONN_ENCODE_LAST 00094 } 00095 p8est_connectivity_encode_t; 00096 00101 int p8est_connect_type_int (p8est_connect_type_t btype); 00102 00107 const char *p8est_connect_type_string (p8est_connect_type_t btype); 00108 00154 typedef struct p8est_connectivity 00155 { 00156 p4est_topidx_t num_vertices; 00159 p4est_topidx_t num_trees; 00160 p4est_topidx_t num_edges; 00162 p4est_topidx_t num_corners; 00165 double *vertices; 00167 p4est_topidx_t *tree_to_vertex; 00170 int8_t *tree_to_attr; 00172 p4est_topidx_t *tree_to_tree; 00174 int8_t *tree_to_face; 00176 p4est_topidx_t *tree_to_edge; 00178 p4est_topidx_t *ett_offset; 00180 p4est_topidx_t *edge_to_tree; 00181 int8_t *edge_to_edge; 00183 p4est_topidx_t *tree_to_corner; 00185 p4est_topidx_t *ctt_offset; 00187 p4est_topidx_t *corner_to_tree; 00188 int8_t *corner_to_corner; 00190 } 00191 p8est_connectivity_t; 00192 00197 size_t p8est_connectivity_memory_used (p8est_connectivity_t * 00198 conn); 00199 00200 typedef struct 00201 { 00202 p4est_topidx_t ntree; 00203 int8_t nedge, naxis[3], nflip, corners; 00204 } 00205 p8est_edge_transform_t; 00206 00207 typedef struct 00208 { 00209 int8_t iedge; 00210 sc_array_t edge_transforms; 00211 } 00212 p8est_edge_info_t; 00213 00214 typedef struct 00215 { 00216 p4est_topidx_t ntree; 00217 int8_t ncorner; 00218 } 00219 p8est_corner_transform_t; 00220 00221 typedef struct 00222 { 00223 p4est_topidx_t icorner; 00224 sc_array_t corner_transforms; 00225 } 00226 p8est_corner_info_t; 00227 00229 extern const int p8est_face_corners[6][4]; 00230 00232 extern const int p8est_face_edges[6][4]; 00233 00235 extern const int p8est_face_dual[6]; 00236 00238 extern const int p8est_face_permutations[8][4]; 00239 00241 extern const int p8est_face_permutation_sets[3][4]; 00242 00246 extern const int p8est_face_permutation_refs[6][6]; 00247 00249 extern const int p8est_edge_faces[12][2]; 00250 00252 extern const int p8est_edge_corners[12][2]; 00253 00255 extern const int p8est_edge_face_corners[12][6][2]; 00256 00258 extern const int p8est_corner_faces[8][3]; 00259 00261 extern const int p8est_corner_edges[8][3]; 00262 00264 extern const int p8est_corner_face_corners[8][6]; 00265 00267 extern const int p8est_child_edge_faces[8][12]; 00268 00270 extern const int p8est_child_corner_faces[8][8]; 00271 00273 extern const int p8est_child_corner_edges[8][8]; 00274 00285 p8est_connectivity_t *p8est_connectivity_new (p4est_topidx_t num_vertices, 00286 p4est_topidx_t num_trees, 00287 p4est_topidx_t num_edges, 00288 p4est_topidx_t num_ett, 00289 p4est_topidx_t num_corners, 00290 p4est_topidx_t num_ctt); 00291 00302 p8est_connectivity_t *p8est_connectivity_new_copy (p4est_topidx_t 00303 num_vertices, 00304 p4est_topidx_t num_trees, 00305 p4est_topidx_t num_edges, 00306 p4est_topidx_t num_corners, 00307 const double *vertices, 00308 const p4est_topidx_t * ttv, 00309 const p4est_topidx_t * ttt, 00310 const int8_t * ttf, 00311 const p4est_topidx_t * tte, 00312 const p4est_topidx_t * 00313 eoff, 00314 const p4est_topidx_t * ett, 00315 const int8_t * ete, 00316 const p4est_topidx_t * ttc, 00317 const p4est_topidx_t * 00318 coff, 00319 const p4est_topidx_t * ctt, 00320 const int8_t * ctc); 00321 00324 void p8est_connectivity_destroy (p8est_connectivity_t * 00325 connectivity); 00326 00333 void p8est_connectivity_set_attr (p8est_connectivity_t * conn, 00334 int enable_tree_attr); 00335 00339 int p8est_connectivity_is_valid (p8est_connectivity_t * 00340 connectivity); 00341 00345 int p8est_connectivity_is_equal (p8est_connectivity_t * conn1, 00346 p8est_connectivity_t * 00347 conn2); 00348 00354 int p8est_connectivity_sink (p8est_connectivity_t * conn, 00355 sc_io_sink_t * sink); 00356 00362 sc_array_t *p8est_connectivity_deflate (p8est_connectivity_t * conn, 00363 p8est_connectivity_encode_t 00364 code); 00365 00371 int p8est_connectivity_save (const char *filename, 00372 p8est_connectivity_t * 00373 connectivity); 00374 00379 p8est_connectivity_t *p8est_connectivity_source (sc_io_source_t * source); 00380 00385 p8est_connectivity_t *p8est_connectivity_inflate (sc_array_t * buffer); 00386 00392 p8est_connectivity_t *p8est_connectivity_load (const char *filename, 00393 size_t * bytes); 00394 00397 p8est_connectivity_t *p8est_connectivity_new_unitcube (void); 00398 00401 p8est_connectivity_t *p8est_connectivity_new_periodic (void); 00402 00407 p8est_connectivity_t *p8est_connectivity_new_rotwrap (void); 00408 00411 p8est_connectivity_t *p8est_connectivity_new_twocubes (void); 00412 00416 p8est_connectivity_t *p8est_connectivity_new_twowrap (void); 00417 00421 p8est_connectivity_t *p8est_connectivity_new_rotcubes (void); 00422 00426 p8est_connectivity_t *p8est_connectivity_new_brick (int m, int n, int p, 00427 int periodic_a, 00428 int periodic_b, 00429 int periodic_c); 00430 00436 p8est_connectivity_t *p8est_connectivity_new_shell (void); 00437 00443 p8est_connectivity_t *p8est_connectivity_new_sphere (void); 00444 00458 p8est_connectivity_t *p8est_connectivity_new_byname (const char *name); 00459 00478 void p8est_expand_face_transform (int iface, int nface, 00479 int ftransform[]); 00480 00490 p4est_topidx_t p8est_find_face_transform (p8est_connectivity_t * 00491 connectivity, 00492 p4est_topidx_t itree, 00493 int iface, int ftransform[]); 00494 00500 void p8est_find_edge_transform (p8est_connectivity_t * 00501 connectivity, 00502 p4est_topidx_t itree, 00503 int iedge, 00504 p8est_edge_info_t * ei); 00505 00511 void p8est_find_corner_transform (p8est_connectivity_t * 00512 connectivity, 00513 p4est_topidx_t itree, 00514 int icorner, 00515 p8est_corner_info_t * ci); 00516 00526 void p8est_connectivity_complete (p8est_connectivity_t * conn); 00527 00542 void p8est_connectivity_permute (p8est_connectivity_t * conn, 00543 sc_array_t * perm, 00544 int is_current_to_new); 00545 00546 #ifdef P4EST_METIS 00547 00570 void p8est_connectivity_reorder (MPI_Comm comm, int k, 00571 p8est_connectivity_t * conn, 00572 p8est_connect_type_t ctype); 00573 00574 #endif /* P4EST_METIS */ 00575 00591 void p8est_connectivity_join_faces (p8est_connectivity_t * 00592 conn, 00593 p4est_topidx_t tree_left, 00594 p4est_topidx_t tree_right, 00595 int face_left, 00596 int face_right, 00597 int orientation); 00598 00609 int p8est_connectivity_is_equivalent (p8est_connectivity_t * 00610 conn1, 00611 p8est_connectivity_t * 00612 conn2); 00613 00615 /*@unused@*/ 00616 static inline p8est_edge_transform_t * 00617 p8est_edge_array_index (sc_array_t * array, size_t it) 00618 { 00619 P4EST_ASSERT (array->elem_size == sizeof (p8est_edge_transform_t)); 00620 P4EST_ASSERT (it < array->elem_count); 00621 00622 return (p8est_edge_transform_t *) (array->array + 00623 sizeof (p8est_edge_transform_t) * it); 00624 } 00625 00627 /*@unused@*/ 00628 static inline p8est_corner_transform_t * 00629 p8est_corner_array_index (sc_array_t * array, size_t it) 00630 { 00631 P4EST_ASSERT (array->elem_size == sizeof (p8est_corner_transform_t)); 00632 P4EST_ASSERT (it < array->elem_count); 00633 00634 return 00635 (p8est_corner_transform_t *) (array->array + 00636 sizeof (p8est_corner_transform_t) * it); 00637 } 00638 00639 int p8est_connectivity_read_inp_stream (FILE * stream, 00640 p4est_topidx_t * 00641 num_vertices, 00642 p4est_topidx_t * 00643 num_trees, 00644 double *vertices, 00645 p4est_topidx_t * 00646 tree_to_vertex); 00647 00648 p8est_connectivity_t *p8est_connectivity_read_inp (const char *filename); 00649 00650 SC_EXTERN_C_END; 00651 00652 #endif /* !P8EST_CONNECTIVITY_H */