From fa23cea0b3a78270bde4924b36bd2108950c59c6 Mon Sep 17 00:00:00 2001 From: "Dreyer, Lukas" Date: Thu, 9 Feb 2023 13:52:11 +0100 Subject: [PATCH 001/255] Partition ghost attributes --- src/t8_cmesh/t8_cmesh_commit.c | 53 +++++++++---- src/t8_cmesh/t8_cmesh_trees.c | 138 ++++++++++++++++++++++++--------- src/t8_cmesh/t8_cmesh_trees.h | 12 ++- 3 files changed, 154 insertions(+), 49 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_commit.c b/src/t8_cmesh/t8_cmesh_commit.c index 0f71fd0898..82fedd14c0 100644 --- a/src/t8_cmesh/t8_cmesh_commit.c +++ b/src/t8_cmesh/t8_cmesh_commit.c @@ -82,25 +82,29 @@ t8_cmesh_set_shmem_type (sc_MPI_Comm comm) t8_shmem_set_type (comm, T8_SHMEM_BEST_TYPE); } -void -t8_cmesh_add_attributes (t8_cmesh_t cmesh) +static void +t8_cmesh_add_attributes (t8_cmesh_t cmesh, sc_hash_t * ghost_ids, + size_t *attribute_data_offset) { t8_stash_attribute_struct_t *attribute; t8_stash_t stash = cmesh->stash; t8_locidx_t ltree; size_t si, sj; + t8_ghost_facejoin_t *temp_facejoin, **facejoin_pp; /* used to lookup global ghost ids in the hash */ + + temp_facejoin = T8_ALLOC_ZERO (t8_ghost_facejoin_t, 1); ltree = -1; for (si = 0, sj = 0; si < stash->attributes.elem_count; si++, sj++) { attribute = (t8_stash_attribute_struct_t *) sc_array_index (&stash->attributes, si); + if (attribute->id > ltree) { + /* Enter a new tree */ + ltree = attribute->id; + sj = 0; + } if (cmesh->first_tree <= attribute->id && attribute->id < cmesh->first_tree + cmesh->num_local_trees) { - if (attribute->id > ltree) { - /* Enter a new tree */ - ltree = attribute->id; - sj = 0; - } /* attribute->id is a gloidx that is casted to a locidx here. * Should not cause problems, since mesh is replicated */ T8_ASSERT (attribute->id - cmesh->first_tree == @@ -108,7 +112,18 @@ t8_cmesh_add_attributes (t8_cmesh_t cmesh) t8_cmesh_trees_add_attribute (cmesh->trees, 0, attribute, attribute->id - cmesh->first_tree, sj); } + else { + T8_ASSERT (ghost_ids != NULL); + temp_facejoin->ghost_id = attribute->id; + if (sc_hash_lookup (ghost_ids, temp_facejoin, (void ***) &facejoin_pp)) { + /* attribute is on a ghost tree */ + t8_cmesh_trees_add_ghost_attribute (cmesh->trees, 0, attribute, + (*facejoin_pp)->local_id, sj, + attribute_data_offset); + } + } } + T8_FREE (temp_facejoin); } static void @@ -158,7 +173,7 @@ t8_cmesh_commit_replicated_new (t8_cmesh_t cmesh) t8_stash_attribute_sort (cmesh->stash); cmesh->num_trees = cmesh->num_local_trees = num_trees; cmesh->first_tree = 0; - t8_cmesh_add_attributes (cmesh); + t8_cmesh_add_attributes (cmesh, NULL, NULL); /* Set all face connections */ t8_cmesh_trees_set_all_boundary (cmesh, cmesh->trees); @@ -193,8 +208,10 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm) int8_t *ttf, *ttf2; t8_stash_joinface_struct_t *joinface; t8_ctree_t tree1, tree2; + t8_cghost_t ghost1; int F; size_t si; + size_t attribute_data_offset; #if T8_ENABLE_DEBUG sc_flopinfo_t fi, snapshot; @@ -203,8 +220,7 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm) sc_hash_t *ghost_ids; sc_mempool_t *ghost_facejoin_mempool; - struct ghost_facejoins_struct *ghost_facejoin = NULL, *temp_facejoin, - **facejoin_pp; + t8_ghost_facejoin_t *ghost_facejoin = NULL, *temp_facejoin, **facejoin_pp; size_t joinfaces_it, iz; t8_gloidx_t last_tree = cmesh->num_local_trees + cmesh->first_tree - 1, id1, id2; @@ -214,7 +230,7 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm) t8_stash_class_struct_t *classentry; int id1_istree, id2_istree; #if T8_ENABLE_DEBUG - t8_cghost_t ghost1, ghost2; + t8_cghost_t ghost2; #endif #if T8_ENABLE_DEBUG @@ -364,6 +380,7 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm) for (si = 0; si < cmesh->stash->attributes.elem_count; si++) { attribute = (t8_stash_attribute_struct_t *) sc_array_index (&cmesh->stash->attributes, si); + temp_facejoin->ghost_id = attribute->id; if (cmesh->first_tree <= attribute->id && attribute->id < cmesh->first_tree + cmesh->num_local_trees) { /* attribute->id is a gloidx that is casted to a locidx here. @@ -373,10 +390,20 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm) tree1 = t8_cmesh_trees_get_tree (cmesh->trees, attribute->id - cmesh->first_tree); tree1->num_attributes++; + /* temporarily misuse the att_offset to store the total attribute size, until t8_cmesh_trees_finish_part */ tree1->att_offset += attribute->attr_size; } + else if (sc_hash_lookup (ghost_ids, temp_facejoin, + (void ***) &facejoin_pp)) { + /* attribute is on a ghost tree */ + ghost1 = + t8_cmesh_trees_get_ghost (cmesh->trees, (*facejoin_pp)->local_id); + ghost1->num_attributes++; + /* temporarily misuse the att_offset to store the total attribute size, until t8_cmesh_trees_finish_part */ + ghost1->att_offset += attribute->attr_size; + } } - t8_cmesh_trees_finish_part (cmesh->trees, 0); + attribute_data_offset = t8_cmesh_trees_finish_part (cmesh->trees, 0); t8_cmesh_trees_set_all_boundary (cmesh, cmesh->trees); /* Go through all face_neighbour entries and parse every @@ -493,7 +520,7 @@ t8_cmesh_commit_partitioned_new (t8_cmesh_t cmesh, sc_MPI_Comm comm) * counting the attributes per tree. */ t8_stash_attribute_sort (cmesh->stash); - t8_cmesh_add_attributes (cmesh); + t8_cmesh_add_attributes (cmesh, ghost_ids, &attribute_data_offset); /* compute global number of trees. id1 serves as buffer since * global number and local number have different datatypes */ diff --git a/src/t8_cmesh/t8_cmesh_trees.c b/src/t8_cmesh/t8_cmesh_trees.c index c036a003a3..7bda486029 100644 --- a/src/t8_cmesh/t8_cmesh_trees.c +++ b/src/t8_cmesh/t8_cmesh_trees.c @@ -142,6 +142,8 @@ t8_cmesh_trees_add_ghost (t8_cmesh_trees_t trees, t8_locidx_t lghost_index, ghost->eclass = eclass; ghost->treeid = gtree_id; ghost->neigh_offset = 0; + ghost->att_offset = 0; + ghost->num_attributes = 0; trees->ghost_to_proc[lghost_index] = proc; /* Insert this ghosts global id into the hash table */ /* build the entry */ @@ -233,29 +235,42 @@ t8_cmesh_trees_start_part (t8_cmesh_trees_t trees, int proc, /* The workflow can be: call start_part, set tree and ghost classes maually, call * init_attributes, call finish_part, successively call add_attributes * and also set all face neighbors (TODO: write function)*/ -void +size_t t8_cmesh_trees_finish_part (t8_cmesh_trees_t trees, int proc) { t8_part_tree_t part; t8_ctree_t tree; t8_cghost_t ghost; - size_t attr_bytes, face_neigh_bytes, temp_offset, - first_face, num_attributes; + size_t tree_attr_bytes; + size_t ghost_attr_bytes; + size_t face_neigh_bytes; /* count the total number of bytes needed for face_neighbor information */ + size_t first_face; /* offset of the first face neighbor information */ + size_t first_tree; /* offset of the first tree */ + size_t first_ghost; /* offset of the first ghost */ + size_t temp_offset; /* offset of the currently looked at tree/ghost */ + size_t num_tree_attributes; /* total number of tree attributes */ + size_t num_ghost_attributes; /* total number of ghost attributes */ t8_attribute_info_struct_t *attr; t8_locidx_t it; #ifndef SC_ENABLE_REALLOC - char *temp; + char *temp; /* temporary storage to emulate functionality of realloc */ #endif T8_ASSERT (trees != NULL); part = t8_cmesh_trees_get_part (trees, proc); T8_ASSERT (part != NULL); - attr_bytes = face_neigh_bytes = 0; + num_tree_attributes = num_ghost_attributes = 0; + tree_attr_bytes = ghost_attr_bytes = face_neigh_bytes = 0; + /* The offset of the first tree */ + first_tree = 0; /* The offset of the first ghost */ - temp_offset = part->num_trees * sizeof (t8_ctree_struct_t); + first_ghost = first_tree + part->num_trees * sizeof (t8_ctree_struct_t); /* The offset of the first ghost face */ - first_face = temp_offset + part->num_ghosts * sizeof (t8_cghost_struct_t); + first_face = first_ghost + part->num_ghosts * sizeof (t8_cghost_struct_t); + + /* First pass through ghosts to set the face neighbor offsets */ + temp_offset = first_ghost; for (it = 0; it < part->num_ghosts; it++) { ghost = t8_part_tree_get_ghost (part, it + part->first_ghost_id); ghost->neigh_offset = first_face + face_neigh_bytes - temp_offset; @@ -268,43 +283,58 @@ t8_cmesh_trees_finish_part (t8_cmesh_trees_t trees, int proc) T8_ASSERT (face_neigh_bytes % T8_PADDING_SIZE == 0); temp_offset += sizeof (t8_cghost_struct_t); } - /* TODO: passing through trees twice is not optimal. Can we do it all in one round? - Currently we need the first one to compute the total number of face bytes */ + /* First pass through trees to set the face neighbor offsets */ temp_offset = 0; - num_attributes = 0; for (it = 0; it < part->num_trees; it++) { tree = t8_part_tree_get_tree (part, it + part->first_tree_id); tree->neigh_offset = first_face + face_neigh_bytes - temp_offset; face_neigh_bytes += t8_eclass_num_faces[tree->eclass] * (sizeof (t8_locidx_t) + sizeof (int8_t)); - num_attributes += tree->num_attributes; face_neigh_bytes += T8_ADD_PADDING (face_neigh_bytes); /* This is for padding, such that face_neigh_bytes %4 == 0 */ T8_ASSERT (face_neigh_bytes % T8_PADDING_SIZE == 0); temp_offset += sizeof (t8_ctree_struct_t); } + /* Second pass through trees to set attribute offsets */ temp_offset = 0; - num_attributes = 0; for (it = 0; it < part->num_trees; it++) { tree = t8_part_tree_get_tree (part, it + part->first_tree_id); - attr_bytes += tree->att_offset; /* att_offset stored the total size of the attributes */ + tree_attr_bytes += tree->att_offset; /* att_offset temporarily stored the total size of the attributes */ /* The att_offset of the tree is the first_face plus the number of attribute * bytes used by previous trees minus the temp_offset */ tree->att_offset = first_face - temp_offset + face_neigh_bytes + - num_attributes * sizeof (t8_attribute_info_struct_t); - num_attributes += tree->num_attributes; + num_tree_attributes * sizeof (t8_attribute_info_struct_t); + num_tree_attributes += tree->num_attributes; temp_offset += sizeof (t8_ctree_struct_t); } - attr_bytes += num_attributes * sizeof (t8_attribute_info_struct_t); + tree_attr_bytes += + num_tree_attributes * sizeof (t8_attribute_info_struct_t); + + /* Second pass through ghosts to set attribute offsets */ + temp_offset = first_ghost; + for (it = 0; it < part->num_ghosts; it++) { + ghost = t8_part_tree_get_ghost (part, it + part->first_ghost_id); + ghost_attr_bytes += ghost->att_offset; /* att_offset temporarily stored the total size of the attributes */ + /* The att_offset of the tree is the first_face plus the number of attribute + * bytes used by previous trees minus the temp_offset */ + ghost->att_offset = + first_face - temp_offset + face_neigh_bytes + tree_attr_bytes + + num_ghost_attributes * sizeof (t8_attribute_info_struct_t); + num_ghost_attributes += tree->num_attributes; + temp_offset += sizeof (t8_cghost_struct_t); + } + ghost_attr_bytes += + num_ghost_attributes * sizeof (t8_attribute_info_struct_t); + size_t attr_bytes = tree_attr_bytes + ghost_attr_bytes; + /* Done setting all tree and ghost offsets */ - /* Allocate memory, first_face + attr_bytes gives the new total byte count */ - /* TODO: Since we use realloc and padding, memcmp will not work, solved with memset */ - first_face = part->num_trees * sizeof (t8_ctree_struct_t) + part->num_ghosts * sizeof (t8_cghost_struct_t); /* Total number of bytes in first_tree */ + /* Allocate memory, first_face + attr_bytes + face_neigh_bytes gives the new total byte count */ #ifdef SC_ENABLE_REALLOC - SC_REALLOC (part->first_tree, char, first_face + attr_bytes - + face_neigh_bytes); + /* Since we use realloc and padding, memcmp will not work if we don't set everything to zero, solved with memset */ + SC_REALLOC (part->first_tree, char, first_face + attr_bytes + + +face_neigh_bytes); memset (part->first_tree + first_face, 0, attr_bytes + face_neigh_bytes) #else temp = T8_ALLOC_ZERO (char, first_face + attr_bytes + face_neigh_bytes); @@ -312,14 +342,13 @@ t8_cmesh_trees_finish_part (t8_cmesh_trees_t trees, int proc) T8_FREE (part->first_tree); part->first_tree = temp; #endif - /* Set attribute first offset, works even if there are no attributes */ - /* TODO: It does not! This is a bug that should be fixed soon */ - if (num_attributes > 0) { + if (num_tree_attributes > 0) { attr = (t8_attribute_info_struct_t *) (part->first_tree + first_face + face_neigh_bytes); attr->attribute_offset = - num_attributes * sizeof (t8_attribute_info_struct_t); + num_tree_attributes * sizeof (t8_attribute_info_struct_t); } + return num_ghost_attributes * sizeof (t8_attribute_info_struct_t); } void @@ -638,12 +667,10 @@ t8_cmesh_trees_init_attributes (t8_cmesh_trees_t trees, t8_locidx_t ltree_id, /* TODO: comment. * add a new attribute to a tree, the number of already added attributes is - * temporarily stored in tree->num_attributes. - */ -/* last is true if this is the last attribute of that tree */ -/* TODO: instead of all these arguments we could accept a stash_attribute_struct */ -/* By adding successively we save us the step of sorting the attribute array by tree_id, - * which is expansive */ + * temporarily stored in tree->num_attributes. */ +/* The offset of the attribute info for which to add data must already be set. + * This is achieved by setting the first offset outside before adding + * any attributes, and setting the offset of the next attribute in this function */ /* TODO: This is not the final version, currently we still need the attributes * array to be sorted! */ void @@ -658,7 +685,8 @@ t8_cmesh_trees_add_attribute (t8_cmesh_trees_t trees, int proc, size_t offset; T8_ASSERT (trees != NULL); - T8_ASSERT (attr != NULL || attr->attr_size == 0); + T8_ASSERT (attr != NULL); + T8_ASSERT (attr->attr_data != NULL || attr->attr_size == 0); T8_ASSERT (attr->id >= 0); part = t8_cmesh_trees_get_part (trees, proc); @@ -673,13 +701,17 @@ t8_cmesh_trees_add_attribute (t8_cmesh_trees_t trees, int proc, attr_info->key = attr->key; attr_info->package_id = attr->package_id; attr_info->attribute_size = attr->attr_size; - /* Store offset */ - offset = attr_info->attribute_offset; - /* Get next attribute and set its offset */ + /* If we are not yet at the last attribute of the part, + * get next attribute and set its offset*/ if (!(index == (size_t) tree->num_attributes - 1 && part->num_trees == tree_id + 1 - part->first_tree_id)) { + /* Store offset of current attribute */ + offset = attr_info->attribute_offset; attr_info = attr_info + 1; attr_info->attribute_offset = offset + attr->attr_size; + /* if the current attribute was the last attribute of the tree + * the next attribute offset must be corrected by the size of + * the attribute infos of the current tree */ if (index == (size_t) tree->num_attributes - 1) { attr_info->attribute_offset -= tree->num_attributes * sizeof (t8_attribute_info_struct_t); @@ -687,6 +719,42 @@ t8_cmesh_trees_add_attribute (t8_cmesh_trees_t trees, int proc, } } +void +t8_cmesh_trees_add_ghost_attribute (t8_cmesh_trees_t trees, int proc, + t8_stash_attribute_struct_t *attr, + t8_locidx_t local_ghost_id, size_t index, + size_t *attribute_data_offset) +{ + t8_part_tree_t part; + t8_cghost_t ghost; + char *new_attr_data; + t8_attribute_info_struct_t *attr_info; + + T8_ASSERT (trees != NULL); + T8_ASSERT (attr != NULL); + T8_ASSERT (attr->attr_data != NULL || attr->attr_size == 0); + T8_ASSERT (attr->id >= 0); + + part = t8_cmesh_trees_get_part (trees, proc); + ghost = t8_part_tree_get_ghost (part, local_ghost_id); + + attr_info = T8_GHOST_ATTR_INFO (ghost, index); + attr_info->attribute_offset = + *attribute_data_offset - + local_ghost_id * sizeof (t8_attribute_info_struct_t); + new_attr_data = T8_GHOST_ATTR (ghost, attr_info); + + memcpy (new_attr_data, attr->attr_data, attr->attr_size); + + /* Set new values */ + attr_info->key = attr->key; + attr_info->package_id = attr->package_id; + attr_info->attribute_size = attr->attr_size; + + *attribute_data_offset += attr->attr_size; + +} + /* gets a key_id_pair as first argument and an attribute as second */ static int t8_cmesh_trees_compare_keyattr (const void *A1, const void *A2) diff --git a/src/t8_cmesh/t8_cmesh_trees.h b/src/t8_cmesh/t8_cmesh_trees.h index b0aa188572..1f3b9b5c2c 100644 --- a/src/t8_cmesh/t8_cmesh_trees.h +++ b/src/t8_cmesh/t8_cmesh_trees.h @@ -227,7 +227,7 @@ void t8_cmesh_trees_start_part (t8_cmesh_trees_t trees, * \param [in,out] trees The trees structure to be updated. * \param [in] proc The number of the part to be finished. */ -void t8_cmesh_trees_finish_part (t8_cmesh_trees_t trees, +size_t t8_cmesh_trees_finish_part (t8_cmesh_trees_t trees, int proc); /** Copy the tree_to_proc and ghost_to_proc arrays of one tree structure to @@ -462,6 +462,16 @@ void t8_cmesh_trees_add_attribute (t8_cmesh_trees_t trees, *attr, t8_locidx_t tree_id, size_t index); +void t8_cmesh_trees_add_ghost_attribute (t8_cmesh_trees_t + trees, int proc, + t8_stash_attribute_struct_t + *attr, + t8_locidx_t + local_ghost_id, + size_t index, + size_t + *attribute_data_offset); + /** Return the number of parts of a trees structure. * \param [in] trees The trees structure. * \return The number of parts in \a trees. From cf395989c4706db7a9ed88abf028a62cf225d928 Mon Sep 17 00:00:00 2001 From: "Dreyer, Lukas" Date: Mon, 27 Feb 2023 10:31:43 +0100 Subject: [PATCH 002/255] fix copy paste error --- src/t8_cmesh/t8_cmesh_trees.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_trees.c b/src/t8_cmesh/t8_cmesh_trees.c index 7bda486029..dea4087508 100644 --- a/src/t8_cmesh/t8_cmesh_trees.c +++ b/src/t8_cmesh/t8_cmesh_trees.c @@ -322,7 +322,7 @@ t8_cmesh_trees_finish_part (t8_cmesh_trees_t trees, int proc) ghost->att_offset = first_face - temp_offset + face_neigh_bytes + tree_attr_bytes + num_ghost_attributes * sizeof (t8_attribute_info_struct_t); - num_ghost_attributes += tree->num_attributes; + num_ghost_attributes += ghost->num_attributes; temp_offset += sizeof (t8_cghost_struct_t); } ghost_attr_bytes += From b8f0e7858a620efdc3185a4408f7e6a30947e0de Mon Sep 17 00:00:00 2001 From: ililikakis Date: Mon, 27 Feb 2023 15:48:29 +0100 Subject: [PATCH 003/255] wrapper function for each eclass function --- src/t8_cmesh/t8_cmesh_examples.c | 116 +++++++++++++++++++++++++++++++ src/t8_cmesh/t8_cmesh_examples.h | 20 ++++++ 2 files changed, 136 insertions(+) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 0c67bda254..7c97de1689 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -846,6 +846,122 @@ t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, return cmesh; } +static t8_cmesh_t +t8_cmesh_new_quad_ext (const double *boundary, + const t8_locidx_t trees_x, + const t8_locidx_t trees_y, + sc_MPI_Comm comm) +{ + /* x axis */ + T8_ASSERT (trees_x > 0); + T8_ASSERT (boundary[3] > boundary[0]); + T8_ASSERT (boundary[9] > boundary[6]); + /* y axis */ + T8_ASSERT (trees_y > 0); + T8_ASSERT (boundary[7] > boundary[1]); + T8_ASSERT (boundary[10] > boundary[4]); + + t8_cmesh_t cmesh; + t8_cmesh_init (&cmesh); + /* We use standard linear geometry */ + const t8_geometry_c *linear_geom = t8_geometry_linear_new (2); + t8_cmesh_register_geometry (cmesh, linear_geom); + + + + + + t8_cmesh_commit (cmesh, comm); + return cmesh; +} + +static t8_cmesh_t +t8_cmesh_new_hex_ext (const double *boundary, + const t8_locidx_t trees_x, + const t8_locidx_t trees_y, + const t8_locidx_t trees_z, + sc_MPI_Comm comm) +{ + /* x axis */ + T8_ASSERT (trees_x > 0); + T8_ASSERT (boundary[3] > boundary[0]); + T8_ASSERT (boundary[9] > boundary[6]); + T8_ASSERT (boundary[15] > boundary[12]); + T8_ASSERT (boundary[21] > boundary[18]); + /* y axis */ + T8_ASSERT (trees_y > 0); + T8_ASSERT (boundary[7] > boundary[1]); + T8_ASSERT (boundary[10] > boundary[4]); + T8_ASSERT (boundary[19] > boundary[13]); + T8_ASSERT (boundary[22] > boundary[16]); + /* z axis */ + T8_ASSERT (trees_z > 0); + T8_ASSERT (boundary[14] > boundary[2]); + T8_ASSERT (boundary[17] > boundary[5]); + T8_ASSERT (boundary[20] > boundary[8]); + T8_ASSERT (boundary[23] > boundary[11]); + + t8_cmesh_t cmesh; + t8_cmesh_init (&cmesh); + /* We use standard linear geometry */ + const t8_geometry_c *linear_geom = t8_geometry_linear_new (3); + t8_cmesh_register_geometry (cmesh, linear_geom); + + + + + + t8_cmesh_commit (cmesh, comm); + return cmesh; +} + + +t8_cmesh_t +t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, + sc_MPI_Comm comm, + const double *boundary, + const t8_locidx_t trees_x, + const t8_locidx_t trees_y, + const t8_locidx_t trees_z) +{ + switch (eclass) { + case T8_ECLASS_VERTEX: + SC_ABORT ("T8_ECLASS_VERTEX is not yet supported by this function.\n"); + return NULL; + break; + case T8_ECLASS_LINE: + SC_ABORT ("T8_ECLASS_LINE is not yet supported by this function.\n"); + return NULL; + break; + case T8_ECLASS_TRIANGLE: + SC_ABORT ("T8_ECLASS_TRIANGLE is not yet supported by this function.\n"); + return NULL; + break; + case T8_ECLASS_QUAD: + return t8_cmesh_new_quad_ext (comm, boundary, trees_x, trees_y); + break; + case T8_ECLASS_TET: + SC_ABORT ("T8_ECLASS_TET is not yet supported by this function.\n"); + return NULL; + break; + case T8_ECLASS_HEX: + return t8_cmesh_new_hex_ext (comm, boundary, trees_x, trees_y, trees_z); + break; + case T8_ECLASS_PYRAMID: + SC_ABORT ("T8_ECLASS_PYRAMID is not yet supported by this function.\n"); + return NULL; + break; + case T8_ECLASS_PRISM: + SC_ABORT ("T8_ECLASS_PRISM is not yet supported by this function.\n"); + return NULL; + break; + default: + SC_ABORT ("Invalid eclass\n"); + return NULL; + } +} + + t8_cmesh_t t8_cmesh_new_periodic_line_more_trees (sc_MPI_Comm comm) { diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 3867279c6c..a7944f6cfb 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -101,6 +101,26 @@ t8_cmesh_t t8_cmesh_new_hypercube (t8_eclass_t eclass, int do_bcast, int do_partition, int periodic); +/** Construct a hypercube forest from one primitive tree class. + * \param [in] eclass This element class determines the dimension of the cube. + * \param [in] comm The mpi communicator to be used. + * \param [in] boundary The coordinate, that define the hypercube vertices. + * \param [in] trees_x The number of trees along the x-axis. + * \param [in] trees_y The number of trees along the y-axis. + * Only required if \a eclass is 2D or 3D. + * \param [in] trees_z The number of trees along the z-axis. + * Only required if \a eclass is 3D. + * \return A committed t8_cmesh structure with + * \a trees_x * \a trees_y * \a trees_z many trees of class \a eclass. + * \note \a boundary must point to an array with 3*8 (3D), 3*4 (2D), 3*2 (1D), or 3 (0D) entries. + */ +t8_cmesh_t t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, + sc_MPI_Comm comm, + const double *boundary, + const t8_locidx_t trees_x, + const t8_locidx_t trees_y, + const t8_locidx_t trees_z); + /** Hybercube with 6 Tets, 6 Prism, 4 Hex. * \param [in] comm The mpi communicator to be used. * \param [in] do_partition If non-zero create a partitioned cmesh. From 7cd426949519f93ff405c586ed22bb093ca6c87d Mon Sep 17 00:00:00 2001 From: ililikakis Date: Mon, 27 Feb 2023 15:58:19 +0100 Subject: [PATCH 004/255] added new vec function Y = a*X --- src/t8_vec.c | 10 ++++++++++ src/t8_vec.h | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/t8_vec.c b/src/t8_vec.c index 2a5b989a62..57b364ba8f 100644 --- a/src/t8_vec.c +++ b/src/t8_vec.c @@ -56,6 +56,16 @@ t8_vec_ax (double vec_x[3], double alpha) } } +void +t8_vec_axy (const double vec_x[3], double vec_y[3], const double alpha) +{ + int i; + + for (i = 0; i < 3; i++) { + vec_y[i] = vec_x[i] * alpha; + } +} + /* y = ax + b */ void t8_vec_axb (const double vec_x[3], double vec_y[3], double alpha, double b) diff --git a/src/t8_vec.h b/src/t8_vec.h index e3fce02ad9..2add28c56c 100644 --- a/src/t8_vec.h +++ b/src/t8_vec.h @@ -52,6 +52,14 @@ double t8_vec_dist (const double vec_x[3], */ void t8_vec_ax (double vec_x[3], double alpha); +/** Compute Y = alpha * X + * \param [in] vec_x A 3D vector. + * \param [in] alpha A factor. + * \param [out] vec_z On output set to \a alpha * \a vec_x. + */ +void t8_vec_axy (const double vec_x[3], double vec_y[3], + const double alpha); + /** Y = alpha * X + b * \param [in] vec_x A 3D vector. * \param [out] vec_y On input, a 3D vector. From 6a6998d8e74b24631cb4452f896d36080b5616dc Mon Sep 17 00:00:00 2001 From: ililikakis Date: Mon, 27 Feb 2023 16:03:32 +0100 Subject: [PATCH 005/255] updated t8_vec.* to coding guidlines --- src/t8_vec.c | 42 +++++++++++++----------------------------- src/t8_vec.h | 8 ++++---- 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/src/t8_vec.c b/src/t8_vec.c index 57b364ba8f..7a2fed6556 100644 --- a/src/t8_vec.c +++ b/src/t8_vec.c @@ -25,10 +25,9 @@ double t8_vec_norm (const double vec[3]) { - int i; double norm = 0; - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { norm += vec[i] * vec[i]; } return sqrt (norm); @@ -37,21 +36,18 @@ t8_vec_norm (const double vec[3]) double t8_vec_dist (const double vec_x[3], const double vec_y[3]) { - int i; double dist = 0; - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { dist += SC_SQR (vec_x[i] - vec_y[i]); } return sqrt (dist); } void -t8_vec_ax (double vec_x[3], double alpha) +t8_vec_ax (double vec_x[3], const double alpha) { - int i; - - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { vec_x[i] *= alpha; } } @@ -59,31 +55,25 @@ t8_vec_ax (double vec_x[3], double alpha) void t8_vec_axy (const double vec_x[3], double vec_y[3], const double alpha) { - int i; - - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { vec_y[i] = vec_x[i] * alpha; } } /* y = ax + b */ void -t8_vec_axb (const double vec_x[3], double vec_y[3], double alpha, double b) +t8_vec_axb (const double vec_x[3], double vec_y[3], const double alpha, const double b) { - int i; - - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { vec_y[i] = alpha * vec_x[i] + b; } } /* y = y + alpha * x */ void -t8_vec_axpy (const double vec_x[3], double vec_y[3], double alpha) +t8_vec_axpy (const double vec_x[3], double vec_y[3], const double alpha) { - int i; - - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { vec_y[i] += alpha * vec_x[i]; } } @@ -91,12 +81,9 @@ t8_vec_axpy (const double vec_x[3], double vec_y[3], double alpha) /* z = y + alpha * x */ void t8_vec_axpyz (const double vec_x[3], const double vec_y[3], double vec_z[3], - double alpha) + const double alpha) { - - int i; - - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { vec_z[i] = vec_y[i] + alpha * vec_x[i]; } } @@ -104,10 +91,9 @@ t8_vec_axpyz (const double vec_x[3], const double vec_y[3], double vec_z[3], double t8_vec_dot (const double vec_x[3], const double vec_y[3]) { - int i; double dot = 0; - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { dot += vec_x[i] * vec_y[i]; } return dot; @@ -116,9 +102,7 @@ t8_vec_dot (const double vec_x[3], const double vec_y[3]) void t8_vec_cross (const double vec_x[3], const double vec_y[3], double cross[3]) { - int i; - - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { cross[i] = vec_x[(i + 1) % 3] * vec_y[(i + 2) % 3] - vec_x[(i + 2) % 3] * vec_y[(i + 1) % 3]; diff --git a/src/t8_vec.h b/src/t8_vec.h index 2add28c56c..a5eeddce5d 100644 --- a/src/t8_vec.h +++ b/src/t8_vec.h @@ -50,7 +50,7 @@ double t8_vec_dist (const double vec_x[3], * \param [in,out] vec_x A 3D vector. On output set to \a alpha * \a vec_x. * \param [in] alpha A factor. */ -void t8_vec_ax (double vec_x[3], double alpha); +void t8_vec_ax (double vec_x[3], const double alpha); /** Compute Y = alpha * X * \param [in] vec_x A 3D vector. @@ -69,7 +69,7 @@ void t8_vec_axy (const double vec_x[3], double vec_y[3], * \note It is possible that vec_x = vec_y on input to overwrite x */ void t8_vec_axb (const double vec_x[3], double vec_y[3], - double alpha, double b); + const double alpha, const double b); /** Y = Y + alpha * X * \param [in] vec_x A 3D vector. @@ -78,7 +78,7 @@ void t8_vec_axb (const double vec_x[3], double vec_y[3], * \param [in] alpha A factor. */ void t8_vec_axpy (const double vec_x[3], double vec_y[3], - double alpha); + const double alpha); /** Z = Y + alpha * X * \param [in] vec_x A 3D vector. @@ -87,7 +87,7 @@ void t8_vec_axpy (const double vec_x[3], double vec_y[3], */ void t8_vec_axpyz (const double vec_x[3], const double vec_y[3], double vec_z[3], - double alpha); + const double alpha); /** Dot product of X and Y. * \param [in] vec_x A 3D vector. From 12d69619ef8383f201e8cbb101d5318ae668d8c4 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Mon, 27 Feb 2023 16:07:11 +0100 Subject: [PATCH 006/255] indent t8_vec.* --- src/t8_vec.c | 3 ++- src/t8_vec.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/t8_vec.c b/src/t8_vec.c index 7a2fed6556..db5c726a19 100644 --- a/src/t8_vec.c +++ b/src/t8_vec.c @@ -62,7 +62,8 @@ t8_vec_axy (const double vec_x[3], double vec_y[3], const double alpha) /* y = ax + b */ void -t8_vec_axb (const double vec_x[3], double vec_y[3], const double alpha, const double b) +t8_vec_axb (const double vec_x[3], double vec_y[3], const double alpha, + const double b) { for (int i = 0; i < 3; i++) { vec_y[i] = alpha * vec_x[i] + b; diff --git a/src/t8_vec.h b/src/t8_vec.h index a5eeddce5d..fcece1118c 100644 --- a/src/t8_vec.h +++ b/src/t8_vec.h @@ -57,7 +57,7 @@ void t8_vec_ax (double vec_x[3], const double alpha); * \param [in] alpha A factor. * \param [out] vec_z On output set to \a alpha * \a vec_x. */ -void t8_vec_axy (const double vec_x[3], double vec_y[3], +void t8_vec_axy (const double vec_x[3], double vec_y[3], const double alpha); /** Y = alpha * X + b From 082352fce9fd8ac8369b4a050323452844fff783 Mon Sep 17 00:00:00 2001 From: "Dreyer, Lukas" Date: Mon, 27 Feb 2023 18:04:22 +0100 Subject: [PATCH 007/255] extend attribute test to partitioned meshes from stash --- src/t8_cmesh/t8_cmesh_examples.c | 14 +++++++- src/t8_cmesh/t8_cmesh_examples.h | 1 + .../t8_cmesh/t8_gtest_multiple_attributes.cxx | 36 +++++++++++++++++-- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 0c67bda254..8bc0bd5314 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1927,7 +1927,7 @@ t8_cmesh_new_full_hybrid (sc_MPI_Comm comm) t8_cmesh_t t8_cmesh_new_row_of_cubes (t8_locidx_t num_trees, const int set_attributes, - sc_MPI_Comm comm) + const int do_partition, sc_MPI_Comm comm) { T8_ASSERT (num_trees > 0); @@ -1973,6 +1973,18 @@ t8_cmesh_new_row_of_cubes (t8_locidx_t num_trees, const int set_attributes, t8_cmesh_set_join (cmesh, tree_id, tree_id + 1, 0, 1, 0); } + if (do_partition) { + int mpirank, mpisize, mpiret; + int first_tree, last_tree; + mpiret = sc_MPI_Comm_rank (comm, &mpirank); + SC_CHECK_MPI (mpiret); + mpiret = sc_MPI_Comm_size (comm, &mpisize); + SC_CHECK_MPI (mpiret); + first_tree = (mpirank * num_trees) / mpisize; + last_tree = ((mpirank + 1) * num_trees) / mpisize - 1; + t8_cmesh_set_partition_range (cmesh, 3, first_tree, last_tree); + } + t8_cmesh_commit (cmesh, comm); return cmesh; } diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 3867279c6c..2aa2a90c9d 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -273,6 +273,7 @@ t8_cmesh_t t8_cmesh_new_long_brick_pyramid (sc_MPI_Comm comm, */ t8_cmesh_t t8_cmesh_new_row_of_cubes (t8_locidx_t num_trees, const int set_attributes, + const int do_partition, sc_MPI_Comm comm); T8_EXTERN_C_END (); diff --git a/test/t8_cmesh/t8_gtest_multiple_attributes.cxx b/test/t8_cmesh/t8_gtest_multiple_attributes.cxx index ea84396be0..fb640e8a75 100644 --- a/test/t8_cmesh/t8_gtest_multiple_attributes.cxx +++ b/test/t8_cmesh/t8_gtest_multiple_attributes.cxx @@ -47,19 +47,23 @@ class cmesh_multiple_attributes : public testing::TestWithParam{ void SetUp() override { num_trees = GetParam(); - cmesh_one_at = t8_cmesh_new_row_of_cubes (num_trees, 0, sc_MPI_COMM_WORLD); + cmesh_one_at = t8_cmesh_new_row_of_cubes (num_trees, 0, 0, sc_MPI_COMM_WORLD); cmesh_one_at = t8_cmesh_partition_cmesh (cmesh_one_at, sc_MPI_COMM_WORLD); - cmesh_mult_at = t8_cmesh_new_row_of_cubes (num_trees, 1, sc_MPI_COMM_WORLD); + cmesh_mult_at = t8_cmesh_new_row_of_cubes (num_trees, 1, 0, sc_MPI_COMM_WORLD); cmesh_mult_at = t8_cmesh_partition_cmesh (cmesh_mult_at, sc_MPI_COMM_WORLD); + + cmesh_mult_at_from_stash = t8_cmesh_new_row_of_cubes (num_trees, 1, 1, sc_MPI_COMM_WORLD); } void TearDown() override { t8_cmesh_destroy (&cmesh_one_at); t8_cmesh_destroy (&cmesh_mult_at); + t8_cmesh_destroy (&cmesh_mult_at_from_stash); } t8_cmesh_t cmesh_one_at; t8_cmesh_t cmesh_mult_at; + t8_cmesh_t cmesh_mult_at_from_stash; t8_locidx_t num_trees; }; @@ -120,6 +124,34 @@ TEST_P (cmesh_multiple_attributes, multiple_attributes) { (cmesh_mult_at, t8_get_package_id (), T8_CMESH_NEXT_POSSIBLE_KEY + 1, ltree_id); EXPECT_EQ(att, t8_cmesh_get_num_trees(cmesh_mult_at)); } + /* Check partitioned cmesh from stash with three attributes. */ + ASSERT_TRUE(t8_cmesh_is_committed (cmesh_mult_at_from_stash)); + EXPECT_EQ(num_local_trees, t8_cmesh_get_num_local_trees(cmesh_mult_at_from_stash)); + t8_locidx_t num_ghosts = t8_cmesh_get_num_ghosts(cmesh_mult_at_from_stash); + for (t8_locidx_t ltree_id = 0; ltree_id < num_local_trees + num_ghosts; ltree_id++) { + t8_gloidx_t gtree_id = t8_cmesh_get_global_id(cmesh_mult_at_from_stash, ltree_id); + const double *vertices_partition = (double *) t8_cmesh_get_attribute + (cmesh_mult_at_from_stash, t8_get_package_id (), T8_CMESH_VERTICES_ATTRIBUTE_KEY, ltree_id); + + t8_eclass_t eclass = (ltree_id <= num_local_trees) ? t8_cmesh_get_tree_class (cmesh_one_at, ltree_id) : t8_cmesh_get_ghost_class (cmesh_one_at, ltree_id - num_local_trees); + EXPECT_EQ(T8_ECLASS_HEX, eclass); + + /* Compare vertices with reference vertices. */ + for (int v_id = 0; v_id < 8; v_id++) { + EXPECT_EQ(vertices_partition[v_id * 3], vertices_ref[v_id*3] + gtree_id); + EXPECT_EQ(vertices_partition[v_id * 3 + 1], vertices_ref[v_id*3 + 1]); + EXPECT_EQ(vertices_partition[v_id * 3 + 2], vertices_ref[v_id*3 + 2]); + } + /* Compare second attribute with global tree id. */ + t8_locidx_t att; + att = *(t8_locidx_t*) t8_cmesh_get_attribute + (cmesh_mult_at_from_stash, t8_get_package_id (), T8_CMESH_NEXT_POSSIBLE_KEY, ltree_id); + EXPECT_EQ(gtree_id, att); + /* Compare third attribute with global number of trees. */ + att = *(t8_locidx_t*) t8_cmesh_get_attribute + (cmesh_mult_at_from_stash, t8_get_package_id (), T8_CMESH_NEXT_POSSIBLE_KEY + 1, ltree_id); + EXPECT_EQ(att, t8_cmesh_get_num_trees(cmesh_mult_at_from_stash)); + } } /* Test for diffrent number of trees. */ From fc985e12b8fbc14b3716a47a172d65f80bd6118a Mon Sep 17 00:00:00 2001 From: "Dreyer, Lukas" Date: Mon, 27 Feb 2023 18:13:28 +0100 Subject: [PATCH 008/255] fixed comparison error --- test/t8_cmesh/t8_gtest_multiple_attributes.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/t8_cmesh/t8_gtest_multiple_attributes.cxx b/test/t8_cmesh/t8_gtest_multiple_attributes.cxx index fb640e8a75..ad1e204656 100644 --- a/test/t8_cmesh/t8_gtest_multiple_attributes.cxx +++ b/test/t8_cmesh/t8_gtest_multiple_attributes.cxx @@ -132,8 +132,7 @@ TEST_P (cmesh_multiple_attributes, multiple_attributes) { t8_gloidx_t gtree_id = t8_cmesh_get_global_id(cmesh_mult_at_from_stash, ltree_id); const double *vertices_partition = (double *) t8_cmesh_get_attribute (cmesh_mult_at_from_stash, t8_get_package_id (), T8_CMESH_VERTICES_ATTRIBUTE_KEY, ltree_id); - - t8_eclass_t eclass = (ltree_id <= num_local_trees) ? t8_cmesh_get_tree_class (cmesh_one_at, ltree_id) : t8_cmesh_get_ghost_class (cmesh_one_at, ltree_id - num_local_trees); + t8_eclass_t eclass = (ltree_id < num_local_trees) ? t8_cmesh_get_tree_class (cmesh_one_at, ltree_id) : t8_cmesh_get_ghost_class (cmesh_one_at, ltree_id - num_local_trees); EXPECT_EQ(T8_ECLASS_HEX, eclass); /* Compare vertices with reference vertices. */ From 026b4e153cfeeb9032681c81bff4f9192234eee3 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Tue, 28 Feb 2023 12:05:43 +0100 Subject: [PATCH 009/255] fixed docu in t8_axy() --- src/t8_vec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_vec.h b/src/t8_vec.h index fcece1118c..adacc9850e 100644 --- a/src/t8_vec.h +++ b/src/t8_vec.h @@ -54,8 +54,8 @@ void t8_vec_ax (double vec_x[3], const double alpha); /** Compute Y = alpha * X * \param [in] vec_x A 3D vector. - * \param [in] alpha A factor. * \param [out] vec_z On output set to \a alpha * \a vec_x. + * \param [in] alpha A factor. */ void t8_vec_axy (const double vec_x[3], double vec_y[3], const double alpha); From f20cf9370ecc1f36133adfeac1963194305518f6 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Tue, 28 Feb 2023 19:23:50 +0100 Subject: [PATCH 010/255] added edge numeration for vertx, line, quad, tri, hex --- src/t8_eclass.c | 158 +++++++++++++++++++++++++++++++----------------- src/t8_eclass.h | 12 ++++ 2 files changed, 115 insertions(+), 55 deletions(-) diff --git a/src/t8_eclass.c b/src/t8_eclass.c index e26d5afabb..4a0d2f9b0c 100644 --- a/src/t8_eclass.c +++ b/src/t8_eclass.c @@ -30,71 +30,119 @@ const int t8_eclass_num_faces[T8_ECLASS_COUNT] = { 0, 2, 4, 3, 6, 4, 5, 5 }; const int t8_eclass_max_num_faces[T8_ECLASS_MAX_DIM + 1] = - { 0, 2, 4, 6}; + { 0, 2, 4, 6 }; + +const int t8_face_vertex_to_tree_vertex[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES][T8_ECLASS_MAX_CORNERS_2D] = { + {{-1}}, /* vertex */ + {{0}, {1}}, /* line */ + {{0, 2}, {1, 3}, {0, 1}, {2, 3}}, /* quad */ + {{1, 2}, {0, 2}, {0, 1}}, /* triangle */ + {{0, 2, 4, 6}, {1, 3, 5, 7}, {0, 1, 4, 5}, {2, 3, 6, 7}, {0, 1, 2, 3}, {4, 5, 6, 7}}, /* hex */ + {{1, 2, 3}, {0, 2, 3}, {0, 1, 3}, {0, 1, 2}}, /* tet */ + {{1, 2, 4, 5}, {0, 2, 3, 5}, {0, 1, 3, 4}, {0, 1, 2}, {3, 4, 5}}, /* prism */ + {{0, 2, 4}, {1, 3, 4}, {0, 1, 4}, {2, 3, 4}, {0, 1, 2, 3}} /* pyramid */ +}; -const int -t8_face_vertex_to_tree_vertex[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES][T8_ECLASS_MAX_CORNERS_2D] = -{ - {{-1}}, /* vertex */ - {{0},{1}}, /* line */ - {{0, 2},{1, 3},{0, 1}, {2, 3}}, /* quad */ - {{1,2},{0,2},{0,1}}, /* triangle */ - {{0,2,4,6},{1,3,5,7},{0,1,4,5},{2,3,6,7},{0,1,2,3},{4,5,6,7}}, /* hex */ - {{1,2,3},{0,2,3},{0,1,3},{0,1,2}}, /* tet */ - {{1,2,4,5},{0,2,3,5},{0,1,3,4},{0,1,2},{3,4,5}}, /* prism */ - {{0,2,4},{1,3,4},{0,1,4},{2,3,4},{0,1,2,3}}/* pyramid */ +/* TODO: tet, prism, pyramid */ +const int t8_face_to_edge_neighbor[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES][T8_ECLASS_MAX_CORNERS_2D] = { + {{-1}}, /* vertex */ + {{-1}}, /* line */ + {{2, 3}, {2, 3}, {0, 1}, {0, 1}}, /* quad */ + {{2, 1}, {2, 0}, {1, 0}}, /* triangle */ + {{0, 1, 2, 3}, {0, 1, 2, 3}, {4, 5, 6, 7}, {4, 5, 6, 7}, {8, 9, 10, 11}, {8, 9, 10, 11}}, /* hex */ + {}, /* tet */ + {}, /* prism */ + {}, /* pyramid */ +}; + +/* TODO: tet, prism, pyramid */ +const int t8_edge_vertex_to_tree_vertex_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2] = { + {{-1}}, /* vertex */ + {{0}, {1}}, /* line */ + {{0, 2}, {1, 3}, {0, 1}, {2, 3}}, /* quad */ + {{1, 2}, {0, 2}, {0, 1}}, /* triangle */ + {{0, 1}, {2, 3}, {4, 5}, {6, 7}, {0, 2}, {1, 3}, {4, 6}, {5, 7}, {0, 4}, {1, 5}, {2, 6}, {3, 7}}, /* hex */ + {}, /* tet */ + {}, /* prism */ + {}, /* pyramid */ }; -const int -t8_eclass_face_orientation[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] = { - {0, -1, -1, -1, -1, -1}, /* vertex */ - {0, 0, -1, -1, -1, -1}, /* line */ - {0, 0, 0, 0, -1, -1}, /* quad */ - {0, 0, 0, -1, -1, -1}, /* triangle */ - {0, 1, 1, 0, 0, 1}, /* hex */ - {0, 1, 0, 1, -1, -1}, /* tet */ - {1, 0, 1, 0, 1, -1}, /* prism */ - {0, 1, 0, 1, 0, -1} /* pyramid */ +/* TODO: tet, prism, pyramid */ +const int t8_edge_to_face_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2] = { + {{-1}}, /* vertex */ + {{0}}, /* line */ + {{0}, {1}, {2}, {3}}, /* quad */ + {{0}, {1}, {2}}, /* triangle */ + {{2, 4}, {3, 4}, {2, 5}, {3, 5}, {0, 4}, {1, 4}, {0, 5}, {1, 5}, {0, 2}, {1, 2}, {0, 3}, {1, 3}}, /* hex */ + {}, /* tet */ + {}, /* prism */ + {}, /* pyramid */ }; -const int t8_eclass_num_vertices[T8_ECLASS_COUNT] = +/* TODO: tet, prism, pyramid */ +const int t8_face_edge_to_tree_edge_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES][T8_ECLASS_MAX_EDGES_2D] = { + {{-1}}, /* vertex */ + {{0}}, /* line */ + {{0}, {1}, {2}, {3}}, /* quad */ + {{0}, {1}, {2}}, /* triangle */ + {{8, 10, 4, 5}, {9, 11, 5, 7}, {8, 9, 0, 2}, {10, 11, 1, 3}, {4, 5, 0, 1}, {6, 7, 2, 3}}, /* hex */ + {}, /* tet */ + {}, /* prism */ + {}, /* pyramid */ +}; + +const int t8_eclass_face_orientation[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] = { + {0, -1, -1, -1, -1, -1}, /* vertex */ + {0, 0, -1, -1, -1, -1}, /* line */ + {0, 0, 0, 0, -1, -1}, /* quad */ + {0, 0, 0, -1, -1, -1}, /* triangle */ + {0, 1, 1, 0, 0, 1}, /* hex */ + {0, 1, 0, 1, -1, -1}, /* tet */ + {1, 0, 1, 0, 1, -1}, /* prism */ + {0, 1, 0, 1, 0, -1} /* pyramid */ +}; + +const int t8_eclass_num_vertices[T8_ECLASS_COUNT] = { 1, 2, 4, 3, 8, 4, 6, 5 }; -const int t8_eclass_num_edges[T8_ECLASS_COUNT] = +const int t8_eclass_num_edges[T8_ECLASS_COUNT] = { 0, 1, 4, 3, 12, 6, 9, 8 }; const int t8_eclass_vtk_type[T8_ECLASS_COUNT] = - { 1, 3, 9, 5, 12, 10, 13, 14}; - -const int t8_eclass_vtk_corner_number[T8_ECLASS_COUNT][T8_ECLASS_MAX_CORNERS] = -{{ 0, -1, -1, -1, -1, -1, -1, -1}, /* vertex */ - { 0, 1, -1, -1, -1, -1, -1, -1}, /* line */ - { 0, 1, 3, 2, -1, -1, -1, -1}, /* quad */ - { 0, 1, 2, -1, -1, -1, -1, -1}, /* triangle */ - { 0, 1, 3, 2, 4, 5, 7, 6}, /* hex */ - { 0, 2, 1, 3, -1, -1, -1, -1}, /* tet */ - { 0, 2, 1, 3, 5, 4, -1, -1}, /* prism */ - { 0, 1, 3, 2, 4, -1, -1, -1}}; /* pyramid */ - -const int t8_eclass_face_types[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] = - {{ -1, -1, -1, -1, -1, -1 }, /* vertex */ - { 0, 0, -1, -1, -1, -1 }, /* line */ - { 1, 1, 1, 1, -1, -1 }, /* quad */ - { 1, 1, 1, -1, -1, -1 }, /* triangle */ - { 2, 2, 2, 2, 2, 2 }, /* hex */ - { 3, 3, 3, 3, -1, -1 }, /* tet */ - { 2, 2, 2, 3, 3, -1 }, /* prism */ - { 3, 3, 3, 3, 2, -1 }}; /* pyramid */ - -const int t8_eclass_boundary_count[T8_ECLASS_COUNT][T8_ECLASS_COUNT] = - {{ 0, 0, 0, 0, 0, 0, 0, 0 }, /* vertex */ - { 2, 0, 0, 0, 0, 0, 0, 0 }, /* line */ - { 4, 4, 0, 0, 0, 0, 0, 0 }, /* quad */ - { 3, 3, 0, 0, 0, 0, 0, 0 }, /* triangle */ - { 8, 12, 6, 0, 0, 0, 0, 0 }, /* hex */ - { 4, 6, 0, 4, 0, 0, 0, 0 }, /* tet */ - { 6, 9, 3, 2, 0, 0, 0, 0 }, /* prism */ - { 5, 8, 1, 4, 0, 0, 0, 0 }}; /* pyramid */ + { 1, 3, 9, 5, 12, 10, 13, 14 }; + +const int t8_eclass_vtk_corner_number[T8_ECLASS_COUNT][T8_ECLASS_MAX_CORNERS] = { + {0, -1, -1, -1, -1, -1, -1, -1}, /* vertex */ + {0, 1, -1, -1, -1, -1, -1, -1}, /* line */ + {0, 1, 3, 2, -1, -1, -1, -1}, /* quad */ + {0, 1, 2, -1, -1, -1, -1, -1}, /* triangle */ + {0, 1, 3, 2, 4, 5, 7, 6}, /* hex */ + {0, 2, 1, 3, -1, -1, -1, -1}, /* tet */ + {0, 2, 1, 3, 5, 4, -1, -1}, /* prism */ + {0, 1, 3, 2, 4, -1, -1, -1} /* pyramid */ +}; + +const int t8_eclass_face_types[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] = { + {-1, -1, -1, -1, -1, -1}, /* vertex */ + { 0, 0, -1, -1, -1, -1}, /* line */ + { 1, 1, 1, 1, -1, -1}, /* quad */ + { 1, 1, 1, -1, -1, -1}, /* triangle */ + { 2, 2, 2, 2, 2, 2}, /* hex */ + { 3, 3, 3, 3, -1, -1}, /* tet */ + { 2, 2, 2, 3, 3, -1}, /* prism */ + { 3, 3, 3, 3, 2, -1} /* pyramid */ +}; + +const int t8_eclass_boundary_count[T8_ECLASS_COUNT][T8_ECLASS_COUNT] = { + {0, 0, 0, 0, 0, 0, 0, 0}, /* vertex */ + {2, 0, 0, 0, 0, 0, 0, 0}, /* line */ + {4, 4, 0, 0, 0, 0, 0, 0}, /* quad */ + {3, 3, 0, 0, 0, 0, 0, 0}, /* triangle */ + {8, 12, 6, 0, 0, 0, 0, 0}, /* hex */ + {4, 6, 0, 4, 0, 0, 0, 0}, /* tet */ + {6, 9, 3, 2, 0, 0, 0, 0}, /* prism */ + {5, 8, 1, 4, 0, 0, 0, 0} /* pyramid */ +}; const char * t8_eclass_to_string[T8_ECLASS_COUNT] = {"Vertex", diff --git a/src/t8_eclass.h b/src/t8_eclass.h index c163ac4b1a..863dce9b9a 100644 --- a/src/t8_eclass.h +++ b/src/t8_eclass.h @@ -94,6 +94,18 @@ extern const int t8_face_vertex_to_tree_vertex[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] [T8_ECLASS_MAX_CORNERS_2D]; +extern const int t8_face_to_edge_neighbor[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] + [T8_ECLASS_MAX_CORNERS_2D]; + +extern const int + t8_edge_vertex_to_tree_vertex_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2]; + +extern const int t8_edge_to_face_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2]; + +extern const int + t8_face_edge_to_tree_edge_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] + [T8_ECLASS_MAX_EDGES_2D]; + /** Each face is either 0 or 1 oriented, depending on the order of its vertices. * We say a face is 0 oriented, if its normal vector points inwards, * 1 oriented otherwise. From c6971a4f31055050d8781893ae62d3b0ee209065 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Tue, 28 Feb 2023 19:24:58 +0100 Subject: [PATCH 011/255] indent --- src/t8_eclass.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/t8_eclass.h b/src/t8_eclass.h index 863dce9b9a..4f1b9e83d7 100644 --- a/src/t8_eclass.h +++ b/src/t8_eclass.h @@ -94,15 +94,17 @@ extern const int t8_face_vertex_to_tree_vertex[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] [T8_ECLASS_MAX_CORNERS_2D]; -extern const int t8_face_to_edge_neighbor[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] +extern const int + t8_face_to_edge_neighbor[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] [T8_ECLASS_MAX_CORNERS_2D]; -extern const int +extern const int t8_edge_vertex_to_tree_vertex_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2]; -extern const int t8_edge_to_face_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2]; +extern const int + t8_edge_to_face_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2]; -extern const int +extern const int t8_face_edge_to_tree_edge_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] [T8_ECLASS_MAX_EDGES_2D]; From 268faee4769f598c80863b79ed3581cc7dbd180d Mon Sep 17 00:00:00 2001 From: ililikakis Date: Tue, 28 Feb 2023 19:26:04 +0100 Subject: [PATCH 012/255] indent --- src/t8_eclass.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/t8_eclass.h b/src/t8_eclass.h index 4f1b9e83d7..2d464ca83b 100644 --- a/src/t8_eclass.h +++ b/src/t8_eclass.h @@ -94,15 +94,15 @@ extern const int t8_face_vertex_to_tree_vertex[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] [T8_ECLASS_MAX_CORNERS_2D]; -extern const int - t8_face_to_edge_neighbor[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] +extern const int + t8_face_to_edge_neighbor[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] [T8_ECLASS_MAX_CORNERS_2D]; extern const int t8_edge_vertex_to_tree_vertex_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2]; -extern const int - t8_edge_to_face_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2]; +extern const int + t8_edge_to_face_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2]; extern const int t8_face_edge_to_tree_edge_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] From a79377b2fa8b60a7ef3429d259f07a5827bd463a Mon Sep 17 00:00:00 2001 From: ililikakis Date: Tue, 28 Feb 2023 19:40:46 +0100 Subject: [PATCH 013/255] const input in t8_cmesh_new_translate_vertices_to_attributes() --- src/t8_cmesh.h | 6 +++--- src/t8_cmesh/t8_cmesh.c | 10 ++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/t8_cmesh.h b/src/t8_cmesh.h index a70ebe37aa..bfe895591a 100644 --- a/src/t8_cmesh.h +++ b/src/t8_cmesh.h @@ -742,13 +742,13 @@ void t8_cmesh_translate_coordinates (const double *coords_in, double translate[3]); /**TODO: Add proper documentation*/ -void t8_cmesh_new_translate_vertices_to_attributes (t8_locidx_t +void t8_cmesh_new_translate_vertices_to_attributes (const t8_locidx_t *tvertices, - double + const double *vertices, double *attr_vertices, - int + const int num_vertices); /** diff --git a/src/t8_cmesh/t8_cmesh.c b/src/t8_cmesh/t8_cmesh.c index 25dc6eb870..49f4458df1 100644 --- a/src/t8_cmesh/t8_cmesh.c +++ b/src/t8_cmesh/t8_cmesh.c @@ -1363,12 +1363,10 @@ t8_cmesh_translate_coordinates (const double *coords_in, double *coords_out, * It would be nice to eventually rewrite these functions correctly. */ void -t8_cmesh_new_translate_vertices_to_attributes (t8_locidx_t *tvertices, - double - *vertices, - double - *attr_vertices, - int num_vertices) +t8_cmesh_new_translate_vertices_to_attributes (const t8_locidx_t *tvertices, + const double *vertices, + double *attr_vertices, + const int num_vertices) { int i; for (i = 0; i < num_vertices; i++) { From 9434a74859357b07a460cd02275dc5996aac53dc Mon Sep 17 00:00:00 2001 From: ililikakis Date: Wed, 1 Mar 2023 10:09:12 +0100 Subject: [PATCH 014/255] fixed number issue in t8_face_edge_to_tree_edge_n --- src/t8_eclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_eclass.c b/src/t8_eclass.c index 4a0d2f9b0c..c5be91406a 100644 --- a/src/t8_eclass.c +++ b/src/t8_eclass.c @@ -85,7 +85,7 @@ const int t8_face_edge_to_tree_edge_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES][T8_E {{0}}, /* line */ {{0}, {1}, {2}, {3}}, /* quad */ {{0}, {1}, {2}}, /* triangle */ - {{8, 10, 4, 5}, {9, 11, 5, 7}, {8, 9, 0, 2}, {10, 11, 1, 3}, {4, 5, 0, 1}, {6, 7, 2, 3}}, /* hex */ + {{8, 10, 4, 6}, {9, 11, 5, 7}, {8, 9, 0, 2}, {10, 11, 1, 3}, {4, 5, 0, 1}, {6, 7, 2, 3}}, /* hex */ {}, /* tet */ {}, /* prism */ {}, /* pyramid */ From 16ea1641393c2f22555672bf87b1961f56c488f3 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 2 Mar 2023 11:15:50 +0100 Subject: [PATCH 015/255] extend t8_cmesh_new_hypercube_ext() by HEX QUAD TRIANGLE --- src/t8_cmesh/t8_cmesh_examples.c | 511 +++++++++++++++++++++++++++---- src/t8_cmesh/t8_cmesh_examples.h | 7 +- 2 files changed, 451 insertions(+), 67 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 7c97de1689..c3db4488da 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include /* TODO: In p4est a tree edge is joined with itself to denote a domain boundary. * Will we do it the same in t8code? This is not yet decided, however the @@ -621,7 +623,7 @@ t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, t8_locidx_t vertices[8]; double attr_vertices[24]; int mpirank, mpiret; - double vertices_coords[24] = { + const double vertices_coords[24] = { 0, 0, 0, 1, 0, 0, 0, 1, 0, @@ -846,119 +848,502 @@ t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, return cmesh; } -static t8_cmesh_t -t8_cmesh_new_quad_ext (const double *boundary, - const t8_locidx_t trees_x, - const t8_locidx_t trees_y, - sc_MPI_Comm comm) +/** + * z > y > x and factor_1 > factor 0 + */ +static void +t8_update_box_face_edges (t8_eclass_t eclass, + double *box_corners, + double *box_edges, + const int face, + const t8_locidx_t *trees) { + T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX); + T8_ASSERT (-1 < face && face < t8_eclass_num_faces[eclass]); + + const int num_face_edges = eclass == T8_ECLASS_QUAD ? 1 : 4; + for (int face_edge = 0; face_edge < num_face_edges; face_edge++) { + const int edge = t8_face_edge_to_tree_edge_n[eclass][face][face_edge]; + const double *v_1 = box_corners + (t8_edge_vertex_to_tree_vertex_n[eclass][edge][0] * 3); + const double *v_2 = box_corners + (t8_edge_vertex_to_tree_vertex_n[eclass][edge][1] * 3); + + /* direction */ + t8_vec_axpyz (v_1, v_2, box_edges + (edge * 3), -1.0); + /* length */ + double length_tree; + const double num_trees = eclass == T8_ECLASS_QUAD ? (double) trees[(edge/2 + 1)%2] : (double) trees[edge/4]; + length_tree = t8_vec_norm (box_edges + (edge * 3)) * num_trees; + length_tree = t8_vec_dist (v_1, v_2) / length_tree; + t8_vec_ax (box_edges + (edge * 3), length_tree); + } +} + +static void +t8_resize_box (t8_eclass_t eclass, + double *box, + double *box_dir, + const int face, + const t8_locidx_t factor, + int *axes) +{ + T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX); + T8_ASSERT (t8_eclass_to_dimension[eclass] > 1); + T8_ASSERT (-1 < face && face < t8_eclass_num_faces[eclass]); + + const int num_face_corner = eclass == T8_ECLASS_QUAD ? 2 : 4; + + for (int face_corner = 0; face_corner < num_face_corner; face_corner++) { + const int box_vertex = t8_face_vertex_to_tree_vertex[eclass][face][face_corner]; + const int box_edge = t8_face_to_edge_neighbor[eclass][face][face_corner]; + t8_vec_axpy (box_dir + (box_edge * 3), box + (box_vertex * 3), (double) factor); + } + + axes[face/2] += face%2 ? factor : -factor; + +} + +static void +t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, + t8_eclass_t eclass, + const double *boundary, + const t8_locidx_t trees_x, + const t8_locidx_t trees_y) +{ + T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_TRIANGLE); /* x axis */ - T8_ASSERT (trees_x > 0); T8_ASSERT (boundary[3] > boundary[0]); T8_ASSERT (boundary[9] > boundary[6]); /* y axis */ - T8_ASSERT (trees_y > 0); T8_ASSERT (boundary[7] > boundary[1]); T8_ASSERT (boundary[10] > boundary[4]); - t8_cmesh_t cmesh; - t8_cmesh_init (&cmesh); - /* We use standard linear geometry */ - const t8_geometry_c *linear_geom = t8_geometry_linear_new (2); - t8_cmesh_register_geometry (cmesh, linear_geom); - - + double vertices[12]; + /* coordinates of reduced boundary box */ + double box[12]; + for (int i = 0; i < 12; i++) { + box[i] = boundary[i]; + } + int axes[2] = {trees_x, trees_y}; + + /* The directional vector between two vertices v_i and v_j, i > j. + * The length is egual to distance (v_i, v_j) / #trees + * along the respective axis. + * --> + * 2 _______ 3 + * | | + * ^ | | ^ + * | | | | + * |_______| + * 0 1 + * --> + **/ + double box_dir[12]; + t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, axes); + t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 1, axes); + t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 2, axes); + t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 3, axes); + + for (t8_locidx_t tree_y = 0; tree_y < trees_y; tree_y++) { + for (t8_locidx_t tree_x = 0; tree_x < trees_x; tree_x++) { + + /* Vertex 0 */ + t8_vec_axy (box, vertices, 1.0); + /* Vertex 2 */ + t8_vec_axpyz (box, box_dir, vertices + 6, 1.0); + + /* reduce box along x axis and update box_dir */ + t8_resize_box (T8_ECLASS_QUAD, box, box_dir, 0, 1, axes); + t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, axes); + + /* Vertex 1 */ + t8_vec_axy (box, vertices + 3, 1.0); + /* Vertex 3 */ + t8_vec_axpyz (box, box_dir, vertices + 9, 1.0); + + if (eclass == T8_ECLASS_QUAD) { + const t8_locidx_t tree_id = tree_y * trees_x + tree_x; + t8_cmesh_set_tree_vertices (cmesh, tree_id, vertices, 4); + } + else { + const t8_locidx_t tree_id = (tree_y * trees_x + tree_x) * 2; + /* Map vertices of a quad on to two triangles */ + double vertices_triangle[9]; + for (int i = 0; i < 3; i++) { + vertices_triangle[i] = vertices[i]; + vertices_triangle[i + 3] = vertices[i + 3]; + vertices_triangle[i + 6] = vertices[i + 9]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id, vertices_triangle, 3); + for (int i = 0; i < 3; i++) { + vertices_triangle[i + 3] = vertices[i + 9]; + vertices_triangle[i + 6] = vertices[i + 6]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id + 1, vertices_triangle, 3); + } + } + /* resize box */ + for (int i = 0; i < 12; i++) { + box[i] = boundary[i]; + } + axes[0] = trees_x; + axes[1] = trees_y; + t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, axes); - t8_cmesh_commit (cmesh, comm); - return cmesh; + /* reduce box along y axis and update box_dir */ + t8_resize_box (T8_ECLASS_QUAD, box, box_dir, 2, tree_y + 1, axes); + t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 2, axes); + } } -static t8_cmesh_t -t8_cmesh_new_hex_ext (const double *boundary, - const t8_locidx_t trees_x, - const t8_locidx_t trees_y, - const t8_locidx_t trees_z, - sc_MPI_Comm comm) +static void +t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, + t8_eclass_t eclass, + const double *boundary, + const t8_locidx_t trees_x, + const t8_locidx_t trees_y, + const t8_locidx_t trees_z) { /* x axis */ - T8_ASSERT (trees_x > 0); T8_ASSERT (boundary[3] > boundary[0]); T8_ASSERT (boundary[9] > boundary[6]); T8_ASSERT (boundary[15] > boundary[12]); T8_ASSERT (boundary[21] > boundary[18]); /* y axis */ - T8_ASSERT (trees_y > 0); T8_ASSERT (boundary[7] > boundary[1]); T8_ASSERT (boundary[10] > boundary[4]); T8_ASSERT (boundary[19] > boundary[13]); T8_ASSERT (boundary[22] > boundary[16]); /* z axis */ - T8_ASSERT (trees_z > 0); T8_ASSERT (boundary[14] > boundary[2]); T8_ASSERT (boundary[17] > boundary[5]); T8_ASSERT (boundary[20] > boundary[8]); T8_ASSERT (boundary[23] > boundary[11]); - t8_cmesh_t cmesh; - t8_cmesh_init (&cmesh); - /* We use standard linear geometry */ - const t8_geometry_c *linear_geom = t8_geometry_linear_new (3); - t8_cmesh_register_geometry (cmesh, linear_geom); - - - + /* coordinates of one tree */ + double vertices[24]; + /* coordinates of reduced boundary box */ + double box[24]; + for (int i = 0; i < 24; i++) { + box[i] = boundary[i]; + } + + t8_locidx_t axes[3] = {trees_x, trees_y, trees_z}; + + /* The directional vector between two vertices v_i and v_j, i > j. + * The length is egual to distance (v_i, v_j) / #trees + * along the respective axis. + **/ + double box_dir[36]; + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, axes); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 1, axes); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 2, axes); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 3, axes); + + /* increse box along every axis by one tree */ + /* increase box along z axis and update box_dir */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 5, 1, axes); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 5, axes); + /* increase box along x axis and update box_dir */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 1, 1, axes); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 1, axes); + /* increase box along y axis and update box_dir */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 3, 1, axes); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 3, axes); + + for (t8_locidx_t tree_z = 0; tree_z < trees_z; tree_z++) { + for (t8_locidx_t tree_y = 0; tree_y < trees_y; tree_y++) { + for (t8_locidx_t tree_x = 0; tree_x < trees_x; tree_x++) { + /* + * 6 ______ 7 The first vertex of box corresponds to the + * /| / first vertex of the current hexahedral tree. + * 4 /_____5/| Resize the box so that the first vertex of box + * | | _ |_| corresponds to vertices 0, 4, 5 and finally 1. + * | 2 | / 3 Along the y axis we can calculate the respective + * |/____|/ vertices 2, 3, 6 and 7. + * 0 1 + */ + + /* Vertex 0 */ + t8_vec_axy (box, vertices, 1.0); + /* Vertex 2 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 6, 1.0); + + /* reduce box along z axis and update box_dir */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 4, 1, axes); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 4, axes); + + /* Vertex 4 */ + t8_vec_axy (box, vertices + 12, 1.0); + /* Vertex 6 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 18, 1.0); + + /* reduce box along x axis and update box_dir */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 0, 1, axes); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, axes); + + /* Vertex 5 */ + t8_vec_axy (box, vertices + 15, 1.0); + /* Vertex 7 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 21, 1.0); + + /* increase box along z axis and update box_dir */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 4, -1, axes); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 4, axes); + + /* Vertex 1 */ + t8_vec_axy (box, vertices + 3, 1.0); + /* Vertex 3 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 9, 1.0); + + const t8_locidx_t cube_id = tree_z * trees_y * trees_x + tree_y * trees_x + tree_x; + switch (eclass) { + case T8_ECLASS_HEX: + t8_cmesh_set_tree_vertices (cmesh, cube_id, vertices, 8); + break; + case T8_ECLASS_TET: + break; + case T8_ECLASS_PRISM: + break; + case T8_ECLASS_PYRAMID: + break; + default: + break; + } + } + T8_ASSERT (axes[0] == 1); + /* resize box along x axis and update box_dir */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 0, -trees_x, axes); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, axes); + + /* reduce box along y axis and update box_dir */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 2, 1, axes); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 2, axes); + } + T8_ASSERT (axes[0] == trees_x + 1); + T8_ASSERT (axes[1] == 1); + /* increase box along y axis and update box_dir */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 2, -trees_y, axes); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 2, axes); - t8_cmesh_commit (cmesh, comm); - return cmesh; + /* reduce box along z axis and update box_dir */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 4, 1, axes); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 4, axes); + } + T8_ASSERT (axes[2] == 1); + T8_ASSERT (axes[1] == trees_y + 1); + T8_ASSERT (axes[0] == trees_x + 1); } t8_cmesh_t t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, - sc_MPI_Comm comm, - const double *boundary, - const t8_locidx_t trees_x, - const t8_locidx_t trees_y, - const t8_locidx_t trees_z) + sc_MPI_Comm comm, + const double *boundary, + t8_locidx_t trees_x, + t8_locidx_t trees_y, + t8_locidx_t trees_z) { + const int dim = t8_eclass_to_dimension[eclass]; + switch (dim) { + case 0: + trees_x = 1; + case 1: + trees_y = 1; + case 2: + trees_z = 1; + default: + T8_ASSERT (trees_x > 0); + T8_ASSERT (trees_y > 0); + T8_ASSERT (trees_z > 0); + break; + } + + t8_cmesh_t cmesh; + t8_cmesh_init (&cmesh); + + /* We use standard linear geometry */ + const t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); + t8_cmesh_register_geometry (cmesh, linear_geom); + + + int num_trees_for_single_hypercube[T8_ECLASS_COUNT] = { + 1, 1, 1, 2, 1, 6, 2, 3 + }; + + /* Set tree class for every tree */ + for (t8_locidx_t tree_id = 0; tree_id < + trees_x * trees_y * trees_z * num_trees_for_single_hypercube[eclass]; + tree_id++) { + t8_cmesh_set_tree_class (cmesh, tree_id, eclass); + } + + /* Set vertices of trees and join them */ switch (eclass) { case T8_ECLASS_VERTEX: - SC_ABORT ("T8_ECLASS_VERTEX is not yet supported by this function.\n"); - return NULL; + { + double vertices_attr_vert[4]; + /* Set first vertex to lower end of line */ + t8_vec_axy (boundary, vertices_attr_vert, 1.0); + t8_cmesh_set_tree_vertices (cmesh, 0, vertices_attr_vert, 1); + } break; case T8_ECLASS_LINE: - SC_ABORT ("T8_ECLASS_LINE is not yet supported by this function.\n"); - return NULL; - break; - case T8_ECLASS_TRIANGLE: - SC_ABORT ("T8_ECLASS_TRIANGLE is not yet supported by this function.\n"); - return NULL; + { + T8_ASSERT (boundary[3] > boundary[0]); + /* Get the direction of the line */ + double line_dir[3]; + t8_vec_axpyz (boundary, boundary + 3, line_dir, -1.0); + /* Get length of one tree */ + double length; + length = t8_vec_norm (line_dir) * (double) trees_x; + length = t8_vec_dist (boundary, boundary + 3) / length; + t8_vec_ax (line_dir, length); + + double vertices_attr[6]; + /* Set first vertex to lower end of line */ + t8_vec_axy (boundary, vertices_attr, 1.0); + /* Set second vertex to lower end of line + line_dir */ + t8_vec_axpyz (vertices_attr + 3, boundary, line_dir, 1.0); + + for (t8_locidx_t tree_x = 0; tree_x < trees_x; tree_x++) { + t8_cmesh_set_tree_vertices (cmesh, tree_x, vertices_attr, 2); + /* Update vertices for next tree */ + t8_vec_axy (vertices_attr, vertices_attr + 3, 1.0); + t8_vec_axpy (line_dir, vertices_attr + 3, 1.0); + } + } break; case T8_ECLASS_QUAD: - return t8_cmesh_new_quad_ext (comm, boundary, trees_x, trees_y); - break; - case T8_ECLASS_TET: - SC_ABORT ("T8_ECLASS_TET is not yet supported by this function.\n"); - return NULL; + case T8_ECLASS_TRIANGLE: + t8_cmesh_set_vertices_2D (cmesh, eclass, boundary, trees_x, trees_y); break; case T8_ECLASS_HEX: - return t8_cmesh_new_hex_ext (comm, boundary, trees_x, trees_y, trees_z); - break; - case T8_ECLASS_PYRAMID: - SC_ABORT ("T8_ECLASS_PYRAMID is not yet supported by this function.\n"); - return NULL; - break; + case T8_ECLASS_TET: case T8_ECLASS_PRISM: - SC_ABORT ("T8_ECLASS_PRISM is not yet supported by this function.\n"); - return NULL; + case T8_ECLASS_PYRAMID: + t8_cmesh_set_vertices_3D (cmesh, eclass, boundary, trees_x, trees_y, trees_z); break; default: SC_ABORT ("Invalid eclass\n"); - return NULL; + break; + } + + /* Join the trees inside each cube */ + for (t8_locidx_t cube_z = 0; cube_z < trees_z; cube_z++) { + for (t8_locidx_t cube_y = 0; cube_y < trees_y; cube_y++) { + for (t8_locidx_t cube_x = 0; cube_x < trees_x; cube_x++) { + const t8_locidx_t cube_id = cube_z * trees_y * trees_x + cube_y * trees_x + cube_x; + t8_locidx_t tree_id_0; + switch (eclass) { + case T8_ECLASS_TRIANGLE: + tree_id_0 = cube_id * 2; + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_0 + 1, 1, 2, 0); + break; + case T8_ECLASS_TET: + break; + case T8_ECLASS_PRISM: + break; + case T8_ECLASS_PYRAMID: + break; + default: + break; + } + } + } } + /* Join the cubes along the x - axis */ + for (t8_locidx_t cube_z = 0; cube_z < trees_z; cube_z++) { + for (t8_locidx_t cube_y = 0; cube_y < trees_y; cube_y++) { + for (t8_locidx_t cube_x = 0; cube_x < trees_x - 1; cube_x++) { + const t8_locidx_t cube_id = cube_z * trees_y * trees_x + cube_y * trees_x + cube_x; + t8_locidx_t tree_id_0; + t8_locidx_t tree_id_1; + switch (eclass) { + case T8_ECLASS_QUAD: + case T8_ECLASS_HEX: + tree_id_0 = cube_id; + tree_id_1 = cube_id + 1; + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 1, 0, 1); + break; + case T8_ECLASS_TRIANGLE: + tree_id_0 = cube_id * 2; + tree_id_1 = cube_id * 2 + 3; + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 1, 0); + break; + case T8_ECLASS_TET: + break; + case T8_ECLASS_PRISM: + break; + case T8_ECLASS_PYRAMID: + break; + default: + break; + } + } + } + } + /* Join the cubes along the y - axis */ + for (t8_locidx_t cube_z = 0; cube_z < trees_z; cube_z++) { + for (t8_locidx_t cube_y = 0; cube_y < trees_y - 1; cube_y++) { + for (t8_locidx_t cube_x = 0; cube_x < trees_x; cube_x++) { + const t8_locidx_t cube_id_0 = cube_z * trees_y * trees_x + cube_y * trees_x + cube_x; + t8_locidx_t tree_id_0; + t8_locidx_t tree_id_1; + switch (eclass) { + case T8_ECLASS_QUAD: + case T8_ECLASS_HEX: + tree_id_0 = cube_id_0; + tree_id_1 = cube_id_0 + trees_x; + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 3, 2, 2); + break; + case T8_ECLASS_TRIANGLE: + tree_id_0 = cube_id_0 * 2 + 1; + tree_id_1 = cube_id_0 * 2 + 2 * trees_x; + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 2, 1); + break; + case T8_ECLASS_TET: + break; + case T8_ECLASS_PRISM: + break; + case T8_ECLASS_PYRAMID: + break; + default: + break; + } + } + } + } + /* Join the cubes along the z - axis */ + for (t8_locidx_t cube_z = 0; cube_z < trees_z - 1; cube_z++) { + for (t8_locidx_t cube_y = 0; cube_y < trees_y; cube_y++) { + for (t8_locidx_t cube_x = 0; cube_x < trees_x; cube_x++) { + const t8_locidx_t cube_id_0 = cube_z * trees_y * trees_x + cube_y * trees_x + cube_x; + t8_locidx_t tree_id_0; + t8_locidx_t tree_id_1; + switch (eclass) { + case T8_ECLASS_HEX: + tree_id_0 = cube_id_0; + tree_id_1 = cube_id_0 + (trees_y * trees_x); + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 5, 4, 4); + break; + case T8_ECLASS_TET: + break; + case T8_ECLASS_PRISM: + break; + case T8_ECLASS_PYRAMID: + break; + default: + break; + } + } + } + } + + t8_cmesh_commit (cmesh, comm); + return cmesh; } diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index a7944f6cfb..022e9a9f00 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -117,9 +117,9 @@ t8_cmesh_t t8_cmesh_new_hypercube (t8_eclass_t eclass, t8_cmesh_t t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, - const t8_locidx_t trees_x, - const t8_locidx_t trees_y, - const t8_locidx_t trees_z); + t8_locidx_t trees_x, + t8_locidx_t trees_y, + t8_locidx_t trees_z); /** Hybercube with 6 Tets, 6 Prism, 4 Hex. * \param [in] comm The mpi communicator to be used. @@ -128,7 +128,6 @@ t8_cmesh_t t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, * \return A comitted cmesh consisting of 6 Tets, 6 prism and 4 hex. * Together, they form a cube. */ - t8_cmesh_t t8_cmesh_new_hypercube_hybrid (sc_MPI_Comm comm, int do_partition, int periodic); From d483c3d447f00ee1a1bf5bf3d37b40646469c16b Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 2 Mar 2023 11:33:09 +0100 Subject: [PATCH 016/255] extend t8_cmesh_new_hypercube_ext() by PRISM --- src/t8_cmesh/t8_cmesh_examples.c | 35 ++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index c3db4488da..b0d7440894 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1105,6 +1105,27 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, case T8_ECLASS_TET: break; case T8_ECLASS_PRISM: + { + const t8_locidx_t tree_id_0 = 2 * cube_id; + /* Map vertices of a quad on to two triangles */ + double vertices_prism[18]; + for (int i = 0; i < 3; i++) { + vertices_prism[i] = vertices[i]; + vertices_prism[i + 3] = vertices[i + 3]; + vertices_prism[i + 6] = vertices[i + 9]; + vertices_prism[i + 9] = vertices[i + 12]; + vertices_prism[i + 12] = vertices[i + 15]; + vertices_prism[i + 15] = vertices[i + 21]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id_0, vertices_prism, 6); + for (int i = 0; i < 3; i++) { + vertices_prism[i + 3] = vertices[i + 9]; + vertices_prism[i + 6] = vertices[i + 6]; + vertices_prism[i + 12] = vertices[i + 21]; + vertices_prism[i + 15] = vertices[i + 18]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 1, vertices_prism, 6); + } break; case T8_ECLASS_PYRAMID: break; @@ -1239,13 +1260,12 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, t8_locidx_t tree_id_0; switch (eclass) { case T8_ECLASS_TRIANGLE: + case T8_ECLASS_PRISM: tree_id_0 = cube_id * 2; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_0 + 1, 1, 2, 0); break; case T8_ECLASS_TET: break; - case T8_ECLASS_PRISM: - break; case T8_ECLASS_PYRAMID: break; default: @@ -1269,14 +1289,13 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 1, 0, 1); break; case T8_ECLASS_TRIANGLE: + case T8_ECLASS_PRISM: tree_id_0 = cube_id * 2; tree_id_1 = cube_id * 2 + 3; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 1, 0); break; case T8_ECLASS_TET: break; - case T8_ECLASS_PRISM: - break; case T8_ECLASS_PYRAMID: break; default: @@ -1300,14 +1319,13 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 3, 2, 2); break; case T8_ECLASS_TRIANGLE: + case T8_ECLASS_PRISM: tree_id_0 = cube_id_0 * 2 + 1; tree_id_1 = cube_id_0 * 2 + 2 * trees_x; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 2, 1); break; case T8_ECLASS_TET: break; - case T8_ECLASS_PRISM: - break; case T8_ECLASS_PYRAMID: break; default: @@ -1332,6 +1350,11 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, case T8_ECLASS_TET: break; case T8_ECLASS_PRISM: + for (int i = 0; i < 2; i++) { + tree_id_0 = cube_id_0 * 2 + i; + tree_id_1 = cube_id_0 * 2 + i + (2 * trees_y * trees_x); + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 4, 3, 3); + } break; case T8_ECLASS_PYRAMID: break; From 9a381c474bb4dfb8583318efca83cb5b900b9f29 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 2 Mar 2023 12:55:51 +0100 Subject: [PATCH 017/255] extend t8_cmesh_new_hypercube_ext() by TET --- src/t8_cmesh/t8_cmesh_examples.c | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index b0d7440894..480b43901d 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1103,6 +1103,43 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, t8_cmesh_set_tree_vertices (cmesh, cube_id, vertices, 8); break; case T8_ECLASS_TET: + { + const t8_locidx_t tree_id_0 = 6 * cube_id; + /* Map vertices of a quad on to two triangles */ + double vertices_tet[12]; + for (int i = 0; i < 3; i++) { + vertices_tet[i] = vertices[i]; + vertices_tet[i + 3] = vertices[i + 3]; + vertices_tet[i + 6] = vertices[i + 15]; + vertices_tet[i + 9] = vertices[i + 21]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id_0, vertices_tet, 4); + for (int i = 0; i < 3; i++) { + vertices_tet[i + 3] = vertices[i + 9]; + vertices_tet[i + 6] = vertices[i + 3]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 1, vertices_tet, 4); + for (int i = 0; i < 3; i++) { + vertices_tet[i + 3] = vertices[i + 6]; + vertices_tet[i + 6] = vertices[i + 9]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 2, vertices_tet, 4); + for (int i = 0; i < 3; i++) { + vertices_tet[i + 3] = vertices[i + 18]; + vertices_tet[i + 6] = vertices[i + 6]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 3, vertices_tet, 4); + for (int i = 0; i < 3; i++) { + vertices_tet[i + 3] = vertices[i + 12]; + vertices_tet[i + 6] = vertices[i + 18]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 4, vertices_tet, 4); + for (int i = 0; i < 3; i++) { + vertices_tet[i + 3] = vertices[i + 15]; + vertices_tet[i + 6] = vertices[i + 12]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 5, vertices_tet, 4); + } break; case T8_ECLASS_PRISM: { @@ -1265,6 +1302,11 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, t8_cmesh_set_join (cmesh, tree_id_0, tree_id_0 + 1, 1, 2, 0); break; case T8_ECLASS_TET: + for (int i = 0; i < 6; i++) { + const t8_locidx_t tree_id_0 = cube_id * 6 + i; + const t8_locidx_t tree_id_1 = cube_id * 6 + (i + 1)%6; + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 2, 1, 0); + } break; case T8_ECLASS_PYRAMID: break; @@ -1295,6 +1337,12 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 1, 0); break; case T8_ECLASS_TET: + tree_id_0 = cube_id * 6; + tree_id_1 = cube_id * 6 + 10; + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 0); + tree_id_0 = cube_id * 6 + 1; + tree_id_1 = cube_id * 6 + 9; + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 0); break; case T8_ECLASS_PYRAMID: break; @@ -1325,6 +1373,12 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 2, 1); break; case T8_ECLASS_TET: + tree_id_0 = cube_id_0 * 6 + 2; + tree_id_1 = cube_id_0 * 6 + 6 * trees_x; + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 0); + tree_id_0 = cube_id_0 * 6 + 3; + tree_id_1 = cube_id_0 * 6 + 6 * trees_x + 5; + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 2); break; case T8_ECLASS_PYRAMID: break; @@ -1348,6 +1402,12 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 5, 4, 4); break; case T8_ECLASS_TET: + tree_id_0 = cube_id_0 * 6 + 5; + tree_id_1 = cube_id_0 * 6 + (6 * trees_y * trees_x) + 1; + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 3); + tree_id_0 = cube_id_0 * 6 + 4; + tree_id_1 = cube_id_0 * 6 + (6 * trees_y * trees_x) + 2; + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 0); break; case T8_ECLASS_PRISM: for (int i = 0; i < 2; i++) { From badfb2d56660e690f74946d30c8908d91d3fff3e Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 2 Mar 2023 14:30:05 +0100 Subject: [PATCH 018/255] switched some switchs into ifs --- src/t8_cmesh/t8_cmesh_examples.c | 339 +++++++++++++------------------ 1 file changed, 146 insertions(+), 193 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 480b43901d..9549766e56 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -966,6 +966,7 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, t8_cmesh_set_tree_vertices (cmesh, tree_id, vertices, 4); } else { + T8_ASSERT (eclass == T8_ECLASS_TRIANGLE); const t8_locidx_t tree_id = (tree_y * trees_x + tree_x) * 2; /* Map vertices of a quad on to two triangles */ double vertices_triangle[9]; @@ -1098,76 +1099,67 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, t8_vec_axpyz (box, box_dir + 12, vertices + 9, 1.0); const t8_locidx_t cube_id = tree_z * trees_y * trees_x + tree_y * trees_x + tree_x; - switch (eclass) { - case T8_ECLASS_HEX: + if (eclass == T8_ECLASS_HEX) { t8_cmesh_set_tree_vertices (cmesh, cube_id, vertices, 8); - break; - case T8_ECLASS_TET: - { - const t8_locidx_t tree_id_0 = 6 * cube_id; - /* Map vertices of a quad on to two triangles */ - double vertices_tet[12]; - for (int i = 0; i < 3; i++) { - vertices_tet[i] = vertices[i]; - vertices_tet[i + 3] = vertices[i + 3]; - vertices_tet[i + 6] = vertices[i + 15]; - vertices_tet[i + 9] = vertices[i + 21]; - } - t8_cmesh_set_tree_vertices (cmesh, tree_id_0, vertices_tet, 4); - for (int i = 0; i < 3; i++) { - vertices_tet[i + 3] = vertices[i + 9]; - vertices_tet[i + 6] = vertices[i + 3]; - } - t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 1, vertices_tet, 4); - for (int i = 0; i < 3; i++) { - vertices_tet[i + 3] = vertices[i + 6]; - vertices_tet[i + 6] = vertices[i + 9]; - } - t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 2, vertices_tet, 4); - for (int i = 0; i < 3; i++) { - vertices_tet[i + 3] = vertices[i + 18]; - vertices_tet[i + 6] = vertices[i + 6]; - } - t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 3, vertices_tet, 4); - for (int i = 0; i < 3; i++) { - vertices_tet[i + 3] = vertices[i + 12]; - vertices_tet[i + 6] = vertices[i + 18]; - } - t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 4, vertices_tet, 4); - for (int i = 0; i < 3; i++) { - vertices_tet[i + 3] = vertices[i + 15]; - vertices_tet[i + 6] = vertices[i + 12]; - } - t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 5, vertices_tet, 4); + } + else if ( eclass == T8_ECLASS_TET) { + const t8_locidx_t tree_id_0 = 6 * cube_id; + /* Map vertices of a quad on to two triangles */ + double vertices_tet[12]; + for (int i = 0; i < 3; i++) { + vertices_tet[i] = vertices[i]; + vertices_tet[i + 3] = vertices[i + 3]; + vertices_tet[i + 6] = vertices[i + 15]; + vertices_tet[i + 9] = vertices[i + 21]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id_0, vertices_tet, 4); + for (int i = 0; i < 3; i++) { + vertices_tet[i + 3] = vertices[i + 9]; + vertices_tet[i + 6] = vertices[i + 3]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 1, vertices_tet, 4); + for (int i = 0; i < 3; i++) { + vertices_tet[i + 3] = vertices[i + 6]; + vertices_tet[i + 6] = vertices[i + 9]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 2, vertices_tet, 4); + for (int i = 0; i < 3; i++) { + vertices_tet[i + 3] = vertices[i + 18]; + vertices_tet[i + 6] = vertices[i + 6]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 3, vertices_tet, 4); + for (int i = 0; i < 3; i++) { + vertices_tet[i + 3] = vertices[i + 12]; + vertices_tet[i + 6] = vertices[i + 18]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 4, vertices_tet, 4); + for (int i = 0; i < 3; i++) { + vertices_tet[i + 3] = vertices[i + 15]; + vertices_tet[i + 6] = vertices[i + 12]; } - break; - case T8_ECLASS_PRISM: - { - const t8_locidx_t tree_id_0 = 2 * cube_id; - /* Map vertices of a quad on to two triangles */ - double vertices_prism[18]; - for (int i = 0; i < 3; i++) { - vertices_prism[i] = vertices[i]; - vertices_prism[i + 3] = vertices[i + 3]; - vertices_prism[i + 6] = vertices[i + 9]; - vertices_prism[i + 9] = vertices[i + 12]; - vertices_prism[i + 12] = vertices[i + 15]; - vertices_prism[i + 15] = vertices[i + 21]; - } - t8_cmesh_set_tree_vertices (cmesh, tree_id_0, vertices_prism, 6); - for (int i = 0; i < 3; i++) { - vertices_prism[i + 3] = vertices[i + 9]; - vertices_prism[i + 6] = vertices[i + 6]; - vertices_prism[i + 12] = vertices[i + 21]; - vertices_prism[i + 15] = vertices[i + 18]; - } - t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 1, vertices_prism, 6); + t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 5, vertices_tet, 4); + } + else { + T8_ASSERT (eclass == T8_ECLASS_PRISM); + const t8_locidx_t tree_id_0 = 2 * cube_id; + /* Map vertices of a quad on to two triangles */ + double vertices_prism[18]; + for (int i = 0; i < 3; i++) { + vertices_prism[i] = vertices[i]; + vertices_prism[i + 3] = vertices[i + 3]; + vertices_prism[i + 6] = vertices[i + 9]; + vertices_prism[i + 9] = vertices[i + 12]; + vertices_prism[i + 12] = vertices[i + 15]; + vertices_prism[i + 15] = vertices[i + 21]; + } + t8_cmesh_set_tree_vertices (cmesh, tree_id_0, vertices_prism, 6); + for (int i = 0; i < 3; i++) { + vertices_prism[i + 3] = vertices[i + 9]; + vertices_prism[i + 6] = vertices[i + 6]; + vertices_prism[i + 12] = vertices[i + 21]; + vertices_prism[i + 15] = vertices[i + 18]; } - break; - case T8_ECLASS_PYRAMID: - break; - default: - break; + t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 1, vertices_prism, 6); } } T8_ASSERT (axes[0] == 1); @@ -1204,6 +1196,7 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, t8_locidx_t trees_y, t8_locidx_t trees_z) { + SC_CHECK_ABORT (eclass != T8_ECLASS_PYRAMID, "Pyramids are not yet supported."); const int dim = t8_eclass_to_dimension[eclass]; switch (dim) { case 0: @@ -1238,55 +1231,47 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, t8_cmesh_set_tree_class (cmesh, tree_id, eclass); } - /* Set vertices of trees and join them */ - switch (eclass) { - case T8_ECLASS_VERTEX: - { - double vertices_attr_vert[4]; - /* Set first vertex to lower end of line */ - t8_vec_axy (boundary, vertices_attr_vert, 1.0); - t8_cmesh_set_tree_vertices (cmesh, 0, vertices_attr_vert, 1); - } - break; - case T8_ECLASS_LINE: - { - T8_ASSERT (boundary[3] > boundary[0]); - /* Get the direction of the line */ - double line_dir[3]; - t8_vec_axpyz (boundary, boundary + 3, line_dir, -1.0); - /* Get length of one tree */ - double length; - length = t8_vec_norm (line_dir) * (double) trees_x; - length = t8_vec_dist (boundary, boundary + 3) / length; - t8_vec_ax (line_dir, length); - - double vertices_attr[6]; - /* Set first vertex to lower end of line */ - t8_vec_axy (boundary, vertices_attr, 1.0); - /* Set second vertex to lower end of line + line_dir */ - t8_vec_axpyz (vertices_attr + 3, boundary, line_dir, 1.0); - - for (t8_locidx_t tree_x = 0; tree_x < trees_x; tree_x++) { - t8_cmesh_set_tree_vertices (cmesh, tree_x, vertices_attr, 2); - /* Update vertices for next tree */ - t8_vec_axy (vertices_attr, vertices_attr + 3, 1.0); - t8_vec_axpy (line_dir, vertices_attr + 3, 1.0); - } - } - break; - case T8_ECLASS_QUAD: - case T8_ECLASS_TRIANGLE: - t8_cmesh_set_vertices_2D (cmesh, eclass, boundary, trees_x, trees_y); - break; - case T8_ECLASS_HEX: - case T8_ECLASS_TET: - case T8_ECLASS_PRISM: - case T8_ECLASS_PYRAMID: + /* Set vertices of trees */ + if (dim == 3) { + T8_ASSERT (eclass == T8_ECLASS_HEX || eclass == T8_ECLASS_TET || eclass == T8_ECLASS_PRISM); t8_cmesh_set_vertices_3D (cmesh, eclass, boundary, trees_x, trees_y, trees_z); - break; - default: - SC_ABORT ("Invalid eclass\n"); - break; + } + else if (dim == 2) { + T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_TRIANGLE); + t8_cmesh_set_vertices_2D (cmesh, eclass, boundary, trees_x, trees_y); + } + else if (dim == 1) { + T8_ASSERT (eclass == T8_ECLASS_LINE); + T8_ASSERT (boundary[3] > boundary[0]); + /* Get the direction of the line */ + double line_dir[3]; + t8_vec_axpyz (boundary, boundary + 3, line_dir, -1.0); + /* Get length of one tree */ + double length; + length = t8_vec_norm (line_dir) * (double) trees_x; + length = t8_vec_dist (boundary, boundary + 3) / length; + t8_vec_ax (line_dir, length); + + double vertices_attr[6]; + /* Set first vertex to lower end of line */ + t8_vec_axy (boundary, vertices_attr, 1.0); + /* Set second vertex to lower end of line + line_dir */ + t8_vec_axpyz (vertices_attr + 3, boundary, line_dir, 1.0); + + for (t8_locidx_t tree_x = 0; tree_x < trees_x; tree_x++) { + t8_cmesh_set_tree_vertices (cmesh, tree_x, vertices_attr, 2); + /* Update vertices for next tree */ + t8_vec_axy (vertices_attr, vertices_attr + 3, 1.0); + t8_vec_axpy (line_dir, vertices_attr + 3, 1.0); + } + } + else { + T8_ASSERT (dim == 0); + T8_ASSERT (eclass == T8_ECLASS_VERTEX); + double vertices_attr_vert[4]; + /* Set first vertex to lower end of line */ + t8_vec_axy (boundary, vertices_attr_vert, 1.0); + t8_cmesh_set_tree_vertices (cmesh, 0, vertices_attr_vert, 1); } /* Join the trees inside each cube */ @@ -1294,24 +1279,18 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, for (t8_locidx_t cube_y = 0; cube_y < trees_y; cube_y++) { for (t8_locidx_t cube_x = 0; cube_x < trees_x; cube_x++) { const t8_locidx_t cube_id = cube_z * trees_y * trees_x + cube_y * trees_x + cube_x; - t8_locidx_t tree_id_0; - switch (eclass) { - case T8_ECLASS_TRIANGLE: - case T8_ECLASS_PRISM: - tree_id_0 = cube_id * 2; - t8_cmesh_set_join (cmesh, tree_id_0, tree_id_0 + 1, 1, 2, 0); - break; - case T8_ECLASS_TET: + if (eclass == T8_ECLASS_TRIANGLE || eclass == T8_ECLASS_PRISM) { + const t8_locidx_t tree_id_0 = cube_id * 2; + const t8_locidx_t tree_id_1 = cube_id * 2 + 1; + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 1, 2, 0); + } + else { + T8_ASSERT (eclass == T8_ECLASS_TET); for (int i = 0; i < 6; i++) { const t8_locidx_t tree_id_0 = cube_id * 6 + i; const t8_locidx_t tree_id_1 = cube_id * 6 + (i + 1)%6; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 2, 1, 0); } - break; - case T8_ECLASS_PYRAMID: - break; - default: - break; } } } @@ -1321,33 +1300,23 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, for (t8_locidx_t cube_y = 0; cube_y < trees_y; cube_y++) { for (t8_locidx_t cube_x = 0; cube_x < trees_x - 1; cube_x++) { const t8_locidx_t cube_id = cube_z * trees_y * trees_x + cube_y * trees_x + cube_x; - t8_locidx_t tree_id_0; - t8_locidx_t tree_id_1; - switch (eclass) { - case T8_ECLASS_QUAD: - case T8_ECLASS_HEX: - tree_id_0 = cube_id; - tree_id_1 = cube_id + 1; + if (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX) { + const t8_locidx_t tree_id_0 = cube_id; + const t8_locidx_t tree_id_1 = cube_id + 1; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 1, 0, 1); - break; - case T8_ECLASS_TRIANGLE: - case T8_ECLASS_PRISM: - tree_id_0 = cube_id * 2; - tree_id_1 = cube_id * 2 + 3; + } + else if (eclass == T8_ECLASS_TRIANGLE || eclass == T8_ECLASS_PRISM) { + const t8_locidx_t tree_id_0 = cube_id * 2; + const t8_locidx_t tree_id_1 = cube_id * 2 + 3; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 1, 0); - break; - case T8_ECLASS_TET: - tree_id_0 = cube_id * 6; - tree_id_1 = cube_id * 6 + 10; - t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 0); - tree_id_0 = cube_id * 6 + 1; - tree_id_1 = cube_id * 6 + 9; - t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 0); - break; - case T8_ECLASS_PYRAMID: - break; - default: - break; + } + else { + T8_ASSERT (eclass == T8_ECLASS_TET); + for (int i = 0; i < 2; i++) { + const t8_locidx_t tree_id_0 = cube_id * 6 + i; + const t8_locidx_t tree_id_1 = cube_id * 6 + 10 - i; + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 0); + } } } } @@ -1357,33 +1326,24 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, for (t8_locidx_t cube_y = 0; cube_y < trees_y - 1; cube_y++) { for (t8_locidx_t cube_x = 0; cube_x < trees_x; cube_x++) { const t8_locidx_t cube_id_0 = cube_z * trees_y * trees_x + cube_y * trees_x + cube_x; - t8_locidx_t tree_id_0; - t8_locidx_t tree_id_1; - switch (eclass) { - case T8_ECLASS_QUAD: - case T8_ECLASS_HEX: - tree_id_0 = cube_id_0; - tree_id_1 = cube_id_0 + trees_x; + if (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX) { + const t8_locidx_t tree_id_0 = cube_id_0; + const t8_locidx_t tree_id_1 = cube_id_0 + trees_x; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 3, 2, 2); - break; - case T8_ECLASS_TRIANGLE: - case T8_ECLASS_PRISM: - tree_id_0 = cube_id_0 * 2 + 1; - tree_id_1 = cube_id_0 * 2 + 2 * trees_x; + } + if (eclass == T8_ECLASS_TRIANGLE || eclass == T8_ECLASS_PRISM) { + const t8_locidx_t tree_id_0 = cube_id_0 * 2 + 1; + const t8_locidx_t tree_id_1 = cube_id_0 * 2 + 2 * trees_x; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 2, 1); - break; - case T8_ECLASS_TET: - tree_id_0 = cube_id_0 * 6 + 2; - tree_id_1 = cube_id_0 * 6 + 6 * trees_x; + } + else { + T8_ASSERT (eclass == T8_ECLASS_TET); + t8_locidx_t tree_id_0 = cube_id_0 * 6 + 2; + t8_locidx_t tree_id_1 = cube_id_0 * 6 + 6 * trees_x; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 0); tree_id_0 = cube_id_0 * 6 + 3; tree_id_1 = cube_id_0 * 6 + 6 * trees_x + 5; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 2); - break; - case T8_ECLASS_PYRAMID: - break; - default: - break; } } } @@ -1393,33 +1353,26 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, for (t8_locidx_t cube_y = 0; cube_y < trees_y; cube_y++) { for (t8_locidx_t cube_x = 0; cube_x < trees_x; cube_x++) { const t8_locidx_t cube_id_0 = cube_z * trees_y * trees_x + cube_y * trees_x + cube_x; - t8_locidx_t tree_id_0; - t8_locidx_t tree_id_1; - switch (eclass) { - case T8_ECLASS_HEX: - tree_id_0 = cube_id_0; - tree_id_1 = cube_id_0 + (trees_y * trees_x); + if (eclass == T8_ECLASS_HEX) { + const t8_locidx_t tree_id_0 = cube_id_0; + const t8_locidx_t tree_id_1 = cube_id_0 + (trees_y * trees_x); t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 5, 4, 4); - break; - case T8_ECLASS_TET: - tree_id_0 = cube_id_0 * 6 + 5; - tree_id_1 = cube_id_0 * 6 + (6 * trees_y * trees_x) + 1; + } + else if (eclass == T8_ECLASS_TET) { + t8_locidx_t tree_id_0 = cube_id_0 * 6 + 5; + t8_locidx_t tree_id_1 = cube_id_0 * 6 + (6 * trees_y * trees_x) + 1; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 3); tree_id_0 = cube_id_0 * 6 + 4; tree_id_1 = cube_id_0 * 6 + (6 * trees_y * trees_x) + 2; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 0); - break; - case T8_ECLASS_PRISM: + } + else { + T8_ASSERT (eclass == T8_ECLASS_PRISM); for (int i = 0; i < 2; i++) { - tree_id_0 = cube_id_0 * 2 + i; - tree_id_1 = cube_id_0 * 2 + i + (2 * trees_y * trees_x); + const t8_locidx_t tree_id_0 = cube_id_0 * 2 + i; + const t8_locidx_t tree_id_1 = cube_id_0 * 2 + i + (2 * trees_y * trees_x); t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 4, 3, 3); } - break; - case T8_ECLASS_PYRAMID: - break; - default: - break; } } } From 05b87c9780be85f3e614784794b1fee96ef2effa Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 2 Mar 2023 15:17:29 +0100 Subject: [PATCH 019/255] renamed variables --- src/t8_cmesh/t8_cmesh_examples.c | 197 +++++++++++++++---------------- 1 file changed, 97 insertions(+), 100 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 9549766e56..864f9db38c 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -856,7 +856,7 @@ t8_update_box_face_edges (t8_eclass_t eclass, double *box_corners, double *box_edges, const int face, - const t8_locidx_t *trees) + const t8_locidx_t *axes) { T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX); T8_ASSERT (-1 < face && face < t8_eclass_num_faces[eclass]); @@ -870,11 +870,11 @@ t8_update_box_face_edges (t8_eclass_t eclass, /* direction */ t8_vec_axpyz (v_1, v_2, box_edges + (edge * 3), -1.0); /* length */ - double length_tree; - const double num_trees = eclass == T8_ECLASS_QUAD ? (double) trees[(edge/2 + 1)%2] : (double) trees[edge/4]; - length_tree = t8_vec_norm (box_edges + (edge * 3)) * num_trees; - length_tree = t8_vec_dist (v_1, v_2) / length_tree; - t8_vec_ax (box_edges + (edge * 3), length_tree); + const double num_cubes = eclass == T8_ECLASS_QUAD ? (double) axes[(edge/2 + 1)%2] : (double) axes[edge/4]; + double length_edge; + length_edge = t8_vec_norm (box_edges + (edge * 3)) * num_cubes; + length_edge = t8_vec_dist (v_1, v_2) / length_edge; + t8_vec_ax (box_edges + (edge * 3), length_edge); } } @@ -906,8 +906,8 @@ static void t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, t8_eclass_t eclass, const double *boundary, - const t8_locidx_t trees_x, - const t8_locidx_t trees_y) + const t8_locidx_t quads_x, + const t8_locidx_t quads_y) { T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_TRIANGLE); /* x axis */ @@ -924,7 +924,7 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, box[i] = boundary[i]; } - int axes[2] = {trees_x, trees_y}; + int axes[2] = {quads_x, quads_y}; /* The directional vector between two vertices v_i and v_j, i > j. * The length is egual to distance (v_i, v_j) / #trees @@ -944,8 +944,8 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 2, axes); t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 3, axes); - for (t8_locidx_t tree_y = 0; tree_y < trees_y; tree_y++) { - for (t8_locidx_t tree_x = 0; tree_x < trees_x; tree_x++) { + for (t8_locidx_t quad_y_id = 0; quad_y_id < quads_y; quad_y_id++) { + for (t8_locidx_t quad_x_id = 0; quad_x_id < quads_x; quad_x_id++) { /* Vertex 0 */ t8_vec_axy (box, vertices, 1.0); @@ -962,12 +962,12 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, t8_vec_axpyz (box, box_dir, vertices + 9, 1.0); if (eclass == T8_ECLASS_QUAD) { - const t8_locidx_t tree_id = tree_y * trees_x + tree_x; + const t8_locidx_t tree_id = quad_y_id * quads_x + quad_x_id; t8_cmesh_set_tree_vertices (cmesh, tree_id, vertices, 4); } else { T8_ASSERT (eclass == T8_ECLASS_TRIANGLE); - const t8_locidx_t tree_id = (tree_y * trees_x + tree_x) * 2; + const t8_locidx_t tree_id = (quad_y_id * quads_x + quad_x_id) * 2; /* Map vertices of a quad on to two triangles */ double vertices_triangle[9]; for (int i = 0; i < 3; i++) { @@ -987,13 +987,12 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, for (int i = 0; i < 12; i++) { box[i] = boundary[i]; } - axes[0] = trees_x; - axes[1] = trees_y; + axes[0] = quads_x; + axes[1] = quads_y; t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, axes); - /* reduce box along y axis and update box_dir */ - t8_resize_box (T8_ECLASS_QUAD, box, box_dir, 2, tree_y + 1, axes); + t8_resize_box (T8_ECLASS_QUAD, box, box_dir, 2, quad_y_id + 1, axes); t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 2, axes); } } @@ -1002,9 +1001,9 @@ static void t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, t8_eclass_t eclass, const double *boundary, - const t8_locidx_t trees_x, - const t8_locidx_t trees_y, - const t8_locidx_t trees_z) + const t8_locidx_t hexs_x, + const t8_locidx_t hexs_y, + const t8_locidx_t hexs_z) { /* x axis */ T8_ASSERT (boundary[3] > boundary[0]); @@ -1030,7 +1029,7 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, box[i] = boundary[i]; } - t8_locidx_t axes[3] = {trees_x, trees_y, trees_z}; + t8_locidx_t axes[3] = {hexs_x, hexs_y, hexs_z}; /* The directional vector between two vertices v_i and v_j, i > j. * The length is egual to distance (v_i, v_j) / #trees @@ -1053,9 +1052,9 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, t8_resize_box (T8_ECLASS_HEX, box, box_dir, 3, 1, axes); t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 3, axes); - for (t8_locidx_t tree_z = 0; tree_z < trees_z; tree_z++) { - for (t8_locidx_t tree_y = 0; tree_y < trees_y; tree_y++) { - for (t8_locidx_t tree_x = 0; tree_x < trees_x; tree_x++) { + for (t8_locidx_t hex_z_id = 0; hex_z_id < hexs_z; hex_z_id++) { + for (t8_locidx_t hex_y_id = 0; hex_y_id < hexs_y; hex_y_id++) { + for (t8_locidx_t hex_x_id = 0; hex_x_id < hexs_x; hex_x_id++) { /* * 6 ______ 7 The first vertex of box corresponds to the * /| / first vertex of the current hexahedral tree. @@ -1098,12 +1097,12 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, /* Vertex 3 */ t8_vec_axpyz (box, box_dir + 12, vertices + 9, 1.0); - const t8_locidx_t cube_id = tree_z * trees_y * trees_x + tree_y * trees_x + tree_x; + const t8_locidx_t hex_id = hex_z_id * hexs_y * hexs_x + hex_y_id * hexs_x + hex_x_id; if (eclass == T8_ECLASS_HEX) { - t8_cmesh_set_tree_vertices (cmesh, cube_id, vertices, 8); + t8_cmesh_set_tree_vertices (cmesh, hex_id, vertices, 8); } else if ( eclass == T8_ECLASS_TET) { - const t8_locidx_t tree_id_0 = 6 * cube_id; + const t8_locidx_t tree_id_0 = 6 * hex_id; /* Map vertices of a quad on to two triangles */ double vertices_tet[12]; for (int i = 0; i < 3; i++) { @@ -1141,7 +1140,7 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, } else { T8_ASSERT (eclass == T8_ECLASS_PRISM); - const t8_locidx_t tree_id_0 = 2 * cube_id; + const t8_locidx_t tree_id_0 = 2 * hex_id; /* Map vertices of a quad on to two triangles */ double vertices_prism[18]; for (int i = 0; i < 3; i++) { @@ -1164,18 +1163,18 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, } T8_ASSERT (axes[0] == 1); /* resize box along x axis and update box_dir */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 0, -trees_x, axes); + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 0, -hexs_x, axes); t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, axes); /* reduce box along y axis and update box_dir */ t8_resize_box (T8_ECLASS_HEX, box, box_dir, 2, 1, axes); t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 2, axes); } - T8_ASSERT (axes[0] == trees_x + 1); + T8_ASSERT (axes[0] == hexs_x + 1); T8_ASSERT (axes[1] == 1); /* increase box along y axis and update box_dir */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 2, -trees_y, axes); + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 2, -hexs_y, axes); t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 2, axes); /* reduce box along z axis and update box_dir */ @@ -1183,8 +1182,8 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 4, axes); } T8_ASSERT (axes[2] == 1); - T8_ASSERT (axes[1] == trees_y + 1); - T8_ASSERT (axes[0] == trees_x + 1); + T8_ASSERT (axes[1] == hexs_y + 1); + T8_ASSERT (axes[0] == hexs_x + 1); } @@ -1192,23 +1191,23 @@ t8_cmesh_t t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, - t8_locidx_t trees_x, - t8_locidx_t trees_y, - t8_locidx_t trees_z) + t8_locidx_t polygons_x, + t8_locidx_t polygons_y, + t8_locidx_t polygons_z) { SC_CHECK_ABORT (eclass != T8_ECLASS_PYRAMID, "Pyramids are not yet supported."); const int dim = t8_eclass_to_dimension[eclass]; switch (dim) { case 0: - trees_x = 1; + polygons_x = 1; case 1: - trees_y = 1; + polygons_y = 1; case 2: - trees_z = 1; + polygons_z = 1; default: - T8_ASSERT (trees_x > 0); - T8_ASSERT (trees_y > 0); - T8_ASSERT (trees_z > 0); + T8_ASSERT (polygons_x > 0); + T8_ASSERT (polygons_y > 0); + T8_ASSERT (polygons_z > 0); break; } @@ -1225,20 +1224,18 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, }; /* Set tree class for every tree */ - for (t8_locidx_t tree_id = 0; tree_id < - trees_x * trees_y * trees_z * num_trees_for_single_hypercube[eclass]; - tree_id++) { + for (t8_locidx_t tree_id = 0; tree_id < polygons_x * polygons_y * polygons_z * num_trees_for_single_hypercube[eclass]; tree_id++) { t8_cmesh_set_tree_class (cmesh, tree_id, eclass); } /* Set vertices of trees */ if (dim == 3) { T8_ASSERT (eclass == T8_ECLASS_HEX || eclass == T8_ECLASS_TET || eclass == T8_ECLASS_PRISM); - t8_cmesh_set_vertices_3D (cmesh, eclass, boundary, trees_x, trees_y, trees_z); + t8_cmesh_set_vertices_3D (cmesh, eclass, boundary, polygons_x, polygons_y, polygons_z); } else if (dim == 2) { T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_TRIANGLE); - t8_cmesh_set_vertices_2D (cmesh, eclass, boundary, trees_x, trees_y); + t8_cmesh_set_vertices_2D (cmesh, eclass, boundary, polygons_x, polygons_y); } else if (dim == 1) { T8_ASSERT (eclass == T8_ECLASS_LINE); @@ -1248,47 +1245,47 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, t8_vec_axpyz (boundary, boundary + 3, line_dir, -1.0); /* Get length of one tree */ double length; - length = t8_vec_norm (line_dir) * (double) trees_x; + length = t8_vec_norm (line_dir) * (double) polygons_x; length = t8_vec_dist (boundary, boundary + 3) / length; t8_vec_ax (line_dir, length); - double vertices_attr[6]; + double vertices[6]; /* Set first vertex to lower end of line */ - t8_vec_axy (boundary, vertices_attr, 1.0); + t8_vec_axy (boundary, vertices, 1.0); /* Set second vertex to lower end of line + line_dir */ - t8_vec_axpyz (vertices_attr + 3, boundary, line_dir, 1.0); + t8_vec_axpyz (vertices + 3, boundary, line_dir, 1.0); - for (t8_locidx_t tree_x = 0; tree_x < trees_x; tree_x++) { - t8_cmesh_set_tree_vertices (cmesh, tree_x, vertices_attr, 2); + for (t8_locidx_t tree_x = 0; tree_x < polygons_x; tree_x++) { + t8_cmesh_set_tree_vertices (cmesh, tree_x, vertices, 2); /* Update vertices for next tree */ - t8_vec_axy (vertices_attr, vertices_attr + 3, 1.0); - t8_vec_axpy (line_dir, vertices_attr + 3, 1.0); + t8_vec_axy (vertices, vertices + 3, 1.0); + t8_vec_axpy (line_dir, vertices + 3, 1.0); } } else { T8_ASSERT (dim == 0); T8_ASSERT (eclass == T8_ECLASS_VERTEX); - double vertices_attr_vert[4]; + double vertex[3]; /* Set first vertex to lower end of line */ - t8_vec_axy (boundary, vertices_attr_vert, 1.0); - t8_cmesh_set_tree_vertices (cmesh, 0, vertices_attr_vert, 1); + t8_vec_axy (boundary, vertex, 1.0); + t8_cmesh_set_tree_vertices (cmesh, 0, vertex, 1); } /* Join the trees inside each cube */ - for (t8_locidx_t cube_z = 0; cube_z < trees_z; cube_z++) { - for (t8_locidx_t cube_y = 0; cube_y < trees_y; cube_y++) { - for (t8_locidx_t cube_x = 0; cube_x < trees_x; cube_x++) { - const t8_locidx_t cube_id = cube_z * trees_y * trees_x + cube_y * trees_x + cube_x; + for (t8_locidx_t poly_z_id = 0; poly_z_id < polygons_z; poly_z_id++) { + for (t8_locidx_t poly_y_id = 0; poly_y_id < polygons_y; poly_y_id++) { + for (t8_locidx_t poly_x_id = 0; poly_x_id < polygons_x; poly_x_id++) { + const t8_locidx_t poly_id = poly_z_id * polygons_y * polygons_x + poly_y_id * polygons_x + poly_x_id; if (eclass == T8_ECLASS_TRIANGLE || eclass == T8_ECLASS_PRISM) { - const t8_locidx_t tree_id_0 = cube_id * 2; - const t8_locidx_t tree_id_1 = cube_id * 2 + 1; + const t8_locidx_t tree_id_0 = poly_id * 2; + const t8_locidx_t tree_id_1 = poly_id * 2 + 1; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 1, 2, 0); } else { T8_ASSERT (eclass == T8_ECLASS_TET); for (int i = 0; i < 6; i++) { - const t8_locidx_t tree_id_0 = cube_id * 6 + i; - const t8_locidx_t tree_id_1 = cube_id * 6 + (i + 1)%6; + const t8_locidx_t tree_id_0 = poly_id * 6 + i; + const t8_locidx_t tree_id_1 = poly_id * 6 + (i + 1)%6; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 2, 1, 0); } } @@ -1296,25 +1293,25 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, } } /* Join the cubes along the x - axis */ - for (t8_locidx_t cube_z = 0; cube_z < trees_z; cube_z++) { - for (t8_locidx_t cube_y = 0; cube_y < trees_y; cube_y++) { - for (t8_locidx_t cube_x = 0; cube_x < trees_x - 1; cube_x++) { - const t8_locidx_t cube_id = cube_z * trees_y * trees_x + cube_y * trees_x + cube_x; + for (t8_locidx_t poly_z_id = 0; poly_z_id < polygons_z; poly_z_id++) { + for (t8_locidx_t poly_y_id = 0; poly_y_id < polygons_y; poly_y_id++) { + for (t8_locidx_t poly_x_id = 0; poly_x_id < polygons_x - 1; poly_x_id++) { + const t8_locidx_t poly_id = poly_z_id * polygons_y * polygons_x + poly_y_id * polygons_x + poly_x_id; if (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX) { - const t8_locidx_t tree_id_0 = cube_id; - const t8_locidx_t tree_id_1 = cube_id + 1; + const t8_locidx_t tree_id_0 = poly_id; + const t8_locidx_t tree_id_1 = poly_id + 1; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 1, 0, 1); } else if (eclass == T8_ECLASS_TRIANGLE || eclass == T8_ECLASS_PRISM) { - const t8_locidx_t tree_id_0 = cube_id * 2; - const t8_locidx_t tree_id_1 = cube_id * 2 + 3; + const t8_locidx_t tree_id_0 = poly_id * 2; + const t8_locidx_t tree_id_1 = poly_id * 2 + 3; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 1, 0); } else { T8_ASSERT (eclass == T8_ECLASS_TET); for (int i = 0; i < 2; i++) { - const t8_locidx_t tree_id_0 = cube_id * 6 + i; - const t8_locidx_t tree_id_1 = cube_id * 6 + 10 - i; + const t8_locidx_t tree_id_0 = poly_id * 6 + i; + const t8_locidx_t tree_id_1 = poly_id * 6 + 10 - i; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 0); } } @@ -1322,55 +1319,55 @@ t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, } } /* Join the cubes along the y - axis */ - for (t8_locidx_t cube_z = 0; cube_z < trees_z; cube_z++) { - for (t8_locidx_t cube_y = 0; cube_y < trees_y - 1; cube_y++) { - for (t8_locidx_t cube_x = 0; cube_x < trees_x; cube_x++) { - const t8_locidx_t cube_id_0 = cube_z * trees_y * trees_x + cube_y * trees_x + cube_x; + for (t8_locidx_t poly_z_id = 0; poly_z_id < polygons_z; poly_z_id++) { + for (t8_locidx_t poly_y_id = 0; poly_y_id < polygons_y - 1; poly_y_id++) { + for (t8_locidx_t poly_x_id = 0; poly_x_id < polygons_x; poly_x_id++) { + const t8_locidx_t poly_id_0 = poly_z_id * polygons_y * polygons_x + poly_y_id * polygons_x + poly_x_id; if (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX) { - const t8_locidx_t tree_id_0 = cube_id_0; - const t8_locidx_t tree_id_1 = cube_id_0 + trees_x; + const t8_locidx_t tree_id_0 = poly_id_0; + const t8_locidx_t tree_id_1 = poly_id_0 + polygons_x; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 3, 2, 2); } if (eclass == T8_ECLASS_TRIANGLE || eclass == T8_ECLASS_PRISM) { - const t8_locidx_t tree_id_0 = cube_id_0 * 2 + 1; - const t8_locidx_t tree_id_1 = cube_id_0 * 2 + 2 * trees_x; + const t8_locidx_t tree_id_0 = poly_id_0 * 2 + 1; + const t8_locidx_t tree_id_1 = poly_id_0 * 2 + 2 * polygons_x; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 2, 1); } else { T8_ASSERT (eclass == T8_ECLASS_TET); - t8_locidx_t tree_id_0 = cube_id_0 * 6 + 2; - t8_locidx_t tree_id_1 = cube_id_0 * 6 + 6 * trees_x; + t8_locidx_t tree_id_0 = poly_id_0 * 6 + 2; + t8_locidx_t tree_id_1 = poly_id_0 * 6 + 6 * polygons_x; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 0); - tree_id_0 = cube_id_0 * 6 + 3; - tree_id_1 = cube_id_0 * 6 + 6 * trees_x + 5; + tree_id_0 = poly_id_0 * 6 + 3; + tree_id_1 = poly_id_0 * 6 + 6 * polygons_x + 5; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 2); } } } } /* Join the cubes along the z - axis */ - for (t8_locidx_t cube_z = 0; cube_z < trees_z - 1; cube_z++) { - for (t8_locidx_t cube_y = 0; cube_y < trees_y; cube_y++) { - for (t8_locidx_t cube_x = 0; cube_x < trees_x; cube_x++) { - const t8_locidx_t cube_id_0 = cube_z * trees_y * trees_x + cube_y * trees_x + cube_x; + for (t8_locidx_t poly_z_id = 0; poly_z_id < polygons_z - 1; poly_z_id++) { + for (t8_locidx_t poly_y_id = 0; poly_y_id < polygons_y; poly_y_id++) { + for (t8_locidx_t poly_x_id = 0; poly_x_id < polygons_x; poly_x_id++) { + const t8_locidx_t poly_id_0 = poly_z_id * polygons_y * polygons_x + poly_y_id * polygons_x + poly_x_id; if (eclass == T8_ECLASS_HEX) { - const t8_locidx_t tree_id_0 = cube_id_0; - const t8_locidx_t tree_id_1 = cube_id_0 + (trees_y * trees_x); + const t8_locidx_t tree_id_0 = poly_id_0; + const t8_locidx_t tree_id_1 = poly_id_0 + (polygons_y * polygons_x); t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 5, 4, 4); } else if (eclass == T8_ECLASS_TET) { - t8_locidx_t tree_id_0 = cube_id_0 * 6 + 5; - t8_locidx_t tree_id_1 = cube_id_0 * 6 + (6 * trees_y * trees_x) + 1; + t8_locidx_t tree_id_0 = poly_id_0 * 6 + 5; + t8_locidx_t tree_id_1 = poly_id_0 * 6 + (6 * polygons_y * polygons_x) + 1; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 3); - tree_id_0 = cube_id_0 * 6 + 4; - tree_id_1 = cube_id_0 * 6 + (6 * trees_y * trees_x) + 2; + tree_id_0 = poly_id_0 * 6 + 4; + tree_id_1 = poly_id_0 * 6 + (6 * polygons_y * polygons_x) + 2; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 0); } else { T8_ASSERT (eclass == T8_ECLASS_PRISM); for (int i = 0; i < 2; i++) { - const t8_locidx_t tree_id_0 = cube_id_0 * 2 + i; - const t8_locidx_t tree_id_1 = cube_id_0 * 2 + i + (2 * trees_y * trees_x); + const t8_locidx_t tree_id_0 = poly_id_0 * 2 + i; + const t8_locidx_t tree_id_1 = poly_id_0 * 2 + i + (2 * polygons_y * polygons_x); t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 4, 3, 3); } } From bc84cd008cbeab089520e412db8110a907eb818e Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 2 Mar 2023 17:17:22 +0100 Subject: [PATCH 020/255] rearranged functions and added documentation in t8_eclass.h/.c --- src/t8_eclass.c | 39 +++++++++++++++++++++------------------ src/t8_eclass.h | 16 ++++++++++++---- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/src/t8_eclass.c b/src/t8_eclass.c index c5be91406a..0e875532bc 100644 --- a/src/t8_eclass.c +++ b/src/t8_eclass.c @@ -33,16 +33,29 @@ const int t8_eclass_max_num_faces[T8_ECLASS_MAX_DIM + 1] = { 0, 2, 4, 6 }; const int t8_face_vertex_to_tree_vertex[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES][T8_ECLASS_MAX_CORNERS_2D] = { - {{-1}}, /* vertex */ - {{0}, {1}}, /* line */ - {{0, 2}, {1, 3}, {0, 1}, {2, 3}}, /* quad */ - {{1, 2}, {0, 2}, {0, 1}}, /* triangle */ + {{-1}}, /* vertex */ + {{0}, {1}}, /* line */ + {{0, 2}, {1, 3}, {0, 1}, {2, 3}}, /* quad */ + {{1, 2}, {0, 2}, {0, 1}}, /* triangle */ {{0, 2, 4, 6}, {1, 3, 5, 7}, {0, 1, 4, 5}, {2, 3, 6, 7}, {0, 1, 2, 3}, {4, 5, 6, 7}}, /* hex */ {{1, 2, 3}, {0, 2, 3}, {0, 1, 3}, {0, 1, 2}}, /* tet */ {{1, 2, 4, 5}, {0, 2, 3, 5}, {0, 1, 3, 4}, {0, 1, 2}, {3, 4, 5}}, /* prism */ {{0, 2, 4}, {1, 3, 4}, {0, 1, 4}, {2, 3, 4}, {0, 1, 2, 3}} /* pyramid */ }; +/* TODO: tet, prism, pyramid + * remove suffix _n if issue #446 is solved */ +const int t8_face_edge_to_tree_edge_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES][T8_ECLASS_MAX_EDGES_2D] = { + {{-1}}, /* vertex */ + {{0}}, /* line */ + {{0}, {1}, {2}, {3}}, /* quad */ + {{0}, {1}, {2}}, /* triangle */ + {{8, 10, 4, 6}, {9, 11, 5, 7}, {8, 9, 0, 2}, {10, 11, 1, 3}, {4, 5, 0, 1}, {6, 7, 2, 3}}, /* hex */ + {}, /* tet */ + {}, /* prism */ + {}, /* pyramid */ +}; + /* TODO: tet, prism, pyramid */ const int t8_face_to_edge_neighbor[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES][T8_ECLASS_MAX_CORNERS_2D] = { {{-1}}, /* vertex */ @@ -55,7 +68,8 @@ const int t8_face_to_edge_neighbor[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES][T8_ECLA {}, /* pyramid */ }; -/* TODO: tet, prism, pyramid */ +/* TODO: tet, prism, pyramid + * remove suffix _n if issue #446 is solved */ const int t8_edge_vertex_to_tree_vertex_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2] = { {{-1}}, /* vertex */ {{0}, {1}}, /* line */ @@ -67,7 +81,8 @@ const int t8_edge_vertex_to_tree_vertex_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][ {}, /* pyramid */ }; -/* TODO: tet, prism, pyramid */ +/* TODO: tet, prism, pyramid + * remove suffix _n if issue #446 is solved */ const int t8_edge_to_face_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2] = { {{-1}}, /* vertex */ {{0}}, /* line */ @@ -79,18 +94,6 @@ const int t8_edge_to_face_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2] = { {}, /* pyramid */ }; -/* TODO: tet, prism, pyramid */ -const int t8_face_edge_to_tree_edge_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES][T8_ECLASS_MAX_EDGES_2D] = { - {{-1}}, /* vertex */ - {{0}}, /* line */ - {{0}, {1}, {2}, {3}}, /* quad */ - {{0}, {1}, {2}}, /* triangle */ - {{8, 10, 4, 6}, {9, 11, 5, 7}, {8, 9, 0, 2}, {10, 11, 1, 3}, {4, 5, 0, 1}, {6, 7, 2, 3}}, /* hex */ - {}, /* tet */ - {}, /* prism */ - {}, /* pyramid */ -}; - const int t8_eclass_face_orientation[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] = { {0, -1, -1, -1, -1, -1}, /* vertex */ {0, 0, -1, -1, -1, -1}, /* line */ diff --git a/src/t8_eclass.h b/src/t8_eclass.h index 2d464ca83b..74efa1246c 100644 --- a/src/t8_eclass.h +++ b/src/t8_eclass.h @@ -94,20 +94,28 @@ extern const int t8_face_vertex_to_tree_vertex[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] [T8_ECLASS_MAX_CORNERS_2D]; +/** For each eclass and each face f the entry i gives the edge number + * of f's i-th edge within all edges of the tree. */ +extern const int + t8_face_edge_to_tree_edge_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] + [T8_ECLASS_MAX_EDGES_2D]; + +/** For each eclass, each face f and the face vertex v, we get the edge number + * of the tree which is incident to vertex v but not part of f. */ extern const int t8_face_to_edge_neighbor[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] [T8_ECLASS_MAX_CORNERS_2D]; +/** For each eclass and each edge e the entry i gives the vertex number + * of e's i-th vertex within all vertices of the tree. */ extern const int t8_edge_vertex_to_tree_vertex_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2]; +/** For each eclass and each edge e the entry i gives the face number + * of e's i-th incident face within all faces of the tree. */ extern const int t8_edge_to_face_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2]; -extern const int - t8_face_edge_to_tree_edge_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] - [T8_ECLASS_MAX_EDGES_2D]; - /** Each face is either 0 or 1 oriented, depending on the order of its vertices. * We say a face is 0 oriented, if its normal vector points inwards, * 1 oriented otherwise. From bf8049ee6af4b93419395af180a281704d0222fb Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 2 Mar 2023 17:31:35 +0100 Subject: [PATCH 021/255] fixed empty initializer braces --- src/t8_eclass.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/t8_eclass.c b/src/t8_eclass.c index 0e875532bc..013179059e 100644 --- a/src/t8_eclass.c +++ b/src/t8_eclass.c @@ -51,9 +51,9 @@ const int t8_face_edge_to_tree_edge_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES][T8_E {{0}, {1}, {2}, {3}}, /* quad */ {{0}, {1}, {2}}, /* triangle */ {{8, 10, 4, 6}, {9, 11, 5, 7}, {8, 9, 0, 2}, {10, 11, 1, 3}, {4, 5, 0, 1}, {6, 7, 2, 3}}, /* hex */ - {}, /* tet */ - {}, /* prism */ - {}, /* pyramid */ + {{-1}}, /* tet */ + {{-1}}, /* prism */ + {{-1}}, /* pyramid */ }; /* TODO: tet, prism, pyramid */ @@ -63,9 +63,9 @@ const int t8_face_to_edge_neighbor[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES][T8_ECLA {{2, 3}, {2, 3}, {0, 1}, {0, 1}}, /* quad */ {{2, 1}, {2, 0}, {1, 0}}, /* triangle */ {{0, 1, 2, 3}, {0, 1, 2, 3}, {4, 5, 6, 7}, {4, 5, 6, 7}, {8, 9, 10, 11}, {8, 9, 10, 11}}, /* hex */ - {}, /* tet */ - {}, /* prism */ - {}, /* pyramid */ + {{-1}}, /* tet */ + {{-1}}, /* prism */ + {{-1}}, /* pyramid */ }; /* TODO: tet, prism, pyramid @@ -76,9 +76,9 @@ const int t8_edge_vertex_to_tree_vertex_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][ {{0, 2}, {1, 3}, {0, 1}, {2, 3}}, /* quad */ {{1, 2}, {0, 2}, {0, 1}}, /* triangle */ {{0, 1}, {2, 3}, {4, 5}, {6, 7}, {0, 2}, {1, 3}, {4, 6}, {5, 7}, {0, 4}, {1, 5}, {2, 6}, {3, 7}}, /* hex */ - {}, /* tet */ - {}, /* prism */ - {}, /* pyramid */ + {{-1}}, /* tet */ + {{-1}}, /* prism */ + {{-1}}, /* pyramid */ }; /* TODO: tet, prism, pyramid @@ -89,9 +89,9 @@ const int t8_edge_to_face_n[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2] = { {{0}, {1}, {2}, {3}}, /* quad */ {{0}, {1}, {2}}, /* triangle */ {{2, 4}, {3, 4}, {2, 5}, {3, 5}, {0, 4}, {1, 4}, {0, 5}, {1, 5}, {0, 2}, {1, 2}, {0, 3}, {1, 3}}, /* hex */ - {}, /* tet */ - {}, /* prism */ - {}, /* pyramid */ + {{-1}}, /* tet */ + {{-1}}, /* prism */ + {{-1}}, /* pyramid */ }; const int t8_eclass_face_orientation[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] = { From f43ccff5dd566acc569993a2688135fc7a4e4a64 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 2 Mar 2023 17:35:24 +0100 Subject: [PATCH 022/255] const some inputparameter --- src/t8_cmesh/t8_cmesh_examples.c | 55 +++++++++++++++++++------------- src/t8_cmesh/t8_cmesh_examples.h | 2 +- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 864f9db38c..2601304d80 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -852,8 +852,8 @@ t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, * z > y > x and factor_1 > factor 0 */ static void -t8_update_box_face_edges (t8_eclass_t eclass, - double *box_corners, +t8_update_box_face_edges (const t8_eclass_t eclass, + const double *box_corners, double *box_edges, const int face, const t8_locidx_t *axes) @@ -879,9 +879,9 @@ t8_update_box_face_edges (t8_eclass_t eclass, } static void -t8_resize_box (t8_eclass_t eclass, +t8_resize_box (const t8_eclass_t eclass, double *box, - double *box_dir, + const double *box_dir, const int face, const t8_locidx_t factor, int *axes) @@ -904,7 +904,7 @@ t8_resize_box (t8_eclass_t eclass, static void t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, - t8_eclass_t eclass, + const t8_eclass_t eclass, const double *boundary, const t8_locidx_t quads_x, const t8_locidx_t quads_y) @@ -926,17 +926,15 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, int axes[2] = {quads_x, quads_y}; - /* The directional vector between two vertices v_i and v_j, i > j. - * The length is egual to distance (v_i, v_j) / #trees + /* The directional vector e_k between two vertices v_i and v_j, i > j. + * The length is egual to distance (v_i, v_j) / #quads * along the respective axis. - * --> - * 2 _______ 3 - * | | - * ^ | | ^ - * | | | | - * |_______| - * 0 1 - * --> + * + * v2--e3--v3 + * | | + * e0 e1 y + * | | | + * v0--e2--v1 0---x **/ double box_dir[12]; t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, axes); @@ -999,7 +997,7 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, static void t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, - t8_eclass_t eclass, + const t8_eclass_t eclass, const double *boundary, const t8_locidx_t hexs_x, const t8_locidx_t hexs_y, @@ -1031,9 +1029,22 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, t8_locidx_t axes[3] = {hexs_x, hexs_y, hexs_z}; - /* The directional vector between two vertices v_i and v_j, i > j. - * The length is egual to distance (v_i, v_j) / #trees + /* The directional vector e_k between two vertices v_i and v_j, i > j. + * The length is egual to distance (v_i, v_j) / #hexes * along the respective axis. + * + * v6-------e3------v7 + * /| /| + * e6 | e7 | + * / e10 / e11 z y + * v4-------e2-----v5 | |/ + * | | | | 0--- x + * | v2 ------e1--|---v3 + * e8 / e9 / + * | e4 | e5 + * |/ | / + * v0------e0------v1 + * **/ double box_dir[36]; t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, axes); @@ -1188,12 +1199,12 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, t8_cmesh_t -t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, +t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, - t8_locidx_t polygons_x, - t8_locidx_t polygons_y, - t8_locidx_t polygons_z) + const t8_locidx_t polygons_x, + const t8_locidx_t polygons_y, + const t8_locidx_t polygons_z) { SC_CHECK_ABORT (eclass != T8_ECLASS_PYRAMID, "Pyramids are not yet supported."); const int dim = t8_eclass_to_dimension[eclass]; diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 022e9a9f00..9176a8c08d 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -114,7 +114,7 @@ t8_cmesh_t t8_cmesh_new_hypercube (t8_eclass_t eclass, * \a trees_x * \a trees_y * \a trees_z many trees of class \a eclass. * \note \a boundary must point to an array with 3*8 (3D), 3*4 (2D), 3*2 (1D), or 3 (0D) entries. */ -t8_cmesh_t t8_cmesh_new_hypercube_ext (t8_eclass_t eclass, +t8_cmesh_t t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t trees_x, From 7356ba4a35469fdb8e6d9af85358d3c006c29f2b Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 2 Mar 2023 18:18:34 +0100 Subject: [PATCH 023/255] unconst input axis parameter of t8_cmesh_new_hypercube_ext() --- src/t8_cmesh/t8_cmesh_examples.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 2601304d80..c67702b4bd 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1202,9 +1202,9 @@ t8_cmesh_t t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, - const t8_locidx_t polygons_x, - const t8_locidx_t polygons_y, - const t8_locidx_t polygons_z) + t8_locidx_t polygons_x, + t8_locidx_t polygons_y, + t8_locidx_t polygons_z) { SC_CHECK_ABORT (eclass != T8_ECLASS_PYRAMID, "Pyramids are not yet supported."); const int dim = t8_eclass_to_dimension[eclass]; From 1c3da76db7d3bcfcef07836ed5091661e662130c Mon Sep 17 00:00:00 2001 From: ililikakis Date: Fri, 3 Mar 2023 13:01:02 +0100 Subject: [PATCH 024/255] more documentation and asserts --- src/t8_cmesh/t8_cmesh_examples.c | 324 +++++++++++++++++-------------- src/t8_cmesh/t8_cmesh_examples.h | 17 +- 2 files changed, 189 insertions(+), 152 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index c67702b4bd..615c4c57a1 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -848,39 +848,53 @@ t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, return cmesh; } -/** - * z > y > x and factor_1 > factor 0 +/** This is just a helper function that was needed when we update the + * directional vector around a box for t8_cmesh_set_vertices_2D and _3D. + * \param [in] eclass The class of the box. T8_ECLASS_QUAD or T8_ECLASS_HEX + * \param [in] box_corners The vertices that define the box. + * \param [in, out] box_dir The direction vectors of the edges of the surrounding box. + * \param [in] face The box face whose edges need to be updated. + * \param [in] axes The number of quads or hexes along the axes. */ static void t8_update_box_face_edges (const t8_eclass_t eclass, const double *box_corners, - double *box_edges, + double *box_dir, const int face, const t8_locidx_t *axes) { T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX); T8_ASSERT (-1 < face && face < t8_eclass_num_faces[eclass]); - const int num_face_edges = eclass == T8_ECLASS_QUAD ? 1 : 4; for (int face_edge = 0; face_edge < num_face_edges; face_edge++) { const int edge = t8_face_edge_to_tree_edge_n[eclass][face][face_edge]; const double *v_1 = box_corners + (t8_edge_vertex_to_tree_vertex_n[eclass][edge][0] * 3); const double *v_2 = box_corners + (t8_edge_vertex_to_tree_vertex_n[eclass][edge][1] * 3); - - /* direction */ - t8_vec_axpyz (v_1, v_2, box_edges + (edge * 3), -1.0); - /* length */ + /* Get the direction vector between v_1 and v_2 and store it in box_dir. */ + t8_vec_axpyz (v_1, v_2, box_dir + (edge * 3), -1.0); + /* Get number of quads or hexs along current edge. */ const double num_cubes = eclass == T8_ECLASS_QUAD ? (double) axes[(edge/2 + 1)%2] : (double) axes[edge/4]; + /* Set length of directional vector to lengh of one quad or hex. */ double length_edge; - length_edge = t8_vec_norm (box_edges + (edge * 3)) * num_cubes; + length_edge = t8_vec_norm (box_dir + (edge * 3)) * num_cubes; length_edge = t8_vec_dist (v_1, v_2) / length_edge; - t8_vec_ax (box_edges + (edge * 3), length_edge); + t8_vec_ax (box_dir + (edge * 3), length_edge); } } +/** This is just a helper function that was needed when we change the + * size of a box for t8_cmesh_set_vertices_2D and _3D. + * \param [in] eclass The class of the box. T8_ECLASS_QUAD or T8_ECLASS_HEX + * \param [in, out] box_corners The vertices that define the box. + * \param [in] box_dir The direction vectors of the edges of the surrounding box. + * \param [in] face The box face along which we change the box size. + * \param [in] factor The number of quads or hexes along an axis + * defined by face by which we decrease or increase box. + * \param [in, out] axes The number of quads or hexes along the axes. + */ static void t8_resize_box (const t8_eclass_t eclass, - double *box, + double *box_corners, const double *box_dir, const int face, const t8_locidx_t factor, @@ -889,19 +903,25 @@ t8_resize_box (const t8_eclass_t eclass, T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX); T8_ASSERT (t8_eclass_to_dimension[eclass] > 1); T8_ASSERT (-1 < face && face < t8_eclass_num_faces[eclass]); - const int num_face_corner = eclass == T8_ECLASS_QUAD ? 2 : 4; - for (int face_corner = 0; face_corner < num_face_corner; face_corner++) { const int box_vertex = t8_face_vertex_to_tree_vertex[eclass][face][face_corner]; const int box_edge = t8_face_to_edge_neighbor[eclass][face][face_corner]; - t8_vec_axpy (box_dir + (box_edge * 3), box + (box_vertex * 3), (double) factor); + t8_vec_axpy (box_dir + (box_edge * 3), box_corners + (box_vertex * 3), (double) factor); } - axes[face/2] += face%2 ? factor : -factor; - } +/** This is just a helper function that was needed when we set the tree vertices + * of a 2 dimentional eclass in t8_cmesh_new_hypercube_ext(*). + * \param [in, out] cmesh The cmesh in which the vertices have to be set. + * \param [in] eclass The class of each tree. T8_ECLASS_QUAD or T8_ECLASS_TRIANGLE + * \param [in] boundary The boundary vertices of \a cmesh. + * \param [in] quads_x The number of quads along the x-axis. + * \param [in] quads_y The number of quads along the y-axis. + * \note each quad of \a quads_x * \a quads_y quads in \a boundary contains one + * tree of \a eclass T8_ECLASS_QUAD or two of T8_ECLASS_TRIANGLE. + */ static void t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, const t8_eclass_t eclass, @@ -909,26 +929,30 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, const t8_locidx_t quads_x, const t8_locidx_t quads_y) { + T8_ASSERT (!t8_cmesh_is_committed(cmesh)); T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_TRIANGLE); - /* x axis */ + /* x axes */ T8_ASSERT (boundary[3] > boundary[0]); T8_ASSERT (boundary[9] > boundary[6]); - /* y axis */ + /* y axes */ T8_ASSERT (boundary[7] > boundary[1]); T8_ASSERT (boundary[10] > boundary[4]); + /* Vertices of one quad inside boundary. */ double vertices[12]; - /* coordinates of reduced boundary box */ + /* Vertices of reduced boundary box. */ double box[12]; for (int i = 0; i < 12; i++) { box[i] = boundary[i]; } - int axes[2] = {quads_x, quads_y}; + /* Every time we change the size of the box, we keep track of it. */ + int box_quads[2] = {quads_x, quads_y}; - /* The directional vector e_k between two vertices v_i and v_j, i > j. - * The length is egual to distance (v_i, v_j) / #quads + /** The directional vector e_k between two vertices v_i and v_j, i > j + * of box. The length is egual to distance (v_i, v_j) / #box_quads * along the respective axis. + * \note Every time, we change the size of box, we must update box_dir. * * v2--e3--v3 * | | @@ -937,36 +961,42 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, * v0--e2--v1 0---x **/ double box_dir[12]; - t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, axes); - t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 1, axes); - t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 2, axes); - t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 3, axes); - + /* Set up initial box_dir. */ + t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, box_quads); + t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 1, box_quads); + t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 2, box_quads); + t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 3, box_quads); + + /* The first vertex of box corresponds to the first vertex of the + * current quad box (or tree in case of eclass = T8_ECLASS_QUADS). + * In every inner loop, reduce the box along the x-axis and face 0 + * so that the first vertex of box corresponds to vertices 0 or 1. + * Along the directional vector e_0 = (box_dir[0], box_dir[1]) + * of each resized box we can calculate the respective vertices 2 and 3. + * We iterate in the order of the trees - from bottom to top and left to right. + */ for (t8_locidx_t quad_y_id = 0; quad_y_id < quads_y; quad_y_id++) { for (t8_locidx_t quad_x_id = 0; quad_x_id < quads_x; quad_x_id++) { - /* Vertex 0 */ - t8_vec_axy (box, vertices, 1.0); - /* Vertex 2 */ - t8_vec_axpyz (box, box_dir, vertices + 6, 1.0); + t8_vec_axy (box, vertices, 1.0); /* Vertex 0 */ + t8_vec_axpyz (box, box_dir, vertices + 6, 1.0); /* Vertex 2 */ - /* reduce box along x axis and update box_dir */ - t8_resize_box (T8_ECLASS_QUAD, box, box_dir, 0, 1, axes); - t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, axes); + /* Reduce box along x axis */ + t8_resize_box (T8_ECLASS_QUAD, box, box_dir, 0, 1, box_quads); + t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, box_quads); - /* Vertex 1 */ - t8_vec_axy (box, vertices + 3, 1.0); - /* Vertex 3 */ - t8_vec_axpyz (box, box_dir, vertices + 9, 1.0); + t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ + t8_vec_axpyz (box, box_dir, vertices + 9, 1.0); /* Vertex 3 */ + /* Map vertices of current quad on to respective trees inside. */ if (eclass == T8_ECLASS_QUAD) { + /* No mapping is required. */ const t8_locidx_t tree_id = quad_y_id * quads_x + quad_x_id; t8_cmesh_set_tree_vertices (cmesh, tree_id, vertices, 4); } else { T8_ASSERT (eclass == T8_ECLASS_TRIANGLE); const t8_locidx_t tree_id = (quad_y_id * quads_x + quad_x_id) * 2; - /* Map vertices of a quad on to two triangles */ double vertices_triangle[9]; for (int i = 0; i < 3; i++) { vertices_triangle[i] = vertices[i]; @@ -981,20 +1011,33 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, t8_cmesh_set_tree_vertices (cmesh, tree_id + 1, vertices_triangle, 3); } } - /* resize box */ + T8_ASSERT (box_quads[0] == 0); + T8_ASSERT (box_quads[1] == quads_y - quad_y_id); + /* Resize box to initial boundary. */ for (int i = 0; i < 12; i++) { box[i] = boundary[i]; } - axes[0] = quads_x; - axes[1] = quads_y; - t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, axes); + box_quads[0] = quads_x; + box_quads[1] = quads_y; + t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, box_quads); - /* reduce box along y axis and update box_dir */ - t8_resize_box (T8_ECLASS_QUAD, box, box_dir, 2, quad_y_id + 1, axes); - t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 2, axes); + /* Reduce box along y axis and face 2. */ + t8_resize_box (T8_ECLASS_QUAD, box, box_dir, 2, quad_y_id + 1, box_quads); + t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 2, box_quads); } } +/** This is just a helper function that was needed when we set the tree vertices + * of a 3 dimentional eclass in t8_cmesh_new_hypercube_ext(*). + * \param [in, out] cmesh The cmesh in which the vertices have to be set. + * \param [in] eclass The class of each tree with dimension 3. + * \param [in] boundary The boundary vertices of \a cmesh. + * \param [in] hexs_x The number of hexs along the x-axis. + * \param [in] hexs_y The number of hexs along the y-axis. + * \param [in] hexs_z The number of hexs along the z-axis. + * \note each hex of \a hexs_x * \a hexs_y * \a hexs_z hexs in \a boundary + * contains several trees of class \a eclass. + */ static void t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, const t8_eclass_t eclass, @@ -1003,35 +1046,37 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, const t8_locidx_t hexs_y, const t8_locidx_t hexs_z) { - /* x axis */ + T8_ASSERT (!t8_cmesh_is_committed(cmesh)); + /* x axes */ T8_ASSERT (boundary[3] > boundary[0]); T8_ASSERT (boundary[9] > boundary[6]); T8_ASSERT (boundary[15] > boundary[12]); T8_ASSERT (boundary[21] > boundary[18]); - /* y axis */ + /* y axes */ T8_ASSERT (boundary[7] > boundary[1]); T8_ASSERT (boundary[10] > boundary[4]); T8_ASSERT (boundary[19] > boundary[13]); T8_ASSERT (boundary[22] > boundary[16]); - /* z axis */ + /* z axes */ T8_ASSERT (boundary[14] > boundary[2]); T8_ASSERT (boundary[17] > boundary[5]); T8_ASSERT (boundary[20] > boundary[8]); T8_ASSERT (boundary[23] > boundary[11]); - /* coordinates of one tree */ + /* Vertices of one hex inside boundary. */ double vertices[24]; - /* coordinates of reduced boundary box */ + /* Vertices of reduced boundary box. */ double box[24]; for (int i = 0; i < 24; i++) { box[i] = boundary[i]; } + /* Every time we change the size of the box, we keep track of it. */ + t8_locidx_t box_hexs[3] = {hexs_x, hexs_y, hexs_z}; - t8_locidx_t axes[3] = {hexs_x, hexs_y, hexs_z}; - - /* The directional vector e_k between two vertices v_i and v_j, i > j. - * The length is egual to distance (v_i, v_j) / #hexes + /** The directional vector e_k between two vertices v_i and v_j, i > j + * of box. The length is egual to distance (v_i, v_j) / #box_hexs * along the respective axis. + * \note Every time, we change the size of box, we must update box_dir. * * v6-------e3------v7 * /| /| @@ -1045,76 +1090,69 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, * |/ | / * v0------e0------v1 * - **/ + */ double box_dir[36]; - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, axes); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 1, axes); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 2, axes); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 3, axes); - - /* increse box along every axis by one tree */ - /* increase box along z axis and update box_dir */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 5, 1, axes); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 5, axes); - /* increase box along x axis and update box_dir */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 1, 1, axes); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 1, axes); - /* increase box along y axis and update box_dir */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 3, 1, axes); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 3, axes); - + /* Set up initial box_dir. Faces 0, 1, 2 and 3 cover all edges. */ + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, box_hexs); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 1, box_hexs); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 2, box_hexs); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 3, box_hexs); + + /* Increase the box along each axis x, y and z with faces 1, 3 and 5 + * by one hex. This is necessary because otherwise we get a box of + * length 0 at one point. */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 1, 1, box_hexs); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 1, box_hexs); + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 3, 1, box_hexs); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 3, box_hexs); + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 5, 1, box_hexs); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 5, box_hexs); + + /* The first vertex of box corresponds to the first vertex of the + * current hexahedral box (or tree in case of eclass = T8_ECLASS_HEX). + * Resize the box 3 times so that the first vertex of box corresponds to + * vertices 0, 4, 5 and finally 1. Along the directional vector + * e_4 = (box_dir[12], box_dir[13], box_dir[14]) of each resized box + * we can calculate the respective vertices 2, 3, 6 and 7. + * We iterate in the order of the trees - + * from bottom to top, front to back and left to right. + */ for (t8_locidx_t hex_z_id = 0; hex_z_id < hexs_z; hex_z_id++) { for (t8_locidx_t hex_y_id = 0; hex_y_id < hexs_y; hex_y_id++) { for (t8_locidx_t hex_x_id = 0; hex_x_id < hexs_x; hex_x_id++) { - /* - * 6 ______ 7 The first vertex of box corresponds to the - * /| / first vertex of the current hexahedral tree. - * 4 /_____5/| Resize the box so that the first vertex of box - * | | _ |_| corresponds to vertices 0, 4, 5 and finally 1. - * | 2 | / 3 Along the y axis we can calculate the respective - * |/____|/ vertices 2, 3, 6 and 7. - * 0 1 - */ - - /* Vertex 0 */ - t8_vec_axy (box, vertices, 1.0); - /* Vertex 2 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 6, 1.0); - - /* reduce box along z axis and update box_dir */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 4, 1, axes); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 4, axes); - - /* Vertex 4 */ - t8_vec_axy (box, vertices + 12, 1.0); - /* Vertex 6 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 18, 1.0); - - /* reduce box along x axis and update box_dir */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 0, 1, axes); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, axes); - - /* Vertex 5 */ - t8_vec_axy (box, vertices + 15, 1.0); - /* Vertex 7 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 21, 1.0); - - /* increase box along z axis and update box_dir */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 4, -1, axes); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 4, axes); - - /* Vertex 1 */ - t8_vec_axy (box, vertices + 3, 1.0); - /* Vertex 3 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 9, 1.0); - - const t8_locidx_t hex_id = hex_z_id * hexs_y * hexs_x + hex_y_id * hexs_x + hex_x_id; + + t8_vec_axy (box, vertices, 1.0); /* Vertex 0 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 6, 1.0); /* Vertex 2 */ + + /* Reduce box along z axis and face 4. */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 4, 1, box_hexs); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 4, box_hexs); + + t8_vec_axy (box, vertices + 12, 1.0); /* Vertex 4 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 18, 1.0); /* Vertex 6 */ + + /* Reduce box along x axis and face 0. */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 0, 1, box_hexs); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, box_hexs); + + t8_vec_axy (box, vertices + 15, 1.0); /* Vertex 5 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 21, 1.0); /* Vertex 7 */ + + /* Increase box along z axis and and face 4 */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 4, -1, box_hexs); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 4, box_hexs); + + t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 9, 1.0); /* Vertex 3 */ + + /* Map vertices of current hex on to respective trees inside. */ + const t8_locidx_t hex_id = hex_z_id * hexs_y * hexs_x + hex_y_id * hexs_x + hex_x_id; if (eclass == T8_ECLASS_HEX) { + /* No mapping is required. */ t8_cmesh_set_tree_vertices (cmesh, hex_id, vertices, 8); } else if ( eclass == T8_ECLASS_TET) { const t8_locidx_t tree_id_0 = 6 * hex_id; - /* Map vertices of a quad on to two triangles */ double vertices_tet[12]; for (int i = 0; i < 3; i++) { vertices_tet[i] = vertices[i]; @@ -1152,7 +1190,6 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, else { T8_ASSERT (eclass == T8_ECLASS_PRISM); const t8_locidx_t tree_id_0 = 2 * hex_id; - /* Map vertices of a quad on to two triangles */ double vertices_prism[18]; for (int i = 0; i < 3; i++) { vertices_prism[i] = vertices[i]; @@ -1172,32 +1209,31 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 1, vertices_prism, 6); } } - T8_ASSERT (axes[0] == 1); - /* resize box along x axis and update box_dir */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 0, -hexs_x, axes); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, axes); - - /* reduce box along y axis and update box_dir */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 2, 1, axes); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 2, axes); + T8_ASSERT (box_hexs[0] == 1); + /* Resize box along x axis and face 0 to get initial length. */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 0, -hexs_x, box_hexs); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, box_hexs); + + /* Reduce box along y axis and face 2. */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 2, 1, box_hexs); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 2, box_hexs); } - T8_ASSERT (axes[0] == hexs_x + 1); - T8_ASSERT (axes[1] == 1); + T8_ASSERT (box_hexs[0] == hexs_x + 1); + T8_ASSERT (box_hexs[1] == 1); - /* increase box along y axis and update box_dir */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 2, -hexs_y, axes); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 2, axes); + /* Resize box along y axis and face 2 to get initial length. */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 2, -hexs_y, box_hexs); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 2, box_hexs); - /* reduce box along z axis and update box_dir */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 4, 1, axes); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 4, axes); + /* Reduce box along z axis and face 4. */ + t8_resize_box (T8_ECLASS_HEX, box, box_dir, 4, 1, box_hexs); + t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 4, box_hexs); } - T8_ASSERT (axes[2] == 1); - T8_ASSERT (axes[1] == hexs_y + 1); - T8_ASSERT (axes[0] == hexs_x + 1); + T8_ASSERT (box_hexs[2] == 1); + T8_ASSERT (box_hexs[1] == hexs_y + 1); + T8_ASSERT (box_hexs[0] == hexs_x + 1); } - t8_cmesh_t t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, sc_MPI_Comm comm, @@ -1229,17 +1265,17 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, const t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); t8_cmesh_register_geometry (cmesh, linear_geom); - + /* Number of trees inside each polygon of given eclass. */ int num_trees_for_single_hypercube[T8_ECLASS_COUNT] = { 1, 1, 1, 2, 1, 6, 2, 3 }; - /* Set tree class for every tree */ + /* Set tree class for every tree. */ for (t8_locidx_t tree_id = 0; tree_id < polygons_x * polygons_y * polygons_z * num_trees_for_single_hypercube[eclass]; tree_id++) { t8_cmesh_set_tree_class (cmesh, tree_id, eclass); } - /* Set vertices of trees */ + /* Set the vertices of all trees. */ if (dim == 3) { T8_ASSERT (eclass == T8_ECLASS_HEX || eclass == T8_ECLASS_TET || eclass == T8_ECLASS_PRISM); t8_cmesh_set_vertices_3D (cmesh, eclass, boundary, polygons_x, polygons_y, polygons_z); @@ -1277,7 +1313,7 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, T8_ASSERT (dim == 0); T8_ASSERT (eclass == T8_ECLASS_VERTEX); double vertex[3]; - /* Set first vertex to lower end of line */ + /* Vertex == boundary. */ t8_vec_axy (boundary, vertex, 1.0); t8_cmesh_set_tree_vertices (cmesh, 0, vertex, 1); } @@ -1303,7 +1339,7 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, } } } - /* Join the cubes along the x - axis */ + /* Join the trees along the x - axis */ for (t8_locidx_t poly_z_id = 0; poly_z_id < polygons_z; poly_z_id++) { for (t8_locidx_t poly_y_id = 0; poly_y_id < polygons_y; poly_y_id++) { for (t8_locidx_t poly_x_id = 0; poly_x_id < polygons_x - 1; poly_x_id++) { @@ -1329,7 +1365,7 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, } } } - /* Join the cubes along the y - axis */ + /* Join the trees along the y - axis */ for (t8_locidx_t poly_z_id = 0; poly_z_id < polygons_z; poly_z_id++) { for (t8_locidx_t poly_y_id = 0; poly_y_id < polygons_y - 1; poly_y_id++) { for (t8_locidx_t poly_x_id = 0; poly_x_id < polygons_x; poly_x_id++) { @@ -1356,7 +1392,7 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, } } } - /* Join the cubes along the z - axis */ + /* Join the trees along the z - axis */ for (t8_locidx_t poly_z_id = 0; poly_z_id < polygons_z - 1; poly_z_id++) { for (t8_locidx_t poly_y_id = 0; poly_y_id < polygons_y; poly_y_id++) { for (t8_locidx_t poly_x_id = 0; poly_x_id < polygons_x; poly_x_id++) { diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 9176a8c08d..dc508486a5 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -104,22 +104,23 @@ t8_cmesh_t t8_cmesh_new_hypercube (t8_eclass_t eclass, /** Construct a hypercube forest from one primitive tree class. * \param [in] eclass This element class determines the dimension of the cube. * \param [in] comm The mpi communicator to be used. - * \param [in] boundary The coordinate, that define the hypercube vertices. - * \param [in] trees_x The number of trees along the x-axis. - * \param [in] trees_y The number of trees along the y-axis. + * \param [in] boundary The vertices, that define the hypercube boundary. + * \param [in] polygons_x The number of polygons along the x-axis. + * \param [in] polygons_y The number of polygons along the y-axis. * Only required if \a eclass is 2D or 3D. - * \param [in] trees_z The number of trees along the z-axis. + * \param [in] polygons_z The number of polygons along the z-axis. * Only required if \a eclass is 3D. * \return A committed t8_cmesh structure with - * \a trees_x * \a trees_y * \a trees_z many trees of class \a eclass. + * \a polygons_x * \a polygons_z * \a polygons_y many + * sub-hypercubes of class \a eclass. * \note \a boundary must point to an array with 3*8 (3D), 3*4 (2D), 3*2 (1D), or 3 (0D) entries. */ t8_cmesh_t t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, - t8_locidx_t trees_x, - t8_locidx_t trees_y, - t8_locidx_t trees_z); + t8_locidx_t polygons_x, + t8_locidx_t polygons_y, + t8_locidx_t polygons_z); /** Hybercube with 6 Tets, 6 Prism, 4 Hex. * \param [in] comm The mpi communicator to be used. From 98a046db8acbc7e4812cda98737655e54fe5d019 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Fri, 3 Mar 2023 13:24:09 +0100 Subject: [PATCH 025/255] indent --- src/t8_cmesh/t8_cmesh_examples.c | 264 ++++++++++++++++--------------- src/t8_cmesh/t8_cmesh_examples.h | 4 +- 2 files changed, 142 insertions(+), 126 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 615c4c57a1..f6d8d4f479 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -860,22 +860,26 @@ static void t8_update_box_face_edges (const t8_eclass_t eclass, const double *box_corners, double *box_dir, - const int face, - const t8_locidx_t *axes) + const int face, const t8_locidx_t *axes) { T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX); T8_ASSERT (-1 < face && face < t8_eclass_num_faces[eclass]); - const int num_face_edges = eclass == T8_ECLASS_QUAD ? 1 : 4; + const int num_face_edges = eclass == T8_ECLASS_QUAD ? 1 : 4; for (int face_edge = 0; face_edge < num_face_edges; face_edge++) { - const int edge = t8_face_edge_to_tree_edge_n[eclass][face][face_edge]; - const double *v_1 = box_corners + (t8_edge_vertex_to_tree_vertex_n[eclass][edge][0] * 3); - const double *v_2 = box_corners + (t8_edge_vertex_to_tree_vertex_n[eclass][edge][1] * 3); + const int edge = + t8_face_edge_to_tree_edge_n[eclass][face][face_edge]; + const double *v_1 = + box_corners + (t8_edge_vertex_to_tree_vertex_n[eclass][edge][0] * 3); + const double *v_2 = + box_corners + (t8_edge_vertex_to_tree_vertex_n[eclass][edge][1] * 3); /* Get the direction vector between v_1 and v_2 and store it in box_dir. */ t8_vec_axpyz (v_1, v_2, box_dir + (edge * 3), -1.0); /* Get number of quads or hexs along current edge. */ - const double num_cubes = eclass == T8_ECLASS_QUAD ? (double) axes[(edge/2 + 1)%2] : (double) axes[edge/4]; + const double num_cubes = + eclass == T8_ECLASS_QUAD ? + (double) axes[(edge / 2 + 1) % 2] : (double) axes[edge / 4]; /* Set length of directional vector to lengh of one quad or hex. */ - double length_edge; + double length_edge; length_edge = t8_vec_norm (box_dir + (edge * 3)) * num_cubes; length_edge = t8_vec_dist (v_1, v_2) / length_edge; t8_vec_ax (box_dir + (edge * 3), length_edge); @@ -896,20 +900,21 @@ static void t8_resize_box (const t8_eclass_t eclass, double *box_corners, const double *box_dir, - const int face, - const t8_locidx_t factor, - int *axes) + const int face, const t8_locidx_t factor, int *axes) { T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX); T8_ASSERT (t8_eclass_to_dimension[eclass] > 1); T8_ASSERT (-1 < face && face < t8_eclass_num_faces[eclass]); - const int num_face_corner = eclass == T8_ECLASS_QUAD ? 2 : 4; + const int num_face_corner = eclass == T8_ECLASS_QUAD ? 2 : 4; for (int face_corner = 0; face_corner < num_face_corner; face_corner++) { - const int box_vertex = t8_face_vertex_to_tree_vertex[eclass][face][face_corner]; - const int box_edge = t8_face_to_edge_neighbor[eclass][face][face_corner]; - t8_vec_axpy (box_dir + (box_edge * 3), box_corners + (box_vertex * 3), (double) factor); - } - axes[face/2] += face%2 ? factor : -factor; + const int box_vertex = + t8_face_vertex_to_tree_vertex[eclass][face][face_corner]; + const int box_edge = + t8_face_to_edge_neighbor[eclass][face][face_corner]; + t8_vec_axpy (box_dir + (box_edge * 3), box_corners + (box_vertex * 3), + (double) factor); + } + axes[face / 2] += face % 2 ? factor : -factor; } /** This is just a helper function that was needed when we set the tree vertices @@ -929,7 +934,7 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, const t8_locidx_t quads_x, const t8_locidx_t quads_y) { - T8_ASSERT (!t8_cmesh_is_committed(cmesh)); + T8_ASSERT (!t8_cmesh_is_committed (cmesh)); T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_TRIANGLE); /* x axes */ T8_ASSERT (boundary[3] > boundary[0]); @@ -947,7 +952,7 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, } /* Every time we change the size of the box, we keep track of it. */ - int box_quads[2] = {quads_x, quads_y}; + int box_quads[2] = { quads_x, quads_y }; /** The directional vector e_k between two vertices v_i and v_j, i > j * of box. The length is egual to distance (v_i, v_j) / #box_quads @@ -960,7 +965,7 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, * | | | * v0--e2--v1 0---x **/ - double box_dir[12]; + double box_dir[12]; /* Set up initial box_dir. */ t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, box_quads); t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 1, box_quads); @@ -975,38 +980,38 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, * of each resized box we can calculate the respective vertices 2 and 3. * We iterate in the order of the trees - from bottom to top and left to right. */ - for (t8_locidx_t quad_y_id = 0; quad_y_id < quads_y; quad_y_id++) { + for (t8_locidx_t quad_y_id = 0; quad_y_id < quads_y; quad_y_id++) { for (t8_locidx_t quad_x_id = 0; quad_x_id < quads_x; quad_x_id++) { - - t8_vec_axy (box, vertices, 1.0); /* Vertex 0 */ - t8_vec_axpyz (box, box_dir, vertices + 6, 1.0); /* Vertex 2 */ + + t8_vec_axy (box, vertices, 1.0); /* Vertex 0 */ + t8_vec_axpyz (box, box_dir, vertices + 6, 1.0); /* Vertex 2 */ /* Reduce box along x axis */ t8_resize_box (T8_ECLASS_QUAD, box, box_dir, 0, 1, box_quads); t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, box_quads); - t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ - t8_vec_axpyz (box, box_dir, vertices + 9, 1.0); /* Vertex 3 */ + t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ + t8_vec_axpyz (box, box_dir, vertices + 9, 1.0); /* Vertex 3 */ /* Map vertices of current quad on to respective trees inside. */ if (eclass == T8_ECLASS_QUAD) { /* No mapping is required. */ - const t8_locidx_t tree_id = quad_y_id * quads_x + quad_x_id; + const t8_locidx_t tree_id = quad_y_id * quads_x + quad_x_id; t8_cmesh_set_tree_vertices (cmesh, tree_id, vertices, 4); } else { T8_ASSERT (eclass == T8_ECLASS_TRIANGLE); - const t8_locidx_t tree_id = (quad_y_id * quads_x + quad_x_id) * 2; - double vertices_triangle[9]; + const t8_locidx_t tree_id = (quad_y_id * quads_x + quad_x_id) * 2; + double vertices_triangle[9]; for (int i = 0; i < 3; i++) { - vertices_triangle[i] = vertices[i]; - vertices_triangle[i + 3] = vertices[i + 3]; - vertices_triangle[i + 6] = vertices[i + 9]; + vertices_triangle[i] = vertices[i]; + vertices_triangle[i + 3] = vertices[i + 3]; + vertices_triangle[i + 6] = vertices[i + 9]; } t8_cmesh_set_tree_vertices (cmesh, tree_id, vertices_triangle, 3); - for (int i = 0; i < 3; i++) { - vertices_triangle[i + 3] = vertices[i + 9]; - vertices_triangle[i + 6] = vertices[i + 6]; + for (int i = 0; i < 3; i++) { + vertices_triangle[i + 3] = vertices[i + 9]; + vertices_triangle[i + 6] = vertices[i + 6]; } t8_cmesh_set_tree_vertices (cmesh, tree_id + 1, vertices_triangle, 3); } @@ -1043,10 +1048,9 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const double *boundary, const t8_locidx_t hexs_x, - const t8_locidx_t hexs_y, - const t8_locidx_t hexs_z) + const t8_locidx_t hexs_y, const t8_locidx_t hexs_z) { - T8_ASSERT (!t8_cmesh_is_committed(cmesh)); + T8_ASSERT (!t8_cmesh_is_committed (cmesh)); /* x axes */ T8_ASSERT (boundary[3] > boundary[0]); T8_ASSERT (boundary[9] > boundary[6]); @@ -1069,9 +1073,9 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, double box[24]; for (int i = 0; i < 24; i++) { box[i] = boundary[i]; - } + } /* Every time we change the size of the box, we keep track of it. */ - t8_locidx_t box_hexs[3] = {hexs_x, hexs_y, hexs_z}; + t8_locidx_t box_hexs[3] = { hexs_x, hexs_y, hexs_z }; /** The directional vector e_k between two vertices v_i and v_j, i > j * of box. The length is egual to distance (v_i, v_j) / #box_hexs @@ -1091,7 +1095,7 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, * v0------e0------v1 * */ - double box_dir[36]; + double box_dir[36]; /* Set up initial box_dir. Faces 0, 1, 2 and 3 cover all edges. */ t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, box_hexs); t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 1, box_hexs); @@ -1121,92 +1125,94 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, for (t8_locidx_t hex_y_id = 0; hex_y_id < hexs_y; hex_y_id++) { for (t8_locidx_t hex_x_id = 0; hex_x_id < hexs_x; hex_x_id++) { - t8_vec_axy (box, vertices, 1.0); /* Vertex 0 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 6, 1.0); /* Vertex 2 */ + t8_vec_axy (box, vertices, 1.0); /* Vertex 0 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 6, 1.0); /* Vertex 2 */ /* Reduce box along z axis and face 4. */ t8_resize_box (T8_ECLASS_HEX, box, box_dir, 4, 1, box_hexs); t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 4, box_hexs); - t8_vec_axy (box, vertices + 12, 1.0); /* Vertex 4 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 18, 1.0); /* Vertex 6 */ + t8_vec_axy (box, vertices + 12, 1.0); /* Vertex 4 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 18, 1.0); /* Vertex 6 */ /* Reduce box along x axis and face 0. */ t8_resize_box (T8_ECLASS_HEX, box, box_dir, 0, 1, box_hexs); t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, box_hexs); - t8_vec_axy (box, vertices + 15, 1.0); /* Vertex 5 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 21, 1.0); /* Vertex 7 */ + t8_vec_axy (box, vertices + 15, 1.0); /* Vertex 5 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 21, 1.0); /* Vertex 7 */ /* Increase box along z axis and and face 4 */ t8_resize_box (T8_ECLASS_HEX, box, box_dir, 4, -1, box_hexs); t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 4, box_hexs); - t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 9, 1.0); /* Vertex 3 */ + t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 9, 1.0); /* Vertex 3 */ /* Map vertices of current hex on to respective trees inside. */ - const t8_locidx_t hex_id = hex_z_id * hexs_y * hexs_x + hex_y_id * hexs_x + hex_x_id; + const t8_locidx_t hex_id = + hex_z_id * hexs_y * hexs_x + hex_y_id * hexs_x + hex_x_id; if (eclass == T8_ECLASS_HEX) { /* No mapping is required. */ t8_cmesh_set_tree_vertices (cmesh, hex_id, vertices, 8); } - else if ( eclass == T8_ECLASS_TET) { - const t8_locidx_t tree_id_0 = 6 * hex_id; - double vertices_tet[12]; + else if (eclass == T8_ECLASS_TET) { + const t8_locidx_t tree_id_0 = hex_id * 6; + double vertices_tet[12]; for (int i = 0; i < 3; i++) { - vertices_tet[i] = vertices[i]; - vertices_tet[i + 3] = vertices[i + 3]; - vertices_tet[i + 6] = vertices[i + 15]; - vertices_tet[i + 9] = vertices[i + 21]; + vertices_tet[i] = vertices[i]; + vertices_tet[i + 3] = vertices[i + 3]; + vertices_tet[i + 6] = vertices[i + 15]; + vertices_tet[i + 9] = vertices[i + 21]; } t8_cmesh_set_tree_vertices (cmesh, tree_id_0, vertices_tet, 4); for (int i = 0; i < 3; i++) { - vertices_tet[i + 3] = vertices[i + 9]; - vertices_tet[i + 6] = vertices[i + 3]; + vertices_tet[i + 3] = vertices[i + 9]; + vertices_tet[i + 6] = vertices[i + 3]; } t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 1, vertices_tet, 4); for (int i = 0; i < 3; i++) { - vertices_tet[i + 3] = vertices[i + 6]; - vertices_tet[i + 6] = vertices[i + 9]; + vertices_tet[i + 3] = vertices[i + 6]; + vertices_tet[i + 6] = vertices[i + 9]; } t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 2, vertices_tet, 4); for (int i = 0; i < 3; i++) { - vertices_tet[i + 3] = vertices[i + 18]; - vertices_tet[i + 6] = vertices[i + 6]; + vertices_tet[i + 3] = vertices[i + 18]; + vertices_tet[i + 6] = vertices[i + 6]; } t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 3, vertices_tet, 4); for (int i = 0; i < 3; i++) { - vertices_tet[i + 3] = vertices[i + 12]; - vertices_tet[i + 6] = vertices[i + 18]; + vertices_tet[i + 3] = vertices[i + 12]; + vertices_tet[i + 6] = vertices[i + 18]; } t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 4, vertices_tet, 4); for (int i = 0; i < 3; i++) { - vertices_tet[i + 3] = vertices[i + 15]; - vertices_tet[i + 6] = vertices[i + 12]; + vertices_tet[i + 3] = vertices[i + 15]; + vertices_tet[i + 6] = vertices[i + 12]; } t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 5, vertices_tet, 4); } else { T8_ASSERT (eclass == T8_ECLASS_PRISM); - const t8_locidx_t tree_id_0 = 2 * hex_id; - double vertices_prism[18]; + const t8_locidx_t tree_id_0 = hex_id * 2; + double vertices_prism[18]; for (int i = 0; i < 3; i++) { - vertices_prism[i] = vertices[i]; - vertices_prism[i + 3] = vertices[i + 3]; - vertices_prism[i + 6] = vertices[i + 9]; - vertices_prism[i + 9] = vertices[i + 12]; + vertices_prism[i] = vertices[i]; + vertices_prism[i + 3] = vertices[i + 3]; + vertices_prism[i + 6] = vertices[i + 9]; + vertices_prism[i + 9] = vertices[i + 12]; vertices_prism[i + 12] = vertices[i + 15]; vertices_prism[i + 15] = vertices[i + 21]; } t8_cmesh_set_tree_vertices (cmesh, tree_id_0, vertices_prism, 6); - for (int i = 0; i < 3; i++) { - vertices_prism[i + 3] = vertices[i + 9]; - vertices_prism[i + 6] = vertices[i + 6]; - vertices_prism[i + 12] = vertices[i + 21]; - vertices_prism[i + 15] = vertices[i + 18]; + for (int i = 0; i < 3; i++) { + vertices_prism[i + 3] = vertices[i + 9]; + vertices_prism[i + 6] = vertices[i + 6]; + vertices_prism[i + 12] = vertices[i + 21]; + vertices_prism[i + 15] = vertices[i + 18]; } - t8_cmesh_set_tree_vertices (cmesh, tree_id_0 + 1, vertices_prism, 6); + t8_cmesh_set_tree_vertices + (cmesh, tree_id_0 + 1, vertices_prism, 6); } } T8_ASSERT (box_hexs[0] == 1); @@ -1234,16 +1240,16 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, T8_ASSERT (box_hexs[0] == hexs_x + 1); } -t8_cmesh_t +t8_cmesh_t t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, sc_MPI_Comm comm, - const double *boundary, + const double *boundary, t8_locidx_t polygons_x, - t8_locidx_t polygons_y, - t8_locidx_t polygons_z) + t8_locidx_t polygons_y, t8_locidx_t polygons_z) { - SC_CHECK_ABORT (eclass != T8_ECLASS_PYRAMID, "Pyramids are not yet supported."); - const int dim = t8_eclass_to_dimension[eclass]; + SC_CHECK_ABORT (eclass != T8_ECLASS_PYRAMID, + "Pyramids are not yet supported."); + const int dim = t8_eclass_to_dimension[eclass]; switch (dim) { case 0: polygons_x = 1; @@ -1262,7 +1268,7 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, t8_cmesh_init (&cmesh); /* We use standard linear geometry */ - const t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); + const t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); t8_cmesh_register_geometry (cmesh, linear_geom); /* Number of trees inside each polygon of given eclass. */ @@ -1271,38 +1277,43 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, }; /* Set tree class for every tree. */ - for (t8_locidx_t tree_id = 0; tree_id < polygons_x * polygons_y * polygons_z * num_trees_for_single_hypercube[eclass]; tree_id++) { + for (t8_locidx_t tree_id = 0; tree_id < + polygons_x * polygons_y * polygons_z * + num_trees_for_single_hypercube[eclass]; tree_id++) { t8_cmesh_set_tree_class (cmesh, tree_id, eclass); } /* Set the vertices of all trees. */ if (dim == 3) { - T8_ASSERT (eclass == T8_ECLASS_HEX || eclass == T8_ECLASS_TET || eclass == T8_ECLASS_PRISM); - t8_cmesh_set_vertices_3D (cmesh, eclass, boundary, polygons_x, polygons_y, polygons_z); + T8_ASSERT (eclass == T8_ECLASS_HEX || eclass == T8_ECLASS_TET + || eclass == T8_ECLASS_PRISM); + t8_cmesh_set_vertices_3D + (cmesh, eclass, boundary, polygons_x, polygons_y, polygons_z); } else if (dim == 2) { T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_TRIANGLE); - t8_cmesh_set_vertices_2D (cmesh, eclass, boundary, polygons_x, polygons_y); + t8_cmesh_set_vertices_2D + (cmesh, eclass, boundary, polygons_x, polygons_y); } else if (dim == 1) { T8_ASSERT (eclass == T8_ECLASS_LINE); T8_ASSERT (boundary[3] > boundary[0]); /* Get the direction of the line */ - double line_dir[3]; + double line_dir[3]; t8_vec_axpyz (boundary, boundary + 3, line_dir, -1.0); /* Get length of one tree */ - double length; + double length; length = t8_vec_norm (line_dir) * (double) polygons_x; length = t8_vec_dist (boundary, boundary + 3) / length; t8_vec_ax (line_dir, length); - double vertices[6]; + double vertices[6]; /* Set first vertex to lower end of line */ t8_vec_axy (boundary, vertices, 1.0); /* Set second vertex to lower end of line + line_dir */ t8_vec_axpyz (vertices + 3, boundary, line_dir, 1.0); - for (t8_locidx_t tree_x = 0; tree_x < polygons_x; tree_x++) { + for (t8_locidx_t tree_x = 0; tree_x < polygons_x; tree_x++) { t8_cmesh_set_tree_vertices (cmesh, tree_x, vertices, 2); /* Update vertices for next tree */ t8_vec_axy (vertices, vertices + 3, 1.0); @@ -1312,7 +1323,7 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, else { T8_ASSERT (dim == 0); T8_ASSERT (eclass == T8_ECLASS_VERTEX); - double vertex[3]; + double vertex[3]; /* Vertex == boundary. */ t8_vec_axy (boundary, vertex, 1.0); t8_cmesh_set_tree_vertices (cmesh, 0, vertex, 1); @@ -1322,18 +1333,19 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, for (t8_locidx_t poly_z_id = 0; poly_z_id < polygons_z; poly_z_id++) { for (t8_locidx_t poly_y_id = 0; poly_y_id < polygons_y; poly_y_id++) { for (t8_locidx_t poly_x_id = 0; poly_x_id < polygons_x; poly_x_id++) { - const t8_locidx_t poly_id = poly_z_id * polygons_y * polygons_x + poly_y_id * polygons_x + poly_x_id; + const t8_locidx_t poly_id = poly_z_id * polygons_y * polygons_x + + poly_y_id * polygons_x + poly_x_id; if (eclass == T8_ECLASS_TRIANGLE || eclass == T8_ECLASS_PRISM) { - const t8_locidx_t tree_id_0 = poly_id * 2; - const t8_locidx_t tree_id_1 = poly_id * 2 + 1; + const t8_locidx_t tree_id_0 = poly_id * 2; + const t8_locidx_t tree_id_1 = poly_id * 2 + 1; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 1, 2, 0); } else { T8_ASSERT (eclass == T8_ECLASS_TET); for (int i = 0; i < 6; i++) { - const t8_locidx_t tree_id_0 = poly_id * 6 + i; - const t8_locidx_t tree_id_1 = poly_id * 6 + (i + 1)%6; - t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 2, 1, 0); + const t8_locidx_t tree_id_0 = poly_id * 6 + i; + const t8_locidx_t tree_id_1 = poly_id * 6 + (i + 1) % 6; + t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 2, 1, 0); } } } @@ -1343,22 +1355,23 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, for (t8_locidx_t poly_z_id = 0; poly_z_id < polygons_z; poly_z_id++) { for (t8_locidx_t poly_y_id = 0; poly_y_id < polygons_y; poly_y_id++) { for (t8_locidx_t poly_x_id = 0; poly_x_id < polygons_x - 1; poly_x_id++) { - const t8_locidx_t poly_id = poly_z_id * polygons_y * polygons_x + poly_y_id * polygons_x + poly_x_id; + const t8_locidx_t poly_id = poly_z_id * polygons_y * polygons_x + + poly_y_id * polygons_x + poly_x_id; if (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX) { - const t8_locidx_t tree_id_0 = poly_id; - const t8_locidx_t tree_id_1 = poly_id + 1; + const t8_locidx_t tree_id_0 = poly_id; + const t8_locidx_t tree_id_1 = poly_id + 1; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 1, 0, 1); } else if (eclass == T8_ECLASS_TRIANGLE || eclass == T8_ECLASS_PRISM) { - const t8_locidx_t tree_id_0 = poly_id * 2; - const t8_locidx_t tree_id_1 = poly_id * 2 + 3; + const t8_locidx_t tree_id_0 = poly_id * 2; + const t8_locidx_t tree_id_1 = poly_id * 2 + 3; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 1, 0); } else { T8_ASSERT (eclass == T8_ECLASS_TET); for (int i = 0; i < 2; i++) { - const t8_locidx_t tree_id_0 = poly_id * 6 + i; - const t8_locidx_t tree_id_1 = poly_id * 6 + 10 - i; + const t8_locidx_t tree_id_0 = poly_id * 6 + i; + const t8_locidx_t tree_id_1 = poly_id * 6 + 10 - i; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 0); } } @@ -1369,21 +1382,22 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, for (t8_locidx_t poly_z_id = 0; poly_z_id < polygons_z; poly_z_id++) { for (t8_locidx_t poly_y_id = 0; poly_y_id < polygons_y - 1; poly_y_id++) { for (t8_locidx_t poly_x_id = 0; poly_x_id < polygons_x; poly_x_id++) { - const t8_locidx_t poly_id_0 = poly_z_id * polygons_y * polygons_x + poly_y_id * polygons_x + poly_x_id; + const t8_locidx_t poly_id_0 = poly_z_id * polygons_y * polygons_x + + poly_y_id * polygons_x + poly_x_id; if (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX) { - const t8_locidx_t tree_id_0 = poly_id_0; - const t8_locidx_t tree_id_1 = poly_id_0 + polygons_x; + const t8_locidx_t tree_id_0 = poly_id_0; + const t8_locidx_t tree_id_1 = poly_id_0 + polygons_x; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 3, 2, 2); } if (eclass == T8_ECLASS_TRIANGLE || eclass == T8_ECLASS_PRISM) { - const t8_locidx_t tree_id_0 = poly_id_0 * 2 + 1; - const t8_locidx_t tree_id_1 = poly_id_0 * 2 + 2 * polygons_x; + const t8_locidx_t tree_id_0 = poly_id_0 * 2 + 1; + const t8_locidx_t tree_id_1 = (poly_id_0 + polygons_x) * 2; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 2, 1); } else { T8_ASSERT (eclass == T8_ECLASS_TET); - t8_locidx_t tree_id_0 = poly_id_0 * 6 + 2; - t8_locidx_t tree_id_1 = poly_id_0 * 6 + 6 * polygons_x; + t8_locidx_t tree_id_0 = poly_id_0 * 6 + 2; + t8_locidx_t tree_id_1 = (poly_id_0 + polygons_x) * 6; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 0); tree_id_0 = poly_id_0 * 6 + 3; tree_id_1 = poly_id_0 * 6 + 6 * polygons_x + 5; @@ -1396,25 +1410,28 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, for (t8_locidx_t poly_z_id = 0; poly_z_id < polygons_z - 1; poly_z_id++) { for (t8_locidx_t poly_y_id = 0; poly_y_id < polygons_y; poly_y_id++) { for (t8_locidx_t poly_x_id = 0; poly_x_id < polygons_x; poly_x_id++) { - const t8_locidx_t poly_id_0 = poly_z_id * polygons_y * polygons_x + poly_y_id * polygons_x + poly_x_id; + const t8_locidx_t poly_id_0 = poly_z_id * polygons_y * polygons_x + + poly_y_id * polygons_x + poly_x_id; if (eclass == T8_ECLASS_HEX) { - const t8_locidx_t tree_id_0 = poly_id_0; - const t8_locidx_t tree_id_1 = poly_id_0 + (polygons_y * polygons_x); + const t8_locidx_t tree_id_0 = poly_id_0; + const t8_locidx_t tree_id_1 = poly_id_0 + polygons_y * polygons_x; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 5, 4, 4); } else if (eclass == T8_ECLASS_TET) { - t8_locidx_t tree_id_0 = poly_id_0 * 6 + 5; - t8_locidx_t tree_id_1 = poly_id_0 * 6 + (6 * polygons_y * polygons_x) + 1; + t8_locidx_t tree_id_0 = poly_id_0 * 6 + 5; + t8_locidx_t tree_id_1 = + (poly_id_0 + polygons_y * polygons_x) * 6 + 1; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 3); tree_id_0 = poly_id_0 * 6 + 4; - tree_id_1 = poly_id_0 * 6 + (6 * polygons_y * polygons_x) + 2; + tree_id_1 = (poly_id_0 + polygons_y * polygons_x) * 6 + 2; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 3, 0); } else { T8_ASSERT (eclass == T8_ECLASS_PRISM); for (int i = 0; i < 2; i++) { - const t8_locidx_t tree_id_0 = poly_id_0 * 2 + i; - const t8_locidx_t tree_id_1 = poly_id_0 * 2 + i + (2 * polygons_y * polygons_x); + const t8_locidx_t tree_id_0 = poly_id_0 * 2 + i; + const t8_locidx_t tree_id_1 = + (poly_id_0 + polygons_y * polygons_x) * 2 + i; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 4, 3, 3); } } @@ -1426,7 +1443,6 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, return cmesh; } - t8_cmesh_t t8_cmesh_new_periodic_line_more_trees (sc_MPI_Comm comm) { diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index dc508486a5..979255243b 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -117,10 +117,10 @@ t8_cmesh_t t8_cmesh_new_hypercube (t8_eclass_t eclass, */ t8_cmesh_t t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, sc_MPI_Comm comm, - const double *boundary, + const double *boundary, t8_locidx_t polygons_x, t8_locidx_t polygons_y, - t8_locidx_t polygons_z); + t8_locidx_t polygons_z); /** Hybercube with 6 Tets, 6 Prism, 4 Hex. * \param [in] comm The mpi communicator to be used. From 7e3ce78251b26fa2b4d549f1721d89f907348cd0 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Mon, 6 Mar 2023 10:34:00 +0100 Subject: [PATCH 026/255] removed pyramids from num_trees_for_single_hypercube[] --- src/t8_cmesh/t8_cmesh_examples.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index f6d8d4f479..9fb7cf78d7 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1273,7 +1273,7 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, /* Number of trees inside each polygon of given eclass. */ int num_trees_for_single_hypercube[T8_ECLASS_COUNT] = { - 1, 1, 1, 2, 1, 6, 2, 3 + 1, 1, 1, 2, 1, 6, 2, -1 }; /* Set tree class for every tree. */ From 2707d6c9d68e60193b71160ab3d961f293ebd277 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Mon, 6 Mar 2023 10:39:50 +0100 Subject: [PATCH 027/255] changed datatype int - t8_locidx_t --- src/t8_cmesh/t8_cmesh_examples.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 9fb7cf78d7..a9b6c0dd5d 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1272,7 +1272,7 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, t8_cmesh_register_geometry (cmesh, linear_geom); /* Number of trees inside each polygon of given eclass. */ - int num_trees_for_single_hypercube[T8_ECLASS_COUNT] = { + const t8_locidx_t num_trees_for_single_hypercube[T8_ECLASS_COUNT] = { 1, 1, 1, 2, 1, 6, 2, -1 }; From 5bffd219a32ce4f715bc66981e6f11193cbabef0 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Mon, 6 Mar 2023 14:18:40 +0100 Subject: [PATCH 028/255] add note in documentation --- src/t8_cmesh/t8_cmesh_examples.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 979255243b..737eaa89de 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -114,6 +114,9 @@ t8_cmesh_t t8_cmesh_new_hypercube (t8_eclass_t eclass, * \a polygons_x * \a polygons_z * \a polygons_y many * sub-hypercubes of class \a eclass. * \note \a boundary must point to an array with 3*8 (3D), 3*4 (2D), 3*2 (1D), or 3 (0D) entries. + * \note Every sub-hypercube contains diffrent number of trees depending on \a eclass. + * \note If \a eclass == T8_ECLASS_VERTEX, _LINE, _QUAD or _HEX every sub-hypercube contains + * one tree, if _TRIANGLE or _PRISM two trees and if _TET six trees. */ t8_cmesh_t t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, sc_MPI_Comm comm, From 29f2f8ba1e2cd265eb1967dfd501d7d686300171 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Mon, 6 Mar 2023 14:26:26 +0100 Subject: [PATCH 029/255] fixed if else issue --- src/t8_cmesh/t8_cmesh_examples.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index a9b6c0dd5d..9ff4475386 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1340,14 +1340,16 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, const t8_locidx_t tree_id_1 = poly_id * 2 + 1; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 1, 2, 0); } - else { - T8_ASSERT (eclass == T8_ECLASS_TET); + else if (eclass == T8_ECLASS_TET) { for (int i = 0; i < 6; i++) { const t8_locidx_t tree_id_0 = poly_id * 6 + i; const t8_locidx_t tree_id_1 = poly_id * 6 + (i + 1) % 6; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 2, 1, 0); } } + else { + T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX); + } } } } @@ -1389,7 +1391,7 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, const t8_locidx_t tree_id_1 = poly_id_0 + polygons_x; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 3, 2, 2); } - if (eclass == T8_ECLASS_TRIANGLE || eclass == T8_ECLASS_PRISM) { + else if (eclass == T8_ECLASS_TRIANGLE || eclass == T8_ECLASS_PRISM) { const t8_locidx_t tree_id_0 = poly_id_0 * 2 + 1; const t8_locidx_t tree_id_1 = (poly_id_0 + polygons_x) * 2; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 0, 2, 1); From 2af4cfb0a18015adb92f3ea11188aafa0fcf6752 Mon Sep 17 00:00:00 2001 From: Knapp Date: Mon, 6 Mar 2023 15:23:55 +0100 Subject: [PATCH 030/255] Add vtk_poly_data_reader that transfers a mesh from a file to vtkSmartPointer --- src/Makefile.am | 6 +- .../t8_cmesh_vtk_polydata.cxx | 120 ++++++++++++++++++ .../t8_cmesh_vtk_polydata.hxx | 50 ++++++++ 3 files changed, 174 insertions(+), 2 deletions(-) create mode 100644 src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx create mode 100644 src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx diff --git a/src/Makefile.am b/src/Makefile.am index c694fd7b2c..3245c06677 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -74,10 +74,11 @@ libt8_internal_headers = \ src/t8_cmesh/t8_cmesh_types.h src/t8_cmesh/t8_cmesh_partition.h \ src/t8_cmesh/t8_cmesh_refine.h src/t8_cmesh/t8_cmesh_copy.h \ src/t8_cmesh/t8_cmesh_offset.h \ + src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx \ src/t8_forest/t8_forest_cxx.h \ src/t8_forest/t8_forest_ghost.h \ src/t8_forest/t8_forest_balance.h src/t8_forest/t8_forest_types.h \ - src/t8_forest/t8_forest_private.h + src/t8_forest/t8_forest_private.h libt8_compiled_sources = \ src/t8.c src/t8_eclass.c src/t8_mesh.c \ src/t8_element.c src/t8_element_cxx.cxx \ @@ -112,7 +113,8 @@ libt8_compiled_sources = \ src/t8_forest/t8_forest_netcdf.cxx \ src/t8_element_shape.c \ src/t8_netcdf.c \ - src/t8_cmesh/t8_cmesh_testcases.c + src/t8_cmesh/t8_cmesh_testcases.c \ + src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx # this variable is used for headers that are not publicly installed T8_CPPFLAGS = diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx new file mode 100644 index 0000000000..4e0c649485 --- /dev/null +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -0,0 +1,120 @@ +/* +This file is part of t8code. +t8code is a C library to manage a collection (a forest) of multiple +connected adaptive space-trees of general element classes in parallel. + +Copyright (C) 2015 the developers + +t8code is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +t8code is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with t8code; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#if T8_WITH_VTK +#include +#include +#include +#include +#include +#include +#include +#include + +void +t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) +{ + char tmp[BUFSIZ], *extension; + /* Get the file-extension to decide which reader to use. */ + strcpy (tmp, filename); + extension = strtok (tmp, "."); + extension = strtok (NULL, "."); + T8_ASSERT (strcmp (extension, "")); + + /* Read the file depending on the extension */ + if (strcmp (extension, "ply") == 0) { + vtkNew < vtkPLYReader > reader; + reader->SetFileName (filename); + reader->Update (); + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else if (strcmp (extension, "vtp") == 0) { + char tmp[BUFSIZ], *extension; + /* Get the file-extension to decide which reader to use. */ + strcpy (tmp, filename); + extension = strtok (tmp, "."); + extension = strtok (NULL, "."); + T8_ASSERT (strcmp (extension, "")); + + /* Read the file depending on the extension. Not all readers have + * a built-in check if the file is readable. */ + if (strcmp (extension, "ply") == 0) { + vtkNew < vtkPLYReader > reader; + reader->SetFileName (filename); + reader->Update (); + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else if (strcmp (extension, "vtp") == 0) { + vtkNew < vtkXMLPolyDataReader > reader; + reader->SetFileName (filename); + if (!reader->CanReadFile (filename)) { + t8_errorf ("Unable to read file.\n"); + return NULL; + } + reader->Update (); + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else if (strcmp (extension, "obj") == 0) { + vtkNew < vtkOBJReader > reader; + reader->SetFileName (filename); + reader->Update (); + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else if (strcmp (extension, "stl") == 0) { + vtkNew < vtkSTLReader > reader; + reader->SetFileName (filename); + reader->Update (); + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else if (strcmp (extension, "vtk") == 0) { + vtkNew < vtkPolyDataReader > reader; + reader->SetFileName (filename); + reader->Update (); + if (!reader->IsFilePolyData ()) { + t8_errorf + ("File-content is not polydata. If it is a vtkUnstructuredGrid use the unstructured Grid reader."); + return NULL; + } + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else if (strcmp (extension, "g") == 0) { + vtkNew < vtkBYUReader > reader; + reader->SetGeometryFileName (filename); + reader->Update (); + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else { + /* Return NULL if the reader is not used correctly. */ + t8_global_errorf + ("Please use .ply, .vtp, .obj, .stl, .vtk or .g file\n"); + return NULL; + } + } +} +#endif diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx new file mode 100644 index 0000000000..ad13a46219 --- /dev/null +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx @@ -0,0 +1,50 @@ +/* +This file is part of t8code. +t8code is a C library to manage a collection (a forest) of multiple +connected adaptive space-trees of general element classes in parallel. + +Copyright (C) 2015 the developers + +t8code is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +t8code is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with t8code; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** + * This file contains all helper functions to translate vtk-polydata. + * + */ + +#ifndef T8_CMESH_VTK_POLYDATA +#define T8_CMESH_VTK_POLYDATA + +#if T8_WITH_VTK +#include +#include +#include + +/** + * Given a filename to a file containing Polydata, read + * the file using the vtk-library. + * + * \param[in] filename The name of the file + * \param[in, out] grid On input a vtkSmartPointer, that will hold the grid described in + * \a filename. + * + */ +void t8_read_poly (const char *filename, + vtkSmartPointer < vtkPolyData > grid); + +#endif + +#endif /* T8_CMESH_VTK_POLYDATA */ From 9d058d0b6c722ee862c3fb92d9b53b3bb1e41e8a Mon Sep 17 00:00:00 2001 From: ililikakis Date: Mon, 6 Mar 2023 15:48:29 +0100 Subject: [PATCH 031/255] indent --- src/t8_cmesh.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/t8_cmesh.h b/src/t8_cmesh.h index bfe895591a..1c66cda999 100644 --- a/src/t8_cmesh.h +++ b/src/t8_cmesh.h @@ -742,9 +742,11 @@ void t8_cmesh_translate_coordinates (const double *coords_in, double translate[3]); /**TODO: Add proper documentation*/ -void t8_cmesh_new_translate_vertices_to_attributes (const t8_locidx_t +void t8_cmesh_new_translate_vertices_to_attributes (const + t8_locidx_t *tvertices, - const double + const + double *vertices, double *attr_vertices, From 61bbe8f7d31743a7bbdee6b5e6ef2a7c3b9047fa Mon Sep 17 00:00:00 2001 From: Knapp Date: Tue, 7 Mar 2023 14:31:08 +0100 Subject: [PATCH 032/255] Adding a dummy-test for the cmesh_vtk_reader --- src/t8_cmesh_vtk_reader.hxx | 1 + test/Makefile.am | 3 ++- test/t8_IO/t8_gtest_vtk_reader.cxx | 41 ++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 test/t8_IO/t8_gtest_vtk_reader.cxx diff --git a/src/t8_cmesh_vtk_reader.hxx b/src/t8_cmesh_vtk_reader.hxx index 21733dcfa6..f02b2abd9c 100644 --- a/src/t8_cmesh_vtk_reader.hxx +++ b/src/t8_cmesh_vtk_reader.hxx @@ -41,6 +41,7 @@ T8_EXTERN_C_BEGIN (); */ typedef enum vtk_file_type { + VTK_FILE_ERROR = -1, /*For Testing purpose. */ VTK_UNSTRUCTURED_FILE = 0, VTK_POLYDATA_FILE = 1 } vtk_file_type_t; diff --git a/test/Makefile.am b/test/Makefile.am index 0848072cea..6eaeffa161 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -69,7 +69,8 @@ test_t8_gtest_main_SOURCES = test/t8_gtest_main.cxx \ test/t8_schemes/t8_gtest_descendant.cxx \ test/t8_cmesh/t8_gtest_cmesh_face_is_boundary.cxx \ test/t8_cmesh/t8_gtest_multiple_attributes.cxx \ - test/t8_schemes/t8_gtest_successor.cxx + test/t8_schemes/t8_gtest_successor.cxx \ + test/t8_IO/t8_gtest_vtk_reader.cxx test_t8_gtest_main_LDADD = $(LDADD) test/libgtest.la test_t8_gtest_main_LDFLAGS = $(AM_LDFLAGS) -pthread diff --git a/test/t8_IO/t8_gtest_vtk_reader.cxx b/test/t8_IO/t8_gtest_vtk_reader.cxx new file mode 100644 index 0000000000..1acf5579d8 --- /dev/null +++ b/test/t8_IO/t8_gtest_vtk_reader.cxx @@ -0,0 +1,41 @@ +/* +This file is part of t8code. +t8code is a C library to manage a collection (a forest) of multiple +connected adaptive space-trees of general element classes in parallel. + +Copyright (C) 2015 the developers + +t8code is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +t8code is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with t8code; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include +#include + +/** + * This is currently a place-holder for a propper cmesh_vtk_reader-test. + * The function is not implemented yet and therefore we do not provide a propper + * test yet. + * + */ +TEST (t8_cmesh_vtk_reader, dummy_test) +{ +#if T8_WITH_VTK + /* Currently the function crashes if compiled with vtk. */ +#else + t8_cmesh_t cmesh = + t8_cmesh_vtk_reader (NULL, 0, 0, sc_MPI_COMM_NULL, VTK_FILE_ERROR); + EXPECT_TRUE (cmesh == NULL); +#endif +} From bb248bdc1e452d5ba640a45c33c3ba5321f21f05 Mon Sep 17 00:00:00 2001 From: Knapp Date: Tue, 7 Mar 2023 16:54:51 +0100 Subject: [PATCH 033/255] Implementation of a translator from vtk_file to vtkDataSet Extends the t8_cmesh_vtk_reader --- config/t8_vtk.m4 | 9 +- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 84 ++++++++++++++++++- .../t8_cmesh_vtk_polydata.cxx | 39 +++++++-- .../t8_cmesh_vtk_polydata.hxx | 7 +- .../t8_cmesh_vtk_unstructured.cxx | 12 +-- .../t8_cmesh_vtk_unstructured.hxx | 9 +- test/t8_IO/t8_gtest_vtk_reader.cxx | 3 +- 7 files changed, 135 insertions(+), 28 deletions(-) diff --git a/config/t8_vtk.m4 b/config/t8_vtk.m4 index c830e9528d..cdf6491cca 100644 --- a/config/t8_vtk.m4 +++ b/config/t8_vtk.m4 @@ -30,10 +30,11 @@ T8_ARG_WITH([vtk], AC_DEFINE_UNQUOTED([VTK_VERSION_USED], "$t8_vtk_version", [VTK version t8code is linked against]) ]) - T8_VTK_LIBS="-lvtkIOXML-$t8_vtk_version -lvtkCommonExecutionModel-$t8_vtk_version \ --lvtkCommonDataModel-$t8_vtk_version -lvtkIOXMLParser-$t8_vtk_version \ --lvtkIOParallelXML-$t8_vtk_version -lvtkParallelMPI-$t8_vtk_version \ --lvtkCommonCore-$t8_vtk_version -lvtkzlib-$t8_vtk_version -lvtksys-$t8_vtk_version" + T8_VTK_LIBS="-lvtkIOXML-$t8_vtk_version -lvtkCommonExecutionModel-$t8_vtk_version \ + -lvtkCommonDataModel-$t8_vtk_version -lvtkIOGeometry-$t8_vtk_version -lvtkIOXMLParser-$t8_vtk_version \ + -lvtkIOParallelXML-$t8_vtk_version -lvtkIOPLY-$t8_vtk_version -lvtkParallelMPI-$t8_vtk_version \ + -lvtkFiltersCore-$t8_vtk_version -lvtksys-$t8_vtk_version -lvtkCommonDataModel-$t8_vtk_version \ + -lvtkCommonCore-$t8_vtk_version -lvtkzlib-$t8_vtk_version -lvtkIOLegacy-$t8_vtk_version" if test "x$T8_WITH_VTK" != xyes ; then T8_VTK_LIBS="$T8_WITH_VTK" dnl AC_MSG_ERROR([Please provide --with-vtk without arguments]) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index 7120d9ff96..0f9cc57c44 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -26,16 +26,98 @@ along with t8code; if not, write to the Free Software Foundation, Inc., */ #include +#include "t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx" +#include "t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx" + +#if T8_WITH_VTK +#include +#endif T8_EXTERN_C_BEGIN (); +#if T8_WITH_VTK +int +t8_file_to_vtkGrid (const char *filename, + vtkDataSet * vtkGrid, + const int partition, const int main_proc, + sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type) +{ + int main_proc_read_successful = 0; + int mpirank; + int mpiret; + mpiret = sc_MPI_Comm_rank (comm, &mpirank); + SC_CHECK_MPI (mpiret); + if (!partition || mpirank == main_proc) { + switch (vtk_file_type) { + case VTK_UNSTRUCTURED_FILE: + t8_read_unstructured (filename, vtkGrid); + break; + case VTK_POLYDATA_FILE: + t8_read_poly (filename, vtkGrid); + default: + vtkGrid = NULL; + t8_errorf ("Filetype not supported.\n"); + break; + } + if (vtkGrid == NULL) { + t8_errorf ("Could not read file\n"); + if (partition) { + main_proc_read_successful = 0; + sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, + comm); + } + } + main_proc_read_successful = 1; + } + if (partition) { + sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, comm); + } + return main_proc_read_successful; +} +#endif + t8_cmesh_t t8_cmesh_vtk_reader (const char *filename, const int partition, const int main_proc, sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type) { #if T8_WITH_VTK - SC_ABORT ("This function is not yet implemented.\n"); + t8_cmesh_t cmesh; + int mpisize; + int mpirank; + int mpiret; + /* Get the size of the communicator and the rank of the process. */ + mpiret = sc_MPI_Comm_size (comm, &mpisize); + SC_CHECK_MPI (mpiret); + mpiret = sc_MPI_Comm_rank (comm, &mpirank); + SC_CHECK_MPI (mpiret); + + /* Ensure that the main-proc is a valid proc. */ + T8_ASSERT (0 <= main_proc && main_proc < mpisize); + T8_ASSERT (filename != NULL); + int main_proc_read_successful = 0; + + vtkDataSet *vtkGrid = NULL; + T8_ASSERT (partition == 0 || (main_proc >= 0 && main_proc < mpisize)); + /* Read the file and set the pointer. */ + main_proc_read_successful = + t8_file_to_vtkGrid (filename, vtkGrid, partition, main_proc, comm, + vtk_file_type); + if (!main_proc_read_successful) { + t8_global_errorf + ("Main process (Rank %i) did not read the file successfully.\n", + main_proc); + t8_cmesh_destroy (&cmesh); + return NULL; + } + else { + /*TODO: translate the vtkGrid into a cmesh and partition it. */ + SC_ABORT + ("The translation from a vtkGrid to a cmesh is not implemented yet.\n"); + return NULL; + } + T8_ASSERT (cmesh != NULL); + return cmesh; #else /* Return NULL if not linked against vtk */ t8_global_errorf diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index 4e0c649485..8bd33e30ef 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -20,8 +20,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "t8_cmesh_vtk_polydata.hxx" #if T8_WITH_VTK -#include #include #include #include @@ -29,9 +29,11 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include +#include +#include -void -t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) +static void +t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) { char tmp[BUFSIZ], *extension; /* Get the file-extension to decide which reader to use. */ @@ -70,7 +72,7 @@ t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) reader->SetFileName (filename); if (!reader->CanReadFile (filename)) { t8_errorf ("Unable to read file.\n"); - return NULL; + return; } reader->Update (); grid->ShallowCopy (reader->GetOutput ()); @@ -97,7 +99,7 @@ t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) if (!reader->IsFilePolyData ()) { t8_errorf ("File-content is not polydata. If it is a vtkUnstructuredGrid use the unstructured Grid reader."); - return NULL; + return; } grid->ShallowCopy (reader->GetOutput ()); return; @@ -113,8 +115,33 @@ t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) /* Return NULL if the reader is not used correctly. */ t8_global_errorf ("Please use .ply, .vtp, .obj, .stl, .vtk or .g file\n"); - return NULL; + return; } } } + +void +t8_read_poly (const char *filename, vtkDataSet * grid) +{ + vtkSmartPointer < vtkPolyData > poly_data = + vtkSmartPointer < vtkPolyData >::New (); + vtkSmartPointer < vtkPolyData > triangulated; + vtkNew < vtkTriangleFilter > tri_filter; + + /* Prepare the poly-data for the translation from vtk to t8code. + * We split all polygons (which are not supported by t8code) to + * triangles, vertices and lines. */ + t8_read_poly_ext (filename, poly_data); + if (poly_data == NULL) { + t8_errorf ("Could not read file.\n"); + return; + } + tri_filter->SetInputData (poly_data); + /* PolyVertex to vertex */ + tri_filter->PassVertsOn (); + /* PolyLines to lines */ + tri_filter->PassLinesOn (); + tri_filter->Update (); + grid->ShallowCopy (vtkDataSet::SafeDownCast (tri_filter->GetOutput ())); +} #endif diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx index ad13a46219..d7ff6a339a 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx @@ -28,10 +28,10 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #ifndef T8_CMESH_VTK_POLYDATA #define T8_CMESH_VTK_POLYDATA +#include #if T8_WITH_VTK -#include -#include #include +#include /** * Given a filename to a file containing Polydata, read @@ -42,8 +42,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * \a filename. * */ -void t8_read_poly (const char *filename, - vtkSmartPointer < vtkPolyData > grid); +void t8_read_poly (const char *filename, vtkDataSet * grid); #endif diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx index 83eca39dca..f2e0ea7c99 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx @@ -20,15 +20,16 @@ along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "t8_cmesh_vtk_unstructured.hxx" + #if T8_WITH_VTK #include #include #include -#include +#include void -t8_read_unstructured_ext (const char *filename, - vtkSmartPointer < vtkUnstructuredGrid > grid) +t8_read_unstructured (const char *filename, vtkDataSet * grid) { char tmp[BUFSIZ], *extension; /* Get the file-extension to decide which reader to use */ @@ -46,7 +47,7 @@ t8_read_unstructured_ext (const char *filename, } reader->SetFileName (filename); reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); + grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); t8_debugf ("Finished reading of file.\n"); return; } @@ -58,7 +59,7 @@ t8_read_unstructured_ext (const char *filename, if (!reader->IsFileUnstructuredGrid ()) { t8_errorf ("File-content is not an unstructured Grid. "); } - grid->ShallowCopy (reader->GetOutput ()); + grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); t8_debugf ("Finished reading of file.\n"); return; @@ -69,5 +70,4 @@ t8_read_unstructured_ext (const char *filename, return; } } - #endif diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx index 42fa801405..a665790f61 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx @@ -28,8 +28,9 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * from a file using the vtk-library. */ +#include #if T8_WITH_VTK -#include +#include /** * Given a filename to a file containing an vtkUnstructured Grid, read @@ -39,9 +40,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * \param[in, out] grid On input a vtkSmartPointer, that will hold the grid described in * \a filename. */ -void t8_read_unstructured_ext (const char *filename, - vtkSmartPointer < - vtkUnstructuredGrid > grid); - +void t8_read_unstructured (const char *filename, + vtkDataSet * grid); #endif #endif /* T8_CMESH_VTK_UNSTRUCTURED_READER */ diff --git a/test/t8_IO/t8_gtest_vtk_reader.cxx b/test/t8_IO/t8_gtest_vtk_reader.cxx index 1acf5579d8..8aec5ee609 100644 --- a/test/t8_IO/t8_gtest_vtk_reader.cxx +++ b/test/t8_IO/t8_gtest_vtk_reader.cxx @@ -32,10 +32,9 @@ along with t8code; if not, write to the Free Software Foundation, Inc., TEST (t8_cmesh_vtk_reader, dummy_test) { #if T8_WITH_VTK - /* Currently the function crashes if compiled with vtk. */ #else t8_cmesh_t cmesh = - t8_cmesh_vtk_reader (NULL, 0, 0, sc_MPI_COMM_NULL, VTK_FILE_ERROR); + t8_cmesh_vtk_reader (NULL, 0, 0, sc_MPI_COMM_WORLD, VTK_FILE_ERROR); EXPECT_TRUE (cmesh == NULL); #endif } From 9e5b10874f3c9f5b63ba0b100c4f59b58eaae1d6 Mon Sep 17 00:00:00 2001 From: Knapp Date: Tue, 7 Mar 2023 17:06:47 +0100 Subject: [PATCH 034/255] More Comments and Clean-Up --- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 20 ++++ .../t8_cmesh_vtk_polydata.cxx | 108 ++++++++---------- 2 files changed, 65 insertions(+), 63 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index 0f9cc57c44..b3156603c8 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -36,6 +36,19 @@ along with t8code; if not, write to the Free Software Foundation, Inc., T8_EXTERN_C_BEGIN (); #if T8_WITH_VTK +/** + * Read a vtk-file and ShallowCopy its content into a vtkDataSet. + * The success (or failure) of the reading process is communicated + * over all processes. + * + * \param[in] filename The name of the file to read + * \param[in, out] vtkGrid A pointer to a vtkDataSet. We ShallowCopy the grid there. + * \param[in] partition Flag if the input is read partitioned + * \param[in] main_proc The main reading proc. + * \param[in] comm A communicator. + * \param[in] vtk_file_type The type of the Data in the file. + * \return 0 if the file was read successfully, 1 otherwise. + */ int t8_file_to_vtkGrid (const char *filename, vtkDataSet * vtkGrid, @@ -44,9 +57,16 @@ t8_file_to_vtkGrid (const char *filename, { int main_proc_read_successful = 0; int mpirank; + int mpisize; int mpiret; mpiret = sc_MPI_Comm_rank (comm, &mpirank); SC_CHECK_MPI (mpiret); + mpiret = sc_MPI_Comm_size (comm, &mpisize); + SC_CHECK_MPI (mpiret); + T8_ASSERT (filename != NULL); + T8_ASSERT (0 <= main_proc && main_proc < mpisize); + + /* Read the file and set the pointer to the */ if (!partition || mpirank == main_proc) { switch (vtk_file_type) { case VTK_UNSTRUCTURED_FILE: diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index 8bd33e30ef..012ee7913e 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -42,7 +42,8 @@ t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) extension = strtok (NULL, "."); T8_ASSERT (strcmp (extension, "")); - /* Read the file depending on the extension */ + /* Read the file depending on the extension. Not all readers have + * a built-in check if the file is readable. */ if (strcmp (extension, "ply") == 0) { vtkNew < vtkPLYReader > reader; reader->SetFileName (filename); @@ -51,72 +52,53 @@ t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) return; } else if (strcmp (extension, "vtp") == 0) { - char tmp[BUFSIZ], *extension; - /* Get the file-extension to decide which reader to use. */ - strcpy (tmp, filename); - extension = strtok (tmp, "."); - extension = strtok (NULL, "."); - T8_ASSERT (strcmp (extension, "")); - - /* Read the file depending on the extension. Not all readers have - * a built-in check if the file is readable. */ - if (strcmp (extension, "ply") == 0) { - vtkNew < vtkPLYReader > reader; - reader->SetFileName (filename); - reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); - return; - } - else if (strcmp (extension, "vtp") == 0) { - vtkNew < vtkXMLPolyDataReader > reader; - reader->SetFileName (filename); - if (!reader->CanReadFile (filename)) { - t8_errorf ("Unable to read file.\n"); - return; - } - reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); - return; - } - else if (strcmp (extension, "obj") == 0) { - vtkNew < vtkOBJReader > reader; - reader->SetFileName (filename); - reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); - return; - } - else if (strcmp (extension, "stl") == 0) { - vtkNew < vtkSTLReader > reader; - reader->SetFileName (filename); - reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); - return; - } - else if (strcmp (extension, "vtk") == 0) { - vtkNew < vtkPolyDataReader > reader; - reader->SetFileName (filename); - reader->Update (); - if (!reader->IsFilePolyData ()) { - t8_errorf - ("File-content is not polydata. If it is a vtkUnstructuredGrid use the unstructured Grid reader."); - return; - } - grid->ShallowCopy (reader->GetOutput ()); - return; - } - else if (strcmp (extension, "g") == 0) { - vtkNew < vtkBYUReader > reader; - reader->SetGeometryFileName (filename); - reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); + vtkNew < vtkXMLPolyDataReader > reader; + reader->SetFileName (filename); + if (!reader->CanReadFile (filename)) { + t8_errorf ("Unable to read file.\n"); return; } - else { - /* Return NULL if the reader is not used correctly. */ - t8_global_errorf - ("Please use .ply, .vtp, .obj, .stl, .vtk or .g file\n"); + reader->Update (); + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else if (strcmp (extension, "obj") == 0) { + vtkNew < vtkOBJReader > reader; + reader->SetFileName (filename); + reader->Update (); + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else if (strcmp (extension, "stl") == 0) { + vtkNew < vtkSTLReader > reader; + reader->SetFileName (filename); + reader->Update (); + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else if (strcmp (extension, "vtk") == 0) { + vtkNew < vtkPolyDataReader > reader; + reader->SetFileName (filename); + reader->Update (); + if (!reader->IsFilePolyData ()) { + t8_errorf + ("File-content is not polydata. If it is a vtkUnstructuredGrid use the unstructured Grid reader."); return; } + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else if (strcmp (extension, "g") == 0) { + vtkNew < vtkBYUReader > reader; + reader->SetGeometryFileName (filename); + reader->Update (); + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else { + /* Return NULL if the reader is not used correctly. */ + t8_global_errorf ("Please use .ply, .vtp, .obj, .stl, .vtk or .g file\n"); + return; } } From 50943fb5040ad936d499d2f927fadf756f672795 Mon Sep 17 00:00:00 2001 From: Knapp Date: Wed, 8 Mar 2023 13:23:52 +0100 Subject: [PATCH 035/255] Add connection between vtk-elements and t8code-elements --- src/t8_cmesh_vtk_reader.hxx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/t8_cmesh_vtk_reader.hxx b/src/t8_cmesh_vtk_reader.hxx index f02b2abd9c..36e4c55c26 100644 --- a/src/t8_cmesh_vtk_reader.hxx +++ b/src/t8_cmesh_vtk_reader.hxx @@ -46,6 +46,36 @@ typedef enum vtk_file_type VTK_POLYDATA_FILE = 1 } vtk_file_type_t; +/** + * Translator between vtk-type of elements and t8code-elements. + * Not all elements are supported. Return T8_ECLASS_INVALID for unsupported + * elements. + */ +extern const t8_eclass_t t8_cmesh_vtk_type_to_t8_type[82] = { + T8_ECLASS_INVALID, T8_ECLASS_VERTEX, T8_ECLASS_INVALID, T8_ECLASS_LINE, + T8_ECLASS_INVALID, T8_ECLASS_TRIANGLE, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_QUAD, T8_ECLASS_QUAD, T8_ECLASS_TET, + T8_ECLASS_HEX, T8_ECLASS_HEX, T8_ECLASS_PRISM, T8_ECLASS_PYRAMID, + T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID +}; + /** * Construct a cmesh given a filename refering to a vtk-file either containing an * unstructured grid, or vtk-polydata, most likely constructed by vtk. From d03ae0df4bebfba12ecbf4eccca1bda994e10ca8 Mon Sep 17 00:00:00 2001 From: Knapp Date: Wed, 8 Mar 2023 17:00:23 +0100 Subject: [PATCH 036/255] Implemented a translator from vtkDataSet to cmesh for unstructuredGrid and Polydata Added an Example, a good googletest is still missing --- config/t8_vtk.m4 | 2 +- example/IO/Makefile.am | 1 + src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 363 +++++++++++++++++- .../t8_cmesh_vtk_polydata.cxx | 14 +- .../t8_cmesh_vtk_unstructured.cxx | 6 +- .../t8_cmesh_vtk_unstructured.hxx | 3 +- src/t8_cmesh_vtk_reader.hxx | 71 ++-- 7 files changed, 397 insertions(+), 63 deletions(-) diff --git a/config/t8_vtk.m4 b/config/t8_vtk.m4 index cdf6491cca..d3ef812005 100644 --- a/config/t8_vtk.m4 +++ b/config/t8_vtk.m4 @@ -33,7 +33,7 @@ T8_ARG_WITH([vtk], T8_VTK_LIBS="-lvtkIOXML-$t8_vtk_version -lvtkCommonExecutionModel-$t8_vtk_version \ -lvtkCommonDataModel-$t8_vtk_version -lvtkIOGeometry-$t8_vtk_version -lvtkIOXMLParser-$t8_vtk_version \ -lvtkIOParallelXML-$t8_vtk_version -lvtkIOPLY-$t8_vtk_version -lvtkParallelMPI-$t8_vtk_version \ - -lvtkFiltersCore-$t8_vtk_version -lvtksys-$t8_vtk_version -lvtkCommonDataModel-$t8_vtk_version \ + -lvtkFiltersCore-$t8_vtk_version -lvtksys-$t8_vtk_version \ -lvtkCommonCore-$t8_vtk_version -lvtkzlib-$t8_vtk_version -lvtkIOLegacy-$t8_vtk_version" if test "x$T8_WITH_VTK" != xyes ; then T8_VTK_LIBS="$T8_WITH_VTK" diff --git a/example/IO/Makefile.am b/example/IO/Makefile.am index 7bc136b797..4dfb2d03f7 100644 --- a/example/IO/Makefile.am +++ b/example/IO/Makefile.am @@ -12,5 +12,6 @@ include example/IO/cmesh/gmsh/Makefile.am include example/IO/cmesh/tetgen/Makefile.am include example/IO/cmesh/triangle/Makefile.am include example/IO/cmesh/netcdf/Makefile.am +include example/IO/cmesh/vtk/Makefile.am include example/IO/forest/netcdf/Makefile.am diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index b3156603c8..db720ba0f4 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -25,33 +25,127 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * The functions can only be used when t8code is linked with the vtk-library. */ +#include /* To set tree vertices */ + #include #include "t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx" #include "t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx" +#include #if T8_WITH_VTK -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif T8_EXTERN_C_BEGIN (); -#if T8_WITH_VTK /** - * Read a vtk-file and ShallowCopy its content into a vtkDataSet. - * The success (or failure) of the reading process is communicated - * over all processes. + * Translator between vtk-type of elements and t8code-elements. + * Not all elements are supported. Return T8_ECLASS_INVALID for unsupported + * elements. + */ +const t8_eclass_t t8_cmesh_vtk_type_to_t8_type[82] = { + T8_ECLASS_INVALID, T8_ECLASS_VERTEX, T8_ECLASS_INVALID, T8_ECLASS_LINE, + T8_ECLASS_INVALID, T8_ECLASS_TRIANGLE, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_QUAD, T8_ECLASS_QUAD, T8_ECLASS_TET, + T8_ECLASS_HEX, T8_ECLASS_HEX, T8_ECLASS_PRISM, T8_ECLASS_PYRAMID, + T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID +}; + +/** + * If the vertices of a tree describe a negative \param, + * permute the tree vertices. * - * \param[in] filename The name of the file to read - * \param[in, out] vtkGrid A pointer to a vtkDataSet. We ShallowCopy the grid there. - * \param[in] partition Flag if the input is read partitioned - * \param[in] main_proc The main reading proc. - * \param[in] comm A communicator. - * \param[in] vtk_file_type The type of the Data in the file. - * \return 0 if the file was read successfully, 1 otherwise. + * \param[in, out] tree_vertices The vertices of a tree + * \param[in] eclass The eclass of the tree. */ +void +t8_cmesh_correct_volume (double *tree_vertices, t8_eclass_t eclass) +{ + /* The \param described is negative. We need to change vertices. + * For tets we switch 0 and 3. + * For prisms we switch 0 and 3, 1 and 4, 2 and 5. + * For hexahedra we switch 0 and 4, 1 and 5, 2 and 6, 3 and 7. + * For pyramids we switch 0 and 4 */ + double temp; + int num_switches = 0; + int switch_indices[4] = { 0 }; + int iswitch; + T8_ASSERT (t8_eclass_to_dimension[eclass] == 3); + t8_debugf ("Correcting negative volume.\n"); + switch (eclass) { + case T8_ECLASS_TET: + /* We switch vertex 0 and vertex 3 */ + num_switches = 1; + switch_indices[0] = 3; + break; + case T8_ECLASS_PRISM: + num_switches = 3; + switch_indices[0] = 3; + switch_indices[1] = 4; + switch_indices[2] = 5; + break; + case T8_ECLASS_HEX: + num_switches = 4; + switch_indices[0] = 4; + switch_indices[1] = 5; + switch_indices[2] = 6; + switch_indices[3] = 7; + break; + case T8_ECLASS_PYRAMID: + num_switches = 1; + switch_indices[0] = 4; + break; + default: + SC_ABORT_NOT_REACHED (); + } + + for (iswitch = 0; iswitch < num_switches; ++iswitch) { + /* We switch vertex 0 + iswitch and vertex switch_indices[iswitch] */ + for (int i = 0; i < 3; i++) { + temp = tree_vertices[3 * iswitch + i]; + tree_vertices[3 * iswitch + i] = + tree_vertices[3 * switch_indices[iswitch] + i]; + tree_vertices[3 * switch_indices[iswitch] + i] = temp; + } + } + T8_ASSERT (!t8_cmesh_tree_vertices_negative_volume + (eclass, tree_vertices, t8_eclass_num_vertices[eclass])); +} + +#if T8_WITH_VTK + int t8_file_to_vtkGrid (const char *filename, - vtkDataSet * vtkGrid, + vtkSmartPointer < vtkDataSet > vtkGrid, const int partition, const int main_proc, sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type) { @@ -65,8 +159,7 @@ t8_file_to_vtkGrid (const char *filename, SC_CHECK_MPI (mpiret); T8_ASSERT (filename != NULL); T8_ASSERT (0 <= main_proc && main_proc < mpisize); - - /* Read the file and set the pointer to the */ + /* Read the file and set the pointer to the vtkGrid */ if (!partition || mpirank == main_proc) { switch (vtk_file_type) { case VTK_UNSTRUCTURED_FILE: @@ -74,15 +167,16 @@ t8_file_to_vtkGrid (const char *filename, break; case VTK_POLYDATA_FILE: t8_read_poly (filename, vtkGrid); + break; default: vtkGrid = NULL; t8_errorf ("Filetype not supported.\n"); break; } if (vtkGrid == NULL) { - t8_errorf ("Could not read file\n"); if (partition) { main_proc_read_successful = 0; + /* Communicate the failure of the reading process. */ sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, comm); } @@ -94,6 +188,224 @@ t8_file_to_vtkGrid (const char *filename, } return main_proc_read_successful; } + +/** + * Get the dimension of a vtkDataSet + * + * \param[in] vtkGrid The vtkDataSet + * \return The dimension of \a vtkGrid. + */ +int +t8_get_dimension (vtkSmartPointer < vtkDataSet > vtkGrid) +{ + /* This array contains the type of each cell */ + vtkSmartPointer < vtkCellTypes > cell_type_of_each_cell = + vtkSmartPointer < vtkCellTypes >::New (); + vtkGrid->GetCellTypes (cell_type_of_each_cell); + vtkSmartPointer < vtkUnsignedCharArray > cell_types = + cell_type_of_each_cell->GetCellTypesArray (); + int max_cell_type = -1; + const vtkIdType num_types = cell_types->GetNumberOfTuples (); + /* Iterate over all types and compare the dimension. They are stored + * in ascending order. */ + for (vtkIdType cell_types_it = 0; cell_types_it < num_types; + cell_types_it++) { + const vtkIdType type = cell_types->GetValue (cell_types_it); + if (type > max_cell_type) { + max_cell_type = type; + } + } + T8_ASSERT (0 <= max_cell_type && max_cell_type < 82); + const int ieclass = t8_cmesh_vtk_type_to_t8_type[max_cell_type]; + T8_ASSERT (ieclass != T8_ECLASS_INVALID); + + return t8_eclass_to_dimension[ieclass]; +} + +/** + * Iterate over all cells of a vtkDataset and construct a cmesh representing + * The vtkGrid. Each cell in the vtkDataSet becomes a tree in the cmesh. This + * function construct a cmesh on a single process. + * + * \param[in] vtkGrid The vtkGrid that gets tranlated + * \param[in, out] cmesh An empty cmesh that is filled with the data. + * \param[in] comm A communicator. + * \return The number of elements that have been read by the process. + */ + +t8_gloidx_t +t8_vtk_iterate_cells (vtkSmartPointer < vtkDataSet > vtkGrid, + t8_cmesh_t cmesh, sc_MPI_Comm comm) +{ + + double *vertices; + double **tuples; + size_t *data_size; + t8_gloidx_t tree_id = 0; + int max_dim = -1; + + vtkCellIterator *cell_it; + vtkSmartPointer < vtkPoints > points; + vtkSmartPointer < vtkCellData > cell_data = vtkGrid->GetCellData (); + const int max_cell_points = vtkGrid->GetMaxCellSize (); + + T8_ASSERT (max_cell_points >= 0); + vertices = T8_ALLOC (double, 3 * max_cell_points); + /* Get cell iterator */ + cell_it = vtkGrid->NewCellIterator (); + /* get the number of data-arrays per cell */ + const int num_data_arrays = cell_data->GetNumberOfArrays (); + T8_ASSERT (num_data_arrays >= 0); + + t8_debugf ("[D] read %i data-arrays\n", num_data_arrays); + /* Prepare attributes */ + if (num_data_arrays > 0) { + size_t tuple_size; + tuples = T8_ALLOC (double *, num_data_arrays); + data_size = T8_ALLOC (size_t, num_data_arrays); + for (int idata = 0; idata < num_data_arrays; idata++) { + vtkDataArray *data = cell_data->GetArray (idata); + tuple_size = data->GetNumberOfComponents (); + data_size[idata] = sizeof (double) * tuple_size; + t8_debugf ("[D] data_size[%i] = %li, tuple_size %li\n", idata, + data_size[idata], tuple_size); + /* Allocate memory for a tuple in array i */ + tuples[idata] = T8_ALLOC (double, tuple_size); + } + } + + /* Iterate over all cells */ + for (cell_it->InitTraversal (); !cell_it->IsDoneWithTraversal (); + cell_it->GoToNextCell ()) { + + /* Set the t8_eclass of the cell */ + const t8_eclass_t cell_type = + t8_cmesh_vtk_type_to_t8_type[cell_it->GetCellType ()]; + SC_CHECK_ABORTF (t8_eclass_is_valid (cell_type), + "vtk-cell-type %i not supported by t8code\n", cell_type); + t8_cmesh_set_tree_class (cmesh, tree_id, cell_type); + /* Get the points of the cell */ + const int num_points = cell_it->GetNumberOfPoints (); + T8_ASSERT (num_points > 0); + points = cell_it->GetPoints (); + + for (int ipoint = 0; ipoint < num_points; ipoint++) { + points->GetPoint (t8_element_shape_vtk_corner_number + (cell_type, ipoint), &vertices[3 * ipoint]); + + } + /* The order of the vertices in vtk might give a tree with negative \param */ + if (t8_cmesh_tree_vertices_negative_volume + (cell_type, vertices, num_points)) { + t8_cmesh_correct_volume (vertices, cell_type); + } + t8_cmesh_set_tree_vertices (cmesh, tree_id, vertices, num_points); + + /* TODO: Avoid magic numbers in the attribute setting. */ + /* Get and set the data of each cell */ + for (int dtype = 0; dtype < num_data_arrays; dtype++) { + const t8_gloidx_t cell_id = cell_it->GetCellId (); + vtkDataArray *data = cell_data->GetArray (dtype); + data->GetTuple (cell_id, tuples[dtype]); + t8_cmesh_set_attribute (cmesh, tree_id, t8_get_package_id (), dtype + 1, + tuples[dtype], data_size[dtype], 0); + } + /* Check geometry-dimension */ + if (max_dim < cell_it->GetCellDimension ()) { + max_dim = cell_it->GetCellDimension (); + } + tree_id++; + } + t8_debugf ("[D] read %li trees\n", tree_id); + + /* Clean-up */ + cell_it->Delete (); + if (num_data_arrays > 0) { + T8_FREE (data_size); + for (int idata = num_data_arrays - 1; idata >= 0; idata--) { + T8_FREE (tuples[idata]); + } + T8_FREE (tuples); + } + T8_FREE (vertices); + return tree_id; +} + +/** + * Given a pointer to a vtkDataSet a cmesh representing the vtkDataSet is + * constructed and can be shared over the processes. + * + * \param[in] vtkGrid A pointer to a vtkDataSet + * \param[in] partition Flag if the cmesh should be partitioned + * \param[in] main_proc The main reading process + * \param[in] comm The communicator. + * \return t8_cmesh_t + */ +t8_cmesh_t +t8_vtkGrid_to_cmesh (vtkSmartPointer < vtkDataSet > vtkGrid, + const int partition, const int main_proc, + sc_MPI_Comm comm) +{ + t8_cmesh_t cmesh; + int mpisize; + int mpirank; + int mpiret; + /* Get the size of the communicator and the rank of the process. */ + mpiret = sc_MPI_Comm_size (comm, &mpisize); + SC_CHECK_MPI (mpiret); + mpiret = sc_MPI_Comm_rank (comm, &mpirank); + SC_CHECK_MPI (mpiret); + + /* Ensure that the main-proc is a valid proc. */ + T8_ASSERT (0 <= main_proc && main_proc < mpisize); + + /* Already declared here, because we might use them during communication */ + t8_gloidx_t num_trees; + int dim; + + t8_cmesh_init (&cmesh); + if (!partition || mpirank == main_proc) { + num_trees = t8_vtk_iterate_cells (vtkGrid, cmesh, comm); + dim = t8_get_dimension (vtkGrid); + t8_cmesh_set_dimension (cmesh, dim); + t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); + t8_cmesh_register_geometry (cmesh, linear_geom); + } + if (partition) { + t8_gloidx_t first_tree; + t8_gloidx_t last_tree; + if (mpirank == main_proc) { + first_tree = 0; + last_tree = num_trees - 1; + } + /* Communicate the dimension to all processes */ + sc_MPI_Bcast (&dim, 1, sc_MPI_INT, main_proc, comm); + t8_debugf ("[D] dim: %i\n", dim); + /* Communicate the number of trees to all processes. + * TODO: This probably crashes when a vtkGrid is distributed in many + * files. */ + sc_MPI_Bcast (&num_trees, 1, T8_MPI_GLOIDX, main_proc, comm); + t8_cmesh_set_dimension (cmesh, dim); + /* Build the partition. */ + if (mpirank < main_proc) { + first_tree = 0; + last_tree = -1; + t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); + t8_cmesh_register_geometry (cmesh, linear_geom); + } + else if (mpirank > main_proc) { + first_tree = num_trees; + last_tree = num_trees - 1; + t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); + t8_cmesh_register_geometry (cmesh, linear_geom); + } + t8_cmesh_set_partition_range (cmesh, 3, first_tree, last_tree); + } + if (cmesh != NULL) { + t8_cmesh_commit (cmesh, comm); + } + return cmesh; +} #endif t8_cmesh_t @@ -117,12 +429,24 @@ t8_cmesh_vtk_reader (const char *filename, const int partition, T8_ASSERT (filename != NULL); int main_proc_read_successful = 0; - vtkDataSet *vtkGrid = NULL; + vtkSmartPointer < vtkDataSet > vtkGrid; + switch (vtk_file_type) { + case VTK_UNSTRUCTURED_FILE: + vtkGrid = vtkSmartPointer < vtkUnstructuredGrid >::New (); + break; + case VTK_POLYDATA_FILE: + vtkGrid = vtkSmartPointer < vtkPolyData >::New (); + break; + default: + t8_errorf ("Filetype is not supported.\n"); + break; + } T8_ASSERT (partition == 0 || (main_proc >= 0 && main_proc < mpisize)); /* Read the file and set the pointer. */ main_proc_read_successful = t8_file_to_vtkGrid (filename, vtkGrid, partition, main_proc, comm, vtk_file_type); + if (!main_proc_read_successful) { t8_global_errorf ("Main process (Rank %i) did not read the file successfully.\n", @@ -131,10 +455,7 @@ t8_cmesh_vtk_reader (const char *filename, const int partition, return NULL; } else { - /*TODO: translate the vtkGrid into a cmesh and partition it. */ - SC_ABORT - ("The translation from a vtkGrid to a cmesh is not implemented yet.\n"); - return NULL; + cmesh = t8_vtkGrid_to_cmesh (vtkGrid, partition, main_proc, comm); } T8_ASSERT (cmesh != NULL); return cmesh; diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index 012ee7913e..53cbf396d6 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -48,7 +48,7 @@ t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) vtkNew < vtkPLYReader > reader; reader->SetFileName (filename); reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); + grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); return; } else if (strcmp (extension, "vtp") == 0) { @@ -59,21 +59,21 @@ t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) return; } reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); + grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); return; } else if (strcmp (extension, "obj") == 0) { vtkNew < vtkOBJReader > reader; reader->SetFileName (filename); reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); + grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); return; } else if (strcmp (extension, "stl") == 0) { vtkNew < vtkSTLReader > reader; reader->SetFileName (filename); reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); + grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); return; } else if (strcmp (extension, "vtk") == 0) { @@ -85,14 +85,14 @@ t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) ("File-content is not polydata. If it is a vtkUnstructuredGrid use the unstructured Grid reader."); return; } - grid->ShallowCopy (reader->GetOutput ()); + grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); return; } else if (strcmp (extension, "g") == 0) { vtkNew < vtkBYUReader > reader; reader->SetGeometryFileName (filename); reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); + grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); return; } else { @@ -124,6 +124,6 @@ t8_read_poly (const char *filename, vtkDataSet * grid) /* PolyLines to lines */ tri_filter->PassLinesOn (); tri_filter->Update (); - grid->ShallowCopy (vtkDataSet::SafeDownCast (tri_filter->GetOutput ())); + grid->DeepCopy (vtkDataSet::SafeDownCast (tri_filter->GetOutput ())); } #endif diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx index f2e0ea7c99..8674751dfb 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx @@ -29,7 +29,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include void -t8_read_unstructured (const char *filename, vtkDataSet * grid) +t8_read_unstructured (const char *filename, + vtkSmartPointer < vtkDataSet > grid) { char tmp[BUFSIZ], *extension; /* Get the file-extension to decide which reader to use */ @@ -48,7 +49,6 @@ t8_read_unstructured (const char *filename, vtkDataSet * grid) reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - t8_debugf ("Finished reading of file.\n"); return; } else if (strcmp (extension, "vtk") == 0) { @@ -60,8 +60,6 @@ t8_read_unstructured (const char *filename, vtkDataSet * grid) t8_errorf ("File-content is not an unstructured Grid. "); } grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - t8_debugf ("Finished reading of file.\n"); - return; } else { diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx index a665790f61..35c5c09d27 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx @@ -41,6 +41,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * \a filename. */ void t8_read_unstructured (const char *filename, - vtkDataSet * grid); + vtkSmartPointer < vtkDataSet > + grid); #endif #endif /* T8_CMESH_VTK_UNSTRUCTURED_READER */ diff --git a/src/t8_cmesh_vtk_reader.hxx b/src/t8_cmesh_vtk_reader.hxx index 36e4c55c26..e41d7195ea 100644 --- a/src/t8_cmesh_vtk_reader.hxx +++ b/src/t8_cmesh_vtk_reader.hxx @@ -46,39 +46,52 @@ typedef enum vtk_file_type VTK_POLYDATA_FILE = 1 } vtk_file_type_t; +#if T8_WITH_VTK /** - * Translator between vtk-type of elements and t8code-elements. - * Not all elements are supported. Return T8_ECLASS_INVALID for unsupported - * elements. + * Read a vtk-file and ShallowCopy its content into a vtkDataSet. + * The success (or failure) of the reading process is communicated + * over all processes. + * + * \param[in] filename The name of the file to read + * \param[in, out] vtkGrid A pointer to a vtkDataSet. We ShallowCopy the grid there. + * \param[in] partition Flag if the input is read partitioned + * \param[in] main_proc The main reading proc. + * \param[in] comm A communicator. + * \param[in] vtk_file_type The type of the Data in the file. + * \return 0 if the file was read successfully, 1 otherwise. */ -extern const t8_eclass_t t8_cmesh_vtk_type_to_t8_type[82] = { - T8_ECLASS_INVALID, T8_ECLASS_VERTEX, T8_ECLASS_INVALID, T8_ECLASS_LINE, - T8_ECLASS_INVALID, T8_ECLASS_TRIANGLE, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_QUAD, T8_ECLASS_QUAD, T8_ECLASS_TET, - T8_ECLASS_HEX, T8_ECLASS_HEX, T8_ECLASS_PRISM, T8_ECLASS_PYRAMID, - T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID -}; +int t8_file_to_vtkGrid (const char *filename, + vtkSmartPointer < vtkDataSet > + vtkGrid, const int partition, + const int main_proc, sc_MPI_Comm comm, + const vtk_file_type_t vtk_file_type); /** - * Construct a cmesh given a filename refering to a vtk-file either containing an - * unstructured grid, or vtk-polydata, most likely constructed by vtk. + * Given a pointer to a vtkDataSet a cmesh representing the vtkDataSet is + * constructed and can be shared over the processes. + * + * \param[in] vtkGrid A pointer to a vtkDataSet + * \param[in] partition Flag if the cmesh should be partitioned + * \param[in] main_proc The main reading process + * \param[in] comm The communicator. + * \return t8_cmesh_t + */ +t8_cmesh_t t8_vtkGrid_to_cmesh (vtkSmartPointer < vtkDataSet > + vtkGrid, const int partition, + const int main_proc, + sc_MPI_Comm comm); + +#endif + +/** + * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and + * construct a cmesh. This is a two stage process. First the file is read and + * stored in a vtkDataSet using \a t8_file_to_vtkGrid. + * In the second stage a cmesh is constructed from the vtkDataSet using \a t8_vtkGrid_to_cmesh. + * + * Both stages use the vtk-library, therefore the function is only available if + * t8code is linked against VTK. + * * * \param[in] filename The name of the file * \param[in] partition Flag if the constructed mesh should be partitioned From 01423138d11bea8f046ecdf8a5fdbcfc7592f541 Mon Sep 17 00:00:00 2001 From: Knapp Date: Thu, 9 Mar 2023 10:37:05 +0100 Subject: [PATCH 037/255] Updated error-handling --- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 17 ++++------- .../t8_cmesh_vtk_polydata.cxx | 30 ++++++++++--------- .../t8_cmesh_vtk_polydata.hxx | 2 +- .../t8_cmesh_vtk_unstructured.cxx | 11 +++---- .../t8_cmesh_vtk_unstructured.hxx | 2 +- 5 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index db720ba0f4..60faaaf16b 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -163,25 +163,21 @@ t8_file_to_vtkGrid (const char *filename, if (!partition || mpirank == main_proc) { switch (vtk_file_type) { case VTK_UNSTRUCTURED_FILE: - t8_read_unstructured (filename, vtkGrid); + main_proc_read_successful = t8_read_unstructured (filename, vtkGrid); break; case VTK_POLYDATA_FILE: - t8_read_poly (filename, vtkGrid); + main_proc_read_successful = t8_read_poly (filename, vtkGrid); break; default: vtkGrid = NULL; t8_errorf ("Filetype not supported.\n"); break; } - if (vtkGrid == NULL) { - if (partition) { - main_proc_read_successful = 0; - /* Communicate the failure of the reading process. */ - sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, - comm); - } + if (partition) { + /* Communicate the success/failure of the reading process. */ + sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, + comm); } - main_proc_read_successful = 1; } if (partition) { sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, comm); @@ -451,7 +447,6 @@ t8_cmesh_vtk_reader (const char *filename, const int partition, t8_global_errorf ("Main process (Rank %i) did not read the file successfully.\n", main_proc); - t8_cmesh_destroy (&cmesh); return NULL; } else { diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index 53cbf396d6..d266c8adde 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -32,7 +32,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include -static void +static int t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) { char tmp[BUFSIZ], *extension; @@ -49,32 +49,32 @@ t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return; + return 1; } else if (strcmp (extension, "vtp") == 0) { vtkNew < vtkXMLPolyDataReader > reader; reader->SetFileName (filename); if (!reader->CanReadFile (filename)) { t8_errorf ("Unable to read file.\n"); - return; + return 0; } reader->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return; + return 1; } else if (strcmp (extension, "obj") == 0) { vtkNew < vtkOBJReader > reader; reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return; + return 1; } else if (strcmp (extension, "stl") == 0) { vtkNew < vtkSTLReader > reader; reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return; + return 1; } else if (strcmp (extension, "vtk") == 0) { vtkNew < vtkPolyDataReader > reader; @@ -83,26 +83,26 @@ t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) if (!reader->IsFilePolyData ()) { t8_errorf ("File-content is not polydata. If it is a vtkUnstructuredGrid use the unstructured Grid reader."); - return; + return 0; } grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return; + return 1; } else if (strcmp (extension, "g") == 0) { vtkNew < vtkBYUReader > reader; reader->SetGeometryFileName (filename); reader->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return; + return 0; } else { /* Return NULL if the reader is not used correctly. */ t8_global_errorf ("Please use .ply, .vtp, .obj, .stl, .vtk or .g file\n"); - return; + return 1; } } -void +int t8_read_poly (const char *filename, vtkDataSet * grid) { vtkSmartPointer < vtkPolyData > poly_data = @@ -113,10 +113,11 @@ t8_read_poly (const char *filename, vtkDataSet * grid) /* Prepare the poly-data for the translation from vtk to t8code. * We split all polygons (which are not supported by t8code) to * triangles, vertices and lines. */ - t8_read_poly_ext (filename, poly_data); - if (poly_data == NULL) { + const int read_successfull = + t8_read_poly_ext (filename, poly_data); + if (!read_successfull) { t8_errorf ("Could not read file.\n"); - return; + return read_successfull; } tri_filter->SetInputData (poly_data); /* PolyVertex to vertex */ @@ -125,5 +126,6 @@ t8_read_poly (const char *filename, vtkDataSet * grid) tri_filter->PassLinesOn (); tri_filter->Update (); grid->DeepCopy (vtkDataSet::SafeDownCast (tri_filter->GetOutput ())); + return read_successfull; } #endif diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx index d7ff6a339a..3d969bd369 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx @@ -42,7 +42,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * \a filename. * */ -void t8_read_poly (const char *filename, vtkDataSet * grid); +int t8_read_poly (const char *filename, vtkDataSet * grid); #endif diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx index 8674751dfb..b85a3167c4 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx @@ -28,7 +28,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include -void +int t8_read_unstructured (const char *filename, vtkSmartPointer < vtkDataSet > grid) { @@ -44,12 +44,12 @@ t8_read_unstructured (const char *filename, vtkSmartPointer < vtkXMLUnstructuredGridReader >::New (); if (!reader->CanReadFile (filename)) { t8_errorf ("Unable to read file.\n"); - return; + return 0; } reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return; + return 1; } else if (strcmp (extension, "vtk") == 0) { vtkSmartPointer < vtkUnstructuredGridReader > reader = @@ -58,14 +58,15 @@ t8_read_unstructured (const char *filename, reader->Update (); if (!reader->IsFileUnstructuredGrid ()) { t8_errorf ("File-content is not an unstructured Grid. "); + return 0; } grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return; + return 1; } else { /* Return NULL if the reader is not used correctly */ t8_global_errorf ("Please use .vtk or .vtu file\n"); - return; + return 0; } } #endif diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx index 35c5c09d27..70f56e892a 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx @@ -40,7 +40,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * \param[in, out] grid On input a vtkSmartPointer, that will hold the grid described in * \a filename. */ -void t8_read_unstructured (const char *filename, +int t8_read_unstructured (const char *filename, vtkSmartPointer < vtkDataSet > grid); #endif From 3029e12e0b06af6d43a8fe05e1fb2f55ff34e1bf Mon Sep 17 00:00:00 2001 From: Knapp Date: Thu, 9 Mar 2023 11:04:21 +0100 Subject: [PATCH 038/255] Avoid magic numbers --- src/Makefile.am | 1 + src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 37 +--------- .../t8_cmesh_vtk_polydata.cxx | 25 ++++--- .../t8_cmesh_vtk_polydata.hxx | 3 +- .../t8_cmesh_vtk_unstructured.cxx | 14 ++-- .../t8_cmesh_vtk_unstructured.hxx | 3 +- .../t8_cmesh_vtk_to_t8/t8_vtk_types.h | 74 +++++++++++++++++++ src/t8_cmesh_vtk_reader.hxx | 12 +-- 8 files changed, 105 insertions(+), 64 deletions(-) create mode 100644 src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_vtk_types.h diff --git a/src/Makefile.am b/src/Makefile.am index b6739bcf23..cd484d7275 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -76,6 +76,7 @@ libt8_internal_headers = \ src/t8_cmesh/t8_cmesh_offset.h \ src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx \ src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx \ + src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_vtk_types.h \ src/t8_forest/t8_forest_cxx.h \ src/t8_forest/t8_forest_ghost.h \ src/t8_forest/t8_forest_balance.h src/t8_forest/t8_forest_types.h \ diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index 60faaaf16b..ff064bf521 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -31,6 +31,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include "t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx" #include "t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx" #include +#include "t8_cmesh_vtk_to_t8/t8_vtk_types.h" #if T8_WITH_VTK #include @@ -50,36 +51,6 @@ along with t8code; if not, write to the Free Software Foundation, Inc., T8_EXTERN_C_BEGIN (); -/** - * Translator between vtk-type of elements and t8code-elements. - * Not all elements are supported. Return T8_ECLASS_INVALID for unsupported - * elements. - */ -const t8_eclass_t t8_cmesh_vtk_type_to_t8_type[82] = { - T8_ECLASS_INVALID, T8_ECLASS_VERTEX, T8_ECLASS_INVALID, T8_ECLASS_LINE, - T8_ECLASS_INVALID, T8_ECLASS_TRIANGLE, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_QUAD, T8_ECLASS_QUAD, T8_ECLASS_TET, - T8_ECLASS_HEX, T8_ECLASS_HEX, T8_ECLASS_PRISM, T8_ECLASS_PYRAMID, - T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, - T8_ECLASS_INVALID, T8_ECLASS_INVALID -}; - /** * If the vertices of a tree describe a negative \param, * permute the tree vertices. @@ -143,13 +114,13 @@ t8_cmesh_correct_volume (double *tree_vertices, t8_eclass_t eclass) #if T8_WITH_VTK -int +vtk_read_success_t t8_file_to_vtkGrid (const char *filename, vtkSmartPointer < vtkDataSet > vtkGrid, const int partition, const int main_proc, sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type) { - int main_proc_read_successful = 0; + vtk_read_success_t main_proc_read_successful = read_failure; int mpirank; int mpisize; int mpiret; @@ -423,7 +394,7 @@ t8_cmesh_vtk_reader (const char *filename, const int partition, /* Ensure that the main-proc is a valid proc. */ T8_ASSERT (0 <= main_proc && main_proc < mpisize); T8_ASSERT (filename != NULL); - int main_proc_read_successful = 0; + vtk_read_success_t main_proc_read_successful = read_failure; vtkSmartPointer < vtkDataSet > vtkGrid; switch (vtk_file_type) { diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index d266c8adde..3feb60079d 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -21,6 +21,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., */ #include "t8_cmesh_vtk_polydata.hxx" +#include "t8_vtk_types.h" #if T8_WITH_VTK #include #include @@ -32,7 +33,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include -static int +static vtk_read_success_t t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) { char tmp[BUFSIZ], *extension; @@ -49,32 +50,32 @@ t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return 1; + return read_success; } else if (strcmp (extension, "vtp") == 0) { vtkNew < vtkXMLPolyDataReader > reader; reader->SetFileName (filename); if (!reader->CanReadFile (filename)) { t8_errorf ("Unable to read file.\n"); - return 0; + return read_failure; } reader->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return 1; + return read_success; } else if (strcmp (extension, "obj") == 0) { vtkNew < vtkOBJReader > reader; reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return 1; + return read_success; } else if (strcmp (extension, "stl") == 0) { vtkNew < vtkSTLReader > reader; reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return 1; + return read_success; } else if (strcmp (extension, "vtk") == 0) { vtkNew < vtkPolyDataReader > reader; @@ -83,26 +84,26 @@ t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) if (!reader->IsFilePolyData ()) { t8_errorf ("File-content is not polydata. If it is a vtkUnstructuredGrid use the unstructured Grid reader."); - return 0; + return read_failure; } grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return 1; + return read_success; } else if (strcmp (extension, "g") == 0) { vtkNew < vtkBYUReader > reader; reader->SetGeometryFileName (filename); reader->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return 0; + return read_failure; } else { /* Return NULL if the reader is not used correctly. */ t8_global_errorf ("Please use .ply, .vtp, .obj, .stl, .vtk or .g file\n"); - return 1; + return read_success; } } -int +vtk_read_success_t t8_read_poly (const char *filename, vtkDataSet * grid) { vtkSmartPointer < vtkPolyData > poly_data = @@ -113,7 +114,7 @@ t8_read_poly (const char *filename, vtkDataSet * grid) /* Prepare the poly-data for the translation from vtk to t8code. * We split all polygons (which are not supported by t8code) to * triangles, vertices and lines. */ - const int read_successfull = + const vtk_read_success_t read_successfull = t8_read_poly_ext (filename, poly_data); if (!read_successfull) { t8_errorf ("Could not read file.\n"); diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx index 3d969bd369..bd3812ef59 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx @@ -29,6 +29,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #define T8_CMESH_VTK_POLYDATA #include +#include "t8_vtk_types.h" #if T8_WITH_VTK #include #include @@ -42,7 +43,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * \a filename. * */ -int t8_read_poly (const char *filename, vtkDataSet * grid); +vtk_read_success_t t8_read_poly (const char *filename, vtkDataSet * grid); #endif diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx index b85a3167c4..562c34a54c 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx @@ -28,7 +28,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include -int +vtk_read_success_t t8_read_unstructured (const char *filename, vtkSmartPointer < vtkDataSet > grid) { @@ -44,12 +44,12 @@ t8_read_unstructured (const char *filename, vtkSmartPointer < vtkXMLUnstructuredGridReader >::New (); if (!reader->CanReadFile (filename)) { t8_errorf ("Unable to read file.\n"); - return 0; + return read_failure; } reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return 1; + return read_success; } else if (strcmp (extension, "vtk") == 0) { vtkSmartPointer < vtkUnstructuredGridReader > reader = @@ -58,15 +58,15 @@ t8_read_unstructured (const char *filename, reader->Update (); if (!reader->IsFileUnstructuredGrid ()) { t8_errorf ("File-content is not an unstructured Grid. "); - return 0; + return read_failure; } grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); - return 1; + return read_success; } else { - /* Return NULL if the reader is not used correctly */ + /* Return failure if the reader is not used correctly */ t8_global_errorf ("Please use .vtk or .vtu file\n"); - return 0; + return read_failure; } } #endif diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx index 70f56e892a..a3d4e3ef82 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx @@ -29,6 +29,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., */ #include +#include "t8_vtk_types.h" #if T8_WITH_VTK #include @@ -40,7 +41,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * \param[in, out] grid On input a vtkSmartPointer, that will hold the grid described in * \a filename. */ -int t8_read_unstructured (const char *filename, +vtk_read_success_t t8_read_unstructured (const char *filename, vtkSmartPointer < vtkDataSet > grid); #endif diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_vtk_types.h b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_vtk_types.h new file mode 100644 index 0000000000..4870d68b11 --- /dev/null +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_vtk_types.h @@ -0,0 +1,74 @@ +/* +This file is part of t8code. +t8code is a C library to manage a collection (a forest) of multiple +connected adaptive space-trees of general element classes in parallel. + +Copyright (C) 2015 the developers + +t8code is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +t8code is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with t8code; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef T8_VTK_TYPES +#define T8_VTK_TYPES + +#include + +/** + * Translator between vtk-type of elements and t8code-elements. + * Not all elements are supported. Return T8_ECLASS_INVALID for unsupported + * elements. + */ +const t8_eclass_t t8_cmesh_vtk_type_to_t8_type[82] = { + T8_ECLASS_INVALID, T8_ECLASS_VERTEX, T8_ECLASS_INVALID, T8_ECLASS_LINE, + T8_ECLASS_INVALID, T8_ECLASS_TRIANGLE, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_QUAD, T8_ECLASS_QUAD, T8_ECLASS_TET, + T8_ECLASS_HEX, T8_ECLASS_HEX, T8_ECLASS_PRISM, T8_ECLASS_PYRAMID, + T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, T8_ECLASS_INVALID, + T8_ECLASS_INVALID, T8_ECLASS_INVALID +}; + +/** + * Enumerator for all types of files readable by t8code. + */ +typedef enum vtk_file_type +{ + VTK_FILE_ERROR = -1, /*For Testing purpose. */ + VTK_UNSTRUCTURED_FILE = 0, + VTK_POLYDATA_FILE = 1 +} vtk_file_type_t; + +typedef enum vtk_read_success +{ + read_failure = 0, + read_success = 1 +} vtk_read_success_t; + +#endif /* T8_VTK_TYPES */ diff --git a/src/t8_cmesh_vtk_reader.hxx b/src/t8_cmesh_vtk_reader.hxx index e41d7195ea..7996f63be5 100644 --- a/src/t8_cmesh_vtk_reader.hxx +++ b/src/t8_cmesh_vtk_reader.hxx @@ -28,6 +28,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #define T8_CMESH_VTK_READER #include +#include "t8_cmesh/t8_cmesh_vtk_to_t8/t8_vtk_types.h" #if T8_WITH_VTK #include @@ -36,15 +37,6 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #endif T8_EXTERN_C_BEGIN (); -/** - * Enumerator for all types of files readable by t8code. - */ -typedef enum vtk_file_type -{ - VTK_FILE_ERROR = -1, /*For Testing purpose. */ - VTK_UNSTRUCTURED_FILE = 0, - VTK_POLYDATA_FILE = 1 -} vtk_file_type_t; #if T8_WITH_VTK /** @@ -60,7 +52,7 @@ typedef enum vtk_file_type * \param[in] vtk_file_type The type of the Data in the file. * \return 0 if the file was read successfully, 1 otherwise. */ -int t8_file_to_vtkGrid (const char *filename, +vtk_read_success_t t8_file_to_vtkGrid (const char *filename, vtkSmartPointer < vtkDataSet > vtkGrid, const int partition, const int main_proc, sc_MPI_Comm comm, From fb6c539e45f06122665c7737396cf8b0ad474126 Mon Sep 17 00:00:00 2001 From: Knapp Date: Mon, 13 Mar 2023 16:27:04 +0100 Subject: [PATCH 039/255] Add example-files --- example/IO/cmesh/vtk/Makefile.am | 8 + .../IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx | 183 ++++++++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 example/IO/cmesh/vtk/Makefile.am create mode 100644 example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx diff --git a/example/IO/cmesh/vtk/Makefile.am b/example/IO/cmesh/vtk/Makefile.am new file mode 100644 index 0000000000..a7d48369cb --- /dev/null +++ b/example/IO/cmesh/vtk/Makefile.am @@ -0,0 +1,8 @@ +# This file is part of t8code +# Non-recursive Makefile.am in example/IO +# Included from toplevel directory + +bin_PROGRAMS += \ + example/IO/cmesh/vtk/t8_cmesh_read_from_vtk + +example_IO_cmesh_vtk_t8_cmesh_read_from_vtk_SOURCES = example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx \ No newline at end of file diff --git a/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx b/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx new file mode 100644 index 0000000000..2b2bf6e004 --- /dev/null +++ b/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx @@ -0,0 +1,183 @@ +/* +This file is part of t8code. +t8code is a C library to manage a collection (a forest) of multiple +connected adaptive space-trees of general element classes in parallel. +Copyright (C) 2015 the developers +t8code is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. +t8code is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +You should have received a copy of the GNU General Public License +along with t8code; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * Construct a cmesh read from a VTK-file type supported by our vtk-reader. + * Given the number of cell-values in the file we read the data again from the forest + * and write it into the file forest.(p)vtu . + * + * \param[in] prefix The prefix of the file to read the mesh from + * \param[in] comm The communicator used in this example + * \param[in] values_per_cell The number of values per cell in the mesh. + */ +void +t8_forest_construct_from_vtk (const char *prefix, sc_MPI_Comm comm, + const int values_per_cell, const int partition, + vtk_file_type_t vtk_file_type) +{ + /* Read a poly-data file (.ply, .vtp, .obj, .stl, .vtk, .g) and construct a cmesh + * representing the mesh. If there is any cell-data, it will be read too. + * Triangle-strips and polygons will be broken down to multiple triangles. */ + t8_cmesh_t cmesh_in = + t8_cmesh_vtk_reader (prefix, partition, 0, comm, vtk_file_type); + if (cmesh_in == NULL) { + t8_errorf ("Error reading file.\n"); + return; + } + t8_cmesh_t cmesh; + t8_cmesh_vtk_write_file (cmesh_in, "t8_cmesh_in", 1.0); + if (partition) { + t8_cmesh_init (&cmesh); + t8_cmesh_set_derive (cmesh, cmesh_in); + t8_cmesh_set_partition_uniform (cmesh, 0, t8_scheme_new_default_cxx ()); + t8_cmesh_commit (cmesh, comm); + } + else { + cmesh = cmesh_in; + } + + t8_cmesh_vtk_write_file (cmesh, "t8_cmesh_", 1.0); + + t8_forest_t forest; + /* Initialize the forest */ + t8_forest_init (&forest); + /* Initialize the cmesh of the forest */ + t8_forest_set_cmesh (forest, cmesh, sc_MPI_COMM_WORLD); + /* Set the scheme of the forest. In this case, the default schemes are used */ + t8_forest_set_scheme (forest, t8_scheme_new_default_cxx ()); + t8_forest_commit (forest); + + t8_vtk_data_field_t *vtk_data; + double **cell_values; + double *tree_data; + /* Read the cell-data if there is any */ + if (values_per_cell > 0) { + const t8_locidx_t num_trees = t8_cmesh_get_num_local_trees (cmesh); + T8_ASSERT (num_trees == t8_forest_get_num_local_trees (forest)); + vtk_data = T8_ALLOC (t8_vtk_data_field_t, values_per_cell); + cell_values = T8_ALLOC (double *, values_per_cell); + for (int ivalues = 0; ivalues < values_per_cell; ivalues++) { + cell_values[ivalues] = T8_ALLOC (double, num_trees); + vtk_data[ivalues].data = cell_values[ivalues]; + /*TODO: Arbitrary type of data */ + vtk_data[ivalues].type = T8_VTK_SCALAR; + snprintf (vtk_data[ivalues].description, BUFSIZ, "cell_data_%i", + ivalues); + } + + for (t8_locidx_t itree = 0; itree < num_trees; itree++) { + for (int ivalues = 1; ivalues <= values_per_cell; ivalues++) { + tree_data = + (double *) t8_cmesh_get_attribute (cmesh, t8_get_package_id (), + ivalues, itree); + cell_values[ivalues - 1][itree] = tree_data[0]; + } + } + } + else { + vtk_data = NULL; + } + + /* Write the forest */ + t8_forest_write_vtk_ext (forest, "forest", 1, 1, 1, 1, 1, 0, 1, + values_per_cell, vtk_data); + + /* Free the cell-data */ + if (values_per_cell > 0) { + for (int ivalues = values_per_cell - 1; ivalues >= 0; ivalues--) { + T8_FREE (cell_values[ivalues]); + } + T8_FREE (cell_values); + T8_FREE (vtk_data); + } + t8_forest_unref (&forest); +} + +int +main (int argc, char **argv) +{ + int mpiret, helpme = 0, parsed, num_keys; + const char *vtk_file; + sc_options_t *opt; + char usage[BUFSIZ], help[BUFSIZ]; + int sreturn; + int partition; + int vtk_file_type; + + snprintf (usage, BUFSIZ, "Usage:\t%s \n\t%s -h\t" + "for a brief overview of all options.", + basename (argv[0]), basename (argv[0])); + sreturn = snprintf (help, BUFSIZ, + "This program reads a .vtk-file and constructs a mesh representing the given Data." + "Arguments can be passed via:\n%s\n\n", usage); + if (sreturn >= BUFSIZ) { + /* The help message was truncated */ + /* Note: gcc >= 7.1 prints a warning if we + * do not check the return value of snprintf. */ + t8_debugf ("Warning: Truncated help message to '%s'\n", help); + } + mpiret = sc_MPI_Init (&argc, &argv); + SC_CHECK_MPI (mpiret); + + sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_ESSENTIAL); + t8_init (SC_LP_DEFAULT); + + opt = sc_options_new (argv[0]); + sc_options_add_switch (opt, 'h', "help", &helpme, + "Display a short help message."); + sc_options_add_string (opt, 'f', "vtk-file", &vtk_file, "", + "The prefix of the .vtk file."); + sc_options_add_int (opt, 'c', "num_cell_values", &num_keys, 0, + "Number of values per cell stored in the vtk-file."); + sc_options_add_int (opt, 't', "type_of_file", &vtk_file_type, -1, + " Set the type of the data in the file.\n" + "0 for vtkUnstructuredGrid \n" "1 for vtkPolyData"); + sc_options_add_bool (opt, 'p', "partition", &partition, 0, + "If set, partition the cmesh uniformly.\n"); + parsed = + sc_options_parse (t8_get_package_id (), SC_LP_ERROR, opt, argc, argv); + + if (helpme) { + sc_options_print_usage (t8_get_package_id (), SC_LP_ERROR, opt, NULL); + } + else if (parsed < 0 || (strcmp (vtk_file, "") == 0) || num_keys < 0) { + fprintf (stderr, "%s", help); + return 1; + } + else { + t8_forest_construct_from_vtk (vtk_file, sc_MPI_COMM_WORLD, num_keys, + partition, (vtk_file_type_t) vtk_file_type); + } + sc_options_destroy (opt); + sc_finalize (); + + mpiret = sc_MPI_Finalize (); + SC_CHECK_MPI (mpiret); + + return 0; +} From 59595c0db424a1a34d2a5409d07270c94f29e84b Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Fri, 31 Mar 2023 08:47:03 +0200 Subject: [PATCH 040/255] Added files for splitted header --- src/t8_forest_general.h | 27 +++++++++++++++++++++++++++ src/t8_forest_geometrical.h | 27 +++++++++++++++++++++++++++ src/t8_forest_profiling.h | 27 +++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 src/t8_forest_general.h create mode 100644 src/t8_forest_geometrical.h create mode 100644 src/t8_forest_profiling.h diff --git a/src/t8_forest_general.h b/src/t8_forest_general.h new file mode 100644 index 0000000000..14b8b2e2a0 --- /dev/null +++ b/src/t8_forest_general.h @@ -0,0 +1,27 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** \file t8_forest_general.h + * We define the forest of trees in this file. + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ \ No newline at end of file diff --git a/src/t8_forest_geometrical.h b/src/t8_forest_geometrical.h new file mode 100644 index 0000000000..078e6476de --- /dev/null +++ b/src/t8_forest_geometrical.h @@ -0,0 +1,27 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** \file t8_forest_geometrical.h + * We define the geometrical queries for a forest of trees in this file. + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ \ No newline at end of file diff --git a/src/t8_forest_profiling.h b/src/t8_forest_profiling.h new file mode 100644 index 0000000000..e804ce9ed4 --- /dev/null +++ b/src/t8_forest_profiling.h @@ -0,0 +1,27 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** \file t8_forest_profiling.h + * We define the forest of trees in this file. + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ \ No newline at end of file From b2c50763a3e1527cb3e02ab15364a083b825f7bb Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Mon, 3 Apr 2023 10:40:19 +0200 Subject: [PATCH 041/255] implementation of element ref coords for quads --- src/t8_element_cxx.hxx | 14 ++++++++ src/t8_forest.h | 32 +++++++++++++++++++ src/t8_forest/t8_forest_cxx.cxx | 18 ++++++++++- .../t8_default_common_cxx.hxx | 14 ++++++++ .../t8_default_hex/t8_default_hex_cxx.cxx | 11 +++++++ .../t8_default_hex/t8_default_hex_cxx.hxx | 14 ++++++++ .../t8_default_line/t8_default_line_cxx.cxx | 11 +++++++ .../t8_default_line/t8_default_line_cxx.hxx | 14 ++++++++ .../t8_default_prism/t8_default_prism_cxx.cxx | 11 +++++++ .../t8_default_prism/t8_default_prism_cxx.hxx | 14 ++++++++ .../t8_default_pyramid_cxx.cxx | 13 ++++++++ .../t8_default_pyramid_cxx.hxx | 14 ++++++++ .../t8_default_quad/t8_default_quad_cxx.cxx | 18 +++++++++++ .../t8_default_quad/t8_default_quad_cxx.hxx | 14 ++++++++ .../t8_default_tet/t8_default_tet_cxx.cxx | 11 +++++++ .../t8_default_tet/t8_default_tet_cxx.hxx | 14 ++++++++ .../t8_default_tri/t8_default_tri_cxx.cxx | 11 +++++++ .../t8_default_tri/t8_default_tri_cxx.hxx | 14 ++++++++ .../t8_default_vertex_cxx.cxx | 13 ++++++++ .../t8_default_vertex_cxx.hxx | 14 ++++++++ 20 files changed, 288 insertions(+), 1 deletion(-) diff --git a/src/t8_element_cxx.hxx b/src/t8_element_cxx.hxx index d08916b044..cb3ca65b19 100644 --- a/src/t8_element_cxx.hxx +++ b/src/t8_element_cxx.hxx @@ -605,6 +605,20 @@ public: double coords[]) const = 0; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] coords_out The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *coords_out) + const = 0; + /* TODO: deactivate */ /** Return a pointer to a t8_element in an array indexed by a size_t. * \param [in] array The \ref sc_array storing \t t8_element_t pointers. diff --git a/src/t8_forest.h b/src/t8_forest.h index 1b55fa160c..bb3ca5c0c5 100644 --- a/src/t8_forest.h +++ b/src/t8_forest.h @@ -929,6 +929,38 @@ void t8_forest_element_coordinate (t8_forest_t forest, int corner_number, double *coordinates); +/** Compute the coordinates of a point inside an element inside a tree. + * The point is given in reference coordinates inside the element and gets + * converted to reference coordinates inside the tree. After that, the point + * is converted to global coordinates inside the domain. If needed, the element + * is stretched by the given stretch factors (the resulting mesh is then + * no longer non-overlapping). + * + * \param [in] forest The forest. + * \param [in] ltreeid The forest local id of the tree in which the element is. + * \param [in] element The element. + * \param [in] ref_coord The reference coordinates of the point inside the element. + * \param [out] coords_out On input an allocated array to store 3 doubles, on output + * the x, y and z coordinates of the point inside the domain. + * \param [in] stretch_factors An element-wise array with d (dimension) doubles per element, + * which are used to stretch the element beyond its original boundary. + * The array must be of length forest->local_num_elements * d. + * If NULL, no stretching is applied. + */ +void + + + + + + + + t8_forest_element_from_ref_coord (t8_forest_t forest, t8_locidx_t ltreeid, + const t8_element_t *element, + const double *ref_coord, + double *coords_out, + sc_array_t *stretch_factors); + /** Compute the coordinates of the centroid of an element if a geometry * for this tree is registered in the forest's cmesh. * The centroid is the sum of all corner vertices divided by the number of corners. diff --git a/src/t8_forest/t8_forest_cxx.cxx b/src/t8_forest/t8_forest_cxx.cxx index 1f19b0dcbb..cc03be84a5 100644 --- a/src/t8_forest/t8_forest_cxx.cxx +++ b/src/t8_forest/t8_forest_cxx.cxx @@ -218,10 +218,26 @@ t8_forest_element_coordinate (t8_forest_t forest, t8_locidx_t ltree_id, gtreeid = t8_forest_global_tree_id (forest, ltree_id); /* Get the cmesh */ cmesh = t8_forest_get_cmesh (forest); - /* Evalute the geometry */ + /* Evaluate the geometry */ t8_geometry_evaluate (cmesh, gtreeid, vertex_coords, coordinates); } +void +t8_forest_element_from_ref_coord (t8_forest_t forest, t8_locidx_t ltreeid, + const t8_element_t *element, + const double *ref_coord, double *coords_out, + sc_array_t *stretch_factors) +{ + //call element_ref_coord + if (stretch_factors != NULL) { + //get element_midpoint + //stretch ref_coords by factor stored in array + } + const t8_cmesh_t cmesh = t8_forest_get_cmesh (forest); + const t8_gloidx_t gtreeid = t8_forest_global_tree_id (forest, ltreeid); + t8_geometry_evaluate (cmesh, gtreeid, ref_coord, coords_out); +} + /* Compute the diameter of an element. */ double t8_forest_element_diam (t8_forest_t forest, t8_locidx_t ltreeid, diff --git a/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx b/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx index 786fcd58d6..424c32ff00 100644 --- a/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx @@ -109,6 +109,20 @@ public: int vertex, int coords[]) const = 0; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] coords_out The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const = 0; + /** Get the integer coordinates of the anchor node of an element. * The default scheme implements the Morton type SFCs. In these SFCs the * elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx index 12bda1fa4d..0cf425efbc 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx @@ -693,6 +693,17 @@ t8_default_scheme_hex_c::t8_element_vertex_reference_coords (const coords[2] = coords_int[2] / (double) P8EST_ROOT_LEN; } +void +t8_default_scheme_hex_c::t8_element_reference_coords (const t8_element_t *t, + const double + *ref_coords, + const void *user_data, + double *coords_out) + const +{ + SC_ABORTF ("Not implemented\n"); +} + int t8_default_scheme_hex_c::t8_element_refines_irregular () const { diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx index f209134bd8..b3c8675561 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx @@ -567,6 +567,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] coords_out The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because hexs refine regularly diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx index 840c7db864..38629f62a8 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx @@ -366,6 +366,17 @@ t8_default_scheme_line_c::t8_element_vertex_reference_coords (const t8_dline_vertex_ref_coords ((const t8_dline_t *) t, vertex, coords); } +void +t8_default_scheme_line_c::t8_element_reference_coords (const t8_element_t *t, + const double + *ref_coords, + const void *user_data, + double *coords_out) + const +{ + SC_ABORTF ("Not implemented\n"); +} + int t8_default_scheme_line_c::t8_element_root_len (const t8_element_t *elem) const { diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx index d0a605a70e..46f6e6e8ac 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx @@ -585,6 +585,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] coords_out The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because lines refine regularly diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx index bd19ad7df4..57ac8aece6 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx @@ -480,6 +480,17 @@ t8_default_scheme_prism_c::t8_element_vertex_reference_coords (const t8_dprism_vertex_ref_coords ((const t8_dprism_t *) elem, vertex, coords); } +void +t8_default_scheme_prism_c::t8_element_reference_coords (const t8_element_t *t, + const double + *ref_coords, + const void *user_data, + double *coords_out) + const +{ + SC_ABORTF ("Not implemented\n"); +} + void t8_default_scheme_prism_c::t8_element_general_function (const t8_element_t *elem, diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx index 92e138d06c..77fd94c82d 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx @@ -594,6 +594,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] coords_out The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because prisms refine regularly diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx index 6e5ab79731..d33625fbed 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx @@ -475,6 +475,19 @@ t8_default_scheme_pyramid_c::t8_element_vertex_reference_coords (const vertex, coords); } +void +t8_default_scheme_pyramid_c::t8_element_reference_coords (const t8_element_t + *t, + const double + *ref_coords, + const void + *user_data, + double *coords_out) + const +{ + SC_ABORTF ("Not implemented\n"); +} + int t8_default_scheme_pyramid_c::t8_element_refines_irregular () const { diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx index 7b42716d94..f5af5c2555 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx @@ -613,6 +613,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] coords_out The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 1, because pyramids refine irregularly diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx index c0652534c9..8486e905c4 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx @@ -793,6 +793,24 @@ t8_default_scheme_quad_c::t8_element_vertex_reference_coords (const coords[1] = coords_int[1] / (double) P4EST_ROOT_LEN; } +void +t8_default_scheme_quad_c::t8_element_reference_coords (const t8_element_t *t, + const double + *ref_coords, + const void *user_data, + double *coords_out) + const +{ + T8_ASSERT (t8_element_is_valid (t)); + const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) t; + const double x_lower = q1->x / (double) P4EST_ROOT_LEN; + const double y_lower = q1->y / (double) P4EST_ROOT_LEN; + const double len = P4EST_QUADRANT_LEN (q1->level); + + coords_out[0] = x_lower + ref_coords[0] * len; + coords_out[1] = y_lower + ref_coords[1] * len; +} + void t8_default_scheme_quad_c::t8_element_new (int length, t8_element_t **elem) const { diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx index a0e363bb54..a9f8fded0a 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx @@ -600,6 +600,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] coords_out The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because quads refine regularly diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx index b0ddfbf69e..40d5e26c51 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx @@ -554,6 +554,17 @@ t8_default_scheme_tet_c::t8_element_vertex_reference_coords (const t8_dtet_compute_ref_coords ((const t8_default_tet_t *) t, vertex, coords); } +void +t8_default_scheme_tet_c::t8_element_reference_coords (const t8_element_t *t, + const double + *ref_coords, + const void *user_data, + double *coords_out) + const +{ + SC_ABORTF ("Not implemented\n"); +} + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. */ diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx index 638288503f..457c6fe8f8 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx @@ -580,6 +580,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] coords_out The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because tets refine regularly diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx index ba1a3dff6c..e420fc9fbb 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx @@ -573,6 +573,17 @@ t8_default_scheme_tri_c::t8_element_vertex_reference_coords (const t8_dtri_compute_ref_coords ((const t8_dtri_t *) t, vertex, coords); } +void +t8_default_scheme_tri_c::t8_element_reference_coords (const t8_element_t *t, + const double + *ref_coords, + const void *user_data, + double *coords_out) + const +{ + SC_ABORTF ("Not implemented\n"); +} + int t8_default_scheme_tri_c::t8_element_refines_irregular () const { diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx index 186c990a73..582281064e 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx @@ -573,6 +573,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] coords_out The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because tris refine regularly diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx index 6a8aa14449..55e8a4c495 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx @@ -320,6 +320,19 @@ t8_default_scheme_vertex_c::t8_element_vertex_reference_coords (const t8_dvertex_vertex_ref_coords ((const t8_dvertex_t *) elem, vertex, coords); } +void +t8_default_scheme_vertex_c::t8_element_reference_coords (const t8_element_t + *t, + const double + *ref_coords, + const void + *user_data, + double *coords_out) + const +{ + SC_ABORTF ("Not implemented\n"); +} + #ifdef T8_ENABLE_DEBUG /* *INDENT-OFF* */ /* indent bug, indent adds a second "const" modifier */ diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx index d4e75ac344..721581a9c9 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx @@ -613,6 +613,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] coords_out The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because vertices refine regularly From 9d3898e73f7d3eec0bea9a99e28fb38c4417f836 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Mon, 3 Apr 2023 16:21:33 +0200 Subject: [PATCH 042/255] first usable implementation of element ref coords in quads --- src/t8_element_cxx.hxx | 6 +- src/t8_forest.h | 22 ++-- src/t8_forest/t8_forest_cxx.cxx | 18 ++- src/t8_forest/t8_forest_vtk.cxx | 115 ++++++++++++++---- .../t8_default_quad/t8_default_quad_cxx.cxx | 3 +- 5 files changed, 119 insertions(+), 45 deletions(-) diff --git a/src/t8_element_cxx.hxx b/src/t8_element_cxx.hxx index cb3ca65b19..e9cea3e04b 100644 --- a/src/t8_element_cxx.hxx +++ b/src/t8_element_cxx.hxx @@ -608,9 +608,9 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. - * \param [in] coords_input The coordinates of the point in the reference space of the element. - * \param [in] user_data User data. + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. * \param [out] coords_out The coordinates of the point in the reference space of the tree. */ virtual void t8_element_reference_coords (const t8_element_t *t, diff --git a/src/t8_forest.h b/src/t8_forest.h index bb3ca5c0c5..06557dbef2 100644 --- a/src/t8_forest.h +++ b/src/t8_forest.h @@ -947,19 +947,15 @@ void t8_forest_element_coordinate (t8_forest_t forest, * The array must be of length forest->local_num_elements * d. * If NULL, no stretching is applied. */ -void - - - - - - - - t8_forest_element_from_ref_coord (t8_forest_t forest, t8_locidx_t ltreeid, - const t8_element_t *element, - const double *ref_coord, - double *coords_out, - sc_array_t *stretch_factors); +void t8_forest_element_from_ref_coords (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t + *element, + const double + *ref_coord, + double *coords_out, + sc_array_t + *stretch_factors); /** Compute the coordinates of the centroid of an element if a geometry * for this tree is registered in the forest's cmesh. diff --git a/src/t8_forest/t8_forest_cxx.cxx b/src/t8_forest/t8_forest_cxx.cxx index cc03be84a5..8ae4841f09 100644 --- a/src/t8_forest/t8_forest_cxx.cxx +++ b/src/t8_forest/t8_forest_cxx.cxx @@ -223,19 +223,25 @@ t8_forest_element_coordinate (t8_forest_t forest, t8_locidx_t ltree_id, } void -t8_forest_element_from_ref_coord (t8_forest_t forest, t8_locidx_t ltreeid, - const t8_element_t *element, - const double *ref_coord, double *coords_out, - sc_array_t *stretch_factors) +t8_forest_element_from_ref_coords (t8_forest_t forest, t8_locidx_t ltreeid, + const t8_element_t *element, + const double *ref_coords, + double *coords_out, + sc_array_t *stretch_factors) { - //call element_ref_coord + double tree_ref_coords[3] = { 0 }; + const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); + const t8_eclass_scheme_c *scheme = + t8_forest_get_eclass_scheme (forest, tree_class); + scheme->t8_element_reference_coords (element, ref_coords, NULL, + tree_ref_coords); if (stretch_factors != NULL) { //get element_midpoint //stretch ref_coords by factor stored in array } const t8_cmesh_t cmesh = t8_forest_get_cmesh (forest); const t8_gloidx_t gtreeid = t8_forest_global_tree_id (forest, ltreeid); - t8_geometry_evaluate (cmesh, gtreeid, ref_coord, coords_out); + t8_geometry_evaluate (cmesh, gtreeid, tree_ref_coords, coords_out); } /* Compute the diameter of an element. */ diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index a76cd68712..df5d7b9c91 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -125,13 +125,81 @@ typedef int (*t8_forest_vtk_cell_data_kernel) (t8_forest_t forest, modus); #if T8_WITH_VTK -/* lookup table for number of nodes for curved eclasses. */ +#define T8_FOREST_VTK_QUADRATIC_ELEMENT_MAX_CORNERS 20 +/** Lookup table for number of nodes for curved eclasses. */ const int t8_curved_eclass_num_nodes[T8_ECLASS_COUNT] = { 1, 3, 8, 6, 20, 10, 15, 13 }; -/* lookup table for vtk types of curved elements */ +/** Lookup table for vtk types of curved elements */ const int t8_curved_eclass_vtk_type[T8_ECLASS_COUNT] = { 1, 21, 23, 22, 25, 24, 26, 27 }; + +/** Map element corners to element reference coordinates */ +const double t8_forest_vtk_point_to_element_ref_coords[T8_ECLASS_COUNT] + [T8_ECLASS_MAX_CORNERS][3] = { + {{0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}}, /* T8_ECLASS_VERTEX */ + {{0, 0, 0}, {1, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}}, /* T8_ECLASS_LINE */ + {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}}, /* T8_ECLASS_QUAD */ + {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}}, /* T8_ECLASS_TRIANGLE */ + {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}}, /* T8_ECLASS_TET */ + {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 1, 0}, {1, 0, 1}, {0, 1, 1}, {1, 1, 1}}, /* T8_ECLASS_HEX */ + {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 1, 0}, {1, 0, 1}, {-1, -1, -1}, {-1, -1, -1}}, /* T8_ECLASS_PRISM */ + {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 1, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}} /* T8_ECLASS_PYRAMID */ +}; + +const double + t8_forest_vtk_point_to_quadratic_element_ref_coords[T8_ECLASS_COUNT] + [T8_FOREST_VTK_QUADRATIC_ELEMENT_MAX_CORNERS][3] = { + { /* T8_ECLASS_VERTEX */ + {0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} + }, + { /* T8_ECLASS_LINE */ + {0, 0, 0}, {1, 0, 0}, {0.5, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} + }, + { /* T8_ECLASS_QUAD */ + {0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}, {0.5, 0, 0}, + {1, 0.5, 0}, {0.5, 1, 0}, {0, 0.5, 0}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} + }, + { /* T8_ECLASS_TRIANGLE */ + {0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} + }, + { /* T8_ECLASS_TET */ + {0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} + }, + { /* T8_ECLASS_HEX */ + {0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} + }, + { /* T8_ECLASS_PRISM */ + {0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} + }, + { /* T8_ECLASS_PYRAMID */ + {0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} + } +}; + #endif /* @@ -150,6 +218,24 @@ t8_get_number_of_vtk_nodes (t8_element_shape_t eclass, int curved_flag) } #endif +#if T8_WITH_VTK +static void +t8_forest_vtk_get_element_nodes (t8_forest_t forest, t8_locidx_t ltreeid, + const t8_element_t *element, + const int vertex, double *out_coords, + sc_array_t *stretch_factors) +{ + const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); + const t8_eclass_scheme_c *scheme = + t8_forest_get_eclass_scheme (forest, tree_class); + const t8_element_shape_t element_shape = scheme->t8_element_shape (element); + const double *ref_coords = + t8_forest_vtk_point_to_quadratic_element_ref_coords[element_shape] + [vertex]; + t8_forest_element_from_ref_coords (forest, ltreeid, element, ref_coords, + out_coords, stretch_factors); +} + /* If we want to write curved elements, we need to calculate * the reference coordinates. For the vertices(end points) * of the elements, we can use t8_element_vertex_reference_coords @@ -161,7 +247,7 @@ t8_get_number_of_vtk_nodes (t8_element_shape_t eclass, int curved_flag) * formulas. For more information look into the vtk documentation. * TODO: Add Pyramids when they are merged into the dev branch. * */ -#if T8_WITH_VTK +#if 0 static void t8_curved_element_get_reference_node_coords (const t8_element_t *elem, t8_element_shape_t eclass, @@ -333,6 +419,7 @@ t8_curved_element_get_reference_node_coords (const t8_element_t *elem, } } #endif +#endif int t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, @@ -354,12 +441,10 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, t8_locidx_t ielement; /* The iterator over elements in a tree. */ t8_locidx_t itree, ivertex; double coordinates[3]; - double vertex_coords[3] = { 0, 0, 0 }; int elem_id = 0; t8_locidx_t num_elements; int freturn = 0; t8_gloidx_t gtreeid; - t8_cmesh_t cmesh; int num_node; /* Since we want to use different element types and a points Array and cellArray @@ -421,7 +506,6 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, vtkDoubleArray **dataArrays; dataArrays = T8_ALLOC (vtkDoubleArray *, num_data); - cmesh = t8_forest_get_cmesh (forest); /* We iterate over all local trees*/ for (itree = 0; itree < t8_forest_get_num_local_trees (forest); itree++) { /* @@ -511,22 +595,9 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, /* For each element we iterate over all points */ for (ivertex = 0; ivertex < num_node; ivertex++, point_id++) { - /* Compute the vertex coordinates inside [0,1]^dim reference cube. */ - if (curved_flag) { - t8_curved_element_get_reference_node_coords (element, element_shape, - scheme, ivertex, - vertex_coords); - } - else { - scheme->t8_element_vertex_reference_coords (element, - t8_eclass_vtk_corner_number - [element_shape] - [ivertex], - vertex_coords); - } - - /* Evaluate the geometry */ - t8_geometry_evaluate (cmesh, gtreeid, vertex_coords, coordinates); + /* Compute the vertex coordinates inside the domain. */ + t8_forest_vtk_get_element_nodes (forest, itree, element, ivertex, + coordinates, NULL); /* Insert point in the points array */ points->InsertNextPoint (coordinates[0], coordinates[1], diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx index 8486e905c4..830f38a880 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx @@ -805,7 +805,8 @@ t8_default_scheme_quad_c::t8_element_reference_coords (const t8_element_t *t, const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) t; const double x_lower = q1->x / (double) P4EST_ROOT_LEN; const double y_lower = q1->y / (double) P4EST_ROOT_LEN; - const double len = P4EST_QUADRANT_LEN (q1->level); + const double len = + P4EST_QUADRANT_LEN (q1->level) / (double) P4EST_ROOT_LEN; coords_out[0] = x_lower + ref_coords[0] * len; coords_out[1] = y_lower + ref_coords[1] * len; From 094d7b3c7ab8a47e8a2ffca5a50e007cace9c1a1 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 4 Apr 2023 09:58:12 +0200 Subject: [PATCH 043/255] typo --- .../t8_default/t8_default_common/t8_default_common_cxx.hxx | 2 +- .../t8_default/t8_default_line/t8_default_line_cxx.cxx | 2 +- .../t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx | 2 +- .../t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx b/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx index 424c32ff00..9bf8d90fb4 100644 --- a/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx @@ -115,7 +115,7 @@ public: * \param [in] t The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. - * \param [out] coords_out The coordinates of the point in the reference space of the tree. + * \param [out] out_coords The coordinates of the point in the reference space of the tree. */ virtual void t8_element_reference_coords (const t8_element_t *t, const double *ref_coords, diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx index 38629f62a8..bc86be1ed8 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx @@ -371,7 +371,7 @@ t8_default_scheme_line_c::t8_element_reference_coords (const t8_element_t *t, const double *ref_coords, const void *user_data, - double *coords_out) + double *out_coords) const { SC_ABORTF ("Not implemented\n"); diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx index 55e8a4c495..3870934bc6 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx @@ -327,7 +327,7 @@ t8_default_scheme_vertex_c::t8_element_reference_coords (const t8_element_t *ref_coords, const void *user_data, - double *coords_out) + double *out_coords) const { SC_ABORTF ("Not implemented\n"); diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx index 721581a9c9..6e7362c07a 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx @@ -619,7 +619,7 @@ public: * \param [in] t The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. - * \param [out] coords_out The coordinates of the point in the reference space of the tree. + * \param [out] out_coords The coordinates of the point in the reference space of the tree. */ virtual void t8_element_reference_coords (const t8_element_t *t, const double *ref_coords, From ea71e158c43f5fd3f1a39a9113e60e46b4530fa6 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 4 Apr 2023 09:58:44 +0200 Subject: [PATCH 044/255] implemented elem ref coords for lines --- .../t8_default/t8_default_line/t8_default_line_cxx.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx index bc86be1ed8..cf55455175 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx @@ -374,7 +374,9 @@ t8_default_scheme_line_c::t8_element_reference_coords (const t8_element_t *t, double *out_coords) const { - SC_ABORTF ("Not implemented\n"); + out_coords[0] = ((const t8_dline_t *) t)->x; + out_coords[0] += + T8_DLINE_LEN (((const t8_dline_t *) t)->level) * ref_coords[0]; } int From b0e4c2e1a9869391ef95171fd3b50eb7fe00a253 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 4 Apr 2023 09:59:13 +0200 Subject: [PATCH 045/255] simplified code --- .../t8_default/t8_default_quad/t8_default_quad_cxx.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx index 830f38a880..d4f2781bbe 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx @@ -803,13 +803,13 @@ t8_default_scheme_quad_c::t8_element_reference_coords (const t8_element_t *t, { T8_ASSERT (t8_element_is_valid (t)); const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) t; - const double x_lower = q1->x / (double) P4EST_ROOT_LEN; - const double y_lower = q1->y / (double) P4EST_ROOT_LEN; + coords_out[0] = q1->x / (double) P4EST_ROOT_LEN; + coords_out[1] = q1->y / (double) P4EST_ROOT_LEN; const double len = P4EST_QUADRANT_LEN (q1->level) / (double) P4EST_ROOT_LEN; - coords_out[0] = x_lower + ref_coords[0] * len; - coords_out[1] = y_lower + ref_coords[1] * len; + coords_out[0] += ref_coords[0] * len; + coords_out[1] += ref_coords[1] * len; } void From 3540805b8b9cf7f1c72852243b1b1c74e0438f4d Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 4 Apr 2023 09:59:31 +0200 Subject: [PATCH 046/255] implemented elem ref coords for vertices --- .../t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx index 3870934bc6..9501fb7d08 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx @@ -330,7 +330,10 @@ t8_default_scheme_vertex_c::t8_element_reference_coords (const t8_element_t double *out_coords) const { - SC_ABORTF ("Not implemented\n"); + T8_ASSERT (t8_element_is_valid (t)); + T8_ASSERT (ref_coords != NULL); + T8_ASSERT (abs (ref_coords[0]) <= T8_PRECISION_EPS); + out_coords[0]; } #ifdef T8_ENABLE_DEBUG From 612696e02d77fb6dcfb3b1bd6ec213f0fa9e324b Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 4 Apr 2023 10:51:10 +0200 Subject: [PATCH 047/255] moved line ref coords to dline_bits --- .../t8_default_line/t8_default_line_cxx.cxx | 6 +++--- .../t8_default/t8_default_line/t8_dline_bits.c | 8 ++++++++ .../t8_default/t8_default_line/t8_dline_bits.h | 12 ++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx index cf55455175..6b38a6caad 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx @@ -374,9 +374,9 @@ t8_default_scheme_line_c::t8_element_reference_coords (const t8_element_t *t, double *out_coords) const { - out_coords[0] = ((const t8_dline_t *) t)->x; - out_coords[0] += - T8_DLINE_LEN (((const t8_dline_t *) t)->level) * ref_coords[0]; + T8_ASSERT (t8_element_is_valid (t)); + T8_ASSERT (ref_coords != NULL); + t8_dline_reference_coords ((const t8_dline_t *) t, ref_coords, out_coords); } int diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c index b9e8f55393..8c244322c8 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c +++ b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c @@ -349,6 +349,14 @@ t8_dline_vertex_ref_coords (const t8_dline_t *elem, const int vertex, coordinates[0] = coords_int / (double) T8_DLINE_ROOT_LEN; } +void +t8_dline_reference_coords (const t8_dline_t *t, const double *ref_coords, + double *out_coords) +{ + out_coords[0] = t->x; + out_coords[0] += T8_DLINE_LEN (t->level) * ref_coords[0]; +} + t8_linearidx_t t8_dline_linear_id (const t8_dline_t *elem, int level) { diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h index 5dea842eba..1e653c4e82 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h +++ b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h @@ -241,6 +241,18 @@ void t8_dline_vertex_ref_coords (const t8_dline_t *elem, const int vertex, double coordinates[1]); +/** Compute the coordinates of an arbitrary point ([0, 1]^1) on a line when the + * tree (level 0 line) is embedded in [0,1]^1. + * \param [in] t Input line. + * \param [in] ref_coords The referenc coordinate on the line [0, 1]^1 + * \param [out] out_coords An array of 1 double that + * will be filled with the reference coordinates + * of the point on the line. + */ +void t8_dline_reference_coords (const t8_dline_t *t, + const double *ref_coords, + double *out_coords); + /** Computes the linear position of a line in an uniform grid. * \param [in] line Line whose id will be computed. * \return Returns the linear position of this line on a grid. From f27fb229d84ef1cf869a750a3d1507b1552d4107 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 4 Apr 2023 10:51:31 +0200 Subject: [PATCH 048/255] moved vertex ref coords to dvertex_bits --- .../t8_default_vertex/t8_default_vertex_cxx.cxx | 5 ++--- .../t8_default/t8_default_vertex/t8_dvertex_bits.c | 8 ++++++++ .../t8_default/t8_default_vertex/t8_dvertex_bits.h | 9 +++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx index 9501fb7d08..606b16b520 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx @@ -331,9 +331,8 @@ t8_default_scheme_vertex_c::t8_element_reference_coords (const t8_element_t const { T8_ASSERT (t8_element_is_valid (t)); - T8_ASSERT (ref_coords != NULL); - T8_ASSERT (abs (ref_coords[0]) <= T8_PRECISION_EPS); - out_coords[0]; + t8_dvertex_reference_coords ((const t8_dvertex_t *) t, ref_coords, + out_coords); } #ifdef T8_ENABLE_DEBUG diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c index 847fa05d79..b9034d2317 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c @@ -173,6 +173,14 @@ t8_dvertex_vertex_ref_coords (const t8_dvertex_t *elem, const int vertex, coords[0] = 0; } +void +t8_dvertex_reference_coords (const t8_dvertex_t *elem, + const double *ref_coords, double *out_coords) +{ + T8_ASSERT (abs (ref_coords[0]) <= T8_PRECISION_EPS); + out_coords[0] = 0; +} + t8_linearidx_t t8_dvertex_linear_id (const t8_dvertex_t *elem, int level) { diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h index 96bb284495..3b0618d719 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h @@ -194,6 +194,15 @@ void t8_dvertex_vertex_ref_coords (const t8_dvertex_t *elem, int vertex, double coords[]); +/** Compute the coordinates of a refrence coordinate (always 0) inside the [0,1]^0 reference space. + * \param [in] elem Vertex whose vertex is computed. + * \param [in] ref_coords The reference coordinate inside the vertex (must be 0). + * \param [out] out_coords The coordinates of the computed vertex, must have one entry (will be set to 0). + */ +void t8_dvertex_reference_coords (const t8_dvertex_t *elem, + const double *ref_coords, + double *out_coords); + /** Computes the linear position of a vertex in an uniform grid. * \param [in] vertex vertex whose id will be computed. * \return Returns the linear position of this vertex on a grid. From 96b07248234e9183dd261498feb88912daf83e96 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 4 Apr 2023 11:05:39 +0200 Subject: [PATCH 049/255] add file documentation --- .../t8_default/t8_default_line/t8_default_line_cxx.hxx | 4 +++- src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h | 1 + .../t8_default/t8_default_prism/t8_default_prism_cxx.hxx | 4 +++- src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.h | 1 + .../t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx | 4 +++- .../t8_default/t8_default_pyramid/t8_dpyramid_bits.h | 4 ++++ .../t8_default/t8_default_tet/t8_default_tet_cxx.hxx | 4 +++- src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h | 2 +- .../t8_default/t8_default_tri/t8_default_tri_cxx.hxx | 4 +++- src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h | 1 + .../t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx | 4 +++- src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h | 1 + 12 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx index 46f6e6e8ac..3be2d057ee 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx @@ -21,7 +21,9 @@ */ /** \file t8_default_lines.h - * The default implementation for lines. + * The default implementation for lines. Interface between the + * \file t8_default_common_cxx.hxx definitions and the element type specific + * implementations in \file t8_dline_bits.h */ #ifndef T8_DEFAULT_LINE_CXX_HXX diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h index 1e653c4e82..26889434ee 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h +++ b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h @@ -21,6 +21,7 @@ */ /** \file t8_dline_bits.h + * Definition if line-specific functions. */ #ifndef T8_DLINE_BITS_H diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx index 77fd94c82d..4a9d88cbff 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx @@ -21,7 +21,9 @@ */ /** \file t8_default_prism_cxx.hxx - * The default implementation for prism. + * The default implementation for prisms. Interface between the + * \file t8_default_common_cxx.hxx definitions and the element type specific + * implementations in \file t8_dprism_bits.h */ #ifndef T8_DEFAULT_PRISM_CXX_HXX diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.h b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.h index d51ec49985..ac0d5bf206 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.h +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.h @@ -21,6 +21,7 @@ */ /** \file t8_dprism_bits.h + * Definition if prism-specific functions. */ #ifndef T8_DPRISM_BITS_H diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx index f5af5c2555..5bfa1b039f 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx @@ -21,7 +21,9 @@ */ /** \file t8_default_pyramid_cxx.hxx - * The default implementation for pyramid. + * The default implementation for pyramids. Interface between the + * \file t8_default_common_cxx.hxx definitions and the element type specific + * implementations in \file t8_dpyramid_bits.h */ #ifndef T8_DEFAULT_PYRAMID_CXX_HXX diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.h b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.h index 28caf3ad9e..c7488e837b 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.h +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.h @@ -20,6 +20,10 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/** \file t8_dpyramid_bits.h + * Definition if pyramid-specific functions. + */ + #ifndef T8_DPYRAMID_BITS_H #define T8_DPYRAMID_BITS_H diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx index 457c6fe8f8..26da458e9d 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx @@ -21,7 +21,9 @@ */ /** \file t8_default_tet_cxx.hxx - * The default implementation for tetrahedra. + * The default implementation for tetrahedra. Interface between the + * \file t8_default_common_cxx.hxx definitions and the element type specific + * implementations in \file t8_dtet_bits.h */ #ifndef T8_DEFAULT_TET_CXX_H diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h b/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h index f6eb8575a9..b31b47530c 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h @@ -21,7 +21,7 @@ */ /** \file t8_dtet_bits.h - * TODO: Document this. + * Definition if tet-specific functions. * TODO: Run make doxygen and grep for files. * Also document all arguments of functions. * TODO: Group the dtet_is functions together. diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx index 582281064e..b2db5e3a2e 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx @@ -21,7 +21,9 @@ */ /** \file t8_default_tri.h - * The default implementation for triangles. + * The default implementation for triangles. Interface between the + * \file t8_default_common_cxx.hxx definitions and the element type specific + * implementations in \file t8_dtri_bits.h */ #ifndef T8_DEFAULT_TRI_CXX_H diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h index 8a7fbed63b..0676ed9aa4 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h @@ -21,6 +21,7 @@ */ /** \file t8_dtri_bits.h + * Definition if triangle-specific functions. */ #ifndef T8_DTRI_BITS_H diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx index 6e7362c07a..9b1ac91b6a 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx @@ -21,7 +21,9 @@ */ /** \file t8_default_vertex.h - * The default implementation for vertex. + * The default implementation for vertices. Interface between the + * \file t8_default_common_cxx.hxx definitions and the element type specific + * implementations in \file t8_dvertex_bits.h */ #ifndef T8_DEFAULT_VERTEX_CXX_H diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h index 3b0618d719..bf991fefe9 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h @@ -21,6 +21,7 @@ */ /** \file t8_dvertex_bits.h + * Definition if vertex-specific functions. */ #ifndef T8_DVERTEX_BITS_H From b0c5240f648807638c43260842aa4fbab0c5602b Mon Sep 17 00:00:00 2001 From: Knapp Date: Tue, 4 Apr 2023 17:06:52 +0200 Subject: [PATCH 050/255] Update vtk_api_writer --- src/t8_forest/t8_forest_vtk.cxx | 165 ++++++++++++++++++-------------- src/t8_forest/t8_forest_vtk.h | 13 +-- 2 files changed, 101 insertions(+), 77 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index a76cd68712..b349c64368 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -140,7 +140,8 @@ const int t8_curved_eclass_vtk_type[T8_ECLASS_COUNT] = */ #if T8_WITH_VTK static int -t8_get_number_of_vtk_nodes (t8_element_shape_t eclass, int curved_flag) +t8_get_number_of_vtk_nodes (const t8_element_shape_t eclass, + const int curved_flag) { /* use the lookup table of the eclasses. */ if (curved_flag) { @@ -164,13 +165,11 @@ t8_get_number_of_vtk_nodes (t8_element_shape_t eclass, int curved_flag) #if T8_WITH_VTK static void t8_curved_element_get_reference_node_coords (const t8_element_t *elem, - t8_element_shape_t eclass, + const t8_element_shape_t eclass, t8_eclass_scheme_c *scheme, - int vertex, double *coords) + const int vertex, double *coords) { double vertex_coords[3] = { 0, 0, 0 }; - int i; - int j; switch (eclass) { case T8_ECLASS_VERTEX: @@ -205,10 +204,13 @@ t8_curved_element_get_reference_node_coords (const t8_element_t *elem, [eclass][vertex], coords); } else { - i = t8_eclass_vtk_corner_number[eclass][(vertex - 4) % 4]; - j = t8_eclass_vtk_corner_number[eclass][(vertex - 3) % 4]; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); + const int ivertex = + t8_eclass_vtk_corner_number[eclass][(vertex - 4) % 4]; + const int jvertex = + t8_eclass_vtk_corner_number[eclass][(vertex - 3) % 4]; + scheme->t8_element_vertex_reference_coords (elem, ivertex, + vertex_coords); + scheme->t8_element_vertex_reference_coords (elem, jvertex, coords); /* Compute the average of those coordinates */ t8_vec_axpy (vertex_coords, coords, 1); t8_vec_ax (coords, 0.5); @@ -222,10 +224,11 @@ t8_curved_element_get_reference_node_coords (const t8_element_t *elem, [eclass][vertex], coords); } else { - i = (vertex - 3) % 3; - j = (vertex - 2) % 3; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); + const int ivertex = (vertex - 3) % 3; + const int jvertex = (vertex - 2) % 3; + scheme->t8_element_vertex_reference_coords (elem, ivertex, + vertex_coords); + scheme->t8_element_vertex_reference_coords (elem, jvertex, coords); /* Compute the average of those coordinates */ t8_vec_axpy (vertex_coords, coords, 1); t8_vec_ax (coords, 0.5); @@ -238,31 +241,38 @@ t8_curved_element_get_reference_node_coords (const t8_element_t *elem, [eclass][vertex], coords); } else if (7 < vertex && vertex < 12) { - i = t8_eclass_vtk_corner_number[eclass][(vertex - 8) % 4]; - j = t8_eclass_vtk_corner_number[eclass][(vertex - 7) % 4]; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); + const int ivertex = + t8_eclass_vtk_corner_number[eclass][(vertex - 8) % 4]; + const int jvertex = + t8_eclass_vtk_corner_number[eclass][(vertex - 7) % 4]; + scheme->t8_element_vertex_reference_coords (elem, ivertex, + vertex_coords); + scheme->t8_element_vertex_reference_coords (elem, jvertex, coords); /* Compute the average of those coordinates */ t8_vec_axpy (vertex_coords, coords, 1); t8_vec_ax (coords, 0.5); } else if (11 < vertex && vertex < 16) { - i = t8_eclass_vtk_corner_number[eclass][((vertex - 8) % 4) + 4]; - j = t8_eclass_vtk_corner_number[eclass][((vertex - 7) % 4) + 4]; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); + const int ivertex = + t8_eclass_vtk_corner_number[eclass][((vertex - 8) % 4) + 4]; + const int jvertex = + t8_eclass_vtk_corner_number[eclass][((vertex - 7) % 4) + 4]; + scheme->t8_element_vertex_reference_coords (elem, ivertex, + vertex_coords); + scheme->t8_element_vertex_reference_coords (elem, jvertex, coords); /* Compute the average of those coordinates */ t8_vec_axpy (vertex_coords, coords, 1); t8_vec_ax (coords, 0.5); } else { - i = t8_eclass_vtk_corner_number[eclass][vertex % 16]; - j = i + 4; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); + const int ivertex = + t8_eclass_vtk_corner_number[eclass][vertex % 16]; + const int jvertex = ivertex + 4; + scheme->t8_element_vertex_reference_coords (elem, ivertex, + vertex_coords); + scheme->t8_element_vertex_reference_coords (elem, jvertex, coords); /* Compute the average of those coordinates */ - t8_vec_axpy (vertex_coords, coords, 1); - t8_vec_ax (coords, 0.5); + } break; @@ -273,19 +283,24 @@ t8_curved_element_get_reference_node_coords (const t8_element_t *elem, [eclass][vertex], coords); } else if (3 < vertex && vertex < 7) { - i = t8_eclass_vtk_corner_number[eclass][(vertex - 4) % 3]; - j = t8_eclass_vtk_corner_number[eclass][(vertex - 3) % 3]; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); + const int ivertex = + t8_eclass_vtk_corner_number[eclass][(vertex - 4) % 3]; + const int jvertex = + t8_eclass_vtk_corner_number[eclass][(vertex - 3) % 3]; + scheme->t8_element_vertex_reference_coords (elem, ivertex, + vertex_coords); + scheme->t8_element_vertex_reference_coords (elem, jvertex, coords); /* Compute the average of those coordinates */ t8_vec_axpy (vertex_coords, coords, 1); t8_vec_ax (coords, 0.5); } else { - i = t8_eclass_vtk_corner_number[eclass][vertex % 7]; - j = 3; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); + const int ivertex = + t8_eclass_vtk_corner_number[eclass][vertex % 7]; + const int jvertex = 3; + scheme->t8_element_vertex_reference_coords (elem, ivertex, + vertex_coords); + scheme->t8_element_vertex_reference_coords (elem, jvertex, coords); /* Compute the average of those coordinates */ t8_vec_axpy (vertex_coords, coords, 1); t8_vec_ax (coords, 0.5); @@ -298,28 +313,37 @@ t8_curved_element_get_reference_node_coords (const t8_element_t *elem, [eclass][vertex], coords); } else if (5 < vertex && vertex < 9) { - i = t8_eclass_vtk_corner_number[eclass][(vertex - 3) % 3]; - j = t8_eclass_vtk_corner_number[eclass][(vertex - 2) % 3]; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); + const int ivertex = + t8_eclass_vtk_corner_number[eclass][(vertex - 3) % 3]; + const int jvertex = + t8_eclass_vtk_corner_number[eclass][(vertex - 2) % 3]; + scheme->t8_element_vertex_reference_coords (elem, ivertex, + vertex_coords); + scheme->t8_element_vertex_reference_coords (elem, jvertex, coords); /* Compute the average of those coordinates */ t8_vec_axpy (vertex_coords, coords, 1); t8_vec_ax (coords, 0.5); } else if (8 < vertex && vertex < 12) { - i = t8_eclass_vtk_corner_number[eclass][(vertex % 3) + 3]; - j = t8_eclass_vtk_corner_number[eclass][((vertex + 1) % 3) + 3]; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); + const int ivertex = + t8_eclass_vtk_corner_number[eclass][(vertex % 3) + 3]; + const int jvertex = + t8_eclass_vtk_corner_number[eclass][((vertex + 1) % 3) + 3]; + scheme->t8_element_vertex_reference_coords (elem, ivertex, + vertex_coords); + scheme->t8_element_vertex_reference_coords (elem, jvertex, coords); /* Compute the average of those coordinates */ t8_vec_axpy (vertex_coords, coords, 1); t8_vec_ax (coords, 0.5); } else { - i = t8_eclass_vtk_corner_number[eclass][vertex % 12]; - j = t8_eclass_vtk_corner_number[eclass][(vertex % 12) + 3]; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); + const int ivertex = + t8_eclass_vtk_corner_number[eclass][vertex % 12]; + const int jvertex = + t8_eclass_vtk_corner_number[eclass][(vertex % 12) + 3]; + scheme->t8_element_vertex_reference_coords (elem, ivertex, + vertex_coords); + scheme->t8_element_vertex_reference_coords (elem, jvertex, coords); /* Compute the average of those coordinates */ t8_vec_axpy (vertex_coords, coords, 1); t8_vec_ax (coords, 0.5); @@ -336,12 +360,13 @@ t8_curved_element_get_reference_node_coords (const t8_element_t *elem, int t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, - int write_treeid, - int write_mpirank, - int write_level, - int write_element_id, - int curved_flag, - int num_data, t8_vtk_data_field_t *data) + const int write_treeid, + const int write_mpirank, + const int write_level, + const int write_element_id, + const int curved_flag, + const int num_data, + t8_vtk_data_field_t *data) { #if T8_WITH_VTK /*Check assertions: forest and fileprefix are not NULL and forest is commited */ @@ -351,16 +376,10 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, T8_ASSERT (fileprefix != NULL); long int point_id = 0; /* The id of the point in the points Object. */ - t8_locidx_t ielement; /* The iterator over elements in a tree. */ - t8_locidx_t itree, ivertex; double coordinates[3]; double vertex_coords[3] = { 0, 0, 0 }; - int elem_id = 0; - t8_locidx_t num_elements; + t8_gloidx_t elem_id = 0; int freturn = 0; - t8_gloidx_t gtreeid; - t8_cmesh_t cmesh; - int num_node; /* Since we want to use different element types and a points Array and cellArray * we have to declare these vtk objects. The cellArray stores the Elements. @@ -387,7 +406,8 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, /* * The cellTypes Array stores the element types as integers(see vtk doc). */ - num_elements = t8_forest_get_local_num_elements (forest); + const t8_locidx_t num_elements = + t8_forest_get_local_num_elements (forest); int *cellTypes = T8_ALLOC (int, num_elements); /* @@ -421,9 +441,10 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, vtkDoubleArray **dataArrays; dataArrays = T8_ALLOC (vtkDoubleArray *, num_data); - cmesh = t8_forest_get_cmesh (forest); + t8_cmesh_t cmesh = t8_forest_get_cmesh (forest); /* We iterate over all local trees*/ - for (itree = 0; itree < t8_forest_get_num_local_trees (forest); itree++) { + for (t8_locidx_t itree = 0; itree < t8_forest_get_num_local_trees (forest); + itree++) { /* * We get the current tree, the scheme for this tree * and the number of elements in this tree. We need the vertices of @@ -433,20 +454,22 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, t8_eclass_scheme_c *scheme = t8_forest_get_eclass_scheme (forest, t8_forest_get_tree_class (forest, itree)); - t8_locidx_t elems_in_tree = + const t8_locidx_t elems_in_tree = t8_forest_get_tree_num_elements (forest, itree); - t8_locidx_t offset = + const t8_locidx_t offset = t8_forest_get_tree_element_offset (forest, itree); /* We iterate over all elements in the tree */ /* Compute the global tree id */ - gtreeid = t8_forest_global_tree_id (forest, itree); - for (ielement = 0; ielement < elems_in_tree; ielement++) { - t8_element_t *element = + const t8_gloidx_t gtreeid = t8_forest_global_tree_id (forest, itree); + for (t8_locidx_t ielement = 0; ielement < elems_in_tree; ielement++) { + const t8_element_t *element = t8_forest_get_element_in_tree (forest, itree, ielement); T8_ASSERT (element != NULL); vtkSmartPointer < vtkCell > pvtkCell = NULL; - t8_element_shape_t element_shape = scheme->t8_element_shape (element); - num_node = t8_get_number_of_vtk_nodes (element_shape, curved_flag); + const t8_element_shape_t element_shape = + scheme->t8_element_shape (element); + const int num_node = + t8_get_number_of_vtk_nodes (element_shape, curved_flag); /* depending on the element type we choose the correct vtk cell to insert points to */ if (curved_flag == 0) { switch (element_shape) { @@ -510,7 +533,7 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, } /* For each element we iterate over all points */ - for (ivertex = 0; ivertex < num_node; ivertex++, point_id++) { + for (t8_locidx_t ivertex = 0; ivertex < num_node; ivertex++, point_id++) { /* Compute the vertex coordinates inside [0,1]^dim reference cube. */ if (curved_flag) { t8_curved_element_get_reference_node_coords (element, element_shape, diff --git a/src/t8_forest/t8_forest_vtk.h b/src/t8_forest/t8_forest_vtk.h index cb0e038b0d..239510eea5 100644 --- a/src/t8_forest/t8_forest_vtk.h +++ b/src/t8_forest/t8_forest_vtk.h @@ -56,12 +56,13 @@ T8_EXTERN_C_BEGIN (); */ int t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, - int write_treeid, - int write_mpirank, - int write_level, - int write_element_id, - int curved_flag, - int num_data, + const int write_treeid, + const int write_mpirank, + const int write_level, + const int + write_element_id, + const int curved_flag, + const int num_data, t8_vtk_data_field_t *data); From 577cedf8406cb3573f9b5daacf2e44133f55a069 Mon Sep 17 00:00:00 2001 From: Knapp Date: Wed, 5 Apr 2023 09:55:25 +0200 Subject: [PATCH 051/255] Updated API-vtk_writer to current coding guidelines --- src/t8_forest/t8_forest_vtk.cxx | 257 +++++++++++++++++--------------- src/t8_forest/t8_forest_vtk.h | 10 +- 2 files changed, 138 insertions(+), 129 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index b349c64368..6ecc011911 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -111,13 +111,15 @@ typedef enum * \return True if successful, false if not (i.e. file i/o error). */ typedef int (*t8_forest_vtk_cell_data_kernel) (t8_forest_t forest, - t8_locidx_t ltree_id, - t8_tree_t tree, - t8_locidx_t + const t8_locidx_t + ltree_id, + const t8_tree_t tree, + const t8_locidx_t element_index, - t8_element_t *element, + const t8_element_t + *element, t8_eclass_scheme_c *ts, - int is_ghost, + const int is_ghost, FILE *vtufile, int *columns, void **data, @@ -738,25 +740,23 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, } static t8_locidx_t -t8_forest_num_points (t8_forest_t forest, int count_ghosts) +t8_forest_num_points (t8_forest_t forest, const int count_ghosts) { - t8_locidx_t itree, num_points, num_ghosts, ielem; - t8_tree_t tree; - t8_eclass_t ghost_class; - size_t num_elements; - t8_element_t *elem; - t8_element_array_t *ghost_elem; - t8_eclass_scheme *tscheme; - - num_points = 0; - for (itree = 0; itree < (t8_locidx_t) forest->trees->elem_count; itree++) { + t8_locidx_t num_points = 0; + + for (t8_locidx_t itree = 0; itree < (t8_locidx_t) forest->trees->elem_count; + itree++) { /* Get the tree that stores the elements */ - tree = (t8_tree_t) t8_sc_array_index_locidx (forest->trees, itree); + t8_tree_t tree = + (t8_tree_t) t8_sc_array_index_locidx (forest->trees, itree); /* Get the scheme of the current tree */ - tscheme = t8_forest_get_eclass_scheme (forest, tree->eclass); - num_elements = t8_element_array_get_count (&tree->elements); - for (ielem = 0; ielem < (t8_locidx_t) num_elements; ielem++) { - elem = t8_element_array_index_locidx (&tree->elements, ielem); + t8_eclass_scheme *tscheme = + t8_forest_get_eclass_scheme (forest, tree->eclass); + const size_t num_elements = + t8_element_array_get_count (&tree->elements); + for (t8_locidx_t ielem = 0; ielem < (t8_locidx_t) num_elements; ielem++) { + const t8_element_t *elem = + t8_element_array_index_locidx (&tree->elements, ielem); num_points += tscheme->t8_element_num_corners (elem); } @@ -764,15 +764,20 @@ t8_forest_num_points (t8_forest_t forest, int count_ghosts) if (count_ghosts) { T8_ASSERT (forest->ghosts != NULL); /* We also count the points of the ghost cells */ - num_ghosts = t8_forest_ghost_num_trees (forest); - for (itree = 0; itree < num_ghosts; itree++) { + const t8_locidx_t num_ghosts = t8_forest_ghost_num_trees (forest); + for (t8_locidx_t itree = 0; itree < num_ghosts; itree++) { /* Get the element class of the ghost */ - ghost_class = t8_forest_ghost_get_tree_class (forest, itree); - ghost_elem = t8_forest_ghost_get_tree_elements (forest, itree); - num_elements = t8_forest_ghost_tree_num_elements (forest, itree); - tscheme = t8_forest_get_eclass_scheme (forest, ghost_class); - for (ielem = 0; ielem < (t8_locidx_t) num_elements; ielem++) { - elem = t8_element_array_index_locidx (ghost_elem, ielem); + t8_eclass_t ghost_class = + t8_forest_ghost_get_tree_class (forest, itree); + t8_element_array_t *ghost_elem = + t8_forest_ghost_get_tree_elements (forest, itree); + const size_t num_elements = + t8_forest_ghost_tree_num_elements (forest, itree); + t8_eclass_scheme *tscheme = + t8_forest_get_eclass_scheme (forest, ghost_class); + for (t8_locidx_t ielem = 0; ielem < (t8_locidx_t) num_elements; ielem++) { + const t8_element_t *elem = + t8_element_array_index_locidx (ghost_elem, ielem); num_points += tscheme->t8_element_num_corners (elem); } } @@ -781,14 +786,15 @@ t8_forest_num_points (t8_forest_t forest, int count_ghosts) } static int -t8_forest_vtk_cells_vertices_kernel (t8_forest_t forest, t8_locidx_t ltree_id, - t8_tree_t tree, - t8_locidx_t element_index, - t8_element_t *element, +t8_forest_vtk_cells_vertices_kernel (t8_forest_t forest, + const t8_locidx_t ltree_id, + const t8_tree_t tree, + const t8_locidx_t element_index, + const t8_element_t *element, t8_eclass_scheme_c *ts, - int is_ghost, - FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) + const int is_ghost, FILE *vtufile, + int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { double element_coordinates[3]; int num_el_vertices, ivertex; @@ -835,13 +841,13 @@ t8_forest_vtk_cells_vertices_kernel (t8_forest_t forest, t8_locidx_t ltree_id, static int t8_forest_vtk_cells_connectivity_kernel (t8_forest_t forest, - t8_locidx_t ltree_id, t8_tree_t tree, - t8_locidx_t element_index, - t8_element_t *elements, + const t8_locidx_t ltree_id, + const t8_tree_t tree, + const t8_locidx_t element_index, + const t8_element_t *element, t8_eclass_scheme_c *ts, - int is_ghost, - FILE *vtufile, int *columns, - void **data, + const int is_ghost, FILE *vtufile, + int *columns, void **data, T8_VTK_KERNEL_MODUS modus) { int ivertex, num_vertices; @@ -861,7 +867,7 @@ t8_forest_vtk_cells_connectivity_kernel (t8_forest_t forest, T8_ASSERT (modus == T8_VTK_KERNEL_EXECUTE); count_vertices = (t8_locidx_t *) *data; - element_shape = ts->t8_element_shape (elements); + element_shape = ts->t8_element_shape (element); num_vertices = t8_eclass_num_vertices[element_shape]; for (ivertex = 0; ivertex < num_vertices; ++ivertex, (*count_vertices)++) { freturn = fprintf (vtufile, " %ld", (long) *count_vertices); @@ -874,14 +880,14 @@ t8_forest_vtk_cells_connectivity_kernel (t8_forest_t forest, } static int -t8_forest_vtk_cells_offset_kernel (t8_forest_t forest, t8_locidx_t ltree_id, - t8_tree_t tree, - t8_locidx_t element_index, - t8_element_t *element, - t8_eclass_scheme_c *ts, - int is_ghost, - FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) +t8_forest_vtk_cells_offset_kernel (t8_forest_t forest, + const t8_locidx_t ltree_id, + const t8_tree_t tree, + const t8_locidx_t element_index, + const t8_element_t *element, + t8_eclass_scheme_c *ts, const int is_ghost, + FILE *vtufile, int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { long long *offset; int freturn; @@ -911,14 +917,14 @@ t8_forest_vtk_cells_offset_kernel (t8_forest_t forest, t8_locidx_t ltree_id, } static int -t8_forest_vtk_cells_type_kernel (t8_forest_t forest, t8_locidx_t ltree_id, - t8_tree_t tree, - t8_locidx_t element_index, - t8_element_t *element, - t8_eclass_scheme_c *ts, - int is_ghost, - FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) +t8_forest_vtk_cells_type_kernel (t8_forest_t forest, + const t8_locidx_t ltree_id, + const t8_tree_t tree, + const t8_locidx_t element_index, + const t8_element_t *element, + t8_eclass_scheme_c *ts, const int is_ghost, + FILE *vtufile, int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { int freturn; if (modus == T8_VTK_KERNEL_EXECUTE) { @@ -936,13 +942,13 @@ t8_forest_vtk_cells_type_kernel (t8_forest_t forest, t8_locidx_t ltree_id, static int t8_forest_vtk_cells_level_kernel (t8_forest_t forest, - t8_locidx_t ltree_id, t8_tree_t tree, - t8_locidx_t element_index, - t8_element_t *element, - t8_eclass_scheme_c *ts, - int is_ghost, - FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t ltree_id, + const t8_tree_t tree, + const t8_locidx_t element_index, + const t8_element_t *element, + t8_eclass_scheme_c *ts, const int is_ghost, + FILE *vtufile, int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { if (modus == T8_VTK_KERNEL_EXECUTE) { fprintf (vtufile, "%i ", ts->t8_element_level (element)); @@ -953,13 +959,13 @@ t8_forest_vtk_cells_level_kernel (t8_forest_t forest, static int t8_forest_vtk_cells_rank_kernel (t8_forest_t forest, - t8_locidx_t ltree_id, t8_tree_t tree, - t8_locidx_t element_index, - t8_element_t *element, - t8_eclass_scheme_c *ts, - int is_ghost, - FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t ltree_id, + const t8_tree_t tree, + const t8_locidx_t element_index, + const t8_element_t *element, + t8_eclass_scheme_c *ts, const int is_ghost, + FILE *vtufile, int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { if (modus == T8_VTK_KERNEL_EXECUTE) { fprintf (vtufile, "%i ", forest->mpirank); @@ -970,13 +976,13 @@ t8_forest_vtk_cells_rank_kernel (t8_forest_t forest, static int t8_forest_vtk_cells_treeid_kernel (t8_forest_t forest, - t8_locidx_t ltree_id, t8_tree_t tree, - t8_locidx_t element_index, - t8_element_t *element, - t8_eclass_scheme_c *ts, - int is_ghost, - FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t ltree_id, + const t8_tree_t tree, + const t8_locidx_t element_index, + const t8_element_t *element, + t8_eclass_scheme_c *ts, const int is_ghost, + FILE *vtufile, int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { if (modus == T8_VTK_KERNEL_EXECUTE) { long long tree_id; @@ -996,13 +1002,14 @@ t8_forest_vtk_cells_treeid_kernel (t8_forest_t forest, static int t8_forest_vtk_cells_elementid_kernel (t8_forest_t forest, - t8_locidx_t ltree_id, t8_tree_t tree, - t8_locidx_t element_index, - t8_element_t *element, + const t8_locidx_t ltree_id, + const t8_tree_t tree, + const t8_locidx_t element_index, + const t8_element_t *element, t8_eclass_scheme_c *ts, - int is_ghost, - FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) + const int is_ghost, FILE *vtufile, + int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { if (modus == T8_VTK_KERNEL_EXECUTE) { if (!is_ghost) { @@ -1019,13 +1026,13 @@ t8_forest_vtk_cells_elementid_kernel (t8_forest_t forest, static int t8_forest_vtk_cells_scalar_kernel (t8_forest_t forest, - t8_locidx_t ltree_id, t8_tree_t tree, - t8_locidx_t element_index, - t8_element_t *element, - t8_eclass_scheme_c *ts, - int is_ghost, - FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t ltree_id, + const t8_tree_t tree, + const t8_locidx_t element_index, + const t8_element_t *element, + t8_eclass_scheme_c *ts, const int is_ghost, + FILE *vtufile, int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { double element_value = 0; t8_locidx_t scalar_index; @@ -1048,13 +1055,13 @@ t8_forest_vtk_cells_scalar_kernel (t8_forest_t forest, static int t8_forest_vtk_cells_vector_kernel (t8_forest_t forest, - t8_locidx_t ltree_id, t8_tree_t tree, - t8_locidx_t element_index, - t8_element_t *element, - t8_eclass_scheme_c *ts, - int is_ghost, - FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t ltree_id, + const t8_tree_t tree, + const t8_locidx_t element_index, + const t8_element_t *element, + t8_eclass_scheme_c *ts, const int is_ghost, + FILE *vtufile, int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { double *element_values, null_vec[3] = { 0, 0, 0 }; int dim, idim; @@ -1084,13 +1091,14 @@ t8_forest_vtk_cells_vector_kernel (t8_forest_t forest, /* The point data version of the scalar kernel */ static int t8_forest_vtk_vertices_scalar_kernel (t8_forest_t forest, - t8_locidx_t ltree_id, t8_tree_t tree, - t8_locidx_t element_index, - t8_element_t *element, + const t8_locidx_t ltree_id, + const t8_tree_t tree, + const t8_locidx_t element_index, + const t8_element_t *element, t8_eclass_scheme_c *ts, - int is_ghost, - FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) + const int is_ghost, FILE *vtufile, + int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { double element_value = 0; int num_vertex, ivertex; @@ -1119,13 +1127,14 @@ t8_forest_vtk_vertices_scalar_kernel (t8_forest_t forest, /* The point data version of the vector kernel */ static int t8_forest_vtk_vertices_vector_kernel (t8_forest_t forest, - t8_locidx_t ltree_id, t8_tree_t tree, - t8_locidx_t element_index, - t8_element_t *element, + const t8_locidx_t ltree_id, + const t8_tree_t tree, + const t8_locidx_t element_index, + const t8_element_t *element, t8_eclass_scheme_c *ts, - int is_ghost, - FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) + const int is_ghost, FILE *vtufile, + int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { double *element_values, null_vec[3] = { 0, 0, 0 }; int dim, idim; @@ -1163,9 +1172,9 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *dataname, const char *datatype, const char *component_string, - int max_columns, + const int max_columns, t8_forest_vtk_cell_data_kernel kernel, - int write_ghosts, void *udata) + const int write_ghosts, void *udata) { int freturn; int countcols; @@ -1305,10 +1314,10 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, * cells was successful or not. */ static int t8_forest_vtk_write_cells (t8_forest_t forest, FILE *vtufile, - int write_treeid, - int write_mpirank, - int write_level, int write_element_id, - int write_ghosts, int num_data, + const int write_treeid, + const int write_mpirank, + const int write_level, const int write_element_id, + const int write_ghosts, const int num_data, t8_vtk_data_field_t *data) { int freturn; @@ -1472,8 +1481,8 @@ t8_forest_vtk_write_cells (t8_forest_t forest, FILE *vtufile, * cells was successful or not. */ static int t8_forest_vtk_write_points (t8_forest_t forest, FILE *vtufile, - int write_ghosts, - int num_data, t8_vtk_data_field_t *data) + const int write_ghosts, + const int num_data, t8_vtk_data_field_t *data) { int freturn; int sreturn; @@ -1567,11 +1576,11 @@ t8_forest_vtk_write_points (t8_forest_t forest, FILE *vtufile, int t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, - int write_treeid, - int write_mpirank, - int write_level, int write_element_id, + const int write_treeid, + const int write_mpirank, + const int write_level, const int write_element_id, int write_ghosts, - int num_data, t8_vtk_data_field_t *data) + const int num_data, t8_vtk_data_field_t *data) { FILE *vtufile = NULL; t8_locidx_t num_elements, num_points; diff --git a/src/t8_forest/t8_forest_vtk.h b/src/t8_forest/t8_forest_vtk.h index 239510eea5..9225f7ef93 100644 --- a/src/t8_forest/t8_forest_vtk.h +++ b/src/t8_forest/t8_forest_vtk.h @@ -88,12 +88,12 @@ int t8_forest_vtk_write_file_via_API (t8_forest_t forest, */ int t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, - int write_treeid, - int write_mpirank, - int write_level, - int write_element_id, + const int write_treeid, + const int write_mpirank, + const int write_level, + const int write_element_id, int write_ghosts, - int num_data, + const int num_data, t8_vtk_data_field_t *data); T8_EXTERN_C_END (); From ed93637a8ef022f5caa9de916318319e46939113 Mon Sep 17 00:00:00 2001 From: Knapp Date: Wed, 5 Apr 2023 10:56:38 +0200 Subject: [PATCH 052/255] Split the vtk-writer into two seperate functions F1: forest -> vtkUnstructuredGrid F2: vtkUnstructuredGrid -> file --- src/t8_forest/t8_forest_vtk.cxx | 208 +++++++++++++++++--------------- src/t8_forest/t8_forest_vtk.h | 39 ++++++ 2 files changed, 153 insertions(+), 94 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index 6ecc011911..08a3c72f0e 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -371,17 +371,122 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, t8_vtk_data_field_t *data) { #if T8_WITH_VTK + int freturn = 0; + T8_ASSERT (fileprefix != NULL); + /* + * Write file: First we construct the unstructured Grid + * that will store the points and elements. It requires + * information about the points(coordinates, stored in the points object) + * and the cells(cellTypes and which points belong to this cell) + */ + vtkSmartPointer < vtkUnstructuredGrid > unstructuredGrid = + vtkSmartPointer < vtkUnstructuredGrid >::New (); + t8_forest_to_vtkUnstructuredGrid (forest, unstructuredGrid, write_treeid, + write_mpirank, write_level, + write_element_id, curved_flag, num_data, + data); + /* + * We define the filename used to write the pvtu and the vtu files. + * The pwriterObj is of class XMLPUnstructuredGridWriter, the P in + * XMLP is important: We want to write a vtu file for each process. + * This class enables us to do exactly that. + */ + char mpifilename[BUFSIZ]; + snprintf (mpifilename, BUFSIZ, "%s.pvtu", fileprefix); + + vtkSmartPointer < vtkXMLPUnstructuredGridWriter > pwriterObj = + vtkSmartPointer < vtkXMLPUnstructuredGridWriter >::New (); +/* + * Get/Set whether the appended data section is base64 encoded. + * If encoded, reading and writing will be slower, but the file + * will be fully valid XML and text-only. + * If not encoded, the XML specification will be violated, + * but reading and writing will be fast. The default is to do the encoding. + * Documentation: https://vtk.org/doc/release/5.0/html/a02260.html#z3560_2 + */ + pwriterObj->EncodeAppendedDataOff (); + +/* We set the filename of the pvtu file. The filenames of the vtu files + * are given based on the name of the pvtu file and the process number. + */ + pwriterObj->SetFileName (mpifilename); + +/* + * Since we want to write multiple files, the processes + * have to communicate. Therefore, we define the communicator + * vtk_comm and set it as the communicator. + * We have to set a controller for the pwriterObj, + * therefore we define the controller vtk_mpi_ctrl. + */ +#if T8_ENABLE_MPI + vtkSmartPointer < vtkMPICommunicator > vtk_comm = + vtkSmartPointer < vtkMPICommunicator >::New (); + vtkMPICommunicatorOpaqueComm vtk_opaque_comm (&forest->mpicomm); + vtk_comm->InitializeExternal (&vtk_opaque_comm); + + vtkSmartPointer < vtkMPIController > vtk_mpi_ctrl = + vtkSmartPointer < vtkMPIController >::New (); + vtk_mpi_ctrl->SetCommunicator (vtk_comm); + + pwriterObj->SetController (vtk_mpi_ctrl); +#endif +/* + * We set the number of pieces as the number of mpi processes, + * since we want to write a file for each process. We also + * need to define a Start and EndPiece for the current + * process. Then we can set the inputData for the writer: + * We want to write the unstructured Grid, update the writer + * and then write. + * + * Note: We could write more than one file per process here, if desired. + */ + pwriterObj->SetNumberOfPieces (forest->mpisize); + pwriterObj->SetStartPiece (forest->mpirank); + pwriterObj->SetEndPiece (forest->mpirank); + +/* We set the input data and write the vtu files. */ + pwriterObj->SetInputData (unstructuredGrid); + pwriterObj->Update (); + if (pwriterObj->Write ()) { + /* Writing was successful */ + freturn = 1; + } + else { + t8_errorf ("Error when writing vtk file.\n"); + } + +/* Return whether writing was successful */ + return freturn; + +#else + t8_global_errorf + ("Warning: t8code is not linked against vtk library. Vtk output will not be generated.\n"); + t8_global_productionf + ("Consider calling 't8_forest_write_vtk' or 't8_forest_vtk_write_file' instead.\n"); + return 0; +#endif +} + +#if T8_WITH_VTK +void +t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, + vtkSmartPointer < vtkUnstructuredGrid > + unstructuredGrid, const int write_treeid, + const int write_mpirank, + const int write_level, + const int write_element_id, + const int curved_flag, const int num_data, + t8_vtk_data_field_t *data) +{ /*Check assertions: forest and fileprefix are not NULL and forest is commited */ T8_ASSERT (forest != NULL); T8_ASSERT (forest->rc.refcount > 0); T8_ASSERT (forest->committed); - T8_ASSERT (fileprefix != NULL); long int point_id = 0; /* The id of the point in the points Object. */ double coordinates[3]; double vertex_coords[3] = { 0, 0, 0 }; t8_gloidx_t elem_id = 0; - int freturn = 0; /* Since we want to use different element types and a points Array and cellArray * we have to declare these vtk objects. The cellArray stores the Elements. @@ -597,73 +702,9 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, } /* end of loop over elements */ } /* end of loop over local trees */ - /* - * Write file: First we construct the unstructured Grid - * that will store the points and elements. It requires - * information about the points(coordinates, stored in the points object) - * and the cells(cellTypes and which points belong to this cell) - */ - - vtkNew < vtkUnstructuredGrid > unstructuredGrid; unstructuredGrid->SetPoints (points); unstructuredGrid->SetCells (cellTypes, cellArray); - /* - * We define the filename used to write the pvtu and the vtu files. - * The pwriterObj is of class XMLPUnstructuredGridWriter, the P in - * XMLP is important: We want to write a vtu file for each process. - * This class enables us to do exactly that. - */ - char mpifilename[BUFSIZ]; - snprintf (mpifilename, BUFSIZ, "%s.pvtu", fileprefix); - - vtkSmartPointer < vtkXMLPUnstructuredGridWriter > pwriterObj = - vtkSmartPointer < vtkXMLPUnstructuredGridWriter >::New (); -/* - * Get/Set whether the appended data section is base64 encoded. - * If encoded, reading and writing will be slower, but the file - * will be fully valid XML and text-only. - * If not encoded, the XML specification will be violated, - * but reading and writing will be fast. The default is to do the encoding. - * Documentation: https://vtk.org/doc/release/5.0/html/a02260.html#z3560_2 - * - * We set the filename of the pvtu file. The filenames of the vtu files - * are given based on the name of the pvtu file and the process number. - */ - pwriterObj->EncodeAppendedDataOff (); - pwriterObj->SetFileName (mpifilename); - -/* - * Since we want to write multiple files, the processes - * have to communicate. Therefore, we define the communicator - * vtk_comm and set it as the communicator. - * We have to set a controller for the pwriterObj, - * therefore we define the controller vtk_mpi_ctrl. - */ -#if T8_ENABLE_MPI - vtkSmartPointer < vtkMPICommunicator > vtk_comm = - vtkSmartPointer < vtkMPICommunicator >::New (); - vtkMPICommunicatorOpaqueComm vtk_opaque_comm (&forest->mpicomm); - vtk_comm->InitializeExternal (&vtk_opaque_comm); - - vtkSmartPointer < vtkMPIController > vtk_mpi_ctrl = - vtkSmartPointer < vtkMPIController >::New (); - vtk_mpi_ctrl->SetCommunicator (vtk_comm); - pwriterObj->SetController (vtk_mpi_ctrl); -#endif -/* - * We set the number of pieces as the number of mpi processes, - * since we want to write a file for each process. We also - * need to define a Start and EndPiece for the current - * process. Then we can set the inputData for the writer: - * We want to write the unstructured Grid, update the writer - * and then write. - * - * Note: We could write more than one file per process here, if desired. - */ - pwriterObj->SetNumberOfPieces (forest->mpisize); - pwriterObj->SetStartPiece (forest->mpirank); - pwriterObj->SetEndPiece (forest->mpirank); /* *INDENT-OFF* */ if (write_treeid) { vtk_treeid->SetName ("treeid"); @@ -683,11 +724,11 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, } /* *INDENT-ON* */ -/* Write the user defined data fields. - * For that we iterate over the idata, set the name, the array - * and then give this data to the unstructured Grid Object. - * We differentiate between scalar and vector data. - */ + /* Write the user defined data fields. + * For that we iterate over the idata, set the name, the array + * and then give this data to the unstructured Grid Object. + * We differentiate between scalar and vector data. + */ for (int idata = 0; idata < num_data; idata++) { dataArrays[idata] = vtkDoubleArray::New (); if (data[idata].type == T8_VTK_SCALAR) { @@ -704,19 +745,7 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, } } -/* We set the input data and write the vtu files. */ - pwriterObj->SetInputData (unstructuredGrid); - pwriterObj->Update (); - if (pwriterObj->Write ()) { - /* Writing was successful */ - freturn = 1; - } - else { - t8_errorf ("Error when writing vtk file.\n"); - } - -/* We have to free the allocated memory for the cellTypes Array and the other arrays we allocated memory for. */ - + /* We have to free the allocated memory for the cellTypes Array and the other arrays we allocated memory for. */ vtk_treeid->Delete (); vtk_mpirank->Delete (); vtk_level->Delete (); @@ -727,17 +756,8 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, T8_FREE (cellTypes); T8_FREE (dataArrays); -/* Return whether writing was successful */ - return freturn; - -#else - t8_global_errorf - ("Warning: t8code is not linked against vtk library. Vtk output will not be generated.\n"); - t8_global_productionf - ("Consider calling 't8_forest_write_vtk' or 't8_forest_vtk_write_file' instead.\n"); - return 0; -#endif } +#endif static t8_locidx_t t8_forest_num_points (t8_forest_t forest, const int count_ghosts) diff --git a/src/t8_forest/t8_forest_vtk.h b/src/t8_forest/t8_forest_vtk.h index 9225f7ef93..cde70532bc 100644 --- a/src/t8_forest/t8_forest_vtk.h +++ b/src/t8_forest/t8_forest_vtk.h @@ -31,8 +31,47 @@ #include #include +#if T8_WITH_VTK +#include +#endif + T8_EXTERN_C_BEGIN (); /* function declarations */ +#if T8_WITH_VTK +/** Write the forest in .pvtu file format. Writes one .vtu file per + * process and a meta .pvtu file. + * This function uses the vtk library. t8code must be configured with + * "--with-vtk" in order to use it. + * Currently does not support pyramid elements. + * \param [in] forest The forest. + * \param [in] fileprefix The prefix of the output files. The meta file will be named \a fileprefix.pvtu . + * \param [in] write_treeid If true, the global tree id is written for each element. + * \param [in] write_mpirank If true, the mpirank is written for each element. + * \param [in] write_level If true, the refinement level is written for each element. + * \param [in] write_element_id If true, the global element id is written for each element. + * \param [in] curved_flag If true, write the elements as curved element types from vtk. + * \param [in] num_data Number of user defined double valued data fields to write. + * \param [in] data Array of t8_vtk_data_field_t of length \a num_data + * providing the user defined per element data. + * If scalar and vector fields are used, all scalar fields + * must come first in the array. + * \return True if successful, false if not (process local). + * \note If t8code was not configured with vtk, use \ref t8_forest_vtk_write_file + */ +void t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, + vtkSmartPointer < + vtkUnstructuredGrid > + unstructuredGrid, + const int write_treeid, + const int write_mpirank, + const int write_level, + const int + write_element_id, + const int curved_flag, + const int num_data, + t8_vtk_data_field_t + *data); +#endif /** Write the forest in .pvtu file format. Writes one .vtu file per * process and a meta .pvtu file. From b28923e1c91f6043654cdf53d920784566b21d36 Mon Sep 17 00:00:00 2001 From: Knapp Date: Wed, 5 Apr 2023 11:48:39 +0200 Subject: [PATCH 053/255] tmp-commit --- src/t8_forest/t8_forest_vtk.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index 08a3c72f0e..b49182bbf2 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -379,6 +379,7 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, * information about the points(coordinates, stored in the points object) * and the cells(cellTypes and which points belong to this cell) */ + vtkSmartPointer < vtkUnstructuredGrid > unstructuredGrid = vtkSmartPointer < vtkUnstructuredGrid >::New (); t8_forest_to_vtkUnstructuredGrid (forest, unstructuredGrid, write_treeid, From db2ef253576962d90bed1ab1e6e2e49d96babd91 Mon Sep 17 00:00:00 2001 From: Knapp Date: Wed, 5 Apr 2023 12:59:45 +0200 Subject: [PATCH 054/255] Update documentation --- src/Makefile.am | 2 +- src/t8_forest/t8_forest_vtk.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 702d8d8efc..48c5489460 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -79,7 +79,7 @@ libt8_internal_headers = \ src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_vtk_types.h \ src/t8_forest/t8_forest_cxx.h \ src/t8_forest/t8_forest_ghost.h \ - src/t8_forest/t8_forest_balance.h src/t8_forest/t8_forest_types.h \ + src/t8_forest/t8_forest_balance.h src/t8_forest/t8_forest_types.h \ src/t8_forest/t8_forest_private.h \ src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx libt8_compiled_sources = \ diff --git a/src/t8_forest/t8_forest_vtk.h b/src/t8_forest/t8_forest_vtk.h index cde70532bc..b323c1d123 100644 --- a/src/t8_forest/t8_forest_vtk.h +++ b/src/t8_forest/t8_forest_vtk.h @@ -44,7 +44,7 @@ T8_EXTERN_C_BEGIN (); * "--with-vtk" in order to use it. * Currently does not support pyramid elements. * \param [in] forest The forest. - * \param [in] fileprefix The prefix of the output files. The meta file will be named \a fileprefix.pvtu . + * \param [in,out] unstructuredGrid A pointer to a vtkUnstructuredGrid, which is going to be filled with the elements and data of the \a forest. * \param [in] write_treeid If true, the global tree id is written for each element. * \param [in] write_mpirank If true, the mpirank is written for each element. * \param [in] write_level If true, the refinement level is written for each element. From 7c57d8a531c484d80245cfa1033d8837f142a5de Mon Sep 17 00:00:00 2001 From: Knapp Date: Wed, 5 Apr 2023 13:21:50 +0200 Subject: [PATCH 055/255] Move VTK-Api headers into a seperate header-file --- src/Makefile.am | 1 + src/t8_forest/t8_forest_vtk.cxx | 1 + src/t8_forest/t8_forest_vtk.h | 71 ------------------- src/t8_forest/t8_forest_vtk_API.hxx | 105 ++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 71 deletions(-) create mode 100644 src/t8_forest/t8_forest_vtk_API.hxx diff --git a/src/Makefile.am b/src/Makefile.am index 48c5489460..2881a95777 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,6 +46,7 @@ libt8_installed_headers_data = \ libt8_installed_headers_forest = \ src/t8_forest/t8_forest_adapt.h \ src/t8_forest/t8_forest_vtk.h \ + src/t8_forest/t8_forest_vtk_API.hxx \ src/t8_forest/t8_forest_iterate.h src/t8_forest/t8_forest_partition.h libt8_installed_headers_geometry = \ src/t8_geometry/t8_geometry.h \ diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index b49182bbf2..38e7e97418 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -20,6 +20,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include #include #include diff --git a/src/t8_forest/t8_forest_vtk.h b/src/t8_forest/t8_forest_vtk.h index b323c1d123..187b076516 100644 --- a/src/t8_forest/t8_forest_vtk.h +++ b/src/t8_forest/t8_forest_vtk.h @@ -31,79 +31,8 @@ #include #include -#if T8_WITH_VTK -#include -#endif - T8_EXTERN_C_BEGIN (); /* function declarations */ -#if T8_WITH_VTK -/** Write the forest in .pvtu file format. Writes one .vtu file per - * process and a meta .pvtu file. - * This function uses the vtk library. t8code must be configured with - * "--with-vtk" in order to use it. - * Currently does not support pyramid elements. - * \param [in] forest The forest. - * \param [in,out] unstructuredGrid A pointer to a vtkUnstructuredGrid, which is going to be filled with the elements and data of the \a forest. - * \param [in] write_treeid If true, the global tree id is written for each element. - * \param [in] write_mpirank If true, the mpirank is written for each element. - * \param [in] write_level If true, the refinement level is written for each element. - * \param [in] write_element_id If true, the global element id is written for each element. - * \param [in] curved_flag If true, write the elements as curved element types from vtk. - * \param [in] num_data Number of user defined double valued data fields to write. - * \param [in] data Array of t8_vtk_data_field_t of length \a num_data - * providing the user defined per element data. - * If scalar and vector fields are used, all scalar fields - * must come first in the array. - * \return True if successful, false if not (process local). - * \note If t8code was not configured with vtk, use \ref t8_forest_vtk_write_file - */ -void t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, - vtkSmartPointer < - vtkUnstructuredGrid > - unstructuredGrid, - const int write_treeid, - const int write_mpirank, - const int write_level, - const int - write_element_id, - const int curved_flag, - const int num_data, - t8_vtk_data_field_t - *data); -#endif - -/** Write the forest in .pvtu file format. Writes one .vtu file per - * process and a meta .pvtu file. - * This function uses the vtk library. t8code must be configured with - * "--with-vtk" in order to use it. - * Currently does not support pyramid elements. - * \param [in] forest The forest. - * \param [in] fileprefix The prefix of the output files. The meta file will be named \a fileprefix.pvtu . - * \param [in] write_treeid If true, the global tree id is written for each element. - * \param [in] write_mpirank If true, the mpirank is written for each element. - * \param [in] write_level If true, the refinement level is written for each element. - * \param [in] write_element_id If true, the global element id is written for each element. - * \param [in] curved_flag If true, write the elements as curved element types from vtk. - * \param [in] num_data Number of user defined double valued data fields to write. - * \param [in] data Array of t8_vtk_data_field_t of length \a num_data - * providing the user defined per element data. - * If scalar and vector fields are used, all scalar fields - * must come first in the array. - * \return True if successful, false if not (process local). - * \note If t8code was not configured with vtk, use \ref t8_forest_vtk_write_file - */ -int t8_forest_vtk_write_file_via_API (t8_forest_t forest, - const char *fileprefix, - const int write_treeid, - const int write_mpirank, - const int write_level, - const int - write_element_id, - const int curved_flag, - const int num_data, - t8_vtk_data_field_t - *data); /** Write the forest in .pvtu file format. Writes one .vtu file per * process and a meta .pvtu file. diff --git a/src/t8_forest/t8_forest_vtk_API.hxx b/src/t8_forest/t8_forest_vtk_API.hxx new file mode 100644 index 0000000000..f9da3c4f77 --- /dev/null +++ b/src/t8_forest/t8_forest_vtk_API.hxx @@ -0,0 +1,105 @@ +/* +This file is part of t8code. +t8code is a C library to manage a collection (a forest) of multiple +connected adaptive space-trees of general element classes in parallel. + +Copyright (C) 2015 the developers + +t8code is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +t8code is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with t8code; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef T8_FOREST_VTK_API_HXX +#define T8_FOREST_VTK_API_HXX + +#include +#include + +#if T8_WITH_VTK +#include +#endif + +T8_EXTERN_C_BEGIN (); + +#if T8_WITH_VTK +/** Write the forest in .pvtu file format. Writes one .vtu file per + * process and a meta .pvtu file. + * This function uses the vtk library. t8code must be configured with + * "--with-vtk" in order to use it. + * Currently does not support pyramid elements. + * \param [in] forest The forest. + * \param [in,out] unstructuredGrid A pointer to a vtkUnstructuredGrid, which is going to be filled with the elements and data of the \a forest. + * \param [in] write_treeid If true, the global tree id is written for each element. + * \param [in] write_mpirank If true, the mpirank is written for each element. + * \param [in] write_level If true, the refinement level is written for each element. + * \param [in] write_element_id If true, the global element id is written for each element. + * \param [in] curved_flag If true, write the elements as curved element types from vtk. + * \param [in] num_data Number of user defined double valued data fields to write. + * \param [in] data Array of t8_vtk_data_field_t of length \a num_data + * providing the user defined per element data. + * If scalar and vector fields are used, all scalar fields + * must come first in the array. + * \return True if successful, false if not (process local). + * \note If t8code was not configured with vtk, use \ref t8_forest_vtk_write_file + */ +void t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, + vtkSmartPointer < + vtkUnstructuredGrid > + unstructuredGrid, + const int write_treeid, + const int write_mpirank, + const int write_level, + const int + write_element_id, + const int curved_flag, + const int num_data, + t8_vtk_data_field_t + *data); +#endif + +/** Write the forest in .pvtu file format. Writes one .vtu file per + * process and a meta .pvtu file. + * This function uses the vtk library. t8code must be configured with + * "--with-vtk" in order to use it. + * Currently does not support pyramid elements. + * \param [in] forest The forest. + * \param [in] fileprefix The prefix of the output files. The meta file will be named \a fileprefix.pvtu . + * \param [in] write_treeid If true, the global tree id is written for each element. + * \param [in] write_mpirank If true, the mpirank is written for each element. + * \param [in] write_level If true, the refinement level is written for each element. + * \param [in] write_element_id If true, the global element id is written for each element. + * \param [in] curved_flag If true, write the elements as curved element types from vtk. + * \param [in] num_data Number of user defined double valued data fields to write. + * \param [in] data Array of t8_vtk_data_field_t of length \a num_data + * providing the user defined per element data. + * If scalar and vector fields are used, all scalar fields + * must come first in the array. + * \return True if successful, false if not (process local). + * \note If t8code was not configured with vtk, use \ref t8_forest_vtk_write_file + */ +int t8_forest_vtk_write_file_via_API (t8_forest_t forest, + const char *fileprefix, + const int write_treeid, + const int write_mpirank, + const int write_level, + const int + write_element_id, + const int curved_flag, + const int num_data, + t8_vtk_data_field_t + *data); + +T8_EXTERN_C_END (); + +#endif /* T8_FOREST_VTK_API_HXX */ From a2d8796ed87c2ded95ae3660fc22426b03017968 Mon Sep 17 00:00:00 2001 From: Knapp Date: Wed, 5 Apr 2023 13:33:02 +0200 Subject: [PATCH 056/255] Seperate C and C++ functions properly --- src/Makefile.am | 2 +- ...I.hxx => t8_forest_to_vtkUnstructured.hxx} | 32 ------------------- src/t8_forest/t8_forest_vtk.cxx | 2 +- src/t8_forest/t8_forest_vtk.h | 32 +++++++++++++++++++ 4 files changed, 34 insertions(+), 34 deletions(-) rename src/t8_forest/{t8_forest_vtk_API.hxx => t8_forest_to_vtkUnstructured.hxx} (61%) diff --git a/src/Makefile.am b/src/Makefile.am index 2881a95777..21195abd95 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,7 +46,7 @@ libt8_installed_headers_data = \ libt8_installed_headers_forest = \ src/t8_forest/t8_forest_adapt.h \ src/t8_forest/t8_forest_vtk.h \ - src/t8_forest/t8_forest_vtk_API.hxx \ + src/t8_forest/t8_forest_to_vtkUnstructured.hxx \ src/t8_forest/t8_forest_iterate.h src/t8_forest/t8_forest_partition.h libt8_installed_headers_geometry = \ src/t8_geometry/t8_geometry.h \ diff --git a/src/t8_forest/t8_forest_vtk_API.hxx b/src/t8_forest/t8_forest_to_vtkUnstructured.hxx similarity index 61% rename from src/t8_forest/t8_forest_vtk_API.hxx rename to src/t8_forest/t8_forest_to_vtkUnstructured.hxx index f9da3c4f77..b8832fde90 100644 --- a/src/t8_forest/t8_forest_vtk_API.hxx +++ b/src/t8_forest/t8_forest_to_vtkUnstructured.hxx @@ -68,38 +68,6 @@ void t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, *data); #endif -/** Write the forest in .pvtu file format. Writes one .vtu file per - * process and a meta .pvtu file. - * This function uses the vtk library. t8code must be configured with - * "--with-vtk" in order to use it. - * Currently does not support pyramid elements. - * \param [in] forest The forest. - * \param [in] fileprefix The prefix of the output files. The meta file will be named \a fileprefix.pvtu . - * \param [in] write_treeid If true, the global tree id is written for each element. - * \param [in] write_mpirank If true, the mpirank is written for each element. - * \param [in] write_level If true, the refinement level is written for each element. - * \param [in] write_element_id If true, the global element id is written for each element. - * \param [in] curved_flag If true, write the elements as curved element types from vtk. - * \param [in] num_data Number of user defined double valued data fields to write. - * \param [in] data Array of t8_vtk_data_field_t of length \a num_data - * providing the user defined per element data. - * If scalar and vector fields are used, all scalar fields - * must come first in the array. - * \return True if successful, false if not (process local). - * \note If t8code was not configured with vtk, use \ref t8_forest_vtk_write_file - */ -int t8_forest_vtk_write_file_via_API (t8_forest_t forest, - const char *fileprefix, - const int write_treeid, - const int write_mpirank, - const int write_level, - const int - write_element_id, - const int curved_flag, - const int num_data, - t8_vtk_data_field_t - *data); - T8_EXTERN_C_END (); #endif /* T8_FOREST_VTK_API_HXX */ diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index 38e7e97418..c78a4b2ee8 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -20,7 +20,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include +#include #include #include #include diff --git a/src/t8_forest/t8_forest_vtk.h b/src/t8_forest/t8_forest_vtk.h index 187b076516..9225f7ef93 100644 --- a/src/t8_forest/t8_forest_vtk.h +++ b/src/t8_forest/t8_forest_vtk.h @@ -34,6 +34,38 @@ T8_EXTERN_C_BEGIN (); /* function declarations */ +/** Write the forest in .pvtu file format. Writes one .vtu file per + * process and a meta .pvtu file. + * This function uses the vtk library. t8code must be configured with + * "--with-vtk" in order to use it. + * Currently does not support pyramid elements. + * \param [in] forest The forest. + * \param [in] fileprefix The prefix of the output files. The meta file will be named \a fileprefix.pvtu . + * \param [in] write_treeid If true, the global tree id is written for each element. + * \param [in] write_mpirank If true, the mpirank is written for each element. + * \param [in] write_level If true, the refinement level is written for each element. + * \param [in] write_element_id If true, the global element id is written for each element. + * \param [in] curved_flag If true, write the elements as curved element types from vtk. + * \param [in] num_data Number of user defined double valued data fields to write. + * \param [in] data Array of t8_vtk_data_field_t of length \a num_data + * providing the user defined per element data. + * If scalar and vector fields are used, all scalar fields + * must come first in the array. + * \return True if successful, false if not (process local). + * \note If t8code was not configured with vtk, use \ref t8_forest_vtk_write_file + */ +int t8_forest_vtk_write_file_via_API (t8_forest_t forest, + const char *fileprefix, + const int write_treeid, + const int write_mpirank, + const int write_level, + const int + write_element_id, + const int curved_flag, + const int num_data, + t8_vtk_data_field_t + *data); + /** Write the forest in .pvtu file format. Writes one .vtu file per * process and a meta .pvtu file. * This function writes ASCII files and can be used when From d273dfe7c1940b57ee6c3d2903e4ec2368447f3b Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 5 Apr 2023 13:57:16 +0200 Subject: [PATCH 057/255] implementation of element ref coords for tri and tet --- .../t8_default_tet/t8_default_tet_cxx.cxx | 9 ++- .../t8_default/t8_default_tet/t8_dtet_bits.h | 19 ++++- .../t8_default_tet/t8_dtri_to_dtet.h | 3 +- .../t8_default_tri/t8_default_tri_cxx.cxx | 8 +- .../t8_default/t8_default_tri/t8_dtri_bits.c | 78 ++++++++++++++++++- .../t8_default/t8_default_tri/t8_dtri_bits.h | 19 ++++- 6 files changed, 121 insertions(+), 15 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx index 40d5e26c51..30ad973b69 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx @@ -551,7 +551,8 @@ t8_default_scheme_tet_c::t8_element_vertex_reference_coords (const const { T8_ASSERT (t8_element_is_valid (t)); - t8_dtet_compute_ref_coords ((const t8_default_tet_t *) t, vertex, coords); + t8_dtet_compute_vertex_ref_coords ((const t8_default_tet_t *) t, vertex, + coords); } void @@ -559,10 +560,12 @@ t8_default_scheme_tet_c::t8_element_reference_coords (const t8_element_t *t, const double *ref_coords, const void *user_data, - double *coords_out) + double *out_coords) const { - SC_ABORTF ("Not implemented\n"); + T8_ASSERT (t8_element_is_valid (t)); + t8_dtet_compute_reference_coords ((const t8_dtet_t *) t, ref_coords, + out_coords); } /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h b/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h index b31b47530c..3ac4e91f22 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h @@ -51,9 +51,22 @@ void t8_dtet_compute_coords (const t8_dtet_t *t, int vertex, * \param [out] coordinates An array of 3 double that * will be filled with the reference coordinates of the vertex. */ -void t8_dtet_compute_ref_coords (const t8_dtet_t *t, - int vertex, - double coordinates[3]); +void t8_dtet_compute_vertex_ref_coords (const t8_dtet_t *t, + int vertex, + double coordinates[3]); + +/** Convert a point in the reference space of a tetrahedron to a point in the + * reference space of the tree (level 0 tetrahedron) embedded in [0,1]^2. + * \param [in] t Input tetrahedron. + * \param [in] ref_coords The reference coordinates inside the + * tet element [0,1]^2 + * \param [out] out_coords An array of 3 doubles that will be filled with the + * reference coordinates in the tree of the tet. + */ +void t8_dtet_compute_reference_coords (const t8_dtet_t *t, + const double + *ref_coords, + double out_coords[3]); /** Compute the coordinates of the four vertices of a tetrahedron. * \param [in] t Input tetrahedron. diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_dtri_to_dtet.h b/src/t8_schemes/t8_default/t8_default_tet/t8_dtri_to_dtet.h index 6a2c687e3c..1dea179b30 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_dtri_to_dtet.h +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_dtri_to_dtet.h @@ -72,7 +72,8 @@ T8_EXTERN_C_BEGIN (); #define t8_dtri_ancestor t8_dtet_ancestor #define t8_dtri_compute_all_coords t8_dtet_compute_all_coords #define t8_dtri_compute_coords t8_dtet_compute_coords -#define t8_dtri_compute_ref_coords t8_dtet_compute_ref_coords +#define t8_dtri_compute_vertex_ref_coords t8_dtet_compute_vertex_ref_coords +#define t8_dtri_compute_reference_coords t8_dtet_compute_reference_coords #define t8_dtri_child t8_dtet_child #define t8_dtri_childrenpv t8_dtet_childrenpv #define t8_dtri_is_familypv t8_dtet_is_familypv diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx index e420fc9fbb..78e408ba56 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx @@ -570,7 +570,7 @@ t8_default_scheme_tri_c::t8_element_vertex_reference_coords (const const { T8_ASSERT (t8_element_is_valid (t)); - t8_dtri_compute_ref_coords ((const t8_dtri_t *) t, vertex, coords); + t8_dtri_compute_vertex_ref_coords ((const t8_dtri_t *) t, vertex, coords); } void @@ -578,10 +578,12 @@ t8_default_scheme_tri_c::t8_element_reference_coords (const t8_element_t *t, const double *ref_coords, const void *user_data, - double *coords_out) + double *out_coords) const { - SC_ABORTF ("Not implemented\n"); + T8_ASSERT (t8_element_is_valid (t)); + t8_dtri_compute_reference_coords ((const t8_dtri_t *) t, ref_coords, + out_coords); } int diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c index 05a8db2c50..b16cdac24c 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c @@ -336,8 +336,8 @@ t8_dtri_compute_coords (const t8_dtri_t *t, const int vertex, } void -t8_dtri_compute_ref_coords (const t8_dtri_t *t, const int vertex, - double coordinates[T8_DTRI_DIM]) +t8_dtri_compute_vertex_ref_coords (const t8_dtri_t *t, const int vertex, + double coordinates[T8_DTRI_DIM]) { int coords_int[T8_DTRI_DIM]; T8_ASSERT (0 <= vertex && vertex < T8_DTRI_CORNERS); @@ -353,6 +353,80 @@ t8_dtri_compute_ref_coords (const t8_dtri_t *t, const int vertex, #endif } +void +t8_dtri_compute_reference_coords (const t8_dtri_t *t, + const double *ref_coords, + double out_coords[T8_DTRI_DIM]) +{ + /* Calculate the reference coordinates of a triangle/tetrahedron in + * relation to its orientation. Orientations are described here: + * https://doi.org/10.1137/15M1040049 + * 1---------------------2 + * | orientation / 2 + * | 1 / / | + * | / / | + * | / / | + * | / / | + * | / / | + * | / / | + * | / / | + * | / / orientation | + * | / / 0 | + * 0 / | + * 0--------------------1 + * + * y + * ^ + * | + * z--> x + */ + T8_ASSERT (ref_coords != NULL); + + t8_dtri_type_t type; +#ifdef T8_DTRI_TO_DTET + int tet_orientation; +#endif + t8_dtri_coord_t h; + + type = t->type; + h = T8_DTRI_LEN (t->level); +#ifndef T8_DTRI_TO_DTET + const int tri_orientation = type; +#else + /* These integers define the sequence, in which the ref_coords are added + * to the out_coords */ + const int tet_orientation0 = type / 2; + const int tet_orientation1 = + (tri_orientation + ((type % 2 == 0) ? 1 : 2)) % 3; + const int tet_orientation2 = + (tri_orientation + ((type % 2 == 0) ? 2 : 1)) % 3; +#endif + + out_coords[0] = t->x; + out_coords[1] = t->y; +#ifdef T8_DTRI_TO_DTET + out_coords[2] = t->z; +#endif +#ifndef T8_DTRI_TO_DTET + out_coords[tri_orientation] += h * ref_coords[0]; + out_coords[1 - tri_orientation] += h * ref_coords[1]; +#else + out_coords[tet_orientation0] += h * ref_coords[0]; + out_coords[tet_orientation1] += h * ref_coords[1]; + out_coords[tet_orientation2] += h * ref_coords[2]; + + /* done 3D */ +#endif + /* Since the integer coordinates are coordinates w.r.t to + * the embedding into [0,T8_DTRI_ROOT_LEN]^d, we just need + * to divide them by the root length. */ + out_coords[0] = out_coords[0] / (double) T8_DTRI_ROOT_LEN; + out_coords[1] = out_coords[1] / (double) T8_DTRI_ROOT_LEN; +#ifdef T8_DTRI_TO_DTET + out_coords[2] = out_coords[2] / (double) T8_DTRI_ROOT_LEN; +#endif +} + /* Compute the coordinates of each vertex of a triangle/tet */ void t8_dtri_compute_all_coords (const t8_dtri_t *t, diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h index 0676ed9aa4..b228d2b842 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h @@ -83,9 +83,22 @@ void t8_dtri_compute_coords (const t8_dtri_t *t, * \param [out] coordinates An array of 2 double that * will be filled with the reference coordinates of the vertex. */ -void t8_dtri_compute_ref_coords (const t8_dtri_t *t, - const int vertex, - double coordinates[2]); +void t8_dtri_compute_vertex_ref_coords (const t8_dtri_t *t, + const int vertex, + double coordinates[2]); + +/** Convert a point in the reference space of a triangle to a point in the + * reference space of the tree (level 0 triangle) embedded in [0,1]^2. + * \param [in] t Input triangle. + * \param [in] ref_coords The reference coordinates inside the + * triangle element [0,1]^2 + * \param [out] out_coords An array of 2 doubles that will be filled with the + * reference coordinates in the tree of the triangle. + */ +void t8_dtri_compute_reference_coords (const t8_dtri_t *t, + const double + *ref_coords, + double out_coords[2]); /** Compute the coordinates of the four vertices of a triangle. * \param [in] t Input triangle. From c5441e3d6c141eeac849bfaf04f597ad38e43186 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 5 Apr 2023 14:12:43 +0200 Subject: [PATCH 058/255] added reference coords for curved vtk tris and tets --- src/t8_forest/t8_forest_vtk.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index df5d7b9c91..3dee0e1b3c 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -169,14 +169,14 @@ const double {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} }, { /* T8_ECLASS_TRIANGLE */ - {0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, - {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {0.5, 0, 0}, {1, 0.5, 0}, + {0.5, 0.5, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} }, { /* T8_ECLASS_TET */ - {0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, - {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {0, 0, 0}, {1, 0, 0}, {1, 1, 1}, {1, 0, 1}, {0.5, 0, 0}, + {1, 0.5, 0.5}, {0.5, 0.5, 0.5}, {0.5, 0, 0.5}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} }, From 49c5307f38492f9e720e9c245f22ba2000584734 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 5 Apr 2023 14:16:05 +0200 Subject: [PATCH 059/255] removed redundant linear vtk reference coords --- src/t8_forest/t8_forest_vtk.cxx | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index 3dee0e1b3c..de38338188 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -134,21 +134,12 @@ const int t8_curved_eclass_num_nodes[T8_ECLASS_COUNT] = const int t8_curved_eclass_vtk_type[T8_ECLASS_COUNT] = { 1, 21, 23, 22, 25, 24, 26, 27 }; -/** Map element corners to element reference coordinates */ +/** Map vtk element corners to element reference coordinates. The reference + * coordinates are defined in such a way, that the linear vtk corners are listed + * first and then the curved coords. This way, this array can be used for linear + * vtk elements as well as quadratic vtk elements. + */ const double t8_forest_vtk_point_to_element_ref_coords[T8_ECLASS_COUNT] - [T8_ECLASS_MAX_CORNERS][3] = { - {{0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}}, /* T8_ECLASS_VERTEX */ - {{0, 0, 0}, {1, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}}, /* T8_ECLASS_LINE */ - {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}}, /* T8_ECLASS_QUAD */ - {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}}, /* T8_ECLASS_TRIANGLE */ - {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}}, /* T8_ECLASS_TET */ - {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 1, 0}, {1, 0, 1}, {0, 1, 1}, {1, 1, 1}}, /* T8_ECLASS_HEX */ - {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 1, 0}, {1, 0, 1}, {-1, -1, -1}, {-1, -1, -1}}, /* T8_ECLASS_PRISM */ - {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 1, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}} /* T8_ECLASS_PYRAMID */ -}; - -const double - t8_forest_vtk_point_to_quadratic_element_ref_coords[T8_ECLASS_COUNT] [T8_FOREST_VTK_QUADRATIC_ELEMENT_MAX_CORNERS][3] = { { /* T8_ECLASS_VERTEX */ {0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, @@ -230,7 +221,7 @@ t8_forest_vtk_get_element_nodes (t8_forest_t forest, t8_locidx_t ltreeid, t8_forest_get_eclass_scheme (forest, tree_class); const t8_element_shape_t element_shape = scheme->t8_element_shape (element); const double *ref_coords = - t8_forest_vtk_point_to_quadratic_element_ref_coords[element_shape] + t8_forest_vtk_point_to_element_ref_coords[element_shape] [vertex]; t8_forest_element_from_ref_coords (forest, ltreeid, element, ref_coords, out_coords, stretch_factors); From 6f21f4ab79a98e55b594e93039bb871d1459dfca Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 5 Apr 2023 14:19:46 +0200 Subject: [PATCH 060/255] bugfix --- src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c index b16cdac24c..59cdeeeac0 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c @@ -383,9 +383,6 @@ t8_dtri_compute_reference_coords (const t8_dtri_t *t, T8_ASSERT (ref_coords != NULL); t8_dtri_type_t type; -#ifdef T8_DTRI_TO_DTET - int tet_orientation; -#endif t8_dtri_coord_t h; type = t->type; @@ -397,9 +394,9 @@ t8_dtri_compute_reference_coords (const t8_dtri_t *t, * to the out_coords */ const int tet_orientation0 = type / 2; const int tet_orientation1 = - (tri_orientation + ((type % 2 == 0) ? 1 : 2)) % 3; + (tet_orientation0 + ((type % 2 == 0) ? 1 : 2)) % 3; const int tet_orientation2 = - (tri_orientation + ((type % 2 == 0) ? 2 : 1)) % 3; + (tet_orientation0 + ((type % 2 == 0) ? 2 : 1)) % 3; #endif out_coords[0] = t->x; From 07dc3133694cdf438b0daedd5b35957fda43347e Mon Sep 17 00:00:00 2001 From: Knapp Date: Wed, 5 Apr 2023 16:56:10 +0200 Subject: [PATCH 061/255] Bug-fix --- src/t8_forest/t8_forest_vtk.cxx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index c78a4b2ee8..7c166b4e65 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -488,7 +488,7 @@ t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, long int point_id = 0; /* The id of the point in the points Object. */ double coordinates[3]; double vertex_coords[3] = { 0, 0, 0 }; - t8_gloidx_t elem_id = 0; + t8_gloidx_t elem_id = t8_forest_get_first_local_element_id (forest); /* Since we want to use different element types and a points Array and cellArray * we have to declare these vtk objects. The cellArray stores the Elements. @@ -551,6 +551,7 @@ t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, dataArrays = T8_ALLOC (vtkDoubleArray *, num_data); t8_cmesh_t cmesh = t8_forest_get_cmesh (forest); + /* We iterate over all local trees*/ for (t8_locidx_t itree = 0; itree < t8_forest_get_num_local_trees (forest); itree++) { @@ -565,8 +566,6 @@ t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, itree)); const t8_locidx_t elems_in_tree = t8_forest_get_tree_num_elements (forest, itree); - const t8_locidx_t offset = - t8_forest_get_tree_element_offset (forest, itree); /* We iterate over all elements in the tree */ /* Compute the global tree id */ const t8_gloidx_t gtreeid = t8_forest_global_tree_id (forest, itree); @@ -695,9 +694,7 @@ t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, vtk_level->InsertNextValue (scheme->t8_element_level (element)); } if (write_element_id == 1) { - vtk_element_id->InsertNextValue (elem_id + offset + - t8_forest_get_first_local_element_id - (forest)); + vtk_element_id->InsertNextValue (elem_id); } /* *INDENT-ON* */ elem_id++; From 43fd7a7916d265faaa3df8100e540951bf440388 Mon Sep 17 00:00:00 2001 From: Knapp Date: Wed, 5 Apr 2023 17:43:11 +0200 Subject: [PATCH 062/255] Use vtkSmartPointers --- src/t8_forest/t8_forest_vtk.cxx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index 7c166b4e65..a96e079aba 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -534,12 +534,14 @@ t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, * metadata if wanted. */ - t8_vtk_gloidx_array_type_t *vtk_treeid = t8_vtk_gloidx_array_type_t::New (); - t8_vtk_gloidx_array_type_t *vtk_mpirank = - t8_vtk_gloidx_array_type_t::New (); - t8_vtk_gloidx_array_type_t *vtk_level = t8_vtk_gloidx_array_type_t::New (); - t8_vtk_gloidx_array_type_t *vtk_element_id = - t8_vtk_gloidx_array_type_t::New (); + vtkSmartPointer < t8_vtk_gloidx_array_type_t > vtk_treeid = + vtkSmartPointer < t8_vtk_gloidx_array_type_t >::New (); + vtkSmartPointer < t8_vtk_gloidx_array_type_t > vtk_mpirank = + vtkSmartPointer < t8_vtk_gloidx_array_type_t >::New (); + vtkSmartPointer < t8_vtk_gloidx_array_type_t > vtk_level = + vtkSmartPointer < t8_vtk_gloidx_array_type_t >::New (); + vtkSmartPointer < t8_vtk_gloidx_array_type_t > vtk_element_id = + vtkSmartPointer < t8_vtk_gloidx_array_type_t >::New (); /* * We need the dataArray for writing double valued user defined data in the vtu files. @@ -745,10 +747,6 @@ t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, } /* We have to free the allocated memory for the cellTypes Array and the other arrays we allocated memory for. */ - vtk_treeid->Delete (); - vtk_mpirank->Delete (); - vtk_level->Delete (); - vtk_element_id->Delete (); for (int idata = 0; idata < num_data; idata++) { dataArrays[idata]->Delete (); } From b69fca3ed4a0204e953ecc8a3e4503bbd8c581a2 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 5 Apr 2023 17:56:24 +0200 Subject: [PATCH 063/255] fixed tet and triangle ref coords --- src/t8_forest/t8_forest_vtk.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index de38338188..049022924d 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -160,23 +160,23 @@ const double t8_forest_vtk_point_to_element_ref_coords[T8_ECLASS_COUNT] {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} }, { /* T8_ECLASS_TRIANGLE */ - {0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {0.5, 0, 0}, {1, 0.5, 0}, + {0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {0, 0.5, 0}, {0.5, 1, 0}, {0.5, 0.5, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} }, - { /* T8_ECLASS_TET */ - {0, 0, 0}, {1, 0, 0}, {1, 1, 1}, {1, 0, 1}, {0.5, 0, 0}, - {1, 0.5, 0.5}, {0.5, 0.5, 0.5}, {0.5, 0, 0.5}, {-1, -1, -1}, {-1, -1, -1}, - {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, - {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} - }, { /* T8_ECLASS_HEX */ {0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} }, + { /* T8_ECLASS_TET */ + {0, 0, 0}, {1, 0, 0}, {1, 1, 1}, {1, 0, 1}, {0.5, 0, 0}, + {1, 0.5, 0.5}, {0.5, 0.5, 0.5}, {0.5, 0, 0.5}, {1, 0, 0.5}, {1, 0.5, 1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} + }, { /* T8_ECLASS_PRISM */ {0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, From 2513098abecd8b10e0d46498431ba856313a8fa7 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 5 Apr 2023 17:56:43 +0200 Subject: [PATCH 064/255] bugfix --- src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c index 59cdeeeac0..e303806b69 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c @@ -405,8 +405,8 @@ t8_dtri_compute_reference_coords (const t8_dtri_t *t, out_coords[2] = t->z; #endif #ifndef T8_DTRI_TO_DTET - out_coords[tri_orientation] += h * ref_coords[0]; - out_coords[1 - tri_orientation] += h * ref_coords[1]; + out_coords[tri_orientation] += h * ref_coords[1]; + out_coords[1 - tri_orientation] += h * ref_coords[0]; #else out_coords[tet_orientation0] += h * ref_coords[0]; out_coords[tet_orientation1] += h * ref_coords[1]; From dabc9a266224a0e273793794041659d21ad11ee9 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Sat, 8 Apr 2023 11:38:29 +0200 Subject: [PATCH 065/255] implemented hex element reference coords --- src/t8_forest/t8_forest_vtk.cxx | 8 ++++---- .../t8_default_hex/t8_default_hex_cxx.cxx | 20 +++++++++++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index 049022924d..4b5fe91761 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -166,10 +166,10 @@ const double t8_forest_vtk_point_to_element_ref_coords[T8_ECLASS_COUNT] {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} }, { /* T8_ECLASS_HEX */ - {0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, - {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, - {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, - {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} + {0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}, {0, 0, 1}, + {1, 0, 1}, {1, 1, 1}, {0, 1, 1}, {0.5, 0, 0}, {1, 0.5, 0}, + {0.5, 1, 0}, {0, 0.5, 0}, {0.5, 0, 1}, {1, 0.5, 1}, {0.5, 1, 1}, + {0, 0.5, 1}, {0, 0, 0.5}, {1, 0, 0.5}, {1, 1, 0.5}, {0, 1, 0.5} }, { /* T8_ECLASS_TET */ {0, 0, 0}, {1, 0, 0}, {1, 1, 1}, {1, 0, 1}, {0.5, 0, 0}, diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx index 0e50084285..120dbef2e8 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx @@ -661,10 +661,26 @@ t8_default_scheme_hex_c::t8_element_reference_coords (const t8_element_t *t, const double *ref_coords, const void *user_data, - double *coords_out) + double *out_coords) const { - SC_ABORTF ("Not implemented\n"); + T8_ASSERT (t8_element_is_valid (t)); + const p8est_quadrant_t *q1 = (const p8est_quadrant_t *) t; + + /* Get the length of the quadrant */ + const int len = P8EST_QUADRANT_LEN (q1->level); + + /* Compute the x, y and z coordinates of the point depending on the + * reference coordinates */ + out_coords[0] = q1->x + ref_coords[0] * len; + out_coords[1] = q1->y + ref_coords[1] * len; + out_coords[2] = q1->z + ref_coords[2] * len; + + /* We divide the integer coordinates by the root length of the hex + * to obtain the reference coordinates. */ + out_coords[0] = out_coords[0] / (double) P8EST_ROOT_LEN; + out_coords[1] = out_coords[1] / (double) P8EST_ROOT_LEN; + out_coords[2] = out_coords[2] / (double) P8EST_ROOT_LEN; } int From a5d6f720c011a3931e694fa5cc4397cc0f259ebb Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Sat, 8 Apr 2023 12:44:45 +0200 Subject: [PATCH 066/255] refractoring --- .../t8_default_hex/t8_default_hex_cxx.cxx | 20 +++-- .../t8_default_hex/t8_default_hex_cxx.hxx | 12 +-- .../t8_default_line/t8_default_line_cxx.cxx | 21 +++-- .../t8_default_line/t8_default_line_cxx.hxx | 20 ++--- .../t8_default_line/t8_dline_bits.c | 6 +- .../t8_default_line/t8_dline_bits.h | 10 +-- .../t8_default_prism/t8_default_prism_cxx.cxx | 5 +- .../t8_default_prism/t8_default_prism_cxx.hxx | 8 +- .../t8_default_prism/t8_dprism_bits.c | 12 +-- .../t8_default_prism/t8_dprism_bits.h | 28 ++++-- .../t8_default_pyramid_cxx.cxx | 2 +- .../t8_default_pyramid_cxx.hxx | 10 +-- .../t8_default_quad/t8_default_quad_cxx.cxx | 20 +++-- .../t8_default_quad/t8_default_quad_cxx.hxx | 16 ++-- .../t8_default_tet/t8_default_tet_cxx.cxx | 20 +++-- .../t8_default_tet/t8_default_tet_cxx.hxx | 16 ++-- .../t8_default/t8_default_tet/t8_dtet_bits.h | 20 ++--- .../t8_default_tri/t8_default_tri_cxx.cxx | 21 +++-- .../t8_default_tri/t8_default_tri_cxx.hxx | 14 +-- .../t8_default/t8_default_tri/t8_dtri_bits.c | 86 ++++++++++++++----- .../t8_default/t8_default_tri/t8_dtri_bits.h | 26 +++--- .../t8_default_vertex_cxx.cxx | 10 +-- .../t8_default_vertex_cxx.hxx | 14 +-- .../t8_default_vertex/t8_dvertex_bits.h | 3 +- 24 files changed, 246 insertions(+), 174 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx index 120dbef2e8..b2552ea0a6 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx @@ -618,14 +618,14 @@ t8_default_scheme_hex_c::t8_element_root_len (const t8_element_t *elem) const } void -t8_default_scheme_hex_c::t8_element_vertex_coords (const t8_element_t *t, +t8_default_scheme_hex_c::t8_element_vertex_coords (const t8_element_t *elem, int vertex, int coords[]) const { - const p8est_quadrant_t *q1 = (const p8est_quadrant_t *) t; + const p8est_quadrant_t *q1 = (const p8est_quadrant_t *) elem; int len; - T8_ASSERT (t8_element_is_valid (t)); + T8_ASSERT (t8_element_is_valid (elem)); T8_ASSERT (0 <= vertex && vertex < 8); /* Get the length of the quadrant */ len = P8EST_QUADRANT_LEN (q1->level); @@ -638,16 +638,17 @@ t8_default_scheme_hex_c::t8_element_vertex_coords (const t8_element_t *t, void t8_default_scheme_hex_c::t8_element_vertex_reference_coords (const - t8_element_t *t, + t8_element_t + *elem, const int vertex, double coords[]) const { - T8_ASSERT (t8_element_is_valid (t)); + T8_ASSERT (t8_element_is_valid (elem)); T8_ASSERT (0 <= vertex && vertex < 8); int coords_int[3]; - t8_element_vertex_coords (t, vertex, coords_int); + t8_element_vertex_coords (elem, vertex, coords_int); /* We divide the integer coordinates by the root length of the hex * to obtain the reference coordinates. */ @@ -657,15 +658,16 @@ t8_default_scheme_hex_c::t8_element_vertex_reference_coords (const } void -t8_default_scheme_hex_c::t8_element_reference_coords (const t8_element_t *t, +t8_default_scheme_hex_c::t8_element_reference_coords (const t8_element_t + *elem, const double *ref_coords, const void *user_data, double *out_coords) const { - T8_ASSERT (t8_element_is_valid (t)); - const p8est_quadrant_t *q1 = (const p8est_quadrant_t *) t; + T8_ASSERT (t8_element_is_valid (elem)); + const p8est_quadrant_t *q1 = (const p8est_quadrant_t *) elem; /* Get the length of the quadrant */ const int len = P8EST_QUADRANT_LEN (q1->level); diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx index b3c8675561..7477e25c0f 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx @@ -545,24 +545,24 @@ public: * elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and * L the maximum refinement level. * All element vertices have integer coordinates in this cube. - * \param [in] t The element to be considered. + * \param [in] elem The element to be considered. * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many integers as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ - virtual void t8_element_vertex_coords (const t8_element_t *t, + virtual void t8_element_vertex_coords (const t8_element_t *elem, int vertex, int coords[]) const; /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). - * \param [in] t The element to be considered. + * \param [in] elem The element to be considered. * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many doubles as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ virtual void t8_element_vertex_reference_coords (const t8_element_t - *t, + *elem, const int vertex, double coords[]) const; @@ -570,12 +570,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] coords_out The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx index 6b38a6caad..263bd41bd3 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx @@ -346,37 +346,40 @@ t8_default_scheme_line_c::t8_element_last_descendant (const t8_element_t } void -t8_default_scheme_line_c::t8_element_vertex_coords (const t8_element_t *t, +t8_default_scheme_line_c::t8_element_vertex_coords (const t8_element_t *elem, int vertex, int coords[]) const { - T8_ASSERT (t8_element_is_valid (t)); - t8_dline_vertex_coords ((const t8_dline_t *) t, vertex, coords); + T8_ASSERT (t8_element_is_valid (elem)); + t8_dline_vertex_coords ((const t8_dline_t *) elem, vertex, coords); } void t8_default_scheme_line_c::t8_element_vertex_reference_coords (const - t8_element_t *t, + t8_element_t + *elem, const int vertex, double coords[]) const { - T8_ASSERT (t8_element_is_valid (t)); - t8_dline_vertex_ref_coords ((const t8_dline_t *) t, vertex, coords); + T8_ASSERT (t8_element_is_valid (elem)); + t8_dline_vertex_ref_coords ((const t8_dline_t *) elem, vertex, coords); } void -t8_default_scheme_line_c::t8_element_reference_coords (const t8_element_t *t, +t8_default_scheme_line_c::t8_element_reference_coords (const t8_element_t + *elem, const double *ref_coords, const void *user_data, double *out_coords) const { - T8_ASSERT (t8_element_is_valid (t)); + T8_ASSERT (t8_element_is_valid (elem)); T8_ASSERT (ref_coords != NULL); - t8_dline_reference_coords ((const t8_dline_t *) t, ref_coords, out_coords); + t8_dline_reference_coords ((const t8_dline_t *) elem, ref_coords, + out_coords); } int diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx index 3be2d057ee..6973ede127 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx @@ -565,24 +565,24 @@ public: * elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and * L the maximum refinement level. * All element vertices have integer coordinates in this cube. - * \param [in] t The element to be considered. - * \param [in] vertex The id of the vertex whose coordinates shall be computed. + * \param [in] elem The element to be considered. + * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many integers as the element's dimension - * whose entries will be filled with the coordinates of \a vertex. + * whose entries will be filled with the coordinates of \a vertex. */ - virtual void t8_element_vertex_coords (const t8_element_t *t, + virtual void t8_element_vertex_coords (const t8_element_t *elem, int vertex, int coords[]) const; /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). - * \param [in] t The element to be considered. - * \param [in] vertex The id of the vertex whose coordinates shall be computed. + * \param [in] elem The element to be considered. + * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many doubles as the element's dimension - * whose entries will be filled with the coordinates of \a vertex. + * whose entries will be filled with the coordinates of \a vertex. */ virtual void t8_element_vertex_reference_coords (const t8_element_t - *t, + *elem, const int vertex, double coords[]) const; @@ -590,12 +590,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] coords_out The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c index 8c244322c8..e62f7dd89a 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c +++ b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c @@ -350,11 +350,11 @@ t8_dline_vertex_ref_coords (const t8_dline_t *elem, const int vertex, } void -t8_dline_reference_coords (const t8_dline_t *t, const double *ref_coords, +t8_dline_reference_coords (const t8_dline_t *elem, const double *ref_coords, double *out_coords) { - out_coords[0] = t->x; - out_coords[0] += T8_DLINE_LEN (t->level) * ref_coords[0]; + out_coords[0] = elem->x; + out_coords[0] += T8_DLINE_LEN (elem->level) * ref_coords[0]; } t8_linearidx_t diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h index 26889434ee..3889cf3c63 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h +++ b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h @@ -242,15 +242,15 @@ void t8_dline_vertex_ref_coords (const t8_dline_t *elem, const int vertex, double coordinates[1]); -/** Compute the coordinates of an arbitrary point ([0, 1]^1) on a line when the - * tree (level 0 line) is embedded in [0,1]^1. - * \param [in] t Input line. - * \param [in] ref_coords The referenc coordinate on the line [0, 1]^1 +/** Convert a point in the reference space of a line element to a point in the + * reference space of the tree (level 0) embedded in [0,1]^1. + * \param [in] elem Input line. + * \param [in] ref_coords The reference coordinate on the line [0, 1]^1 * \param [out] out_coords An array of 1 double that * will be filled with the reference coordinates * of the point on the line. */ -void t8_dline_reference_coords (const t8_dline_t *t, +void t8_dline_reference_coords (const t8_dline_t *elem, const double *ref_coords, double *out_coords); diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx index 57ac8aece6..d45d39a2c9 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx @@ -481,11 +481,12 @@ t8_default_scheme_prism_c::t8_element_vertex_reference_coords (const } void -t8_default_scheme_prism_c::t8_element_reference_coords (const t8_element_t *t, +t8_default_scheme_prism_c::t8_element_reference_coords (const t8_element_t + *elem, const double *ref_coords, const void *user_data, - double *coords_out) + double *out_coords) const { SC_ABORTF ("Not implemented\n"); diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx index 4a9d88cbff..0903a2d7af 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx @@ -585,13 +585,13 @@ public: /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). - * \param [in] t The element to be considered. + * \param [in] elem The element to be considered. * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many doubles as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ virtual void t8_element_vertex_reference_coords (const t8_element_t - *t, + *elem, const int vertex, double coords[]) const; @@ -599,12 +599,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] coords_out The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c index af351aafd8..a28d6e7d12 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c @@ -550,29 +550,29 @@ t8_dprism_corner_descendant (const t8_dprism_t *p, t8_dprism_t *s, } void -t8_dprism_vertex_coords (const t8_dprism_t *p, const int vertex, +t8_dprism_vertex_coords (const t8_dprism_t *elem, const int vertex, int coords[3]) { T8_ASSERT (vertex >= 0 && vertex < 6); - T8_ASSERT (p->line.level == p->tri.level); + T8_ASSERT (elem->line.level == elem->tri.level); /*Compute x and y coordinate */ - t8_dtri_compute_coords (&p->tri, vertex % 3, coords); + t8_dtri_compute_coords (&elem->tri, vertex % 3, coords); /*Compute z coordinatecoords[0] *= T8_DPRISM_ROOT_BY_DTRI_ROOT; */ - t8_dline_vertex_coords (&p->line, vertex / 3, &coords[2]); + t8_dline_vertex_coords (&elem->line, vertex / 3, &coords[2]); coords[0] /= T8_DPRISM_ROOT_BY_DTRI_ROOT; coords[1] /= T8_DPRISM_ROOT_BY_DTRI_ROOT; coords[2] /= T8_DPRISM_ROOT_BY_DLINE_ROOT; } void -t8_dprism_vertex_ref_coords (const t8_dprism_t *p, const int vertex, +t8_dprism_vertex_ref_coords (const t8_dprism_t *elem, const int vertex, double coords[3]) { int coords_int[3]; T8_ASSERT (vertex >= 0 && vertex < 6); /* Compute the integere coordinates in [0, root_len]^3 */ - t8_dprism_vertex_coords (p, vertex, coords_int); + t8_dprism_vertex_coords (elem, vertex, coords_int); /* Divide by the root length. */ coords[0] = coords_int[0] / (double) T8_DPRISM_ROOT_LEN; diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.h b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.h index ac0d5bf206..09f7629199 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.h +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.h @@ -296,25 +296,39 @@ void t8_dprism_corner_descendant (const t8_dprism_t *p, int level); /** Compute the coordinates of a vertex of a prism. - * \param [in] p Input prism. - * \param [in] vertex The number of the vertex. + * \param [in] elem Input prism. + * \param [in] vertex The number of the vertex. * \param [out] coordinates An array of 3 t8_dprism_coord_t that * will be filled with the coordinates of the vertex. */ -void t8_dprism_vertex_coords (const t8_dprism_t *p, +void t8_dprism_vertex_coords (const t8_dprism_t *elem, int vertex, int coords[3]); /** Compute the reference coordinates of a vertex of a prism when the - * tree (level 0 prism) is embedded in [0,1]^3. - * \param [in] p Input prism. - * \param [in] vertex The number of the vertex. + * tree (level 0) is embedded in [0,1]^3. + * \param [in] elem Input prism. + * \param [in] vertex The number of the vertex. * \param [out] coordinates An array of 3 double that * will be filled with the reference coordinates of the vertex. */ -void t8_dprism_vertex_ref_coords (const t8_dprism_t *p, +void t8_dprism_vertex_ref_coords (const t8_dprism_t *elem, int vertex, double coords[3]); +/** Convert a point in the reference space of a prism element to a point in the + * reference space of the tree (level 0) embedded in [0,1]^3. + * \param [in] elem Input prism. + * \param [in] ref_coords The reference coordinates inside the + * prism element [0,1]^3 + * \param [out] out_coords An array of 3 doubles that will be filled with the + * reference coordinates in the tree of the prism. + */ +void t8_dprism_compute_reference_coords (const t8_dprism_t + *elem, + const double + *ref_coords, + double *out_coords); + /** Computes the linear position of a prism in an uniform grid. * \param [in] p Prism whose id will be computed. * \return Returns the linear position of this prism on a grid. diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx index d33625fbed..4aee0f70b3 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx @@ -477,7 +477,7 @@ t8_default_scheme_pyramid_c::t8_element_vertex_reference_coords (const void t8_default_scheme_pyramid_c::t8_element_reference_coords (const t8_element_t - *t, + *elem, const double *ref_coords, const void diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx index 5bfa1b039f..a749a1db66 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx @@ -604,13 +604,13 @@ public: /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). - * \param [in] t The element to be considered. - * \param [in] vertex The id of the vertex whose coordinates shall be computed. + * \param [in] elem The element to be considered. + * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many doubles as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ virtual void t8_element_vertex_reference_coords (const t8_element_t - *t, + *elem, const int vertex, double coords[]) const; @@ -618,12 +618,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] coords_out The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx index 43959ea6d0..a16d72d393 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx @@ -752,14 +752,14 @@ t8_default_scheme_quad_c::t8_element_root_len (const t8_element_t *elem) const } void -t8_default_scheme_quad_c::t8_element_vertex_coords (const t8_element_t *t, +t8_default_scheme_quad_c::t8_element_vertex_coords (const t8_element_t *elem, int vertex, int coords[]) const { - const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) t; + const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) elem; int len; - T8_ASSERT (t8_element_is_valid (t)); + T8_ASSERT (t8_element_is_valid (elem)); T8_ASSERT (0 <= vertex && vertex < 4); /* Get the length of the quadrant */ len = P4EST_QUADRANT_LEN (q1->level); @@ -771,17 +771,18 @@ t8_default_scheme_quad_c::t8_element_vertex_coords (const t8_element_t *t, void t8_default_scheme_quad_c::t8_element_vertex_reference_coords (const - t8_element_t *t, + t8_element_t + *elem, const int vertex, double coords[]) const { - T8_ASSERT (t8_element_is_valid (t)); + T8_ASSERT (t8_element_is_valid (elem)); T8_ASSERT (0 <= vertex && vertex < 4); int coords_int[2]; - t8_element_vertex_coords (t, vertex, coords_int); + t8_element_vertex_coords (elem, vertex, coords_int); /* We divide the integer coordinates by the root length of the quad * to obtain the reference coordinates. */ @@ -790,15 +791,16 @@ t8_default_scheme_quad_c::t8_element_vertex_reference_coords (const } void -t8_default_scheme_quad_c::t8_element_reference_coords (const t8_element_t *t, +t8_default_scheme_quad_c::t8_element_reference_coords (const t8_element_t + *elem, const double *ref_coords, const void *user_data, double *coords_out) const { - T8_ASSERT (t8_element_is_valid (t)); - const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) t; + T8_ASSERT (t8_element_is_valid (elem)); + const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) elem; coords_out[0] = q1->x / (double) P4EST_ROOT_LEN; coords_out[1] = q1->y / (double) P4EST_ROOT_LEN; const double len = diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx index a9f8fded0a..3f06bd9e5f 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx @@ -578,24 +578,24 @@ public: * elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and * L the maximum refinement level. * All element vertices have integer coordinates in this cube. - * \param [in] t The element to be considered. - * \param [in] vertex The id of the vertex whose coordinates shall be computed. + * \param [in] elem The element to be considered. + * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many integers as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ - virtual void t8_element_vertex_coords (const t8_element_t *t, + virtual void t8_element_vertex_coords (const t8_element_t *elem, int vertex, int coords[]) const; /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). - * \param [in] t The element to be considered. - * \param [in] vertex The id of the vertex whose coordinates shall be computed. + * \param [in] elem The element. + * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many doubles as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ virtual void t8_element_vertex_reference_coords (const t8_element_t - *t, + *elem, const int vertex, double coords[]) const; @@ -603,12 +603,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] coords_out The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx index 30ad973b69..286cb3c53f 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx @@ -522,12 +522,12 @@ t8_default_scheme_tet_c::t8_element_root_len (const t8_element_t *elem) const } void -t8_default_scheme_tet_c::t8_element_vertex_coords (const t8_element_t *t, +t8_default_scheme_tet_c::t8_element_vertex_coords (const t8_element_t *elem, int vertex, int coords[]) const { - T8_ASSERT (t8_element_is_valid (t)); - t8_dtet_compute_coords ((const t8_default_tet_t *) t, vertex, coords); + T8_ASSERT (t8_element_is_valid (elem)); + t8_dtet_compute_coords ((const t8_default_tet_t *) elem, vertex, coords); } void @@ -545,26 +545,28 @@ t8_default_scheme_tet_c::t8_element_general_function (const t8_element_t void t8_default_scheme_tet_c::t8_element_vertex_reference_coords (const - t8_element_t *t, + t8_element_t + *elem, const int vertex, double coords[]) const { - T8_ASSERT (t8_element_is_valid (t)); - t8_dtet_compute_vertex_ref_coords ((const t8_default_tet_t *) t, vertex, + T8_ASSERT (t8_element_is_valid (elem)); + t8_dtet_compute_vertex_ref_coords ((const t8_default_tet_t *) elem, vertex, coords); } void -t8_default_scheme_tet_c::t8_element_reference_coords (const t8_element_t *t, +t8_default_scheme_tet_c::t8_element_reference_coords (const t8_element_t + *elem, const double *ref_coords, const void *user_data, double *out_coords) const { - T8_ASSERT (t8_element_is_valid (t)); - t8_dtet_compute_reference_coords ((const t8_dtet_t *) t, ref_coords, + T8_ASSERT (t8_element_is_valid (elem)); + t8_dtet_compute_reference_coords ((const t8_dtet_t *) elem, ref_coords, out_coords); } diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx index 26da458e9d..e4ea0391c6 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx @@ -549,12 +549,12 @@ public: * elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and * L the maximum refinement level. * All element vertices have integer coordinates in this cube. - * \param [in] t The element to be considered. - * \param [in] vertex The id of the vertex whose coordinates shall be computed. + * \param [in] elem The element to be considered. + * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many integers as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ - virtual void t8_element_vertex_coords (const t8_element_t *t, + virtual void t8_element_vertex_coords (const t8_element_t *elem, const int vertex, int coords[]) const; @@ -571,13 +571,13 @@ public: /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). - * \param [in] t The element to be considered. - * \param [in] vertex The id of the vertex whose coordinates shall be computed. + * \param [in] elem The element to be considered. + * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many doubles as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ virtual void t8_element_vertex_reference_coords (const t8_element_t - *t, + *elem, const int vertex, double coords[]) const; @@ -585,12 +585,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] coords_out The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h b/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h index 3ac4e91f22..50f6485515 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h @@ -41,39 +41,39 @@ T8_EXTERN_C_BEGIN (); * \param [out] coordinates An array of 3 t8_dtet_coord_t that * will be filled with the coordinates of the vertex. */ -void t8_dtet_compute_coords (const t8_dtet_t *t, int vertex, +void t8_dtet_compute_coords (const t8_dtet_t *elem, int vertex, t8_dtet_coord_t coordinates[3]); /** Compute the coordinates of a vertex of a tetrahedron when the * tree (level 0 tetrahedron) is embedded in [0,1]^3. - * \param [in] t Input tetrahedron. - * \param [in] vertex The number of the vertex. + * \param [in] elem Input tetrahedron. + * \param [in] vertex The number of the vertex. * \param [out] coordinates An array of 3 double that * will be filled with the reference coordinates of the vertex. */ -void t8_dtet_compute_vertex_ref_coords (const t8_dtet_t *t, +void t8_dtet_compute_vertex_ref_coords (const t8_dtet_t *elem, int vertex, double coordinates[3]); -/** Convert a point in the reference space of a tetrahedron to a point in the - * reference space of the tree (level 0 tetrahedron) embedded in [0,1]^2. - * \param [in] t Input tetrahedron. +/** Convert a point in the reference space of a tet element to a point in the + * reference space of the tree (level 0) embedded in [0,1]^3. + * \param [in] elem Input tetrahedron. * \param [in] ref_coords The reference coordinates inside the * tet element [0,1]^2 * \param [out] out_coords An array of 3 doubles that will be filled with the * reference coordinates in the tree of the tet. */ -void t8_dtet_compute_reference_coords (const t8_dtet_t *t, +void t8_dtet_compute_reference_coords (const t8_dtet_t *elem, const double *ref_coords, double out_coords[3]); /** Compute the coordinates of the four vertices of a tetrahedron. - * \param [in] t Input tetrahedron. + * \param [in] elem Input tetrahedron. * \param [out] coordinates An array of 4x3 t8_dtet_coord_t that * will be filled with the coordinates of t's vertices. */ -void t8_dtet_compute_all_coords (const t8_dtet_t *t, +void t8_dtet_compute_all_coords (const t8_dtet_t *elem, t8_dtet_coord_t coordinates[4][3]); diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx index 78e408ba56..91a2437bc2 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx @@ -541,12 +541,12 @@ t8_default_scheme_tri_c::t8_element_root_len (const t8_element_t *elem) const } void -t8_default_scheme_tri_c::t8_element_vertex_coords (const t8_element_t *t, +t8_default_scheme_tri_c::t8_element_vertex_coords (const t8_element_t *elem, int vertex, int coords[]) const { - T8_ASSERT (t8_element_is_valid (t)); - t8_dtri_compute_coords ((const t8_dtri_t *) t, vertex, coords); + T8_ASSERT (t8_element_is_valid (elem)); + t8_dtri_compute_coords ((const t8_dtri_t *) elem, vertex, coords); } void @@ -564,25 +564,28 @@ t8_default_scheme_tri_c::t8_element_general_function (const t8_element_t void t8_default_scheme_tri_c::t8_element_vertex_reference_coords (const - t8_element_t *t, + t8_element_t + *elem, const int vertex, double coords[]) const { - T8_ASSERT (t8_element_is_valid (t)); - t8_dtri_compute_vertex_ref_coords ((const t8_dtri_t *) t, vertex, coords); + T8_ASSERT (t8_element_is_valid (elem)); + t8_dtri_compute_vertex_ref_coords ((const t8_dtri_t *) elem, vertex, + coords); } void -t8_default_scheme_tri_c::t8_element_reference_coords (const t8_element_t *t, +t8_default_scheme_tri_c::t8_element_reference_coords (const t8_element_t + *elem, const double *ref_coords, const void *user_data, double *out_coords) const { - T8_ASSERT (t8_element_is_valid (t)); - t8_dtri_compute_reference_coords ((const t8_dtri_t *) t, ref_coords, + T8_ASSERT (t8_element_is_valid (elem)); + t8_dtri_compute_reference_coords ((const t8_dtri_t *) elem, ref_coords, out_coords); } diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx index b2db5e3a2e..563581813d 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx @@ -542,12 +542,12 @@ public: * elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and * L the maximum refinement level. * All element vertices have integer coordinates in this cube. - * \param [in] t The element to be considered. + * \param [in] elem The element to be considered. * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many integers as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ - virtual void t8_element_vertex_coords (const t8_element_t *t, + virtual void t8_element_vertex_coords (const t8_element_t *elem, int vertex, int coords[]) const; @@ -564,13 +564,13 @@ public: /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). - * \param [in] t The element to be considered. - * \param [in] vertex The id of the vertex whose coordinates shall be computed. + * \param [in] elem The element to be considered. + * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many doubles as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ virtual void t8_element_vertex_reference_coords (const t8_element_t - *t, + *elem, const int vertex, double coords[]) const; @@ -578,12 +578,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] coords_out The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c index e303806b69..000db17ef9 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c @@ -288,9 +288,31 @@ t8_dtri_ancestor (const t8_dtri_t *t, int level, t8_dtri_t *ancestor) /* Compute the coordinates of a given vertex of a triangle/tet */ void -t8_dtri_compute_coords (const t8_dtri_t *t, const int vertex, +t8_dtri_compute_coords (const t8_dtri_t *elem, const int vertex, t8_dtri_coord_t coordinates[T8_DTRI_DIM]) { + /* Calculate the vertex coordinates of a triangle/tetrahedron in + * relation to its orientation. Orientations are described here: + * https://doi.org/10.1137/15M1040049 + * 1---------------------2 + * | orientation / 2 + * | 1 / / | + * | / / | + * | / / | + * | / / | + * | / / | + * | / / | + * | / / | + * | / / orientation | + * | / / 0 | + * 0 / | + * 0--------------------1 + * + * y + * ^ + * | + * z--> x + */ t8_dtri_type_t type; int ei; #ifdef T8_DTRI_TO_DTET @@ -299,8 +321,8 @@ t8_dtri_compute_coords (const t8_dtri_t *t, const int vertex, t8_dtri_coord_t h; T8_ASSERT (0 <= vertex && vertex < T8_DTRI_FACES); - type = t->type; - h = T8_DTRI_LEN (t->level); + type = elem->type; + h = T8_DTRI_LEN (elem->level); #ifndef T8_DTRI_TO_DTET ei = type; #else @@ -308,10 +330,10 @@ t8_dtri_compute_coords (const t8_dtri_t *t, const int vertex, ej = (ei + ((type % 2 == 0) ? 2 : 1)) % 3; #endif - coordinates[0] = t->x; - coordinates[1] = t->y; + coordinates[0] = elem->x; + coordinates[1] = elem->y; #ifdef T8_DTRI_TO_DTET - coordinates[2] = t->z; + coordinates[2] = elem->z; #endif if (vertex == 0) { return; @@ -336,13 +358,13 @@ t8_dtri_compute_coords (const t8_dtri_t *t, const int vertex, } void -t8_dtri_compute_vertex_ref_coords (const t8_dtri_t *t, const int vertex, +t8_dtri_compute_vertex_ref_coords (const t8_dtri_t *elem, const int vertex, double coordinates[T8_DTRI_DIM]) { int coords_int[T8_DTRI_DIM]; T8_ASSERT (0 <= vertex && vertex < T8_DTRI_CORNERS); - t8_dtri_compute_coords (t, vertex, coords_int); + t8_dtri_compute_coords (elem, vertex, coords_int); /* Since the integer coordinates are coordinates w.r.t to * the embedding into [0,T8_DTRI_ROOT_LEN]^d, we just need * to divide them by the root length. */ @@ -354,7 +376,7 @@ t8_dtri_compute_vertex_ref_coords (const t8_dtri_t *t, const int vertex, } void -t8_dtri_compute_reference_coords (const t8_dtri_t *t, +t8_dtri_compute_reference_coords (const t8_dtri_t *elem, const double *ref_coords, double out_coords[T8_DTRI_DIM]) { @@ -385,8 +407,8 @@ t8_dtri_compute_reference_coords (const t8_dtri_t *t, t8_dtri_type_t type; t8_dtri_coord_t h; - type = t->type; - h = T8_DTRI_LEN (t->level); + type = elem->type; + h = T8_DTRI_LEN (elem->level); #ifndef T8_DTRI_TO_DTET const int tri_orientation = type; #else @@ -399,10 +421,10 @@ t8_dtri_compute_reference_coords (const t8_dtri_t *t, (tet_orientation0 + ((type % 2 == 0) ? 2 : 1)) % 3; #endif - out_coords[0] = t->x; - out_coords[1] = t->y; + out_coords[0] = elem->x; + out_coords[1] = elem->y; #ifdef T8_DTRI_TO_DTET - out_coords[2] = t->z; + out_coords[2] = elem->z; #endif #ifndef T8_DTRI_TO_DTET out_coords[tri_orientation] += h * ref_coords[1]; @@ -426,10 +448,32 @@ t8_dtri_compute_reference_coords (const t8_dtri_t *t, /* Compute the coordinates of each vertex of a triangle/tet */ void -t8_dtri_compute_all_coords (const t8_dtri_t *t, +t8_dtri_compute_all_coords (const t8_dtri_t *elem, t8_dtri_coord_t coordinates[T8_DTRI_FACES][T8_DTRI_DIM]) { + /* Calculate the vertex coordinates of a triangle/tetrahedron in + * relation to its orientation. Orientations are described here: + * https://doi.org/10.1137/15M1040049 + * 1---------------------2 + * | orientation / 2 + * | 1 / / | + * | / / | + * | / / | + * | / / | + * | / / | + * | / / | + * | / / | + * | / / orientation | + * | / / 0 | + * 0 / | + * 0--------------------1 + * + * y + * ^ + * | + * z--> x + */ t8_dtri_type_t type; int ei; #ifdef T8_DTRI_TO_DTET @@ -438,8 +482,8 @@ t8_dtri_compute_all_coords (const t8_dtri_t *t, int i; t8_dtri_coord_t h; - type = t->type; - h = T8_DTRI_LEN (t->level); + type = elem->type; + h = T8_DTRI_LEN (elem->level); #ifndef T8_DTRI_TO_DTET ei = type; #else @@ -447,10 +491,10 @@ t8_dtri_compute_all_coords (const t8_dtri_t *t, ej = (ei + ((type % 2 == 0) ? 2 : 1)) % 3; #endif - coordinates[0][0] = t->x; - coordinates[0][1] = t->y; + coordinates[0][0] = elem->x; + coordinates[0][1] = elem->y; #ifdef T8_DTRI_TO_DTET - coordinates[0][2] = t->z; + coordinates[0][2] = elem->z; #endif for (i = 0; i < T8_DTRI_DIM; i++) { coordinates[1][i] = coordinates[0][i]; @@ -474,7 +518,7 @@ t8_dtri_compute_all_coords (const t8_dtri_t *t, int ivertex; t8_dtri_coord_t coords[T8_DTRI_DIM]; for (ivertex = 0; ivertex < T8_DTRI_FACES; ivertex++) { - t8_dtri_compute_coords (t, ivertex, coords); + t8_dtri_compute_coords (elem, ivertex, coords); T8_ASSERT (coords[0] == coordinates[ivertex][0]); T8_ASSERT (coords[1] == coordinates[ivertex][1]); #ifdef T8_DTRI_TO_DTET diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h index b228d2b842..7307e55aa8 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h @@ -67,45 +67,45 @@ void t8_dtri_ancestor (const t8_dtri_t *t, int level, t8_dtri_t *ancestor); /** Compute the coordinates of a vertex of a triangle. - * \param [in] t Input triangle. + * \param [in] elem Input triangle. + * \param [in] vertex The number of the vertex. * \param [out] coordinates An array of 2 t8_dtri_coord_t that - * will be filled with the coordinates of the vertex. - * \param [in] vertex The number of the vertex. + * will be filled with the coordinates of the vertex. */ -void t8_dtri_compute_coords (const t8_dtri_t *t, +void t8_dtri_compute_coords (const t8_dtri_t *elem, const int vertex, t8_dtri_coord_t coordinates[2]); /** Compute the reference coordinates of a vertex of a triangle when the * tree (level 0 triangle) is embedded in [0,1]^2. - * \param [in] t Input triangle. - * \param [in] vertex The number of the vertex. + * \param [in] elem Input triangle. + * \param [in] vertex The number of the vertex. * \param [out] coordinates An array of 2 double that * will be filled with the reference coordinates of the vertex. */ -void t8_dtri_compute_vertex_ref_coords (const t8_dtri_t *t, +void t8_dtri_compute_vertex_ref_coords (const t8_dtri_t *elem, const int vertex, double coordinates[2]); -/** Convert a point in the reference space of a triangle to a point in the - * reference space of the tree (level 0 triangle) embedded in [0,1]^2. - * \param [in] t Input triangle. +/** Convert a point in the reference space of a triangle element to a point in + * the reference space of the tree (level 0) embedded in [0,1]^2. + * \param [in] elem Input triangle. * \param [in] ref_coords The reference coordinates inside the * triangle element [0,1]^2 * \param [out] out_coords An array of 2 doubles that will be filled with the * reference coordinates in the tree of the triangle. */ -void t8_dtri_compute_reference_coords (const t8_dtri_t *t, +void t8_dtri_compute_reference_coords (const t8_dtri_t *elem, const double *ref_coords, double out_coords[2]); /** Compute the coordinates of the four vertices of a triangle. - * \param [in] t Input triangle. + * \param [in] elem Input triangle. * \param [out] coordinates An array of 4x3 t8_dtri_coord_t that * will be filled with the coordinates of t's vertices. */ -void t8_dtri_compute_all_coords (const t8_dtri_t *t, +void t8_dtri_compute_all_coords (const t8_dtri_t *elem, t8_dtri_coord_t coordinates[3][2]); diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx index 606b16b520..9902f69b13 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx @@ -299,8 +299,8 @@ t8_default_scheme_vertex_c::t8_element_vertex_coords (const t8_element_t /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). - * \param [in] t The element to be considered. - * \param [in] vertex The id of the vertex whose coordinates shall be computed. + * \param [in] elem The element. + * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many doubles as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ @@ -322,7 +322,7 @@ t8_default_scheme_vertex_c::t8_element_vertex_reference_coords (const void t8_default_scheme_vertex_c::t8_element_reference_coords (const t8_element_t - *t, + *elem, const double *ref_coords, const void @@ -330,8 +330,8 @@ t8_default_scheme_vertex_c::t8_element_reference_coords (const t8_element_t double *out_coords) const { - T8_ASSERT (t8_element_is_valid (t)); - t8_dvertex_reference_coords ((const t8_dvertex_t *) t, ref_coords, + T8_ASSERT (t8_element_is_valid (elem)); + t8_dvertex_reference_coords ((const t8_dvertex_t *) elem, ref_coords, out_coords); } diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx index 9b1ac91b6a..be5047aa5b 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx @@ -593,24 +593,24 @@ public: * elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and * L the maximum refinement level. * All element vertices have integer coordinates in this cube. - * \param [in] t The element to be considered. - * \param [in] vertex The id of the vertex whose coordinates shall be computed. + * \param [in] elem The element. + * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many integers as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ - virtual void t8_element_vertex_coords (const t8_element_t *t, + virtual void t8_element_vertex_coords (const t8_element_t *elem, int vertex, int coords[]) const; /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). - * \param [in] t The element to be considered. + * \param [in] elem The element. * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many doubles as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ virtual void t8_element_vertex_reference_coords (const t8_element_t - *t, + *elem, const int vertex, double coords[]) const; @@ -618,12 +618,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] out_coords The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h index bf991fefe9..8daa145594 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h @@ -195,7 +195,8 @@ void t8_dvertex_vertex_ref_coords (const t8_dvertex_t *elem, int vertex, double coords[]); -/** Compute the coordinates of a refrence coordinate (always 0) inside the [0,1]^0 reference space. +/** Compute the coordinates of a refrence coordinate (always 0) inside the + * [0,1]^0 reference space. * \param [in] elem Vertex whose vertex is computed. * \param [in] ref_coords The reference coordinate inside the vertex (must be 0). * \param [out] out_coords The coordinates of the computed vertex, must have one entry (will be set to 0). From 02b48a42de31a8cae50e77ecad12e545afd9a54a Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Tue, 11 Apr 2023 09:50:37 +0200 Subject: [PATCH 067/255] Add a header for the forest I/O code --- src/t8_forest_io.h | 111 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 src/t8_forest_io.h diff --git a/src/t8_forest_io.h b/src/t8_forest_io.h new file mode 100644 index 0000000000..6f32ca6767 --- /dev/null +++ b/src/t8_forest_io.h @@ -0,0 +1,111 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** \file t8_forest_general.h + * We define the forest of trees in this file. + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + +#ifndef T8_FOREST_GENERAL_H +#define T8_FOREST_GENERAL_H + +/*TODO: Check if all headers are needed */ +#include +#include +#include +#include +#include + +T8_EXTERN_C_BEGIN (); + +/* TODO: implement */ +void t8_forest_save (t8_forest_t forest); + +/** Write the forest in a parallel vtu format. Extended version. + * See \ref t8_forest_write_vtk for the standard version of this function. + * Writes one master .pvtu file and each process writes in its own .vtu file. + * If linked and not otherwise specified, the VTK API is used. + * If the VTK library is not linked, an ASCII file is written. + * This may change in accordance with \a write_ghosts, \a write_curved and + * \a do_not_use_API, because the export of ghosts is not yet available with + * the VTK API and the export of curved elements is not available with the + * inbuilt function to write ASCII files. The function will for example + * still use the VTK API to satisfy \a write_curved, even if \a do_not_use_API + * is set to true. + * Forest must be committed when calling this function. + * This function is collective and must be called on each process. + * \param [in] forest The forest to write. + * \param [in] fileprefix The prefix of the files where the vtk will + * be stored. The master file is then fileprefix.pvtu + * and the process with rank r writes in the file + * fileprefix_r.vtu. + * \param [in] write_treeid If true, the global tree id is written for each element. + * \param [in] write_mpirank If true, the mpirank is written for each element. + * \param [in] write_level If true, the refinement level is written for each element. + * \param [in] write_element_id If true, the global element id is written for each element. + * \param [in] write_ghosts If true, each process additionally writes its ghost elements. + * For ghost element the treeid is -1. + * \param [in] write_curved If true, write the elements as curved element types from vtk. + * \param [in] do_not_use_API Do not use the VTK API, even if linked and available. + * \param [in] num_data Number of user defined double valued data fields to write. + * \param [in] data Array of t8_vtk_data_field_t of length \a num_data + * providing the user defined per element data. + * If scalar and vector fields are used, all scalar fields + * must come first in the array. + * \return True if successful, false if not (process local). + * See also \ref t8_forest_write_vtk . + */ +int t8_forest_write_vtk_ext (t8_forest_t forest, + const char *fileprefix, + int write_treeid, + int write_mpirank, + int write_level, + int write_element_id, + int write_ghosts, + int write_curved, + int do_not_use_API, + int num_data, + t8_vtk_data_field_t *data); + +/** Write the forest in a parallel vtu format. Writes one master + * .pvtu file and each process writes in its own .vtu file. + * If linked, the VTK API is used. + * If the VTK library is not linked, an ASCII file is written. + * This function writes the forest elements, the tree id, element level, mpirank and element id as data. + * Forest must be committed when calling this function. + * This function is collective and must be called on each process. + * For more options use \ref t8_forest_write_vtk_ext + * \param [in] forest The forest to write. + * \param [in] fileprefix The prefix of the files where the vtk will + * be stored. The master file is then fileprefix.pvtu + * and the process with rank r writes in the file + * fileprefix_r.vtu. + * \return True if successful, false if not (process local). + */ +int t8_forest_write_vtk (t8_forest_t forest, + const char *fileprefix); + + +T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_IO_H */ \ No newline at end of file From 8a0708b10fbe8b5e323f715ab0b2fe4f88ffdee9 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Tue, 11 Apr 2023 09:51:53 +0200 Subject: [PATCH 068/255] Sort t8_forest.h code into new headers --- src/t8_forest_general.h | 790 +++++++++++++++++++++++++++++++++++- src/t8_forest_geometrical.h | 138 ++++++- src/t8_forest_profiling.h | 121 +++++- 3 files changed, 1046 insertions(+), 3 deletions(-) diff --git a/src/t8_forest_general.h b/src/t8_forest_general.h index 14b8b2e2a0..b66c46959f 100644 --- a/src/t8_forest_general.h +++ b/src/t8_forest_general.h @@ -24,4 +24,792 @@ * We define the forest of trees in this file. */ -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ \ No newline at end of file +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + +#ifndef T8_FOREST_GENERAL_H +#define T8_FOREST_GENERAL_H + +/*TODO: Check if all headers are needed */ +#include +#include +#include +#include +#include + +/** Opaque pointer to a forest implementation. */ +typedef struct t8_forest *t8_forest_t; +typedef struct t8_tree *t8_tree_t; + +/** This typedef is needed as a helper construct to + * properly be able to define a function that returns + * a pointer to a void fun(void) function. \see t8_forest_get_user_function. + */ +typedef void (*t8_generic_function_pointer) (void); + +T8_EXTERN_C_BEGIN (); + + /** Create a new forest with reference count one. + * This forest needs to be specialized with the t8_forest_set_* calls. + * Currently it is manatory to either call the functions \ref + * t8_forest_set_mpicomm, \ref t8_forest_set_cmesh, and \ref t8_forest_set_scheme, + * or to call one of \ref t8_forest_set_copy, \ref t8_forest_set_adapt, or + * \ref t8_forest_set_partition. It is illegal to mix these calls, or to + * call more than one of the three latter functions + * Then it needs to be set up with \ref t8_forest_commit. + * \param [in,out] pforest On input, this pointer must be non-NULL. + * On return, this pointer set to the new forest. + */ +void t8_forest_init (t8_forest_t *pforest); + +/** Check whether a forest is not NULL, initialized and not committed. + * In addition, it asserts that the forest is consistent as much as possible. + * \param [in] forest This forest is examined. May be NULL. + * \return True if forest is not NULL, + * \ref t8_forest_init has been called on it, + * but not \ref t8_forest_commit. + * False otherwise. + */ +int t8_forest_is_initialized (t8_forest_t forest); + +/** Check whether a forest is not NULL, initialized and committed. + * In addition, it asserts that the forest is consistent as much as possible. + * \param [in] forest This forest is examined. May be NULL. + * \return True if forest is not NULL and + * \ref t8_forest_init has been called on it + * as well as \ref t8_forest_commit. + * False otherwise. + */ +int t8_forest_is_committed (t8_forest_t forest); + +/** Check whether two committed forests have the same local elements. + * \param [in] forest_a The first forest. + * \param [in] forest_b The second forest. + * \return True if \a forest_a and \a forest_b do have the same + * number of local trees and each local tree has the same + * elements, that is \ref t8_element_compare returns false + * for each pair of elements of \a forest_a and \a forest_b. + * \note This function is not collective. It only returns the state on the current + * rank. + */ +int t8_forest_is_equal (t8_forest_t forest_a, + t8_forest_t forest_b); + +/** Set the cmesh associated to a forest. + * By default, the forest takes ownership of the cmesh such that it will be + * destroyed when the forest is destroyed. To keep ownership of the cmesh, + * call \ref t8_cmesh_ref before passing it to \ref t8_forest_set_cmesh. + * This means that it is ILLEGAL to continue using cmesh or dereferencing it + * UNLESS it is referenced directly before passing it into this function. + * \param [in,out] forest The forest whose cmesh variable will be set. + * \param [in] cmesh The cmesh to be set. We take ownership. + * This can be prevented by referencing \b cmesh. + */ +void t8_forest_set_cmesh (t8_forest_t forest, + t8_cmesh_t cmesh, sc_MPI_Comm comm); + +/** Set the element scheme associated to a forest. + * By default, the forest takes ownership of the scheme such that it will be + * destroyed when the forest is destroyed. To keep ownership of the scheme, call + * \ref t8_scheme_ref before passing it to \ref t8_forest_set_scheme. + * This means that it is ILLEGAL to continue using scheme or dereferencing it + * UNLESS it is referenced directly before passing it into this function. + * \param [in,out] forest The forest whose scheme variable will be set. + * \param [in] scheme The scheme to be set. We take ownership. + * This can be prevented by referencing \b scheme. + */ +void t8_forest_set_scheme (t8_forest_t forest, + t8_scheme_cxx_t *scheme); + +/** Set the initial refinement level to be used when \b forest is commited. + * \param [in,out] forest The forest whose level will be set. + * \param [in] level The initial refinement level of \b forest, when + * it is commited. + * \note This setting cannot be combined with any of the derived forest methods + * (\ref t8_forest_set_copy, \ref t8_forest_set_adapt, \ref t8_forest_set_partition, + * and \ref t8_forest_set_balance) and overwrites any of these settings. + * If this function is used, then the forest is created from scratch as a uniform + * refinement of the specified cmesh (\ref t8_forest_set_cmesh, \ref t8_forest_set_scheme). + */ +void t8_forest_set_level (t8_forest_t forest, int level); + +/** Set a forest as source for copying on commiting. + * By default, the forest takes ownership of the source \b from such that it will + * be destroyed on calling \ref t8_forest_commit. To keep ownership of \b + * from, call \ref t8_forest_ref before passing it into this function. + * This means that it is ILLEGAL to continue using \b from or dereferencing it + * UNLESS it is referenced directly before passing it into this function. + * \param [in,out] forest The forest. + * \param [in] from A second forest from which \a forest will be copied + * in \ref t8_forest_commit. + * \note This setting cannot be combined with \ref t8_forest_set_adapt, + * \ref t8_forest_set_partition, or \ref t8_forest_set_balance and overwrites these + * settings. + */ +void t8_forest_set_copy (t8_forest_t forest, + const t8_forest_t from); + +/** Enable or disable the creation of a layer of ghost elements. + * On default no ghosts are created. + * \param [in] forest The forest. + * \param [in] do_ghost If non-zero a ghost layer will be created. + * \param [in] ghost_type Controls which neighbors count as ghost elements, + * currently only T8_GHOST_FACES is supported. This value + * is ignored if \a do_ghost = 0. + */ +void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, + t8_ghost_type_t ghost_type); + +/** Like \ref t8_forest_set_ghost but with the additional options to change the + * ghost algorithm. This is used for debugging and timing the algorithm. + * An application should almost always use \ref t8_forest_set_ghost. + * \param [in] ghost_version If 1, the iterative ghost algorithm for balanced forests is used. + * If 2, the iterativ algorithm for unbalanced forests. + * If 3, the top-down search algorithm for unbalanced forests. + * \see t8_forest_set_ghost + */ +void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, + t8_ghost_type_t ghost_type, + int ghost_version); + +/** Compute the global number of elements in a forest as the sum + * of the local element counts. + * \param [in] forest The forest. + */ +void t8_forest_comm_global_num_elements (t8_forest_t forest); + +/** After allocating and adding properties to a forest, commit the changes. + * This call sets up the internal state of the forest. + * \param [in,out] forest Must be created with \ref t8_forest_init and + * specialized with t8_forest_set_* calls first. + */ +void t8_forest_commit (t8_forest_t forest); + +/** Return the maximum allowed refinement level for any element in a forest. + * \param [in] forest A forest. + * \return The maximum level of refinement that is allowed for + * an element in this forest. It is guarenteed that any tree + * in \a forest can be refined this many times and it is not + * allowed to refine further. + * \a forest must be committed before calling this function. + * For forest with a single element class (non-hybrid) maxlevel is the maximum + * refinement level of this element class, whilst for hybrid forests the maxlevel is + * the minimum of all maxlevels of the element classes in this forest. + */ +int t8_forest_get_maxlevel (t8_forest_t forest); + +/** Return the number of process local elements in the forest. + * \param [in] forest A forest. + * \return The number of elements on this process in \a forest. + * \a forest must be committed before calling this function. + */ +t8_locidx_t t8_forest_get_local_num_elements (t8_forest_t forest); + +/** Return the number of global elements in the forest. + * \param [in] forest A forest. + * \return The number of elements (summed over all processes) in \a forest. + * \a forest must be committed before calling this function. + */ +t8_gloidx_t t8_forest_get_global_num_elements (t8_forest_t forest); + +/** Return the number of ghost elements of a forest. + * \param [in] forest The forest. + * \return The number of ghost elements stored in the ghost + * structure of \a forest. 0 if no ghosts were constructed. + * \see t8_forest_set_ghost + * \a forest must be committed before calling this function. + */ +t8_locidx_t t8_forest_get_num_ghosts (t8_forest_t forest); + +/** Given a global tree id compute the forest local id of this tree. + * If the tree is a local tree, then the local id is between 0 and the number + * of local trees. If the tree is not a local tree, a negative number is returned. + * \param [in] forest The forest. + * \param [in] gtreeid The global id of a tree. + * \return The tree's local id in \a forest, if it is a local tree. + * A negative number if not. + * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + */ +t8_locidx_t t8_forest_get_local_id (t8_forest_t forest, + t8_gloidx_t gtreeid); + +/** Given the local id of a tree in a forest, compute the tree's local id + * in the associated cmesh. + * \param [in] forest The forest. + * \param [in] ltreeid The local id of a tree or ghost in the forest. + * \return The local id of the tree in the cmesh associated with the forest. + * \a forest must be committed before calling this function. + * \note For forest local trees, this is the inverse function of \ref t8_forest_cmesh_ltreeid_to_ltreeid. + * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + */ +t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, + t8_locidx_t ltreeid); + +/** Given the local id of a tree in the coarse mesh of a forest, compute + * the tree's local id in the forest. + * \param [in] forest The forest. + * \param [in] ltreeid The local id of a tree in the coarse mesh of \a forest. + * \return The local id of the tree in the forest. -1 if the tree is not forest local. + * \a forest must be committed before calling this function. + * \note For forest local trees, this is the inverse function of \ref t8_forest_ltreeid_to_cmesh_ltreeid. + * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + */ +t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, + t8_locidx_t lctreeid); + +/** Given the local id of a tree in a forest, return the coarse tree of the + * cmesh that corresponds to this tree. + * \param [in] forest The forest. + * \param [in] ltreeid The local id of a tree in the forest. + * \return The coarse tree that matches the forest tree with local + * id \a ltreeid. + */ +t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, + t8_locidx_t ltreeid); + +/** Print the ghost structure of a forest. Only used for debugging. */ +void t8_forest_ghost_print (t8_forest_t forest); + +/** Change the cmesh associated to a forest to a partitioned cmesh that + * is partitioned according to the tree distribution in the forest. + * \param [in,out] forest The forest. + * \param [in] comm The MPI communicator that is used to partition + * and commit the cmesh. + * \param [in] set_profiling If true, profiling for the new cmesh + * will be enabled. \see t8_cmesh_set_profiling, \see t8_cmesh_print_profile + * \see t8_cmesh.h + */ + + +/** Return the mpi communicator associated to a forest. + * \param [in] forest The forest. + * \return The mpi communicator of \a forest. + * \a forest must be committed before calling this function. + */ +sc_MPI_Comm t8_forest_get_mpicomm (t8_forest_t forest); + +/** Return the global id of the first local tree of a forest. + * \param [in] forest The forest. + * \return The global id of the first local tree in \a forest. + */ +t8_gloidx_t t8_forest_get_first_local_tree_id (t8_forest_t forest); + +/** Return the number of local trees of a given forest. + * \param [in] forest The forest. + * \return The number of local trees of that forest. + */ +t8_locidx_t t8_forest_get_num_local_trees (t8_forest_t forest); + +/** Return the number of ghost trees of a given forest. + * \param [in] forest The forest. + * \return The number of ghost trees of that forest. + */ +t8_locidx_t t8_forest_get_num_ghost_trees (t8_forest_t forest); + +/** Return the number of global trees of a given forest. + * \param [in] forest The forest. + * \return The number of global trees of that forest. + */ +t8_gloidx_t t8_forest_get_num_global_trees (t8_forest_t forest); + +/** Return the global id of a local tree or a ghost tree. + * \param [in] forest The forest. + * \param [in] ltreeid An id 0 <= \a ltreeid < num_local_trees + num_ghosts + * specifying a local tree or ghost tree. + * \return The global id corresponding to the tree with local id \a ltreeid. + * \a forest must be committed before calling this function. + * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + */ +t8_gloidx_t t8_forest_global_tree_id (t8_forest_t forest, + t8_locidx_t ltreeid); + +/** Return a pointer to a tree in a forest. + * \param [in] forest The forest. + * \param [in] ltree_id The local id of the tree. + * \return A pointer to the tree with local id \a ltree_id. + * \a forest must be committed before calling this function. + */ +t8_tree_t t8_forest_get_tree (t8_forest_t forest, + t8_locidx_t ltree_id); + +/** Return a pointer to the vertex coordinates of a tree. + * \param [in] forest The forest. + * \param [in] ltreeid The id of a local tree. + * \return If stored, a pointer to the vertex coordinates of \a tree. + * If no coordinates for this tree are found, NULL. + */ +double *t8_forest_get_tree_vertices (t8_forest_t forest, + t8_locidx_t ltreeid); + +/** Return the array of leaf elements of a local tree in a forest. + * \param [in] forest The forest. + * \param [in] ltree_id The local id of a local tree of \a forest. + * \return An array of t8_element_t * storing all leaf elements + * of this tree. + */ +t8_element_array_t *t8_forest_tree_get_leafs (t8_forest_t forest, + t8_locidx_t ltree_id); + +/** Return a cmesh associated to a forest. + * \param [in] forest The forest. + * \return The cmesh associated to the forest. + */ +t8_cmesh_t t8_forest_get_cmesh (t8_forest_t forest); + +/** Return an element of the forest. + * \param [in] forest The forest. + * \param [in] lelement_id The local id of an element in \a forest. + * \param [out] ltreeid If not NULL, on output the local tree id of the tree in which the + * element lies in. + * \return A pointer to the element. NULL if this element does not exist. + * \note This function performs a binary search. For constant access, use \ref t8_forest_get_element_in_tree + * \a forest must be committed before calling this function. + */ +t8_element_t *t8_forest_get_element (t8_forest_t forest, + t8_locidx_t lelement_id, + t8_locidx_t *ltreeid); + +/** Return an element of a local tree in a forest. + * \param [in] forest The forest. + * \param [in] ltreeid An id of a local tree in the forest. + * \param [in] leid_in_tree The index of an element in the tree. + * \return A pointer to the element. + * \note If the tree id is know, this function should be preferred over \ref t8_forest_get_element. + * \a forest must be committed before calling this function. + */ +t8_element_t *t8_forest_get_element_in_tree (t8_forest_t forest, + t8_locidx_t ltreeid, + t8_locidx_t leid_in_tree); + +/** Return the number of elements of a tree. + * \param [in] forest The forest. + * \param [in] ltreeid A local id of a tree. + * \return The number of elements in the local tree \a ltreeid. + */ +t8_locidx_t t8_forest_get_tree_num_elements (t8_forest_t forest, + t8_locidx_t ltreeid); + +/** Return the element offset of a local tree, that is the number of elements + * in all trees with smaller local treeid. + * \param [in] forest The forest. + * \param [in] ltreeid A local id of a tree. + * \return The number of leaf elements on all local tree with + * id < \a ltreeid. + * \note \a forest must be committed before calling this function. + */ +t8_locidx_t t8_forest_get_tree_element_offset (t8_forest_t forest, + t8_locidx_t ltreeid); + +/** Return the number of elements of a tree. + * \param [in] tree A tree in a forest. + * \return The number of elements of that tree. + */ +t8_locidx_t t8_forest_get_tree_element_count (t8_tree_t tree); + +/** Compute the global index of the first local element of a forest. + * This function is collective. + * \param [in] forest A committed forest, whose first element's index is computed. + * \return The global index of \a forest's first local element. + * Forest must be committed when calling this function. + * This function is collective and must be called on each process. + */ +t8_gloidx_t t8_forest_get_first_local_element_id (t8_forest_t forest); + +/** Construct the face neighbor of an element, possibly across tree boundaries. + * Returns the global tree-id of the tree in which the neighbor element lies in. + * + * \param [in] elem The element to be considered. + * \param [in,out] neigh On input an allocated element of the scheme of the + * face_neighbors eclass. + * On output, this element's data is filled with the + * data of the face neighbor. If the neighbor does not exist + * the data could be modified arbitrarily. + * \param [in] neigh_scheme The eclass scheme of \a neigh. + * \param [in] face The number of the face along which the neighbor should be + * constructed. + * \param [out] neigh_face The number of the face viewed from perspective of \a neigh. + * \return The global tree-id of the tree in which \a neigh is in. + * -1 if there exists no neighbor across that face. + */ +t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t *elem, + t8_element_t *neigh, + t8_eclass_scheme_c + *neigh_scheme, int face, + int *neigh_face); + + +/* TODO: implement */ +void t8_forest_iterate (t8_forest_t forest); + +/** Query whether a given point lies inside an element or not. For bilinearly interpolated elements. + * \note For 2D quadrilateral elements this function is only an approximation. It is correct + * if the four vertices lie in the same plane, but it may produce only approximate results if + * the vertices do not lie in the same plane. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \param [in] point 3-dimensional coordinates of the point to check + * \param [in] tolerance tolerance that we allow the point to not exactly match the element. + * If this value is larger we detect more points. + * If it is zero we probably do not detect points even if they are inside + * due to rounding errors. + * \return True (non-zero) if \a point lies within \a element, false otherwise. + * The return value is also true if the point lies on the element boundary. + * Thus, this function may return true for different leaf elements, if they + * are neighbors and the point lies on the common boundary. + */ +int t8_forest_element_point_inside (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t + *element, + const double point[3], + const double tolerance); + +/* TODO: if set level and partition/adapt/balance all give NULL, then + * refine uniformly and partition/adapt/balance the unfiform forest. */ +/** Build a uniformly refined forest on a coarse mesh. + * \param [in] cmesh A coarse mesh. + * \param [in] scheme An eclass scheme. + * \param [in] level An initial uniform refinement level. + * \param [in] do_face_ghost If true, a layer of ghost elements is created for the forest. + * \param [in] comm MPI communicator to use. + * \return A uniform forest with coarse mesh \a cmesh, eclass_scheme + * \a scheme and refinement level \a level. + * \note This is equivalent to calling \ref t8_forest_init, \ref t8_forest_set_cmesh, + * \ref t8_forest_set_scheme, \ref t8_forest_set_level, and \ref t8_forest_commit. + */ +t8_forest_t t8_forest_new_uniform (t8_cmesh_t cmesh, + t8_scheme_cxx_t *scheme, + int level, int do_face_ghost, + sc_MPI_Comm comm); + +/** Build a adapted forest from another forest. + * \param [in] forest_from The forest to refine + * \param [in] adapt_fn Adapt function to use + * \param [in] replace_fn Replace function to use + * \param [in] recursive If true adptation is recursive + * \param [in] do_face_ghost If true, a layer of ghost elements is created for the forest. + * \param [in] user_data If not NULL, the user data pointer of the forest is set to this value. + * \return A new forest that is adapted from \a forest_from. + * \note This is equivalent to calling \ref t8_forest_init, \ref t8_forest_set_adapt, + * \red t8_forest_set_ghost, and \ref t8_forest_commit + */ +/* TODO: make user_data const. */ +t8_forest_t t8_forest_new_adapt (t8_forest_t forest_from, + t8_forest_adapt_t adapt_fn, + int recursive, int do_face_ghost, + void *user_data); + +/** Increase the reference counter of a forest. + * \param [in,out] forest On input, this forest must exist with positive + * reference count. It may be in any state. + */ +void t8_forest_ref (t8_forest_t forest); + +/** Decrease the reference counter of a forest. + * If the counter reaches zero, this forest is destroyed. + * In this case, the forest dereferences its cmesh and scheme members. + * \param [in,out] pforest On input, the forest pointed to must exist + * with positive reference count. It may be in + * any state. If the reference count reaches + * zero, the forest is destroyed and this pointer + * set to NULL. + * Otherwise, the pointer is not changed and + * the forest is not modified in other ways. + */ +void t8_forest_unref (t8_forest_t *pforest); + + + + + + + + + + + + + +/** Set the user data of a forest. This can i.e. be used to pass user defined + * arguments to the adapt routine. + * \param [in,out] forest The forest + * \param [in] data A pointer to user data. t8code will never touch the data. + * The forest does not need be committed before calling this function. + * \see t8_forest_get_user_data + */ +void t8_forest_set_user_data (t8_forest_t forest, void *data); + +/** Return the user data pointer associated with a forest. + * \param [in] forest The forest. + * \return The user data pointer of \a forest. + * The forest does not need be committed before calling this function. + * \see t8_forest_set_user_data + */ +void *t8_forest_get_user_data (t8_forest_t forest); + +/** Set the user function pointer of a forest. This can i.e. be used to pass user defined + * functions to the adapt routine. + * \param [in,out] forest The forest + * \param [in] function A pointer to a user defined function. t8code will never touch the function. + * The forest does not need be committed before calling this function. + * \note \a function can be an arbitrary function with return value and parameters of + * your choice. When accessing it with \ref t8_forest_get_user_function you should cast + * it into the proper type. + * \see t8_forest_get_user_function + */ +void t8_forest_set_user_function (t8_forest_t forest, + t8_generic_function_pointer + functrion); + +/** Return the user function pointer associated with a forest. + * \param [in] forest The forest. + * \return The user function pointer of \a forest. + * The forest does not need be committed before calling this function. + * \see t8_forest_set_user_function + */ +t8_generic_function_pointer t8_forest_get_user_function (t8_forest_t forest); + +/* TODO: use assertions and document that the forest_set (..., from) and + * set_load are mutually exclusive. */ +void t8_forest_set_load (t8_forest_t forest, + const char *filename); + +/** Exchange ghost information of user defined element data. + * \param[in] forest The forest. Must be committed. + * \param[in] element_data An array of length num_local_elements + num_ghosts + * storing one value for each local element and ghost in \a forest. + * After calling this function the entries for the ghost elements + * are update with the entries in the \a element_data array of + * the corresponding owning process. + * \note This function is collective and hence must be called by all processes in the forest's + * MPI Communicator. + */ +/* TODO: In \ref t8_forest_ghost_cxx we already implemented a begin and end function + * that allow for overlapping communication and computation. We will make them + * available in this interface in the future. */ +void t8_forest_ghost_exchange_data (t8_forest_t forest, + sc_array_t *element_data); + + + /** Callback function prototype to replace one set of elements with another. + * + * This is used by the replace routine which can be called after adapt, + * when the elements of an existing, valid + * forest are changed. The callback allows the user to make changes to the elements + * of the new forest that are either refined, coarsened or the same as elements in the + * old forest. + * + * \param [in] forest_old The forest that is adapted + * \param [in] forest_new The forest that is newly constructed from \a forest_old + * \param [in] which_tree The local tree containing \a outgoing and \a incoming + * \param [in] ts The eclass scheme of the tree + * \param [in] refine -1 if family in \a forest_old got coarsened, 0 if element + * has not been touched, 1 if element got refined. + * See return of t8_forest_adapt_t. + * \param [in] num_outgoing The number of outgoing elements. + * \param [in] first_outgoing The tree local index of the first outgoing element. + * 0 <= first_outgoing < which_tree->num_elements + * \param [in] num_incoming The number of incoming elements. + * \param [in] first_incoming The tree local index of the first incoming element. + * 0 <= first_incom < new_which_tree->num_elements + * + * If an element is being refined, \a refine and \a num_outgoing will be 1 and + * \a num_incoming will be the number of children. + * If a family is being coarsened, \a refine will be -1, \a num_outgoing will be + * the number of family members and \a num_incoming will be 1. Else \a refine will + * be 0 and \a num_outgoing and \a num_incoming will both be 1. + * \see t8_forest_iterate_replace + */ +typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, + t8_forest_t forest_new, + t8_locidx_t which_tree, + t8_eclass_scheme_c *ts, + int refine, + int num_outgoing, + t8_locidx_t first_outgoing, + int num_incoming, + t8_locidx_t first_incoming); + + + +/** Callback function prototype to decide for refining and coarsening. + * If \a is_family equals 1, the first \a num_elements in \a elements + * form a family and we decide whether this family should be coarsened + * or only the first element should be refined. + * Otherwise \a is_family must equal zero and we consider the first entry + * of the element array for refinement. + * Entries of the element array beyond the first \a num_elements are undefined. + * \param [in] forest the forest to which the new elements belong + * \param [in] forest_from the forest that is adapted. + * \param [in] which_tree the local tree containing \a elements + * \param [in] lelement_id the local element id in \a forest_old in the tree of the current element + * \param [in] ts the eclass scheme of the tree + * \param [in] is_family if 1, the first \a num_elements entries in \a elements form a family. If 0, they do not. + * \param [in] num_elements the number of entries in \a elements that are defined + * \param [in] elements Pointers to a family or, if \a is_family is zero, + * pointer to one element. + * \return greater zero if the first entry in \a elements should be refined, + * smaller zero if the family \a elements shall be coarsened, + * zero else. + */ +/* TODO: Do we really need the forest argument? Since the forest is not committed yet it + * seems dangerous to expose to the user. */ +typedef int (*t8_forest_adapt_t) (t8_forest_t forest, + t8_forest_t forest_from, + t8_locidx_t which_tree, + t8_locidx_t lelement_id, + t8_eclass_scheme_c *ts, + const int is_family, + const int num_elements, + t8_element_t *elements[]); + +/** Set a source forest with an adapt function to be adapted on commiting. + * By default, the forest takes ownership of the source \b set_from such that it + * will be destroyed on calling \ref t8_forest_commit. To keep ownership of \b + * set_from, call \ref t8_forest_ref before passing it into this function. + * This means that it is ILLEGAL to continue using \b set_from or dereferencing it + * UNLESS it is referenced directly before passing it into this function. + * \param [in,out] forest The forest + * \param [in] set_from The source forest from which \b forest will be adapted. + * We take ownership. This can be prevented by + * referencing \b set_from. + * If NULL, a previously (or later) set forest will + * be taken (\ref t8_forest_set_partition, \ref t8_forest_set_balance). + * \param [in] adapt_fn The adapt function used on commiting. + * \param [in] recursive A flag specifying whether adaptation is to be done recursively + * or not. If the value is zero, adaptation is not recursive + * and it is recursive otherwise. + * \note This setting can be combined with \ref t8_forest_set_partition and \ref + * t8_forest_set_balance. The order in which these operations are executed is always + * 1) Adapt 2) Balance 3) Partition + * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites + * this setting. + */ +/* TODO: make recursive flag to int specifying the number of recursions? */ +void t8_forest_set_adapt (t8_forest_t forest, + const t8_forest_t set_from, + t8_forest_adapt_t adapt_fn, + int recursive); + +/** Set a source forest to be partitioned during commit. + * The partitioning is done according to the SFC and each rank is assinged + * the same (maybe +1) number of elements. + * \param [in, out] forest The forest. + * \param [in] set_from A second forest that should be partitioned. + * We take ownership. This can be prevented by + * referencing \b set_from. + * If NULL, a previously (or later) set forest will + * be taken (\ref t8_forest_set_adapt, \ref t8_forest_set_balance). + * \param [in] set_for_coarsening CURRENTLY DISABLED. If true, then the partitions + * are choose such that coarsening an element once is a process local + * operation. + * \note This setting can be combined with \ref t8_forest_set_adapt and \ref + * t8_forest_set_balance. The order in which these operations are executed is always + * 1) Adapt 2) Balance 3) Partition + * If \ref t8_forest_set_balance is called with the \a no_repartition parameter set as + * false, it is not neccessary to call \ref t8_forest_set_partition additionally. + * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites + * this setting. + */ +void t8_forest_set_partition (t8_forest_t forest, + const t8_forest_t set_from, + int set_for_coarsening); + +/** Set a source forest to be balanced during commit. + * A forest is said to be balanced if each element has face neighbors of level + * at most +1 or -1 of the element's level. + * \param [in, out] forest The forest. + * \param [in] set_from A second forest that should be balanced. + * We take ownership. This can be prevented by + * referencing \b set_from. + * If NULL, a previously (or later) set forest will + * be taken (\ref t8_forest_set_adapt, \ref t8_forest_set_partition) + * \param [in] no_repartition Balance constructs several intermediate forest that + * are refined from each other. In order to maintain a balanced load + * these forest are repartitioned in each round and the resulting + * forest is load-balanced per default. + * If this behaviour is not desired, \a no_repartition should be + * set to true. + * If \a no_repartition is false, an additional call of \ref t8_forest_set_partition is not + * neccessary. + * \note This setting can be combined with \ref t8_forest_set_adapt and \ref + * t8_forest_set_balance. The order in which these operations are executed is always + * 1) Adapt 2) Balance 3) Partition. + * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites + * this setting. + */ +void t8_forest_set_balance (t8_forest_t forest, + const t8_forest_t set_from, + int no_repartition); + +/** Return the element class of a forest local tree. + * \param [in] forest The forest. + * \param [in] ltreeid The local id of a tree in \a forest. + * \return The element class of the tree \a ltreeid. + * \a forest must be committed before calling this function. + */ +t8_eclass_t t8_forest_get_eclass (t8_forest_t forest, + t8_locidx_t ltreeid); + +/** Compute the leaf face neighbors of a forest. + * \param [in] forest The forest. Must have a valid ghost layer. + * \param [in] ltreeid A local tree id. + * \param [in] leaf A leaf in tree \a ltreeid of \a forest. + * \param [out] neighbor_leafs Unallocated on input. On output the neighbor + * leafs are stored here. + * \param [in] face The index of the face across which the face neighbors + * are searched. + * \param [out] dual_face On output the face id's of the neighboring elements' faces. + * \param [out] num_neighbors On output the number of neighbor leafs. + * \param [out] pelement_indices Unallocated on input. On output the element indices + * of the neighbor leafs are stored here. + * 0, 1, ... num_local_el - 1 for local leafs and + * num_local_el , ... , num_local_el + num_ghosts - 1 for ghosts. + * \param [out] pneigh_scheme On output the eclass scheme of the neighbor elements. + * \param [in] forest_is_balanced True if we know that \a forest is balanced, false + * otherwise. + * \note If there are no face neighbors, then *neighbor_leafs = NULL, num_neighbors = 0, + * and *pelement_indices = NULL on output. + * \note Currently \a forest must be balanced. + * \note \a forest must be committed before calling this function. + */ +void t8_forest_leaf_face_neighbors (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t *leaf, + t8_element_t + **pneighbor_leafs[], + int face, + int *dual_faces[], + int *num_neighbors, + t8_locidx_t + **pelement_indices, + t8_eclass_scheme_c + **pneigh_scheme, + int forest_is_balanced); + +/** Change the cmesh associated to a forest to a partitioned cmesh that + * is partitioned according to the tree distribution in the forest. + * \param [in,out] forest The forest. + * \param [in] comm The MPI communicator that is used to partition + * and commit the cmesh. + * \param [in] set_profiling If true, profiling for the new cmesh + * will be enabled. \see t8_cmesh_set_profiling, \see t8_cmesh_print_profile + * \see t8_cmesh.h + */ +void t8_forest_partition_cmesh (t8_forest_t forest, + sc_MPI_Comm comm, + int set_profiling); +/** Return the eclass of a tree in a forest. + * \param [in] forest The forest. + * \param [in] ltreeid The local id of a tree (local or ghost) in \a forest. + * \return The element class of the tree with local id \a ltreeid. + */ +t8_eclass_t t8_forest_get_tree_class (t8_forest_t forest, + t8_locidx_t ltreeid); + + +T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_GENERAL_H */ diff --git a/src/t8_forest_geometrical.h b/src/t8_forest_geometrical.h index 078e6476de..0d17ae6c57 100644 --- a/src/t8_forest_geometrical.h +++ b/src/t8_forest_geometrical.h @@ -24,4 +24,140 @@ * We define the geometrical queries for a forest of trees in this file. */ -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ \ No newline at end of file +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + +#ifndef T8_FOREST_GEOMETRICAL_H +#define T8_FOREST_GEOMETRICAL_H + +/*TODO: Check if all headers are needed */ +#include +#include +#include +#include +#include + +/** This type controls, which neighbors count as ghost elements. + * Currently, we support face-neighbors. Vertex and edge neighbors + * will eventually be added. */ +typedef enum +{ + T8_GHOST_NONE = 0, /**< Do not create ghost layer. */ + T8_GHOST_FACES, /**< Consider all face (codimension 1) neighbors. */ + T8_GHOST_EDGES, /**< Consider all edge (codimension 2) and face neighbors. */ + T8_GHOST_VERTICES /**< Consider all vertex (codimension 3) and edge and face neighbors. */ +} t8_ghost_type_t; + +T8_EXTERN_C_BEGIN (); + +/** Compute the coordinates of a given vertex of an element if a geometry + * for this tree is registered in the forest's cmesh. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \param [in] corner_number The corner number, in Z-order, of the vertex which should be computed. + * \param [out] coordinates On input an allocated array to store 3 doubles, on output + * the x, y and z coordinates of the vertex. + */ +void t8_forest_element_coordinate (t8_forest_t forest, + t8_locidx_t ltree_id, + const t8_element_t *element, + int corner_number, + double *coordinates); + +/** Compute the coordinates of the centroid of an element if a geometry + * for this tree is registered in the forest's cmesh. + * The centroid is the sum of all corner vertices divided by the number of corners. + * The centroid can be seen as the midpoint of an element and thus can for example be used + * to compute level-set values or the distance between two elements. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \param [out] coordinates On input an allocated array to store 3 doubles, on output + * the x, y and z coordinates of the centroid. + */ +void t8_forest_element_centroid (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t *element, + double *coordinates); + +/** Compute the diameter of an element if a geometry + * for this tree is registered in the forest's cmesh. + * This is only an approximation. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \return The diameter of the element. + * \note For lines the value is exact while for other element types it is only + * an approximation. + */ +double t8_forest_element_diam (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t *element); + +/** Compute the volume of an element if a geometry + * for this tree is registered in the forest's cmesh. + * This is only an approximation. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \return The diameter of the element. + * \note This function assumes d-linear interpolation for the + * tree vertex coordinates. + * \a forest must be committed when calling this function. + */ +double t8_forest_element_volume (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t *element); + +/** Compute the area of an element's face if a geometry + * for this tree is registered in the forest's cmesh. + * Currently implemented for 2D elements only. + * This is only an approximation. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \param [in] face A face of \a element. + * \return The area of \a face. + * \a forest must be committed when calling this function. + */ +double t8_forest_element_face_area (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t *element, + int face); + +/** Compute the vertex coordinates of the centroid of an element's face if a geometry + * for this tree is registered in the forest's cmesh. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \param [in] face A face of \a element. + * \param [out] normal On output the centroid of \a face. + * \a forest must be committed when calling this function. + */ +void t8_forest_element_face_centroid (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t + *element, int face, + double centroid[3]); + +/** Compute the normal vector of an element's face if a geometry + * for this tree is registered in the forest's cmesh. + * Currently implemented for 2D elements only. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \param [in] face A face of \a element. + * \param [out] normal On output the normal vector of \a element at \a face. + * \a forest must be committed when calling this function. + */ +void t8_forest_element_face_normal (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t + *element, int face, + double normal[3]); + + + +T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_GEOMETRICAL_H */ diff --git a/src/t8_forest_profiling.h b/src/t8_forest_profiling.h index e804ce9ed4..8c43ff72fb 100644 --- a/src/t8_forest_profiling.h +++ b/src/t8_forest_profiling.h @@ -24,4 +24,123 @@ * We define the forest of trees in this file. */ -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ \ No newline at end of file +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + +#ifndef T8_FOREST_PROFILING_H +#define T8_FOREST_PROFILING_H + +/*TODO: Check if all headers are needed */ +#include +#include +#include +#include +#include + +T8_EXTERN_C_BEGIN (); + +/** Enable or disable profiling for a forest. If profiling is enabled, runtimes + * and statistics are collected during forest_commit. + * \param [in,out] forest The forest to be updated. + * \param [in] set_profiling If true, profiling will be enabled, if false + * disabled. + * + * Profiling is disabled by default. + * The forest must not be committed before calling this function. + * \see t8_forest_print_profile + */ +void t8_forest_set_profiling (t8_forest_t forest, + int set_profiling); + +/* TODO: document */ +void t8_forest_compute_profile (t8_forest_t forest); + +const sc_statinfo_t *t8_forest_profile_get_adapt_stats (t8_forest_t forest); + +const sc_statinfo_t *t8_forest_profile_get_ghost_stats (t8_forest_t forest); + +const sc_statinfo_t *t8_forest_profile_get_partition_stats (t8_forest_t + forest); + +const sc_statinfo_t *t8_forest_profile_get_commit_stats (t8_forest_t forest); + +const sc_statinfo_t *t8_forest_profile_get_balance_stats (t8_forest_t forest); + +const sc_statinfo_t *t8_forest_profile_get_balance_rounds_stats (t8_forest_t + forest); + +/** Print the collected statistics from a forest profile. + * \param [in] forest The forest. + * + * \a forest must be committed before calling this function. + * \see t8_forest_set_profiling + */ +void t8_forest_print_profile (t8_forest_t forest); + +/** Get the runtime of the last call to \ref t8_forest_adapt. + * \param [in] forest The forest. + * \return The runtime of adapt if profiling was activated. + * 0 otherwise. + * \a forest must be committed before calling this function. + * \see t8_forest_set_profiling + * \see t8_forest_set_adapt + */ +double t8_forest_profile_get_adapt_time (t8_forest_t forest); + +/** Get the runtime of the last call to \ref t8_forest_partition. + * \param [in] forest The forest. + * \param [out] procs_sent On output the number of processes that this rank + * sent elements to in partition + * if profiling was activated. + * \return The runtime of partition if profiling was activated. + * 0 otherwise. + * \a forest must be committed before calling this function. + * \see t8_forest_set_profiling + * \see t8_forest_set_partition + */ +double t8_forest_profile_get_partition_time (t8_forest_t forest, + int *procs_sent); + +/** Get the runtime of the last call to \ref t8_forest_balance. + * \param [in] forest The forest. + * \param [out] balance_rounts On output the number of rounds in balance + * if profiling was activated. + * \return The runtime of balance if profiling was activated. + * 0 otherwise. + * \a forest must be committed before calling this function. + * \see t8_forest_set_profiling + * \see t8_forest_set_balance + */ +double t8_forest_profile_get_balance_time (t8_forest_t forest, + int *balance_rounds); + +/** Get the runtime of the last call to \ref t8_forest_create_ghosts. + * \param [in] forest The forest. + * \param [out] ghosts_sent On output the number of ghost elements sent to other processes + * if profiling was activated. + * \return The runtime of ghost if profiling was activated. + * 0 otherwise. + * \a forest must be committed before calling this function. + * \see t8_forest_set_profiling + * \see t8_forest_set_ghost + */ +double t8_forest_profile_get_ghost_time (t8_forest_t forest, + t8_locidx_t + *ghosts_sent); + +/** Get the waittime of the last call to \ref t8_forest_ghost_exchange_data. + * \param [in] forest The forest. + * \return The time of ghost_exchange_data that was spent waiting + * for other MPI processes, if profiling was activated. + * 0 otherwise. + * \a forest must be committed before calling this function. + * \see t8_forest_set_profiling + * \see t8_forest_ghost_exchange_data + */ +double t8_forest_profile_get_ghostexchange_waittime (t8_forest_t + forest); + + + +T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_PROFILING_H */ From d824949a2d24d11f555305b702764d4d72fd7c75 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Tue, 11 Apr 2023 12:49:46 +0200 Subject: [PATCH 069/255] changed includes regarding splitted headers --- benchmarks/ExtremeScaling/bunny.cxx | 2 +- benchmarks/t8_time_prism_adapt.cxx | 4 +- benchmarks/time_forest_partition.cxx | 5 +- benchmarks/time_new_refine.c | 2 +- benchmarks/time_refine_type03.c | 2 +- .../gmsh/t8_load_and_refine_square_w_hole.cxx | 4 +- .../IO/cmesh/tetgen/t8_forest_from_tetgen.cxx | 3 +- .../forest/netcdf/t8_write_forest_netcdf.cxx | 3 +- example/advect/t8_advection.cxx | 5 +- example/cmesh/t8_cmesh_partition.cxx | 2 +- example/common/t8_example_common.cxx | 3 +- example/common/t8_example_common.h | 2 +- example/forest/t8_face_neighbor.cxx | 2 +- example/forest/t8_test_face_iterate.cxx | 4 +- example/forest/t8_test_ghost.cxx | 4 +- .../forest/t8_test_ghost_large_level_diff.cxx | 2 + example/geometry/t8_example_geometries.cxx | 3 +- src/Makefile.am | 5 +- src/t8_forest.h | 4 + src/t8_forest/t8_forest.c | 2 +- src/t8_forest/t8_forest_adapt.cxx | 2 +- src/t8_forest/t8_forest_adapt.h | 2 +- src/t8_forest/t8_forest_balance.cxx | 3 +- src/t8_forest/t8_forest_cxx.cxx | 3 +- src/t8_forest/t8_forest_cxx.h | 2 +- src/t8_forest/t8_forest_ghost.cxx | 2 +- src/t8_forest/t8_forest_iterate.cxx | 2 +- src/t8_forest/t8_forest_iterate.h | 2 +- src/t8_forest/t8_forest_netcdf.cxx | 3 +- src/t8_forest/t8_forest_partition.cxx | 2 +- src/t8_forest/t8_forest_partition.h | 2 +- src/t8_forest/t8_forest_private.c | 2 +- src/t8_forest/t8_forest_private.h | 2 +- src/t8_forest/t8_forest_types.h | 2 +- src/t8_forest/t8_forest_vtk.cxx | 2 +- src/t8_forest/t8_forest_vtk.h | 3 +- src/t8_forest_general.h | 582 +++++++++--------- src/t8_forest_geometrical.h | 11 - src/t8_forest_io.h | 4 +- src/t8_forest_netcdf.h | 2 +- test/t8_forest/t8_gtest_element_volume.cxx | 3 +- .../t8_test_element_general_function.cxx | 2 +- test/t8_forest/t8_test_find_owner.cxx | 2 +- test/t8_forest/t8_test_forest_commit.cxx | 2 +- test/t8_forest/t8_test_ghost_and_owner.cxx | 2 +- test/t8_forest/t8_test_ghost_exchange.cxx | 2 +- test/t8_forest/t8_test_half_neighbors.cxx | 2 +- test/t8_forest/t8_test_search.cxx | 2 +- test/t8_forest/t8_test_transform.cxx | 2 +- test/t8_forest/t8_test_user_data.cxx | 2 +- test/t8_geometry/t8_gtest_geometry_occ.cxx | 2 +- test/t8_geometry/t8_test_point_inside.cxx | 3 +- test/t8_schemes/t8_gtest_init_linear_id.cxx | 2 +- .../features/t8_features_curved_meshes.cxx | 4 +- tutorials/general/t8_step2_uniform_forest.cxx | 3 +- tutorials/general/t8_step3.h | 2 +- tutorials/general/t8_step3_adapt_forest.cxx | 4 +- .../t8_step4_partition_balance_ghost.cxx | 3 +- tutorials/general/t8_step5_element_data.cxx | 4 +- .../t8_step5_element_data_c_interface.c | 2 +- tutorials/general/t8_step6_stencil.cxx | 4 +- tutorials/general/t8_tutorial_search.cxx | 3 +- 62 files changed, 411 insertions(+), 344 deletions(-) diff --git a/benchmarks/ExtremeScaling/bunny.cxx b/benchmarks/ExtremeScaling/bunny.cxx index 796f9d55ca..e436712a1a 100644 --- a/benchmarks/ExtremeScaling/bunny.cxx +++ b/benchmarks/ExtremeScaling/bunny.cxx @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/benchmarks/t8_time_prism_adapt.cxx b/benchmarks/t8_time_prism_adapt.cxx index 77833ec747..d3fb3b8baf 100644 --- a/benchmarks/t8_time_prism_adapt.cxx +++ b/benchmarks/t8_time_prism_adapt.cxx @@ -26,7 +26,9 @@ #include #include #include -#include +#include +#include +#include #include #include #include diff --git a/benchmarks/time_forest_partition.cxx b/benchmarks/time_forest_partition.cxx index 905ca346cc..fc16b4b6f7 100644 --- a/benchmarks/time_forest_partition.cxx +++ b/benchmarks/time_forest_partition.cxx @@ -32,7 +32,10 @@ #include #include #include -#include +#include +#include +#include +#include #include #include diff --git a/benchmarks/time_new_refine.c b/benchmarks/time_new_refine.c index 659c1e380c..0e45de6eb0 100644 --- a/benchmarks/time_new_refine.c +++ b/benchmarks/time_new_refine.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/benchmarks/time_refine_type03.c b/benchmarks/time_refine_type03.c index 8166c0f4e5..cec9b97879 100644 --- a/benchmarks/time_refine_type03.c +++ b/benchmarks/time_refine_type03.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx b/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx index 7ff3138b19..ca5bfb1c67 100644 --- a/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx +++ b/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx @@ -30,7 +30,9 @@ #include #include #include -#include +#include +#include +#include #include /* Simple 3 dimensional vector product */ diff --git a/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx b/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx index 11177d9982..33101725ae 100644 --- a/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx +++ b/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx @@ -27,7 +27,8 @@ #include #include #include -#include +#include +#include static t8_cmesh_t t8_cmesh_from_tetgen (const char *prefix, int do_partition) diff --git a/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx b/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx index c53066e826..04d1385bfc 100644 --- a/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx +++ b/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx @@ -39,7 +39,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/example/advect/t8_advection.cxx b/example/advect/t8_advection.cxx index c388d290af..10d244c73e 100644 --- a/example/advect/t8_advection.cxx +++ b/example/advect/t8_advection.cxx @@ -23,7 +23,10 @@ #include #include #include -#include +#include +#include +#include +#include #include #include #include diff --git a/example/cmesh/t8_cmesh_partition.cxx b/example/cmesh/t8_cmesh_partition.cxx index a4b037d3dc..2c062dbe07 100644 --- a/example/cmesh/t8_cmesh_partition.cxx +++ b/example/cmesh/t8_cmesh_partition.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/example/common/t8_example_common.cxx b/example/common/t8_example_common.cxx index 49dd48445a..5f9b0f14d0 100644 --- a/example/common/t8_example_common.cxx +++ b/example/common/t8_example_common.cxx @@ -26,7 +26,8 @@ #include #include #include -#include +#include +#include #include T8_EXTERN_C_BEGIN (); diff --git a/example/common/t8_example_common.h b/example/common/t8_example_common.h index ba44696d72..1339c26af9 100644 --- a/example/common/t8_example_common.h +++ b/example/common/t8_example_common.h @@ -31,7 +31,7 @@ #define T8_EXAMPLE_COMMON_H #include -#include +#include /** A levelset function in 3+1 space dimensions. */ typedef double (*t8_example_level_set_fn) (const double[3], double, diff --git a/example/forest/t8_face_neighbor.cxx b/example/forest/t8_face_neighbor.cxx index 3322b1f608..f94756ef56 100644 --- a/example/forest/t8_face_neighbor.cxx +++ b/example/forest/t8_face_neighbor.cxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/example/forest/t8_test_face_iterate.cxx b/example/forest/t8_test_face_iterate.cxx index 2d17d97964..dfeb8dc774 100644 --- a/example/forest/t8_test_face_iterate.cxx +++ b/example/forest/t8_test_face_iterate.cxx @@ -26,7 +26,9 @@ #include #include #include -#include +#include +#include +#include #include #include #include diff --git a/example/forest/t8_test_ghost.cxx b/example/forest/t8_test_ghost.cxx index 16b5b1fb3c..cd4c12ace9 100644 --- a/example/forest/t8_test_ghost.cxx +++ b/example/forest/t8_test_ghost.cxx @@ -25,7 +25,9 @@ #include #include #include -#include +#include +#include +#include #include #include #include diff --git a/example/forest/t8_test_ghost_large_level_diff.cxx b/example/forest/t8_test_ghost_large_level_diff.cxx index cf6ba0fc55..2bd76e55bf 100644 --- a/example/forest/t8_test_ghost_large_level_diff.cxx +++ b/example/forest/t8_test_ghost_large_level_diff.cxx @@ -42,6 +42,8 @@ #include #include #include +#include +#include #include /* The refinement criterion diff --git a/example/geometry/t8_example_geometries.cxx b/example/geometry/t8_example_geometries.cxx index 0238918385..ceb6b57436 100644 --- a/example/geometry/t8_example_geometries.cxx +++ b/example/geometry/t8_example_geometries.cxx @@ -23,7 +23,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/Makefile.am b/src/Makefile.am index eb92ceb7bf..c8ffbd7bc7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,7 +26,10 @@ libt8_installed_headers = \ src/t8_refcount.h src/t8_cmesh.h src/t8_cmesh_triangle.h \ src/t8_cmesh_tetgen.h src/t8_cmesh_readmshfile.h \ src/t8_cmesh_vtk.h \ - src/t8_forest.h \ + src/t8_forest_general.h \ + src/t8_forest_geometrical.h \ + src/t8_forest_profiling.h \ + src/t8_forest_io.h \ src/t8_vec.h \ src/t8_version.h \ src/t8_vtk.h \ diff --git a/src/t8_forest.h b/src/t8_forest.h index 1b55fa160c..d6f398937f 100644 --- a/src/t8_forest.h +++ b/src/t8_forest.h @@ -26,6 +26,8 @@ /* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ +#if 0 + #ifndef T8_FOREST_H #define T8_FOREST_H @@ -1102,3 +1104,5 @@ void t8_forest_unref (t8_forest_t *pforest); T8_EXTERN_C_END (); #endif /* !T8_FOREST_H */ + +#endif \ No newline at end of file diff --git a/src/t8_forest/t8_forest.c b/src/t8_forest/t8_forest.c index 0557f3425b..1344c927f9 100644 --- a/src/t8_forest/t8_forest.c +++ b/src/t8_forest/t8_forest.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/t8_forest/t8_forest_adapt.cxx b/src/t8_forest/t8_forest_adapt.cxx index 3f8d2f2e9f..0c0ccf132d 100644 --- a/src/t8_forest/t8_forest_adapt.cxx +++ b/src/t8_forest/t8_forest_adapt.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include diff --git a/src/t8_forest/t8_forest_adapt.h b/src/t8_forest/t8_forest_adapt.h index 37b5f64b92..da10e88be5 100644 --- a/src/t8_forest/t8_forest_adapt.h +++ b/src/t8_forest/t8_forest_adapt.h @@ -30,7 +30,7 @@ #define T8_FOREST_ADAPT_H #include -#include +#include T8_EXTERN_C_BEGIN (); /* TODO: comment */ diff --git a/src/t8_forest/t8_forest_balance.cxx b/src/t8_forest/t8_forest_balance.cxx index 3e43f714c3..1c6b173481 100644 --- a/src/t8_forest/t8_forest_balance.cxx +++ b/src/t8_forest/t8_forest_balance.cxx @@ -25,7 +25,8 @@ #include #include #include -#include +#include +#include #include /* We want to export the whole implementation to be callable from "C" */ diff --git a/src/t8_forest/t8_forest_cxx.cxx b/src/t8_forest/t8_forest_cxx.cxx index 1f19b0dcbb..720e4456b8 100644 --- a/src/t8_forest/t8_forest_cxx.cxx +++ b/src/t8_forest/t8_forest_cxx.cxx @@ -23,7 +23,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/t8_forest/t8_forest_cxx.h b/src/t8_forest/t8_forest_cxx.h index 6431d169fa..e77088dc46 100644 --- a/src/t8_forest/t8_forest_cxx.h +++ b/src/t8_forest/t8_forest_cxx.h @@ -31,7 +31,7 @@ #define T8_FOREST_CXX_H #include -#include +#include T8_EXTERN_C_BEGIN (); diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index 4f579a301f..6d186fb55c 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/t8_forest/t8_forest_iterate.cxx b/src/t8_forest/t8_forest_iterate.cxx index e098b6b260..e9a862d6ab 100644 --- a/src/t8_forest/t8_forest_iterate.cxx +++ b/src/t8_forest/t8_forest_iterate.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include /* We want to export the whole implementation to be callable from "C" */ diff --git a/src/t8_forest/t8_forest_iterate.h b/src/t8_forest/t8_forest_iterate.h index 82cae85bc0..77e00af2fc 100644 --- a/src/t8_forest/t8_forest_iterate.h +++ b/src/t8_forest/t8_forest_iterate.h @@ -31,7 +31,7 @@ #define T8_FOREST_ITERATE_H #include -#include +#include typedef int (*t8_forest_iterate_face_fn) (t8_forest_t forest, t8_locidx_t ltreeid, diff --git a/src/t8_forest/t8_forest_netcdf.cxx b/src/t8_forest/t8_forest_netcdf.cxx index 52b6402fa3..fd0e1b2edb 100644 --- a/src/t8_forest/t8_forest_netcdf.cxx +++ b/src/t8_forest/t8_forest_netcdf.cxx @@ -52,7 +52,8 @@ These functions write a file in the NetCDF-format which represents the given 2D- #endif #endif #include -#include +#include +#include #include #include diff --git a/src/t8_forest/t8_forest_partition.cxx b/src/t8_forest/t8_forest_partition.cxx index c9879e4a75..36e18da482 100644 --- a/src/t8_forest/t8_forest_partition.cxx +++ b/src/t8_forest/t8_forest_partition.cxx @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/t8_forest/t8_forest_partition.h b/src/t8_forest/t8_forest_partition.h index b7e32e93e4..ce220b1963 100644 --- a/src/t8_forest/t8_forest_partition.h +++ b/src/t8_forest/t8_forest_partition.h @@ -30,7 +30,7 @@ #define T8_FOREST_PARTITION_H #include -#include +#include T8_EXTERN_C_BEGIN (); /* TODO: document */ diff --git a/src/t8_forest/t8_forest_private.c b/src/t8_forest/t8_forest_private.c index 5f07eca034..2fd769f4e0 100644 --- a/src/t8_forest/t8_forest_private.c +++ b/src/t8_forest/t8_forest_private.c @@ -22,7 +22,7 @@ #include #include -#include +#include t8_element_t * t8_forest_get_tree_element (t8_tree_t tree, t8_locidx_t elem_in_tree) diff --git a/src/t8_forest/t8_forest_private.h b/src/t8_forest/t8_forest_private.h index ef83f6d6a2..4fb65f501d 100644 --- a/src/t8_forest/t8_forest_private.h +++ b/src/t8_forest/t8_forest_private.h @@ -31,7 +31,7 @@ #define T8_FOREST_PRIVATE_H #include -#include +#include T8_EXTERN_C_BEGIN (); diff --git a/src/t8_forest/t8_forest_types.h b/src/t8_forest/t8_forest_types.h index 2eddfcda08..ddcf492089 100644 --- a/src/t8_forest/t8_forest_types.h +++ b/src/t8_forest/t8_forest_types.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include typedef struct t8_profile t8_profile_t; /* Defined below */ typedef struct t8_forest_ghost *t8_forest_ghost_t; /* Defined below */ diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index a76cd68712..17dbdf2fd1 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -56,7 +56,7 @@ #endif #endif #include -#include +#include /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); diff --git a/src/t8_forest/t8_forest_vtk.h b/src/t8_forest/t8_forest_vtk.h index cb0e038b0d..043a91c6d1 100644 --- a/src/t8_forest/t8_forest_vtk.h +++ b/src/t8_forest/t8_forest_vtk.h @@ -29,7 +29,8 @@ #define T8_FOREST_VTK_H #include -#include +#include +#include T8_EXTERN_C_BEGIN (); /* function declarations */ diff --git a/src/t8_forest_general.h b/src/t8_forest_general.h index b66c46959f..91347c6f1e 100644 --- a/src/t8_forest_general.h +++ b/src/t8_forest_general.h @@ -40,6 +40,17 @@ typedef struct t8_forest *t8_forest_t; typedef struct t8_tree *t8_tree_t; +/** This type controls, which neighbors count as ghost elements. + * Currently, we support face-neighbors. Vertex and edge neighbors + * will eventually be added. */ +typedef enum +{ + T8_GHOST_NONE = 0, /**< Do not create ghost layer. */ + T8_GHOST_FACES, /**< Consider all face (codimension 1) neighbors. */ + T8_GHOST_EDGES, /**< Consider all edge (codimension 2) and face neighbors. */ + T8_GHOST_VERTICES /**< Consider all vertex (codimension 3) and edge and face neighbors. */ +} t8_ghost_type_t; + /** This typedef is needed as a helper construct to * properly be able to define a function that returns * a pointer to a void fun(void) function. \see t8_forest_get_user_function. @@ -48,6 +59,76 @@ typedef void (*t8_generic_function_pointer) (void); T8_EXTERN_C_BEGIN (); +/** Callback function prototype to replace one set of elements with another. + * + * This is used by the replace routine which can be called after adapt, + * when the elements of an existing, valid + * forest are changed. The callback allows the user to make changes to the elements + * of the new forest that are either refined, coarsened or the same as elements in the + * old forest. + * + * \param [in] forest_old The forest that is adapted + * \param [in] forest_new The forest that is newly constructed from \a forest_old + * \param [in] which_tree The local tree containing \a outgoing and \a incoming + * \param [in] ts The eclass scheme of the tree + * \param [in] refine -1 if family in \a forest_old got coarsened, 0 if element + * has not been touched, 1 if element got refined. + * See return of t8_forest_adapt_t. + * \param [in] num_outgoing The number of outgoing elements. + * \param [in] first_outgoing The tree local index of the first outgoing element. + * 0 <= first_outgoing < which_tree->num_elements + * \param [in] num_incoming The number of incoming elements. + * \param [in] first_incoming The tree local index of the first incoming element. + * 0 <= first_incom < new_which_tree->num_elements + * + * If an element is being refined, \a refine and \a num_outgoing will be 1 and + * \a num_incoming will be the number of children. + * If a family is being coarsened, \a refine will be -1, \a num_outgoing will be + * the number of family members and \a num_incoming will be 1. Else \a refine will + * be 0 and \a num_outgoing and \a num_incoming will both be 1. + * \see t8_forest_iterate_replace + */ +typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, + t8_forest_t forest_new, + t8_locidx_t which_tree, + t8_eclass_scheme_c *ts, + int refine, + int num_outgoing, + t8_locidx_t first_outgoing, + int num_incoming, + t8_locidx_t first_incoming); + +/** Callback function prototype to decide for refining and coarsening. + * If \a is_family equals 1, the first \a num_elements in \a elements + * form a family and we decide whether this family should be coarsened + * or only the first element should be refined. + * Otherwise \a is_family must equal zero and we consider the first entry + * of the element array for refinement. + * Entries of the element array beyond the first \a num_elements are undefined. + * \param [in] forest the forest to which the new elements belong + * \param [in] forest_from the forest that is adapted. + * \param [in] which_tree the local tree containing \a elements + * \param [in] lelement_id the local element id in \a forest_old in the tree of the current element + * \param [in] ts the eclass scheme of the tree + * \param [in] is_family if 1, the first \a num_elements entries in \a elements form a family. If 0, they do not. + * \param [in] num_elements the number of entries in \a elements that are defined + * \param [in] elements Pointers to a family or, if \a is_family is zero, + * pointer to one element. + * \return greater zero if the first entry in \a elements should be refined, + * smaller zero if the family \a elements shall be coarsened, + * zero else. + */ +/* TODO: Do we really need the forest argument? Since the forest is not committed yet it + * seems dangerous to expose to the user. */ +typedef int (*t8_forest_adapt_t) (t8_forest_t forest, + t8_forest_t forest_from, + t8_locidx_t which_tree, + t8_locidx_t lelement_id, + t8_eclass_scheme_c *ts, + const int is_family, + const int num_elements, + t8_element_t *elements[]); + /** Create a new forest with reference count one. * This forest needs to be specialized with the t8_forest_set_* calls. * Currently it is manatory to either call the functions \ref @@ -148,6 +229,124 @@ void t8_forest_set_level (t8_forest_t forest, int level); void t8_forest_set_copy (t8_forest_t forest, const t8_forest_t from); +/** Set a source forest with an adapt function to be adapted on commiting. + * By default, the forest takes ownership of the source \b set_from such that it + * will be destroyed on calling \ref t8_forest_commit. To keep ownership of \b + * set_from, call \ref t8_forest_ref before passing it into this function. + * This means that it is ILLEGAL to continue using \b set_from or dereferencing it + * UNLESS it is referenced directly before passing it into this function. + * \param [in,out] forest The forest + * \param [in] set_from The source forest from which \b forest will be adapted. + * We take ownership. This can be prevented by + * referencing \b set_from. + * If NULL, a previously (or later) set forest will + * be taken (\ref t8_forest_set_partition, \ref t8_forest_set_balance). + * \param [in] adapt_fn The adapt function used on commiting. + * \param [in] recursive A flag specifying whether adaptation is to be done recursively + * or not. If the value is zero, adaptation is not recursive + * and it is recursive otherwise. + * \note This setting can be combined with \ref t8_forest_set_partition and \ref + * t8_forest_set_balance. The order in which these operations are executed is always + * 1) Adapt 2) Balance 3) Partition + * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites + * this setting. + */ +/* TODO: make recursive flag to int specifying the number of recursions? */ +void t8_forest_set_adapt (t8_forest_t forest, + const t8_forest_t set_from, + t8_forest_adapt_t adapt_fn, + int recursive); + +/** Set the user data of a forest. This can i.e. be used to pass user defined + * arguments to the adapt routine. + * \param [in,out] forest The forest + * \param [in] data A pointer to user data. t8code will never touch the data. + * The forest does not need be committed before calling this function. + * \see t8_forest_get_user_data + */ +void t8_forest_set_user_data (t8_forest_t forest, void *data); + +/** Return the user data pointer associated with a forest. + * \param [in] forest The forest. + * \return The user data pointer of \a forest. + * The forest does not need be committed before calling this function. + * \see t8_forest_set_user_data + */ +void *t8_forest_get_user_data (t8_forest_t forest); + +/** Set the user function pointer of a forest. This can i.e. be used to pass user defined + * functions to the adapt routine. + * \param [in,out] forest The forest + * \param [in] function A pointer to a user defined function. t8code will never touch the function. + * The forest does not need be committed before calling this function. + * \note \a function can be an arbitrary function with return value and parameters of + * your choice. When accessing it with \ref t8_forest_get_user_function you should cast + * it into the proper type. + * \see t8_forest_get_user_function + */ +void t8_forest_set_user_function (t8_forest_t forest, + t8_generic_function_pointer + functrion); + +/** Return the user function pointer associated with a forest. + * \param [in] forest The forest. + * \return The user function pointer of \a forest. + * The forest does not need be committed before calling this function. + * \see t8_forest_set_user_function + */ +t8_generic_function_pointer t8_forest_get_user_function (t8_forest_t forest); + +/** Set a source forest to be partitioned during commit. + * The partitioning is done according to the SFC and each rank is assinged + * the same (maybe +1) number of elements. + * \param [in, out] forest The forest. + * \param [in] set_from A second forest that should be partitioned. + * We take ownership. This can be prevented by + * referencing \b set_from. + * If NULL, a previously (or later) set forest will + * be taken (\ref t8_forest_set_adapt, \ref t8_forest_set_balance). + * \param [in] set_for_coarsening CURRENTLY DISABLED. If true, then the partitions + * are choose such that coarsening an element once is a process local + * operation. + * \note This setting can be combined with \ref t8_forest_set_adapt and \ref + * t8_forest_set_balance. The order in which these operations are executed is always + * 1) Adapt 2) Balance 3) Partition + * If \ref t8_forest_set_balance is called with the \a no_repartition parameter set as + * false, it is not neccessary to call \ref t8_forest_set_partition additionally. + * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites + * this setting. + */ +void t8_forest_set_partition (t8_forest_t forest, + const t8_forest_t set_from, + int set_for_coarsening); + +/** Set a source forest to be balanced during commit. + * A forest is said to be balanced if each element has face neighbors of level + * at most +1 or -1 of the element's level. + * \param [in, out] forest The forest. + * \param [in] set_from A second forest that should be balanced. + * We take ownership. This can be prevented by + * referencing \b set_from. + * If NULL, a previously (or later) set forest will + * be taken (\ref t8_forest_set_adapt, \ref t8_forest_set_partition) + * \param [in] no_repartition Balance constructs several intermediate forest that + * are refined from each other. In order to maintain a balanced load + * these forest are repartitioned in each round and the resulting + * forest is load-balanced per default. + * If this behaviour is not desired, \a no_repartition should be + * set to true. + * If \a no_repartition is false, an additional call of \ref t8_forest_set_partition is not + * neccessary. + * \note This setting can be combined with \ref t8_forest_set_adapt and \ref + * t8_forest_set_balance. The order in which these operations are executed is always + * 1) Adapt 2) Balance 3) Partition. + * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites + * this setting. + */ +void t8_forest_set_balance (t8_forest_t forest, + const t8_forest_t set_from, + int no_repartition); + /** Enable or disable the creation of a layer of ghost elements. * On default no ghosts are created. * \param [in] forest The forest. @@ -171,6 +370,11 @@ void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type, int ghost_version); +/* TODO: use assertions and document that the forest_set (..., from) and + * set_load are mutually exclusive. */ +void t8_forest_set_load (t8_forest_t forest, + const char *filename); + /** Compute the global number of elements in a forest as the sum * of the local element counts. * \param [in] forest The forest. @@ -220,6 +424,15 @@ t8_gloidx_t t8_forest_get_global_num_elements (t8_forest_t forest); */ t8_locidx_t t8_forest_get_num_ghosts (t8_forest_t forest); +/** Return the element class of a forest local tree. + * \param [in] forest The forest. + * \param [in] ltreeid The local id of a tree in \a forest. + * \return The element class of the tree \a ltreeid. + * \a forest must be committed before calling this function. + */ +t8_eclass_t t8_forest_get_eclass (t8_forest_t forest, + t8_locidx_t ltreeid); + /** Given a global tree id compute the forest local id of this tree. * If the tree is a local tree, then the local id is between 0 and the number * of local trees. If the tree is not a local tree, a negative number is returned. @@ -266,6 +479,58 @@ t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, t8_locidx_t ltreeid); +/** Compute the leaf face neighbors of a forest. + * \param [in] forest The forest. Must have a valid ghost layer. + * \param [in] ltreeid A local tree id. + * \param [in] leaf A leaf in tree \a ltreeid of \a forest. + * \param [out] neighbor_leafs Unallocated on input. On output the neighbor + * leafs are stored here. + * \param [in] face The index of the face across which the face neighbors + * are searched. + * \param [out] dual_face On output the face id's of the neighboring elements' faces. + * \param [out] num_neighbors On output the number of neighbor leafs. + * \param [out] pelement_indices Unallocated on input. On output the element indices + * of the neighbor leafs are stored here. + * 0, 1, ... num_local_el - 1 for local leafs and + * num_local_el , ... , num_local_el + num_ghosts - 1 for ghosts. + * \param [out] pneigh_scheme On output the eclass scheme of the neighbor elements. + * \param [in] forest_is_balanced True if we know that \a forest is balanced, false + * otherwise. + * \note If there are no face neighbors, then *neighbor_leafs = NULL, num_neighbors = 0, + * and *pelement_indices = NULL on output. + * \note Currently \a forest must be balanced. + * \note \a forest must be committed before calling this function. + */ +void t8_forest_leaf_face_neighbors (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t *leaf, + t8_element_t + **pneighbor_leafs[], + int face, + int *dual_faces[], + int *num_neighbors, + t8_locidx_t + **pelement_indices, + t8_eclass_scheme_c + **pneigh_scheme, + int forest_is_balanced); + +/** Exchange ghost information of user defined element data. + * \param[in] forest The forest. Must be committed. + * \param[in] element_data An array of length num_local_elements + num_ghosts + * storing one value for each local element and ghost in \a forest. + * After calling this function the entries for the ghost elements + * are update with the entries in the \a element_data array of + * the corresponding owning process. + * \note This function is collective and hence must be called by all processes in the forest's + * MPI Communicator. + */ +/* TODO: In \ref t8_forest_ghost_cxx we already implemented a begin and end function + * that allow for overlapping communication and computation. We will make them + * available in this interface in the future. */ +void t8_forest_ghost_exchange_data (t8_forest_t forest, + sc_array_t *element_data); + /** Print the ghost structure of a forest. Only used for debugging. */ void t8_forest_ghost_print (t8_forest_t forest); @@ -278,8 +543,10 @@ void t8_forest_ghost_print (t8_forest_t forest); * will be enabled. \see t8_cmesh_set_profiling, \see t8_cmesh_print_profile * \see t8_cmesh.h */ - - +void t8_forest_partition_cmesh (t8_forest_t forest, + sc_MPI_Comm comm, + int set_profiling); + /** Return the mpi communicator associated to a forest. * \param [in] forest The forest. * \return The mpi communicator of \a forest. @@ -405,6 +672,14 @@ t8_locidx_t t8_forest_get_tree_element_offset (t8_forest_t forest, */ t8_locidx_t t8_forest_get_tree_element_count (t8_tree_t tree); +/** Return the eclass of a tree in a forest. + * \param [in] forest The forest. + * \param [in] ltreeid The local id of a tree (local or ghost) in \a forest. + * \return The element class of the tree with local id \a ltreeid. + */ +t8_eclass_t t8_forest_get_tree_class (t8_forest_t forest, + t8_locidx_t ltreeid); + /** Compute the global index of the first local element of a forest. * This function is collective. * \param [in] forest A committed forest, whose first element's index is computed. @@ -414,6 +689,37 @@ t8_locidx_t t8_forest_get_tree_element_count (t8_tree_t tree); */ t8_gloidx_t t8_forest_get_first_local_element_id (t8_forest_t forest); +/** Return the element scheme associated to a forest. + * \param [in] forest. A committed forest. + * \return The element scheme of the forest. + * \see t8_forest_set_scheme + */ +t8_scheme_cxx_t *t8_forest_get_scheme (t8_forest_t forest); + +/** Return the eclass scheme of a given element class associated to a forest. + * \param [in] forest. A committed forest. + * \param [in] eclass. An element class. + * \return The eclass scheme of \a eclass associated to forest. + * \see t8_forest_set_scheme + * \note The forest is not required to have trees of class \a eclass. + */ +t8_eclass_scheme_c *t8_forest_get_eclass_scheme (t8_forest_t forest, + t8_eclass_t eclass); + +/** Return the eclass of the tree in which a face neighbor of a given element + * lies. + * \param [in] forest. A committed forest. + * \param [in] ltreeid. The local tree in which the element lies. + * \param [in] elem. An element in the tree \a ltreeid. + * \param [in] face. A face number of \a elem. + * \return The local tree id of the tree in which the face + * neighbor of \a elem across \a face lies. + */ +t8_eclass_t t8_forest_element_neighbor_eclass (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t + *elem, int face); + /** Construct the face neighbor of an element, possibly across tree boundaries. * Returns the global tree-id of the tree in which the neighbor element lies in. * @@ -532,282 +838,10 @@ void t8_forest_unref (t8_forest_t *pforest); -/** Set the user data of a forest. This can i.e. be used to pass user defined - * arguments to the adapt routine. - * \param [in,out] forest The forest - * \param [in] data A pointer to user data. t8code will never touch the data. - * The forest does not need be committed before calling this function. - * \see t8_forest_get_user_data - */ -void t8_forest_set_user_data (t8_forest_t forest, void *data); - -/** Return the user data pointer associated with a forest. - * \param [in] forest The forest. - * \return The user data pointer of \a forest. - * The forest does not need be committed before calling this function. - * \see t8_forest_set_user_data - */ -void *t8_forest_get_user_data (t8_forest_t forest); - -/** Set the user function pointer of a forest. This can i.e. be used to pass user defined - * functions to the adapt routine. - * \param [in,out] forest The forest - * \param [in] function A pointer to a user defined function. t8code will never touch the function. - * The forest does not need be committed before calling this function. - * \note \a function can be an arbitrary function with return value and parameters of - * your choice. When accessing it with \ref t8_forest_get_user_function you should cast - * it into the proper type. - * \see t8_forest_get_user_function - */ -void t8_forest_set_user_function (t8_forest_t forest, - t8_generic_function_pointer - functrion); - -/** Return the user function pointer associated with a forest. - * \param [in] forest The forest. - * \return The user function pointer of \a forest. - * The forest does not need be committed before calling this function. - * \see t8_forest_set_user_function - */ -t8_generic_function_pointer t8_forest_get_user_function (t8_forest_t forest); - -/* TODO: use assertions and document that the forest_set (..., from) and - * set_load are mutually exclusive. */ -void t8_forest_set_load (t8_forest_t forest, - const char *filename); - -/** Exchange ghost information of user defined element data. - * \param[in] forest The forest. Must be committed. - * \param[in] element_data An array of length num_local_elements + num_ghosts - * storing one value for each local element and ghost in \a forest. - * After calling this function the entries for the ghost elements - * are update with the entries in the \a element_data array of - * the corresponding owning process. - * \note This function is collective and hence must be called by all processes in the forest's - * MPI Communicator. - */ -/* TODO: In \ref t8_forest_ghost_cxx we already implemented a begin and end function - * that allow for overlapping communication and computation. We will make them - * available in this interface in the future. */ -void t8_forest_ghost_exchange_data (t8_forest_t forest, - sc_array_t *element_data); - - - /** Callback function prototype to replace one set of elements with another. - * - * This is used by the replace routine which can be called after adapt, - * when the elements of an existing, valid - * forest are changed. The callback allows the user to make changes to the elements - * of the new forest that are either refined, coarsened or the same as elements in the - * old forest. - * - * \param [in] forest_old The forest that is adapted - * \param [in] forest_new The forest that is newly constructed from \a forest_old - * \param [in] which_tree The local tree containing \a outgoing and \a incoming - * \param [in] ts The eclass scheme of the tree - * \param [in] refine -1 if family in \a forest_old got coarsened, 0 if element - * has not been touched, 1 if element got refined. - * See return of t8_forest_adapt_t. - * \param [in] num_outgoing The number of outgoing elements. - * \param [in] first_outgoing The tree local index of the first outgoing element. - * 0 <= first_outgoing < which_tree->num_elements - * \param [in] num_incoming The number of incoming elements. - * \param [in] first_incoming The tree local index of the first incoming element. - * 0 <= first_incom < new_which_tree->num_elements - * - * If an element is being refined, \a refine and \a num_outgoing will be 1 and - * \a num_incoming will be the number of children. - * If a family is being coarsened, \a refine will be -1, \a num_outgoing will be - * the number of family members and \a num_incoming will be 1. Else \a refine will - * be 0 and \a num_outgoing and \a num_incoming will both be 1. - * \see t8_forest_iterate_replace - */ -typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, - t8_forest_t forest_new, - t8_locidx_t which_tree, - t8_eclass_scheme_c *ts, - int refine, - int num_outgoing, - t8_locidx_t first_outgoing, - int num_incoming, - t8_locidx_t first_incoming); - - - -/** Callback function prototype to decide for refining and coarsening. - * If \a is_family equals 1, the first \a num_elements in \a elements - * form a family and we decide whether this family should be coarsened - * or only the first element should be refined. - * Otherwise \a is_family must equal zero and we consider the first entry - * of the element array for refinement. - * Entries of the element array beyond the first \a num_elements are undefined. - * \param [in] forest the forest to which the new elements belong - * \param [in] forest_from the forest that is adapted. - * \param [in] which_tree the local tree containing \a elements - * \param [in] lelement_id the local element id in \a forest_old in the tree of the current element - * \param [in] ts the eclass scheme of the tree - * \param [in] is_family if 1, the first \a num_elements entries in \a elements form a family. If 0, they do not. - * \param [in] num_elements the number of entries in \a elements that are defined - * \param [in] elements Pointers to a family or, if \a is_family is zero, - * pointer to one element. - * \return greater zero if the first entry in \a elements should be refined, - * smaller zero if the family \a elements shall be coarsened, - * zero else. - */ -/* TODO: Do we really need the forest argument? Since the forest is not committed yet it - * seems dangerous to expose to the user. */ -typedef int (*t8_forest_adapt_t) (t8_forest_t forest, - t8_forest_t forest_from, - t8_locidx_t which_tree, - t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, - const int is_family, - const int num_elements, - t8_element_t *elements[]); - -/** Set a source forest with an adapt function to be adapted on commiting. - * By default, the forest takes ownership of the source \b set_from such that it - * will be destroyed on calling \ref t8_forest_commit. To keep ownership of \b - * set_from, call \ref t8_forest_ref before passing it into this function. - * This means that it is ILLEGAL to continue using \b set_from or dereferencing it - * UNLESS it is referenced directly before passing it into this function. - * \param [in,out] forest The forest - * \param [in] set_from The source forest from which \b forest will be adapted. - * We take ownership. This can be prevented by - * referencing \b set_from. - * If NULL, a previously (or later) set forest will - * be taken (\ref t8_forest_set_partition, \ref t8_forest_set_balance). - * \param [in] adapt_fn The adapt function used on commiting. - * \param [in] recursive A flag specifying whether adaptation is to be done recursively - * or not. If the value is zero, adaptation is not recursive - * and it is recursive otherwise. - * \note This setting can be combined with \ref t8_forest_set_partition and \ref - * t8_forest_set_balance. The order in which these operations are executed is always - * 1) Adapt 2) Balance 3) Partition - * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites - * this setting. - */ -/* TODO: make recursive flag to int specifying the number of recursions? */ -void t8_forest_set_adapt (t8_forest_t forest, - const t8_forest_t set_from, - t8_forest_adapt_t adapt_fn, - int recursive); - -/** Set a source forest to be partitioned during commit. - * The partitioning is done according to the SFC and each rank is assinged - * the same (maybe +1) number of elements. - * \param [in, out] forest The forest. - * \param [in] set_from A second forest that should be partitioned. - * We take ownership. This can be prevented by - * referencing \b set_from. - * If NULL, a previously (or later) set forest will - * be taken (\ref t8_forest_set_adapt, \ref t8_forest_set_balance). - * \param [in] set_for_coarsening CURRENTLY DISABLED. If true, then the partitions - * are choose such that coarsening an element once is a process local - * operation. - * \note This setting can be combined with \ref t8_forest_set_adapt and \ref - * t8_forest_set_balance. The order in which these operations are executed is always - * 1) Adapt 2) Balance 3) Partition - * If \ref t8_forest_set_balance is called with the \a no_repartition parameter set as - * false, it is not neccessary to call \ref t8_forest_set_partition additionally. - * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites - * this setting. - */ -void t8_forest_set_partition (t8_forest_t forest, - const t8_forest_t set_from, - int set_for_coarsening); -/** Set a source forest to be balanced during commit. - * A forest is said to be balanced if each element has face neighbors of level - * at most +1 or -1 of the element's level. - * \param [in, out] forest The forest. - * \param [in] set_from A second forest that should be balanced. - * We take ownership. This can be prevented by - * referencing \b set_from. - * If NULL, a previously (or later) set forest will - * be taken (\ref t8_forest_set_adapt, \ref t8_forest_set_partition) - * \param [in] no_repartition Balance constructs several intermediate forest that - * are refined from each other. In order to maintain a balanced load - * these forest are repartitioned in each round and the resulting - * forest is load-balanced per default. - * If this behaviour is not desired, \a no_repartition should be - * set to true. - * If \a no_repartition is false, an additional call of \ref t8_forest_set_partition is not - * neccessary. - * \note This setting can be combined with \ref t8_forest_set_adapt and \ref - * t8_forest_set_balance. The order in which these operations are executed is always - * 1) Adapt 2) Balance 3) Partition. - * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites - * this setting. - */ -void t8_forest_set_balance (t8_forest_t forest, - const t8_forest_t set_from, - int no_repartition); -/** Return the element class of a forest local tree. - * \param [in] forest The forest. - * \param [in] ltreeid The local id of a tree in \a forest. - * \return The element class of the tree \a ltreeid. - * \a forest must be committed before calling this function. - */ -t8_eclass_t t8_forest_get_eclass (t8_forest_t forest, - t8_locidx_t ltreeid); -/** Compute the leaf face neighbors of a forest. - * \param [in] forest The forest. Must have a valid ghost layer. - * \param [in] ltreeid A local tree id. - * \param [in] leaf A leaf in tree \a ltreeid of \a forest. - * \param [out] neighbor_leafs Unallocated on input. On output the neighbor - * leafs are stored here. - * \param [in] face The index of the face across which the face neighbors - * are searched. - * \param [out] dual_face On output the face id's of the neighboring elements' faces. - * \param [out] num_neighbors On output the number of neighbor leafs. - * \param [out] pelement_indices Unallocated on input. On output the element indices - * of the neighbor leafs are stored here. - * 0, 1, ... num_local_el - 1 for local leafs and - * num_local_el , ... , num_local_el + num_ghosts - 1 for ghosts. - * \param [out] pneigh_scheme On output the eclass scheme of the neighbor elements. - * \param [in] forest_is_balanced True if we know that \a forest is balanced, false - * otherwise. - * \note If there are no face neighbors, then *neighbor_leafs = NULL, num_neighbors = 0, - * and *pelement_indices = NULL on output. - * \note Currently \a forest must be balanced. - * \note \a forest must be committed before calling this function. - */ -void t8_forest_leaf_face_neighbors (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *leaf, - t8_element_t - **pneighbor_leafs[], - int face, - int *dual_faces[], - int *num_neighbors, - t8_locidx_t - **pelement_indices, - t8_eclass_scheme_c - **pneigh_scheme, - int forest_is_balanced); -/** Change the cmesh associated to a forest to a partitioned cmesh that - * is partitioned according to the tree distribution in the forest. - * \param [in,out] forest The forest. - * \param [in] comm The MPI communicator that is used to partition - * and commit the cmesh. - * \param [in] set_profiling If true, profiling for the new cmesh - * will be enabled. \see t8_cmesh_set_profiling, \see t8_cmesh_print_profile - * \see t8_cmesh.h - */ -void t8_forest_partition_cmesh (t8_forest_t forest, - sc_MPI_Comm comm, - int set_profiling); -/** Return the eclass of a tree in a forest. - * \param [in] forest The forest. - * \param [in] ltreeid The local id of a tree (local or ghost) in \a forest. - * \return The element class of the tree with local id \a ltreeid. - */ -t8_eclass_t t8_forest_get_tree_class (t8_forest_t forest, - t8_locidx_t ltreeid); T8_EXTERN_C_END (); diff --git a/src/t8_forest_geometrical.h b/src/t8_forest_geometrical.h index 0d17ae6c57..8bf406eee1 100644 --- a/src/t8_forest_geometrical.h +++ b/src/t8_forest_geometrical.h @@ -36,17 +36,6 @@ #include #include -/** This type controls, which neighbors count as ghost elements. - * Currently, we support face-neighbors. Vertex and edge neighbors - * will eventually be added. */ -typedef enum -{ - T8_GHOST_NONE = 0, /**< Do not create ghost layer. */ - T8_GHOST_FACES, /**< Consider all face (codimension 1) neighbors. */ - T8_GHOST_EDGES, /**< Consider all edge (codimension 2) and face neighbors. */ - T8_GHOST_VERTICES /**< Consider all vertex (codimension 3) and edge and face neighbors. */ -} t8_ghost_type_t; - T8_EXTERN_C_BEGIN (); /** Compute the coordinates of a given vertex of an element if a geometry diff --git a/src/t8_forest_io.h b/src/t8_forest_io.h index 6f32ca6767..6e40f1e017 100644 --- a/src/t8_forest_io.h +++ b/src/t8_forest_io.h @@ -26,8 +26,8 @@ /* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ -#ifndef T8_FOREST_GENERAL_H -#define T8_FOREST_GENERAL_H +#ifndef T8_FOREST_IO_H +#define T8_FOREST_IO_H /*TODO: Check if all headers are needed */ #include diff --git a/src/t8_forest_netcdf.h b/src/t8_forest_netcdf.h index a707a44a96..70952b62a1 100644 --- a/src/t8_forest_netcdf.h +++ b/src/t8_forest_netcdf.h @@ -27,7 +27,7 @@ #ifndef T8_FOREST_NETCDF_H #define T8_FOREST_NETCDF_H -#include +#include #include T8_EXTERN_C_BEGIN (); diff --git a/test/t8_forest/t8_gtest_element_volume.cxx b/test/t8_forest/t8_gtest_element_volume.cxx index a96c9df8e1..948eb59097 100644 --- a/test/t8_forest/t8_gtest_element_volume.cxx +++ b/test/t8_forest/t8_gtest_element_volume.cxx @@ -26,7 +26,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include -#include +#include +#include /** * This file tests the volume-computation of elements. diff --git a/test/t8_forest/t8_test_element_general_function.cxx b/test/t8_forest/t8_test_element_general_function.cxx index 6d18f71433..3345f94efc 100644 --- a/test/t8_forest/t8_test_element_general_function.cxx +++ b/test/t8_forest/t8_test_element_general_function.cxx @@ -27,7 +27,7 @@ #include #include #include -#include +#include /* * In this file we test whether the t8_element_general_function diff --git a/test/t8_forest/t8_test_find_owner.cxx b/test/t8_forest/t8_test_find_owner.cxx index f7c926e270..e3823104fb 100644 --- a/test/t8_forest/t8_test_find_owner.cxx +++ b/test/t8_forest/t8_test_find_owner.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/test/t8_forest/t8_test_forest_commit.cxx b/test/t8_forest/t8_test_forest_commit.cxx index 14203ce4ca..d1f6f3d5aa 100644 --- a/test/t8_forest/t8_test_forest_commit.cxx +++ b/test/t8_forest/t8_test_forest_commit.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/test/t8_forest/t8_test_ghost_and_owner.cxx b/test/t8_forest/t8_test_ghost_and_owner.cxx index 9309c0c25f..b9c5ebde3b 100644 --- a/test/t8_forest/t8_test_ghost_and_owner.cxx +++ b/test/t8_forest/t8_test_ghost_and_owner.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/test/t8_forest/t8_test_ghost_exchange.cxx b/test/t8_forest/t8_test_ghost_exchange.cxx index dc09226c52..a09098af4e 100644 --- a/test/t8_forest/t8_test_ghost_exchange.cxx +++ b/test/t8_forest/t8_test_ghost_exchange.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/test/t8_forest/t8_test_half_neighbors.cxx b/test/t8_forest/t8_test_half_neighbors.cxx index 9e72ef2dc8..660975ce6f 100644 --- a/test/t8_forest/t8_test_half_neighbors.cxx +++ b/test/t8_forest/t8_test_half_neighbors.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/test/t8_forest/t8_test_search.cxx b/test/t8_forest/t8_test_search.cxx index 0a851022e2..058ad9a140 100644 --- a/test/t8_forest/t8_test_search.cxx +++ b/test/t8_forest/t8_test_search.cxx @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/test/t8_forest/t8_test_transform.cxx b/test/t8_forest/t8_test_transform.cxx index 9c1f3e0e70..56d937e48a 100644 --- a/test/t8_forest/t8_test_transform.cxx +++ b/test/t8_forest/t8_test_transform.cxx @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/test/t8_forest/t8_test_user_data.cxx b/test/t8_forest/t8_test_user_data.cxx index e3ab5a2d09..5fe51a4e7b 100644 --- a/test/t8_forest/t8_test_user_data.cxx +++ b/test/t8_forest/t8_test_user_data.cxx @@ -27,7 +27,7 @@ #include #include #include -#include +#include /* Test t8_forest_set/get_user_data. * We build a forest and set user data for it. diff --git a/test/t8_geometry/t8_gtest_geometry_occ.cxx b/test/t8_geometry/t8_gtest_geometry_occ.cxx index caa1fd2062..44f2b83f0a 100755 --- a/test/t8_geometry/t8_gtest_geometry_occ.cxx +++ b/test/t8_geometry/t8_gtest_geometry_occ.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/test/t8_geometry/t8_test_point_inside.cxx b/test/t8_geometry/t8_test_point_inside.cxx index 63abe17401..05679c2138 100644 --- a/test/t8_geometry/t8_test_point_inside.cxx +++ b/test/t8_geometry/t8_test_point_inside.cxx @@ -26,7 +26,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/test/t8_schemes/t8_gtest_init_linear_id.cxx b/test/t8_schemes/t8_gtest_init_linear_id.cxx index b8b8e4c70a..bde253f664 100644 --- a/test/t8_schemes/t8_gtest_init_linear_id.cxx +++ b/test/t8_schemes/t8_gtest_init_linear_id.cxx @@ -22,7 +22,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include -#include +#include #include #include #include diff --git a/tutorials/features/t8_features_curved_meshes.cxx b/tutorials/features/t8_features_curved_meshes.cxx index d5c73b4b1a..b1ee0c0f70 100644 --- a/tutorials/features/t8_features_curved_meshes.cxx +++ b/tutorials/features/t8_features_curved_meshes.cxx @@ -38,7 +38,9 @@ #include /* General t8code header, always include this. */ #include /* CLI parser */ #include /* cmesh definition and basic interface. */ -#include /* forest definition and basic interface. */ +#include /* forest definition and basic interface. */ +#include /* save forest */ +#include /* geometrical information of the tree */ #include /* default refinement scheme. */ #include /* Linear geometry calculation of trees */ #include /* Curved geometry calculation of trees */ diff --git a/tutorials/general/t8_step2_uniform_forest.cxx b/tutorials/general/t8_step2_uniform_forest.cxx index 8f1ee3f9f6..06c4f2e250 100644 --- a/tutorials/general/t8_step2_uniform_forest.cxx +++ b/tutorials/general/t8_step2_uniform_forest.cxx @@ -47,7 +47,8 @@ #include #include #include -#include +#include +#include #include #include diff --git a/tutorials/general/t8_step3.h b/tutorials/general/t8_step3.h index 0b85c57f42..db782d34a8 100644 --- a/tutorials/general/t8_step3.h +++ b/tutorials/general/t8_step3.h @@ -32,7 +32,7 @@ #define T8_STEP3_H #include /* General t8code header, always include this. */ -#include /* forest definition and basic interface. */ +#include /* forest definition and basic interface. */ T8_EXTERN_C_BEGIN (); diff --git a/tutorials/general/t8_step3_adapt_forest.cxx b/tutorials/general/t8_step3_adapt_forest.cxx index 7357fb2f18..65216761f5 100644 --- a/tutorials/general/t8_step3_adapt_forest.cxx +++ b/tutorials/general/t8_step3_adapt_forest.cxx @@ -52,7 +52,9 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ +#include /* forest definition and basic interface. */ +#include /* save forest */ +#include #include /* default refinement scheme. */ #include /* Basic operations on 3D vectors. */ #include diff --git a/tutorials/general/t8_step4_partition_balance_ghost.cxx b/tutorials/general/t8_step4_partition_balance_ghost.cxx index d1507f3500..64d085272d 100644 --- a/tutorials/general/t8_step4_partition_balance_ghost.cxx +++ b/tutorials/general/t8_step4_partition_balance_ghost.cxx @@ -88,7 +88,8 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ +#include /* forest definition and basic interface. */ +#include /* save forest */ #include /* default refinement scheme. */ #include diff --git a/tutorials/general/t8_step5_element_data.cxx b/tutorials/general/t8_step5_element_data.cxx index 3bed8c1e5d..d88249f6b3 100644 --- a/tutorials/general/t8_step5_element_data.cxx +++ b/tutorials/general/t8_step5_element_data.cxx @@ -45,7 +45,9 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ +#include /* forest definition and basic interface. */ +#include /* save forest */ +#include /* geometrical information */ #include /* default refinement scheme. */ #include diff --git a/tutorials/general/t8_step5_element_data_c_interface.c b/tutorials/general/t8_step5_element_data_c_interface.c index 5473da3f54..d9c42d46e1 100644 --- a/tutorials/general/t8_step5_element_data_c_interface.c +++ b/tutorials/general/t8_step5_element_data_c_interface.c @@ -47,7 +47,7 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ +#include /* forest definition and basic interface. */ #include /* default refinement scheme. */ #include /* default refinement scheme. */ #include diff --git a/tutorials/general/t8_step6_stencil.cxx b/tutorials/general/t8_step6_stencil.cxx index fe8dbd1853..01cb6a1cd1 100644 --- a/tutorials/general/t8_step6_stencil.cxx +++ b/tutorials/general/t8_step6_stencil.cxx @@ -42,7 +42,9 @@ #include /* General t8code header, always include this. */ #include /* Basic operations on 3D vectors. */ #include /* cmesh definition and basic interface. */ -#include /* forest definition and basic interface. */ +#include /* forest definition and basic interface. */ +#include /* save forest */ +#include /* geometrical information */ #include /* A collection of exemplary cmeshes */ #include /* default refinement scheme. */ #include diff --git a/tutorials/general/t8_tutorial_search.cxx b/tutorials/general/t8_tutorial_search.cxx index 654dd5ec9f..9c39869de8 100644 --- a/tutorials/general/t8_tutorial_search.cxx +++ b/tutorials/general/t8_tutorial_search.cxx @@ -110,7 +110,8 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ +#include /* forest definition and basic interface. */ +#include /* save forest */ #include /* default refinement scheme. */ #include /* Basic operations on 3D vectors. */ #include /* For the search algorithm. */ From 6f271e52bc3a66087292a4bf189d36592c8bd5b4 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 11 Apr 2023 12:56:47 +0200 Subject: [PATCH 070/255] refractoring --- .../t8_default_hex/t8_default_hex_cxx.cxx | 12 ++++++------ .../t8_default_line/t8_default_line_cxx.cxx | 4 ++-- .../t8_default/t8_default_line/t8_dline_bits.c | 7 +++++-- .../t8_default/t8_default_line/t8_dline_bits.h | 7 ++++--- .../t8_default_quad/t8_default_quad_cxx.cxx | 17 ++++++++++------- .../t8_default/t8_default_tri/t8_dtri_bits.c | 12 ++++++------ 6 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx index b2552ea0a6..512e96f34d 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx @@ -652,9 +652,9 @@ t8_default_scheme_hex_c::t8_element_vertex_reference_coords (const /* We divide the integer coordinates by the root length of the hex * to obtain the reference coordinates. */ - coords[0] = coords_int[0] / (double) P8EST_ROOT_LEN; - coords[1] = coords_int[1] / (double) P8EST_ROOT_LEN; - coords[2] = coords_int[2] / (double) P8EST_ROOT_LEN; + coords[0] /= (double) P8EST_ROOT_LEN; + coords[1] /= (double) P8EST_ROOT_LEN; + coords[2] /= (double) P8EST_ROOT_LEN; } void @@ -680,9 +680,9 @@ t8_default_scheme_hex_c::t8_element_reference_coords (const t8_element_t /* We divide the integer coordinates by the root length of the hex * to obtain the reference coordinates. */ - out_coords[0] = out_coords[0] / (double) P8EST_ROOT_LEN; - out_coords[1] = out_coords[1] / (double) P8EST_ROOT_LEN; - out_coords[2] = out_coords[2] / (double) P8EST_ROOT_LEN; + out_coords[0] /= (double) P8EST_ROOT_LEN; + out_coords[1] /= (double) P8EST_ROOT_LEN; + out_coords[2] /= (double) P8EST_ROOT_LEN; } int diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx index 263bd41bd3..f0bd28d5c0 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx @@ -378,8 +378,8 @@ t8_default_scheme_line_c::t8_element_reference_coords (const t8_element_t { T8_ASSERT (t8_element_is_valid (elem)); T8_ASSERT (ref_coords != NULL); - t8_dline_reference_coords ((const t8_dline_t *) elem, ref_coords, - out_coords); + t8_dline_compute_reference_coords ((const t8_dline_t *) elem, ref_coords, + out_coords); } int diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c index e62f7dd89a..9c814665b4 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c +++ b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c @@ -350,11 +350,14 @@ t8_dline_vertex_ref_coords (const t8_dline_t *elem, const int vertex, } void -t8_dline_reference_coords (const t8_dline_t *elem, const double *ref_coords, - double *out_coords) +t8_dline_compute_reference_coords (const t8_dline_t *elem, + const double *ref_coords, + double *out_coords) { + T8_ASSERT (t8_element_is_valid (elem)); out_coords[0] = elem->x; out_coords[0] += T8_DLINE_LEN (elem->level) * ref_coords[0]; + out_coords[0] /= (double) T8_DLINE_ROOT_LEN; } t8_linearidx_t diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h index 3889cf3c63..7d1394f945 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h +++ b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h @@ -250,9 +250,10 @@ void t8_dline_vertex_ref_coords (const t8_dline_t *elem, * will be filled with the reference coordinates * of the point on the line. */ -void t8_dline_reference_coords (const t8_dline_t *elem, - const double *ref_coords, - double *out_coords); +void t8_dline_compute_reference_coords (const t8_dline_t *elem, + const double + *ref_coords, + double *out_coords); /** Computes the linear position of a line in an uniform grid. * \param [in] line Line whose id will be computed. diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx index a16d72d393..0ab1db9cd5 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx @@ -786,8 +786,8 @@ t8_default_scheme_quad_c::t8_element_vertex_reference_coords (const /* We divide the integer coordinates by the root length of the quad * to obtain the reference coordinates. */ - coords[0] = coords_int[0] / (double) P4EST_ROOT_LEN; - coords[1] = coords_int[1] / (double) P4EST_ROOT_LEN; + coords[0] /= (double) P4EST_ROOT_LEN; + coords[1] /= (double) P4EST_ROOT_LEN; } void @@ -796,18 +796,21 @@ t8_default_scheme_quad_c::t8_element_reference_coords (const t8_element_t const double *ref_coords, const void *user_data, - double *coords_out) + double *out_coords) const { T8_ASSERT (t8_element_is_valid (elem)); const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) elem; - coords_out[0] = q1->x / (double) P4EST_ROOT_LEN; - coords_out[1] = q1->y / (double) P4EST_ROOT_LEN; + out_coords[0] = q1->x / (double) P4EST_ROOT_LEN; + out_coords[1] = q1->y / (double) P4EST_ROOT_LEN; const double len = P4EST_QUADRANT_LEN (q1->level) / (double) P4EST_ROOT_LEN; - coords_out[0] += ref_coords[0] * len; - coords_out[1] += ref_coords[1] * len; + out_coords[0] += ref_coords[0] * len; + out_coords[1] += ref_coords[1] * len; + + out_coords[0] /= (double) P4EST_ROOT_LEN; + out_coords[1] /= (double) P4EST_ROOT_LEN; } void diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c index 000db17ef9..5e000cb7fc 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c @@ -368,10 +368,10 @@ t8_dtri_compute_vertex_ref_coords (const t8_dtri_t *elem, const int vertex, /* Since the integer coordinates are coordinates w.r.t to * the embedding into [0,T8_DTRI_ROOT_LEN]^d, we just need * to divide them by the root length. */ - coordinates[0] = coords_int[0] / (double) T8_DTRI_ROOT_LEN; - coordinates[1] = coords_int[1] / (double) T8_DTRI_ROOT_LEN; + coordinates[0] /= (double) T8_DTRI_ROOT_LEN; + coordinates[1] /= (double) T8_DTRI_ROOT_LEN; #ifdef T8_DTRI_TO_DTET - coordinates[2] = coords_int[2] / (double) T8_DTRI_ROOT_LEN; + coordinates[2] /= (double) T8_DTRI_ROOT_LEN; #endif } @@ -439,10 +439,10 @@ t8_dtri_compute_reference_coords (const t8_dtri_t *elem, /* Since the integer coordinates are coordinates w.r.t to * the embedding into [0,T8_DTRI_ROOT_LEN]^d, we just need * to divide them by the root length. */ - out_coords[0] = out_coords[0] / (double) T8_DTRI_ROOT_LEN; - out_coords[1] = out_coords[1] / (double) T8_DTRI_ROOT_LEN; + out_coords[0] /= (double) T8_DTRI_ROOT_LEN; + out_coords[1] /= (double) T8_DTRI_ROOT_LEN; #ifdef T8_DTRI_TO_DTET - out_coords[2] = out_coords[2] / (double) T8_DTRI_ROOT_LEN; + out_coords[2] /= (double) T8_DTRI_ROOT_LEN; #endif } From ca4a83bc57fc2b8698dae9e63a573128a77d957d Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 11 Apr 2023 12:57:13 +0200 Subject: [PATCH 071/255] add element ref coords for prisms --- src/t8_forest/t8_forest_vtk.cxx | 6 +++--- .../t8_default_prism/t8_default_prism_cxx.cxx | 4 +++- .../t8_default/t8_default_prism/t8_dprism_bits.c | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index 4b5fe91761..90d24a9a63 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -178,9 +178,9 @@ const double t8_forest_vtk_point_to_element_ref_coords[T8_ECLASS_COUNT] {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} }, { /* T8_ECLASS_PRISM */ - {0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, - {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, - {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {0, 0, 1}, {0, 1, 1}, + {1, 1, 1}, {0, 0.5, 0}, {0.5, 1, 0}, {0.5, 0.5, 0}, {0, 0.5, 1}, + {0.5, 1, 1}, {0.5, 0.5, 1}, {0, 0, 0.5}, {0, 1, 0.5}, {1, 1, 0.5}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} }, { /* T8_ECLASS_PYRAMID */ diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx index d45d39a2c9..26bd38c20b 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx @@ -489,7 +489,9 @@ t8_default_scheme_prism_c::t8_element_reference_coords (const t8_element_t double *out_coords) const { - SC_ABORTF ("Not implemented\n"); + T8_ASSERT (t8_element_is_valid (elem)); + t8_dprism_compute_reference_coords ((const t8_dprism_t *) elem, ref_coords, + out_coords); } void diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c index a28d6e7d12..2b10119772 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c @@ -580,6 +580,20 @@ t8_dprism_vertex_ref_coords (const t8_dprism_t *elem, const int vertex, coords[2] = coords_int[2] / (double) T8_DPRISM_ROOT_LEN; } +void +t8_dprism_compute_reference_coords (const t8_dprism_t *elem, + const double *ref_coords, + double *out_coords) +{ + T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (elem->line.level == elem->tri.level); + /*Compute x and y coordinate */ + t8_dtri_compute_reference_coords (&elem->tri, ref_coords, out_coords); + /*Compute z coordinate */ + t8_dline_compute_reference_coords (&elem->line, ref_coords + 2, + out_coords + 2); +} + t8_linearidx_t t8_dprism_linear_id (const t8_dprism_t *p, int level) { From dbcd8dc584a3f0a4f1cf251ff644ea46c4a3e1be Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Tue, 11 Apr 2023 13:53:32 +0200 Subject: [PATCH 072/255] Delete old t8_forest.h --- src/t8_forest.h | 1108 ----------------------------------------------- 1 file changed, 1108 deletions(-) delete mode 100644 src/t8_forest.h diff --git a/src/t8_forest.h b/src/t8_forest.h deleted file mode 100644 index d6f398937f..0000000000 --- a/src/t8_forest.h +++ /dev/null @@ -1,1108 +0,0 @@ -/* - This file is part of t8code. - t8code is a C library to manage a collection (a forest) of multiple - connected adaptive space-trees of general element classes in parallel. - - Copyright (C) 2015 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -/** \file t8_forest.h - * We define the forest of trees in this file. - */ - -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ - -#if 0 - -#ifndef T8_FOREST_H -#define T8_FOREST_H - -#include -#include -#include -#include -#include - -/** Opaque pointer to a forest implementation. */ -typedef struct t8_forest *t8_forest_t; -typedef struct t8_tree *t8_tree_t; - -/** This type controls, which neighbors count as ghost elements. - * Currently, we support face-neighbors. Vertex and edge neighbors - * will eventually be added. */ -typedef enum -{ - T8_GHOST_NONE = 0, /**< Do not create ghost layer. */ - T8_GHOST_FACES, /**< Consider all face (codimension 1) neighbors. */ - T8_GHOST_EDGES, /**< Consider all edge (codimension 2) and face neighbors. */ - T8_GHOST_VERTICES /**< Consider all vertex (codimension 3) and edge and face neighbors. */ -} t8_ghost_type_t; - -/** This typedef is needed as a helper construct to - * properly be able to define a function that returns - * a pointer to a void fun(void) function. \see t8_forest_get_user_function. - */ -typedef void (*t8_generic_function_pointer) (void); - -T8_EXTERN_C_BEGIN (); - -/** Callback function prototype to replace one set of elements with another. - * - * This is used by the replace routine which can be called after adapt, - * when the elements of an existing, valid - * forest are changed. The callback allows the user to make changes to the elements - * of the new forest that are either refined, coarsened or the same as elements in the - * old forest. - * - * \param [in] forest_old The forest that is adapted - * \param [in] forest_new The forest that is newly constructed from \a forest_old - * \param [in] which_tree The local tree containing \a outgoing and \a incoming - * \param [in] ts The eclass scheme of the tree - * \param [in] refine -1 if family in \a forest_old got coarsened, 0 if element - * has not been touched, 1 if element got refined. - * See return of t8_forest_adapt_t. - * \param [in] num_outgoing The number of outgoing elements. - * \param [in] first_outgoing The tree local index of the first outgoing element. - * 0 <= first_outgoing < which_tree->num_elements - * \param [in] num_incoming The number of incoming elements. - * \param [in] first_incoming The tree local index of the first incoming element. - * 0 <= first_incom < new_which_tree->num_elements - * - * If an element is being refined, \a refine and \a num_outgoing will be 1 and - * \a num_incoming will be the number of children. - * If a family is being coarsened, \a refine will be -1, \a num_outgoing will be - * the number of family members and \a num_incoming will be 1. Else \a refine will - * be 0 and \a num_outgoing and \a num_incoming will both be 1. - * \see t8_forest_iterate_replace - */ -typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, - t8_forest_t forest_new, - t8_locidx_t which_tree, - t8_eclass_scheme_c *ts, - int refine, - int num_outgoing, - t8_locidx_t first_outgoing, - int num_incoming, - t8_locidx_t first_incoming); - -/** Callback function prototype to decide for refining and coarsening. - * If \a is_family equals 1, the first \a num_elements in \a elements - * form a family and we decide whether this family should be coarsened - * or only the first element should be refined. - * Otherwise \a is_family must equal zero and we consider the first entry - * of the element array for refinement. - * Entries of the element array beyond the first \a num_elements are undefined. - * \param [in] forest the forest to which the new elements belong - * \param [in] forest_from the forest that is adapted. - * \param [in] which_tree the local tree containing \a elements - * \param [in] lelement_id the local element id in \a forest_old in the tree of the current element - * \param [in] ts the eclass scheme of the tree - * \param [in] is_family if 1, the first \a num_elements entries in \a elements form a family. If 0, they do not. - * \param [in] num_elements the number of entries in \a elements that are defined - * \param [in] elements Pointers to a family or, if \a is_family is zero, - * pointer to one element. - * \return greater zero if the first entry in \a elements should be refined, - * smaller zero if the family \a elements shall be coarsened, - * zero else. - */ -/* TODO: Do we really need the forest argument? Since the forest is not committed yet it - * seems dangerous to expose to the user. */ -typedef int (*t8_forest_adapt_t) (t8_forest_t forest, - t8_forest_t forest_from, - t8_locidx_t which_tree, - t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, - const int is_family, - const int num_elements, - t8_element_t *elements[]); - - /** Create a new forest with reference count one. - * This forest needs to be specialized with the t8_forest_set_* calls. - * Currently it is manatory to either call the functions \ref - * t8_forest_set_mpicomm, \ref t8_forest_set_cmesh, and \ref t8_forest_set_scheme, - * or to call one of \ref t8_forest_set_copy, \ref t8_forest_set_adapt, or - * \ref t8_forest_set_partition. It is illegal to mix these calls, or to - * call more than one of the three latter functions - * Then it needs to be set up with \ref t8_forest_commit. - * \param [in,out] pforest On input, this pointer must be non-NULL. - * On return, this pointer set to the new forest. - */ -void t8_forest_init (t8_forest_t *pforest); - -/** Check whether a forest is not NULL, initialized and not committed. - * In addition, it asserts that the forest is consistent as much as possible. - * \param [in] forest This forest is examined. May be NULL. - * \return True if forest is not NULL, - * \ref t8_forest_init has been called on it, - * but not \ref t8_forest_commit. - * False otherwise. - */ -int t8_forest_is_initialized (t8_forest_t forest); - -/** Check whether a forest is not NULL, initialized and committed. - * In addition, it asserts that the forest is consistent as much as possible. - * \param [in] forest This forest is examined. May be NULL. - * \return True if forest is not NULL and - * \ref t8_forest_init has been called on it - * as well as \ref t8_forest_commit. - * False otherwise. - */ -int t8_forest_is_committed (t8_forest_t forest); - -/** Check whether two committed forests have the same local elements. - * \param [in] forest_a The first forest. - * \param [in] forest_b The second forest. - * \return True if \a forest_a and \a forest_b do have the same - * number of local trees and each local tree has the same - * elements, that is \ref t8_element_compare returns false - * for each pair of elements of \a forest_a and \a forest_b. - * \note This function is not collective. It only returns the state on the current - * rank. - */ -int t8_forest_is_equal (t8_forest_t forest_a, - t8_forest_t forest_b); - -/** Set the cmesh associated to a forest. - * By default, the forest takes ownership of the cmesh such that it will be - * destroyed when the forest is destroyed. To keep ownership of the cmesh, - * call \ref t8_cmesh_ref before passing it to \ref t8_forest_set_cmesh. - * This means that it is ILLEGAL to continue using cmesh or dereferencing it - * UNLESS it is referenced directly before passing it into this function. - * \param [in,out] forest The forest whose cmesh variable will be set. - * \param [in] cmesh The cmesh to be set. We take ownership. - * This can be prevented by referencing \b cmesh. - */ -void t8_forest_set_cmesh (t8_forest_t forest, - t8_cmesh_t cmesh, sc_MPI_Comm comm); - -/** Set the element scheme associated to a forest. - * By default, the forest takes ownership of the scheme such that it will be - * destroyed when the forest is destroyed. To keep ownership of the scheme, call - * \ref t8_scheme_ref before passing it to \ref t8_forest_set_scheme. - * This means that it is ILLEGAL to continue using scheme or dereferencing it - * UNLESS it is referenced directly before passing it into this function. - * \param [in,out] forest The forest whose scheme variable will be set. - * \param [in] scheme The scheme to be set. We take ownership. - * This can be prevented by referencing \b scheme. - */ -void t8_forest_set_scheme (t8_forest_t forest, - t8_scheme_cxx_t *scheme); - -/** Set the initial refinement level to be used when \b forest is commited. - * \param [in,out] forest The forest whose level will be set. - * \param [in] level The initial refinement level of \b forest, when - * it is commited. - * \note This setting cannot be combined with any of the derived forest methods - * (\ref t8_forest_set_copy, \ref t8_forest_set_adapt, \ref t8_forest_set_partition, - * and \ref t8_forest_set_balance) and overwrites any of these settings. - * If this function is used, then the forest is created from scratch as a uniform - * refinement of the specified cmesh (\ref t8_forest_set_cmesh, \ref t8_forest_set_scheme). - */ -void t8_forest_set_level (t8_forest_t forest, int level); - -/** Set a forest as source for copying on commiting. - * By default, the forest takes ownership of the source \b from such that it will - * be destroyed on calling \ref t8_forest_commit. To keep ownership of \b - * from, call \ref t8_forest_ref before passing it into this function. - * This means that it is ILLEGAL to continue using \b from or dereferencing it - * UNLESS it is referenced directly before passing it into this function. - * \param [in,out] forest The forest. - * \param [in] from A second forest from which \a forest will be copied - * in \ref t8_forest_commit. - * \note This setting cannot be combined with \ref t8_forest_set_adapt, - * \ref t8_forest_set_partition, or \ref t8_forest_set_balance and overwrites these - * settings. - */ -void t8_forest_set_copy (t8_forest_t forest, - const t8_forest_t from); - -/** Set a source forest with an adapt function to be adapted on commiting. - * By default, the forest takes ownership of the source \b set_from such that it - * will be destroyed on calling \ref t8_forest_commit. To keep ownership of \b - * set_from, call \ref t8_forest_ref before passing it into this function. - * This means that it is ILLEGAL to continue using \b set_from or dereferencing it - * UNLESS it is referenced directly before passing it into this function. - * \param [in,out] forest The forest - * \param [in] set_from The source forest from which \b forest will be adapted. - * We take ownership. This can be prevented by - * referencing \b set_from. - * If NULL, a previously (or later) set forest will - * be taken (\ref t8_forest_set_partition, \ref t8_forest_set_balance). - * \param [in] adapt_fn The adapt function used on commiting. - * \param [in] recursive A flag specifying whether adaptation is to be done recursively - * or not. If the value is zero, adaptation is not recursive - * and it is recursive otherwise. - * \note This setting can be combined with \ref t8_forest_set_partition and \ref - * t8_forest_set_balance. The order in which these operations are executed is always - * 1) Adapt 2) Balance 3) Partition - * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites - * this setting. - */ -/* TODO: make recursive flag to int specifying the number of recursions? */ -void t8_forest_set_adapt (t8_forest_t forest, - const t8_forest_t set_from, - t8_forest_adapt_t adapt_fn, - int recursive); - -/** Set the user data of a forest. This can i.e. be used to pass user defined - * arguments to the adapt routine. - * \param [in,out] forest The forest - * \param [in] data A pointer to user data. t8code will never touch the data. - * The forest does not need be committed before calling this function. - * \see t8_forest_get_user_data - */ -void t8_forest_set_user_data (t8_forest_t forest, void *data); - -/** Return the user data pointer associated with a forest. - * \param [in] forest The forest. - * \return The user data pointer of \a forest. - * The forest does not need be committed before calling this function. - * \see t8_forest_set_user_data - */ -void *t8_forest_get_user_data (t8_forest_t forest); - -/** Set the user function pointer of a forest. This can i.e. be used to pass user defined - * functions to the adapt routine. - * \param [in,out] forest The forest - * \param [in] function A pointer to a user defined function. t8code will never touch the function. - * The forest does not need be committed before calling this function. - * \note \a function can be an arbitrary function with return value and parameters of - * your choice. When accessing it with \ref t8_forest_get_user_function you should cast - * it into the proper type. - * \see t8_forest_get_user_function - */ -void t8_forest_set_user_function (t8_forest_t forest, - t8_generic_function_pointer - functrion); - -/** Return the user function pointer associated with a forest. - * \param [in] forest The forest. - * \return The user function pointer of \a forest. - * The forest does not need be committed before calling this function. - * \see t8_forest_set_user_function - */ -t8_generic_function_pointer t8_forest_get_user_function (t8_forest_t forest); - -/** Set a source forest to be partitioned during commit. - * The partitioning is done according to the SFC and each rank is assinged - * the same (maybe +1) number of elements. - * \param [in, out] forest The forest. - * \param [in] set_from A second forest that should be partitioned. - * We take ownership. This can be prevented by - * referencing \b set_from. - * If NULL, a previously (or later) set forest will - * be taken (\ref t8_forest_set_adapt, \ref t8_forest_set_balance). - * \param [in] set_for_coarsening CURRENTLY DISABLED. If true, then the partitions - * are choose such that coarsening an element once is a process local - * operation. - * \note This setting can be combined with \ref t8_forest_set_adapt and \ref - * t8_forest_set_balance. The order in which these operations are executed is always - * 1) Adapt 2) Balance 3) Partition - * If \ref t8_forest_set_balance is called with the \a no_repartition parameter set as - * false, it is not neccessary to call \ref t8_forest_set_partition additionally. - * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites - * this setting. - */ -void t8_forest_set_partition (t8_forest_t forest, - const t8_forest_t set_from, - int set_for_coarsening); - -/** Set a source forest to be balanced during commit. - * A forest is said to be balanced if each element has face neighbors of level - * at most +1 or -1 of the element's level. - * \param [in, out] forest The forest. - * \param [in] set_from A second forest that should be balanced. - * We take ownership. This can be prevented by - * referencing \b set_from. - * If NULL, a previously (or later) set forest will - * be taken (\ref t8_forest_set_adapt, \ref t8_forest_set_partition) - * \param [in] no_repartition Balance constructs several intermediate forest that - * are refined from each other. In order to maintain a balanced load - * these forest are repartitioned in each round and the resulting - * forest is load-balanced per default. - * If this behaviour is not desired, \a no_repartition should be - * set to true. - * If \a no_repartition is false, an additional call of \ref t8_forest_set_partition is not - * neccessary. - * \note This setting can be combined with \ref t8_forest_set_adapt and \ref - * t8_forest_set_balance. The order in which these operations are executed is always - * 1) Adapt 2) Balance 3) Partition. - * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites - * this setting. - */ -void t8_forest_set_balance (t8_forest_t forest, - const t8_forest_t set_from, - int no_repartition); - -/** Enable or disable the creation of a layer of ghost elements. - * On default no ghosts are created. - * \param [in] forest The forest. - * \param [in] do_ghost If non-zero a ghost layer will be created. - * \param [in] ghost_type Controls which neighbors count as ghost elements, - * currently only T8_GHOST_FACES is supported. This value - * is ignored if \a do_ghost = 0. - */ -void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, - t8_ghost_type_t ghost_type); - -/** Like \ref t8_forest_set_ghost but with the additional options to change the - * ghost algorithm. This is used for debugging and timing the algorithm. - * An application should almost always use \ref t8_forest_set_ghost. - * \param [in] ghost_version If 1, the iterative ghost algorithm for balanced forests is used. - * If 2, the iterativ algorithm for unbalanced forests. - * If 3, the top-down search algorithm for unbalanced forests. - * \see t8_forest_set_ghost - */ -void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, - t8_ghost_type_t ghost_type, - int ghost_version); - -/* TODO: use assertions and document that the forest_set (..., from) and - * set_load are mutually exclusive. */ -void t8_forest_set_load (t8_forest_t forest, - const char *filename); - -/** Compute the global number of elements in a forest as the sum - * of the local element counts. - * \param [in] forest The forest. - */ -void t8_forest_comm_global_num_elements (t8_forest_t forest); - -/** After allocating and adding properties to a forest, commit the changes. - * This call sets up the internal state of the forest. - * \param [in,out] forest Must be created with \ref t8_forest_init and - * specialized with t8_forest_set_* calls first. - */ -void t8_forest_commit (t8_forest_t forest); - -/** Return the maximum allowed refinement level for any element in a forest. - * \param [in] forest A forest. - * \return The maximum level of refinement that is allowed for - * an element in this forest. It is guarenteed that any tree - * in \a forest can be refined this many times and it is not - * allowed to refine further. - * \a forest must be committed before calling this function. - * For forest with a single element class (non-hybrid) maxlevel is the maximum - * refinement level of this element class, whilst for hybrid forests the maxlevel is - * the minimum of all maxlevels of the element classes in this forest. - */ -int t8_forest_get_maxlevel (t8_forest_t forest); - -/** Return the number of process local elements in the forest. - * \param [in] forest A forest. - * \return The number of elements on this process in \a forest. - * \a forest must be committed before calling this function. - */ -t8_locidx_t t8_forest_get_local_num_elements (t8_forest_t forest); - -/** Return the number of global elements in the forest. - * \param [in] forest A forest. - * \return The number of elements (summed over all processes) in \a forest. - * \a forest must be committed before calling this function. - */ -t8_gloidx_t t8_forest_get_global_num_elements (t8_forest_t forest); - -/** Return the number of ghost elements of a forest. - * \param [in] forest The forest. - * \return The number of ghost elements stored in the ghost - * structure of \a forest. 0 if no ghosts were constructed. - * \see t8_forest_set_ghost - * \a forest must be committed before calling this function. - */ -t8_locidx_t t8_forest_get_num_ghosts (t8_forest_t forest); - -/** Return the element class of a forest local tree. - * \param [in] forest The forest. - * \param [in] ltreeid The local id of a tree in \a forest. - * \return The element class of the tree \a ltreeid. - * \a forest must be committed before calling this function. - */ -t8_eclass_t t8_forest_get_eclass (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Given a global tree id compute the forest local id of this tree. - * If the tree is a local tree, then the local id is between 0 and the number - * of local trees. If the tree is not a local tree, a negative number is returned. - * \param [in] forest The forest. - * \param [in] gtreeid The global id of a tree. - * \return The tree's local id in \a forest, if it is a local tree. - * A negative number if not. - * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ -t8_locidx_t t8_forest_get_local_id (t8_forest_t forest, - t8_gloidx_t gtreeid); - -/** Given the local id of a tree in a forest, compute the tree's local id - * in the associated cmesh. - * \param [in] forest The forest. - * \param [in] ltreeid The local id of a tree or ghost in the forest. - * \return The local id of the tree in the cmesh associated with the forest. - * \a forest must be committed before calling this function. - * \note For forest local trees, this is the inverse function of \ref t8_forest_cmesh_ltreeid_to_ltreeid. - * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ -t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Given the local id of a tree in the coarse mesh of a forest, compute - * the tree's local id in the forest. - * \param [in] forest The forest. - * \param [in] ltreeid The local id of a tree in the coarse mesh of \a forest. - * \return The local id of the tree in the forest. -1 if the tree is not forest local. - * \a forest must be committed before calling this function. - * \note For forest local trees, this is the inverse function of \ref t8_forest_ltreeid_to_cmesh_ltreeid. - * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ -t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, - t8_locidx_t lctreeid); - -/** Given the local id of a tree in a forest, return the coarse tree of the - * cmesh that corresponds to this tree. - * \param [in] forest The forest. - * \param [in] ltreeid The local id of a tree in the forest. - * \return The coarse tree that matches the forest tree with local - * id \a ltreeid. - */ -t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Compute the leaf face neighbors of a forest. - * \param [in] forest The forest. Must have a valid ghost layer. - * \param [in] ltreeid A local tree id. - * \param [in] leaf A leaf in tree \a ltreeid of \a forest. - * \param [out] neighbor_leafs Unallocated on input. On output the neighbor - * leafs are stored here. - * \param [in] face The index of the face across which the face neighbors - * are searched. - * \param [out] dual_face On output the face id's of the neighboring elements' faces. - * \param [out] num_neighbors On output the number of neighbor leafs. - * \param [out] pelement_indices Unallocated on input. On output the element indices - * of the neighbor leafs are stored here. - * 0, 1, ... num_local_el - 1 for local leafs and - * num_local_el , ... , num_local_el + num_ghosts - 1 for ghosts. - * \param [out] pneigh_scheme On output the eclass scheme of the neighbor elements. - * \param [in] forest_is_balanced True if we know that \a forest is balanced, false - * otherwise. - * \note If there are no face neighbors, then *neighbor_leafs = NULL, num_neighbors = 0, - * and *pelement_indices = NULL on output. - * \note Currently \a forest must be balanced. - * \note \a forest must be committed before calling this function. - */ -void t8_forest_leaf_face_neighbors (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *leaf, - t8_element_t - **pneighbor_leafs[], - int face, - int *dual_faces[], - int *num_neighbors, - t8_locidx_t - **pelement_indices, - t8_eclass_scheme_c - **pneigh_scheme, - int forest_is_balanced); - -/** Exchange ghost information of user defined element data. - * \param[in] forest The forest. Must be committed. - * \param[in] element_data An array of length num_local_elements + num_ghosts - * storing one value for each local element and ghost in \a forest. - * After calling this function the entries for the ghost elements - * are update with the entries in the \a element_data array of - * the corresponding owning process. - * \note This function is collective and hence must be called by all processes in the forest's - * MPI Communicator. - */ -/* TODO: In \ref t8_forest_ghost_cxx we already implemented a begin and end function - * that allow for overlapping communication and computation. We will make them - * available in this interface in the future. */ -void t8_forest_ghost_exchange_data (t8_forest_t forest, - sc_array_t *element_data); - -/** Enable or disable profiling for a forest. If profiling is enabled, runtimes - * and statistics are collected during forest_commit. - * \param [in,out] forest The forest to be updated. - * \param [in] set_profiling If true, profiling will be enabled, if false - * disabled. - * - * Profiling is disabled by default. - * The forest must not be committed before calling this function. - * \see t8_forest_print_profile - */ -void t8_forest_set_profiling (t8_forest_t forest, - int set_profiling); - -/* TODO: document */ -void t8_forest_compute_profile (t8_forest_t forest); - -const sc_statinfo_t *t8_forest_profile_get_adapt_stats (t8_forest_t forest); - -const sc_statinfo_t *t8_forest_profile_get_ghost_stats (t8_forest_t forest); - -const sc_statinfo_t *t8_forest_profile_get_partition_stats (t8_forest_t - forest); - -const sc_statinfo_t *t8_forest_profile_get_commit_stats (t8_forest_t forest); - -const sc_statinfo_t *t8_forest_profile_get_balance_stats (t8_forest_t forest); - -const sc_statinfo_t *t8_forest_profile_get_balance_rounds_stats (t8_forest_t - forest); - -/** Print the collected statistics from a forest profile. - * \param [in] forest The forest. - * - * \a forest must be committed before calling this function. - * \see t8_forest_set_profiling - */ -void t8_forest_print_profile (t8_forest_t forest); - -/** Get the runtime of the last call to \ref t8_forest_adapt. - * \param [in] forest The forest. - * \return The runtime of adapt if profiling was activated. - * 0 otherwise. - * \a forest must be committed before calling this function. - * \see t8_forest_set_profiling - * \see t8_forest_set_adapt - */ -double t8_forest_profile_get_adapt_time (t8_forest_t forest); - -/** Get the runtime of the last call to \ref t8_forest_partition. - * \param [in] forest The forest. - * \param [out] procs_sent On output the number of processes that this rank - * sent elements to in partition - * if profiling was activated. - * \return The runtime of partition if profiling was activated. - * 0 otherwise. - * \a forest must be committed before calling this function. - * \see t8_forest_set_profiling - * \see t8_forest_set_partition - */ -double t8_forest_profile_get_partition_time (t8_forest_t forest, - int *procs_sent); - -/** Get the runtime of the last call to \ref t8_forest_balance. - * \param [in] forest The forest. - * \param [out] balance_rounts On output the number of rounds in balance - * if profiling was activated. - * \return The runtime of balance if profiling was activated. - * 0 otherwise. - * \a forest must be committed before calling this function. - * \see t8_forest_set_profiling - * \see t8_forest_set_balance - */ -double t8_forest_profile_get_balance_time (t8_forest_t forest, - int *balance_rounds); - -/** Get the runtime of the last call to \ref t8_forest_create_ghosts. - * \param [in] forest The forest. - * \param [out] ghosts_sent On output the number of ghost elements sent to other processes - * if profiling was activated. - * \return The runtime of ghost if profiling was activated. - * 0 otherwise. - * \a forest must be committed before calling this function. - * \see t8_forest_set_profiling - * \see t8_forest_set_ghost - */ -double t8_forest_profile_get_ghost_time (t8_forest_t forest, - t8_locidx_t - *ghosts_sent); - -/** Get the waittime of the last call to \ref t8_forest_ghost_exchange_data. - * \param [in] forest The forest. - * \return The time of ghost_exchange_data that was spent waiting - * for other MPI processes, if profiling was activated. - * 0 otherwise. - * \a forest must be committed before calling this function. - * \see t8_forest_set_profiling - * \see t8_forest_ghost_exchange_data - */ -double t8_forest_profile_get_ghostexchange_waittime (t8_forest_t - forest); - -/** Print the ghost structure of a forest. Only used for debugging. */ -void t8_forest_ghost_print (t8_forest_t forest); - -/** Change the cmesh associated to a forest to a partitioned cmesh that - * is partitioned according to the tree distribution in the forest. - * \param [in,out] forest The forest. - * \param [in] comm The MPI communicator that is used to partition - * and commit the cmesh. - * \param [in] set_profiling If true, profiling for the new cmesh - * will be enabled. \see t8_cmesh_set_profiling, \see t8_cmesh_print_profile - * \see t8_cmesh.h - */ -void t8_forest_partition_cmesh (t8_forest_t forest, - sc_MPI_Comm comm, - int set_profiling); - -/** Return the mpi communicator associated to a forest. - * \param [in] forest The forest. - * \return The mpi communicator of \a forest. - * \a forest must be committed before calling this function. - */ -sc_MPI_Comm t8_forest_get_mpicomm (t8_forest_t forest); - -/** Return the global id of the first local tree of a forest. - * \param [in] forest The forest. - * \return The global id of the first local tree in \a forest. - */ -t8_gloidx_t t8_forest_get_first_local_tree_id (t8_forest_t forest); - -/** Return the number of local trees of a given forest. - * \param [in] forest The forest. - * \return The number of local trees of that forest. - */ -t8_locidx_t t8_forest_get_num_local_trees (t8_forest_t forest); - -/** Return the number of ghost trees of a given forest. - * \param [in] forest The forest. - * \return The number of ghost trees of that forest. - */ -t8_locidx_t t8_forest_get_num_ghost_trees (t8_forest_t forest); - -/** Return the number of global trees of a given forest. - * \param [in] forest The forest. - * \return The number of global trees of that forest. - */ -t8_gloidx_t t8_forest_get_num_global_trees (t8_forest_t forest); - -/** Return the global id of a local tree or a ghost tree. - * \param [in] forest The forest. - * \param [in] ltreeid An id 0 <= \a ltreeid < num_local_trees + num_ghosts - * specifying a local tree or ghost tree. - * \return The global id corresponding to the tree with local id \a ltreeid. - * \a forest must be committed before calling this function. - * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ -t8_gloidx_t t8_forest_global_tree_id (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Return a pointer to a tree in a forest. - * \param [in] forest The forest. - * \param [in] ltree_id The local id of the tree. - * \return A pointer to the tree with local id \a ltree_id. - * \a forest must be committed before calling this function. - */ -t8_tree_t t8_forest_get_tree (t8_forest_t forest, - t8_locidx_t ltree_id); - -/** Return a pointer to the vertex coordinates of a tree. - * \param [in] forest The forest. - * \param [in] ltreeid The id of a local tree. - * \return If stored, a pointer to the vertex coordinates of \a tree. - * If no coordinates for this tree are found, NULL. - */ -double *t8_forest_get_tree_vertices (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Return the array of leaf elements of a local tree in a forest. - * \param [in] forest The forest. - * \param [in] ltree_id The local id of a local tree of \a forest. - * \return An array of t8_element_t * storing all leaf elements - * of this tree. - */ -t8_element_array_t *t8_forest_tree_get_leafs (t8_forest_t forest, - t8_locidx_t ltree_id); - -/** Return a cmesh associated to a forest. - * \param [in] forest The forest. - * \return The cmesh associated to the forest. - */ -t8_cmesh_t t8_forest_get_cmesh (t8_forest_t forest); - -/** Return an element of the forest. - * \param [in] forest The forest. - * \param [in] lelement_id The local id of an element in \a forest. - * \param [out] ltreeid If not NULL, on output the local tree id of the tree in which the - * element lies in. - * \return A pointer to the element. NULL if this element does not exist. - * \note This function performs a binary search. For constant access, use \ref t8_forest_get_element_in_tree - * \a forest must be committed before calling this function. - */ -t8_element_t *t8_forest_get_element (t8_forest_t forest, - t8_locidx_t lelement_id, - t8_locidx_t *ltreeid); - -/** Return an element of a local tree in a forest. - * \param [in] forest The forest. - * \param [in] ltreeid An id of a local tree in the forest. - * \param [in] leid_in_tree The index of an element in the tree. - * \return A pointer to the element. - * \note If the tree id is know, this function should be preferred over \ref t8_forest_get_element. - * \a forest must be committed before calling this function. - */ -t8_element_t *t8_forest_get_element_in_tree (t8_forest_t forest, - t8_locidx_t ltreeid, - t8_locidx_t leid_in_tree); - -/** Return the number of elements of a tree. - * \param [in] forest The forest. - * \param [in] ltreeid A local id of a tree. - * \return The number of elements in the local tree \a ltreeid. - */ -t8_locidx_t t8_forest_get_tree_num_elements (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Return the element offset of a local tree, that is the number of elements - * in all trees with smaller local treeid. - * \param [in] forest The forest. - * \param [in] ltreeid A local id of a tree. - * \return The number of leaf elements on all local tree with - * id < \a ltreeid. - * \note \a forest must be committed before calling this function. - */ -t8_locidx_t t8_forest_get_tree_element_offset (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Return the number of elements of a tree. - * \param [in] tree A tree in a forest. - * \return The number of elements of that tree. - */ -t8_locidx_t t8_forest_get_tree_element_count (t8_tree_t tree); - -/** Return the eclass of a tree in a forest. - * \param [in] forest The forest. - * \param [in] ltreeid The local id of a tree (local or ghost) in \a forest. - * \return The element class of the tree with local id \a ltreeid. - */ -t8_eclass_t t8_forest_get_tree_class (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Compute the global index of the first local element of a forest. - * This function is collective. - * \param [in] forest A committed forest, whose first element's index is computed. - * \return The global index of \a forest's first local element. - * Forest must be committed when calling this function. - * This function is collective and must be called on each process. - */ -t8_gloidx_t t8_forest_get_first_local_element_id (t8_forest_t forest); - -/** Return the element scheme associated to a forest. - * \param [in] forest. A committed forest. - * \return The element scheme of the forest. - * \see t8_forest_set_scheme - */ -t8_scheme_cxx_t *t8_forest_get_scheme (t8_forest_t forest); - -/** Return the eclass scheme of a given element class associated to a forest. - * \param [in] forest. A committed forest. - * \param [in] eclass. An element class. - * \return The eclass scheme of \a eclass associated to forest. - * \see t8_forest_set_scheme - * \note The forest is not required to have trees of class \a eclass. - */ -t8_eclass_scheme_c *t8_forest_get_eclass_scheme (t8_forest_t forest, - t8_eclass_t eclass); - -/** Return the eclass of the tree in which a face neighbor of a given element - * lies. - * \param [in] forest. A committed forest. - * \param [in] ltreeid. The local tree in which the element lies. - * \param [in] elem. An element in the tree \a ltreeid. - * \param [in] face. A face number of \a elem. - * \return The local tree id of the tree in which the face - * neighbor of \a elem across \a face lies. - */ -t8_eclass_t t8_forest_element_neighbor_eclass (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t - *elem, int face); - -/** Construct the face neighbor of an element, possibly across tree boundaries. - * Returns the global tree-id of the tree in which the neighbor element lies in. - * - * \param [in] elem The element to be considered. - * \param [in,out] neigh On input an allocated element of the scheme of the - * face_neighbors eclass. - * On output, this element's data is filled with the - * data of the face neighbor. If the neighbor does not exist - * the data could be modified arbitrarily. - * \param [in] neigh_scheme The eclass scheme of \a neigh. - * \param [in] face The number of the face along which the neighbor should be - * constructed. - * \param [out] neigh_face The number of the face viewed from perspective of \a neigh. - * \return The global tree-id of the tree in which \a neigh is in. - * -1 if there exists no neighbor across that face. - */ -t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *elem, - t8_element_t *neigh, - t8_eclass_scheme_c - *neigh_scheme, int face, - int *neigh_face); - -/* TODO: implement */ -void t8_forest_save (t8_forest_t forest); - -/** Write the forest in a parallel vtu format. Extended version. - * See \ref t8_forest_write_vtk for the standard version of this function. - * Writes one master .pvtu file and each process writes in its own .vtu file. - * If linked and not otherwise specified, the VTK API is used. - * If the VTK library is not linked, an ASCII file is written. - * This may change in accordance with \a write_ghosts, \a write_curved and - * \a do_not_use_API, because the export of ghosts is not yet available with - * the VTK API and the export of curved elements is not available with the - * inbuilt function to write ASCII files. The function will for example - * still use the VTK API to satisfy \a write_curved, even if \a do_not_use_API - * is set to true. - * Forest must be committed when calling this function. - * This function is collective and must be called on each process. - * \param [in] forest The forest to write. - * \param [in] fileprefix The prefix of the files where the vtk will - * be stored. The master file is then fileprefix.pvtu - * and the process with rank r writes in the file - * fileprefix_r.vtu. - * \param [in] write_treeid If true, the global tree id is written for each element. - * \param [in] write_mpirank If true, the mpirank is written for each element. - * \param [in] write_level If true, the refinement level is written for each element. - * \param [in] write_element_id If true, the global element id is written for each element. - * \param [in] write_ghosts If true, each process additionally writes its ghost elements. - * For ghost element the treeid is -1. - * \param [in] write_curved If true, write the elements as curved element types from vtk. - * \param [in] do_not_use_API Do not use the VTK API, even if linked and available. - * \param [in] num_data Number of user defined double valued data fields to write. - * \param [in] data Array of t8_vtk_data_field_t of length \a num_data - * providing the user defined per element data. - * If scalar and vector fields are used, all scalar fields - * must come first in the array. - * \return True if successful, false if not (process local). - * See also \ref t8_forest_write_vtk . - */ -int t8_forest_write_vtk_ext (t8_forest_t forest, - const char *fileprefix, - int write_treeid, - int write_mpirank, - int write_level, - int write_element_id, - int write_ghosts, - int write_curved, - int do_not_use_API, - int num_data, - t8_vtk_data_field_t *data); - -/** Write the forest in a parallel vtu format. Writes one master - * .pvtu file and each process writes in its own .vtu file. - * If linked, the VTK API is used. - * If the VTK library is not linked, an ASCII file is written. - * This function writes the forest elements, the tree id, element level, mpirank and element id as data. - * Forest must be committed when calling this function. - * This function is collective and must be called on each process. - * For more options use \ref t8_forest_write_vtk_ext - * \param [in] forest The forest to write. - * \param [in] fileprefix The prefix of the files where the vtk will - * be stored. The master file is then fileprefix.pvtu - * and the process with rank r writes in the file - * fileprefix_r.vtu. - * \return True if successful, false if not (process local). - */ -int t8_forest_write_vtk (t8_forest_t forest, - const char *fileprefix); - -/* TODO: implement */ -void t8_forest_iterate (t8_forest_t forest); - -/** Compute the coordinates of a given vertex of an element if a geometry - * for this tree is registered in the forest's cmesh. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \param [in] corner_number The corner number, in Z-order, of the vertex which should be computed. - * \param [out] coordinates On input an allocated array to store 3 doubles, on output - * the x, y and z coordinates of the vertex. - */ -void t8_forest_element_coordinate (t8_forest_t forest, - t8_locidx_t ltree_id, - const t8_element_t *element, - int corner_number, - double *coordinates); - -/** Compute the coordinates of the centroid of an element if a geometry - * for this tree is registered in the forest's cmesh. - * The centroid is the sum of all corner vertices divided by the number of corners. - * The centroid can be seen as the midpoint of an element and thus can for example be used - * to compute level-set values or the distance between two elements. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \param [out] coordinates On input an allocated array to store 3 doubles, on output - * the x, y and z coordinates of the centroid. - */ -void t8_forest_element_centroid (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *element, - double *coordinates); - -/** Compute the diameter of an element if a geometry - * for this tree is registered in the forest's cmesh. - * This is only an approximation. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \return The diameter of the element. - * \note For lines the value is exact while for other element types it is only - * an approximation. - */ -double t8_forest_element_diam (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *element); - -/** Compute the volume of an element if a geometry - * for this tree is registered in the forest's cmesh. - * This is only an approximation. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \return The diameter of the element. - * \note This function assumes d-linear interpolation for the - * tree vertex coordinates. - * \a forest must be committed when calling this function. - */ -double t8_forest_element_volume (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *element); - -/** Compute the area of an element's face if a geometry - * for this tree is registered in the forest's cmesh. - * Currently implemented for 2D elements only. - * This is only an approximation. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \param [in] face A face of \a element. - * \return The area of \a face. - * \a forest must be committed when calling this function. - */ -double t8_forest_element_face_area (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *element, - int face); - -/** Compute the vertex coordinates of the centroid of an element's face if a geometry - * for this tree is registered in the forest's cmesh. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \param [in] face A face of \a element. - * \param [out] normal On output the centroid of \a face. - * \a forest must be committed when calling this function. - */ -void t8_forest_element_face_centroid (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t - *element, int face, - double centroid[3]); - -/** Compute the normal vector of an element's face if a geometry - * for this tree is registered in the forest's cmesh. - * Currently implemented for 2D elements only. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \param [in] face A face of \a element. - * \param [out] normal On output the normal vector of \a element at \a face. - * \a forest must be committed when calling this function. - */ -void t8_forest_element_face_normal (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t - *element, int face, - double normal[3]); - -/** Query whether a given point lies inside an element or not. For bilinearly interpolated elements. - * \note For 2D quadrilateral elements this function is only an approximation. It is correct - * if the four vertices lie in the same plane, but it may produce only approximate results if - * the vertices do not lie in the same plane. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \param [in] point 3-dimensional coordinates of the point to check - * \param [in] tolerance tolerance that we allow the point to not exactly match the element. - * If this value is larger we detect more points. - * If it is zero we probably do not detect points even if they are inside - * due to rounding errors. - * \return True (non-zero) if \a point lies within \a element, false otherwise. - * The return value is also true if the point lies on the element boundary. - * Thus, this function may return true for different leaf elements, if they - * are neighbors and the point lies on the common boundary. - */ -int t8_forest_element_point_inside (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t - *element, - const double point[3], - const double tolerance); - -/* TODO: if set level and partition/adapt/balance all give NULL, then - * refine uniformly and partition/adapt/balance the unfiform forest. */ -/** Build a uniformly refined forest on a coarse mesh. - * \param [in] cmesh A coarse mesh. - * \param [in] scheme An eclass scheme. - * \param [in] level An initial uniform refinement level. - * \param [in] do_face_ghost If true, a layer of ghost elements is created for the forest. - * \param [in] comm MPI communicator to use. - * \return A uniform forest with coarse mesh \a cmesh, eclass_scheme - * \a scheme and refinement level \a level. - * \note This is equivalent to calling \ref t8_forest_init, \ref t8_forest_set_cmesh, - * \ref t8_forest_set_scheme, \ref t8_forest_set_level, and \ref t8_forest_commit. - */ -t8_forest_t t8_forest_new_uniform (t8_cmesh_t cmesh, - t8_scheme_cxx_t *scheme, - int level, int do_face_ghost, - sc_MPI_Comm comm); - -/** Build a adapted forest from another forest. - * \param [in] forest_from The forest to refine - * \param [in] adapt_fn Adapt function to use - * \param [in] replace_fn Replace function to use - * \param [in] recursive If true adptation is recursive - * \param [in] do_face_ghost If true, a layer of ghost elements is created for the forest. - * \param [in] user_data If not NULL, the user data pointer of the forest is set to this value. - * \return A new forest that is adapted from \a forest_from. - * \note This is equivalent to calling \ref t8_forest_init, \ref t8_forest_set_adapt, - * \red t8_forest_set_ghost, and \ref t8_forest_commit - */ -/* TODO: make user_data const. */ -t8_forest_t t8_forest_new_adapt (t8_forest_t forest_from, - t8_forest_adapt_t adapt_fn, - int recursive, int do_face_ghost, - void *user_data); - -/** Increase the reference counter of a forest. - * \param [in,out] forest On input, this forest must exist with positive - * reference count. It may be in any state. - */ -void t8_forest_ref (t8_forest_t forest); - -/** Decrease the reference counter of a forest. - * If the counter reaches zero, this forest is destroyed. - * In this case, the forest dereferences its cmesh and scheme members. - * \param [in,out] pforest On input, the forest pointed to must exist - * with positive reference count. It may be in - * any state. If the reference count reaches - * zero, the forest is destroyed and this pointer - * set to NULL. - * Otherwise, the pointer is not changed and - * the forest is not modified in other ways. - */ -void t8_forest_unref (t8_forest_t *pforest); - -T8_EXTERN_C_END (); - -#endif /* !T8_FOREST_H */ - -#endif \ No newline at end of file From 70787b68f3c36ba32ecde27e06cd1aa45087d610 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Wed, 12 Apr 2023 08:41:22 +0200 Subject: [PATCH 073/255] Delete includes that are not needed --- src/t8_forest_general.h | 6 +----- src/t8_forest_geometrical.h | 4 ---- src/t8_forest_io.h | 3 --- src/t8_forest_profiling.h | 2 -- 4 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/t8_forest_general.h b/src/t8_forest_general.h index 91347c6f1e..ff47e31271 100644 --- a/src/t8_forest_general.h +++ b/src/t8_forest_general.h @@ -29,12 +29,8 @@ #ifndef T8_FOREST_GENERAL_H #define T8_FOREST_GENERAL_H -/*TODO: Check if all headers are needed */ #include -#include -#include -#include -#include +#include /* also includes t8_element.h and sc_containers.h */ /** Opaque pointer to a forest implementation. */ typedef struct t8_forest *t8_forest_t; diff --git a/src/t8_forest_geometrical.h b/src/t8_forest_geometrical.h index 8bf406eee1..56e6873933 100644 --- a/src/t8_forest_geometrical.h +++ b/src/t8_forest_geometrical.h @@ -29,12 +29,8 @@ #ifndef T8_FOREST_GEOMETRICAL_H #define T8_FOREST_GEOMETRICAL_H -/*TODO: Check if all headers are needed */ #include #include -#include -#include -#include T8_EXTERN_C_BEGIN (); diff --git a/src/t8_forest_io.h b/src/t8_forest_io.h index 6e40f1e017..3c674fa946 100644 --- a/src/t8_forest_io.h +++ b/src/t8_forest_io.h @@ -30,11 +30,8 @@ #define T8_FOREST_IO_H /*TODO: Check if all headers are needed */ -#include #include -#include #include -#include T8_EXTERN_C_BEGIN (); diff --git a/src/t8_forest_profiling.h b/src/t8_forest_profiling.h index 8c43ff72fb..0eb1fa5837 100644 --- a/src/t8_forest_profiling.h +++ b/src/t8_forest_profiling.h @@ -139,8 +139,6 @@ double t8_forest_profile_get_ghost_time (t8_forest_t forest, double t8_forest_profile_get_ghostexchange_waittime (t8_forest_t forest); - - T8_EXTERN_C_END (); #endif /* !T8_FOREST_PROFILING_H */ From da4862db67414d2f20072f76961e7ab44e47ea63 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 12 Apr 2023 10:16:59 +0200 Subject: [PATCH 074/255] refractoring --- .../t8_default_vertex/t8_default_vertex_cxx.cxx | 4 ++-- .../t8_default/t8_default_vertex/t8_dvertex_bits.c | 5 +++-- .../t8_default/t8_default_vertex/t8_dvertex_bits.h | 8 +++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx index 9902f69b13..4b8da2ed98 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx @@ -331,8 +331,8 @@ t8_default_scheme_vertex_c::t8_element_reference_coords (const t8_element_t const { T8_ASSERT (t8_element_is_valid (elem)); - t8_dvertex_reference_coords ((const t8_dvertex_t *) elem, ref_coords, - out_coords); + t8_dvertex_compute_reference_coords ((const t8_dvertex_t *) elem, + ref_coords, out_coords); } #ifdef T8_ENABLE_DEBUG diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c index b9034d2317..3cc63d46eb 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c @@ -174,8 +174,9 @@ t8_dvertex_vertex_ref_coords (const t8_dvertex_t *elem, const int vertex, } void -t8_dvertex_reference_coords (const t8_dvertex_t *elem, - const double *ref_coords, double *out_coords) +t8_dvertex_compute_reference_coords (const t8_dvertex_t *elem, + const double *ref_coords, + double *out_coords) { T8_ASSERT (abs (ref_coords[0]) <= T8_PRECISION_EPS); out_coords[0] = 0; diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h index 8daa145594..5718871003 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h @@ -201,9 +201,11 @@ void t8_dvertex_vertex_ref_coords (const t8_dvertex_t *elem, * \param [in] ref_coords The reference coordinate inside the vertex (must be 0). * \param [out] out_coords The coordinates of the computed vertex, must have one entry (will be set to 0). */ -void t8_dvertex_reference_coords (const t8_dvertex_t *elem, - const double *ref_coords, - double *out_coords); +void t8_dvertex_compute_reference_coords (const t8_dvertex_t + *elem, + const double + *ref_coords, + double *out_coords); /** Computes the linear position of a vertex in an uniform grid. * \param [in] vertex vertex whose id will be computed. From 26d45aca364a6a1538aad03daab9ce7de68c491d Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 12 Apr 2023 10:17:32 +0200 Subject: [PATCH 075/255] code optimization --- .../t8_default_pyramid/t8_dpyramid_bits.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c index 6a9aabb1b6..e543173ae6 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c @@ -1695,25 +1695,31 @@ t8_dpyramid_compute_coords (const t8_dpyramid_t *p, const int vertex, coords[2] = p->pyramid.z; switch (vertex) { case 0: - coords[2] += (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) ? length : 0; + if (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) + coords[2] += length; break; case 1: coords[0] += length; - coords[2] += (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) ? length : 0; + if (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) + coords[2] += length; break; case 2: coords[1] += length; - coords[2] += (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) ? length : 0; + if (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) + coords[2] += length; break; case 3: coords[0] += length; coords[1] += length; - coords[2] += (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) ? length : 0; + if (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) + coords[2] += length; break; case 4: - coords[0] += (p->pyramid.type == T8_DPYRAMID_FIRST_TYPE) ? length : 0; - coords[1] += (p->pyramid.type == T8_DPYRAMID_FIRST_TYPE) ? length : 0; - coords[2] += (p->pyramid.type == T8_DPYRAMID_FIRST_TYPE) ? length : 0; + if (p->pyramid.type == T8_DPYRAMID_FIRST_TYPE) { + coords[0] += length; + coords[1] += length; + coords[2] += length; + } break; } } From 3705d9b006cc97f74a990337f407daefe1282e5a Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Wed, 12 Apr 2023 10:17:47 +0200 Subject: [PATCH 076/255] Delete includes that are not needed --- src/t8_forest_profiling.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/t8_forest_profiling.h b/src/t8_forest_profiling.h index 0eb1fa5837..9d3e273bb8 100644 --- a/src/t8_forest_profiling.h +++ b/src/t8_forest_profiling.h @@ -32,9 +32,6 @@ /*TODO: Check if all headers are needed */ #include #include -#include -#include -#include T8_EXTERN_C_BEGIN (); From a92281653106c6104b4b0a31c8da64b9da9f3cd4 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 12 Apr 2023 14:09:33 +0200 Subject: [PATCH 077/255] enable element ref coords for pyramids --- .../t8_default_pyramid_cxx.cxx | 4 +- .../t8_default_pyramid/t8_dpyramid_bits.c | 59 +++++++++++++++---- .../t8_default_pyramid/t8_dpyramid_bits.h | 20 ++++++- 3 files changed, 67 insertions(+), 16 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx index 4aee0f70b3..87c9be858a 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx @@ -485,7 +485,9 @@ t8_default_scheme_pyramid_c::t8_element_reference_coords (const t8_element_t double *coords_out) const { - SC_ABORTF ("Not implemented\n"); + T8_ASSERT (t8_element_is_valid (elem)); + t8_dpyramid_compute_reference_coords ((const t8_dpyramid_t *) elem, + ref_coords, coords_out); } int diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c index e543173ae6..2e817dde8b 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c @@ -1683,39 +1683,39 @@ t8_dpyramid_successor (const t8_dpyramid_t *elem, t8_dpyramid_t *succ, } void -t8_dpyramid_compute_coords (const t8_dpyramid_t *p, const int vertex, +t8_dpyramid_compute_coords (const t8_dpyramid_t *elem, const int vertex, int coords[]) { T8_ASSERT (0 <= vertex && vertex < T8_DPYRAMID_CORNERS); - if (t8_dpyramid_shape (p) == T8_ECLASS_PYRAMID) { - const t8_dpyramid_coord_t length = T8_DPYRAMID_LEN (p->pyramid.level); - coords[0] = p->pyramid.x; - coords[1] = p->pyramid.y; - coords[2] = p->pyramid.z; + if (t8_dpyramid_shape (elem) == T8_ECLASS_PYRAMID) { + const t8_dpyramid_coord_t length = T8_DPYRAMID_LEN (elem->pyramid.level); + coords[0] = elem->pyramid.x; + coords[1] = elem->pyramid.y; + coords[2] = elem->pyramid.z; switch (vertex) { case 0: - if (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) + if (elem->pyramid.type == T8_DPYRAMID_SECOND_TYPE) coords[2] += length; break; case 1: coords[0] += length; - if (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) + if (elem->pyramid.type == T8_DPYRAMID_SECOND_TYPE) coords[2] += length; break; case 2: coords[1] += length; - if (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) + if (elem->pyramid.type == T8_DPYRAMID_SECOND_TYPE) coords[2] += length; break; case 3: coords[0] += length; coords[1] += length; - if (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) + if (elem->pyramid.type == T8_DPYRAMID_SECOND_TYPE) coords[2] += length; break; case 4: - if (p->pyramid.type == T8_DPYRAMID_FIRST_TYPE) { + if (elem->pyramid.type == T8_DPYRAMID_FIRST_TYPE) { coords[0] += length; coords[1] += length; coords[2] += length; @@ -1725,7 +1725,7 @@ t8_dpyramid_compute_coords (const t8_dpyramid_t *p, const int vertex, } else { T8_ASSERT (0 <= vertex && vertex < T8_DTET_CORNERS); - t8_dtet_compute_coords (&(p->pyramid), vertex, coords); + t8_dtet_compute_coords (&(elem->pyramid), vertex, coords); } } @@ -1742,6 +1742,41 @@ t8_dpyramid_vertex_reference_coords (const t8_dpyramid_t *elem, coords[2] = coords_int[2] / (double) T8_DPYRAMID_ROOT_LEN; } +void +t8_dpyramid_compute_reference_coords (const t8_dpyramid_t *elem, + const double *ref_coords, + double *out_coords) +{ + T8_ASSERT (ref_coords != NULL); + T8_ASSERT (t8_element_is_valid (elem)); + if (t8_dpyramid_shape (elem) == T8_ECLASS_PYRAMID) { + const t8_dpyramid_coord_t length = T8_DPYRAMID_LEN (elem->pyramid.level); + out_coords[0] = elem->pyramid.x; + out_coords[1] = elem->pyramid.y; + out_coords[2] = elem->pyramid.z; + + if (elem->pyramid.type == T8_DPYRAMID_FIRST_TYPE) { + out_coords[0] += ref_coords[0] * length; + out_coords[1] += ref_coords[1] * length; + out_coords[2] += ref_coords[2] * length; + } + else { + out_coords[0] += ref_coords[0] * length * (1 - ref_coords[2]); + out_coords[1] += ref_coords[1] * length * (1 - ref_coords[2]); + out_coords[2] += (1 - ref_coords[2]) * length; + } + + /*scale the coordinates onto the reference cube */ + out_coords[0] /= (double) T8_DPYRAMID_ROOT_LEN; + out_coords[1] /= (double) T8_DPYRAMID_ROOT_LEN; + out_coords[2] /= (double) T8_DPYRAMID_ROOT_LEN; + } + else { + t8_dtet_compute_reference_coords (&(elem->pyramid), ref_coords, + out_coords); + } +} + /** * Compute the ancestor of \a pyra on level \a level. * diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.h b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.h index c7488e837b..09eaccdcc2 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.h +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.h @@ -261,12 +261,12 @@ void t8_dpyramid_last_descendant_face (const t8_dpyramid_t *p, const int level); /** Compute the coordinates of a vertex of a pyramid. - * \param [in] p Input pyramid. - * \param [in] vertex The number of the vertex. + * \param [in] elem Input pyramid. + * \param [in] vertex The number of the vertex. * \param [out] coords An array of 3 t8_dpyramid_coord_t that * will be filled with the coordinates of the vertex. */ -void t8_dpyramid_compute_coords (const t8_dpyramid_t *p, +void t8_dpyramid_compute_coords (const t8_dpyramid_t *elem, const int vertex, int coords[]); @@ -372,6 +372,20 @@ void t8_dpyramid_vertex_reference_coords (const t8_dpyramid_t const int vertex, double coords[]); +/** Convert a point in the reference space of a pyramid element to a point in + * the reference space of the tree (level 0) embedded in [0,1]^3. + * \param [in] elem Input pyramid. + * \param [in] ref_coords The reference coordinates inside the + * pyramid element [0,1]^3 + * \param [out] out_coords An array of 3 doubles that will be filled with the + * reference coordinates in the tree of the pyramid. + */ +void t8_dpyramid_compute_reference_coords (const t8_dpyramid_t + *elem, + const double + *ref_coords, + double *out_coords); + /** * Compute the nearest common ancestor of two elements * \param [in] pyra1 The first pyramid From ad2df691d8b60b364fdc6c1ec0025d9a2c7a1aaa Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 12 Apr 2023 14:10:03 +0200 Subject: [PATCH 078/255] enable quadratic pyramids in vtk --- src/t8_forest/t8_forest_vtk.cxx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index 90d24a9a63..86df97feae 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -184,9 +185,9 @@ const double t8_forest_vtk_point_to_element_ref_coords[T8_ECLASS_COUNT] {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} }, { /* T8_ECLASS_PYRAMID */ - {0, 0, 0}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, - {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, - {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, + {0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}, {1, 1, 1}, + {0.5, 0, 0}, {1, 0.5, 0}, {0.5, 1, 0}, {0, 0.5, 0}, {0.5, 0.5, 0.5}, + {1, 0.5, 0.5}, {1, 1, 0.5}, {0.5, 1, 0.5}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1}, {-1, -1, -1} } }; @@ -459,6 +460,7 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, vtkNew < vtkQuadraticTetra > quadratictet; vtkNew < vtkQuadraticHexahedron > quadratichexa; vtkNew < vtkQuadraticWedge > quadraticprism; + vtkNew < vtkQuadraticPyramid > quadraticpyra; /* * The cellTypes Array stores the element types as integers(see vtk doc). @@ -577,8 +579,8 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, pvtkCell = quadraticprism; break; case T8_ECLASS_PYRAMID: - SC_CHECK_ABORT (element_shape != T8_ECLASS_PYRAMID, - "Quadratic Pyramids are not supported in vtk output"); + pvtkCell = quadraticpyra; + break; default: SC_ABORT_NOT_REACHED (); } From f2ffc4dd9da8cc489d3bcbebf2b549d0f266dbff Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 12 Apr 2023 16:07:37 +0200 Subject: [PATCH 079/255] add element ref coords interface --- src/t8_element_cxx.hxx | 14 ++++++++++++++ .../t8_default_common/t8_default_common_cxx.hxx | 14 ++++++++++++++ .../t8_default_hex/t8_default_hex_cxx.cxx | 11 +++++++++++ .../t8_default_hex/t8_default_hex_cxx.hxx | 14 ++++++++++++++ .../t8_default_line/t8_default_line_cxx.cxx | 11 +++++++++++ .../t8_default_line/t8_default_line_cxx.hxx | 14 ++++++++++++++ .../t8_default_prism/t8_default_prism_cxx.cxx | 11 +++++++++++ .../t8_default_prism/t8_default_prism_cxx.hxx | 14 ++++++++++++++ .../t8_default_pyramid/t8_default_pyramid_cxx.cxx | 13 +++++++++++++ .../t8_default_pyramid/t8_default_pyramid_cxx.hxx | 14 ++++++++++++++ .../t8_default_quad/t8_default_quad_cxx.cxx | 11 +++++++++++ .../t8_default_quad/t8_default_quad_cxx.hxx | 14 ++++++++++++++ .../t8_default_tet/t8_default_tet_cxx.cxx | 11 +++++++++++ .../t8_default_tet/t8_default_tet_cxx.hxx | 14 ++++++++++++++ .../t8_default_tri/t8_default_tri_cxx.cxx | 11 +++++++++++ .../t8_default_tri/t8_default_tri_cxx.hxx | 14 ++++++++++++++ .../t8_default_vertex/t8_default_vertex_cxx.cxx | 13 +++++++++++++ .../t8_default_vertex/t8_default_vertex_cxx.hxx | 14 ++++++++++++++ 18 files changed, 232 insertions(+) diff --git a/src/t8_element_cxx.hxx b/src/t8_element_cxx.hxx index d08916b044..92b9c10534 100644 --- a/src/t8_element_cxx.hxx +++ b/src/t8_element_cxx.hxx @@ -605,6 +605,20 @@ public: double coords[]) const = 0; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] out_coords The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const = 0; + /* TODO: deactivate */ /** Return a pointer to a t8_element in an array indexed by a size_t. * \param [in] array The \ref sc_array storing \t t8_element_t pointers. diff --git a/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx b/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx index 786fcd58d6..9bf8d90fb4 100644 --- a/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx @@ -109,6 +109,20 @@ public: int vertex, int coords[]) const = 0; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] out_coords The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const = 0; + /** Get the integer coordinates of the anchor node of an element. * The default scheme implements the Morton type SFCs. In these SFCs the * elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx index 91aa03abb0..a278b26962 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx @@ -657,6 +657,17 @@ t8_default_scheme_hex_c::t8_element_vertex_reference_coords (const coords[2] /= (double) P8EST_ROOT_LEN; } +void +t8_default_scheme_hex_c::t8_element_reference_coords (const t8_element_t *t, + const double + *ref_coords, + const void *user_data, + double *out_coords) + const +{ + SC_ABORTF ("Not implemented\n"); +} + int t8_default_scheme_hex_c::t8_element_refines_irregular () const { diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx index a1eaf1c103..30056e6895 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx @@ -567,6 +567,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] out_coords The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because hexs refine regularly diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx index b88165b248..abd28b1777 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx @@ -367,6 +367,17 @@ t8_default_scheme_line_c::t8_element_vertex_reference_coords (const t8_dline_vertex_ref_coords ((const t8_dline_t *) elem, vertex, coords); } +void +t8_default_scheme_line_c::t8_element_reference_coords (const t8_element_t *t, + const double + *ref_coords, + const void *user_data, + double *out_coords) + const +{ + SC_ABORTF ("Not implemented\n"); +} + int t8_default_scheme_line_c::t8_element_root_len (const t8_element_t *elem) const { diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx index a6d6a8ffd2..2eb0e5eb5b 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx @@ -587,6 +587,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] out_coords The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because lines refine regularly diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx index bd19ad7df4..269b4401ae 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx @@ -480,6 +480,17 @@ t8_default_scheme_prism_c::t8_element_vertex_reference_coords (const t8_dprism_vertex_ref_coords ((const t8_dprism_t *) elem, vertex, coords); } +void +t8_default_scheme_prism_c::t8_element_reference_coords (const t8_element_t *t, + const double + *ref_coords, + const void *user_data, + double *out_coords) + const +{ + SC_ABORTF ("Not implemented\n"); +} + void t8_default_scheme_prism_c::t8_element_general_function (const t8_element_t *elem, diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx index 10d77a0f21..e33d53e2c3 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx @@ -596,6 +596,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] out_coords The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because prisms refine regularly diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx index 6e5ab79731..6c63ee4bf9 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx @@ -475,6 +475,19 @@ t8_default_scheme_pyramid_c::t8_element_vertex_reference_coords (const vertex, coords); } +void +t8_default_scheme_pyramid_c::t8_element_reference_coords (const t8_element_t + *t, + const double + *ref_coords, + const void + *user_data, + double *out_coords) + const +{ + SC_ABORTF ("Not implemented\n"); +} + int t8_default_scheme_pyramid_c::t8_element_refines_irregular () const { diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx index b7e7c23b83..976117ee99 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx @@ -615,6 +615,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] out_coords The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 1, because pyramids refine irregularly diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx index 2e89c43405..28cafd5c6c 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx @@ -790,6 +790,17 @@ t8_default_scheme_quad_c::t8_element_vertex_reference_coords (const coords[1] /= (double) P4EST_ROOT_LEN; } +void +t8_default_scheme_quad_c::t8_element_reference_coords (const t8_element_t *t, + const double + *ref_coords, + const void *user_data, + double *out_coords) + const +{ + SC_ABORTF ("Not implemented\n"); +} + void t8_default_scheme_quad_c::t8_element_new (int length, t8_element_t **elem) const { diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx index 46cba1eafe..df2b0dd65a 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx @@ -600,6 +600,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] out_coords The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because quads refine regularly diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx index faf2e2c39b..b627e2cf48 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx @@ -556,6 +556,17 @@ t8_default_scheme_tet_c::t8_element_vertex_reference_coords (const coords); } +void +t8_default_scheme_tet_c::t8_element_reference_coords (const t8_element_t *t, + const double + *ref_coords, + const void *user_data, + double *out_coords) + const +{ + SC_ABORTF ("Not implemented\n"); +} + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. */ diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx index d3895bd325..11550d1920 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx @@ -582,6 +582,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] out_coords The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because tets refine regularly diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx index 4bf8fefb89..e858a25a8d 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx @@ -575,6 +575,17 @@ t8_default_scheme_tri_c::t8_element_vertex_reference_coords (const coords); } +void +t8_default_scheme_tri_c::t8_element_reference_coords (const t8_element_t *t, + const double + *ref_coords, + const void *user_data, + double *out_coords) + const +{ + SC_ABORTF ("Not implemented\n"); +} + int t8_default_scheme_tri_c::t8_element_refines_irregular () const { diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx index 44e0f97227..be4a48c99e 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx @@ -575,6 +575,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] out_coords The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because tris refine regularly diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx index 8fb279a219..03b8ee9a39 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx @@ -320,6 +320,19 @@ t8_default_scheme_vertex_c::t8_element_vertex_reference_coords (const t8_dvertex_vertex_ref_coords ((const t8_dvertex_t *) elem, vertex, coords); } +void +t8_default_scheme_vertex_c::t8_element_reference_coords (const t8_element_t + *t, + const double + *ref_coords, + const void + *user_data, + double *out_coords) + const +{ + SC_ABORTF ("Not implemented\n"); +} + #ifdef T8_ENABLE_DEBUG /* *INDENT-OFF* */ /* indent bug, indent adds a second "const" modifier */ diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx index 31b85e7d57..55db8f8e5a 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx @@ -615,6 +615,20 @@ public: double coords[]) const; + /** Convert a point in the reference space of an element to a point in the + * reference space of the tree. + * + * \param [in] t The element. + * \param [in] coords_input The coordinates of the point in the reference space of the element. + * \param [in] user_data User data. + * \param [out] out_coords The coordinates of the point in the reference space of the tree. + */ + virtual void t8_element_reference_coords (const t8_element_t *t, + const double *ref_coords, + const void *user_data, + double *out_coords) + const; + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because vertices refine regularly From 5d667af9b3de21635eee2e2b32008ff68d4ef233 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 12 Apr 2023 17:09:12 +0200 Subject: [PATCH 080/255] rename argument --- src/t8_element_cxx.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_element_cxx.hxx b/src/t8_element_cxx.hxx index 92b9c10534..8028d6ac32 100644 --- a/src/t8_element_cxx.hxx +++ b/src/t8_element_cxx.hxx @@ -608,12 +608,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] out_coords The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) From fe3054f6390187a4b117550321d023ff60dd62e8 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Wed, 12 Apr 2023 17:19:50 +0200 Subject: [PATCH 081/255] changed input of static helper functions --- src/t8_cmesh/t8_cmesh_examples.c | 81 ++++++++++++++++---------------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 1c63ff55be..32a91d0808 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -850,19 +850,20 @@ t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, /** This is just a helper function that was needed when we update the * directional vector around a box for t8_cmesh_set_vertices_2D and _3D. - * \param [in] eclass The class of the box. T8_ECLASS_QUAD or T8_ECLASS_HEX + * \param [in] dim The dimension of the box. 2 or 3D. * \param [in] box_corners The vertices that define the box. * \param [in, out] box_dir The direction vectors of the edges of the surrounding box. * \param [in] face The box face whose edges need to be updated. * \param [in] axes The number of quads or hexes along the axes. */ static void -t8_update_box_face_edges (const t8_eclass_t eclass, +t8_update_box_face_edges (const int dim, const double *box_corners, double *box_dir, const int face, const t8_locidx_t *axes) { - T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX); + T8_ASSERT (dim == 2 || dim == 3); + const t8_eclass_t eclass = dim == 2 ? T8_ECLASS_QUAD : T8_ECLASS_HEX; T8_ASSERT (-1 < face && face < t8_eclass_num_faces[eclass]); const int num_face_edges = eclass == T8_ECLASS_QUAD ? 1 : 4; for (int face_edge = 0; face_edge < num_face_edges; face_edge++) { @@ -888,7 +889,7 @@ t8_update_box_face_edges (const t8_eclass_t eclass, /** This is just a helper function that was needed when we change the * size of a box for t8_cmesh_set_vertices_2D and _3D. - * \param [in] eclass The class of the box. T8_ECLASS_QUAD or T8_ECLASS_HEX + * \param [in] dim The dimension of the box. 2 or 3D. * \param [in, out] box_corners The vertices that define the box. * \param [in] box_dir The direction vectors of the edges of the surrounding box. * \param [in] face The box face along which we change the box size. @@ -897,13 +898,13 @@ t8_update_box_face_edges (const t8_eclass_t eclass, * \param [in, out] axes The number of quads or hexes along the axes. */ static void -t8_resize_box (const t8_eclass_t eclass, +t8_resize_box (const int dim, double *box_corners, const double *box_dir, const int face, const t8_locidx_t factor, int *axes) { - T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX); - T8_ASSERT (t8_eclass_to_dimension[eclass] > 1); + T8_ASSERT (dim == 2 || dim == 3); + const t8_eclass_t eclass = dim == 2 ? T8_ECLASS_QUAD : T8_ECLASS_HEX; T8_ASSERT (-1 < face && face < t8_eclass_num_faces[eclass]); const int num_face_corner = eclass == T8_ECLASS_QUAD ? 2 : 4; for (int face_corner = 0; face_corner < num_face_corner; face_corner++) { @@ -967,10 +968,10 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, **/ double box_dir[12]; /* Set up initial box_dir. */ - t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, box_quads); - t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 1, box_quads); - t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 2, box_quads); - t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 3, box_quads); + t8_update_box_face_edges (2, box, box_dir, 0, box_quads); + t8_update_box_face_edges (2, box, box_dir, 1, box_quads); + t8_update_box_face_edges (2, box, box_dir, 2, box_quads); + t8_update_box_face_edges (2, box, box_dir, 3, box_quads); /* The first vertex of box corresponds to the first vertex of the * current quad box (or tree in case of eclass = T8_ECLASS_QUADS). @@ -987,8 +988,8 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, t8_vec_axpyz (box, box_dir, vertices + 6, 1.0); /* Vertex 2 */ /* Reduce box along x axis */ - t8_resize_box (T8_ECLASS_QUAD, box, box_dir, 0, 1, box_quads); - t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, box_quads); + t8_resize_box (2, box, box_dir, 0, 1, box_quads); + t8_update_box_face_edges (2, box, box_dir, 0, box_quads); t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ t8_vec_axpyz (box, box_dir, vertices + 9, 1.0); /* Vertex 3 */ @@ -1024,11 +1025,11 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, } box_quads[0] = quads_x; box_quads[1] = quads_y; - t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 0, box_quads); + t8_update_box_face_edges (2, box, box_dir, 0, box_quads); /* Reduce box along y axis and face 2. */ - t8_resize_box (T8_ECLASS_QUAD, box, box_dir, 2, quad_y_id + 1, box_quads); - t8_update_box_face_edges (T8_ECLASS_QUAD, box, box_dir, 2, box_quads); + t8_resize_box (2, box, box_dir, 2, quad_y_id + 1, box_quads); + t8_update_box_face_edges (2, box, box_dir, 2, box_quads); } } @@ -1097,20 +1098,20 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, */ double box_dir[36]; /* Set up initial box_dir. Faces 0, 1, 2 and 3 cover all edges. */ - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, box_hexs); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 1, box_hexs); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 2, box_hexs); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 3, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 0, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 1, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 2, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 3, box_hexs); /* Increase the box along each axis x, y and z with faces 1, 3 and 5 * by one hex. This is necessary because otherwise we get a box of * length 0 at one point. */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 1, 1, box_hexs); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 1, box_hexs); - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 3, 1, box_hexs); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 3, box_hexs); - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 5, 1, box_hexs); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 5, box_hexs); + t8_resize_box (3, box, box_dir, 1, 1, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 1, box_hexs); + t8_resize_box (3, box, box_dir, 3, 1, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 3, box_hexs); + t8_resize_box (3, box, box_dir, 5, 1, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 5, box_hexs); /* The first vertex of box corresponds to the first vertex of the * current hexahedral box (or tree in case of eclass = T8_ECLASS_HEX). @@ -1129,22 +1130,22 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, t8_vec_axpyz (box, box_dir + 12, vertices + 6, 1.0); /* Vertex 2 */ /* Reduce box along z axis and face 4. */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 4, 1, box_hexs); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 4, box_hexs); + t8_resize_box (3, box, box_dir, 4, 1, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 4, box_hexs); t8_vec_axy (box, vertices + 12, 1.0); /* Vertex 4 */ t8_vec_axpyz (box, box_dir + 12, vertices + 18, 1.0); /* Vertex 6 */ /* Reduce box along x axis and face 0. */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 0, 1, box_hexs); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, box_hexs); + t8_resize_box (3, box, box_dir, 0, 1, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 0, box_hexs); t8_vec_axy (box, vertices + 15, 1.0); /* Vertex 5 */ t8_vec_axpyz (box, box_dir + 12, vertices + 21, 1.0); /* Vertex 7 */ /* Increase box along z axis and and face 4 */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 4, -1, box_hexs); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 4, box_hexs); + t8_resize_box (3, box, box_dir, 4, -1, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 4, box_hexs); t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ t8_vec_axpyz (box, box_dir + 12, vertices + 9, 1.0); /* Vertex 3 */ @@ -1217,23 +1218,23 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, } T8_ASSERT (box_hexs[0] == 1); /* Resize box along x axis and face 0 to get initial length. */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 0, -hexs_x, box_hexs); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 0, box_hexs); + t8_resize_box (3, box, box_dir, 0, -hexs_x, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 0, box_hexs); /* Reduce box along y axis and face 2. */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 2, 1, box_hexs); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 2, box_hexs); + t8_resize_box (3, box, box_dir, 2, 1, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 2, box_hexs); } T8_ASSERT (box_hexs[0] == hexs_x + 1); T8_ASSERT (box_hexs[1] == 1); /* Resize box along y axis and face 2 to get initial length. */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 2, -hexs_y, box_hexs); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 2, box_hexs); + t8_resize_box (3, box, box_dir, 2, -hexs_y, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 2, box_hexs); /* Reduce box along z axis and face 4. */ - t8_resize_box (T8_ECLASS_HEX, box, box_dir, 4, 1, box_hexs); - t8_update_box_face_edges (T8_ECLASS_HEX, box, box_dir, 4, box_hexs); + t8_resize_box (3, box, box_dir, 4, 1, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 4, box_hexs); } T8_ASSERT (box_hexs[2] == 1); T8_ASSERT (box_hexs[1] == hexs_y + 1); From d37b8b1dde8703d72e4557b73db839df30cd3526 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 12 Apr 2023 17:24:50 +0200 Subject: [PATCH 082/255] refactoring --- .../t8_default/t8_default_hex/t8_default_hex_cxx.cxx | 3 ++- .../t8_default/t8_default_hex/t8_default_hex_cxx.hxx | 4 ++-- .../t8_default/t8_default_line/t8_default_line_cxx.cxx | 3 ++- .../t8_default/t8_default_line/t8_default_line_cxx.hxx | 4 ++-- .../t8_default/t8_default_prism/t8_default_prism_cxx.cxx | 3 ++- .../t8_default/t8_default_prism/t8_default_prism_cxx.hxx | 4 ++-- .../t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx | 2 +- .../t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx | 4 ++-- .../t8_default/t8_default_quad/t8_default_quad_cxx.cxx | 3 ++- .../t8_default/t8_default_quad/t8_default_quad_cxx.hxx | 4 ++-- .../t8_default/t8_default_tet/t8_default_tet_cxx.cxx | 3 ++- .../t8_default/t8_default_tet/t8_default_tet_cxx.hxx | 4 ++-- .../t8_default/t8_default_tri/t8_default_tri_cxx.cxx | 3 ++- .../t8_default/t8_default_tri/t8_default_tri_cxx.hxx | 4 ++-- .../t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx | 2 +- .../t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx | 4 ++-- 16 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx index a278b26962..9d03a1471e 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx @@ -658,7 +658,8 @@ t8_default_scheme_hex_c::t8_element_vertex_reference_coords (const } void -t8_default_scheme_hex_c::t8_element_reference_coords (const t8_element_t *t, +t8_default_scheme_hex_c::t8_element_reference_coords (const t8_element_t + *elem, const double *ref_coords, const void *user_data, diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx index 30056e6895..793cd83ada 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx @@ -570,12 +570,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] out_coords The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx index abd28b1777..7b652e174c 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx @@ -368,7 +368,8 @@ t8_default_scheme_line_c::t8_element_vertex_reference_coords (const } void -t8_default_scheme_line_c::t8_element_reference_coords (const t8_element_t *t, +t8_default_scheme_line_c::t8_element_reference_coords (const t8_element_t + *elem, const double *ref_coords, const void *user_data, diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx index 2eb0e5eb5b..477c70f845 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx @@ -590,12 +590,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] out_coords The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx index 269b4401ae..d45d39a2c9 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx @@ -481,7 +481,8 @@ t8_default_scheme_prism_c::t8_element_vertex_reference_coords (const } void -t8_default_scheme_prism_c::t8_element_reference_coords (const t8_element_t *t, +t8_default_scheme_prism_c::t8_element_reference_coords (const t8_element_t + *elem, const double *ref_coords, const void *user_data, diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx index e33d53e2c3..bbb11f582a 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.hxx @@ -599,12 +599,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] out_coords The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx index 6c63ee4bf9..b5d2772533 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx @@ -477,7 +477,7 @@ t8_default_scheme_pyramid_c::t8_element_vertex_reference_coords (const void t8_default_scheme_pyramid_c::t8_element_reference_coords (const t8_element_t - *t, + *elem, const double *ref_coords, const void diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx index 976117ee99..18e6048a63 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.hxx @@ -618,12 +618,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] out_coords The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx index 28cafd5c6c..c502674195 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx @@ -791,7 +791,8 @@ t8_default_scheme_quad_c::t8_element_vertex_reference_coords (const } void -t8_default_scheme_quad_c::t8_element_reference_coords (const t8_element_t *t, +t8_default_scheme_quad_c::t8_element_reference_coords (const t8_element_t + *elem, const double *ref_coords, const void *user_data, diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx index df2b0dd65a..e21cfb0e2a 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx @@ -603,12 +603,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] out_coords The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx index b627e2cf48..20b04fb957 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx @@ -557,7 +557,8 @@ t8_default_scheme_tet_c::t8_element_vertex_reference_coords (const } void -t8_default_scheme_tet_c::t8_element_reference_coords (const t8_element_t *t, +t8_default_scheme_tet_c::t8_element_reference_coords (const t8_element_t + *elem, const double *ref_coords, const void *user_data, diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx index 11550d1920..aafdf53686 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx @@ -585,12 +585,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] out_coords The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx index e858a25a8d..e6b3096e30 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx @@ -576,7 +576,8 @@ t8_default_scheme_tri_c::t8_element_vertex_reference_coords (const } void -t8_default_scheme_tri_c::t8_element_reference_coords (const t8_element_t *t, +t8_default_scheme_tri_c::t8_element_reference_coords (const t8_element_t + *elem, const double *ref_coords, const void *user_data, diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx index be4a48c99e..1bc0719392 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx @@ -578,12 +578,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] out_coords The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx index 03b8ee9a39..ac10d64da7 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx @@ -322,7 +322,7 @@ t8_default_scheme_vertex_c::t8_element_vertex_reference_coords (const void t8_default_scheme_vertex_c::t8_element_reference_coords (const t8_element_t - *t, + *elem, const double *ref_coords, const void diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx index 55db8f8e5a..be5047aa5b 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.hxx @@ -618,12 +618,12 @@ public: /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] out_coords The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) From 426fd19a7837c5e8f3235d2abfb8059dae7e8a2b Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 12 Apr 2023 17:29:58 +0200 Subject: [PATCH 083/255] renamed argument --- .../t8_default_common/t8_default_common_cxx.hxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx b/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx index 9bf8d90fb4..538859b9e5 100644 --- a/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx @@ -100,24 +100,24 @@ public: * elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and * L the maximum refinement level. * All element vertices have integer coordinates in this cube. - * \param [in] t The element to be considered. + * \param [in] elem The element. * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many integers as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ - virtual void t8_element_vertex_coords (const t8_element_t *t, + virtual void t8_element_vertex_coords (const t8_element_t *elem, int vertex, int coords[]) const = 0; /** Convert a point in the reference space of an element to a point in the * reference space of the tree. * - * \param [in] t The element. + * \param [in] elem The element. * \param [in] coords_input The coordinates of the point in the reference space of the element. * \param [in] user_data User data. * \param [out] out_coords The coordinates of the point in the reference space of the tree. */ - virtual void t8_element_reference_coords (const t8_element_t *t, + virtual void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) From b426571acc0fbdb18d5fb213e080ca64ae3ada52 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 12 Apr 2023 17:43:55 +0200 Subject: [PATCH 084/255] remove redundant function --- src/t8_forest/t8_forest_vtk.cxx | 184 -------------------------------- 1 file changed, 184 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index 86df97feae..a725bfb546 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -227,190 +227,6 @@ t8_forest_vtk_get_element_nodes (t8_forest_t forest, t8_locidx_t ltreeid, t8_forest_element_from_ref_coords (forest, ltreeid, element, ref_coords, out_coords, stretch_factors); } - -/* If we want to write curved elements, we need to calculate - * the reference coordinates. For the vertices(end points) - * of the elements, we can use t8_element_vertex_reference_coords - * to get them. But for curved elements, we also need nodes at the - * middle points of lines of elements. We get those coordinates by - * adding the vertices and multiplying by 0.5. To get the - * correct node, we use e.g. (vertex - 3) % 4, for each - * element there is a correct order, therefore we have those - * formulas. For more information look into the vtk documentation. - * TODO: Add Pyramids when they are merged into the dev branch. - * */ -#if 0 -static void -t8_curved_element_get_reference_node_coords (const t8_element_t *elem, - t8_element_shape_t eclass, - t8_eclass_scheme_c *scheme, - int vertex, double *coords) -{ - double vertex_coords[3] = { 0, 0, 0 }; - int i; - int j; - - switch (eclass) { - case T8_ECLASS_VERTEX: - scheme->t8_element_vertex_reference_coords (elem, - t8_eclass_vtk_corner_number - [eclass][vertex], coords); - break; - case T8_ECLASS_LINE: - if (vertex < 2) { - scheme->t8_element_vertex_reference_coords (elem, - t8_eclass_vtk_corner_number - [eclass][vertex], coords); - } - else { - scheme->t8_element_vertex_reference_coords (elem, - t8_eclass_vtk_corner_number - [eclass][vertex - 1], - vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, - t8_eclass_vtk_corner_number - [eclass][vertex - 2], - coords); - /* Compute the average of those coordinates */ - t8_vec_axpy (vertex_coords, coords, 1); - t8_vec_ax (coords, 0.5); - } - break; - case T8_ECLASS_QUAD: - if (vertex < 4) { - scheme->t8_element_vertex_reference_coords (elem, - t8_eclass_vtk_corner_number - [eclass][vertex], coords); - } - else { - i = t8_eclass_vtk_corner_number[eclass][(vertex - 4) % 4]; - j = t8_eclass_vtk_corner_number[eclass][(vertex - 3) % 4]; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); - /* Compute the average of those coordinates */ - t8_vec_axpy (vertex_coords, coords, 1); - t8_vec_ax (coords, 0.5); - } - - break; - case T8_ECLASS_TRIANGLE: - if (0 <= vertex && vertex <= 2) { - scheme->t8_element_vertex_reference_coords (elem, - t8_eclass_vtk_corner_number - [eclass][vertex], coords); - } - else { - i = (vertex - 3) % 3; - j = (vertex - 2) % 3; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); - /* Compute the average of those coordinates */ - t8_vec_axpy (vertex_coords, coords, 1); - t8_vec_ax (coords, 0.5); - } - break; - case T8_ECLASS_HEX: - if (vertex < 8) { - scheme->t8_element_vertex_reference_coords (elem, - t8_eclass_vtk_corner_number - [eclass][vertex], coords); - } - else if (7 < vertex && vertex < 12) { - i = t8_eclass_vtk_corner_number[eclass][(vertex - 8) % 4]; - j = t8_eclass_vtk_corner_number[eclass][(vertex - 7) % 4]; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); - /* Compute the average of those coordinates */ - t8_vec_axpy (vertex_coords, coords, 1); - t8_vec_ax (coords, 0.5); - } - else if (11 < vertex && vertex < 16) { - i = t8_eclass_vtk_corner_number[eclass][((vertex - 8) % 4) + 4]; - j = t8_eclass_vtk_corner_number[eclass][((vertex - 7) % 4) + 4]; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); - /* Compute the average of those coordinates */ - t8_vec_axpy (vertex_coords, coords, 1); - t8_vec_ax (coords, 0.5); - } - else { - i = t8_eclass_vtk_corner_number[eclass][vertex % 16]; - j = i + 4; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); - /* Compute the average of those coordinates */ - t8_vec_axpy (vertex_coords, coords, 1); - t8_vec_ax (coords, 0.5); - } - - break; - case T8_ECLASS_TET: - if (vertex < 4) { - scheme->t8_element_vertex_reference_coords (elem, - t8_eclass_vtk_corner_number - [eclass][vertex], coords); - } - else if (3 < vertex && vertex < 7) { - i = t8_eclass_vtk_corner_number[eclass][(vertex - 4) % 3]; - j = t8_eclass_vtk_corner_number[eclass][(vertex - 3) % 3]; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); - /* Compute the average of those coordinates */ - t8_vec_axpy (vertex_coords, coords, 1); - t8_vec_ax (coords, 0.5); - } - else { - i = t8_eclass_vtk_corner_number[eclass][vertex % 7]; - j = 3; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); - /* Compute the average of those coordinates */ - t8_vec_axpy (vertex_coords, coords, 1); - t8_vec_ax (coords, 0.5); - } - break; - case T8_ECLASS_PRISM: - if (vertex < 6) { - scheme->t8_element_vertex_reference_coords (elem, - t8_eclass_vtk_corner_number - [eclass][vertex], coords); - } - else if (5 < vertex && vertex < 9) { - i = t8_eclass_vtk_corner_number[eclass][(vertex - 3) % 3]; - j = t8_eclass_vtk_corner_number[eclass][(vertex - 2) % 3]; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); - /* Compute the average of those coordinates */ - t8_vec_axpy (vertex_coords, coords, 1); - t8_vec_ax (coords, 0.5); - } - else if (8 < vertex && vertex < 12) { - i = t8_eclass_vtk_corner_number[eclass][(vertex % 3) + 3]; - j = t8_eclass_vtk_corner_number[eclass][((vertex + 1) % 3) + 3]; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); - /* Compute the average of those coordinates */ - t8_vec_axpy (vertex_coords, coords, 1); - t8_vec_ax (coords, 0.5); - } - else { - i = t8_eclass_vtk_corner_number[eclass][vertex % 12]; - j = t8_eclass_vtk_corner_number[eclass][(vertex % 12) + 3]; - scheme->t8_element_vertex_reference_coords (elem, i, vertex_coords); - scheme->t8_element_vertex_reference_coords (elem, j, coords); - /* Compute the average of those coordinates */ - t8_vec_axpy (vertex_coords, coords, 1); - t8_vec_ax (coords, 0.5); - } - break; - default: - scheme->t8_element_vertex_reference_coords (elem, - t8_eclass_vtk_corner_number - [eclass][vertex], coords); - break; - } -} -#endif #endif int From e1d09fc7a9f2248d4170be19b6e6998188f363c8 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Wed, 12 Apr 2023 18:24:20 +0200 Subject: [PATCH 085/255] Joined trees of eclass_line --- src/t8_cmesh/t8_cmesh_examples.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 32a91d0808..1d2699d872 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1349,7 +1349,8 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, } } else { - T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX); + T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX || + eclass == T8_ECLASS_VERTEX || eclass == T8_ECLASS_LINE); } } } @@ -1360,7 +1361,8 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, for (t8_locidx_t poly_x_id = 0; poly_x_id < polygons_x - 1; poly_x_id++) { const t8_locidx_t poly_id = poly_z_id * polygons_y * polygons_x + poly_y_id * polygons_x + poly_x_id; - if (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX) { + if (eclass == T8_ECLASS_LINE || eclass == T8_ECLASS_QUAD + || eclass == T8_ECLASS_HEX) { const t8_locidx_t tree_id_0 = poly_id; const t8_locidx_t tree_id_1 = poly_id + 1; t8_cmesh_set_join (cmesh, tree_id_0, tree_id_1, 1, 0, 1); From 778fa526431531ca866237b04ca02e7ef11a5ce3 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Wed, 12 Apr 2023 18:36:27 +0200 Subject: [PATCH 086/255] indent --- src/t8_cmesh/t8_cmesh_examples.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 1d2699d872..3accc9c58d 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -863,7 +863,7 @@ t8_update_box_face_edges (const int dim, const int face, const t8_locidx_t *axes) { T8_ASSERT (dim == 2 || dim == 3); - const t8_eclass_t eclass = dim == 2 ? T8_ECLASS_QUAD : T8_ECLASS_HEX; + const t8_eclass_t eclass = dim == 2 ? T8_ECLASS_QUAD : T8_ECLASS_HEX; T8_ASSERT (-1 < face && face < t8_eclass_num_faces[eclass]); const int num_face_edges = eclass == T8_ECLASS_QUAD ? 1 : 4; for (int face_edge = 0; face_edge < num_face_edges; face_edge++) { @@ -904,7 +904,7 @@ t8_resize_box (const int dim, const int face, const t8_locidx_t factor, int *axes) { T8_ASSERT (dim == 2 || dim == 3); - const t8_eclass_t eclass = dim == 2 ? T8_ECLASS_QUAD : T8_ECLASS_HEX; + const t8_eclass_t eclass = dim == 2 ? T8_ECLASS_QUAD : T8_ECLASS_HEX; T8_ASSERT (-1 < face && face < t8_eclass_num_faces[eclass]); const int num_face_corner = eclass == T8_ECLASS_QUAD ? 2 : 4; for (int face_corner = 0; face_corner < num_face_corner; face_corner++) { @@ -1361,7 +1361,7 @@ t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, for (t8_locidx_t poly_x_id = 0; poly_x_id < polygons_x - 1; poly_x_id++) { const t8_locidx_t poly_id = poly_z_id * polygons_y * polygons_x + poly_y_id * polygons_x + poly_x_id; - if (eclass == T8_ECLASS_LINE || eclass == T8_ECLASS_QUAD + if (eclass == T8_ECLASS_LINE || eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_HEX) { const t8_locidx_t tree_id_0 = poly_id; const t8_locidx_t tree_id_1 = poly_id + 1; From 9b6d80907973d35793564d52cc293139ad785166 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Wed, 12 Apr 2023 21:16:09 +0200 Subject: [PATCH 087/255] Add include --- tutorials/general/t8_step5_element_data_c_interface.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tutorials/general/t8_step5_element_data_c_interface.c b/tutorials/general/t8_step5_element_data_c_interface.c index d9c42d46e1..8aa59058ca 100644 --- a/tutorials/general/t8_step5_element_data_c_interface.c +++ b/tutorials/general/t8_step5_element_data_c_interface.c @@ -48,6 +48,7 @@ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ #include /* forest definition and basic interface. */ +#include /* save forest */ #include /* default refinement scheme. */ #include /* default refinement scheme. */ #include From 377a78d37ccc599bc8d577f8eac4db9ac80e077c Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Wed, 12 Apr 2023 21:26:51 +0200 Subject: [PATCH 088/255] Clean up --- src/t8_forest_general.h | 19 ------------------- src/t8_forest_geometrical.h | 2 -- src/t8_forest_io.h | 1 - 3 files changed, 22 deletions(-) diff --git a/src/t8_forest_general.h b/src/t8_forest_general.h index ff47e31271..09446ca18c 100644 --- a/src/t8_forest_general.h +++ b/src/t8_forest_general.h @@ -740,7 +740,6 @@ t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, *neigh_scheme, int face, int *neigh_face); - /* TODO: implement */ void t8_forest_iterate (t8_forest_t forest); @@ -822,24 +821,6 @@ void t8_forest_ref (t8_forest_t forest); */ void t8_forest_unref (t8_forest_t *pforest); - - - - - - - - - - - - - - - - - - T8_EXTERN_C_END (); #endif /* !T8_FOREST_GENERAL_H */ diff --git a/src/t8_forest_geometrical.h b/src/t8_forest_geometrical.h index 56e6873933..29d3a4f434 100644 --- a/src/t8_forest_geometrical.h +++ b/src/t8_forest_geometrical.h @@ -141,8 +141,6 @@ void t8_forest_element_face_normal (t8_forest_t forest, *element, int face, double normal[3]); - - T8_EXTERN_C_END (); #endif /* !T8_FOREST_GEOMETRICAL_H */ diff --git a/src/t8_forest_io.h b/src/t8_forest_io.h index 3c674fa946..c14708f5d3 100644 --- a/src/t8_forest_io.h +++ b/src/t8_forest_io.h @@ -102,7 +102,6 @@ int t8_forest_write_vtk_ext (t8_forest_t forest, int t8_forest_write_vtk (t8_forest_t forest, const char *fileprefix); - T8_EXTERN_C_END (); #endif /* !T8_FOREST_IO_H */ \ No newline at end of file From d23ede175448cf9dc8309c4493fdb7368f4a65b5 Mon Sep 17 00:00:00 2001 From: Knapp Date: Thu, 13 Apr 2023 09:49:08 +0200 Subject: [PATCH 089/255] Add offset variable to ensure no out of bounds access of arrays --- src/t8_forest/t8_forest_vtk.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index a96e079aba..327ebd5e4a 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -488,7 +488,8 @@ t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, long int point_id = 0; /* The id of the point in the points Object. */ double coordinates[3]; double vertex_coords[3] = { 0, 0, 0 }; - t8_gloidx_t elem_id = t8_forest_get_first_local_element_id (forest); + const t8_gloidx_t offset = t8_forest_get_first_local_element_id (forest); + t8_gloidx_t elem_id = offset; /* Since we want to use different element types and a points Array and cellArray * we have to declare these vtk objects. The cellArray stores the Elements. @@ -681,10 +682,10 @@ t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, /* *INDENT-OFF* */ if(curved_flag==0){ - cellTypes[elem_id] = t8_eclass_vtk_type[element_shape]; + cellTypes[elem_id - offset] = t8_eclass_vtk_type[element_shape]; } else{ - cellTypes[elem_id] = t8_curved_eclass_vtk_type[element_shape]; + cellTypes[elem_id - offset] = t8_curved_eclass_vtk_type[element_shape]; } if (write_treeid == 1) { vtk_treeid->InsertNextValue (gtreeid); From 0ed85dfb08037eb94a411f8f5818f9aecf61dee8 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Thu, 13 Apr 2023 10:36:05 +0200 Subject: [PATCH 090/255] Merge element ref coords implementations from 'feature-puma_patches' branch --- .../t8_default_hex/t8_default_hex_cxx.cxx | 18 ++++- .../t8_default_line/t8_default_line_cxx.cxx | 5 +- .../t8_default_line/t8_dline_bits.c | 11 +++ .../t8_default_line/t8_dline_bits.h | 13 ++++ .../t8_default_prism/t8_default_prism_cxx.cxx | 4 +- .../t8_default_prism/t8_dprism_bits.c | 14 ++++ .../t8_default_prism/t8_dprism_bits.h | 14 ++++ .../t8_default_pyramid_cxx.cxx | 6 +- .../t8_default_pyramid/t8_dpyramid_bits.c | 69 ++++++++++++++---- .../t8_default_pyramid/t8_dpyramid_bits.h | 20 +++++- .../t8_default_quad/t8_default_quad_cxx.cxx | 13 +++- .../t8_default_tet/t8_default_tet_cxx.cxx | 4 +- .../t8_default/t8_default_tet/t8_dtet_bits.h | 13 ++++ .../t8_default_tet/t8_dtri_to_dtet.h | 1 + .../t8_default_tri/t8_default_tri_cxx.cxx | 4 +- .../t8_default/t8_default_tri/t8_dtri_bits.c | 71 +++++++++++++++++++ .../t8_default/t8_default_tri/t8_dtri_bits.h | 13 ++++ .../t8_default_vertex_cxx.cxx | 4 +- .../t8_default_vertex/t8_dvertex_bits.c | 9 +++ .../t8_default_vertex/t8_dvertex_bits.h | 12 ++++ 20 files changed, 292 insertions(+), 26 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx index cf8b11d0a1..ffbf356573 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx @@ -666,7 +666,23 @@ t8_default_scheme_hex_c::t8_element_reference_coords (const t8_element_t double *out_coords) const { - SC_ABORTF ("Not implemented\n"); + T8_ASSERT (t8_element_is_valid (elem)); + const p8est_quadrant_t *q1 = (const p8est_quadrant_t *) elem; + + /* Get the length of the quadrant */ + const int len = P8EST_QUADRANT_LEN (q1->level); + + /* Compute the x, y and z coordinates of the point depending on the + * reference coordinates */ + out_coords[0] = q1->x + ref_coords[0] * len; + out_coords[1] = q1->y + ref_coords[1] * len; + out_coords[2] = q1->z + ref_coords[2] * len; + + /* We divide the integer coordinates by the root length of the hex + * to obtain the reference coordinates. */ + out_coords[0] /= (double) P8EST_ROOT_LEN; + out_coords[1] /= (double) P8EST_ROOT_LEN; + out_coords[2] /= (double) P8EST_ROOT_LEN; } int diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx index 7b652e174c..f0bd28d5c0 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx @@ -376,7 +376,10 @@ t8_default_scheme_line_c::t8_element_reference_coords (const t8_element_t double *out_coords) const { - SC_ABORTF ("Not implemented\n"); + T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (ref_coords != NULL); + t8_dline_compute_reference_coords ((const t8_dline_t *) elem, ref_coords, + out_coords); } int diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c index b9e8f55393..9c814665b4 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c +++ b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c @@ -349,6 +349,17 @@ t8_dline_vertex_ref_coords (const t8_dline_t *elem, const int vertex, coordinates[0] = coords_int / (double) T8_DLINE_ROOT_LEN; } +void +t8_dline_compute_reference_coords (const t8_dline_t *elem, + const double *ref_coords, + double *out_coords) +{ + T8_ASSERT (t8_element_is_valid (elem)); + out_coords[0] = elem->x; + out_coords[0] += T8_DLINE_LEN (elem->level) * ref_coords[0]; + out_coords[0] /= (double) T8_DLINE_ROOT_LEN; +} + t8_linearidx_t t8_dline_linear_id (const t8_dline_t *elem, int level) { diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h index d59f3cf295..66b5efbaf4 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h +++ b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h @@ -242,6 +242,19 @@ void t8_dline_vertex_ref_coords (const t8_dline_t *elem, const int vertex, double coordinates[1]); +/** Convert a point in the reference space of a line element to a point in the + * reference space of the tree (level 0) embedded in [0,1]^1. + * \param [in] elem Input line. + * \param [in] ref_coords The reference coordinate on the line [0, 1]^1 + * \param [out] out_coords An array of 1 double that + * will be filled with the reference coordinates + * of the point on the line. + */ +void t8_dline_compute_reference_coords (const t8_dline_t *elem, + const double + *ref_coords, + double *out_coords); + /** Computes the linear position of a line in an uniform grid. * \param [in] line Line whose id will be computed. * \return Returns the linear position of this line on a grid. diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx index d45d39a2c9..26bd38c20b 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx @@ -489,7 +489,9 @@ t8_default_scheme_prism_c::t8_element_reference_coords (const t8_element_t double *out_coords) const { - SC_ABORTF ("Not implemented\n"); + T8_ASSERT (t8_element_is_valid (elem)); + t8_dprism_compute_reference_coords ((const t8_dprism_t *) elem, ref_coords, + out_coords); } void diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c index a28d6e7d12..2b10119772 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c @@ -580,6 +580,20 @@ t8_dprism_vertex_ref_coords (const t8_dprism_t *elem, const int vertex, coords[2] = coords_int[2] / (double) T8_DPRISM_ROOT_LEN; } +void +t8_dprism_compute_reference_coords (const t8_dprism_t *elem, + const double *ref_coords, + double *out_coords) +{ + T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (elem->line.level == elem->tri.level); + /*Compute x and y coordinate */ + t8_dtri_compute_reference_coords (&elem->tri, ref_coords, out_coords); + /*Compute z coordinate */ + t8_dline_compute_reference_coords (&elem->line, ref_coords + 2, + out_coords + 2); +} + t8_linearidx_t t8_dprism_linear_id (const t8_dprism_t *p, int level) { diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.h b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.h index 47780e7988..09f7629199 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.h +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.h @@ -315,6 +315,20 @@ void t8_dprism_vertex_ref_coords (const t8_dprism_t *elem, int vertex, double coords[3]); +/** Convert a point in the reference space of a prism element to a point in the + * reference space of the tree (level 0) embedded in [0,1]^3. + * \param [in] elem Input prism. + * \param [in] ref_coords The reference coordinates inside the + * prism element [0,1]^3 + * \param [out] out_coords An array of 3 doubles that will be filled with the + * reference coordinates in the tree of the prism. + */ +void t8_dprism_compute_reference_coords (const t8_dprism_t + *elem, + const double + *ref_coords, + double *out_coords); + /** Computes the linear position of a prism in an uniform grid. * \param [in] p Prism whose id will be computed. * \return Returns the linear position of this prism on a grid. diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx index b5d2772533..87c9be858a 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx @@ -482,10 +482,12 @@ t8_default_scheme_pyramid_c::t8_element_reference_coords (const t8_element_t *ref_coords, const void *user_data, - double *out_coords) + double *coords_out) const { - SC_ABORTF ("Not implemented\n"); + T8_ASSERT (t8_element_is_valid (elem)); + t8_dpyramid_compute_reference_coords ((const t8_dpyramid_t *) elem, + ref_coords, coords_out); } int diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c index 6a9aabb1b6..2e817dde8b 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c @@ -1683,43 +1683,49 @@ t8_dpyramid_successor (const t8_dpyramid_t *elem, t8_dpyramid_t *succ, } void -t8_dpyramid_compute_coords (const t8_dpyramid_t *p, const int vertex, +t8_dpyramid_compute_coords (const t8_dpyramid_t *elem, const int vertex, int coords[]) { T8_ASSERT (0 <= vertex && vertex < T8_DPYRAMID_CORNERS); - if (t8_dpyramid_shape (p) == T8_ECLASS_PYRAMID) { - const t8_dpyramid_coord_t length = T8_DPYRAMID_LEN (p->pyramid.level); - coords[0] = p->pyramid.x; - coords[1] = p->pyramid.y; - coords[2] = p->pyramid.z; + if (t8_dpyramid_shape (elem) == T8_ECLASS_PYRAMID) { + const t8_dpyramid_coord_t length = T8_DPYRAMID_LEN (elem->pyramid.level); + coords[0] = elem->pyramid.x; + coords[1] = elem->pyramid.y; + coords[2] = elem->pyramid.z; switch (vertex) { case 0: - coords[2] += (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) ? length : 0; + if (elem->pyramid.type == T8_DPYRAMID_SECOND_TYPE) + coords[2] += length; break; case 1: coords[0] += length; - coords[2] += (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) ? length : 0; + if (elem->pyramid.type == T8_DPYRAMID_SECOND_TYPE) + coords[2] += length; break; case 2: coords[1] += length; - coords[2] += (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) ? length : 0; + if (elem->pyramid.type == T8_DPYRAMID_SECOND_TYPE) + coords[2] += length; break; case 3: coords[0] += length; coords[1] += length; - coords[2] += (p->pyramid.type == T8_DPYRAMID_SECOND_TYPE) ? length : 0; + if (elem->pyramid.type == T8_DPYRAMID_SECOND_TYPE) + coords[2] += length; break; case 4: - coords[0] += (p->pyramid.type == T8_DPYRAMID_FIRST_TYPE) ? length : 0; - coords[1] += (p->pyramid.type == T8_DPYRAMID_FIRST_TYPE) ? length : 0; - coords[2] += (p->pyramid.type == T8_DPYRAMID_FIRST_TYPE) ? length : 0; + if (elem->pyramid.type == T8_DPYRAMID_FIRST_TYPE) { + coords[0] += length; + coords[1] += length; + coords[2] += length; + } break; } } else { T8_ASSERT (0 <= vertex && vertex < T8_DTET_CORNERS); - t8_dtet_compute_coords (&(p->pyramid), vertex, coords); + t8_dtet_compute_coords (&(elem->pyramid), vertex, coords); } } @@ -1736,6 +1742,41 @@ t8_dpyramid_vertex_reference_coords (const t8_dpyramid_t *elem, coords[2] = coords_int[2] / (double) T8_DPYRAMID_ROOT_LEN; } +void +t8_dpyramid_compute_reference_coords (const t8_dpyramid_t *elem, + const double *ref_coords, + double *out_coords) +{ + T8_ASSERT (ref_coords != NULL); + T8_ASSERT (t8_element_is_valid (elem)); + if (t8_dpyramid_shape (elem) == T8_ECLASS_PYRAMID) { + const t8_dpyramid_coord_t length = T8_DPYRAMID_LEN (elem->pyramid.level); + out_coords[0] = elem->pyramid.x; + out_coords[1] = elem->pyramid.y; + out_coords[2] = elem->pyramid.z; + + if (elem->pyramid.type == T8_DPYRAMID_FIRST_TYPE) { + out_coords[0] += ref_coords[0] * length; + out_coords[1] += ref_coords[1] * length; + out_coords[2] += ref_coords[2] * length; + } + else { + out_coords[0] += ref_coords[0] * length * (1 - ref_coords[2]); + out_coords[1] += ref_coords[1] * length * (1 - ref_coords[2]); + out_coords[2] += (1 - ref_coords[2]) * length; + } + + /*scale the coordinates onto the reference cube */ + out_coords[0] /= (double) T8_DPYRAMID_ROOT_LEN; + out_coords[1] /= (double) T8_DPYRAMID_ROOT_LEN; + out_coords[2] /= (double) T8_DPYRAMID_ROOT_LEN; + } + else { + t8_dtet_compute_reference_coords (&(elem->pyramid), ref_coords, + out_coords); + } +} + /** * Compute the ancestor of \a pyra on level \a level. * diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.h b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.h index 14f5e35730..9e9fdfab34 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.h +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.h @@ -261,12 +261,12 @@ void t8_dpyramid_last_descendant_face (const t8_dpyramid_t *p, const int level); /** Compute the coordinates of a vertex of a pyramid. - * \param [in] p Input pyramid. - * \param [in] vertex The number of the vertex. + * \param [in] elem Input pyramid. + * \param [in] vertex The number of the vertex. * \param [out] coords An array of 3 t8_dpyramid_coord_t that * will be filled with the coordinates of the vertex. */ -void t8_dpyramid_compute_coords (const t8_dpyramid_t *p, +void t8_dpyramid_compute_coords (const t8_dpyramid_t *elem, const int vertex, int coords[]); @@ -372,6 +372,20 @@ void t8_dpyramid_vertex_reference_coords (const t8_dpyramid_t const int vertex, double coords[]); +/** Convert a point in the reference space of a pyramid element to a point in + * the reference space of the tree (level 0) embedded in [0,1]^3. + * \param [in] elem Input pyramid. + * \param [in] ref_coords The reference coordinates inside the + * pyramid element [0,1]^3 + * \param [out] out_coords An array of 3 doubles that will be filled with the + * reference coordinates in the tree of the pyramid. + */ +void t8_dpyramid_compute_reference_coords (const t8_dpyramid_t + *elem, + const double + *ref_coords, + double *out_coords); + /** * Compute the nearest common ancestor of two elements * \param [in] pyra1 The first pyramid diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx index c267cdd828..e5c8e869fe 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx @@ -799,7 +799,18 @@ t8_default_scheme_quad_c::t8_element_reference_coords (const t8_element_t double *out_coords) const { - SC_ABORTF ("Not implemented\n"); + T8_ASSERT (t8_element_is_valid (elem)); + const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) elem; + out_coords[0] = q1->x / (double) P4EST_ROOT_LEN; + out_coords[1] = q1->y / (double) P4EST_ROOT_LEN; + const double len = + P4EST_QUADRANT_LEN (q1->level) / (double) P4EST_ROOT_LEN; + + out_coords[0] += ref_coords[0] * len; + out_coords[1] += ref_coords[1] * len; + + out_coords[0] /= (double) P4EST_ROOT_LEN; + out_coords[1] /= (double) P4EST_ROOT_LEN; } void diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx index 20b04fb957..286cb3c53f 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx @@ -565,7 +565,9 @@ t8_default_scheme_tet_c::t8_element_reference_coords (const t8_element_t double *out_coords) const { - SC_ABORTF ("Not implemented\n"); + T8_ASSERT (t8_element_is_valid (elem)); + t8_dtet_compute_reference_coords ((const t8_dtet_t *) elem, ref_coords, + out_coords); } /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h b/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h index 0961eaba73..dd815fd06a 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.h @@ -55,6 +55,19 @@ void t8_dtet_compute_vertex_ref_coords (const t8_dtet_t *elem, int vertex, double coordinates[3]); +/** Convert a point in the reference space of a tet element to a point in the + * reference space of the tree (level 0) embedded in [0,1]^3. + * \param [in] elem Input tetrahedron. + * \param [in] ref_coords The reference coordinates inside the + * tet element [0,1]^2 + * \param [out] out_coords An array of 3 doubles that will be filled with the + * reference coordinates in the tree of the tet. + */ +void t8_dtet_compute_reference_coords (const t8_dtet_t *elem, + const double + *ref_coords, + double out_coords[3]); + /** Compute the coordinates of the four vertices of a tetrahedron. * \param [in] elem Input tetrahedron. * \param [out] coordinates An array of 4x3 t8_dtet_coord_t that diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_dtri_to_dtet.h b/src/t8_schemes/t8_default/t8_default_tet/t8_dtri_to_dtet.h index cd9abd3d80..1dea179b30 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_dtri_to_dtet.h +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_dtri_to_dtet.h @@ -73,6 +73,7 @@ T8_EXTERN_C_BEGIN (); #define t8_dtri_compute_all_coords t8_dtet_compute_all_coords #define t8_dtri_compute_coords t8_dtet_compute_coords #define t8_dtri_compute_vertex_ref_coords t8_dtet_compute_vertex_ref_coords +#define t8_dtri_compute_reference_coords t8_dtet_compute_reference_coords #define t8_dtri_child t8_dtet_child #define t8_dtri_childrenpv t8_dtet_childrenpv #define t8_dtri_is_familypv t8_dtet_is_familypv diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx index e6b3096e30..91a2437bc2 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.cxx @@ -584,7 +584,9 @@ t8_default_scheme_tri_c::t8_element_reference_coords (const t8_element_t double *out_coords) const { - SC_ABORTF ("Not implemented\n"); + T8_ASSERT (t8_element_is_valid (elem)); + t8_dtri_compute_reference_coords ((const t8_dtri_t *) elem, ref_coords, + out_coords); } int diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c index eb233e5187..8186997d41 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c @@ -375,6 +375,77 @@ t8_dtri_compute_vertex_ref_coords (const t8_dtri_t *elem, const int vertex, #endif } +void +t8_dtri_compute_reference_coords (const t8_dtri_t *elem, + const double *ref_coords, + double out_coords[T8_DTRI_DIM]) +{ + /* Calculate the reference coordinates of a triangle/tetrahedron in + * relation to its orientation. Orientations are described here: + * https://doi.org/10.1137/15M1040049 + * 1---------------------2 + * | orientation / 2 + * | 1 / / | + * | / / | + * | / / | + * | / / | + * | / / | + * | / / | + * | / / | + * | / / orientation | + * | / / 0 | + * 0 / | + * 0--------------------1 + * + * y + * ^ + * | + * z--> x + */ + T8_ASSERT (ref_coords != NULL); + + t8_dtri_type_t type; + t8_dtri_coord_t h; + + type = elem->type; + h = T8_DTRI_LEN (elem->level); +#ifndef T8_DTRI_TO_DTET + const int tri_orientation = type; +#else + /* These integers define the sequence, in which the ref_coords are added + * to the out_coords */ + const int tet_orientation0 = type / 2; + const int tet_orientation1 = + (tet_orientation0 + ((type % 2 == 0) ? 1 : 2)) % 3; + const int tet_orientation2 = + (tet_orientation0 + ((type % 2 == 0) ? 2 : 1)) % 3; +#endif + + out_coords[0] = elem->x; + out_coords[1] = elem->y; +#ifdef T8_DTRI_TO_DTET + out_coords[2] = elem->z; +#endif +#ifndef T8_DTRI_TO_DTET + out_coords[tri_orientation] += h * ref_coords[1]; + out_coords[1 - tri_orientation] += h * ref_coords[0]; +#else + out_coords[tet_orientation0] += h * ref_coords[0]; + out_coords[tet_orientation1] += h * ref_coords[1]; + out_coords[tet_orientation2] += h * ref_coords[2]; + + /* done 3D */ +#endif + /* Since the integer coordinates are coordinates w.r.t to + * the embedding into [0,T8_DTRI_ROOT_LEN]^d, we just need + * to divide them by the root length. */ + out_coords[0] /= (double) T8_DTRI_ROOT_LEN; + out_coords[1] /= (double) T8_DTRI_ROOT_LEN; +#ifdef T8_DTRI_TO_DTET + out_coords[2] /= (double) T8_DTRI_ROOT_LEN; +#endif +} + /* Compute the coordinates of each vertex of a triangle/tet */ void t8_dtri_compute_all_coords (const t8_dtri_t *elem, diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h index 8dbb06d703..a8fcc35470 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h @@ -87,6 +87,19 @@ void t8_dtri_compute_vertex_ref_coords (const t8_dtri_t *elem, const int vertex, double coordinates[2]); +/** Convert a point in the reference space of a triangle element to a point in + * the reference space of the tree (level 0) embedded in [0,1]^2. + * \param [in] elem Input triangle. + * \param [in] ref_coords The reference coordinates inside the + * triangle element [0,1]^2 + * \param [out] out_coords An array of 2 doubles that will be filled with the + * reference coordinates in the tree of the triangle. + */ +void t8_dtri_compute_reference_coords (const t8_dtri_t *elem, + const double + *ref_coords, + double out_coords[2]); + /** Compute the coordinates of the four vertices of a triangle. * \param [in] elem Input triangle. * \param [out] coordinates An array of 4x3 t8_dtri_coord_t that diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx index ac10d64da7..4b8da2ed98 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex_cxx.cxx @@ -330,7 +330,9 @@ t8_default_scheme_vertex_c::t8_element_reference_coords (const t8_element_t double *out_coords) const { - SC_ABORTF ("Not implemented\n"); + T8_ASSERT (t8_element_is_valid (elem)); + t8_dvertex_compute_reference_coords ((const t8_dvertex_t *) elem, + ref_coords, out_coords); } #ifdef T8_ENABLE_DEBUG diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c index 847fa05d79..3cc63d46eb 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c @@ -173,6 +173,15 @@ t8_dvertex_vertex_ref_coords (const t8_dvertex_t *elem, const int vertex, coords[0] = 0; } +void +t8_dvertex_compute_reference_coords (const t8_dvertex_t *elem, + const double *ref_coords, + double *out_coords) +{ + T8_ASSERT (abs (ref_coords[0]) <= T8_PRECISION_EPS); + out_coords[0] = 0; +} + t8_linearidx_t t8_dvertex_linear_id (const t8_dvertex_t *elem, int level) { diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h index 4ecdfd7d26..4fabaa5a98 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.h @@ -195,6 +195,18 @@ void t8_dvertex_vertex_ref_coords (const t8_dvertex_t *elem, int vertex, double coords[]); +/** Compute the coordinates of a refrence coordinate (always 0) inside the + * [0,1]^0 reference space. + * \param [in] elem Vertex whose vertex is computed. + * \param [in] ref_coords The reference coordinate inside the vertex (must be 0). + * \param [out] out_coords The coordinates of the computed vertex, must have one entry (will be set to 0). + */ +void t8_dvertex_compute_reference_coords (const t8_dvertex_t + *elem, + const double + *ref_coords, + double *out_coords); + /** Computes the linear position of a vertex in an uniform grid. * \param [in] vertex vertex whose id will be computed. * \return Returns the linear position of this vertex on a grid. From d6543d49ff1ca9d6a217b2b046e28acb2e226a0f Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Thu, 13 Apr 2023 10:39:21 +0200 Subject: [PATCH 091/255] renamed function argument --- .../t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx index 87c9be858a..1b04009493 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx @@ -482,12 +482,12 @@ t8_default_scheme_pyramid_c::t8_element_reference_coords (const t8_element_t *ref_coords, const void *user_data, - double *coords_out) + double *out_coords) const { T8_ASSERT (t8_element_is_valid (elem)); t8_dpyramid_compute_reference_coords ((const t8_dpyramid_t *) elem, - ref_coords, coords_out); + ref_coords, out_coords); } int From 1c046aa304a5713b7be72889f0984de2f03e21b7 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Thu, 13 Apr 2023 11:02:25 +0200 Subject: [PATCH 092/255] remove code fragment --- src/t8_forest/t8_forest_cxx.cxx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/t8_forest/t8_forest_cxx.cxx b/src/t8_forest/t8_forest_cxx.cxx index 8ae4841f09..e74ba2fe2a 100644 --- a/src/t8_forest/t8_forest_cxx.cxx +++ b/src/t8_forest/t8_forest_cxx.cxx @@ -235,10 +235,6 @@ t8_forest_element_from_ref_coords (t8_forest_t forest, t8_locidx_t ltreeid, t8_forest_get_eclass_scheme (forest, tree_class); scheme->t8_element_reference_coords (element, ref_coords, NULL, tree_ref_coords); - if (stretch_factors != NULL) { - //get element_midpoint - //stretch ref_coords by factor stored in array - } const t8_cmesh_t cmesh = t8_forest_get_cmesh (forest); const t8_gloidx_t gtreeid = t8_forest_global_tree_id (forest, ltreeid); t8_geometry_evaluate (cmesh, gtreeid, tree_ref_coords, coords_out); From dbd57e578b64129f45147ae14f7a8accaff42e32 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Thu, 13 Apr 2023 11:12:18 +0200 Subject: [PATCH 093/255] renamed fuction argument --- .../t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx index bcecaace98..1b04009493 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid_cxx.cxx @@ -482,7 +482,7 @@ t8_default_scheme_pyramid_c::t8_element_reference_coords (const t8_element_t *ref_coords, const void *user_data, - double *coords_out) + double *out_coords) const { T8_ASSERT (t8_element_is_valid (elem)); From b1f5fb7d799f955d0168f3c92a70a43b46ac158c Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Thu, 13 Apr 2023 12:17:37 +0200 Subject: [PATCH 094/255] Eliminate compiling errors --- src/t8_forest/t8_forest.c | 1 + tutorials/general/t8_step5_element_data_c_interface.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/t8_forest/t8_forest.c b/src/t8_forest/t8_forest.c index 1344c927f9..7679657464 100644 --- a/src/t8_forest/t8_forest.c +++ b/src/t8_forest/t8_forest.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/tutorials/general/t8_step5_element_data_c_interface.c b/tutorials/general/t8_step5_element_data_c_interface.c index 8aa59058ca..9df076eb84 100644 --- a/tutorials/general/t8_step5_element_data_c_interface.c +++ b/tutorials/general/t8_step5_element_data_c_interface.c @@ -48,6 +48,7 @@ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ #include /* forest definition and basic interface. */ +#include #include /* save forest */ #include /* default refinement scheme. */ #include /* default refinement scheme. */ From eb1533d8662918feb50c2f765d6db611b15ad641 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Thu, 13 Apr 2023 12:44:36 +0200 Subject: [PATCH 095/255] Put t8_forest header files in t8_forest/ --- benchmarks/ExtremeScaling/bunny.cxx | 2 +- benchmarks/t8_time_prism_adapt.cxx | 6 ++-- benchmarks/time_forest_partition.cxx | 8 ++--- benchmarks/time_new_refine.c | 2 +- benchmarks/time_refine_type03.c | 2 +- .../gmsh/t8_load_and_refine_square_w_hole.cxx | 6 ++-- .../IO/cmesh/tetgen/t8_forest_from_tetgen.cxx | 4 +-- .../forest/netcdf/t8_write_forest_netcdf.cxx | 4 +-- example/advect/t8_advection.cxx | 8 ++--- example/cmesh/t8_cmesh_partition.cxx | 2 +- example/common/t8_example_common.cxx | 4 +-- example/common/t8_example_common.h | 2 +- example/forest/t8_face_neighbor.cxx | 2 +- example/forest/t8_test_face_iterate.cxx | 6 ++-- example/forest/t8_test_ghost.cxx | 6 ++-- .../forest/t8_test_ghost_large_level_diff.cxx | 4 +-- example/geometry/t8_example_geometries.cxx | 4 +-- src/Makefile.am | 9 ++--- src/t8_forest/t8_forest.c | 4 +-- src/t8_forest/t8_forest.h | 36 +++++++++++++++++++ src/t8_forest/t8_forest_adapt.cxx | 2 +- src/t8_forest/t8_forest_adapt.h | 2 +- src/t8_forest/t8_forest_balance.cxx | 4 +-- src/t8_forest/t8_forest_cxx.cxx | 4 +-- src/t8_forest/t8_forest_cxx.h | 2 +- src/{ => t8_forest}/t8_forest_general.h | 0 src/{ => t8_forest}/t8_forest_geometrical.h | 0 src/t8_forest/t8_forest_ghost.cxx | 2 +- src/{ => t8_forest}/t8_forest_io.h | 0 src/t8_forest/t8_forest_iterate.cxx | 2 +- src/t8_forest/t8_forest_iterate.h | 2 +- src/t8_forest/t8_forest_netcdf.cxx | 4 +-- src/t8_forest/t8_forest_partition.cxx | 2 +- src/t8_forest/t8_forest_partition.h | 2 +- src/t8_forest/t8_forest_private.c | 2 +- src/t8_forest/t8_forest_private.h | 2 +- src/{ => t8_forest}/t8_forest_profiling.h | 0 src/t8_forest/t8_forest_types.h | 2 +- src/t8_forest/t8_forest_vtk.cxx | 2 +- src/t8_forest/t8_forest_vtk.h | 4 +-- src/t8_forest_netcdf.h | 2 +- .../t8_gtest_element_general_function.cxx | 2 +- test/t8_forest/t8_gtest_element_volume.cxx | 4 +-- test/t8_forest/t8_gtest_find_owner.cxx | 2 +- test/t8_forest/t8_gtest_forest_commit.cxx | 2 +- test/t8_forest/t8_gtest_ghost_and_owner.cxx | 2 +- test/t8_forest/t8_gtest_ghost_exchange.cxx | 2 +- test/t8_forest/t8_gtest_half_neighbors.cxx | 2 +- test/t8_forest/t8_gtest_search.cxx | 2 +- test/t8_forest/t8_gtest_transform.cxx | 2 +- test/t8_forest/t8_gtest_user_data.cxx | 2 +- test/t8_forest/t8_test_user_data.cxx | 2 +- test/t8_geometry/t8_gtest_geometry_occ.cxx | 2 +- test/t8_geometry/t8_gtest_point_inside.cxx | 4 +-- test/t8_schemes/t8_gtest_init_linear_id.cxx | 2 +- .../features/t8_features_curved_meshes.cxx | 6 ++-- tutorials/general/t8_step2_uniform_forest.cxx | 4 +-- tutorials/general/t8_step3.h | 2 +- tutorials/general/t8_step3_adapt_forest.cxx | 6 ++-- .../t8_step4_partition_balance_ghost.cxx | 4 +-- tutorials/general/t8_step5_element_data.cxx | 6 ++-- .../t8_step5_element_data_c_interface.c | 6 ++-- tutorials/general/t8_step6_stencil.cxx | 6 ++-- tutorials/general/t8_tutorial_search.cxx | 4 +-- 64 files changed, 138 insertions(+), 101 deletions(-) create mode 100644 src/t8_forest/t8_forest.h rename src/{ => t8_forest}/t8_forest_general.h (100%) rename src/{ => t8_forest}/t8_forest_geometrical.h (100%) rename src/{ => t8_forest}/t8_forest_io.h (100%) rename src/{ => t8_forest}/t8_forest_profiling.h (100%) diff --git a/benchmarks/ExtremeScaling/bunny.cxx b/benchmarks/ExtremeScaling/bunny.cxx index e91e5e9462..4d36fb4da9 100644 --- a/benchmarks/ExtremeScaling/bunny.cxx +++ b/benchmarks/ExtremeScaling/bunny.cxx @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/benchmarks/t8_time_prism_adapt.cxx b/benchmarks/t8_time_prism_adapt.cxx index d3fb3b8baf..d9ebeb43c9 100644 --- a/benchmarks/t8_time_prism_adapt.cxx +++ b/benchmarks/t8_time_prism_adapt.cxx @@ -26,9 +26,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/benchmarks/time_forest_partition.cxx b/benchmarks/time_forest_partition.cxx index 66a927cff4..56497a61e2 100644 --- a/benchmarks/time_forest_partition.cxx +++ b/benchmarks/time_forest_partition.cxx @@ -32,10 +32,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/benchmarks/time_new_refine.c b/benchmarks/time_new_refine.c index 0e45de6eb0..675df1c9d4 100644 --- a/benchmarks/time_new_refine.c +++ b/benchmarks/time_new_refine.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/benchmarks/time_refine_type03.c b/benchmarks/time_refine_type03.c index cec9b97879..3ef99d622c 100644 --- a/benchmarks/time_refine_type03.c +++ b/benchmarks/time_refine_type03.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx b/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx index 89210e0a5a..8e84238e0d 100644 --- a/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx +++ b/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx @@ -30,9 +30,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include /* Simple 3 dimensional vector product */ diff --git a/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx b/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx index 781244043b..cd49364317 100644 --- a/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx +++ b/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx @@ -27,8 +27,8 @@ #include #include #include -#include -#include +#include +#include static t8_cmesh_t t8_cmesh_from_tetgen (const char *prefix, int do_partition) diff --git a/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx b/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx index 04d1385bfc..756b8746d6 100644 --- a/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx +++ b/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx @@ -39,8 +39,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/example/advect/t8_advection.cxx b/example/advect/t8_advection.cxx index cb9ac93a8e..4d9c85bc2f 100644 --- a/example/advect/t8_advection.cxx +++ b/example/advect/t8_advection.cxx @@ -23,10 +23,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/example/cmesh/t8_cmesh_partition.cxx b/example/cmesh/t8_cmesh_partition.cxx index 888ba7f92e..3a26b74379 100644 --- a/example/cmesh/t8_cmesh_partition.cxx +++ b/example/cmesh/t8_cmesh_partition.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/example/common/t8_example_common.cxx b/example/common/t8_example_common.cxx index 5f9b0f14d0..5378f5d957 100644 --- a/example/common/t8_example_common.cxx +++ b/example/common/t8_example_common.cxx @@ -26,8 +26,8 @@ #include #include #include -#include -#include +#include +#include #include T8_EXTERN_C_BEGIN (); diff --git a/example/common/t8_example_common.h b/example/common/t8_example_common.h index 1339c26af9..986f69a4f0 100644 --- a/example/common/t8_example_common.h +++ b/example/common/t8_example_common.h @@ -31,7 +31,7 @@ #define T8_EXAMPLE_COMMON_H #include -#include +#include /** A levelset function in 3+1 space dimensions. */ typedef double (*t8_example_level_set_fn) (const double[3], double, diff --git a/example/forest/t8_face_neighbor.cxx b/example/forest/t8_face_neighbor.cxx index f94756ef56..1ab4677c24 100644 --- a/example/forest/t8_face_neighbor.cxx +++ b/example/forest/t8_face_neighbor.cxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/example/forest/t8_test_face_iterate.cxx b/example/forest/t8_test_face_iterate.cxx index b779136ddb..e289063263 100644 --- a/example/forest/t8_test_face_iterate.cxx +++ b/example/forest/t8_test_face_iterate.cxx @@ -26,9 +26,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/example/forest/t8_test_ghost.cxx b/example/forest/t8_test_ghost.cxx index b93c458109..e3f530d452 100644 --- a/example/forest/t8_test_ghost.cxx +++ b/example/forest/t8_test_ghost.cxx @@ -25,9 +25,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/example/forest/t8_test_ghost_large_level_diff.cxx b/example/forest/t8_test_ghost_large_level_diff.cxx index 9df3e5b8f6..7f5cc71f3a 100644 --- a/example/forest/t8_test_ghost_large_level_diff.cxx +++ b/example/forest/t8_test_ghost_large_level_diff.cxx @@ -42,8 +42,8 @@ #include #include #include -#include -#include +#include +#include #include /* The refinement criterion diff --git a/example/geometry/t8_example_geometries.cxx b/example/geometry/t8_example_geometries.cxx index c8b5ce63c7..9a5c63edad 100644 --- a/example/geometry/t8_example_geometries.cxx +++ b/example/geometry/t8_example_geometries.cxx @@ -23,8 +23,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/Makefile.am b/src/Makefile.am index 45485ba2af..a3141548e2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,10 +25,6 @@ libt8_installed_headers = \ src/t8_element_c_interface.h \ src/t8_refcount.h src/t8_cmesh.h src/t8_cmesh_triangle.h \ src/t8_cmesh_tetgen.h src/t8_cmesh_readmshfile.h \ - src/t8_forest_general.h \ - src/t8_forest_geometrical.h \ - src/t8_forest_profiling.h \ - src/t8_forest_io.h \ src/t8_cmesh_vtk_writer.h \ src/t8_cmesh_vtk_reader.hxx \ src/t8_vec.h \ @@ -47,6 +43,11 @@ libt8_installed_headers_cmesh = \ libt8_installed_headers_data = \ src/t8_data/t8_shmem.h src/t8_data/t8_containers.h libt8_installed_headers_forest = \ + src/t8_forest/t8_forest.h \ + src/t8_forest/t8_forest_general.h \ + src/t8_forest/t8_forest_geometrical.h \ + src/t8_forest/t8_forest_profiling.h \ + src/t8_forest/t8_forest_io.h \ src/t8_forest/t8_forest_adapt.h \ src/t8_forest/t8_forest_vtk.h \ src/t8_forest/t8_forest_iterate.h src/t8_forest/t8_forest_partition.h diff --git a/src/t8_forest/t8_forest.c b/src/t8_forest/t8_forest.c index 7679657464..63ff7da523 100644 --- a/src/t8_forest/t8_forest.c +++ b/src/t8_forest/t8_forest.c @@ -22,8 +22,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/t8_forest/t8_forest.h b/src/t8_forest/t8_forest.h new file mode 100644 index 0000000000..60dee242f1 --- /dev/null +++ b/src/t8_forest/t8_forest.h @@ -0,0 +1,36 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** \file t8_forest.h + * Includes all headers based on previous t8_forest.h + */ + +#ifndef T8_FOREST_H +#define T8_FOREST_H + + +#include +#include +#include +#include + +#endif /* !T8_FOREST_H */ \ No newline at end of file diff --git a/src/t8_forest/t8_forest_adapt.cxx b/src/t8_forest/t8_forest_adapt.cxx index 593d20571c..34f11d386a 100644 --- a/src/t8_forest/t8_forest_adapt.cxx +++ b/src/t8_forest/t8_forest_adapt.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include diff --git a/src/t8_forest/t8_forest_adapt.h b/src/t8_forest/t8_forest_adapt.h index da10e88be5..d771dab4f1 100644 --- a/src/t8_forest/t8_forest_adapt.h +++ b/src/t8_forest/t8_forest_adapt.h @@ -30,7 +30,7 @@ #define T8_FOREST_ADAPT_H #include -#include +#include T8_EXTERN_C_BEGIN (); /* TODO: comment */ diff --git a/src/t8_forest/t8_forest_balance.cxx b/src/t8_forest/t8_forest_balance.cxx index 1c6b173481..1560fc5681 100644 --- a/src/t8_forest/t8_forest_balance.cxx +++ b/src/t8_forest/t8_forest_balance.cxx @@ -25,8 +25,8 @@ #include #include #include -#include -#include +#include +#include #include /* We want to export the whole implementation to be callable from "C" */ diff --git a/src/t8_forest/t8_forest_cxx.cxx b/src/t8_forest/t8_forest_cxx.cxx index 720e4456b8..8283691177 100644 --- a/src/t8_forest/t8_forest_cxx.cxx +++ b/src/t8_forest/t8_forest_cxx.cxx @@ -23,8 +23,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/t8_forest/t8_forest_cxx.h b/src/t8_forest/t8_forest_cxx.h index e77088dc46..e81e5f25e4 100644 --- a/src/t8_forest/t8_forest_cxx.h +++ b/src/t8_forest/t8_forest_cxx.h @@ -31,7 +31,7 @@ #define T8_FOREST_CXX_H #include -#include +#include T8_EXTERN_C_BEGIN (); diff --git a/src/t8_forest_general.h b/src/t8_forest/t8_forest_general.h similarity index 100% rename from src/t8_forest_general.h rename to src/t8_forest/t8_forest_general.h diff --git a/src/t8_forest_geometrical.h b/src/t8_forest/t8_forest_geometrical.h similarity index 100% rename from src/t8_forest_geometrical.h rename to src/t8_forest/t8_forest_geometrical.h diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index 6d186fb55c..5271fb119b 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/t8_forest_io.h b/src/t8_forest/t8_forest_io.h similarity index 100% rename from src/t8_forest_io.h rename to src/t8_forest/t8_forest_io.h diff --git a/src/t8_forest/t8_forest_iterate.cxx b/src/t8_forest/t8_forest_iterate.cxx index e9a862d6ab..7869463e56 100644 --- a/src/t8_forest/t8_forest_iterate.cxx +++ b/src/t8_forest/t8_forest_iterate.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include /* We want to export the whole implementation to be callable from "C" */ diff --git a/src/t8_forest/t8_forest_iterate.h b/src/t8_forest/t8_forest_iterate.h index 77e00af2fc..59e5a24081 100644 --- a/src/t8_forest/t8_forest_iterate.h +++ b/src/t8_forest/t8_forest_iterate.h @@ -31,7 +31,7 @@ #define T8_FOREST_ITERATE_H #include -#include +#include typedef int (*t8_forest_iterate_face_fn) (t8_forest_t forest, t8_locidx_t ltreeid, diff --git a/src/t8_forest/t8_forest_netcdf.cxx b/src/t8_forest/t8_forest_netcdf.cxx index fd0e1b2edb..70f1e457b8 100644 --- a/src/t8_forest/t8_forest_netcdf.cxx +++ b/src/t8_forest/t8_forest_netcdf.cxx @@ -52,8 +52,8 @@ These functions write a file in the NetCDF-format which represents the given 2D- #endif #endif #include -#include -#include +#include +#include #include #include diff --git a/src/t8_forest/t8_forest_partition.cxx b/src/t8_forest/t8_forest_partition.cxx index 36e18da482..d2bebf638d 100644 --- a/src/t8_forest/t8_forest_partition.cxx +++ b/src/t8_forest/t8_forest_partition.cxx @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/t8_forest/t8_forest_partition.h b/src/t8_forest/t8_forest_partition.h index ce220b1963..fa25db75aa 100644 --- a/src/t8_forest/t8_forest_partition.h +++ b/src/t8_forest/t8_forest_partition.h @@ -30,7 +30,7 @@ #define T8_FOREST_PARTITION_H #include -#include +#include T8_EXTERN_C_BEGIN (); /* TODO: document */ diff --git a/src/t8_forest/t8_forest_private.c b/src/t8_forest/t8_forest_private.c index 2fd769f4e0..2fc365e492 100644 --- a/src/t8_forest/t8_forest_private.c +++ b/src/t8_forest/t8_forest_private.c @@ -22,7 +22,7 @@ #include #include -#include +#include t8_element_t * t8_forest_get_tree_element (t8_tree_t tree, t8_locidx_t elem_in_tree) diff --git a/src/t8_forest/t8_forest_private.h b/src/t8_forest/t8_forest_private.h index 4fb65f501d..3144b346b0 100644 --- a/src/t8_forest/t8_forest_private.h +++ b/src/t8_forest/t8_forest_private.h @@ -31,7 +31,7 @@ #define T8_FOREST_PRIVATE_H #include -#include +#include T8_EXTERN_C_BEGIN (); diff --git a/src/t8_forest_profiling.h b/src/t8_forest/t8_forest_profiling.h similarity index 100% rename from src/t8_forest_profiling.h rename to src/t8_forest/t8_forest_profiling.h diff --git a/src/t8_forest/t8_forest_types.h b/src/t8_forest/t8_forest_types.h index ddcf492089..85bd4a34c1 100644 --- a/src/t8_forest/t8_forest_types.h +++ b/src/t8_forest/t8_forest_types.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include typedef struct t8_profile t8_profile_t; /* Defined below */ typedef struct t8_forest_ghost *t8_forest_ghost_t; /* Defined below */ diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index 17dbdf2fd1..d7782a0261 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -56,7 +56,7 @@ #endif #endif #include -#include +#include /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); diff --git a/src/t8_forest/t8_forest_vtk.h b/src/t8_forest/t8_forest_vtk.h index 043a91c6d1..4bba7d486e 100644 --- a/src/t8_forest/t8_forest_vtk.h +++ b/src/t8_forest/t8_forest_vtk.h @@ -29,8 +29,8 @@ #define T8_FOREST_VTK_H #include -#include -#include +#include +#include T8_EXTERN_C_BEGIN (); /* function declarations */ diff --git a/src/t8_forest_netcdf.h b/src/t8_forest_netcdf.h index 70952b62a1..a3fbeb1cbc 100644 --- a/src/t8_forest_netcdf.h +++ b/src/t8_forest_netcdf.h @@ -27,7 +27,7 @@ #ifndef T8_FOREST_NETCDF_H #define T8_FOREST_NETCDF_H -#include +#include #include T8_EXTERN_C_BEGIN (); diff --git a/test/t8_forest/t8_gtest_element_general_function.cxx b/test/t8_forest/t8_gtest_element_general_function.cxx index 0fc5355a83..a166928cd3 100644 --- a/test/t8_forest/t8_gtest_element_general_function.cxx +++ b/test/t8_forest/t8_gtest_element_general_function.cxx @@ -28,7 +28,7 @@ #include #include #include -#include +#include /* * In this file we test whether the t8_element_general_function diff --git a/test/t8_forest/t8_gtest_element_volume.cxx b/test/t8_forest/t8_gtest_element_volume.cxx index 948eb59097..ef9dbe6e92 100644 --- a/test/t8_forest/t8_gtest_element_volume.cxx +++ b/test/t8_forest/t8_gtest_element_volume.cxx @@ -26,8 +26,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include -#include -#include +#include +#include /** * This file tests the volume-computation of elements. diff --git a/test/t8_forest/t8_gtest_find_owner.cxx b/test/t8_forest/t8_gtest_find_owner.cxx index 5586969e6d..fc0d06b534 100644 --- a/test/t8_forest/t8_gtest_find_owner.cxx +++ b/test/t8_forest/t8_gtest_find_owner.cxx @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/test/t8_forest/t8_gtest_forest_commit.cxx b/test/t8_forest/t8_gtest_forest_commit.cxx index 7c7ecedd5a..c948f81202 100644 --- a/test/t8_forest/t8_gtest_forest_commit.cxx +++ b/test/t8_forest/t8_gtest_forest_commit.cxx @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/test/t8_forest/t8_gtest_ghost_and_owner.cxx b/test/t8_forest/t8_gtest_ghost_and_owner.cxx index 0f79866072..5a80090df5 100644 --- a/test/t8_forest/t8_gtest_ghost_and_owner.cxx +++ b/test/t8_forest/t8_gtest_ghost_and_owner.cxx @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/test/t8_forest/t8_gtest_ghost_exchange.cxx b/test/t8_forest/t8_gtest_ghost_exchange.cxx index 96a7e45792..abb9831ecd 100644 --- a/test/t8_forest/t8_gtest_ghost_exchange.cxx +++ b/test/t8_forest/t8_gtest_ghost_exchange.cxx @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/test/t8_forest/t8_gtest_half_neighbors.cxx b/test/t8_forest/t8_gtest_half_neighbors.cxx index 5e8e20a0f8..57fe02a686 100644 --- a/test/t8_forest/t8_gtest_half_neighbors.cxx +++ b/test/t8_forest/t8_gtest_half_neighbors.cxx @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/test/t8_forest/t8_gtest_search.cxx b/test/t8_forest/t8_gtest_search.cxx index 7b8627354e..b5a625ccbf 100644 --- a/test/t8_forest/t8_gtest_search.cxx +++ b/test/t8_forest/t8_gtest_search.cxx @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include diff --git a/test/t8_forest/t8_gtest_transform.cxx b/test/t8_forest/t8_gtest_transform.cxx index e1475ee99a..874f679895 100644 --- a/test/t8_forest/t8_gtest_transform.cxx +++ b/test/t8_forest/t8_gtest_transform.cxx @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/test/t8_forest/t8_gtest_user_data.cxx b/test/t8_forest/t8_gtest_user_data.cxx index 5b6e0085d6..3dd306ed72 100644 --- a/test/t8_forest/t8_gtest_user_data.cxx +++ b/test/t8_forest/t8_gtest_user_data.cxx @@ -28,7 +28,7 @@ #include #include #include -#include +#include /* Test t8_forest_set/get_user_data. * We build a forest and set user data for it. diff --git a/test/t8_forest/t8_test_user_data.cxx b/test/t8_forest/t8_test_user_data.cxx index 5fe51a4e7b..7ea39ddb10 100644 --- a/test/t8_forest/t8_test_user_data.cxx +++ b/test/t8_forest/t8_test_user_data.cxx @@ -27,7 +27,7 @@ #include #include #include -#include +#include /* Test t8_forest_set/get_user_data. * We build a forest and set user data for it. diff --git a/test/t8_geometry/t8_gtest_geometry_occ.cxx b/test/t8_geometry/t8_gtest_geometry_occ.cxx index 4b9ea20c62..5edf208436 100755 --- a/test/t8_geometry/t8_gtest_geometry_occ.cxx +++ b/test/t8_geometry/t8_gtest_geometry_occ.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/test/t8_geometry/t8_gtest_point_inside.cxx b/test/t8_geometry/t8_gtest_point_inside.cxx index 4b3414806c..9c7f95a5c4 100644 --- a/test/t8_geometry/t8_gtest_point_inside.cxx +++ b/test/t8_geometry/t8_gtest_point_inside.cxx @@ -27,8 +27,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/test/t8_schemes/t8_gtest_init_linear_id.cxx b/test/t8_schemes/t8_gtest_init_linear_id.cxx index bde253f664..b8c4b8c15c 100644 --- a/test/t8_schemes/t8_gtest_init_linear_id.cxx +++ b/test/t8_schemes/t8_gtest_init_linear_id.cxx @@ -22,7 +22,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include -#include +#include #include #include #include diff --git a/tutorials/features/t8_features_curved_meshes.cxx b/tutorials/features/t8_features_curved_meshes.cxx index b1ee0c0f70..31ea2ee9b5 100644 --- a/tutorials/features/t8_features_curved_meshes.cxx +++ b/tutorials/features/t8_features_curved_meshes.cxx @@ -38,9 +38,9 @@ #include /* General t8code header, always include this. */ #include /* CLI parser */ #include /* cmesh definition and basic interface. */ -#include /* forest definition and basic interface. */ -#include /* save forest */ -#include /* geometrical information of the tree */ +#include /* forest definition and basic interface. */ +#include /* save forest */ +#include /* geometrical information of the tree */ #include /* default refinement scheme. */ #include /* Linear geometry calculation of trees */ #include /* Curved geometry calculation of trees */ diff --git a/tutorials/general/t8_step2_uniform_forest.cxx b/tutorials/general/t8_step2_uniform_forest.cxx index 06c4f2e250..6c7e55fbce 100644 --- a/tutorials/general/t8_step2_uniform_forest.cxx +++ b/tutorials/general/t8_step2_uniform_forest.cxx @@ -47,8 +47,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/tutorials/general/t8_step3.h b/tutorials/general/t8_step3.h index db782d34a8..a514ddc5ac 100644 --- a/tutorials/general/t8_step3.h +++ b/tutorials/general/t8_step3.h @@ -32,7 +32,7 @@ #define T8_STEP3_H #include /* General t8code header, always include this. */ -#include /* forest definition and basic interface. */ +#include /* forest definition and basic interface. */ T8_EXTERN_C_BEGIN (); diff --git a/tutorials/general/t8_step3_adapt_forest.cxx b/tutorials/general/t8_step3_adapt_forest.cxx index 65216761f5..5a6442923a 100644 --- a/tutorials/general/t8_step3_adapt_forest.cxx +++ b/tutorials/general/t8_step3_adapt_forest.cxx @@ -52,9 +52,9 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ -#include /* save forest */ -#include +#include /* forest definition and basic interface. */ +#include /* save forest */ +#include #include /* default refinement scheme. */ #include /* Basic operations on 3D vectors. */ #include diff --git a/tutorials/general/t8_step4_partition_balance_ghost.cxx b/tutorials/general/t8_step4_partition_balance_ghost.cxx index 64d085272d..aa8f307835 100644 --- a/tutorials/general/t8_step4_partition_balance_ghost.cxx +++ b/tutorials/general/t8_step4_partition_balance_ghost.cxx @@ -88,8 +88,8 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ -#include /* save forest */ +#include /* forest definition and basic interface. */ +#include /* save forest */ #include /* default refinement scheme. */ #include diff --git a/tutorials/general/t8_step5_element_data.cxx b/tutorials/general/t8_step5_element_data.cxx index d88249f6b3..bac6afd79f 100644 --- a/tutorials/general/t8_step5_element_data.cxx +++ b/tutorials/general/t8_step5_element_data.cxx @@ -45,9 +45,9 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ -#include /* save forest */ -#include /* geometrical information */ +#include /* forest definition and basic interface. */ +#include /* save forest */ +#include /* geometrical information */ #include /* default refinement scheme. */ #include diff --git a/tutorials/general/t8_step5_element_data_c_interface.c b/tutorials/general/t8_step5_element_data_c_interface.c index 9df076eb84..48d12e1a36 100644 --- a/tutorials/general/t8_step5_element_data_c_interface.c +++ b/tutorials/general/t8_step5_element_data_c_interface.c @@ -47,9 +47,9 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ -#include -#include /* save forest */ +#include /* forest definition and basic interface. */ +#include +#include /* save forest */ #include /* default refinement scheme. */ #include /* default refinement scheme. */ #include diff --git a/tutorials/general/t8_step6_stencil.cxx b/tutorials/general/t8_step6_stencil.cxx index 01cb6a1cd1..d609e29555 100644 --- a/tutorials/general/t8_step6_stencil.cxx +++ b/tutorials/general/t8_step6_stencil.cxx @@ -42,9 +42,9 @@ #include /* General t8code header, always include this. */ #include /* Basic operations on 3D vectors. */ #include /* cmesh definition and basic interface. */ -#include /* forest definition and basic interface. */ -#include /* save forest */ -#include /* geometrical information */ +#include /* forest definition and basic interface. */ +#include /* save forest */ +#include /* geometrical information */ #include /* A collection of exemplary cmeshes */ #include /* default refinement scheme. */ #include diff --git a/tutorials/general/t8_tutorial_search.cxx b/tutorials/general/t8_tutorial_search.cxx index 9c39869de8..4b2603feca 100644 --- a/tutorials/general/t8_tutorial_search.cxx +++ b/tutorials/general/t8_tutorial_search.cxx @@ -110,8 +110,8 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ -#include /* save forest */ +#include /* forest definition and basic interface. */ +#include /* save forest */ #include /* default refinement scheme. */ #include /* Basic operations on 3D vectors. */ #include /* For the search algorithm. */ From 7fe3cacff28ccde52b940cb1bc440e96607fd386 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Thu, 13 Apr 2023 12:48:49 +0200 Subject: [PATCH 096/255] Solve 'check error' --- test/t8_forest/t8_gtest_find_owner.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/test/t8_forest/t8_gtest_find_owner.cxx b/test/t8_forest/t8_gtest_find_owner.cxx index fc0d06b534..a005dc7cd9 100644 --- a/test/t8_forest/t8_gtest_find_owner.cxx +++ b/test/t8_forest/t8_gtest_find_owner.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include From 3a5250295d0d86dbbd8200e66a6f1aa55c3b2692 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Thu, 13 Apr 2023 16:01:54 +0200 Subject: [PATCH 097/255] removed second implementation of t8_dtri_compute_reference_coords --- .../t8_default/t8_default_tri/t8_dtri_bits.c | 71 ------------------- 1 file changed, 71 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c index 148c4646d8..8186997d41 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c @@ -446,77 +446,6 @@ t8_dtri_compute_reference_coords (const t8_dtri_t *elem, #endif } -void -t8_dtri_compute_reference_coords (const t8_dtri_t *elem, - const double *ref_coords, - double out_coords[T8_DTRI_DIM]) -{ - /* Calculate the reference coordinates of a triangle/tetrahedron in - * relation to its orientation. Orientations are described here: - * https://doi.org/10.1137/15M1040049 - * 1---------------------2 - * | orientation / 2 - * | 1 / / | - * | / / | - * | / / | - * | / / | - * | / / | - * | / / | - * | / / | - * | / / orientation | - * | / / 0 | - * 0 / | - * 0--------------------1 - * - * y - * ^ - * | - * z--> x - */ - T8_ASSERT (ref_coords != NULL); - - t8_dtri_type_t type; - t8_dtri_coord_t h; - - type = elem->type; - h = T8_DTRI_LEN (elem->level); -#ifndef T8_DTRI_TO_DTET - const int tri_orientation = type; -#else - /* These integers define the sequence, in which the ref_coords are added - * to the out_coords */ - const int tet_orientation0 = type / 2; - const int tet_orientation1 = - (tet_orientation0 + ((type % 2 == 0) ? 1 : 2)) % 3; - const int tet_orientation2 = - (tet_orientation0 + ((type % 2 == 0) ? 2 : 1)) % 3; -#endif - - out_coords[0] = elem->x; - out_coords[1] = elem->y; -#ifdef T8_DTRI_TO_DTET - out_coords[2] = elem->z; -#endif -#ifndef T8_DTRI_TO_DTET - out_coords[tri_orientation] += h * ref_coords[1]; - out_coords[1 - tri_orientation] += h * ref_coords[0]; -#else - out_coords[tet_orientation0] += h * ref_coords[0]; - out_coords[tet_orientation1] += h * ref_coords[1]; - out_coords[tet_orientation2] += h * ref_coords[2]; - - /* done 3D */ -#endif - /* Since the integer coordinates are coordinates w.r.t to - * the embedding into [0,T8_DTRI_ROOT_LEN]^d, we just need - * to divide them by the root length. */ - out_coords[0] /= (double) T8_DTRI_ROOT_LEN; - out_coords[1] /= (double) T8_DTRI_ROOT_LEN; -#ifdef T8_DTRI_TO_DTET - out_coords[2] /= (double) T8_DTRI_ROOT_LEN; -#endif -} - /* Compute the coordinates of each vertex of a triangle/tet */ void t8_dtri_compute_all_coords (const t8_dtri_t *elem, From 97931a0418c765520021e08f783e984f891777a3 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Fri, 14 Apr 2023 08:02:34 +0200 Subject: [PATCH 098/255] Correct indentation --- src/t8_forest/t8_forest.h | 15 +- src/t8_forest/t8_forest_general.h | 608 +++++++++--------- src/t8_forest/t8_forest_geometrical.h | 111 ++-- src/t8_forest/t8_forest_io.h | 66 +- src/t8_forest/t8_forest_profiling.h | 112 ++-- .../features/t8_features_curved_meshes.cxx | 6 +- tutorials/general/t8_step2_uniform_forest.cxx | 2 +- tutorials/general/t8_step3.h | 2 +- tutorials/general/t8_step3_adapt_forest.cxx | 4 +- .../t8_step4_partition_balance_ghost.cxx | 4 +- tutorials/general/t8_step5_element_data.cxx | 6 +- .../t8_step5_element_data_c_interface.c | 8 +- tutorials/general/t8_step6_stencil.cxx | 6 +- tutorials/general/t8_tutorial_search.cxx | 4 +- 14 files changed, 473 insertions(+), 481 deletions(-) diff --git a/src/t8_forest/t8_forest.h b/src/t8_forest/t8_forest.h index 60dee242f1..88adc71e7b 100644 --- a/src/t8_forest/t8_forest.h +++ b/src/t8_forest/t8_forest.h @@ -18,19 +18,18 @@ You should have received a copy of the GNU General Public License along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - +*/ + /** \file t8_forest.h * Includes all headers based on previous t8_forest.h - */ - + */ + #ifndef T8_FOREST_H #define T8_FOREST_H - - + #include #include #include #include - -#endif /* !T8_FOREST_H */ \ No newline at end of file + +#endif /* !T8_FOREST_H */ diff --git a/src/t8_forest/t8_forest_general.h b/src/t8_forest/t8_forest_general.h index 192d12959f..5095bb3889 100644 --- a/src/t8_forest/t8_forest_general.h +++ b/src/t8_forest/t8_forest_general.h @@ -18,44 +18,44 @@ You should have received a copy of the GNU General Public License along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - +*/ + /** \file t8_forest_general.h * We define the forest of trees in this file. - */ - -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ - + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + #ifndef T8_FOREST_GENERAL_H #define T8_FOREST_GENERAL_H - + #include #include #include - -/** Opaque pointer to a forest implementation. */ -typedef struct t8_forest *t8_forest_t; -typedef struct t8_tree *t8_tree_t; - + +/** Opaque pointer to a forest implementation. */ +typedef struct t8_forest *t8_forest_t; + typedef struct t8_tree *t8_tree_t; + /** This type controls, which neighbors count as ghost elements. * Currently, we support face-neighbors. Vertex and edge neighbors - * will eventually be added. */ -typedef enum -{ - T8_GHOST_NONE = 0, /**< Do not create ghost layer. */ - T8_GHOST_FACES, /**< Consider all face (codimension 1) neighbors. */ - T8_GHOST_EDGES, /**< Consider all edge (codimension 2) and face neighbors. */ - T8_GHOST_VERTICES /**< Consider all vertex (codimension 3) and edge and face neighbors. */ -} t8_ghost_type_t; - + * will eventually be added. */ +typedef enum +{ T8_GHOST_NONE = 0, /**< Do not create ghost layer. */ + T8_GHOST_FACES, /**< Consider all face (codimension 1) neighbors. */ + T8_GHOST_EDGES, /**< Consider all edge (codimension 2) and face neighbors. */ + T8_GHOST_VERTICES + /**< Consider all vertex (codimension 3) and edge and face neighbors. */ + +} t8_ghost_type_t; + /** This typedef is needed as a helper construct to * properly be able to define a function that returns * a pointer to a void fun(void) function. \see t8_forest_get_user_function. - */ -typedef void (*t8_generic_function_pointer) (void); - -T8_EXTERN_C_BEGIN (); - + */ +typedef void (*t8_generic_function_pointer) (void); + T8_EXTERN_C_BEGIN (); + /** Callback function prototype to replace one set of elements with another. * * This is used by the replace routine which can be called after adapt, @@ -84,17 +84,16 @@ T8_EXTERN_C_BEGIN (); * the number of family members and \a num_incoming will be 1. Else \a refine will * be 0 and \a num_outgoing and \a num_incoming will both be 1. * \see t8_forest_iterate_replace - */ -typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, - t8_forest_t forest_new, - t8_locidx_t which_tree, - t8_eclass_scheme_c *ts, - int refine, - int num_outgoing, - t8_locidx_t first_outgoing, - int num_incoming, - t8_locidx_t first_incoming); - + */ +typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, + t8_forest_t forest_new, + t8_locidx_t which_tree, + t8_eclass_scheme_c *ts, + int refine, int num_outgoing, + t8_locidx_t first_outgoing, + int num_incoming, + t8_locidx_t first_incoming); + /** Callback function prototype to decide for refining and coarsening. * If \a is_family equals 1, the first \a num_elements in \a elements * form a family and we decide whether this family should be coarsened @@ -114,18 +113,18 @@ typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, * \return greater zero if the first entry in \a elements should be refined, * smaller zero if the family \a elements shall be coarsened, * zero else. - */ + */ /* TODO: Do we really need the forest argument? Since the forest is not committed yet it - * seems dangerous to expose to the user. */ -typedef int (*t8_forest_adapt_t) (t8_forest_t forest, - t8_forest_t forest_from, - t8_locidx_t which_tree, - t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, - const int is_family, - const int num_elements, - t8_element_t *elements[]); - + * seems dangerous to expose to the user. */ +typedef int (*t8_forest_adapt_t) (t8_forest_t forest, + t8_forest_t forest_from, + t8_locidx_t which_tree, + t8_locidx_t lelement_id, + t8_eclass_scheme_c *ts, + const int is_family, + const int num_elements, + t8_element_t *elements[]); + /** Create a new forest with reference count one. * This forest needs to be specialized with the t8_forest_set_* calls. * Currently it is manatory to either call the functions \ref @@ -136,9 +135,9 @@ typedef int (*t8_forest_adapt_t) (t8_forest_t forest, * Then it needs to be set up with \ref t8_forest_commit. * \param [in,out] pforest On input, this pointer must be non-NULL. * On return, this pointer set to the new forest. - */ -void t8_forest_init (t8_forest_t *pforest); - + */ +void t8_forest_init (t8_forest_t *pforest); + /** Check whether a forest is not NULL, initialized and not committed. * In addition, it asserts that the forest is consistent as much as possible. * \param [in] forest This forest is examined. May be NULL. @@ -146,9 +145,9 @@ void t8_forest_init (t8_forest_t *pforest); * \ref t8_forest_init has been called on it, * but not \ref t8_forest_commit. * False otherwise. - */ -int t8_forest_is_initialized (t8_forest_t forest); - + */ +int t8_forest_is_initialized (t8_forest_t forest); + /** Check whether a forest is not NULL, initialized and committed. * In addition, it asserts that the forest is consistent as much as possible. * \param [in] forest This forest is examined. May be NULL. @@ -156,9 +155,9 @@ int t8_forest_is_initialized (t8_forest_t forest); * \ref t8_forest_init has been called on it * as well as \ref t8_forest_commit. * False otherwise. - */ -int t8_forest_is_committed (t8_forest_t forest); - + */ +int t8_forest_is_committed (t8_forest_t forest); + /** Check whether two committed forests have the same local elements. * \param [in] forest_a The first forest. * \param [in] forest_b The second forest. @@ -168,10 +167,10 @@ int t8_forest_is_committed (t8_forest_t forest); * for each pair of elements of \a forest_a and \a forest_b. * \note This function is not collective. It only returns the state on the current * rank. - */ -int t8_forest_is_equal (t8_forest_t forest_a, - t8_forest_t forest_b); - + */ +int t8_forest_is_equal (t8_forest_t forest_a, + t8_forest_t forest_b); + /** Set the cmesh associated to a forest. * By default, the forest takes ownership of the cmesh such that it will be * destroyed when the forest is destroyed. To keep ownership of the cmesh, @@ -181,10 +180,10 @@ int t8_forest_is_equal (t8_forest_t forest_a, * \param [in,out] forest The forest whose cmesh variable will be set. * \param [in] cmesh The cmesh to be set. We take ownership. * This can be prevented by referencing \b cmesh. - */ -void t8_forest_set_cmesh (t8_forest_t forest, - t8_cmesh_t cmesh, sc_MPI_Comm comm); - + */ +void t8_forest_set_cmesh (t8_forest_t forest, + t8_cmesh_t cmesh, sc_MPI_Comm comm); + /** Set the element scheme associated to a forest. * By default, the forest takes ownership of the scheme such that it will be * destroyed when the forest is destroyed. To keep ownership of the scheme, call @@ -194,10 +193,10 @@ void t8_forest_set_cmesh (t8_forest_t forest, * \param [in,out] forest The forest whose scheme variable will be set. * \param [in] scheme The scheme to be set. We take ownership. * This can be prevented by referencing \b scheme. - */ -void t8_forest_set_scheme (t8_forest_t forest, - t8_scheme_cxx_t *scheme); - + */ +void t8_forest_set_scheme (t8_forest_t forest, + t8_scheme_cxx_t *scheme); + /** Set the initial refinement level to be used when \b forest is commited. * \param [in,out] forest The forest whose level will be set. * \param [in] level The initial refinement level of \b forest, when @@ -207,9 +206,9 @@ void t8_forest_set_scheme (t8_forest_t forest, * and \ref t8_forest_set_balance) and overwrites any of these settings. * If this function is used, then the forest is created from scratch as a uniform * refinement of the specified cmesh (\ref t8_forest_set_cmesh, \ref t8_forest_set_scheme). - */ -void t8_forest_set_level (t8_forest_t forest, int level); - + */ +void t8_forest_set_level (t8_forest_t forest, int level); + /** Set a forest as source for copying on commiting. * By default, the forest takes ownership of the source \b from such that it will * be destroyed on calling \ref t8_forest_commit. To keep ownership of \b @@ -222,10 +221,10 @@ void t8_forest_set_level (t8_forest_t forest, int level); * \note This setting cannot be combined with \ref t8_forest_set_adapt, * \ref t8_forest_set_partition, or \ref t8_forest_set_balance and overwrites these * settings. - */ -void t8_forest_set_copy (t8_forest_t forest, - const t8_forest_t from); - + */ +void t8_forest_set_copy (t8_forest_t forest, + const t8_forest_t from); + /** Set a source forest with an adapt function to be adapted on commiting. * By default, the forest takes ownership of the source \b set_from such that it * will be destroyed on calling \ref t8_forest_commit. To keep ownership of \b @@ -247,30 +246,30 @@ void t8_forest_set_copy (t8_forest_t forest, * 1) Adapt 2) Balance 3) Partition * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites * this setting. - */ -/* TODO: make recursive flag to int specifying the number of recursions? */ -void t8_forest_set_adapt (t8_forest_t forest, - const t8_forest_t set_from, - t8_forest_adapt_t adapt_fn, - int recursive); - + */ +/* TODO: make recursive flag to int specifying the number of recursions? */ +void t8_forest_set_adapt (t8_forest_t forest, + const t8_forest_t set_from, + t8_forest_adapt_t adapt_fn, + int recursive); + /** Set the user data of a forest. This can i.e. be used to pass user defined * arguments to the adapt routine. * \param [in,out] forest The forest * \param [in] data A pointer to user data. t8code will never touch the data. * The forest does not need be committed before calling this function. * \see t8_forest_get_user_data - */ -void t8_forest_set_user_data (t8_forest_t forest, void *data); - + */ +void t8_forest_set_user_data (t8_forest_t forest, void *data); + /** Return the user data pointer associated with a forest. * \param [in] forest The forest. * \return The user data pointer of \a forest. * The forest does not need be committed before calling this function. * \see t8_forest_set_user_data - */ -void *t8_forest_get_user_data (t8_forest_t forest); - + */ +void *t8_forest_get_user_data (t8_forest_t forest); + /** Set the user function pointer of a forest. This can i.e. be used to pass user defined * functions to the adapt routine. * \param [in,out] forest The forest @@ -280,19 +279,20 @@ void *t8_forest_get_user_data (t8_forest_t forest); * your choice. When accessing it with \ref t8_forest_get_user_function you should cast * it into the proper type. * \see t8_forest_get_user_function - */ -void t8_forest_set_user_function (t8_forest_t forest, - t8_generic_function_pointer - functrion); - + */ +void t8_forest_set_user_function (t8_forest_t forest, + t8_generic_function_pointer + functrion); + /** Return the user function pointer associated with a forest. * \param [in] forest The forest. * \return The user function pointer of \a forest. * The forest does not need be committed before calling this function. * \see t8_forest_set_user_function - */ -t8_generic_function_pointer t8_forest_get_user_function (t8_forest_t forest); - + */ + t8_generic_function_pointer t8_forest_get_user_function (t8_forest_t + forest); + /** Set a source forest to be partitioned during commit. * The partitioning is done according to the SFC and each rank is assinged * the same (maybe +1) number of elements. @@ -312,11 +312,11 @@ t8_generic_function_pointer t8_forest_get_user_function (t8_forest_t forest); * false, it is not neccessary to call \ref t8_forest_set_partition additionally. * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites * this setting. - */ -void t8_forest_set_partition (t8_forest_t forest, - const t8_forest_t set_from, - int set_for_coarsening); - + */ +void t8_forest_set_partition (t8_forest_t forest, + const t8_forest_t set_from, + int set_for_coarsening); + /** Set a source forest to be balanced during commit. * A forest is said to be balanced if each element has face neighbors of level * at most +1 or -1 of the element's level. @@ -339,11 +339,11 @@ void t8_forest_set_partition (t8_forest_t forest, * 1) Adapt 2) Balance 3) Partition. * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites * this setting. - */ -void t8_forest_set_balance (t8_forest_t forest, - const t8_forest_t set_from, - int no_repartition); - + */ +void t8_forest_set_balance (t8_forest_t forest, + const t8_forest_t set_from, + int no_repartition); + /** Enable or disable the creation of a layer of ghost elements. * On default no ghosts are created. * \param [in] forest The forest. @@ -351,10 +351,10 @@ void t8_forest_set_balance (t8_forest_t forest, * \param [in] ghost_type Controls which neighbors count as ghost elements, * currently only T8_GHOST_FACES is supported. This value * is ignored if \a do_ghost = 0. - */ -void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, - t8_ghost_type_t ghost_type); - + */ +void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, + t8_ghost_type_t ghost_type); + /** Like \ref t8_forest_set_ghost but with the additional options to change the * ghost algorithm. This is used for debugging and timing the algorithm. * An application should almost always use \ref t8_forest_set_ghost. @@ -362,29 +362,29 @@ void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, * If 2, the iterativ algorithm for unbalanced forests. * If 3, the top-down search algorithm for unbalanced forests. * \see t8_forest_set_ghost - */ -void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, - t8_ghost_type_t ghost_type, - int ghost_version); - + */ +void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, + t8_ghost_type_t ghost_type, + int ghost_version); + /* TODO: use assertions and document that the forest_set (..., from) and - * set_load are mutually exclusive. */ -void t8_forest_set_load (t8_forest_t forest, - const char *filename); - + * set_load are mutually exclusive. */ +void t8_forest_set_load (t8_forest_t forest, + const char *filename); + /** Compute the global number of elements in a forest as the sum * of the local element counts. * \param [in] forest The forest. - */ -void t8_forest_comm_global_num_elements (t8_forest_t forest); - + */ +void t8_forest_comm_global_num_elements (t8_forest_t forest); + /** After allocating and adding properties to a forest, commit the changes. * This call sets up the internal state of the forest. * \param [in,out] forest Must be created with \ref t8_forest_init and * specialized with t8_forest_set_* calls first. - */ -void t8_forest_commit (t8_forest_t forest); - + */ +void t8_forest_commit (t8_forest_t forest); + /** Return the maximum allowed refinement level for any element in a forest. * \param [in] forest A forest. * \return The maximum level of refinement that is allowed for @@ -395,41 +395,41 @@ void t8_forest_commit (t8_forest_t forest); * For forest with a single element class (non-hybrid) maxlevel is the maximum * refinement level of this element class, whilst for hybrid forests the maxlevel is * the minimum of all maxlevels of the element classes in this forest. - */ -int t8_forest_get_maxlevel (t8_forest_t forest); - + */ +int t8_forest_get_maxlevel (t8_forest_t forest); + /** Return the number of process local elements in the forest. * \param [in] forest A forest. * \return The number of elements on this process in \a forest. * \a forest must be committed before calling this function. - */ -t8_locidx_t t8_forest_get_local_num_elements (t8_forest_t forest); - + */ +t8_locidx_t t8_forest_get_local_num_elements (t8_forest_t forest); + /** Return the number of global elements in the forest. * \param [in] forest A forest. * \return The number of elements (summed over all processes) in \a forest. * \a forest must be committed before calling this function. - */ -t8_gloidx_t t8_forest_get_global_num_elements (t8_forest_t forest); - + */ +t8_gloidx_t t8_forest_get_global_num_elements (t8_forest_t forest); + /** Return the number of ghost elements of a forest. * \param [in] forest The forest. * \return The number of ghost elements stored in the ghost * structure of \a forest. 0 if no ghosts were constructed. * \see t8_forest_set_ghost * \a forest must be committed before calling this function. - */ -t8_locidx_t t8_forest_get_num_ghosts (t8_forest_t forest); - + */ +t8_locidx_t t8_forest_get_num_ghosts (t8_forest_t forest); + /** Return the element class of a forest local tree. * \param [in] forest The forest. * \param [in] ltreeid The local id of a tree in \a forest. * \return The element class of the tree \a ltreeid. * \a forest must be committed before calling this function. - */ -t8_eclass_t t8_forest_get_eclass (t8_forest_t forest, - t8_locidx_t ltreeid); - + */ +t8_eclass_t t8_forest_get_eclass (t8_forest_t forest, + t8_locidx_t ltreeid); + /** Given a global tree id compute the forest local id of this tree. * If the tree is a local tree, then the local id is between 0 and the number * of local trees. If the tree is not a local tree, a negative number is returned. @@ -438,10 +438,10 @@ t8_eclass_t t8_forest_get_eclass (t8_forest_t forest, * \return The tree's local id in \a forest, if it is a local tree. * A negative number if not. * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ -t8_locidx_t t8_forest_get_local_id (t8_forest_t forest, - t8_gloidx_t gtreeid); - + */ +t8_locidx_t t8_forest_get_local_id (t8_forest_t forest, + t8_gloidx_t gtreeid); + /** Given the local id of a tree in a forest, compute the tree's local id * in the associated cmesh. * \param [in] forest The forest. @@ -450,10 +450,10 @@ t8_locidx_t t8_forest_get_local_id (t8_forest_t forest, * \a forest must be committed before calling this function. * \note For forest local trees, this is the inverse function of \ref t8_forest_cmesh_ltreeid_to_ltreeid. * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ -t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, - t8_locidx_t ltreeid); - + */ +t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, + t8_locidx_t ltreeid); + /** Given the local id of a tree in the coarse mesh of a forest, compute * the tree's local id in the forest. * \param [in] forest The forest. @@ -462,20 +462,21 @@ t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, * \a forest must be committed before calling this function. * \note For forest local trees, this is the inverse function of \ref t8_forest_ltreeid_to_cmesh_ltreeid. * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ -t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, - t8_locidx_t lctreeid); - + */ +t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, + t8_locidx_t + lctreeid); + /** Given the local id of a tree in a forest, return the coarse tree of the * cmesh that corresponds to this tree. * \param [in] forest The forest. * \param [in] ltreeid The local id of a tree in the forest. * \return The coarse tree that matches the forest tree with local * id \a ltreeid. - */ -t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, - t8_locidx_t ltreeid); - + */ + t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, + t8_locidx_t ltreeid); + /** Compute the leaf face neighbors of a forest. * \param [in] forest The forest. Must have a valid ghost layer. * \param [in] ltreeid A local tree id. @@ -497,21 +498,21 @@ t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, * and *pelement_indices = NULL on output. * \note Currently \a forest must be balanced. * \note \a forest must be committed before calling this function. - */ -void t8_forest_leaf_face_neighbors (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *leaf, - t8_element_t - **pneighbor_leafs[], - int face, - int *dual_faces[], - int *num_neighbors, - t8_locidx_t - **pelement_indices, - t8_eclass_scheme_c - **pneigh_scheme, - int forest_is_balanced); - + */ +void t8_forest_leaf_face_neighbors (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t *leaf, + t8_element_t + **pneighbor_leafs[], + int face, + int *dual_faces[], + int *num_neighbors, + t8_locidx_t + **pelement_indices, + t8_eclass_scheme_c + **pneigh_scheme, + int forest_is_balanced); + /** Exchange ghost information of user defined element data. * \param[in] forest The forest. Must be committed. * \param[in] element_data An array of length num_local_elements + num_ghosts @@ -521,16 +522,16 @@ void t8_forest_leaf_face_neighbors (t8_forest_t forest, * the corresponding owning process. * \note This function is collective and hence must be called by all processes in the forest's * MPI Communicator. - */ + */ /* TODO: In \ref t8_forest_ghost_cxx we already implemented a begin and end function * that allow for overlapping communication and computation. We will make them - * available in this interface in the future. */ -void t8_forest_ghost_exchange_data (t8_forest_t forest, - sc_array_t *element_data); - -/** Print the ghost structure of a forest. Only used for debugging. */ -void t8_forest_ghost_print (t8_forest_t forest); - + * available in this interface in the future. */ +void t8_forest_ghost_exchange_data (t8_forest_t forest, + sc_array_t *element_data); + +/** Print the ghost structure of a forest. Only used for debugging. */ +void t8_forest_ghost_print (t8_forest_t forest); + /** Change the cmesh associated to a forest to a partitioned cmesh that * is partitioned according to the tree distribution in the forest. * \param [in,out] forest The forest. @@ -539,42 +540,42 @@ void t8_forest_ghost_print (t8_forest_t forest); * \param [in] set_profiling If true, profiling for the new cmesh * will be enabled. \see t8_cmesh_set_profiling, \see t8_cmesh_print_profile * \see t8_cmesh.h - */ -void t8_forest_partition_cmesh (t8_forest_t forest, - sc_MPI_Comm comm, - int set_profiling); - + */ +void t8_forest_partition_cmesh (t8_forest_t forest, + sc_MPI_Comm comm, + int set_profiling); + /** Return the mpi communicator associated to a forest. * \param [in] forest The forest. * \return The mpi communicator of \a forest. * \a forest must be committed before calling this function. - */ -sc_MPI_Comm t8_forest_get_mpicomm (t8_forest_t forest); - + */ + sc_MPI_Comm t8_forest_get_mpicomm (t8_forest_t forest); + /** Return the global id of the first local tree of a forest. * \param [in] forest The forest. * \return The global id of the first local tree in \a forest. - */ -t8_gloidx_t t8_forest_get_first_local_tree_id (t8_forest_t forest); - + */ +t8_gloidx_t t8_forest_get_first_local_tree_id (t8_forest_t forest); + /** Return the number of local trees of a given forest. * \param [in] forest The forest. * \return The number of local trees of that forest. - */ -t8_locidx_t t8_forest_get_num_local_trees (t8_forest_t forest); - + */ +t8_locidx_t t8_forest_get_num_local_trees (t8_forest_t forest); + /** Return the number of ghost trees of a given forest. * \param [in] forest The forest. * \return The number of ghost trees of that forest. - */ -t8_locidx_t t8_forest_get_num_ghost_trees (t8_forest_t forest); - + */ +t8_locidx_t t8_forest_get_num_ghost_trees (t8_forest_t forest); + /** Return the number of global trees of a given forest. * \param [in] forest The forest. * \return The number of global trees of that forest. - */ -t8_gloidx_t t8_forest_get_num_global_trees (t8_forest_t forest); - + */ +t8_gloidx_t t8_forest_get_num_global_trees (t8_forest_t forest); + /** Return the global id of a local tree or a ghost tree. * \param [in] forest The forest. * \param [in] ltreeid An id 0 <= \a ltreeid < num_local_trees + num_ghosts @@ -582,43 +583,42 @@ t8_gloidx_t t8_forest_get_num_global_trees (t8_forest_t forest); * \return The global id corresponding to the tree with local id \a ltreeid. * \a forest must be committed before calling this function. * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ -t8_gloidx_t t8_forest_global_tree_id (t8_forest_t forest, - t8_locidx_t ltreeid); - + */ +t8_gloidx_t t8_forest_global_tree_id (t8_forest_t forest, + t8_locidx_t ltreeid); + /** Return a pointer to a tree in a forest. * \param [in] forest The forest. * \param [in] ltree_id The local id of the tree. * \return A pointer to the tree with local id \a ltree_id. * \a forest must be committed before calling this function. - */ -t8_tree_t t8_forest_get_tree (t8_forest_t forest, - t8_locidx_t ltree_id); - + */ + t8_tree_t t8_forest_get_tree (t8_forest_t forest, t8_locidx_t ltree_id); + /** Return a pointer to the vertex coordinates of a tree. * \param [in] forest The forest. * \param [in] ltreeid The id of a local tree. * \return If stored, a pointer to the vertex coordinates of \a tree. * If no coordinates for this tree are found, NULL. - */ -double *t8_forest_get_tree_vertices (t8_forest_t forest, - t8_locidx_t ltreeid); - + */ +double *t8_forest_get_tree_vertices (t8_forest_t forest, + t8_locidx_t ltreeid); + /** Return the array of leaf elements of a local tree in a forest. * \param [in] forest The forest. * \param [in] ltree_id The local id of a local tree of \a forest. * \return An array of t8_element_t * storing all leaf elements * of this tree. - */ -t8_element_array_t *t8_forest_tree_get_leafs (t8_forest_t forest, - t8_locidx_t ltree_id); - + */ +t8_element_array_t *t8_forest_tree_get_leafs (t8_forest_t forest, + t8_locidx_t ltree_id); + /** Return a cmesh associated to a forest. * \param [in] forest The forest. * \return The cmesh associated to the forest. - */ -t8_cmesh_t t8_forest_get_cmesh (t8_forest_t forest); - + */ +t8_cmesh_t t8_forest_get_cmesh (t8_forest_t forest); + /** Return an element of the forest. * \param [in] forest The forest. * \param [in] lelement_id The local id of an element in \a forest. @@ -627,11 +627,11 @@ t8_cmesh_t t8_forest_get_cmesh (t8_forest_t forest); * \return A pointer to the element. NULL if this element does not exist. * \note This function performs a binary search. For constant access, use \ref t8_forest_get_element_in_tree * \a forest must be committed before calling this function. - */ -t8_element_t *t8_forest_get_element (t8_forest_t forest, - t8_locidx_t lelement_id, - t8_locidx_t *ltreeid); - + */ +t8_element_t *t8_forest_get_element (t8_forest_t forest, + t8_locidx_t lelement_id, + t8_locidx_t *ltreeid); + /** Return an element of a local tree in a forest. * \param [in] forest The forest. * \param [in] ltreeid An id of a local tree in the forest. @@ -639,19 +639,19 @@ t8_element_t *t8_forest_get_element (t8_forest_t forest, * \return A pointer to the element. * \note If the tree id is know, this function should be preferred over \ref t8_forest_get_element. * \a forest must be committed before calling this function. - */ -t8_element_t *t8_forest_get_element_in_tree (t8_forest_t forest, - t8_locidx_t ltreeid, - t8_locidx_t leid_in_tree); - + */ +t8_element_t *t8_forest_get_element_in_tree (t8_forest_t forest, + t8_locidx_t ltreeid, + t8_locidx_t leid_in_tree); + /** Return the number of elements of a tree. * \param [in] forest The forest. * \param [in] ltreeid A local id of a tree. * \return The number of elements in the local tree \a ltreeid. - */ -t8_locidx_t t8_forest_get_tree_num_elements (t8_forest_t forest, - t8_locidx_t ltreeid); - + */ +t8_locidx_t t8_forest_get_tree_num_elements (t8_forest_t forest, + t8_locidx_t ltreeid); + /** Return the element offset of a local tree, that is the number of elements * in all trees with smaller local treeid. * \param [in] forest The forest. @@ -659,50 +659,50 @@ t8_locidx_t t8_forest_get_tree_num_elements (t8_forest_t forest, * \return The number of leaf elements on all local tree with * id < \a ltreeid. * \note \a forest must be committed before calling this function. - */ -t8_locidx_t t8_forest_get_tree_element_offset (t8_forest_t forest, - t8_locidx_t ltreeid); - + */ +t8_locidx_t t8_forest_get_tree_element_offset (t8_forest_t forest, + t8_locidx_t ltreeid); + /** Return the number of elements of a tree. * \param [in] tree A tree in a forest. * \return The number of elements of that tree. - */ -t8_locidx_t t8_forest_get_tree_element_count (t8_tree_t tree); - + */ +t8_locidx_t t8_forest_get_tree_element_count (t8_tree_t tree); + /** Return the eclass of a tree in a forest. * \param [in] forest The forest. * \param [in] ltreeid The local id of a tree (local or ghost) in \a forest. * \return The element class of the tree with local id \a ltreeid. - */ -t8_eclass_t t8_forest_get_tree_class (t8_forest_t forest, - t8_locidx_t ltreeid); - + */ +t8_eclass_t t8_forest_get_tree_class (t8_forest_t forest, + t8_locidx_t ltreeid); + /** Compute the global index of the first local element of a forest. * This function is collective. * \param [in] forest A committed forest, whose first element's index is computed. * \return The global index of \a forest's first local element. * Forest must be committed when calling this function. * This function is collective and must be called on each process. - */ -t8_gloidx_t t8_forest_get_first_local_element_id (t8_forest_t forest); - + */ +t8_gloidx_t t8_forest_get_first_local_element_id (t8_forest_t forest); + /** Return the element scheme associated to a forest. * \param [in] forest. A committed forest. * \return The element scheme of the forest. * \see t8_forest_set_scheme - */ -t8_scheme_cxx_t *t8_forest_get_scheme (t8_forest_t forest); - + */ +t8_scheme_cxx_t *t8_forest_get_scheme (t8_forest_t forest); + /** Return the eclass scheme of a given element class associated to a forest. * \param [in] forest. A committed forest. * \param [in] eclass. An element class. * \return The eclass scheme of \a eclass associated to forest. * \see t8_forest_set_scheme * \note The forest is not required to have trees of class \a eclass. - */ -t8_eclass_scheme_c *t8_forest_get_eclass_scheme (t8_forest_t forest, - t8_eclass_t eclass); - + */ +t8_eclass_scheme_c *t8_forest_get_eclass_scheme (t8_forest_t forest, + t8_eclass_t eclass); + /** Return the eclass of the tree in which a face neighbor of a given element * lies. * \param [in] forest. A committed forest. @@ -711,12 +711,12 @@ t8_eclass_scheme_c *t8_forest_get_eclass_scheme (t8_forest_t forest, * \param [in] face. A face number of \a elem. * \return The local tree id of the tree in which the face * neighbor of \a elem across \a face lies. - */ -t8_eclass_t t8_forest_element_neighbor_eclass (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t - *elem, int face); - + */ +t8_eclass_t t8_forest_element_neighbor_eclass (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t + *elem, int face); + /** Construct the face neighbor of an element, possibly across tree boundaries. * Returns the global tree-id of the tree in which the neighbor element lies in. * @@ -732,18 +732,19 @@ t8_eclass_t t8_forest_element_neighbor_eclass (t8_forest_t forest, * \param [out] neigh_face The number of the face viewed from perspective of \a neigh. * \return The global tree-id of the tree in which \a neigh is in. * -1 if there exists no neighbor across that face. - */ -t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *elem, - t8_element_t *neigh, - t8_eclass_scheme_c - *neigh_scheme, int face, - int *neigh_face); - -/* TODO: implement */ -void t8_forest_iterate (t8_forest_t forest); - + */ +t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t + *elem, + t8_element_t *neigh, + t8_eclass_scheme_c + *neigh_scheme, int face, + int *neigh_face); + +/* TODO: implement */ +void t8_forest_iterate (t8_forest_t forest); + /** Query whether a given point lies inside an element or not. For bilinearly interpolated elements. * \note For 2D quadrilateral elements this function is only an approximation. It is correct * if the four vertices lie in the same plane, but it may produce only approximate results if @@ -760,16 +761,16 @@ void t8_forest_iterate (t8_forest_t forest); * The return value is also true if the point lies on the element boundary. * Thus, this function may return true for different leaf elements, if they * are neighbors and the point lies on the common boundary. - */ -int t8_forest_element_point_inside (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t - *element, - const double point[3], - const double tolerance); - + */ +int t8_forest_element_point_inside (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t + *element, + const double point[3], + const double tolerance); + /* TODO: if set level and partition/adapt/balance all give NULL, then - * refine uniformly and partition/adapt/balance the unfiform forest. */ + * refine uniformly and partition/adapt/balance the unfiform forest. */ /** Build a uniformly refined forest on a coarse mesh. * \param [in] cmesh A coarse mesh. * \param [in] scheme An eclass scheme. @@ -780,12 +781,12 @@ int t8_forest_element_point_inside (t8_forest_t forest, * \a scheme and refinement level \a level. * \note This is equivalent to calling \ref t8_forest_init, \ref t8_forest_set_cmesh, * \ref t8_forest_set_scheme, \ref t8_forest_set_level, and \ref t8_forest_commit. - */ -t8_forest_t t8_forest_new_uniform (t8_cmesh_t cmesh, - t8_scheme_cxx_t *scheme, - int level, int do_face_ghost, - sc_MPI_Comm comm); - + */ +t8_forest_t t8_forest_new_uniform (t8_cmesh_t cmesh, + t8_scheme_cxx_t *scheme, + int level, int do_face_ghost, + sc_MPI_Comm comm); + /** Build a adapted forest from another forest. * \param [in] forest_from The forest to refine * \param [in] adapt_fn Adapt function to use @@ -796,19 +797,19 @@ t8_forest_t t8_forest_new_uniform (t8_cmesh_t cmesh, * \return A new forest that is adapted from \a forest_from. * \note This is equivalent to calling \ref t8_forest_init, \ref t8_forest_set_adapt, * \red t8_forest_set_ghost, and \ref t8_forest_commit - */ -/* TODO: make user_data const. */ -t8_forest_t t8_forest_new_adapt (t8_forest_t forest_from, - t8_forest_adapt_t adapt_fn, - int recursive, int do_face_ghost, - void *user_data); - + */ +/* TODO: make user_data const. */ +t8_forest_t t8_forest_new_adapt (t8_forest_t forest_from, + t8_forest_adapt_t adapt_fn, + int recursive, int do_face_ghost, + void *user_data); + /** Increase the reference counter of a forest. * \param [in,out] forest On input, this forest must exist with positive * reference count. It may be in any state. - */ -void t8_forest_ref (t8_forest_t forest); - + */ +void t8_forest_ref (t8_forest_t forest); + /** Decrease the reference counter of a forest. * If the counter reaches zero, this forest is destroyed. * In this case, the forest dereferences its cmesh and scheme members. @@ -819,9 +820,8 @@ void t8_forest_ref (t8_forest_t forest); * set to NULL. * Otherwise, the pointer is not changed and * the forest is not modified in other ways. - */ -void t8_forest_unref (t8_forest_t *pforest); - -T8_EXTERN_C_END (); - -#endif /* !T8_FOREST_GENERAL_H */ + */ +void t8_forest_unref (t8_forest_t *pforest); + T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_GENERAL_H */ diff --git a/src/t8_forest/t8_forest_geometrical.h b/src/t8_forest/t8_forest_geometrical.h index 29d3a4f434..b98e6af5d8 100644 --- a/src/t8_forest/t8_forest_geometrical.h +++ b/src/t8_forest/t8_forest_geometrical.h @@ -18,22 +18,21 @@ You should have received a copy of the GNU General Public License along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - +*/ + /** \file t8_forest_geometrical.h * We define the geometrical queries for a forest of trees in this file. - */ - -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ - + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + #ifndef T8_FOREST_GEOMETRICAL_H #define T8_FOREST_GEOMETRICAL_H - + #include #include - -T8_EXTERN_C_BEGIN (); - + T8_EXTERN_C_BEGIN (); + /** Compute the coordinates of a given vertex of an element if a geometry * for this tree is registered in the forest's cmesh. * \param [in] forest The forest. @@ -42,13 +41,14 @@ T8_EXTERN_C_BEGIN (); * \param [in] corner_number The corner number, in Z-order, of the vertex which should be computed. * \param [out] coordinates On input an allocated array to store 3 doubles, on output * the x, y and z coordinates of the vertex. - */ -void t8_forest_element_coordinate (t8_forest_t forest, - t8_locidx_t ltree_id, - const t8_element_t *element, - int corner_number, - double *coordinates); - + */ +void t8_forest_element_coordinate (t8_forest_t forest, + t8_locidx_t ltree_id, + const t8_element_t + *element, + int corner_number, + double *coordinates); + /** Compute the coordinates of the centroid of an element if a geometry * for this tree is registered in the forest's cmesh. * The centroid is the sum of all corner vertices divided by the number of corners. @@ -59,12 +59,12 @@ void t8_forest_element_coordinate (t8_forest_t forest, * \param [in] element The element. * \param [out] coordinates On input an allocated array to store 3 doubles, on output * the x, y and z coordinates of the centroid. - */ -void t8_forest_element_centroid (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *element, - double *coordinates); - + */ +void t8_forest_element_centroid (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t *element, + double *coordinates); + /** Compute the diameter of an element if a geometry * for this tree is registered in the forest's cmesh. * This is only an approximation. @@ -74,11 +74,11 @@ void t8_forest_element_centroid (t8_forest_t forest, * \return The diameter of the element. * \note For lines the value is exact while for other element types it is only * an approximation. - */ -double t8_forest_element_diam (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *element); - + */ +double t8_forest_element_diam (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t *element); + /** Compute the volume of an element if a geometry * for this tree is registered in the forest's cmesh. * This is only an approximation. @@ -89,11 +89,11 @@ double t8_forest_element_diam (t8_forest_t forest, * \note This function assumes d-linear interpolation for the * tree vertex coordinates. * \a forest must be committed when calling this function. - */ -double t8_forest_element_volume (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *element); - + */ +double t8_forest_element_volume (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t *element); + /** Compute the area of an element's face if a geometry * for this tree is registered in the forest's cmesh. * Currently implemented for 2D elements only. @@ -104,12 +104,12 @@ double t8_forest_element_volume (t8_forest_t forest, * \param [in] face A face of \a element. * \return The area of \a face. * \a forest must be committed when calling this function. - */ -double t8_forest_element_face_area (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *element, - int face); - + */ +double t8_forest_element_face_area (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t *element, + int face); + /** Compute the vertex coordinates of the centroid of an element's face if a geometry * for this tree is registered in the forest's cmesh. * \param [in] forest The forest. @@ -118,13 +118,13 @@ double t8_forest_element_face_area (t8_forest_t forest, * \param [in] face A face of \a element. * \param [out] normal On output the centroid of \a face. * \a forest must be committed when calling this function. - */ -void t8_forest_element_face_centroid (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t - *element, int face, - double centroid[3]); - + */ +void t8_forest_element_face_centroid (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t + *element, int face, + double centroid[3]); + /** Compute the normal vector of an element's face if a geometry * for this tree is registered in the forest's cmesh. * Currently implemented for 2D elements only. @@ -134,13 +134,12 @@ void t8_forest_element_face_centroid (t8_forest_t forest, * \param [in] face A face of \a element. * \param [out] normal On output the normal vector of \a element at \a face. * \a forest must be committed when calling this function. - */ -void t8_forest_element_face_normal (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t - *element, int face, - double normal[3]); - -T8_EXTERN_C_END (); - -#endif /* !T8_FOREST_GEOMETRICAL_H */ + */ +void t8_forest_element_face_normal (t8_forest_t forest, + t8_locidx_t ltreeid, + const t8_element_t + *element, int face, + double normal[3]); + T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_GEOMETRICAL_H */ diff --git a/src/t8_forest/t8_forest_io.h b/src/t8_forest/t8_forest_io.h index c14708f5d3..4a86ce87dd 100644 --- a/src/t8_forest/t8_forest_io.h +++ b/src/t8_forest/t8_forest_io.h @@ -18,26 +18,25 @@ You should have received a copy of the GNU General Public License along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - +*/ + /** \file t8_forest_general.h * We define the forest of trees in this file. - */ - -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ - + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + #ifndef T8_FOREST_IO_H #define T8_FOREST_IO_H - -/*TODO: Check if all headers are needed */ + +/*TODO: Check if all headers are needed */ #include #include - -T8_EXTERN_C_BEGIN (); - -/* TODO: implement */ -void t8_forest_save (t8_forest_t forest); - + T8_EXTERN_C_BEGIN (); + +/* TODO: implement */ +void t8_forest_save (t8_forest_t forest); + /** Write the forest in a parallel vtu format. Extended version. * See \ref t8_forest_write_vtk for the standard version of this function. * Writes one master .pvtu file and each process writes in its own .vtu file. @@ -71,19 +70,19 @@ void t8_forest_save (t8_forest_t forest); * must come first in the array. * \return True if successful, false if not (process local). * See also \ref t8_forest_write_vtk . - */ -int t8_forest_write_vtk_ext (t8_forest_t forest, - const char *fileprefix, - int write_treeid, - int write_mpirank, - int write_level, - int write_element_id, - int write_ghosts, - int write_curved, - int do_not_use_API, - int num_data, - t8_vtk_data_field_t *data); - + */ +int t8_forest_write_vtk_ext (t8_forest_t forest, + const char *fileprefix, + int write_treeid, + int write_mpirank, + int write_level, + int write_element_id, + int write_ghosts, + int write_curved, + int do_not_use_API, + int num_data, + t8_vtk_data_field_t *data); + /** Write the forest in a parallel vtu format. Writes one master * .pvtu file and each process writes in its own .vtu file. * If linked, the VTK API is used. @@ -98,10 +97,9 @@ int t8_forest_write_vtk_ext (t8_forest_t forest, * and the process with rank r writes in the file * fileprefix_r.vtu. * \return True if successful, false if not (process local). - */ -int t8_forest_write_vtk (t8_forest_t forest, - const char *fileprefix); - -T8_EXTERN_C_END (); - -#endif /* !T8_FOREST_IO_H */ \ No newline at end of file + */ +int t8_forest_write_vtk (t8_forest_t forest, + const char *fileprefix); + T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_IO_H */ diff --git a/src/t8_forest/t8_forest_profiling.h b/src/t8_forest/t8_forest_profiling.h index 9d3e273bb8..03915d6f89 100644 --- a/src/t8_forest/t8_forest_profiling.h +++ b/src/t8_forest/t8_forest_profiling.h @@ -18,23 +18,22 @@ You should have received a copy of the GNU General Public License along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - +*/ + /** \file t8_forest_profiling.h * We define the forest of trees in this file. - */ - -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ - + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + #ifndef T8_FOREST_PROFILING_H #define T8_FOREST_PROFILING_H - -/*TODO: Check if all headers are needed */ + +/*TODO: Check if all headers are needed */ #include #include - -T8_EXTERN_C_BEGIN (); - + T8_EXTERN_C_BEGIN (); + /** Enable or disable profiling for a forest. If profiling is enabled, runtimes * and statistics are collected during forest_commit. * \param [in,out] forest The forest to be updated. @@ -44,35 +43,33 @@ T8_EXTERN_C_BEGIN (); * Profiling is disabled by default. * The forest must not be committed before calling this function. * \see t8_forest_print_profile - */ -void t8_forest_set_profiling (t8_forest_t forest, - int set_profiling); - -/* TODO: document */ -void t8_forest_compute_profile (t8_forest_t forest); - -const sc_statinfo_t *t8_forest_profile_get_adapt_stats (t8_forest_t forest); - -const sc_statinfo_t *t8_forest_profile_get_ghost_stats (t8_forest_t forest); - -const sc_statinfo_t *t8_forest_profile_get_partition_stats (t8_forest_t - forest); - -const sc_statinfo_t *t8_forest_profile_get_commit_stats (t8_forest_t forest); - -const sc_statinfo_t *t8_forest_profile_get_balance_stats (t8_forest_t forest); - -const sc_statinfo_t *t8_forest_profile_get_balance_rounds_stats (t8_forest_t - forest); - + */ +void t8_forest_set_profiling (t8_forest_t forest, + int set_profiling); + +/* TODO: document */ +void t8_forest_compute_profile (t8_forest_t forest); + const sc_statinfo_t *t8_forest_profile_get_adapt_stats (t8_forest_t + forest); + const sc_statinfo_t *t8_forest_profile_get_ghost_stats (t8_forest_t + forest); + const sc_statinfo_t *t8_forest_profile_get_partition_stats (t8_forest_t + forest); + const sc_statinfo_t *t8_forest_profile_get_commit_stats (t8_forest_t + forest); + const sc_statinfo_t *t8_forest_profile_get_balance_stats (t8_forest_t + forest); + const sc_statinfo_t + * t8_forest_profile_get_balance_rounds_stats (t8_forest_t forest); + /** Print the collected statistics from a forest profile. * \param [in] forest The forest. * * \a forest must be committed before calling this function. * \see t8_forest_set_profiling - */ -void t8_forest_print_profile (t8_forest_t forest); - + */ +void t8_forest_print_profile (t8_forest_t forest); + /** Get the runtime of the last call to \ref t8_forest_adapt. * \param [in] forest The forest. * \return The runtime of adapt if profiling was activated. @@ -80,9 +77,9 @@ void t8_forest_print_profile (t8_forest_t forest); * \a forest must be committed before calling this function. * \see t8_forest_set_profiling * \see t8_forest_set_adapt - */ -double t8_forest_profile_get_adapt_time (t8_forest_t forest); - + */ +double t8_forest_profile_get_adapt_time (t8_forest_t forest); + /** Get the runtime of the last call to \ref t8_forest_partition. * \param [in] forest The forest. * \param [out] procs_sent On output the number of processes that this rank @@ -93,10 +90,10 @@ double t8_forest_profile_get_adapt_time (t8_forest_t forest); * \a forest must be committed before calling this function. * \see t8_forest_set_profiling * \see t8_forest_set_partition - */ -double t8_forest_profile_get_partition_time (t8_forest_t forest, - int *procs_sent); - + */ +double t8_forest_profile_get_partition_time (t8_forest_t forest, + int *procs_sent); + /** Get the runtime of the last call to \ref t8_forest_balance. * \param [in] forest The forest. * \param [out] balance_rounts On output the number of rounds in balance @@ -106,10 +103,10 @@ double t8_forest_profile_get_partition_time (t8_forest_t forest, * \a forest must be committed before calling this function. * \see t8_forest_set_profiling * \see t8_forest_set_balance - */ -double t8_forest_profile_get_balance_time (t8_forest_t forest, - int *balance_rounds); - + */ +double t8_forest_profile_get_balance_time (t8_forest_t forest, + int *balance_rounds); + /** Get the runtime of the last call to \ref t8_forest_create_ghosts. * \param [in] forest The forest. * \param [out] ghosts_sent On output the number of ghost elements sent to other processes @@ -119,11 +116,11 @@ double t8_forest_profile_get_balance_time (t8_forest_t forest, * \a forest must be committed before calling this function. * \see t8_forest_set_profiling * \see t8_forest_set_ghost - */ -double t8_forest_profile_get_ghost_time (t8_forest_t forest, - t8_locidx_t - *ghosts_sent); - + */ +double t8_forest_profile_get_ghost_time (t8_forest_t forest, + t8_locidx_t + *ghosts_sent); + /** Get the waittime of the last call to \ref t8_forest_ghost_exchange_data. * \param [in] forest The forest. * \return The time of ghost_exchange_data that was spent waiting @@ -132,10 +129,9 @@ double t8_forest_profile_get_ghost_time (t8_forest_t forest, * \a forest must be committed before calling this function. * \see t8_forest_set_profiling * \see t8_forest_ghost_exchange_data - */ -double t8_forest_profile_get_ghostexchange_waittime (t8_forest_t - forest); - -T8_EXTERN_C_END (); - -#endif /* !T8_FOREST_PROFILING_H */ + */ +double t8_forest_profile_get_ghostexchange_waittime (t8_forest_t + forest); + T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_PROFILING_H */ diff --git a/tutorials/features/t8_features_curved_meshes.cxx b/tutorials/features/t8_features_curved_meshes.cxx index 31ea2ee9b5..19157e09ea 100644 --- a/tutorials/features/t8_features_curved_meshes.cxx +++ b/tutorials/features/t8_features_curved_meshes.cxx @@ -38,9 +38,9 @@ #include /* General t8code header, always include this. */ #include /* CLI parser */ #include /* cmesh definition and basic interface. */ -#include /* forest definition and basic interface. */ -#include /* save forest */ -#include /* geometrical information of the tree */ +#include /* forest definition and basic interface. */ +#include /* save forest */ +#include /* geometrical information of the tree */ #include /* default refinement scheme. */ #include /* Linear geometry calculation of trees */ #include /* Curved geometry calculation of trees */ diff --git a/tutorials/general/t8_step2_uniform_forest.cxx b/tutorials/general/t8_step2_uniform_forest.cxx index 6c7e55fbce..67f2a634f0 100644 --- a/tutorials/general/t8_step2_uniform_forest.cxx +++ b/tutorials/general/t8_step2_uniform_forest.cxx @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include diff --git a/tutorials/general/t8_step3.h b/tutorials/general/t8_step3.h index a514ddc5ac..7590dc1730 100644 --- a/tutorials/general/t8_step3.h +++ b/tutorials/general/t8_step3.h @@ -32,7 +32,7 @@ #define T8_STEP3_H #include /* General t8code header, always include this. */ -#include /* forest definition and basic interface. */ +#include /* forest definition and basic interface. */ T8_EXTERN_C_BEGIN (); diff --git a/tutorials/general/t8_step3_adapt_forest.cxx b/tutorials/general/t8_step3_adapt_forest.cxx index 5a6442923a..892bb528c4 100644 --- a/tutorials/general/t8_step3_adapt_forest.cxx +++ b/tutorials/general/t8_step3_adapt_forest.cxx @@ -52,8 +52,8 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ -#include /* save forest */ +#include /* forest definition and basic interface. */ +#include /* save forest */ #include #include /* default refinement scheme. */ #include /* Basic operations on 3D vectors. */ diff --git a/tutorials/general/t8_step4_partition_balance_ghost.cxx b/tutorials/general/t8_step4_partition_balance_ghost.cxx index aa8f307835..4e7b3a6b81 100644 --- a/tutorials/general/t8_step4_partition_balance_ghost.cxx +++ b/tutorials/general/t8_step4_partition_balance_ghost.cxx @@ -88,8 +88,8 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ -#include /* save forest */ +#include /* forest definition and basic interface. */ +#include /* save forest */ #include /* default refinement scheme. */ #include diff --git a/tutorials/general/t8_step5_element_data.cxx b/tutorials/general/t8_step5_element_data.cxx index bac6afd79f..025fd78c30 100644 --- a/tutorials/general/t8_step5_element_data.cxx +++ b/tutorials/general/t8_step5_element_data.cxx @@ -45,9 +45,9 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ -#include /* save forest */ -#include /* geometrical information */ +#include /* forest definition and basic interface. */ +#include /* save forest */ +#include /* geometrical information */ #include /* default refinement scheme. */ #include diff --git a/tutorials/general/t8_step5_element_data_c_interface.c b/tutorials/general/t8_step5_element_data_c_interface.c index 48d12e1a36..770f5cad87 100644 --- a/tutorials/general/t8_step5_element_data_c_interface.c +++ b/tutorials/general/t8_step5_element_data_c_interface.c @@ -46,10 +46,10 @@ #include /* sc library. */ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ -#include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ -#include -#include /* save forest */ +#include /* A collection of exemplary cmeshes. */ +#include /* forest definition and basic interface. */ +#include /* geometrical information of a forest. */ +#include /* save forest. */ #include /* default refinement scheme. */ #include /* default refinement scheme. */ #include diff --git a/tutorials/general/t8_step6_stencil.cxx b/tutorials/general/t8_step6_stencil.cxx index d609e29555..941bbe1aac 100644 --- a/tutorials/general/t8_step6_stencil.cxx +++ b/tutorials/general/t8_step6_stencil.cxx @@ -42,9 +42,9 @@ #include /* General t8code header, always include this. */ #include /* Basic operations on 3D vectors. */ #include /* cmesh definition and basic interface. */ -#include /* forest definition and basic interface. */ -#include /* save forest */ -#include /* geometrical information */ +#include /* forest definition and basic interface. */ +#include /* save forest */ +#include /* geometrical information */ #include /* A collection of exemplary cmeshes */ #include /* default refinement scheme. */ #include diff --git a/tutorials/general/t8_tutorial_search.cxx b/tutorials/general/t8_tutorial_search.cxx index 4b2603feca..1f0d99cc7c 100644 --- a/tutorials/general/t8_tutorial_search.cxx +++ b/tutorials/general/t8_tutorial_search.cxx @@ -110,8 +110,8 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ -#include /* save forest */ +#include /* forest definition and basic interface. */ +#include /* save forest */ #include /* default refinement scheme. */ #include /* Basic operations on 3D vectors. */ #include /* For the search algorithm. */ From 2c81f1ab05006cd83865e8614fde5e05619408bc Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Fri, 14 Apr 2023 12:08:22 +0200 Subject: [PATCH 099/255] Searched for all functions in the headers and add the missing header include files --- src/t8_forest/t8_forest.c | 1 + src/t8_forest/t8_forest_profiling.h | 27 ++++++++++--------- src/t8_forest/t8_forest_vtk.cxx | 2 ++ .../features/t8_features_curved_meshes.cxx | 2 +- tutorials/general/t8_step3_adapt_forest.cxx | 2 +- tutorials/general/t8_step6_stencil.cxx | 2 +- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/t8_forest/t8_forest.c b/src/t8_forest/t8_forest.c index 63ff7da523..74efcdcaf7 100644 --- a/src/t8_forest/t8_forest.c +++ b/src/t8_forest/t8_forest.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/src/t8_forest/t8_forest_profiling.h b/src/t8_forest/t8_forest_profiling.h index 03915d6f89..6a6950bf17 100644 --- a/src/t8_forest/t8_forest_profiling.h +++ b/src/t8_forest/t8_forest_profiling.h @@ -45,22 +45,22 @@ * \see t8_forest_print_profile */ void t8_forest_set_profiling (t8_forest_t forest, - int set_profiling); + int set_profiling); /* TODO: document */ void t8_forest_compute_profile (t8_forest_t forest); const sc_statinfo_t *t8_forest_profile_get_adapt_stats (t8_forest_t - forest); + forest); const sc_statinfo_t *t8_forest_profile_get_ghost_stats (t8_forest_t - forest); + forest); const sc_statinfo_t *t8_forest_profile_get_partition_stats (t8_forest_t - forest); + forest); const sc_statinfo_t *t8_forest_profile_get_commit_stats (t8_forest_t - forest); + forest); const sc_statinfo_t *t8_forest_profile_get_balance_stats (t8_forest_t - forest); - const sc_statinfo_t - * t8_forest_profile_get_balance_rounds_stats (t8_forest_t forest); + forest); + const sc_statinfo_t + *t8_forest_profile_get_balance_rounds_stats (t8_forest_t forest); /** Print the collected statistics from a forest profile. * \param [in] forest The forest. @@ -92,7 +92,7 @@ double t8_forest_profile_get_adapt_time (t8_forest_t forest); * \see t8_forest_set_partition */ double t8_forest_profile_get_partition_time (t8_forest_t forest, - int *procs_sent); + int *procs_sent); /** Get the runtime of the last call to \ref t8_forest_balance. * \param [in] forest The forest. @@ -105,7 +105,8 @@ double t8_forest_profile_get_partition_time (t8_forest_t forest, * \see t8_forest_set_balance */ double t8_forest_profile_get_balance_time (t8_forest_t forest, - int *balance_rounds); + int + *balance_rounds); /** Get the runtime of the last call to \ref t8_forest_create_ghosts. * \param [in] forest The forest. @@ -118,8 +119,8 @@ double t8_forest_profile_get_balance_time (t8_forest_t forest, * \see t8_forest_set_ghost */ double t8_forest_profile_get_ghost_time (t8_forest_t forest, - t8_locidx_t - *ghosts_sent); + t8_locidx_t + *ghosts_sent); /** Get the waittime of the last call to \ref t8_forest_ghost_exchange_data. * \param [in] forest The forest. @@ -131,7 +132,7 @@ double t8_forest_profile_get_ghost_time (t8_forest_t forest, * \see t8_forest_ghost_exchange_data */ double t8_forest_profile_get_ghostexchange_waittime (t8_forest_t - forest); + forest); T8_EXTERN_C_END (); #endif /* !T8_FOREST_PROFILING_H */ diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index d7782a0261..74279412af 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -57,6 +57,8 @@ #endif #include #include +#include +#include /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); diff --git a/tutorials/features/t8_features_curved_meshes.cxx b/tutorials/features/t8_features_curved_meshes.cxx index 19157e09ea..26e5d791d9 100644 --- a/tutorials/features/t8_features_curved_meshes.cxx +++ b/tutorials/features/t8_features_curved_meshes.cxx @@ -40,7 +40,7 @@ #include /* cmesh definition and basic interface. */ #include /* forest definition and basic interface. */ #include /* save forest */ -#include /* geometrical information of the tree */ +#include /* geometrical information of the forest */ #include /* default refinement scheme. */ #include /* Linear geometry calculation of trees */ #include /* Curved geometry calculation of trees */ diff --git a/tutorials/general/t8_step3_adapt_forest.cxx b/tutorials/general/t8_step3_adapt_forest.cxx index 892bb528c4..5f6abb1eaa 100644 --- a/tutorials/general/t8_step3_adapt_forest.cxx +++ b/tutorials/general/t8_step3_adapt_forest.cxx @@ -54,7 +54,7 @@ #include /* A collection of exemplary cmeshes */ #include /* forest definition and basic interface. */ #include /* save forest */ -#include +#include /* geometrical information of the forest */ #include /* default refinement scheme. */ #include /* Basic operations on 3D vectors. */ #include diff --git a/tutorials/general/t8_step6_stencil.cxx b/tutorials/general/t8_step6_stencil.cxx index 941bbe1aac..27be3533ab 100644 --- a/tutorials/general/t8_step6_stencil.cxx +++ b/tutorials/general/t8_step6_stencil.cxx @@ -44,7 +44,7 @@ #include /* cmesh definition and basic interface. */ #include /* forest definition and basic interface. */ #include /* save forest */ -#include /* geometrical information */ +#include /* geometrical information of the forest */ #include /* A collection of exemplary cmeshes */ #include /* default refinement scheme. */ #include From 93e33fb3e0965083e6b8d83a624ed180da924f1c Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Mon, 17 Apr 2023 17:23:10 +0200 Subject: [PATCH 100/255] fixed compiler error in debug mode --- src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c | 2 +- src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c | 2 +- src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c | 2 +- src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c | 1 + src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c index 9c814665b4..76c3000acf 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c +++ b/src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c @@ -354,7 +354,7 @@ t8_dline_compute_reference_coords (const t8_dline_t *elem, const double *ref_coords, double *out_coords) { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (t8_dline_is_valid (elem)); out_coords[0] = elem->x; out_coords[0] += T8_DLINE_LEN (elem->level) * ref_coords[0]; out_coords[0] /= (double) T8_DLINE_ROOT_LEN; diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c index 2b10119772..613579f57b 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c @@ -585,7 +585,7 @@ t8_dprism_compute_reference_coords (const t8_dprism_t *elem, const double *ref_coords, double *out_coords) { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (t8_dprism_is_valid (elem)); T8_ASSERT (elem->line.level == elem->tri.level); /*Compute x and y coordinate */ t8_dtri_compute_reference_coords (&elem->tri, ref_coords, out_coords); diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c index 2e817dde8b..67ac00bfed 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c @@ -1748,7 +1748,7 @@ t8_dpyramid_compute_reference_coords (const t8_dpyramid_t *elem, double *out_coords) { T8_ASSERT (ref_coords != NULL); - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (t8_dpyramid_is_valid (elem)); if (t8_dpyramid_shape (elem) == T8_ECLASS_PYRAMID) { const t8_dpyramid_coord_t length = T8_DPYRAMID_LEN (elem->pyramid.level); out_coords[0] = elem->pyramid.x; diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c index 8186997d41..d3eac86179 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c @@ -403,6 +403,7 @@ t8_dtri_compute_reference_coords (const t8_dtri_t *elem, * z--> x */ T8_ASSERT (ref_coords != NULL); + T8_ASSERT (t8_dtri_is_valid (elem)); t8_dtri_type_t type; t8_dtri_coord_t h; diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c index 3cc63d46eb..671ace7291 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c @@ -179,6 +179,7 @@ t8_dvertex_compute_reference_coords (const t8_dvertex_t *elem, double *out_coords) { T8_ASSERT (abs (ref_coords[0]) <= T8_PRECISION_EPS); + T8_ASSERT (t8_dvertex_is_valid (elem)); out_coords[0] = 0; } From 1bb7ed3051612853b3e11a5c9e436e174d1bbf15 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 18 Apr 2023 12:42:08 +0200 Subject: [PATCH 101/255] Update test/t8_IO/t8_gtest_vtk_reader.cxx Co-authored-by: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> --- test/t8_IO/t8_gtest_vtk_reader.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/t8_IO/t8_gtest_vtk_reader.cxx b/test/t8_IO/t8_gtest_vtk_reader.cxx index 1acf5579d8..cc384c2e4c 100644 --- a/test/t8_IO/t8_gtest_vtk_reader.cxx +++ b/test/t8_IO/t8_gtest_vtk_reader.cxx @@ -25,7 +25,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., /** * This is currently a place-holder for a propper cmesh_vtk_reader-test. - * The function is not implemented yet and therefore we do not provide a propper + * The function is not implemented yet and therefore we do not provide a proper * test yet. * */ From ab3d3ca8ed56dd35eef06073548d80714b77b01c Mon Sep 17 00:00:00 2001 From: ililikakis Date: Tue, 18 Apr 2023 16:17:03 +0200 Subject: [PATCH 102/255] added vtkDataSet to vtkPointSet --- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 80 +++++++++++++++++++++++++--- src/t8_cmesh_vtk_reader.hxx | 70 +++++++++++++++++------- 2 files changed, 123 insertions(+), 27 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index ff064bf521..e6e6348192 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -35,7 +35,11 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #if T8_WITH_VTK #include +#include #include +#include +#include +#include #include #include #include @@ -373,15 +377,43 @@ t8_vtkGrid_to_cmesh (vtkSmartPointer < vtkDataSet > vtkGrid, } return cmesh; } -#endif -t8_cmesh_t -t8_cmesh_vtk_reader (const char *filename, const int partition, - const int main_proc, sc_MPI_Comm comm, - const vtk_file_type_t vtk_file_type) +vtkSmartPointer < vtkPointSet > +t8_vtkGrid_to_vtkPointSet (vtkSmartPointer < vtkDataSet > vtkGrid) +{ + /* Set points */ + vtkSmartPointer < vtkPoints > points = vtkSmartPointer < vtkPoints >::New (); + const vtkIdType num_points = vtkGrid->GetNumberOfPoints (); + points->SetDataType (VTK_DOUBLE); + points->SetNumberOfPoints (num_points); + + for (vtkIdType ipoint = 0; ipoint < num_points; ipoint++) { + double vp[3]; + vtkGrid->GetPoint (ipoint, vp); + points->SetPoint (ipoint, vp); + } + points->Modified (); + T8_ASSERT (points->GetNumberOfPoints() == num_points); + vtkSmartPointer < vtkPointSet > cloud = + vtkSmartPointer < vtkPointSet >::New (); + cloud->SetPoints (points); + + /* Map cell data to point data */ + vtkSmartPointer < vtkCellDataToPointData > c2p = vtkCellDataToPointData::New (); + c2p->PassCellDataOff (); + c2p->SetInputData (vtkGrid); + c2p->Update (); + cloud->DeepCopy (c2p->GetOutput ()); + //cloud->DeepCopy (vtkPointSet::SafeDownCast (c2p->GetOutput ())); + + return cloud; +} + +vtkSmartPointer < vtkDataSet > +t8_vtk_reader (const char *filename, const int partition, + const int main_proc, sc_MPI_Comm comm, + const vtk_file_type_t vtk_file_type) { -#if T8_WITH_VTK - t8_cmesh_t cmesh; int mpisize; int mpirank; int mpiret; @@ -421,8 +453,40 @@ t8_cmesh_vtk_reader (const char *filename, const int partition, return NULL; } else { - cmesh = t8_vtkGrid_to_cmesh (vtkGrid, partition, main_proc, comm); + return vtkGrid; } +} +#endif + +vtkSmartPointer < vtkPointSet > +t8_pointSet_vtk_reader (const char *filename, + const int partition, + const int main_proc, + sc_MPI_Comm comm, + const vtk_file_type_t vtk_file_type) +{ +#if T8_WITH_VTK + vtkSmartPointer < vtkDataSet > vtkGrid = + t8_vtk_reader (filename, partition, main_proc, comm, vtk_file_type); + return t8_vtkGrid_to_vtkPointSet (vtkGrid); +#else + /* Return NULL if not linked against vtk */ + t8_global_errorf + ("WARNING: t8code is not linked against the vtk library. Without proper linking t8code cannot use the vtk-reader\n"); +#endif + return NULL; +} + +t8_cmesh_t +t8_cmesh_vtk_reader (const char *filename, const int partition, + const int main_proc, sc_MPI_Comm comm, + const vtk_file_type_t vtk_file_type) +{ +#if T8_WITH_VTK + vtkSmartPointer < vtkDataSet > vtkGrid = + t8_vtk_reader (filename, partition, main_proc, comm, vtk_file_type); + + t8_cmesh_t cmesh = t8_vtkGrid_to_cmesh (vtkGrid, partition, main_proc, comm); T8_ASSERT (cmesh != NULL); return cmesh; #else diff --git a/src/t8_cmesh_vtk_reader.hxx b/src/t8_cmesh_vtk_reader.hxx index 7996f63be5..42f08c0075 100644 --- a/src/t8_cmesh_vtk_reader.hxx +++ b/src/t8_cmesh_vtk_reader.hxx @@ -34,29 +34,12 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include +#include #endif T8_EXTERN_C_BEGIN (); #if T8_WITH_VTK -/** - * Read a vtk-file and ShallowCopy its content into a vtkDataSet. - * The success (or failure) of the reading process is communicated - * over all processes. - * - * \param[in] filename The name of the file to read - * \param[in, out] vtkGrid A pointer to a vtkDataSet. We ShallowCopy the grid there. - * \param[in] partition Flag if the input is read partitioned - * \param[in] main_proc The main reading proc. - * \param[in] comm A communicator. - * \param[in] vtk_file_type The type of the Data in the file. - * \return 0 if the file was read successfully, 1 otherwise. - */ -vtk_read_success_t t8_file_to_vtkGrid (const char *filename, - vtkSmartPointer < vtkDataSet > - vtkGrid, const int partition, - const int main_proc, sc_MPI_Comm comm, - const vtk_file_type_t vtk_file_type); /** * Given a pointer to a vtkDataSet a cmesh representing the vtkDataSet is @@ -73,12 +56,38 @@ t8_cmesh_t t8_vtkGrid_to_cmesh (vtkSmartPointer < vtkDataSet > const int main_proc, sc_MPI_Comm comm); +/** + * Given a pointer to a vtkDataSet a vtkPointSet storing a set of points of + * is constructed. The cell data of vtkDataSet is mapt on the points of vtkPointSet. + * + * \param[in] vtkGrid A pointer to a vtkDataSet + * \return A pointer to a vtkPointSet + */ +vtkSmartPointer < vtkPointSet > t8_vtkGrid_to_vtkPointSet (vtkSmartPointer < vtkDataSet > vtkGrid); + +/** + * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and + * construct a abstract class to specify dataset behavior. The file is read and + * stored in a vtkDataSet. + * \note This function is only available if t8code is linked against VTK. + * + * \param[in] filename The name of the file + * \param[in] partition Flag if the constructed mesh should be partitioned + * \param[in] main_proc The main reading processor + * \param[in] comm An mpi-communicator + * \param[in] vtk_file_type A vtk-filetype that is readable by t8code. + * \return Pointer to vtkDataSet + */ +vtkSmartPointer < vtkDataSet > t8_vtk_reader (const char *filename, const int partition, + const int main_proc, sc_MPI_Comm comm, + const vtk_file_type_t vtk_file_type); + #endif /** * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and * construct a cmesh. This is a two stage process. First the file is read and - * stored in a vtkDataSet using \a t8_file_to_vtkGrid. + * stored in a vtkDataSet using \a t8_vtk_reader and \a t8_file_to_vtkGrid. * In the second stage a cmesh is constructed from the vtkDataSet using \a t8_vtkGrid_to_cmesh. * * Both stages use the vtk-library, therefore the function is only available if @@ -98,6 +107,29 @@ t8_cmesh_t t8_cmesh_vtk_reader (const char *filename, sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type); +/** + * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and + * a set of points is constructed. This is a two stage process. First the file + * is read and stored in a vtkDataSet using \a t8_vtk_reader and + * \a t8_file_to_vtkGrid. In the second stage a vtkPointSet is constructed from + * the vtkDataSet using \a t8_vtkGrid_to_vtkPointSet. + * + * Both stages use the vtk-library, therefore the function is only available if + * t8code is linked against VTK. + * + * \param[in] filename The name of the file + * \param[in] partition Flag if the constructed mesh should be partitioned + * \param[in] main_proc The main reading processor + * \param[in] comm An mpi-communicator + * \param[in] vtk_file_type A vtk-filetype that is readable by t8code. + * \return Pointer to vtkDataSet + */ +vtkSmartPointer < vtkPointSet > t8_pointSet_vtk_reader (const char *filename, + const int partition, + const int main_proc, + sc_MPI_Comm comm, + const vtk_file_type_t vtk_file_type); + T8_EXTERN_C_END (); #endif /* T8_CMESH_VTK_READER */ From 3f53ab88ac373d6b08161dcf0d147d0222f20759 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Tue, 18 Apr 2023 16:24:12 +0200 Subject: [PATCH 103/255] removed not required includes --- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index e6e6348192..8ba628bab8 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -35,11 +35,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #if T8_WITH_VTK #include -#include #include #include -#include -#include #include #include #include From 28e688c7858332959ad52bf3ddb5f3fec0143c73 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Fri, 21 Apr 2023 12:20:05 +0200 Subject: [PATCH 104/255] Define files for step 8 tutorial --- tutorials/general/t8_step8.h | 39 ++++++++++++++ tutorials/general/t8_step8_main.cxx | 35 +++++++++++++ .../general/t8_step8_user_defined_mesh.cxx | 51 +++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 tutorials/general/t8_step8.h create mode 100644 tutorials/general/t8_step8_main.cxx create mode 100644 tutorials/general/t8_step8_user_defined_mesh.cxx diff --git a/tutorials/general/t8_step8.h b/tutorials/general/t8_step8.h new file mode 100644 index 0000000000..88552ec9a5 --- /dev/null +++ b/tutorials/general/t8_step8.h @@ -0,0 +1,39 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** file t8_step8.h + */ + +#ifndef T8_STEP8_H +#define T8_STEP8_H + +#include + +T8_EXTERN_C_BEGIN (); + +/** This is the main program of this example. + */ +int t8_step8_main (int argc, char **argv); + +T8_EXTERN_C_END (); + +#endif /* !T8_STEP8_H */ diff --git a/tutorials/general/t8_step8_main.cxx b/tutorials/general/t8_step8_main.cxx new file mode 100644 index 0000000000..7cdb98e232 --- /dev/null +++ b/tutorials/general/t8_step8_main.cxx @@ -0,0 +1,35 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element types in parallel. + + Copyright (C) 2023 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/* This file is part of the step6 example of t8code. + * Here, we only wrap the main function. See t8_step8_user_defined_mesh.cxx for the documentation of + * the step8 example. + */ + +#include + +int +main (int argc, char **argv) +{ + return t8_step8_main (argc, argv); +} + \ No newline at end of file diff --git a/tutorials/general/t8_step8_user_defined_mesh.cxx b/tutorials/general/t8_step8_user_defined_mesh.cxx new file mode 100644 index 0000000000..ae9d66eb01 --- /dev/null +++ b/tutorials/general/t8_step8_user_defined_mesh.cxx @@ -0,0 +1,51 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element types in parallel. + + Copyright (C) 2023 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/* See also: https://github.com/DLR-AMR/t8code/wiki/Step-6-Computing-stencils + * + * This is step8 of the t8code tutorials using the C++ interface of t8code. + * In the following we will create two user defined meshes. + * The first example is given by a periodic two dimensional mesh using linear + * geometry consisting of four triangles and and two quads. + * The second example is given by a non-periodic three dimensional mesh + * with linear geometry constructed using one tetrahedron, two prisms and one + * hexaedron. + * + * How you can experiment here: + * - Look at the paraview output files of the different meshes. + * - Change the element types of the mesh. + * - Change the face connections between the different elements. + * - Create an own mesh. + * */ + +#include /* General t8code header, always include this. */ +#include /* cmesh definition and basic interface. */ +#include /* forest definition and basic interface. */ +#include /* default refinement scheme. */ +#include /* write file in vtu file */ +#include /* linear geometry of the cmesh */ + +T8_EXTERN_C_BEGIN (); + + + +T8_EXTERN_C_END (); From 517e9b34d98ce71479c2eb60eee279c453017e28 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Fri, 21 Apr 2023 12:30:54 +0200 Subject: [PATCH 105/255] Mention tutorial in the makefile --- tutorials/Makefile.am | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tutorials/Makefile.am b/tutorials/Makefile.am index 1b4e799ba7..9b99def2ea 100644 --- a/tutorials/Makefile.am +++ b/tutorials/Makefile.am @@ -11,6 +11,7 @@ bin_PROGRAMS += \ tutorials/general/t8_step5_element_data \ tutorials/general/t8_step5_element_data_c_interface \ tutorials/general/t8_step6_stencil \ + tutorials/general/t8_step8_user_defined_mesh \ tutorials/general/t8_tutorial_search \ tutorials/features/t8_features_curved_meshes @@ -43,6 +44,9 @@ tutorials_general_t8_step6_stencil_SOURCES = \ tutorials/general/t8_step3_adapt_forest.cxx \ tutorials/general/t8_step6_stencil.cxx \ tutorials/general/t8_step6_main.cxx +tutorials_general_t8_step8_user_defined_mesh_SOURCES = \ + tutorials/general/t8_step8_user_defined_mesh.cxx \ + tutorials/general/t8_step8_main.cxx tutorials_general_t8_tutorial_search_SOURCES = \ tutorials/general/t8_tutorial_search.cxx \ tutorials/general/t8_step3_adapt_forest.cxx @@ -53,5 +57,6 @@ libt8_installed_headers += \ tutorials/general/t8_step3.h \ tutorials/general/t8_step4.h \ tutorials/general/t8_step5.h \ - tutorials/general/t8_step6.h + tutorials/general/t8_step6.h \ + tutorials/general/t8_step8.h From 9d2383e5ed09ae8e8390606d979ffd7acd5a29a3 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Fri, 21 Apr 2023 12:31:59 +0200 Subject: [PATCH 106/255] Add description of how to define a mesh --- .../general/t8_step8_user_defined_mesh.cxx | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/tutorials/general/t8_step8_user_defined_mesh.cxx b/tutorials/general/t8_step8_user_defined_mesh.cxx index ae9d66eb01..770b86130b 100644 --- a/tutorials/general/t8_step8_user_defined_mesh.cxx +++ b/tutorials/general/t8_step8_user_defined_mesh.cxx @@ -46,6 +46,83 @@ T8_EXTERN_C_BEGIN (); +/* Different steps of creating a cmesh + * 1. Defining an array with all vertices + * The vertices are ordered in a listing for each cell. + * Thus, there can be duplicates in the List. + * Example: double vertices[numberOfValues] = { + * //point values for cell 1 + * x_1,y_1,z_1 //(x,y,z) of first point of cell 1 + * x_2,y_2,z_2 //(x,y,z) of second point of cell 1 + * . + * . + * . + * x_n,y_n,z_n //(x,y,z) of nth point (last point) of cell 1 + * + * //point values for cell 2 + * x_1,y_1,z_1 //(x,y,z) of first point of cell 2 + * x_2,y_2,z_2 //(x,y,z) of second point of cell 2 + * . + * . + * . + * x_m,y_m,z_m //(x,y,z) of nth point (last point) of cell 2 + * + * . + * . + * . + * + * //point values for the last cell + * x_1,y_1,z_1 //(x,y,z) of first point of the last cell + * x_2,y_2,z_2 //(x,y,z) of second point of the last cell + * . + * . + * . + * x_o,y_o,z_o //(x,y,z) of nth point (last point) of the last cell + * }; + * + * 2. Initialization of the mesh + * Example: t8_cmesh_t cmesh; + * t8_cmesh_init (&cmesh); + * + * + * 3. Definition of the geometry + * t8_geometry_c *linear_geom = [defineTheGeometry]; + * + * 4. Defitition of the classes of the different trees - each tree is defined by one cell + * Example: //Class of the first tree + * t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_[TYPE]); + * //Class of the second tree + * t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_[TYPE]); + * . + * . + * . + * //Class of the last tree + * t8_cmesh_set_tree_class (cmesh, x, T8_ECLASS_[TYPE]); + * + * 5. Classification of the vertices for each tree + * // Vertices of the first tree + * t8_cmesh_set_tree_vertices (cmesh, 0, [pointerToVerticesOfTreeOne], [numberOfVerticesTreeOne]); + * // Vertices of the second tree + * t8_cmesh_set_tree_vertices (cmesh, 1, [pointerToVerticesOfTreeTwo] , [numberOfVerticesTreeTwo]); + * . + * . + * . + * // Vertices of the last tree + * t8_cmesh_set_tree_vertices (cmesh, x, [pointerToVerticesOfTree(x+1)] , [numberOfVerticesTree(x+1)]); + * + * 6. Definition of the face neighboors between the different trees + * // List of all face neighboor connections + * t8_cmesh_set_join (cmesh, [treeId1], [treeId2], [faceIdInTree1], [faceIdInTree2], [orientation]); + * t8_cmesh_set_join (cmesh, [treeId1], [treeId2], [faceIdInTree1], [faceIdInTree2], [orientation]); + * . + * . + * . + * t8_cmesh_set_join (cmesh, [treeId1], [treeId2], [faceIdInTree1], [faceIdInTree2], [orientation]); + * + * 7. Commit the mesh + * t8_cmesh_commit (cmesh, comm); + * */ + T8_EXTERN_C_END (); From 005ab81353f130561d247f61bc69f94ac6378beb Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Fri, 21 Apr 2023 12:32:39 +0200 Subject: [PATCH 107/255] Define 2d mesh --- .../general/t8_step8_user_defined_mesh.cxx | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/tutorials/general/t8_step8_user_defined_mesh.cxx b/tutorials/general/t8_step8_user_defined_mesh.cxx index 770b86130b..596a0eaee9 100644 --- a/tutorials/general/t8_step8_user_defined_mesh.cxx +++ b/tutorials/general/t8_step8_user_defined_mesh.cxx @@ -124,5 +124,97 @@ T8_EXTERN_C_BEGIN (); * */ +/* Definition of a two dimensional mesh with linear geometry and periodic boundaries. + * The mesh consists of four triangles and two quads. + * + * This is how the cmesh looks like. The numbers are the tree numbers: + * + * +---+---+ + * | |5 /| + * | 3 | / | + * | |/ 4| + * +---+---+ + * |1 /| | + * | / | 2 | + * |/0 | | + * +---+---+ + * */ +t8_cmesh_t +t8_cmesh_new_periodic_hybrid_2d (sc_MPI_Comm comm) +{ + + /* 1. Defining an array with all vertices */ + /* Just all vertices of all trees. partly duplicated */ + double vertices[60] = { + 0, 0, 0, /* tree 0, triangle */ + 0.5, 0, 0, + 0.5, 0.5, 0, + 0, 0, 0, /* tree 1, triangle */ + 0.5, 0.5, 0, + 0, 0.5, 0, + 0.5, 0, 0, /* tree 2, quad */ + 1, 0, 0, + 0.5, 0.5, 0, + 1, 0.5, 0, + 0, 0.5, 0, /* tree 3, quad */ + 0.5, 0.5, 0, + 0, 1, 0, + 0.5, 1, 0, + 0.5, 0.5, 0, /* tree 4, triangle */ + 1, 0.5, 0, + 1, 1, 0, + 0.5, 0.5, 0, /* tree 5, triangle */ + 1, 1, 0, + 0.5, 1, 0 + }; + + /* 2. Initialization of the mesh */ + t8_cmesh_t cmesh; + t8_cmesh_init (&cmesh); + + /* 3. Definition of the geometry */ + t8_geometry_c *linear_geom = t8_geometry_linear_new (2); + t8_cmesh_register_geometry (cmesh, linear_geom); /* Use linear geometry */ + + + /* 4. Defitition of the classes of the different trees */ + t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_TRIANGLE); + t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_TRIANGLE); + t8_cmesh_set_tree_class (cmesh, 2, T8_ECLASS_QUAD); + t8_cmesh_set_tree_class (cmesh, 3, T8_ECLASS_QUAD); + t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_TRIANGLE); + t8_cmesh_set_tree_class (cmesh, 5, T8_ECLASS_TRIANGLE); + + /* 5. Classification of the vertices for each tree */ + t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 3); + t8_cmesh_set_tree_vertices (cmesh, 1, vertices + 9, 3); + t8_cmesh_set_tree_vertices (cmesh, 2, vertices + 18, 4); + t8_cmesh_set_tree_vertices (cmesh, 3, vertices + 30, 4); + t8_cmesh_set_tree_vertices (cmesh, 4, vertices + 42, 3); + t8_cmesh_set_tree_vertices (cmesh, 5, vertices + 51, 3); + + /* 6. Definition of the face neighboors between the different trees */ + t8_cmesh_set_join (cmesh, 0, 1, 1, 2, 0); + t8_cmesh_set_join (cmesh, 0, 2, 0, 0, 0); + t8_cmesh_set_join (cmesh, 0, 3, 2, 3, 0); + + t8_cmesh_set_join (cmesh, 1, 3, 0, 2, 1); + t8_cmesh_set_join (cmesh, 1, 2, 1, 1, 0); + + t8_cmesh_set_join (cmesh, 2, 4, 3, 2, 0); + t8_cmesh_set_join (cmesh, 2, 5, 2, 0, 1); + + t8_cmesh_set_join (cmesh, 3, 5, 1, 1, 0); + t8_cmesh_set_join (cmesh, 3, 4, 0, 0, 0); + + t8_cmesh_set_join (cmesh, 4, 5, 1, 2, 0); + + /* 7. Commit the mesh */ + t8_cmesh_commit (cmesh, comm); + + return cmesh; +} + + T8_EXTERN_C_END (); From ad84badb5358f29b9e51c40b0f0f148395d689c5 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Fri, 21 Apr 2023 12:34:00 +0200 Subject: [PATCH 108/255] Add description of 3d mesh sheme --- .../general/t8_step8_user_defined_mesh.cxx | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/tutorials/general/t8_step8_user_defined_mesh.cxx b/tutorials/general/t8_step8_user_defined_mesh.cxx index 596a0eaee9..9ab385a974 100644 --- a/tutorials/general/t8_step8_user_defined_mesh.cxx +++ b/tutorials/general/t8_step8_user_defined_mesh.cxx @@ -215,6 +215,84 @@ t8_cmesh_new_periodic_hybrid_2d (sc_MPI_Comm comm) return cmesh; } +/* Definition of a three dimensional mesh with linear geometry. + * The mesh consists of two tetrahedra, two prisms and one hexahedron. + * */ +t8_cmesh_t +t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) +{ + /* Definition of the mesh according to the above scheme + * // 1. Defining an array with all vertices + * double vertices[ ] = + * { + * 0.43, 0, 2, // Tetrahedron 1 vertices + 0, 0, 1, + 0.86, -0.5, 1, + 0.86, 0.5, 1, + + 2.29, 0, 2, // Tetrahedron 2 vertices + 1.86, -0.5, 1, + 2.72, 0, 1, + 1.86, 0.5, 1, + 0, 0, 0, // Prism 1 vertices + 0.86, -0.5, 0, + 0.86, 0.5, 0, + 0, 0, 1, + 0.86, -0.5, 1, + 0.86, 0.5, 1, + + 1.86, -0.5, 0, // Prism 2 vertices + 2.72, 0, 0, + 1.86, 0.5, 0, + 1.86, -0.5, 1, + 2.72, 0, 1, + 1.86, 0.5, 1, + + 0.86, -0.5, 0, // Hex coordinates + 1.86, -0.5, 0, + 0.86, 0.5, 0, + 1.86, 0.5, 0, + 0.86, -0.5, 1, + 1.86, -0.5, 1, + 0.86, 0.5, 1, + 1.86, 0.5, 1 + * } + * // 2. Initialization of the mesh + * t8_cmesh_t cmesh; + * t8_cmesh_init (&cmesh); + * + * // 3. Definition of the geometry + * t8_geometry_c *linear_geom = t8_geometry_linear_new (3); + * t8_cmesh_register_geometry (cmesh, linear_geom); // Use linear geometry + * + * // 4. Defitition of the classes of the different trees + * t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_TET); + * t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_TET); + * t8_cmesh_set_tree_class (cmesh, 2, T8_ECLASS_PRISM); + * t8_cmesh_set_tree_class (cmesh, 3, T8_ECLASS_PRISM); + * t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_HEX); + * + * // 5. Classification of the vertices for each tree + * t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 4); + * t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 4); + * t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 4); + * t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 4); + * t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 4); + * + * // 6. Definition of the face neighboors between the different trees + * t8_cmesh_set_join (cmesh, 0, 2, 0, 4, 0); + * t8_cmesh_set_join (cmesh, 1, 3, 0, 4, 0); + * t8_cmesh_set_join (cmesh, 2, 4, 0, 0, 0); + * t8_cmesh_set_join (cmesh, 3, 4, 1, 1, 0); + * + * // 7. Commit the mesh + * t8_cmesh_commit (cmesh, comm); + * + * return cmesh; + * */ + + +} T8_EXTERN_C_END (); From 75101aadbaf50c5561381d4d58ef3241c229b021 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Fri, 21 Apr 2023 12:34:24 +0200 Subject: [PATCH 109/255] Define 3d mesh --- .../general/t8_step8_user_defined_mesh.cxx | 158 +++++++++++++++++- 1 file changed, 157 insertions(+), 1 deletion(-) diff --git a/tutorials/general/t8_step8_user_defined_mesh.cxx b/tutorials/general/t8_step8_user_defined_mesh.cxx index 9ab385a974..6bb9f114e9 100644 --- a/tutorials/general/t8_step8_user_defined_mesh.cxx +++ b/tutorials/general/t8_step8_user_defined_mesh.cxx @@ -292,7 +292,163 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) * return cmesh; * */ - + /* In many cases the points of the different trees are dependent of these of the previous trees + * or of these of the same tree. Then it is reasonable to define the different vertices dependent + * of each other. + * Also the order of the sheme is not fixed. The definition of the face neighboors can be + * before the definition of the vertices. + * In the following example the tree classes are defined, then the face neighboors are set. + * After that the vertices are defined for each tree separate. + * */ + + double vertices[24]; + int i; + t8_geometry_c *linear_geom = t8_geometry_linear_new (3); + + /* Initialization of the mesh */ + t8_cmesh_t cmesh; + t8_cmesh_init (&cmesh); + + /* Definition of the geometry */ + t8_cmesh_register_geometry (cmesh, linear_geom); /* Use linear geometry */ + + /* Defitition of the classes of the different trees */ + t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_TET); + t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_TET); + t8_cmesh_set_tree_class (cmesh, 2, T8_ECLASS_PRISM); + t8_cmesh_set_tree_class (cmesh, 3, T8_ECLASS_PRISM); + t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_HEX); + + /* Classification of the vertices for each tree */ + t8_cmesh_set_join (cmesh, 0, 2, 0, 4, 0); + t8_cmesh_set_join (cmesh, 1, 3, 0, 4, 0); + t8_cmesh_set_join (cmesh, 2, 4, 0, 0, 0); + t8_cmesh_set_join (cmesh, 3, 4, 1, 1, 0); + + /* + * Definition of the first tree + */ + /* Tetrahedron 1 vertices */ + vertices[0] = 0.43; + vertices[1] = 0; + vertices[2] = 2; + + vertices[3] = 0; + vertices[4] = 0; + vertices[5] = 1; + + vertices[6] = 0.86; + vertices[7] = -0.5; + vertices[8] = 1; + + vertices[9] = 0.86; + vertices[10] = 0.5; + vertices[11] = 1; + + /* Classification of the vertices for the first tree */ + t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 4); + + /* + * Definition of the second tree + */ + /* Tetrahedron 2 vertices */ + for (i = 0; i < 3; i++) { + + vertices[i] = vertices[i] + (i == 0 ? 1 + 0.86 : 0); + vertices[3 + i] = vertices[6 + i] + (i == 0 ? 1 : 0); + vertices[9 + i] = vertices[9 + i] + (i == 0 ? 1 : 0); + } + + + vertices[6] = 1 + 2 * 0.86; + vertices[7] = 0; + vertices[8] = 1; + + /* Classification of the vertices for the second tree */ + t8_cmesh_set_tree_vertices (cmesh, 1, vertices, 4); + + /* + * Definition of the third tree + */ + /* Prism 1 vertices */ + vertices[0] = 0; + vertices[1] = 0; + vertices[2] = 0; + + vertices[3] = 0.86; + vertices[4] = -0.5; + vertices[5] = 0; + + vertices[6] = 0.86; + vertices[7] = 0.5; + vertices[8] = 0; + + /* Translate +1 in z-axis for the upper vertices */ + for (i = 0; i < 3; i++) { + vertices[9 + 3 * i] = vertices[3 * i]; + vertices[9 + 3 * i + 1] = vertices[3 * i + 1]; + vertices[9 + 3 * i + 2] = vertices[3 * i + 2] + 1; + } + + /* Classification of the vertices for the third tree */ + t8_cmesh_set_tree_vertices (cmesh, 2, vertices, 6); + + /* + * Definition of the fourth tree + */ + /* Prism 2 vertices */ + for (i = 0; i < 3; i++) { + vertices[3 + i] = vertices[i] + (i == 0 ? 1 + 2 * 0.86 : 0); + vertices[6 + i] = vertices[6 + i] + (i == 0 ? 1 : 0); + } + + vertices[0] = 0.86 + 1; + vertices[1] = -0.5; + vertices[2] = 0; + + /* Translate +1 in z-axis for the upper vertices */ + for (i = 0; i < 3; i++) { + vertices[9 + 3 * i] = vertices[3 * i]; + vertices[9 + 3 * i + 1] = vertices[3 * i + 1]; + vertices[9 + 3 * i + 2] = vertices[3 * i + 2] + 1; + } + + /* Classification of the vertices for the fourth tree */ + t8_cmesh_set_tree_vertices (cmesh, 3, vertices, 6); + + /* + * Definition of the fifth tree + */ + /* Hex coordinates */ + vertices[0] = 0.86; + vertices[1] = -0.5; + vertices[2] = 0; + + vertices[3] = 1.86; + vertices[4] = -0.5; + vertices[5] = 0; + + vertices[6] = 0.86; + vertices[7] = 0.5; + vertices[8] = 0; + + vertices[9] = 1.86; + vertices[10] = 0.5; + vertices[11] = 0; + + /* Translate +1 in z-axis for the upper vertices */ + for (i = 0; i < 4; i++) { + vertices[12 + 3 * i] = vertices[3 * i]; + vertices[12 + 3 * i + 1] = vertices[3 * i + 1]; + vertices[12 + 3 * i + 2] = vertices[3 * i + 2] + 1; + } + + /* Classification of the vertices for the fifth tree */ + t8_cmesh_set_tree_vertices (cmesh, 4, vertices, 8); + + /* Commit the mesh */ + t8_cmesh_commit (cmesh, comm); + return cmesh; } T8_EXTERN_C_END (); From 36d5a7510ca0cd1ab3246f2b366c1c1e14a8de83 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Fri, 21 Apr 2023 12:35:24 +0200 Subject: [PATCH 110/255] Add main definition --- .../general/t8_step8_user_defined_mesh.cxx | 59 ++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/tutorials/general/t8_step8_user_defined_mesh.cxx b/tutorials/general/t8_step8_user_defined_mesh.cxx index 6bb9f114e9..bcbca7c8d2 100644 --- a/tutorials/general/t8_step8_user_defined_mesh.cxx +++ b/tutorials/general/t8_step8_user_defined_mesh.cxx @@ -308,7 +308,7 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) /* Initialization of the mesh */ t8_cmesh_t cmesh; t8_cmesh_init (&cmesh); - + /* Definition of the geometry */ t8_cmesh_register_geometry (cmesh, linear_geom); /* Use linear geometry */ @@ -451,4 +451,61 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) return cmesh; } +int +t8_step8_main (int argc, char **argv) +{ + int mpiret; + sc_MPI_Comm comm; + t8_cmesh_t cmesh_2D; + t8_cmesh_t cmesh_3D; + + /* The prefix for our output files. */ + const char *prefix_2D = "t8_step8_user_defined_mesh_2D"; + const char *prefix_3D = "t8_step8_user_defined_mesh_3D"; + + /* The uniform refinement level of the forest. */ + const int level = 0; + + /* + * Initialization. + */ + + /* Initialize MPI. This has to happen before we initialize sc or t8code. */ + mpiret = sc_MPI_Init (&argc, &argv); + /* Error check the MPI return value. */ + SC_CHECK_MPI (mpiret); + + /* Initialize the sc library, has to happen before we initialize t8code. */ + sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_ESSENTIAL); + /* Initialize t8code with log level SC_LP_PRODUCTION. See sc.h for more info on the log levels. */ + t8_init (SC_LP_PRODUCTION); + + /* We will use MPI_COMM_WORLD as a communicator. */ + comm = sc_MPI_COMM_WORLD; + + + /* + * Definition of the meshes. + */ + /* Creation of a two dimensional cmesh with periodic boundaries. */ + cmesh_2D = t8_cmesh_new_periodic_hybrid_2d(comm); + + /* Creation of a three dimensional cmesh */ + cmesh_3D = t8_cmesh_new_hybrid_gate_3d(comm); + + /* Output the meshes to vtu files. */ + t8_cmesh_vtk_write_file(cmesh_2D, prefix_2D, 1.0); + t8_cmesh_vtk_write_file(cmesh_3D, prefix_3D, 1.0); + + /* + * Clean-up + */ + sc_finalize (); + + mpiret = sc_MPI_Finalize (); + SC_CHECK_MPI (mpiret); + + return 0; +} + T8_EXTERN_C_END (); From 8a2d75bb1125ce8eb8feb92f5b6cf26881e4f421 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Fri, 21 Apr 2023 13:05:29 +0200 Subject: [PATCH 111/255] Correct typo --- tutorials/general/t8_step8_user_defined_mesh.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tutorials/general/t8_step8_user_defined_mesh.cxx b/tutorials/general/t8_step8_user_defined_mesh.cxx index bcbca7c8d2..3625c1d20e 100644 --- a/tutorials/general/t8_step8_user_defined_mesh.cxx +++ b/tutorials/general/t8_step8_user_defined_mesh.cxx @@ -88,7 +88,7 @@ T8_EXTERN_C_BEGIN (); * 3. Definition of the geometry * t8_geometry_c *linear_geom = [defineTheGeometry]; * - * 4. Defitition of the classes of the different trees - each tree is defined by one cell + * 4. Definition of the classes of the different trees - each tree is defined by one cell * Example: //Class of the first tree * t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_[TYPE]); * //Class of the second tree @@ -177,7 +177,7 @@ t8_cmesh_new_periodic_hybrid_2d (sc_MPI_Comm comm) t8_cmesh_register_geometry (cmesh, linear_geom); /* Use linear geometry */ - /* 4. Defitition of the classes of the different trees */ + /* 4. Definition of the classes of the different trees */ t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_TRIANGLE); t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_TRIANGLE); t8_cmesh_set_tree_class (cmesh, 2, T8_ECLASS_QUAD); @@ -266,7 +266,7 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) * t8_geometry_c *linear_geom = t8_geometry_linear_new (3); * t8_cmesh_register_geometry (cmesh, linear_geom); // Use linear geometry * - * // 4. Defitition of the classes of the different trees + * // 4. Definition of the classes of the different trees * t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_TET); * t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_TET); * t8_cmesh_set_tree_class (cmesh, 2, T8_ECLASS_PRISM); @@ -308,7 +308,7 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) /* Initialization of the mesh */ t8_cmesh_t cmesh; t8_cmesh_init (&cmesh); - + /* Definition of the geometry */ t8_cmesh_register_geometry (cmesh, linear_geom); /* Use linear geometry */ From 7db210079b90808a6f6970f916a872f2aaffa4c6 Mon Sep 17 00:00:00 2001 From: Johannes Markert <10619309+jmark@users.noreply.github.com> Date: Mon, 24 Apr 2023 09:59:55 +0200 Subject: [PATCH 112/255] Update t8_default_common_cxx.hxx --- .../t8_default/t8_default_common/t8_default_common_cxx.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx b/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx index 538859b9e5..1f8c152f08 100644 --- a/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.hxx @@ -100,8 +100,8 @@ public: * elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and * L the maximum refinement level. * All element vertices have integer coordinates in this cube. - * \param [in] elem The element. - * \param [in] vertex The id of the vertex whose coordinates shall be computed. + * \param [in] elem The element. + * \param [in] vertex The id of the vertex whose coordinates shall be computed. * \param [out] coords An array of at least as many integers as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ From e144234152a4288af39fe7d8c44742c4ac16404a Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Mon, 24 Apr 2023 11:46:22 +0200 Subject: [PATCH 113/255] Add pyramid to 3d example --- .../general/t8_step8_user_defined_mesh.cxx | 53 ++++++++++++++----- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/tutorials/general/t8_step8_user_defined_mesh.cxx b/tutorials/general/t8_step8_user_defined_mesh.cxx index 3625c1d20e..cc664a9f26 100644 --- a/tutorials/general/t8_step8_user_defined_mesh.cxx +++ b/tutorials/general/t8_step8_user_defined_mesh.cxx @@ -196,10 +196,10 @@ t8_cmesh_new_periodic_hybrid_2d (sc_MPI_Comm comm) /* 6. Definition of the face neighboors between the different trees */ t8_cmesh_set_join (cmesh, 0, 1, 1, 2, 0); t8_cmesh_set_join (cmesh, 0, 2, 0, 0, 0); - t8_cmesh_set_join (cmesh, 0, 3, 2, 3, 0); + t8_cmesh_set_join (cmesh, 0, 3, 2, 3, 0); t8_cmesh_set_join (cmesh, 1, 3, 0, 2, 1); - t8_cmesh_set_join (cmesh, 1, 2, 1, 1, 0); + t8_cmesh_set_join (cmesh, 1, 2, 1, 1, 0); t8_cmesh_set_join (cmesh, 2, 4, 3, 2, 0); t8_cmesh_set_join (cmesh, 2, 5, 2, 0, 1); @@ -249,6 +249,12 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) 2.72, 0, 1, 1.86, 0.5, 1, + 0.86, -0.5, 0, // Pyramid coordinates + 1.86, -0.5, 0, + 0.86, 0.5, 0, + 1.86, 0.5, 0, + 1.29, 0, 0, + 0.86, -0.5, 0, // Hex coordinates 1.86, -0.5, 0, 0.86, 0.5, 0, @@ -257,6 +263,7 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) 1.86, -0.5, 1, 0.86, 0.5, 1, 1.86, 0.5, 1 + * } * // 2. Initialization of the mesh * t8_cmesh_t cmesh; @@ -271,20 +278,23 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) * t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_TET); * t8_cmesh_set_tree_class (cmesh, 2, T8_ECLASS_PRISM); * t8_cmesh_set_tree_class (cmesh, 3, T8_ECLASS_PRISM); + * t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_PYRAMID); * t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_HEX); * * // 5. Classification of the vertices for each tree - * t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 4); - * t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 4); - * t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 4); - * t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 4); - * t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 4); + * t8_cmesh_set_tree_vertices (cmesh, 0, vertices + 12, 4); + * t8_cmesh_set_tree_vertices (cmesh, 1, vertices + 24, 4); + * t8_cmesh_set_tree_vertices (cmesh, 2, vertices + 42, 6); + * t8_cmesh_set_tree_vertices (cmesh, 3, vertices + 60, 6); + * t8_cmesh_set_tree_vertices (cmesh, 4, vertices + 78, 5); + * t8_cmesh_set_tree_vertices (cmesh, 5, vertices + 93, 8); * * // 6. Definition of the face neighboors between the different trees * t8_cmesh_set_join (cmesh, 0, 2, 0, 4, 0); * t8_cmesh_set_join (cmesh, 1, 3, 0, 4, 0); - * t8_cmesh_set_join (cmesh, 2, 4, 0, 0, 0); - * t8_cmesh_set_join (cmesh, 3, 4, 1, 1, 0); + * t8_cmesh_set_join (cmesh, 2, 5, 0, 0, 0); + * t8_cmesh_set_join (cmesh, 3, 5, 1, 1, 0); + * t8_cmesh_set_join (cmesh, 4, 5, 4, 2, 0); * * // 7. Commit the mesh * t8_cmesh_commit (cmesh, comm); @@ -317,13 +327,15 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_TET); t8_cmesh_set_tree_class (cmesh, 2, T8_ECLASS_PRISM); t8_cmesh_set_tree_class (cmesh, 3, T8_ECLASS_PRISM); - t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_HEX); + t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_PYRAMID); + t8_cmesh_set_tree_class (cmesh, 5, T8_ECLASS_HEX); /* Classification of the vertices for each tree */ t8_cmesh_set_join (cmesh, 0, 2, 0, 4, 0); t8_cmesh_set_join (cmesh, 1, 3, 0, 4, 0); - t8_cmesh_set_join (cmesh, 2, 4, 0, 0, 0); - t8_cmesh_set_join (cmesh, 3, 4, 1, 1, 0); + t8_cmesh_set_join (cmesh, 2, 5, 0, 0, 0); + t8_cmesh_set_join (cmesh, 3, 5, 1, 1, 0); + t8_cmesh_set_join (cmesh, 4, 5, 4, 2, 0); /* * Definition of the first tree @@ -416,10 +428,12 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) /* Classification of the vertices for the fourth tree */ t8_cmesh_set_tree_vertices (cmesh, 3, vertices, 6); + /* * Definition of the fifth tree */ - /* Hex coordinates */ + /* Pyramid vertices */ + vertices[0] = 0.86; vertices[1] = -0.5; vertices[2] = 0; @@ -436,6 +450,17 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) vertices[10] = 0.5; vertices[11] = 0; + vertices[12] = 1.36; + vertices[13] = 0; + vertices[14] = -0.5; + + /* Classification of the vertices for the fifth tree */ + t8_cmesh_set_tree_vertices (cmesh, 4, vertices, 5); + + /* + * Definition of the sixth tree + */ + /* Hex coordinates */ /* Translate +1 in z-axis for the upper vertices */ for (i = 0; i < 4; i++) { vertices[12 + 3 * i] = vertices[3 * i]; @@ -444,7 +469,7 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) } /* Classification of the vertices for the fifth tree */ - t8_cmesh_set_tree_vertices (cmesh, 4, vertices, 8); + t8_cmesh_set_tree_vertices (cmesh, 5, vertices, 8); /* Commit the mesh */ t8_cmesh_commit (cmesh, comm); From 8576c3b0a8a78e91974092ae83f35e02238f82ca Mon Sep 17 00:00:00 2001 From: Ioannis Lilikakis <73935606+ililikakis@users.noreply.github.com> Date: Mon, 24 Apr 2023 16:19:10 +0200 Subject: [PATCH 114/255] Update CITATION.cff --- CITATION.cff | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index c3c92e9789..6922d56fb9 100755 --- a/CITATION.cff +++ b/CITATION.cff @@ -1,6 +1,6 @@ title: t8code -version: 1.1.0 -date-released: "2023-02-27" +version: 1.2.0 +date-released: "2023-04-24" repository-code: "https://github.com/dlr-amr/t8code" url: "https://dlr-amr.github.io/t8code/" doi: "10.5281/zenodo.7034838" @@ -54,6 +54,21 @@ authors: family-names: Becker email: F.Becker@dlr.de affiliation: "German Aerospace Center (DLR)" + - given-names: Jakob + family-names: Fußbroich + email: jakob.fussbroich@dlr.de + affiliation: "German Aerospace Center (DLR)" + orcid: "https://orcid.org/0000-0003-0784-2182" + - given-names: Chiara + family-names: Hergl + email: Chiara.Hergl@dlr.de + affiliation: "German Aerospace Center (DLR)" + orcid: "https://orcid.org/0000-0002-4016-9113" + - given-names: Schlottke-Lakemper + family-names: Michael + email: "m.schlottke-lakemper@acom.rwth-aachen.de" + affiliation: "RWTH Aachen" + orcid: "https://orcid.org/0000-0002-3195-2536" #Contributors cff-version: 1.2.0 message: >- From f60a6166cc99b3fdee4470e46fff23353ce35137 Mon Sep 17 00:00:00 2001 From: Ioannis Lilikakis <73935606+ililikakis@users.noreply.github.com> Date: Mon, 24 Apr 2023 16:23:26 +0200 Subject: [PATCH 115/255] Update t8_gtest_version.cxx --- test/t8_gtest_version.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/t8_gtest_version.cxx b/test/t8_gtest_version.cxx index e4edcf505a..16ea5259fa 100644 --- a/test/t8_gtest_version.cxx +++ b/test/t8_gtest_version.cxx @@ -27,7 +27,7 @@ /* The following three tests check whether t8code computes the correct * version. * The current version of t8code is - * 1.1.0 + * 1.2.0 * If you increase the major or minor version number, you need to adjust these tests and * this comment. */ @@ -42,7 +42,7 @@ TEST (t8_gtest_version, major_version) TEST (t8_gtest_version, minor_version) { /* Change this number when you increase the minor version. */ - const int minor_version = 1; + const int minor_version = 2; EXPECT_EQ (t8_get_version_minor (), minor_version); } From 7e1b245b5dae3f7bc33f8b8dfb5e1c00adc4dd48 Mon Sep 17 00:00:00 2001 From: Prasanna Ponnusamy <112905663+Prasanna-Ponnusamy@users.noreply.github.com> Date: Mon, 24 Apr 2023 16:40:40 +0200 Subject: [PATCH 116/255] Create author_ponnusamy.txt --- doc/author_ponnusamy.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/author_ponnusamy.txt diff --git a/doc/author_ponnusamy.txt b/doc/author_ponnusamy.txt new file mode 100644 index 0000000000..3462e88a0c --- /dev/null +++ b/doc/author_ponnusamy.txt @@ -0,0 +1 @@ +I place my contributions to t8code under the FreeBSD license. Prasanna Ponnusamy (prasanna.december17@gmail.com) From b6e6c43c98cf172028e1b7f642d9b292f1f42d54 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Mon, 24 Apr 2023 16:42:51 +0200 Subject: [PATCH 117/255] Update doc/author_ponnusamy.txt --- doc/author_ponnusamy.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/author_ponnusamy.txt b/doc/author_ponnusamy.txt index 3462e88a0c..fee95df155 100644 --- a/doc/author_ponnusamy.txt +++ b/doc/author_ponnusamy.txt @@ -1 +1 @@ -I place my contributions to t8code under the FreeBSD license. Prasanna Ponnusamy (prasanna.december17@gmail.com) +I place my contributions to t8code under the FreeBSD license. Prasanna Ponnusamy (Prasanna.Ponnusamy@dlr.de). From 2c7c80257eb1ac9bcbececad81736a83304ec86c Mon Sep 17 00:00:00 2001 From: Ioannis Lilikakis <73935606+ililikakis@users.noreply.github.com> Date: Mon, 24 Apr 2023 16:44:37 +0200 Subject: [PATCH 118/255] Update CITATION.cff --- CITATION.cff | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CITATION.cff b/CITATION.cff index 6922d56fb9..3707e13909 100755 --- a/CITATION.cff +++ b/CITATION.cff @@ -69,6 +69,11 @@ authors: email: "m.schlottke-lakemper@acom.rwth-aachen.de" affiliation: "RWTH Aachen" orcid: "https://orcid.org/0000-0002-3195-2536" + - given-names: Ponnusamy + family-names: Prasanna + email: "Prasanna.Prasanna@dlr.de" + affiliation: "German Aerospace Center (DLR)" + orcid: "https://orcid.org/0000-0002-4950-7297" #Contributors cff-version: 1.2.0 message: >- From 141d33ca662b9ea1f187358f51259f3767dde1db Mon Sep 17 00:00:00 2001 From: Ioannis Lilikakis <73935606+ililikakis@users.noreply.github.com> Date: Mon, 24 Apr 2023 16:46:35 +0200 Subject: [PATCH 119/255] Update CITATION.cff Co-authored-by: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> --- CITATION.cff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CITATION.cff b/CITATION.cff index 3707e13909..fc5db6c923 100755 --- a/CITATION.cff +++ b/CITATION.cff @@ -71,7 +71,7 @@ authors: orcid: "https://orcid.org/0000-0002-3195-2536" - given-names: Ponnusamy family-names: Prasanna - email: "Prasanna.Prasanna@dlr.de" + email: "Prasanna.Ponnusamy@dlr.de" affiliation: "German Aerospace Center (DLR)" orcid: "https://orcid.org/0000-0002-4950-7297" #Contributors From dee369a208c65b5298e4bc8f7b123587fc85a2b2 Mon Sep 17 00:00:00 2001 From: Ioannis Lilikakis <73935606+ililikakis@users.noreply.github.com> Date: Mon, 24 Apr 2023 16:51:25 +0200 Subject: [PATCH 120/255] Update CITATION.cff Co-authored-by: Johannes Holke --- CITATION.cff | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index fc5db6c923..9b2a2a37a6 100755 --- a/CITATION.cff +++ b/CITATION.cff @@ -69,8 +69,8 @@ authors: email: "m.schlottke-lakemper@acom.rwth-aachen.de" affiliation: "RWTH Aachen" orcid: "https://orcid.org/0000-0002-3195-2536" - - given-names: Ponnusamy - family-names: Prasanna + - given-names: Prasanna + family-names: Ponnusamy email: "Prasanna.Ponnusamy@dlr.de" affiliation: "German Aerospace Center (DLR)" orcid: "https://orcid.org/0000-0002-4950-7297" From cb5e8363f48f567e75169014f22681360ce198ee Mon Sep 17 00:00:00 2001 From: Ioannis Lilikakis <73935606+ililikakis@users.noreply.github.com> Date: Mon, 24 Apr 2023 16:53:09 +0200 Subject: [PATCH 121/255] Update CITATION.cff --- CITATION.cff | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 6922d56fb9..bd4702126d 100755 --- a/CITATION.cff +++ b/CITATION.cff @@ -64,8 +64,8 @@ authors: email: Chiara.Hergl@dlr.de affiliation: "German Aerospace Center (DLR)" orcid: "https://orcid.org/0000-0002-4016-9113" - - given-names: Schlottke-Lakemper - family-names: Michael + - given-names: Michael + family-names: Schlottke-Lakemper email: "m.schlottke-lakemper@acom.rwth-aachen.de" affiliation: "RWTH Aachen" orcid: "https://orcid.org/0000-0002-3195-2536" From 7ca4f471634deb74e314eb7cb930e757c7a30ae4 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Tue, 25 Apr 2023 07:18:52 +0200 Subject: [PATCH 122/255] Remove unused variable --- tutorials/general/t8_step8_user_defined_mesh.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/tutorials/general/t8_step8_user_defined_mesh.cxx b/tutorials/general/t8_step8_user_defined_mesh.cxx index cc664a9f26..7a08e769d9 100644 --- a/tutorials/general/t8_step8_user_defined_mesh.cxx +++ b/tutorials/general/t8_step8_user_defined_mesh.cxx @@ -488,9 +488,6 @@ t8_step8_main (int argc, char **argv) const char *prefix_2D = "t8_step8_user_defined_mesh_2D"; const char *prefix_3D = "t8_step8_user_defined_mesh_3D"; - /* The uniform refinement level of the forest. */ - const int level = 0; - /* * Initialization. */ From 39fc752f0cecef2a5393377f745e4a3ec8613a09 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Tue, 25 Apr 2023 07:42:10 +0200 Subject: [PATCH 123/255] Change name of tutorial --- tutorials/Makefile.am | 10 +++++----- ...er_defined_mesh.cxx => t8_tutorial_build_cmesh.cxx} | 1 - .../general/{t8_step8.h => t8_tutorial_build_cmesh.h} | 0 ...step8_main.cxx => t8_tutorial_build_cmesh_main.cxx} | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) rename tutorials/general/{t8_step8_user_defined_mesh.cxx => t8_tutorial_build_cmesh.cxx} (97%) rename tutorials/general/{t8_step8.h => t8_tutorial_build_cmesh.h} (100%) rename tutorials/general/{t8_step8_main.cxx => t8_tutorial_build_cmesh_main.cxx} (92%) diff --git a/tutorials/Makefile.am b/tutorials/Makefile.am index 9b99def2ea..4de5501a5d 100644 --- a/tutorials/Makefile.am +++ b/tutorials/Makefile.am @@ -11,7 +11,7 @@ bin_PROGRAMS += \ tutorials/general/t8_step5_element_data \ tutorials/general/t8_step5_element_data_c_interface \ tutorials/general/t8_step6_stencil \ - tutorials/general/t8_step8_user_defined_mesh \ + tutorials/general/t8_tutorial_build_cmesh \ tutorials/general/t8_tutorial_search \ tutorials/features/t8_features_curved_meshes @@ -44,9 +44,9 @@ tutorials_general_t8_step6_stencil_SOURCES = \ tutorials/general/t8_step3_adapt_forest.cxx \ tutorials/general/t8_step6_stencil.cxx \ tutorials/general/t8_step6_main.cxx -tutorials_general_t8_step8_user_defined_mesh_SOURCES = \ - tutorials/general/t8_step8_user_defined_mesh.cxx \ - tutorials/general/t8_step8_main.cxx +tutorials_general_t8_tutorial_build_cmesh_SOURCES = \ + tutorials/general/t8_tutorial_build_cmesh.cxx \ + tutorials/general/t8_tutorial_build_cmesh_main.cxx tutorials_general_t8_tutorial_search_SOURCES = \ tutorials/general/t8_tutorial_search.cxx \ tutorials/general/t8_step3_adapt_forest.cxx @@ -58,5 +58,5 @@ libt8_installed_headers += \ tutorials/general/t8_step4.h \ tutorials/general/t8_step5.h \ tutorials/general/t8_step6.h \ - tutorials/general/t8_step8.h + tutorials/general/t8_tutorial_build_cmesh.h diff --git a/tutorials/general/t8_step8_user_defined_mesh.cxx b/tutorials/general/t8_tutorial_build_cmesh.cxx similarity index 97% rename from tutorials/general/t8_step8_user_defined_mesh.cxx rename to tutorials/general/t8_tutorial_build_cmesh.cxx index 7a08e769d9..84f3d06aa3 100644 --- a/tutorials/general/t8_step8_user_defined_mesh.cxx +++ b/tutorials/general/t8_tutorial_build_cmesh.cxx @@ -505,7 +505,6 @@ t8_step8_main (int argc, char **argv) /* We will use MPI_COMM_WORLD as a communicator. */ comm = sc_MPI_COMM_WORLD; - /* * Definition of the meshes. */ diff --git a/tutorials/general/t8_step8.h b/tutorials/general/t8_tutorial_build_cmesh.h similarity index 100% rename from tutorials/general/t8_step8.h rename to tutorials/general/t8_tutorial_build_cmesh.h diff --git a/tutorials/general/t8_step8_main.cxx b/tutorials/general/t8_tutorial_build_cmesh_main.cxx similarity index 92% rename from tutorials/general/t8_step8_main.cxx rename to tutorials/general/t8_tutorial_build_cmesh_main.cxx index 7cdb98e232..f2eba66831 100644 --- a/tutorials/general/t8_step8_main.cxx +++ b/tutorials/general/t8_tutorial_build_cmesh_main.cxx @@ -25,7 +25,7 @@ * the step8 example. */ -#include +#include int main (int argc, char **argv) From 798a6463f56ffcf3a90e3173c3c70a8c78f86594 Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Tue, 25 Apr 2023 10:35:32 +0200 Subject: [PATCH 124/255] Removed all Windows(TM) cariage return characters. Also added a script for later use. --- ...e-all-windows-cariage-return-characters.sh | 29 + src/t8_forest/t8_forest.h | 68 +- src/t8_forest/t8_forest_general.h | 1516 ++++++++--------- src/t8_forest/t8_forest_geometrical.h | 274 +-- src/t8_forest/t8_forest_io.h | 202 +-- src/t8_forest/t8_forest_profiling.h | 258 +-- 6 files changed, 1188 insertions(+), 1159 deletions(-) create mode 100755 scripts/remove-all-windows-cariage-return-characters.sh diff --git a/scripts/remove-all-windows-cariage-return-characters.sh b/scripts/remove-all-windows-cariage-return-characters.sh new file mode 100755 index 0000000000..8b3b475e6f --- /dev/null +++ b/scripts/remove-all-windows-cariage-return-characters.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# This file is part of t8code. t8code is a C library to manage a collection (a +# forest) of multiple connected adaptive space-trees of general element classes +# in parallel. +# +# Copyright (C) 2023 Johannes Markert +# +# t8code is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# t8code is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin +# Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# Usage +# +# Search and remove all Windows(TM) cariage return characters '\r' from C/C++ +# source files in 'src', 'tutorials', and 'test' directories. Usually, these +# characters are visible as '^M' characters and are introduced by misconfigured +# source code editors on Windows(TM). + +grep -R -l $'\r' src tutorials test | xargs -r -l1 perl -i -p -e 's/\r//g' diff --git a/src/t8_forest/t8_forest.h b/src/t8_forest/t8_forest.h index 88adc71e7b..61cb7aa7ae 100644 --- a/src/t8_forest/t8_forest.h +++ b/src/t8_forest/t8_forest.h @@ -1,35 +1,35 @@ -/* - This file is part of t8code. - t8code is a C library to manage a collection (a forest) of multiple - connected adaptive space-trees of general element classes in parallel. - - Copyright (C) 2015 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -/** \file t8_forest.h - * Includes all headers based on previous t8_forest.h - */ - -#ifndef T8_FOREST_H -#define T8_FOREST_H - -#include -#include -#include -#include - +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** \file t8_forest.h + * Includes all headers based on previous t8_forest.h + */ + +#ifndef T8_FOREST_H +#define T8_FOREST_H + +#include +#include +#include +#include + #endif /* !T8_FOREST_H */ diff --git a/src/t8_forest/t8_forest_general.h b/src/t8_forest/t8_forest_general.h index 5095bb3889..ce8b42c6a4 100644 --- a/src/t8_forest/t8_forest_general.h +++ b/src/t8_forest/t8_forest_general.h @@ -1,827 +1,827 @@ -/* - This file is part of t8code. - t8code is a C library to manage a collection (a forest) of multiple - connected adaptive space-trees of general element classes in parallel. - - Copyright (C) 2015 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -/** \file t8_forest_general.h - * We define the forest of trees in this file. - */ - -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ - -#ifndef T8_FOREST_GENERAL_H -#define T8_FOREST_GENERAL_H - -#include -#include -#include - -/** Opaque pointer to a forest implementation. */ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** \file t8_forest_general.h + * We define the forest of trees in this file. + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + +#ifndef T8_FOREST_GENERAL_H +#define T8_FOREST_GENERAL_H + +#include +#include +#include + +/** Opaque pointer to a forest implementation. */ typedef struct t8_forest *t8_forest_t; - typedef struct t8_tree *t8_tree_t; - -/** This type controls, which neighbors count as ghost elements. - * Currently, we support face-neighbors. Vertex and edge neighbors - * will eventually be added. */ -typedef enum -{ T8_GHOST_NONE = 0, /**< Do not create ghost layer. */ - T8_GHOST_FACES, /**< Consider all face (codimension 1) neighbors. */ - T8_GHOST_EDGES, /**< Consider all edge (codimension 2) and face neighbors. */ +typedef struct t8_tree *t8_tree_t; + +/** This type controls, which neighbors count as ghost elements. + * Currently, we support face-neighbors. Vertex and edge neighbors + * will eventually be added. */ +typedef enum +{ T8_GHOST_NONE = 0, /**< Do not create ghost layer. */ + T8_GHOST_FACES, /**< Consider all face (codimension 1) neighbors. */ + T8_GHOST_EDGES, /**< Consider all edge (codimension 2) and face neighbors. */ T8_GHOST_VERTICES /**< Consider all vertex (codimension 3) and edge and face neighbors. */ - + } t8_ghost_type_t; - -/** This typedef is needed as a helper construct to - * properly be able to define a function that returns - * a pointer to a void fun(void) function. \see t8_forest_get_user_function. - */ + +/** This typedef is needed as a helper construct to + * properly be able to define a function that returns + * a pointer to a void fun(void) function. \see t8_forest_get_user_function. + */ typedef void (*t8_generic_function_pointer) (void); - T8_EXTERN_C_BEGIN (); - -/** Callback function prototype to replace one set of elements with another. - * - * This is used by the replace routine which can be called after adapt, - * when the elements of an existing, valid - * forest are changed. The callback allows the user to make changes to the elements - * of the new forest that are either refined, coarsened or the same as elements in the - * old forest. - * - * \param [in] forest_old The forest that is adapted - * \param [in] forest_new The forest that is newly constructed from \a forest_old - * \param [in] which_tree The local tree containing \a outgoing and \a incoming - * \param [in] ts The eclass scheme of the tree - * \param [in] refine -1 if family in \a forest_old got coarsened, 0 if element - * has not been touched, 1 if element got refined. - * See return of t8_forest_adapt_t. - * \param [in] num_outgoing The number of outgoing elements. - * \param [in] first_outgoing The tree local index of the first outgoing element. - * 0 <= first_outgoing < which_tree->num_elements - * \param [in] num_incoming The number of incoming elements. - * \param [in] first_incoming The tree local index of the first incoming element. - * 0 <= first_incom < new_which_tree->num_elements - * - * If an element is being refined, \a refine and \a num_outgoing will be 1 and - * \a num_incoming will be the number of children. - * If a family is being coarsened, \a refine will be -1, \a num_outgoing will be - * the number of family members and \a num_incoming will be 1. Else \a refine will - * be 0 and \a num_outgoing and \a num_incoming will both be 1. - * \see t8_forest_iterate_replace - */ + T8_EXTERN_C_BEGIN (); + +/** Callback function prototype to replace one set of elements with another. + * + * This is used by the replace routine which can be called after adapt, + * when the elements of an existing, valid + * forest are changed. The callback allows the user to make changes to the elements + * of the new forest that are either refined, coarsened or the same as elements in the + * old forest. + * + * \param [in] forest_old The forest that is adapted + * \param [in] forest_new The forest that is newly constructed from \a forest_old + * \param [in] which_tree The local tree containing \a outgoing and \a incoming + * \param [in] ts The eclass scheme of the tree + * \param [in] refine -1 if family in \a forest_old got coarsened, 0 if element + * has not been touched, 1 if element got refined. + * See return of t8_forest_adapt_t. + * \param [in] num_outgoing The number of outgoing elements. + * \param [in] first_outgoing The tree local index of the first outgoing element. + * 0 <= first_outgoing < which_tree->num_elements + * \param [in] num_incoming The number of incoming elements. + * \param [in] first_incoming The tree local index of the first incoming element. + * 0 <= first_incom < new_which_tree->num_elements + * + * If an element is being refined, \a refine and \a num_outgoing will be 1 and + * \a num_incoming will be the number of children. + * If a family is being coarsened, \a refine will be -1, \a num_outgoing will be + * the number of family members and \a num_incoming will be 1. Else \a refine will + * be 0 and \a num_outgoing and \a num_incoming will both be 1. + * \see t8_forest_iterate_replace + */ typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, - t8_forest_t forest_new, - t8_locidx_t which_tree, - t8_eclass_scheme_c *ts, - int refine, int num_outgoing, - t8_locidx_t first_outgoing, - int num_incoming, - t8_locidx_t first_incoming); - -/** Callback function prototype to decide for refining and coarsening. - * If \a is_family equals 1, the first \a num_elements in \a elements - * form a family and we decide whether this family should be coarsened - * or only the first element should be refined. - * Otherwise \a is_family must equal zero and we consider the first entry - * of the element array for refinement. - * Entries of the element array beyond the first \a num_elements are undefined. - * \param [in] forest the forest to which the new elements belong - * \param [in] forest_from the forest that is adapted. - * \param [in] which_tree the local tree containing \a elements - * \param [in] lelement_id the local element id in \a forest_old in the tree of the current element - * \param [in] ts the eclass scheme of the tree - * \param [in] is_family if 1, the first \a num_elements entries in \a elements form a family. If 0, they do not. - * \param [in] num_elements the number of entries in \a elements that are defined - * \param [in] elements Pointers to a family or, if \a is_family is zero, - * pointer to one element. - * \return greater zero if the first entry in \a elements should be refined, - * smaller zero if the family \a elements shall be coarsened, - * zero else. - */ -/* TODO: Do we really need the forest argument? Since the forest is not committed yet it - * seems dangerous to expose to the user. */ + t8_forest_t forest_new, + t8_locidx_t which_tree, + t8_eclass_scheme_c *ts, + int refine, int num_outgoing, + t8_locidx_t first_outgoing, + int num_incoming, + t8_locidx_t first_incoming); + +/** Callback function prototype to decide for refining and coarsening. + * If \a is_family equals 1, the first \a num_elements in \a elements + * form a family and we decide whether this family should be coarsened + * or only the first element should be refined. + * Otherwise \a is_family must equal zero and we consider the first entry + * of the element array for refinement. + * Entries of the element array beyond the first \a num_elements are undefined. + * \param [in] forest the forest to which the new elements belong + * \param [in] forest_from the forest that is adapted. + * \param [in] which_tree the local tree containing \a elements + * \param [in] lelement_id the local element id in \a forest_old in the tree of the current element + * \param [in] ts the eclass scheme of the tree + * \param [in] is_family if 1, the first \a num_elements entries in \a elements form a family. If 0, they do not. + * \param [in] num_elements the number of entries in \a elements that are defined + * \param [in] elements Pointers to a family or, if \a is_family is zero, + * pointer to one element. + * \return greater zero if the first entry in \a elements should be refined, + * smaller zero if the family \a elements shall be coarsened, + * zero else. + */ +/* TODO: Do we really need the forest argument? Since the forest is not committed yet it + * seems dangerous to expose to the user. */ typedef int (*t8_forest_adapt_t) (t8_forest_t forest, - t8_forest_t forest_from, - t8_locidx_t which_tree, - t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, - const int is_family, - const int num_elements, - t8_element_t *elements[]); - - /** Create a new forest with reference count one. - * This forest needs to be specialized with the t8_forest_set_* calls. - * Currently it is manatory to either call the functions \ref - * t8_forest_set_mpicomm, \ref t8_forest_set_cmesh, and \ref t8_forest_set_scheme, - * or to call one of \ref t8_forest_set_copy, \ref t8_forest_set_adapt, or - * \ref t8_forest_set_partition. It is illegal to mix these calls, or to - * call more than one of the three latter functions - * Then it needs to be set up with \ref t8_forest_commit. - * \param [in,out] pforest On input, this pointer must be non-NULL. - * On return, this pointer set to the new forest. - */ + t8_forest_t forest_from, + t8_locidx_t which_tree, + t8_locidx_t lelement_id, + t8_eclass_scheme_c *ts, + const int is_family, + const int num_elements, + t8_element_t *elements[]); + + /** Create a new forest with reference count one. + * This forest needs to be specialized with the t8_forest_set_* calls. + * Currently it is manatory to either call the functions \ref + * t8_forest_set_mpicomm, \ref t8_forest_set_cmesh, and \ref t8_forest_set_scheme, + * or to call one of \ref t8_forest_set_copy, \ref t8_forest_set_adapt, or + * \ref t8_forest_set_partition. It is illegal to mix these calls, or to + * call more than one of the three latter functions + * Then it needs to be set up with \ref t8_forest_commit. + * \param [in,out] pforest On input, this pointer must be non-NULL. + * On return, this pointer set to the new forest. + */ void t8_forest_init (t8_forest_t *pforest); - -/** Check whether a forest is not NULL, initialized and not committed. - * In addition, it asserts that the forest is consistent as much as possible. - * \param [in] forest This forest is examined. May be NULL. - * \return True if forest is not NULL, - * \ref t8_forest_init has been called on it, - * but not \ref t8_forest_commit. - * False otherwise. - */ + +/** Check whether a forest is not NULL, initialized and not committed. + * In addition, it asserts that the forest is consistent as much as possible. + * \param [in] forest This forest is examined. May be NULL. + * \return True if forest is not NULL, + * \ref t8_forest_init has been called on it, + * but not \ref t8_forest_commit. + * False otherwise. + */ int t8_forest_is_initialized (t8_forest_t forest); - -/** Check whether a forest is not NULL, initialized and committed. - * In addition, it asserts that the forest is consistent as much as possible. - * \param [in] forest This forest is examined. May be NULL. - * \return True if forest is not NULL and - * \ref t8_forest_init has been called on it - * as well as \ref t8_forest_commit. - * False otherwise. - */ + +/** Check whether a forest is not NULL, initialized and committed. + * In addition, it asserts that the forest is consistent as much as possible. + * \param [in] forest This forest is examined. May be NULL. + * \return True if forest is not NULL and + * \ref t8_forest_init has been called on it + * as well as \ref t8_forest_commit. + * False otherwise. + */ int t8_forest_is_committed (t8_forest_t forest); - -/** Check whether two committed forests have the same local elements. - * \param [in] forest_a The first forest. - * \param [in] forest_b The second forest. - * \return True if \a forest_a and \a forest_b do have the same - * number of local trees and each local tree has the same - * elements, that is \ref t8_element_compare returns false - * for each pair of elements of \a forest_a and \a forest_b. - * \note This function is not collective. It only returns the state on the current - * rank. - */ + +/** Check whether two committed forests have the same local elements. + * \param [in] forest_a The first forest. + * \param [in] forest_b The second forest. + * \return True if \a forest_a and \a forest_b do have the same + * number of local trees and each local tree has the same + * elements, that is \ref t8_element_compare returns false + * for each pair of elements of \a forest_a and \a forest_b. + * \note This function is not collective. It only returns the state on the current + * rank. + */ int t8_forest_is_equal (t8_forest_t forest_a, - t8_forest_t forest_b); - -/** Set the cmesh associated to a forest. - * By default, the forest takes ownership of the cmesh such that it will be - * destroyed when the forest is destroyed. To keep ownership of the cmesh, - * call \ref t8_cmesh_ref before passing it to \ref t8_forest_set_cmesh. - * This means that it is ILLEGAL to continue using cmesh or dereferencing it - * UNLESS it is referenced directly before passing it into this function. - * \param [in,out] forest The forest whose cmesh variable will be set. - * \param [in] cmesh The cmesh to be set. We take ownership. - * This can be prevented by referencing \b cmesh. - */ + t8_forest_t forest_b); + +/** Set the cmesh associated to a forest. + * By default, the forest takes ownership of the cmesh such that it will be + * destroyed when the forest is destroyed. To keep ownership of the cmesh, + * call \ref t8_cmesh_ref before passing it to \ref t8_forest_set_cmesh. + * This means that it is ILLEGAL to continue using cmesh or dereferencing it + * UNLESS it is referenced directly before passing it into this function. + * \param [in,out] forest The forest whose cmesh variable will be set. + * \param [in] cmesh The cmesh to be set. We take ownership. + * This can be prevented by referencing \b cmesh. + */ void t8_forest_set_cmesh (t8_forest_t forest, - t8_cmesh_t cmesh, sc_MPI_Comm comm); - -/** Set the element scheme associated to a forest. - * By default, the forest takes ownership of the scheme such that it will be - * destroyed when the forest is destroyed. To keep ownership of the scheme, call - * \ref t8_scheme_ref before passing it to \ref t8_forest_set_scheme. - * This means that it is ILLEGAL to continue using scheme or dereferencing it - * UNLESS it is referenced directly before passing it into this function. - * \param [in,out] forest The forest whose scheme variable will be set. - * \param [in] scheme The scheme to be set. We take ownership. - * This can be prevented by referencing \b scheme. - */ + t8_cmesh_t cmesh, sc_MPI_Comm comm); + +/** Set the element scheme associated to a forest. + * By default, the forest takes ownership of the scheme such that it will be + * destroyed when the forest is destroyed. To keep ownership of the scheme, call + * \ref t8_scheme_ref before passing it to \ref t8_forest_set_scheme. + * This means that it is ILLEGAL to continue using scheme or dereferencing it + * UNLESS it is referenced directly before passing it into this function. + * \param [in,out] forest The forest whose scheme variable will be set. + * \param [in] scheme The scheme to be set. We take ownership. + * This can be prevented by referencing \b scheme. + */ void t8_forest_set_scheme (t8_forest_t forest, - t8_scheme_cxx_t *scheme); - -/** Set the initial refinement level to be used when \b forest is commited. - * \param [in,out] forest The forest whose level will be set. - * \param [in] level The initial refinement level of \b forest, when - * it is commited. - * \note This setting cannot be combined with any of the derived forest methods - * (\ref t8_forest_set_copy, \ref t8_forest_set_adapt, \ref t8_forest_set_partition, - * and \ref t8_forest_set_balance) and overwrites any of these settings. - * If this function is used, then the forest is created from scratch as a uniform - * refinement of the specified cmesh (\ref t8_forest_set_cmesh, \ref t8_forest_set_scheme). - */ + t8_scheme_cxx_t *scheme); + +/** Set the initial refinement level to be used when \b forest is commited. + * \param [in,out] forest The forest whose level will be set. + * \param [in] level The initial refinement level of \b forest, when + * it is commited. + * \note This setting cannot be combined with any of the derived forest methods + * (\ref t8_forest_set_copy, \ref t8_forest_set_adapt, \ref t8_forest_set_partition, + * and \ref t8_forest_set_balance) and overwrites any of these settings. + * If this function is used, then the forest is created from scratch as a uniform + * refinement of the specified cmesh (\ref t8_forest_set_cmesh, \ref t8_forest_set_scheme). + */ void t8_forest_set_level (t8_forest_t forest, int level); - -/** Set a forest as source for copying on commiting. - * By default, the forest takes ownership of the source \b from such that it will - * be destroyed on calling \ref t8_forest_commit. To keep ownership of \b - * from, call \ref t8_forest_ref before passing it into this function. - * This means that it is ILLEGAL to continue using \b from or dereferencing it - * UNLESS it is referenced directly before passing it into this function. - * \param [in,out] forest The forest. - * \param [in] from A second forest from which \a forest will be copied - * in \ref t8_forest_commit. - * \note This setting cannot be combined with \ref t8_forest_set_adapt, - * \ref t8_forest_set_partition, or \ref t8_forest_set_balance and overwrites these - * settings. - */ + +/** Set a forest as source for copying on commiting. + * By default, the forest takes ownership of the source \b from such that it will + * be destroyed on calling \ref t8_forest_commit. To keep ownership of \b + * from, call \ref t8_forest_ref before passing it into this function. + * This means that it is ILLEGAL to continue using \b from or dereferencing it + * UNLESS it is referenced directly before passing it into this function. + * \param [in,out] forest The forest. + * \param [in] from A second forest from which \a forest will be copied + * in \ref t8_forest_commit. + * \note This setting cannot be combined with \ref t8_forest_set_adapt, + * \ref t8_forest_set_partition, or \ref t8_forest_set_balance and overwrites these + * settings. + */ void t8_forest_set_copy (t8_forest_t forest, - const t8_forest_t from); - -/** Set a source forest with an adapt function to be adapted on commiting. - * By default, the forest takes ownership of the source \b set_from such that it - * will be destroyed on calling \ref t8_forest_commit. To keep ownership of \b - * set_from, call \ref t8_forest_ref before passing it into this function. - * This means that it is ILLEGAL to continue using \b set_from or dereferencing it - * UNLESS it is referenced directly before passing it into this function. - * \param [in,out] forest The forest - * \param [in] set_from The source forest from which \b forest will be adapted. - * We take ownership. This can be prevented by - * referencing \b set_from. - * If NULL, a previously (or later) set forest will - * be taken (\ref t8_forest_set_partition, \ref t8_forest_set_balance). - * \param [in] adapt_fn The adapt function used on commiting. - * \param [in] recursive A flag specifying whether adaptation is to be done recursively - * or not. If the value is zero, adaptation is not recursive - * and it is recursive otherwise. - * \note This setting can be combined with \ref t8_forest_set_partition and \ref - * t8_forest_set_balance. The order in which these operations are executed is always - * 1) Adapt 2) Balance 3) Partition - * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites - * this setting. - */ -/* TODO: make recursive flag to int specifying the number of recursions? */ + const t8_forest_t from); + +/** Set a source forest with an adapt function to be adapted on commiting. + * By default, the forest takes ownership of the source \b set_from such that it + * will be destroyed on calling \ref t8_forest_commit. To keep ownership of \b + * set_from, call \ref t8_forest_ref before passing it into this function. + * This means that it is ILLEGAL to continue using \b set_from or dereferencing it + * UNLESS it is referenced directly before passing it into this function. + * \param [in,out] forest The forest + * \param [in] set_from The source forest from which \b forest will be adapted. + * We take ownership. This can be prevented by + * referencing \b set_from. + * If NULL, a previously (or later) set forest will + * be taken (\ref t8_forest_set_partition, \ref t8_forest_set_balance). + * \param [in] adapt_fn The adapt function used on commiting. + * \param [in] recursive A flag specifying whether adaptation is to be done recursively + * or not. If the value is zero, adaptation is not recursive + * and it is recursive otherwise. + * \note This setting can be combined with \ref t8_forest_set_partition and \ref + * t8_forest_set_balance. The order in which these operations are executed is always + * 1) Adapt 2) Balance 3) Partition + * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites + * this setting. + */ +/* TODO: make recursive flag to int specifying the number of recursions? */ void t8_forest_set_adapt (t8_forest_t forest, - const t8_forest_t set_from, - t8_forest_adapt_t adapt_fn, - int recursive); - -/** Set the user data of a forest. This can i.e. be used to pass user defined - * arguments to the adapt routine. - * \param [in,out] forest The forest - * \param [in] data A pointer to user data. t8code will never touch the data. - * The forest does not need be committed before calling this function. - * \see t8_forest_get_user_data - */ + const t8_forest_t set_from, + t8_forest_adapt_t adapt_fn, + int recursive); + +/** Set the user data of a forest. This can i.e. be used to pass user defined + * arguments to the adapt routine. + * \param [in,out] forest The forest + * \param [in] data A pointer to user data. t8code will never touch the data. + * The forest does not need be committed before calling this function. + * \see t8_forest_get_user_data + */ void t8_forest_set_user_data (t8_forest_t forest, void *data); - -/** Return the user data pointer associated with a forest. - * \param [in] forest The forest. - * \return The user data pointer of \a forest. - * The forest does not need be committed before calling this function. - * \see t8_forest_set_user_data - */ + +/** Return the user data pointer associated with a forest. + * \param [in] forest The forest. + * \return The user data pointer of \a forest. + * The forest does not need be committed before calling this function. + * \see t8_forest_set_user_data + */ void *t8_forest_get_user_data (t8_forest_t forest); - -/** Set the user function pointer of a forest. This can i.e. be used to pass user defined - * functions to the adapt routine. - * \param [in,out] forest The forest - * \param [in] function A pointer to a user defined function. t8code will never touch the function. - * The forest does not need be committed before calling this function. - * \note \a function can be an arbitrary function with return value and parameters of - * your choice. When accessing it with \ref t8_forest_get_user_function you should cast - * it into the proper type. - * \see t8_forest_get_user_function - */ + +/** Set the user function pointer of a forest. This can i.e. be used to pass user defined + * functions to the adapt routine. + * \param [in,out] forest The forest + * \param [in] function A pointer to a user defined function. t8code will never touch the function. + * The forest does not need be committed before calling this function. + * \note \a function can be an arbitrary function with return value and parameters of + * your choice. When accessing it with \ref t8_forest_get_user_function you should cast + * it into the proper type. + * \see t8_forest_get_user_function + */ void t8_forest_set_user_function (t8_forest_t forest, - t8_generic_function_pointer - functrion); - -/** Return the user function pointer associated with a forest. - * \param [in] forest The forest. - * \return The user function pointer of \a forest. - * The forest does not need be committed before calling this function. - * \see t8_forest_set_user_function - */ + t8_generic_function_pointer + functrion); + +/** Return the user function pointer associated with a forest. + * \param [in] forest The forest. + * \return The user function pointer of \a forest. + * The forest does not need be committed before calling this function. + * \see t8_forest_set_user_function + */ t8_generic_function_pointer t8_forest_get_user_function (t8_forest_t forest); - -/** Set a source forest to be partitioned during commit. - * The partitioning is done according to the SFC and each rank is assinged - * the same (maybe +1) number of elements. - * \param [in, out] forest The forest. - * \param [in] set_from A second forest that should be partitioned. - * We take ownership. This can be prevented by - * referencing \b set_from. - * If NULL, a previously (or later) set forest will - * be taken (\ref t8_forest_set_adapt, \ref t8_forest_set_balance). - * \param [in] set_for_coarsening CURRENTLY DISABLED. If true, then the partitions - * are choose such that coarsening an element once is a process local - * operation. - * \note This setting can be combined with \ref t8_forest_set_adapt and \ref - * t8_forest_set_balance. The order in which these operations are executed is always - * 1) Adapt 2) Balance 3) Partition - * If \ref t8_forest_set_balance is called with the \a no_repartition parameter set as - * false, it is not neccessary to call \ref t8_forest_set_partition additionally. - * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites - * this setting. - */ + +/** Set a source forest to be partitioned during commit. + * The partitioning is done according to the SFC and each rank is assinged + * the same (maybe +1) number of elements. + * \param [in, out] forest The forest. + * \param [in] set_from A second forest that should be partitioned. + * We take ownership. This can be prevented by + * referencing \b set_from. + * If NULL, a previously (or later) set forest will + * be taken (\ref t8_forest_set_adapt, \ref t8_forest_set_balance). + * \param [in] set_for_coarsening CURRENTLY DISABLED. If true, then the partitions + * are choose such that coarsening an element once is a process local + * operation. + * \note This setting can be combined with \ref t8_forest_set_adapt and \ref + * t8_forest_set_balance. The order in which these operations are executed is always + * 1) Adapt 2) Balance 3) Partition + * If \ref t8_forest_set_balance is called with the \a no_repartition parameter set as + * false, it is not neccessary to call \ref t8_forest_set_partition additionally. + * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites + * this setting. + */ void t8_forest_set_partition (t8_forest_t forest, - const t8_forest_t set_from, - int set_for_coarsening); - -/** Set a source forest to be balanced during commit. - * A forest is said to be balanced if each element has face neighbors of level - * at most +1 or -1 of the element's level. - * \param [in, out] forest The forest. - * \param [in] set_from A second forest that should be balanced. - * We take ownership. This can be prevented by - * referencing \b set_from. - * If NULL, a previously (or later) set forest will - * be taken (\ref t8_forest_set_adapt, \ref t8_forest_set_partition) - * \param [in] no_repartition Balance constructs several intermediate forest that - * are refined from each other. In order to maintain a balanced load - * these forest are repartitioned in each round and the resulting - * forest is load-balanced per default. - * If this behaviour is not desired, \a no_repartition should be - * set to true. - * If \a no_repartition is false, an additional call of \ref t8_forest_set_partition is not - * neccessary. - * \note This setting can be combined with \ref t8_forest_set_adapt and \ref - * t8_forest_set_balance. The order in which these operations are executed is always - * 1) Adapt 2) Balance 3) Partition. - * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites - * this setting. - */ + const t8_forest_t set_from, + int set_for_coarsening); + +/** Set a source forest to be balanced during commit. + * A forest is said to be balanced if each element has face neighbors of level + * at most +1 or -1 of the element's level. + * \param [in, out] forest The forest. + * \param [in] set_from A second forest that should be balanced. + * We take ownership. This can be prevented by + * referencing \b set_from. + * If NULL, a previously (or later) set forest will + * be taken (\ref t8_forest_set_adapt, \ref t8_forest_set_partition) + * \param [in] no_repartition Balance constructs several intermediate forest that + * are refined from each other. In order to maintain a balanced load + * these forest are repartitioned in each round and the resulting + * forest is load-balanced per default. + * If this behaviour is not desired, \a no_repartition should be + * set to true. + * If \a no_repartition is false, an additional call of \ref t8_forest_set_partition is not + * neccessary. + * \note This setting can be combined with \ref t8_forest_set_adapt and \ref + * t8_forest_set_balance. The order in which these operations are executed is always + * 1) Adapt 2) Balance 3) Partition. + * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites + * this setting. + */ void t8_forest_set_balance (t8_forest_t forest, - const t8_forest_t set_from, - int no_repartition); - -/** Enable or disable the creation of a layer of ghost elements. - * On default no ghosts are created. - * \param [in] forest The forest. - * \param [in] do_ghost If non-zero a ghost layer will be created. - * \param [in] ghost_type Controls which neighbors count as ghost elements, - * currently only T8_GHOST_FACES is supported. This value - * is ignored if \a do_ghost = 0. - */ + const t8_forest_t set_from, + int no_repartition); + +/** Enable or disable the creation of a layer of ghost elements. + * On default no ghosts are created. + * \param [in] forest The forest. + * \param [in] do_ghost If non-zero a ghost layer will be created. + * \param [in] ghost_type Controls which neighbors count as ghost elements, + * currently only T8_GHOST_FACES is supported. This value + * is ignored if \a do_ghost = 0. + */ void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, - t8_ghost_type_t ghost_type); - -/** Like \ref t8_forest_set_ghost but with the additional options to change the - * ghost algorithm. This is used for debugging and timing the algorithm. - * An application should almost always use \ref t8_forest_set_ghost. - * \param [in] ghost_version If 1, the iterative ghost algorithm for balanced forests is used. - * If 2, the iterativ algorithm for unbalanced forests. - * If 3, the top-down search algorithm for unbalanced forests. - * \see t8_forest_set_ghost - */ + t8_ghost_type_t ghost_type); + +/** Like \ref t8_forest_set_ghost but with the additional options to change the + * ghost algorithm. This is used for debugging and timing the algorithm. + * An application should almost always use \ref t8_forest_set_ghost. + * \param [in] ghost_version If 1, the iterative ghost algorithm for balanced forests is used. + * If 2, the iterativ algorithm for unbalanced forests. + * If 3, the top-down search algorithm for unbalanced forests. + * \see t8_forest_set_ghost + */ void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, - t8_ghost_type_t ghost_type, - int ghost_version); - -/* TODO: use assertions and document that the forest_set (..., from) and - * set_load are mutually exclusive. */ + t8_ghost_type_t ghost_type, + int ghost_version); + +/* TODO: use assertions and document that the forest_set (..., from) and + * set_load are mutually exclusive. */ void t8_forest_set_load (t8_forest_t forest, - const char *filename); - -/** Compute the global number of elements in a forest as the sum - * of the local element counts. - * \param [in] forest The forest. - */ + const char *filename); + +/** Compute the global number of elements in a forest as the sum + * of the local element counts. + * \param [in] forest The forest. + */ void t8_forest_comm_global_num_elements (t8_forest_t forest); - -/** After allocating and adding properties to a forest, commit the changes. - * This call sets up the internal state of the forest. - * \param [in,out] forest Must be created with \ref t8_forest_init and - * specialized with t8_forest_set_* calls first. - */ + +/** After allocating and adding properties to a forest, commit the changes. + * This call sets up the internal state of the forest. + * \param [in,out] forest Must be created with \ref t8_forest_init and + * specialized with t8_forest_set_* calls first. + */ void t8_forest_commit (t8_forest_t forest); - -/** Return the maximum allowed refinement level for any element in a forest. - * \param [in] forest A forest. - * \return The maximum level of refinement that is allowed for - * an element in this forest. It is guarenteed that any tree - * in \a forest can be refined this many times and it is not - * allowed to refine further. - * \a forest must be committed before calling this function. - * For forest with a single element class (non-hybrid) maxlevel is the maximum - * refinement level of this element class, whilst for hybrid forests the maxlevel is - * the minimum of all maxlevels of the element classes in this forest. - */ + +/** Return the maximum allowed refinement level for any element in a forest. + * \param [in] forest A forest. + * \return The maximum level of refinement that is allowed for + * an element in this forest. It is guarenteed that any tree + * in \a forest can be refined this many times and it is not + * allowed to refine further. + * \a forest must be committed before calling this function. + * For forest with a single element class (non-hybrid) maxlevel is the maximum + * refinement level of this element class, whilst for hybrid forests the maxlevel is + * the minimum of all maxlevels of the element classes in this forest. + */ int t8_forest_get_maxlevel (t8_forest_t forest); - -/** Return the number of process local elements in the forest. - * \param [in] forest A forest. - * \return The number of elements on this process in \a forest. - * \a forest must be committed before calling this function. - */ + +/** Return the number of process local elements in the forest. + * \param [in] forest A forest. + * \return The number of elements on this process in \a forest. + * \a forest must be committed before calling this function. + */ t8_locidx_t t8_forest_get_local_num_elements (t8_forest_t forest); - -/** Return the number of global elements in the forest. - * \param [in] forest A forest. - * \return The number of elements (summed over all processes) in \a forest. - * \a forest must be committed before calling this function. - */ + +/** Return the number of global elements in the forest. + * \param [in] forest A forest. + * \return The number of elements (summed over all processes) in \a forest. + * \a forest must be committed before calling this function. + */ t8_gloidx_t t8_forest_get_global_num_elements (t8_forest_t forest); - -/** Return the number of ghost elements of a forest. - * \param [in] forest The forest. - * \return The number of ghost elements stored in the ghost - * structure of \a forest. 0 if no ghosts were constructed. - * \see t8_forest_set_ghost - * \a forest must be committed before calling this function. - */ + +/** Return the number of ghost elements of a forest. + * \param [in] forest The forest. + * \return The number of ghost elements stored in the ghost + * structure of \a forest. 0 if no ghosts were constructed. + * \see t8_forest_set_ghost + * \a forest must be committed before calling this function. + */ t8_locidx_t t8_forest_get_num_ghosts (t8_forest_t forest); - -/** Return the element class of a forest local tree. - * \param [in] forest The forest. - * \param [in] ltreeid The local id of a tree in \a forest. - * \return The element class of the tree \a ltreeid. - * \a forest must be committed before calling this function. - */ + +/** Return the element class of a forest local tree. + * \param [in] forest The forest. + * \param [in] ltreeid The local id of a tree in \a forest. + * \return The element class of the tree \a ltreeid. + * \a forest must be committed before calling this function. + */ t8_eclass_t t8_forest_get_eclass (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Given a global tree id compute the forest local id of this tree. - * If the tree is a local tree, then the local id is between 0 and the number - * of local trees. If the tree is not a local tree, a negative number is returned. - * \param [in] forest The forest. - * \param [in] gtreeid The global id of a tree. - * \return The tree's local id in \a forest, if it is a local tree. - * A negative number if not. - * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ + t8_locidx_t ltreeid); + +/** Given a global tree id compute the forest local id of this tree. + * If the tree is a local tree, then the local id is between 0 and the number + * of local trees. If the tree is not a local tree, a negative number is returned. + * \param [in] forest The forest. + * \param [in] gtreeid The global id of a tree. + * \return The tree's local id in \a forest, if it is a local tree. + * A negative number if not. + * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + */ t8_locidx_t t8_forest_get_local_id (t8_forest_t forest, - t8_gloidx_t gtreeid); - -/** Given the local id of a tree in a forest, compute the tree's local id - * in the associated cmesh. - * \param [in] forest The forest. - * \param [in] ltreeid The local id of a tree or ghost in the forest. - * \return The local id of the tree in the cmesh associated with the forest. - * \a forest must be committed before calling this function. - * \note For forest local trees, this is the inverse function of \ref t8_forest_cmesh_ltreeid_to_ltreeid. - * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ + t8_gloidx_t gtreeid); + +/** Given the local id of a tree in a forest, compute the tree's local id + * in the associated cmesh. + * \param [in] forest The forest. + * \param [in] ltreeid The local id of a tree or ghost in the forest. + * \return The local id of the tree in the cmesh associated with the forest. + * \a forest must be committed before calling this function. + * \note For forest local trees, this is the inverse function of \ref t8_forest_cmesh_ltreeid_to_ltreeid. + * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + */ t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Given the local id of a tree in the coarse mesh of a forest, compute - * the tree's local id in the forest. - * \param [in] forest The forest. - * \param [in] ltreeid The local id of a tree in the coarse mesh of \a forest. - * \return The local id of the tree in the forest. -1 if the tree is not forest local. - * \a forest must be committed before calling this function. - * \note For forest local trees, this is the inverse function of \ref t8_forest_ltreeid_to_cmesh_ltreeid. - * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ + t8_locidx_t ltreeid); + +/** Given the local id of a tree in the coarse mesh of a forest, compute + * the tree's local id in the forest. + * \param [in] forest The forest. + * \param [in] ltreeid The local id of a tree in the coarse mesh of \a forest. + * \return The local id of the tree in the forest. -1 if the tree is not forest local. + * \a forest must be committed before calling this function. + * \note For forest local trees, this is the inverse function of \ref t8_forest_ltreeid_to_cmesh_ltreeid. + * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + */ t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, - t8_locidx_t + t8_locidx_t lctreeid); - -/** Given the local id of a tree in a forest, return the coarse tree of the - * cmesh that corresponds to this tree. - * \param [in] forest The forest. - * \param [in] ltreeid The local id of a tree in the forest. - * \return The coarse tree that matches the forest tree with local - * id \a ltreeid. - */ + +/** Given the local id of a tree in a forest, return the coarse tree of the + * cmesh that corresponds to this tree. + * \param [in] forest The forest. + * \param [in] ltreeid The local id of a tree in the forest. + * \return The coarse tree that matches the forest tree with local + * id \a ltreeid. + */ t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Compute the leaf face neighbors of a forest. - * \param [in] forest The forest. Must have a valid ghost layer. - * \param [in] ltreeid A local tree id. - * \param [in] leaf A leaf in tree \a ltreeid of \a forest. - * \param [out] neighbor_leafs Unallocated on input. On output the neighbor - * leafs are stored here. - * \param [in] face The index of the face across which the face neighbors - * are searched. - * \param [out] dual_face On output the face id's of the neighboring elements' faces. - * \param [out] num_neighbors On output the number of neighbor leafs. - * \param [out] pelement_indices Unallocated on input. On output the element indices - * of the neighbor leafs are stored here. - * 0, 1, ... num_local_el - 1 for local leafs and - * num_local_el , ... , num_local_el + num_ghosts - 1 for ghosts. - * \param [out] pneigh_scheme On output the eclass scheme of the neighbor elements. - * \param [in] forest_is_balanced True if we know that \a forest is balanced, false - * otherwise. - * \note If there are no face neighbors, then *neighbor_leafs = NULL, num_neighbors = 0, - * and *pelement_indices = NULL on output. - * \note Currently \a forest must be balanced. - * \note \a forest must be committed before calling this function. - */ + t8_locidx_t ltreeid); + +/** Compute the leaf face neighbors of a forest. + * \param [in] forest The forest. Must have a valid ghost layer. + * \param [in] ltreeid A local tree id. + * \param [in] leaf A leaf in tree \a ltreeid of \a forest. + * \param [out] neighbor_leafs Unallocated on input. On output the neighbor + * leafs are stored here. + * \param [in] face The index of the face across which the face neighbors + * are searched. + * \param [out] dual_face On output the face id's of the neighboring elements' faces. + * \param [out] num_neighbors On output the number of neighbor leafs. + * \param [out] pelement_indices Unallocated on input. On output the element indices + * of the neighbor leafs are stored here. + * 0, 1, ... num_local_el - 1 for local leafs and + * num_local_el , ... , num_local_el + num_ghosts - 1 for ghosts. + * \param [out] pneigh_scheme On output the eclass scheme of the neighbor elements. + * \param [in] forest_is_balanced True if we know that \a forest is balanced, false + * otherwise. + * \note If there are no face neighbors, then *neighbor_leafs = NULL, num_neighbors = 0, + * and *pelement_indices = NULL on output. + * \note Currently \a forest must be balanced. + * \note \a forest must be committed before calling this function. + */ void t8_forest_leaf_face_neighbors (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *leaf, - t8_element_t - **pneighbor_leafs[], - int face, - int *dual_faces[], - int *num_neighbors, - t8_locidx_t - **pelement_indices, - t8_eclass_scheme_c - **pneigh_scheme, - int forest_is_balanced); - -/** Exchange ghost information of user defined element data. - * \param[in] forest The forest. Must be committed. - * \param[in] element_data An array of length num_local_elements + num_ghosts - * storing one value for each local element and ghost in \a forest. - * After calling this function the entries for the ghost elements - * are update with the entries in the \a element_data array of - * the corresponding owning process. - * \note This function is collective and hence must be called by all processes in the forest's - * MPI Communicator. - */ -/* TODO: In \ref t8_forest_ghost_cxx we already implemented a begin and end function - * that allow for overlapping communication and computation. We will make them - * available in this interface in the future. */ + t8_locidx_t ltreeid, + const t8_element_t *leaf, + t8_element_t + **pneighbor_leafs[], + int face, + int *dual_faces[], + int *num_neighbors, + t8_locidx_t + **pelement_indices, + t8_eclass_scheme_c + **pneigh_scheme, + int forest_is_balanced); + +/** Exchange ghost information of user defined element data. + * \param[in] forest The forest. Must be committed. + * \param[in] element_data An array of length num_local_elements + num_ghosts + * storing one value for each local element and ghost in \a forest. + * After calling this function the entries for the ghost elements + * are update with the entries in the \a element_data array of + * the corresponding owning process. + * \note This function is collective and hence must be called by all processes in the forest's + * MPI Communicator. + */ +/* TODO: In \ref t8_forest_ghost_cxx we already implemented a begin and end function + * that allow for overlapping communication and computation. We will make them + * available in this interface in the future. */ void t8_forest_ghost_exchange_data (t8_forest_t forest, - sc_array_t *element_data); - -/** Print the ghost structure of a forest. Only used for debugging. */ + sc_array_t *element_data); + +/** Print the ghost structure of a forest. Only used for debugging. */ void t8_forest_ghost_print (t8_forest_t forest); - -/** Change the cmesh associated to a forest to a partitioned cmesh that - * is partitioned according to the tree distribution in the forest. - * \param [in,out] forest The forest. - * \param [in] comm The MPI communicator that is used to partition - * and commit the cmesh. - * \param [in] set_profiling If true, profiling for the new cmesh - * will be enabled. \see t8_cmesh_set_profiling, \see t8_cmesh_print_profile - * \see t8_cmesh.h - */ + +/** Change the cmesh associated to a forest to a partitioned cmesh that + * is partitioned according to the tree distribution in the forest. + * \param [in,out] forest The forest. + * \param [in] comm The MPI communicator that is used to partition + * and commit the cmesh. + * \param [in] set_profiling If true, profiling for the new cmesh + * will be enabled. \see t8_cmesh_set_profiling, \see t8_cmesh_print_profile + * \see t8_cmesh.h + */ void t8_forest_partition_cmesh (t8_forest_t forest, - sc_MPI_Comm comm, - int set_profiling); - -/** Return the mpi communicator associated to a forest. - * \param [in] forest The forest. - * \return The mpi communicator of \a forest. - * \a forest must be committed before calling this function. - */ + sc_MPI_Comm comm, + int set_profiling); + +/** Return the mpi communicator associated to a forest. + * \param [in] forest The forest. + * \return The mpi communicator of \a forest. + * \a forest must be committed before calling this function. + */ sc_MPI_Comm t8_forest_get_mpicomm (t8_forest_t forest); - -/** Return the global id of the first local tree of a forest. - * \param [in] forest The forest. - * \return The global id of the first local tree in \a forest. - */ + +/** Return the global id of the first local tree of a forest. + * \param [in] forest The forest. + * \return The global id of the first local tree in \a forest. + */ t8_gloidx_t t8_forest_get_first_local_tree_id (t8_forest_t forest); - -/** Return the number of local trees of a given forest. - * \param [in] forest The forest. - * \return The number of local trees of that forest. - */ + +/** Return the number of local trees of a given forest. + * \param [in] forest The forest. + * \return The number of local trees of that forest. + */ t8_locidx_t t8_forest_get_num_local_trees (t8_forest_t forest); - -/** Return the number of ghost trees of a given forest. - * \param [in] forest The forest. - * \return The number of ghost trees of that forest. - */ + +/** Return the number of ghost trees of a given forest. + * \param [in] forest The forest. + * \return The number of ghost trees of that forest. + */ t8_locidx_t t8_forest_get_num_ghost_trees (t8_forest_t forest); - -/** Return the number of global trees of a given forest. - * \param [in] forest The forest. - * \return The number of global trees of that forest. - */ + +/** Return the number of global trees of a given forest. + * \param [in] forest The forest. + * \return The number of global trees of that forest. + */ t8_gloidx_t t8_forest_get_num_global_trees (t8_forest_t forest); - -/** Return the global id of a local tree or a ghost tree. - * \param [in] forest The forest. - * \param [in] ltreeid An id 0 <= \a ltreeid < num_local_trees + num_ghosts - * specifying a local tree or ghost tree. - * \return The global id corresponding to the tree with local id \a ltreeid. - * \a forest must be committed before calling this function. - * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ + +/** Return the global id of a local tree or a ghost tree. + * \param [in] forest The forest. + * \param [in] ltreeid An id 0 <= \a ltreeid < num_local_trees + num_ghosts + * specifying a local tree or ghost tree. + * \return The global id corresponding to the tree with local id \a ltreeid. + * \a forest must be committed before calling this function. + * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. + */ t8_gloidx_t t8_forest_global_tree_id (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Return a pointer to a tree in a forest. - * \param [in] forest The forest. - * \param [in] ltree_id The local id of the tree. - * \return A pointer to the tree with local id \a ltree_id. - * \a forest must be committed before calling this function. - */ - t8_tree_t t8_forest_get_tree (t8_forest_t forest, t8_locidx_t ltree_id); - -/** Return a pointer to the vertex coordinates of a tree. - * \param [in] forest The forest. - * \param [in] ltreeid The id of a local tree. - * \return If stored, a pointer to the vertex coordinates of \a tree. - * If no coordinates for this tree are found, NULL. - */ + t8_locidx_t ltreeid); + +/** Return a pointer to a tree in a forest. + * \param [in] forest The forest. + * \param [in] ltree_id The local id of the tree. + * \return A pointer to the tree with local id \a ltree_id. + * \a forest must be committed before calling this function. + */ + t8_tree_t t8_forest_get_tree (t8_forest_t forest, t8_locidx_t ltree_id); + +/** Return a pointer to the vertex coordinates of a tree. + * \param [in] forest The forest. + * \param [in] ltreeid The id of a local tree. + * \return If stored, a pointer to the vertex coordinates of \a tree. + * If no coordinates for this tree are found, NULL. + */ double *t8_forest_get_tree_vertices (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Return the array of leaf elements of a local tree in a forest. - * \param [in] forest The forest. - * \param [in] ltree_id The local id of a local tree of \a forest. - * \return An array of t8_element_t * storing all leaf elements - * of this tree. - */ + t8_locidx_t ltreeid); + +/** Return the array of leaf elements of a local tree in a forest. + * \param [in] forest The forest. + * \param [in] ltree_id The local id of a local tree of \a forest. + * \return An array of t8_element_t * storing all leaf elements + * of this tree. + */ t8_element_array_t *t8_forest_tree_get_leafs (t8_forest_t forest, - t8_locidx_t ltree_id); - -/** Return a cmesh associated to a forest. - * \param [in] forest The forest. - * \return The cmesh associated to the forest. - */ + t8_locidx_t ltree_id); + +/** Return a cmesh associated to a forest. + * \param [in] forest The forest. + * \return The cmesh associated to the forest. + */ t8_cmesh_t t8_forest_get_cmesh (t8_forest_t forest); - -/** Return an element of the forest. - * \param [in] forest The forest. - * \param [in] lelement_id The local id of an element in \a forest. - * \param [out] ltreeid If not NULL, on output the local tree id of the tree in which the - * element lies in. - * \return A pointer to the element. NULL if this element does not exist. - * \note This function performs a binary search. For constant access, use \ref t8_forest_get_element_in_tree - * \a forest must be committed before calling this function. - */ + +/** Return an element of the forest. + * \param [in] forest The forest. + * \param [in] lelement_id The local id of an element in \a forest. + * \param [out] ltreeid If not NULL, on output the local tree id of the tree in which the + * element lies in. + * \return A pointer to the element. NULL if this element does not exist. + * \note This function performs a binary search. For constant access, use \ref t8_forest_get_element_in_tree + * \a forest must be committed before calling this function. + */ t8_element_t *t8_forest_get_element (t8_forest_t forest, - t8_locidx_t lelement_id, - t8_locidx_t *ltreeid); - -/** Return an element of a local tree in a forest. - * \param [in] forest The forest. - * \param [in] ltreeid An id of a local tree in the forest. - * \param [in] leid_in_tree The index of an element in the tree. - * \return A pointer to the element. - * \note If the tree id is know, this function should be preferred over \ref t8_forest_get_element. - * \a forest must be committed before calling this function. - */ + t8_locidx_t lelement_id, + t8_locidx_t *ltreeid); + +/** Return an element of a local tree in a forest. + * \param [in] forest The forest. + * \param [in] ltreeid An id of a local tree in the forest. + * \param [in] leid_in_tree The index of an element in the tree. + * \return A pointer to the element. + * \note If the tree id is know, this function should be preferred over \ref t8_forest_get_element. + * \a forest must be committed before calling this function. + */ t8_element_t *t8_forest_get_element_in_tree (t8_forest_t forest, - t8_locidx_t ltreeid, - t8_locidx_t leid_in_tree); - -/** Return the number of elements of a tree. - * \param [in] forest The forest. - * \param [in] ltreeid A local id of a tree. - * \return The number of elements in the local tree \a ltreeid. - */ + t8_locidx_t ltreeid, + t8_locidx_t leid_in_tree); + +/** Return the number of elements of a tree. + * \param [in] forest The forest. + * \param [in] ltreeid A local id of a tree. + * \return The number of elements in the local tree \a ltreeid. + */ t8_locidx_t t8_forest_get_tree_num_elements (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Return the element offset of a local tree, that is the number of elements - * in all trees with smaller local treeid. - * \param [in] forest The forest. - * \param [in] ltreeid A local id of a tree. - * \return The number of leaf elements on all local tree with - * id < \a ltreeid. - * \note \a forest must be committed before calling this function. - */ + t8_locidx_t ltreeid); + +/** Return the element offset of a local tree, that is the number of elements + * in all trees with smaller local treeid. + * \param [in] forest The forest. + * \param [in] ltreeid A local id of a tree. + * \return The number of leaf elements on all local tree with + * id < \a ltreeid. + * \note \a forest must be committed before calling this function. + */ t8_locidx_t t8_forest_get_tree_element_offset (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Return the number of elements of a tree. - * \param [in] tree A tree in a forest. - * \return The number of elements of that tree. - */ + t8_locidx_t ltreeid); + +/** Return the number of elements of a tree. + * \param [in] tree A tree in a forest. + * \return The number of elements of that tree. + */ t8_locidx_t t8_forest_get_tree_element_count (t8_tree_t tree); - -/** Return the eclass of a tree in a forest. - * \param [in] forest The forest. - * \param [in] ltreeid The local id of a tree (local or ghost) in \a forest. - * \return The element class of the tree with local id \a ltreeid. - */ + +/** Return the eclass of a tree in a forest. + * \param [in] forest The forest. + * \param [in] ltreeid The local id of a tree (local or ghost) in \a forest. + * \return The element class of the tree with local id \a ltreeid. + */ t8_eclass_t t8_forest_get_tree_class (t8_forest_t forest, - t8_locidx_t ltreeid); - -/** Compute the global index of the first local element of a forest. - * This function is collective. - * \param [in] forest A committed forest, whose first element's index is computed. - * \return The global index of \a forest's first local element. - * Forest must be committed when calling this function. - * This function is collective and must be called on each process. - */ + t8_locidx_t ltreeid); + +/** Compute the global index of the first local element of a forest. + * This function is collective. + * \param [in] forest A committed forest, whose first element's index is computed. + * \return The global index of \a forest's first local element. + * Forest must be committed when calling this function. + * This function is collective and must be called on each process. + */ t8_gloidx_t t8_forest_get_first_local_element_id (t8_forest_t forest); - -/** Return the element scheme associated to a forest. - * \param [in] forest. A committed forest. - * \return The element scheme of the forest. - * \see t8_forest_set_scheme - */ + +/** Return the element scheme associated to a forest. + * \param [in] forest. A committed forest. + * \return The element scheme of the forest. + * \see t8_forest_set_scheme + */ t8_scheme_cxx_t *t8_forest_get_scheme (t8_forest_t forest); - -/** Return the eclass scheme of a given element class associated to a forest. - * \param [in] forest. A committed forest. - * \param [in] eclass. An element class. - * \return The eclass scheme of \a eclass associated to forest. - * \see t8_forest_set_scheme - * \note The forest is not required to have trees of class \a eclass. - */ + +/** Return the eclass scheme of a given element class associated to a forest. + * \param [in] forest. A committed forest. + * \param [in] eclass. An element class. + * \return The eclass scheme of \a eclass associated to forest. + * \see t8_forest_set_scheme + * \note The forest is not required to have trees of class \a eclass. + */ t8_eclass_scheme_c *t8_forest_get_eclass_scheme (t8_forest_t forest, - t8_eclass_t eclass); - -/** Return the eclass of the tree in which a face neighbor of a given element - * lies. - * \param [in] forest. A committed forest. - * \param [in] ltreeid. The local tree in which the element lies. - * \param [in] elem. An element in the tree \a ltreeid. - * \param [in] face. A face number of \a elem. - * \return The local tree id of the tree in which the face - * neighbor of \a elem across \a face lies. - */ + t8_eclass_t eclass); + +/** Return the eclass of the tree in which a face neighbor of a given element + * lies. + * \param [in] forest. A committed forest. + * \param [in] ltreeid. The local tree in which the element lies. + * \param [in] elem. An element in the tree \a ltreeid. + * \param [in] face. A face number of \a elem. + * \return The local tree id of the tree in which the face + * neighbor of \a elem across \a face lies. + */ t8_eclass_t t8_forest_element_neighbor_eclass (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t - *elem, int face); - -/** Construct the face neighbor of an element, possibly across tree boundaries. - * Returns the global tree-id of the tree in which the neighbor element lies in. - * - * \param [in] elem The element to be considered. - * \param [in,out] neigh On input an allocated element of the scheme of the - * face_neighbors eclass. - * On output, this element's data is filled with the - * data of the face neighbor. If the neighbor does not exist - * the data could be modified arbitrarily. - * \param [in] neigh_scheme The eclass scheme of \a neigh. - * \param [in] face The number of the face along which the neighbor should be - * constructed. - * \param [out] neigh_face The number of the face viewed from perspective of \a neigh. - * \return The global tree-id of the tree in which \a neigh is in. - * -1 if there exists no neighbor across that face. - */ + t8_locidx_t ltreeid, + const t8_element_t + *elem, int face); + +/** Construct the face neighbor of an element, possibly across tree boundaries. + * Returns the global tree-id of the tree in which the neighbor element lies in. + * + * \param [in] elem The element to be considered. + * \param [in,out] neigh On input an allocated element of the scheme of the + * face_neighbors eclass. + * On output, this element's data is filled with the + * data of the face neighbor. If the neighbor does not exist + * the data could be modified arbitrarily. + * \param [in] neigh_scheme The eclass scheme of \a neigh. + * \param [in] face The number of the face along which the neighbor should be + * constructed. + * \param [out] neigh_face The number of the face viewed from perspective of \a neigh. + * \return The global tree-id of the tree in which \a neigh is in. + * -1 if there exists no neighbor across that face. + */ t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t + t8_locidx_t ltreeid, + const t8_element_t *elem, - t8_element_t *neigh, - t8_eclass_scheme_c - *neigh_scheme, int face, - int *neigh_face); - -/* TODO: implement */ + t8_element_t *neigh, + t8_eclass_scheme_c + *neigh_scheme, int face, + int *neigh_face); + +/* TODO: implement */ void t8_forest_iterate (t8_forest_t forest); - -/** Query whether a given point lies inside an element or not. For bilinearly interpolated elements. - * \note For 2D quadrilateral elements this function is only an approximation. It is correct - * if the four vertices lie in the same plane, but it may produce only approximate results if - * the vertices do not lie in the same plane. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \param [in] point 3-dimensional coordinates of the point to check - * \param [in] tolerance tolerance that we allow the point to not exactly match the element. - * If this value is larger we detect more points. - * If it is zero we probably do not detect points even if they are inside - * due to rounding errors. - * \return True (non-zero) if \a point lies within \a element, false otherwise. - * The return value is also true if the point lies on the element boundary. - * Thus, this function may return true for different leaf elements, if they - * are neighbors and the point lies on the common boundary. - */ + +/** Query whether a given point lies inside an element or not. For bilinearly interpolated elements. + * \note For 2D quadrilateral elements this function is only an approximation. It is correct + * if the four vertices lie in the same plane, but it may produce only approximate results if + * the vertices do not lie in the same plane. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \param [in] point 3-dimensional coordinates of the point to check + * \param [in] tolerance tolerance that we allow the point to not exactly match the element. + * If this value is larger we detect more points. + * If it is zero we probably do not detect points even if they are inside + * due to rounding errors. + * \return True (non-zero) if \a point lies within \a element, false otherwise. + * The return value is also true if the point lies on the element boundary. + * Thus, this function may return true for different leaf elements, if they + * are neighbors and the point lies on the common boundary. + */ int t8_forest_element_point_inside (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t - *element, - const double point[3], - const double tolerance); - -/* TODO: if set level and partition/adapt/balance all give NULL, then - * refine uniformly and partition/adapt/balance the unfiform forest. */ -/** Build a uniformly refined forest on a coarse mesh. - * \param [in] cmesh A coarse mesh. - * \param [in] scheme An eclass scheme. - * \param [in] level An initial uniform refinement level. - * \param [in] do_face_ghost If true, a layer of ghost elements is created for the forest. - * \param [in] comm MPI communicator to use. - * \return A uniform forest with coarse mesh \a cmesh, eclass_scheme - * \a scheme and refinement level \a level. - * \note This is equivalent to calling \ref t8_forest_init, \ref t8_forest_set_cmesh, - * \ref t8_forest_set_scheme, \ref t8_forest_set_level, and \ref t8_forest_commit. - */ + t8_locidx_t ltreeid, + const t8_element_t + *element, + const double point[3], + const double tolerance); + +/* TODO: if set level and partition/adapt/balance all give NULL, then + * refine uniformly and partition/adapt/balance the unfiform forest. */ +/** Build a uniformly refined forest on a coarse mesh. + * \param [in] cmesh A coarse mesh. + * \param [in] scheme An eclass scheme. + * \param [in] level An initial uniform refinement level. + * \param [in] do_face_ghost If true, a layer of ghost elements is created for the forest. + * \param [in] comm MPI communicator to use. + * \return A uniform forest with coarse mesh \a cmesh, eclass_scheme + * \a scheme and refinement level \a level. + * \note This is equivalent to calling \ref t8_forest_init, \ref t8_forest_set_cmesh, + * \ref t8_forest_set_scheme, \ref t8_forest_set_level, and \ref t8_forest_commit. + */ t8_forest_t t8_forest_new_uniform (t8_cmesh_t cmesh, - t8_scheme_cxx_t *scheme, - int level, int do_face_ghost, - sc_MPI_Comm comm); - -/** Build a adapted forest from another forest. - * \param [in] forest_from The forest to refine - * \param [in] adapt_fn Adapt function to use - * \param [in] replace_fn Replace function to use - * \param [in] recursive If true adptation is recursive - * \param [in] do_face_ghost If true, a layer of ghost elements is created for the forest. - * \param [in] user_data If not NULL, the user data pointer of the forest is set to this value. - * \return A new forest that is adapted from \a forest_from. - * \note This is equivalent to calling \ref t8_forest_init, \ref t8_forest_set_adapt, - * \red t8_forest_set_ghost, and \ref t8_forest_commit - */ -/* TODO: make user_data const. */ + t8_scheme_cxx_t *scheme, + int level, int do_face_ghost, + sc_MPI_Comm comm); + +/** Build a adapted forest from another forest. + * \param [in] forest_from The forest to refine + * \param [in] adapt_fn Adapt function to use + * \param [in] replace_fn Replace function to use + * \param [in] recursive If true adptation is recursive + * \param [in] do_face_ghost If true, a layer of ghost elements is created for the forest. + * \param [in] user_data If not NULL, the user data pointer of the forest is set to this value. + * \return A new forest that is adapted from \a forest_from. + * \note This is equivalent to calling \ref t8_forest_init, \ref t8_forest_set_adapt, + * \red t8_forest_set_ghost, and \ref t8_forest_commit + */ +/* TODO: make user_data const. */ t8_forest_t t8_forest_new_adapt (t8_forest_t forest_from, - t8_forest_adapt_t adapt_fn, - int recursive, int do_face_ghost, - void *user_data); - -/** Increase the reference counter of a forest. - * \param [in,out] forest On input, this forest must exist with positive - * reference count. It may be in any state. - */ + t8_forest_adapt_t adapt_fn, + int recursive, int do_face_ghost, + void *user_data); + +/** Increase the reference counter of a forest. + * \param [in,out] forest On input, this forest must exist with positive + * reference count. It may be in any state. + */ void t8_forest_ref (t8_forest_t forest); - -/** Decrease the reference counter of a forest. - * If the counter reaches zero, this forest is destroyed. - * In this case, the forest dereferences its cmesh and scheme members. - * \param [in,out] pforest On input, the forest pointed to must exist - * with positive reference count. It may be in - * any state. If the reference count reaches - * zero, the forest is destroyed and this pointer - * set to NULL. - * Otherwise, the pointer is not changed and - * the forest is not modified in other ways. - */ + +/** Decrease the reference counter of a forest. + * If the counter reaches zero, this forest is destroyed. + * In this case, the forest dereferences its cmesh and scheme members. + * \param [in,out] pforest On input, the forest pointed to must exist + * with positive reference count. It may be in + * any state. If the reference count reaches + * zero, the forest is destroyed and this pointer + * set to NULL. + * Otherwise, the pointer is not changed and + * the forest is not modified in other ways. + */ void t8_forest_unref (t8_forest_t *pforest); - T8_EXTERN_C_END (); - -#endif /* !T8_FOREST_GENERAL_H */ + T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_GENERAL_H */ diff --git a/src/t8_forest/t8_forest_geometrical.h b/src/t8_forest/t8_forest_geometrical.h index b98e6af5d8..f0a93213df 100644 --- a/src/t8_forest/t8_forest_geometrical.h +++ b/src/t8_forest/t8_forest_geometrical.h @@ -1,145 +1,145 @@ -/* - This file is part of t8code. - t8code is a C library to manage a collection (a forest) of multiple - connected adaptive space-trees of general element classes in parallel. - - Copyright (C) 2015 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -/** \file t8_forest_geometrical.h - * We define the geometrical queries for a forest of trees in this file. - */ - -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ - -#ifndef T8_FOREST_GEOMETRICAL_H -#define T8_FOREST_GEOMETRICAL_H - -#include -#include - T8_EXTERN_C_BEGIN (); - -/** Compute the coordinates of a given vertex of an element if a geometry - * for this tree is registered in the forest's cmesh. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \param [in] corner_number The corner number, in Z-order, of the vertex which should be computed. - * \param [out] coordinates On input an allocated array to store 3 doubles, on output - * the x, y and z coordinates of the vertex. - */ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** \file t8_forest_geometrical.h + * We define the geometrical queries for a forest of trees in this file. + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + +#ifndef T8_FOREST_GEOMETRICAL_H +#define T8_FOREST_GEOMETRICAL_H + +#include +#include + T8_EXTERN_C_BEGIN (); + +/** Compute the coordinates of a given vertex of an element if a geometry + * for this tree is registered in the forest's cmesh. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \param [in] corner_number The corner number, in Z-order, of the vertex which should be computed. + * \param [out] coordinates On input an allocated array to store 3 doubles, on output + * the x, y and z coordinates of the vertex. + */ void t8_forest_element_coordinate (t8_forest_t forest, - t8_locidx_t ltree_id, - const t8_element_t + t8_locidx_t ltree_id, + const t8_element_t *element, - int corner_number, - double *coordinates); - -/** Compute the coordinates of the centroid of an element if a geometry - * for this tree is registered in the forest's cmesh. - * The centroid is the sum of all corner vertices divided by the number of corners. - * The centroid can be seen as the midpoint of an element and thus can for example be used - * to compute level-set values or the distance between two elements. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \param [out] coordinates On input an allocated array to store 3 doubles, on output - * the x, y and z coordinates of the centroid. - */ + int corner_number, + double *coordinates); + +/** Compute the coordinates of the centroid of an element if a geometry + * for this tree is registered in the forest's cmesh. + * The centroid is the sum of all corner vertices divided by the number of corners. + * The centroid can be seen as the midpoint of an element and thus can for example be used + * to compute level-set values or the distance between two elements. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \param [out] coordinates On input an allocated array to store 3 doubles, on output + * the x, y and z coordinates of the centroid. + */ void t8_forest_element_centroid (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *element, - double *coordinates); - -/** Compute the diameter of an element if a geometry - * for this tree is registered in the forest's cmesh. - * This is only an approximation. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \return The diameter of the element. - * \note For lines the value is exact while for other element types it is only - * an approximation. - */ + t8_locidx_t ltreeid, + const t8_element_t *element, + double *coordinates); + +/** Compute the diameter of an element if a geometry + * for this tree is registered in the forest's cmesh. + * This is only an approximation. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \return The diameter of the element. + * \note For lines the value is exact while for other element types it is only + * an approximation. + */ double t8_forest_element_diam (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *element); - -/** Compute the volume of an element if a geometry - * for this tree is registered in the forest's cmesh. - * This is only an approximation. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \return The diameter of the element. - * \note This function assumes d-linear interpolation for the - * tree vertex coordinates. - * \a forest must be committed when calling this function. - */ + t8_locidx_t ltreeid, + const t8_element_t *element); + +/** Compute the volume of an element if a geometry + * for this tree is registered in the forest's cmesh. + * This is only an approximation. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \return The diameter of the element. + * \note This function assumes d-linear interpolation for the + * tree vertex coordinates. + * \a forest must be committed when calling this function. + */ double t8_forest_element_volume (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *element); - -/** Compute the area of an element's face if a geometry - * for this tree is registered in the forest's cmesh. - * Currently implemented for 2D elements only. - * This is only an approximation. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \param [in] face A face of \a element. - * \return The area of \a face. - * \a forest must be committed when calling this function. - */ + t8_locidx_t ltreeid, + const t8_element_t *element); + +/** Compute the area of an element's face if a geometry + * for this tree is registered in the forest's cmesh. + * Currently implemented for 2D elements only. + * This is only an approximation. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \param [in] face A face of \a element. + * \return The area of \a face. + * \a forest must be committed when calling this function. + */ double t8_forest_element_face_area (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t *element, - int face); - -/** Compute the vertex coordinates of the centroid of an element's face if a geometry - * for this tree is registered in the forest's cmesh. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \param [in] face A face of \a element. - * \param [out] normal On output the centroid of \a face. - * \a forest must be committed when calling this function. - */ + t8_locidx_t ltreeid, + const t8_element_t *element, + int face); + +/** Compute the vertex coordinates of the centroid of an element's face if a geometry + * for this tree is registered in the forest's cmesh. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \param [in] face A face of \a element. + * \param [out] normal On output the centroid of \a face. + * \a forest must be committed when calling this function. + */ void t8_forest_element_face_centroid (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t - *element, int face, - double centroid[3]); - -/** Compute the normal vector of an element's face if a geometry - * for this tree is registered in the forest's cmesh. - * Currently implemented for 2D elements only. - * \param [in] forest The forest. - * \param [in] ltree_id The forest local id of the tree in which the element is. - * \param [in] element The element. - * \param [in] face A face of \a element. - * \param [out] normal On output the normal vector of \a element at \a face. - * \a forest must be committed when calling this function. - */ + t8_locidx_t ltreeid, + const t8_element_t + *element, int face, + double centroid[3]); + +/** Compute the normal vector of an element's face if a geometry + * for this tree is registered in the forest's cmesh. + * Currently implemented for 2D elements only. + * \param [in] forest The forest. + * \param [in] ltree_id The forest local id of the tree in which the element is. + * \param [in] element The element. + * \param [in] face A face of \a element. + * \param [out] normal On output the normal vector of \a element at \a face. + * \a forest must be committed when calling this function. + */ void t8_forest_element_face_normal (t8_forest_t forest, - t8_locidx_t ltreeid, - const t8_element_t - *element, int face, - double normal[3]); - T8_EXTERN_C_END (); - -#endif /* !T8_FOREST_GEOMETRICAL_H */ + t8_locidx_t ltreeid, + const t8_element_t + *element, int face, + double normal[3]); + T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_GEOMETRICAL_H */ diff --git a/src/t8_forest/t8_forest_io.h b/src/t8_forest/t8_forest_io.h index 4a86ce87dd..f1689651da 100644 --- a/src/t8_forest/t8_forest_io.h +++ b/src/t8_forest/t8_forest_io.h @@ -1,105 +1,105 @@ -/* - This file is part of t8code. - t8code is a C library to manage a collection (a forest) of multiple - connected adaptive space-trees of general element classes in parallel. - - Copyright (C) 2015 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -/** \file t8_forest_general.h - * We define the forest of trees in this file. - */ - -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ - -#ifndef T8_FOREST_IO_H -#define T8_FOREST_IO_H - -/*TODO: Check if all headers are needed */ -#include -#include - T8_EXTERN_C_BEGIN (); - -/* TODO: implement */ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** \file t8_forest_general.h + * We define the forest of trees in this file. + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + +#ifndef T8_FOREST_IO_H +#define T8_FOREST_IO_H + +/*TODO: Check if all headers are needed */ +#include +#include + T8_EXTERN_C_BEGIN (); + +/* TODO: implement */ void t8_forest_save (t8_forest_t forest); - -/** Write the forest in a parallel vtu format. Extended version. - * See \ref t8_forest_write_vtk for the standard version of this function. - * Writes one master .pvtu file and each process writes in its own .vtu file. - * If linked and not otherwise specified, the VTK API is used. - * If the VTK library is not linked, an ASCII file is written. - * This may change in accordance with \a write_ghosts, \a write_curved and - * \a do_not_use_API, because the export of ghosts is not yet available with - * the VTK API and the export of curved elements is not available with the - * inbuilt function to write ASCII files. The function will for example - * still use the VTK API to satisfy \a write_curved, even if \a do_not_use_API - * is set to true. - * Forest must be committed when calling this function. - * This function is collective and must be called on each process. - * \param [in] forest The forest to write. - * \param [in] fileprefix The prefix of the files where the vtk will - * be stored. The master file is then fileprefix.pvtu - * and the process with rank r writes in the file - * fileprefix_r.vtu. - * \param [in] write_treeid If true, the global tree id is written for each element. - * \param [in] write_mpirank If true, the mpirank is written for each element. - * \param [in] write_level If true, the refinement level is written for each element. - * \param [in] write_element_id If true, the global element id is written for each element. - * \param [in] write_ghosts If true, each process additionally writes its ghost elements. - * For ghost element the treeid is -1. - * \param [in] write_curved If true, write the elements as curved element types from vtk. - * \param [in] do_not_use_API Do not use the VTK API, even if linked and available. - * \param [in] num_data Number of user defined double valued data fields to write. - * \param [in] data Array of t8_vtk_data_field_t of length \a num_data - * providing the user defined per element data. - * If scalar and vector fields are used, all scalar fields - * must come first in the array. - * \return True if successful, false if not (process local). - * See also \ref t8_forest_write_vtk . - */ + +/** Write the forest in a parallel vtu format. Extended version. + * See \ref t8_forest_write_vtk for the standard version of this function. + * Writes one master .pvtu file and each process writes in its own .vtu file. + * If linked and not otherwise specified, the VTK API is used. + * If the VTK library is not linked, an ASCII file is written. + * This may change in accordance with \a write_ghosts, \a write_curved and + * \a do_not_use_API, because the export of ghosts is not yet available with + * the VTK API and the export of curved elements is not available with the + * inbuilt function to write ASCII files. The function will for example + * still use the VTK API to satisfy \a write_curved, even if \a do_not_use_API + * is set to true. + * Forest must be committed when calling this function. + * This function is collective and must be called on each process. + * \param [in] forest The forest to write. + * \param [in] fileprefix The prefix of the files where the vtk will + * be stored. The master file is then fileprefix.pvtu + * and the process with rank r writes in the file + * fileprefix_r.vtu. + * \param [in] write_treeid If true, the global tree id is written for each element. + * \param [in] write_mpirank If true, the mpirank is written for each element. + * \param [in] write_level If true, the refinement level is written for each element. + * \param [in] write_element_id If true, the global element id is written for each element. + * \param [in] write_ghosts If true, each process additionally writes its ghost elements. + * For ghost element the treeid is -1. + * \param [in] write_curved If true, write the elements as curved element types from vtk. + * \param [in] do_not_use_API Do not use the VTK API, even if linked and available. + * \param [in] num_data Number of user defined double valued data fields to write. + * \param [in] data Array of t8_vtk_data_field_t of length \a num_data + * providing the user defined per element data. + * If scalar and vector fields are used, all scalar fields + * must come first in the array. + * \return True if successful, false if not (process local). + * See also \ref t8_forest_write_vtk . + */ int t8_forest_write_vtk_ext (t8_forest_t forest, - const char *fileprefix, - int write_treeid, - int write_mpirank, - int write_level, - int write_element_id, - int write_ghosts, - int write_curved, - int do_not_use_API, - int num_data, - t8_vtk_data_field_t *data); - -/** Write the forest in a parallel vtu format. Writes one master - * .pvtu file and each process writes in its own .vtu file. - * If linked, the VTK API is used. - * If the VTK library is not linked, an ASCII file is written. - * This function writes the forest elements, the tree id, element level, mpirank and element id as data. - * Forest must be committed when calling this function. - * This function is collective and must be called on each process. - * For more options use \ref t8_forest_write_vtk_ext - * \param [in] forest The forest to write. - * \param [in] fileprefix The prefix of the files where the vtk will - * be stored. The master file is then fileprefix.pvtu - * and the process with rank r writes in the file - * fileprefix_r.vtu. - * \return True if successful, false if not (process local). - */ + const char *fileprefix, + int write_treeid, + int write_mpirank, + int write_level, + int write_element_id, + int write_ghosts, + int write_curved, + int do_not_use_API, + int num_data, + t8_vtk_data_field_t *data); + +/** Write the forest in a parallel vtu format. Writes one master + * .pvtu file and each process writes in its own .vtu file. + * If linked, the VTK API is used. + * If the VTK library is not linked, an ASCII file is written. + * This function writes the forest elements, the tree id, element level, mpirank and element id as data. + * Forest must be committed when calling this function. + * This function is collective and must be called on each process. + * For more options use \ref t8_forest_write_vtk_ext + * \param [in] forest The forest to write. + * \param [in] fileprefix The prefix of the files where the vtk will + * be stored. The master file is then fileprefix.pvtu + * and the process with rank r writes in the file + * fileprefix_r.vtu. + * \return True if successful, false if not (process local). + */ int t8_forest_write_vtk (t8_forest_t forest, - const char *fileprefix); - T8_EXTERN_C_END (); - + const char *fileprefix); + T8_EXTERN_C_END (); + #endif /* !T8_FOREST_IO_H */ diff --git a/src/t8_forest/t8_forest_profiling.h b/src/t8_forest/t8_forest_profiling.h index 6a6950bf17..80e19d60d4 100644 --- a/src/t8_forest/t8_forest_profiling.h +++ b/src/t8_forest/t8_forest_profiling.h @@ -1,138 +1,138 @@ -/* - This file is part of t8code. - t8code is a C library to manage a collection (a forest) of multiple - connected adaptive space-trees of general element classes in parallel. - - Copyright (C) 2015 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -/** \file t8_forest_profiling.h - * We define the forest of trees in this file. - */ - -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ - -#ifndef T8_FOREST_PROFILING_H -#define T8_FOREST_PROFILING_H - -/*TODO: Check if all headers are needed */ -#include -#include - T8_EXTERN_C_BEGIN (); - -/** Enable or disable profiling for a forest. If profiling is enabled, runtimes - * and statistics are collected during forest_commit. - * \param [in,out] forest The forest to be updated. - * \param [in] set_profiling If true, profiling will be enabled, if false - * disabled. - * - * Profiling is disabled by default. - * The forest must not be committed before calling this function. - * \see t8_forest_print_profile - */ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** \file t8_forest_profiling.h + * We define the forest of trees in this file. + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + +#ifndef T8_FOREST_PROFILING_H +#define T8_FOREST_PROFILING_H + +/*TODO: Check if all headers are needed */ +#include +#include + T8_EXTERN_C_BEGIN (); + +/** Enable or disable profiling for a forest. If profiling is enabled, runtimes + * and statistics are collected during forest_commit. + * \param [in,out] forest The forest to be updated. + * \param [in] set_profiling If true, profiling will be enabled, if false + * disabled. + * + * Profiling is disabled by default. + * The forest must not be committed before calling this function. + * \see t8_forest_print_profile + */ void t8_forest_set_profiling (t8_forest_t forest, - int set_profiling); - -/* TODO: document */ + int set_profiling); + +/* TODO: document */ void t8_forest_compute_profile (t8_forest_t forest); - const sc_statinfo_t *t8_forest_profile_get_adapt_stats (t8_forest_t - forest); - const sc_statinfo_t *t8_forest_profile_get_ghost_stats (t8_forest_t - forest); - const sc_statinfo_t *t8_forest_profile_get_partition_stats (t8_forest_t - forest); - const sc_statinfo_t *t8_forest_profile_get_commit_stats (t8_forest_t - forest); - const sc_statinfo_t *t8_forest_profile_get_balance_stats (t8_forest_t - forest); - const sc_statinfo_t - *t8_forest_profile_get_balance_rounds_stats (t8_forest_t forest); - -/** Print the collected statistics from a forest profile. - * \param [in] forest The forest. - * - * \a forest must be committed before calling this function. - * \see t8_forest_set_profiling - */ + const sc_statinfo_t *t8_forest_profile_get_adapt_stats (t8_forest_t + forest); + const sc_statinfo_t *t8_forest_profile_get_ghost_stats (t8_forest_t + forest); + const sc_statinfo_t *t8_forest_profile_get_partition_stats (t8_forest_t + forest); + const sc_statinfo_t *t8_forest_profile_get_commit_stats (t8_forest_t + forest); + const sc_statinfo_t *t8_forest_profile_get_balance_stats (t8_forest_t + forest); + const sc_statinfo_t + *t8_forest_profile_get_balance_rounds_stats (t8_forest_t forest); + +/** Print the collected statistics from a forest profile. + * \param [in] forest The forest. + * + * \a forest must be committed before calling this function. + * \see t8_forest_set_profiling + */ void t8_forest_print_profile (t8_forest_t forest); - -/** Get the runtime of the last call to \ref t8_forest_adapt. - * \param [in] forest The forest. - * \return The runtime of adapt if profiling was activated. - * 0 otherwise. - * \a forest must be committed before calling this function. - * \see t8_forest_set_profiling - * \see t8_forest_set_adapt - */ + +/** Get the runtime of the last call to \ref t8_forest_adapt. + * \param [in] forest The forest. + * \return The runtime of adapt if profiling was activated. + * 0 otherwise. + * \a forest must be committed before calling this function. + * \see t8_forest_set_profiling + * \see t8_forest_set_adapt + */ double t8_forest_profile_get_adapt_time (t8_forest_t forest); - -/** Get the runtime of the last call to \ref t8_forest_partition. - * \param [in] forest The forest. - * \param [out] procs_sent On output the number of processes that this rank - * sent elements to in partition - * if profiling was activated. - * \return The runtime of partition if profiling was activated. - * 0 otherwise. - * \a forest must be committed before calling this function. - * \see t8_forest_set_profiling - * \see t8_forest_set_partition - */ + +/** Get the runtime of the last call to \ref t8_forest_partition. + * \param [in] forest The forest. + * \param [out] procs_sent On output the number of processes that this rank + * sent elements to in partition + * if profiling was activated. + * \return The runtime of partition if profiling was activated. + * 0 otherwise. + * \a forest must be committed before calling this function. + * \see t8_forest_set_profiling + * \see t8_forest_set_partition + */ double t8_forest_profile_get_partition_time (t8_forest_t forest, - int *procs_sent); - -/** Get the runtime of the last call to \ref t8_forest_balance. - * \param [in] forest The forest. - * \param [out] balance_rounts On output the number of rounds in balance - * if profiling was activated. - * \return The runtime of balance if profiling was activated. - * 0 otherwise. - * \a forest must be committed before calling this function. - * \see t8_forest_set_profiling - * \see t8_forest_set_balance - */ + int *procs_sent); + +/** Get the runtime of the last call to \ref t8_forest_balance. + * \param [in] forest The forest. + * \param [out] balance_rounts On output the number of rounds in balance + * if profiling was activated. + * \return The runtime of balance if profiling was activated. + * 0 otherwise. + * \a forest must be committed before calling this function. + * \see t8_forest_set_profiling + * \see t8_forest_set_balance + */ double t8_forest_profile_get_balance_time (t8_forest_t forest, - int + int *balance_rounds); - -/** Get the runtime of the last call to \ref t8_forest_create_ghosts. - * \param [in] forest The forest. - * \param [out] ghosts_sent On output the number of ghost elements sent to other processes - * if profiling was activated. - * \return The runtime of ghost if profiling was activated. - * 0 otherwise. - * \a forest must be committed before calling this function. - * \see t8_forest_set_profiling - * \see t8_forest_set_ghost - */ + +/** Get the runtime of the last call to \ref t8_forest_create_ghosts. + * \param [in] forest The forest. + * \param [out] ghosts_sent On output the number of ghost elements sent to other processes + * if profiling was activated. + * \return The runtime of ghost if profiling was activated. + * 0 otherwise. + * \a forest must be committed before calling this function. + * \see t8_forest_set_profiling + * \see t8_forest_set_ghost + */ double t8_forest_profile_get_ghost_time (t8_forest_t forest, - t8_locidx_t - *ghosts_sent); - -/** Get the waittime of the last call to \ref t8_forest_ghost_exchange_data. - * \param [in] forest The forest. - * \return The time of ghost_exchange_data that was spent waiting - * for other MPI processes, if profiling was activated. - * 0 otherwise. - * \a forest must be committed before calling this function. - * \see t8_forest_set_profiling - * \see t8_forest_ghost_exchange_data - */ + t8_locidx_t + *ghosts_sent); + +/** Get the waittime of the last call to \ref t8_forest_ghost_exchange_data. + * \param [in] forest The forest. + * \return The time of ghost_exchange_data that was spent waiting + * for other MPI processes, if profiling was activated. + * 0 otherwise. + * \a forest must be committed before calling this function. + * \see t8_forest_set_profiling + * \see t8_forest_ghost_exchange_data + */ double t8_forest_profile_get_ghostexchange_waittime (t8_forest_t - forest); - T8_EXTERN_C_END (); - -#endif /* !T8_FOREST_PROFILING_H */ + forest); + T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_PROFILING_H */ From f6cc7233bfa4f9009b62094401a574e2aba1f45f Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Tue, 25 Apr 2023 10:48:58 +0200 Subject: [PATCH 125/255] Applied intend script. --- .../forest/netcdf/t8_write_forest_netcdf.cxx | 2 +- example/advect/t8_advection.cxx | 43 ++- scripts/remove-all-if-zero-pragmas.sh | 2 +- ...e-all-windows-cariage-return-characters.sh | 4 +- src/t8_cmesh/t8_cmesh_examples.c | 4 +- src/t8_cmesh/t8_cmesh_netcdf.c | 54 +-- src/t8_cmesh/t8_cmesh_partition.c | 4 +- src/t8_cmesh/t8_cmesh_readmshfile.cxx | 13 +- src/t8_cmesh/t8_cmesh_refine.cxx | 18 +- src/t8_cmesh/t8_cmesh_triangle.c | 12 +- src/t8_forest/t8_forest.h | 12 +- src/t8_forest/t8_forest_adapt.cxx | 2 +- src/t8_forest/t8_forest_general.h | 320 +++++++++--------- src/t8_forest/t8_forest_geometrical.h | 50 +-- src/t8_forest/t8_forest_ghost.cxx | 4 +- src/t8_forest/t8_forest_io.h | 34 +- src/t8_forest/t8_forest_netcdf.cxx | 56 +-- src/t8_forest/t8_forest_partition.cxx | 6 +- src/t8_forest/t8_forest_profiling.h | 87 +++-- .../t8_geometry_occ.cxx | 2 +- src/t8_netcdf.c | 2 +- .../t8_default_common_cxx.cxx | 4 +- .../t8_default_pyramid/t8_dpyramid_bits.c | 2 +- .../t8_default_quad/t8_default_quad_cxx.cxx | 2 +- tutorials/general/t8_tutorial_search.cxx | 4 +- 25 files changed, 367 insertions(+), 376 deletions(-) diff --git a/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx b/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx index 756b8746d6..ffab6271d0 100644 --- a/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx +++ b/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx @@ -152,7 +152,7 @@ t8_example_time_netcdf_writing_operation (t8_forest_t forest, int netcdf_var_mpi_access, const char *title, int num_additional_vars, - t8_netcdf_variable_t * ext_vars[]) + t8_netcdf_variable_t *ext_vars[]) { #if T8_WITH_NETCDF_PAR double start_time, end_time, duration, global; diff --git a/example/advect/t8_advection.cxx b/example/advect/t8_advection.cxx index 4d9c85bc2f..d7fe0210b1 100644 --- a/example/advect/t8_advection.cxx +++ b/example/advect/t8_advection.cxx @@ -158,7 +158,7 @@ typedef struct * 0 <= ielement < num_elements + num_ghosts */ static double -t8_advect_element_get_phi (const t8_advect_problem_t * problem, +t8_advect_element_get_phi (const t8_advect_problem_t *problem, t8_locidx_t ielement) { return *((double *) @@ -167,7 +167,7 @@ t8_advect_element_get_phi (const t8_advect_problem_t * problem, /* Set the phi value of an element to a given entry */ static void -t8_advect_element_set_phi (const t8_advect_problem_t * problem, +t8_advect_element_set_phi (const t8_advect_problem_t *problem, t8_locidx_t ielement, double phi) { *((double *) t8_sc_array_index_locidx (problem->phi_values, ielement)) = @@ -176,7 +176,7 @@ t8_advect_element_set_phi (const t8_advect_problem_t * problem, /* Set the phi value of an element in the adapted forest to a given entry */ static void -t8_advect_element_set_phi_adapt (const t8_advect_problem_t * problem, +t8_advect_element_set_phi_adapt (const t8_advect_problem_t *problem, t8_locidx_t ielement, double phi) { *((double *) t8_sc_array_index_locidx (problem->phi_values_adapt, ielement)) @@ -242,7 +242,7 @@ t8_advect_adapt (t8_forest_t forest, t8_forest_t forest_from, /* Compute the total volume of the elements with negative phi value */ static double -t8_advect_level_set_volume (const t8_advect_problem_t * problem) +t8_advect_level_set_volume (const t8_advect_problem_t *problem) { t8_locidx_t num_local_elements, ielem; t8_advect_element_data_t *elem_data; @@ -267,7 +267,7 @@ t8_advect_level_set_volume (const t8_advect_problem_t * problem) /* Compute the relative l_infty error of the stored phi values compared to a * given analytical function at time problem->t */ static double -t8_advect_l_infty_rel (const t8_advect_problem_t * problem, +t8_advect_l_infty_rel (const t8_advect_problem_t *problem, t8_example_level_set_fn analytical_sol, double distance) { @@ -308,7 +308,7 @@ t8_advect_l_infty_rel (const t8_advect_problem_t * problem, } static double -t8_advect_l_2_rel (const t8_advect_problem_t * problem, +t8_advect_l_2_rel (const t8_advect_problem_t *problem, t8_example_level_set_fn analytical_sol, double distance) { t8_locidx_t num_local_elements, ielem, count = 0; @@ -350,7 +350,7 @@ t8_advect_l_2_rel (const t8_advect_problem_t * problem, } static double -t8_advect_flux_upwind_1d (const t8_advect_problem_t * problem, +t8_advect_flux_upwind_1d (const t8_advect_problem_t *problem, const t8_locidx_t el_plus, const t8_locidx_t el_minus, int face) { @@ -397,7 +397,7 @@ t8_advect_flux_upwind_1d (const t8_advect_problem_t * problem, /* This works also if element_plus hangs on element_minus. * It does not work if it hangs the other way around. */ static double -t8_advect_flux_upwind (const t8_advect_problem_t * problem, +t8_advect_flux_upwind (const t8_advect_problem_t *problem, double el_plus_phi, double el_minus_phi, t8_locidx_t ltreeid, @@ -452,7 +452,7 @@ t8_advect_flux_upwind (const t8_advect_problem_t * problem, */ int a = 0; static double -t8_advect_flux_upwind_hanging (const t8_advect_problem_t * problem, +t8_advect_flux_upwind_hanging (const t8_advect_problem_t *problem, t8_locidx_t iel_hang, t8_locidx_t ltreeid, t8_element_t *element_hang, @@ -536,7 +536,7 @@ t8_advect_flux_upwind_hanging (const t8_advect_problem_t * problem, * We currently set the phi value * to the value of the element itself. */ static void -t8_advect_boundary_set_phi (const t8_advect_problem_t * problem, +t8_advect_boundary_set_phi (const t8_advect_problem_t *problem, t8_locidx_t ielement, double *boundary_phi) { @@ -544,8 +544,7 @@ t8_advect_boundary_set_phi (const t8_advect_problem_t * problem, } static void -t8_advect_advance_element (t8_advect_problem_t * problem, - t8_locidx_t lelement) +t8_advect_advance_element (t8_advect_problem_t *problem, t8_locidx_t lelement) { int iface, ineigh; double flux_sum = 0; @@ -572,8 +571,8 @@ t8_advect_advance_element (t8_advect_problem_t * problem, /* Compute element midpoint and vol and store at element_data field. */ static void -t8_advect_compute_element_data (t8_advect_problem_t * problem, - t8_advect_element_data_t * elem_data, +t8_advect_compute_element_data (t8_advect_problem_t *problem, + t8_advect_element_data_t *elem_data, t8_element_t *element, t8_locidx_t ltreeid, t8_eclass_scheme_c *ts) { @@ -715,7 +714,7 @@ t8_advect_replace (t8_forest_t forest_old, } static void -t8_advect_problem_elements_destroy (t8_advect_problem_t * problem) +t8_advect_problem_elements_destroy (t8_advect_problem_t *problem) { t8_locidx_t lelement, num_local_elem; @@ -748,7 +747,7 @@ t8_advect_problem_elements_destroy (t8_advect_problem_t * problem) /* Adapt the forest and interpolate the phi values to the new grid, * compute the new u values on the grid */ static void -t8_advect_problem_adapt (t8_advect_problem_t * problem, int measure_time) +t8_advect_problem_adapt (t8_advect_problem_t *problem, int measure_time) { t8_locidx_t num_elems_p_ghosts, num_elems; double adapt_time, balance_time = 0, ghost_time; @@ -847,7 +846,7 @@ t8_advect_problem_adapt (t8_advect_problem_t * problem, int measure_time) /* Re-partition the forest and element data of a problem */ static void -t8_advect_problem_partition (t8_advect_problem_t * problem, int measure_time) +t8_advect_problem_partition (t8_advect_problem_t *problem, int measure_time) { t8_forest_t forest_partition; sc_array_t data_view, data_view_new, phi_view, phi_view_new; @@ -1062,7 +1061,7 @@ t8_advect_problem_init (t8_cmesh_t cmesh, /* Project the solution at the last time step to the forest. * Also set the fluxes to invalid */ static void -t8_advect_project_element_data (t8_advect_problem_t * problem) +t8_advect_project_element_data (t8_advect_problem_t *problem) { t8_locidx_t num_local_elements, ielem; t8_advect_element_data_t *elem_data; @@ -1086,7 +1085,7 @@ t8_advect_project_element_data (t8_advect_problem_t * problem) } static void -t8_advect_problem_init_elements (t8_advect_problem_t * problem) +t8_advect_problem_init_elements (t8_advect_problem_t *problem) { t8_locidx_t itree, ielement, idata; t8_locidx_t num_trees, num_elems_in_tree; @@ -1190,7 +1189,7 @@ t8_advect_problem_init_elements (t8_advect_problem_t * problem) } static void -t8_advect_write_vtk (t8_advect_problem_t * problem) +t8_advect_write_vtk (t8_advect_problem_t *problem) { double *u_and_phi_array[4], u_temp[3]; t8_locidx_t num_local_elements, ielem; @@ -1260,7 +1259,7 @@ t8_advect_write_vtk (t8_advect_problem_t * problem) #ifdef T8_ENABLE_DEBUG static void -t8_advect_print_phi (t8_advect_problem_t * problem) +t8_advect_print_phi (t8_advect_problem_t *problem) { t8_locidx_t ielement; t8_locidx_t num_local_els; @@ -1283,7 +1282,7 @@ t8_advect_print_phi (t8_advect_problem_t * problem) #endif static void -t8_advect_problem_destroy (t8_advect_problem_t ** pproblem) +t8_advect_problem_destroy (t8_advect_problem_t **pproblem) { t8_advect_problem_t *problem; diff --git a/scripts/remove-all-if-zero-pragmas.sh b/scripts/remove-all-if-zero-pragmas.sh index 7239dbb24d..af1dd2223f 100755 --- a/scripts/remove-all-if-zero-pragmas.sh +++ b/scripts/remove-all-if-zero-pragmas.sh @@ -32,4 +32,4 @@ # Usage: ./scripts/remove-all-if-zero-pragmas.sh # -grep -r -i -l -E '^\s*#\s*if\s+0' src/ tutorials/ example/ | xargs unifdef -k -m +grep -r -i -l -E '^\s*#\s*if\s+0' src/ tutorials/ example/ test/ | xargs unifdef -k -m diff --git a/scripts/remove-all-windows-cariage-return-characters.sh b/scripts/remove-all-windows-cariage-return-characters.sh index 8b3b475e6f..eb78b5741a 100755 --- a/scripts/remove-all-windows-cariage-return-characters.sh +++ b/scripts/remove-all-windows-cariage-return-characters.sh @@ -22,8 +22,8 @@ # Usage # # Search and remove all Windows(TM) cariage return characters '\r' from C/C++ -# source files in 'src', 'tutorials', and 'test' directories. Usually, these +# source files in source code directories. Usually, these # characters are visible as '^M' characters and are introduced by misconfigured # source code editors on Windows(TM). -grep -R -l $'\r' src tutorials test | xargs -r -l1 perl -i -p -e 's/\r//g' +grep -R -l $'\r' src tutorials example test | xargs -r -l1 perl -i -p -e 's/\r//g' diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index c6ab38b4ac..c3c5c5f5e1 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -150,14 +150,14 @@ t8_cmesh_new_from_p4est_ext (void *conn, int dim, } t8_cmesh_t -t8_cmesh_new_from_p4est (p4est_connectivity_t * conn, +t8_cmesh_new_from_p4est (p4est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition) { return t8_cmesh_new_from_p4est_ext (conn, 2, comm, do_partition, 0); } t8_cmesh_t -t8_cmesh_new_from_p8est (p8est_connectivity_t * conn, +t8_cmesh_new_from_p8est (p8est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition) { return t8_cmesh_new_from_p4est_ext (conn, 3, comm, do_partition, 0); diff --git a/src/t8_cmesh/t8_cmesh_netcdf.c b/src/t8_cmesh/t8_cmesh_netcdf.c index 05f42cb82f..614679e4fe 100644 --- a/src/t8_cmesh/t8_cmesh_netcdf.c +++ b/src/t8_cmesh/t8_cmesh_netcdf.c @@ -97,8 +97,8 @@ typedef struct /* The UGRID conventions are applied for dimension and variable descriptions */ static void -t8_cmesh_init_ugrid_namespace_context (t8_cmesh_netcdf_ugrid_namespace_t * - namespace_conv, int dim) +t8_cmesh_init_ugrid_namespace_context (t8_cmesh_netcdf_ugrid_namespace_t + *namespace_conv, int dim) { if (dim == 2) { namespace_conv->mesh = "Mesh2"; @@ -138,10 +138,10 @@ t8_cmesh_init_ugrid_namespace_context (t8_cmesh_netcdf_ugrid_namespace_t * /* Define NetCDF-coordinate-dimension */ static void -t8_cmesh_write_netcdf_coordinate_dimension (t8_cmesh_netcdf_context_t * - context, +t8_cmesh_write_netcdf_coordinate_dimension (t8_cmesh_netcdf_context_t + *context, t8_cmesh_netcdf_ugrid_namespace_t - * namespace_context) + *namespace_context) { #if T8_WITH_NETCDF /* Define dimension: number of nodes */ @@ -156,10 +156,10 @@ t8_cmesh_write_netcdf_coordinate_dimension (t8_cmesh_netcdf_context_t * /* Define NetCDF-coordinate-variables */ static void -t8_cmesh_write_netcdf_coordinate_variables (t8_cmesh_netcdf_context_t * - context, +t8_cmesh_write_netcdf_coordinate_variables (t8_cmesh_netcdf_context_t + *context, t8_cmesh_netcdf_ugrid_namespace_t - * namespace_context) + *namespace_context) { #if T8_WITH_NETCDF /* Define the Mesh_node_x variable. */ @@ -309,9 +309,9 @@ t8_cmesh_write_netcdf_coordinate_variables (t8_cmesh_netcdf_context_t * /* Define NetCDF-dimesnions */ static void -t8_cmesh_write_netcdf_dimensions (t8_cmesh_netcdf_context_t * context, - t8_cmesh_netcdf_ugrid_namespace_t * - namespace_context) +t8_cmesh_write_netcdf_dimensions (t8_cmesh_netcdf_context_t *context, + t8_cmesh_netcdf_ugrid_namespace_t + *namespace_context) { #if T8_WITH_NETCDF /* *Define dimensions in the NetCDF file.* */ @@ -343,9 +343,9 @@ t8_cmesh_write_netcdf_dimensions (t8_cmesh_netcdf_context_t * context, /* Define NetCDF-variables */ static void -t8_cmesh_write_netcdf_variables (t8_cmesh_netcdf_context_t * context, - t8_cmesh_netcdf_ugrid_namespace_t * - namespace_context) +t8_cmesh_write_netcdf_variables (t8_cmesh_netcdf_context_t *context, + t8_cmesh_netcdf_ugrid_namespace_t + *namespace_context) { #if T8_WITH_NETCDF /* *Define variables in the NetCDF file.* */ @@ -580,11 +580,11 @@ t8_cmesh_write_netcdf_variables (t8_cmesh_netcdf_context_t * context, /* Declare the user-defined elementwise NetCDF-variables which were passed to function. */ static void -t8_cmesh_write_user_netcdf_vars (t8_cmesh_netcdf_context_t * context, - t8_cmesh_netcdf_ugrid_namespace_t * - namespace_context, +t8_cmesh_write_user_netcdf_vars (t8_cmesh_netcdf_context_t *context, + t8_cmesh_netcdf_ugrid_namespace_t + *namespace_context, int num_extern_netcdf_vars, - t8_netcdf_variable_t * ext_variables[], + t8_netcdf_variable_t *ext_variables[], sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -672,7 +672,7 @@ t8_cmesh_write_user_netcdf_vars (t8_cmesh_netcdf_context_t * context, /* Write NetCDF-coordinate data */ static void t8_cmesh_write_netcdf_coordinate_data (t8_cmesh_t cmesh, - t8_cmesh_netcdf_context_t * context, + t8_cmesh_netcdf_context_t *context, sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -800,7 +800,7 @@ t8_cmesh_write_netcdf_coordinate_data (t8_cmesh_t cmesh, static void t8_cmesh_write_netcdf_data (t8_cmesh_t cmesh, - t8_cmesh_netcdf_context_t * context, + t8_cmesh_netcdf_context_t *context, sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -873,9 +873,9 @@ t8_cmesh_write_netcdf_data (t8_cmesh_t cmesh, /* It is only possible to write exactly one value per element per variable */ static void t8_cmesh_write_user_netcdf_data (t8_cmesh_t cmesh, - t8_cmesh_netcdf_context_t * context, + t8_cmesh_netcdf_context_t *context, int num_extern_netcdf_vars, - t8_netcdf_variable_t * ext_variables[], + t8_netcdf_variable_t *ext_variables[], sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -935,10 +935,10 @@ t8_cmesh_write_user_netcdf_data (t8_cmesh_t cmesh, /* Function that creates the NetCDF-File and fills it */ static void t8_cmesh_write_netcdf_file (t8_cmesh_t cmesh, - t8_cmesh_netcdf_context_t * context, - t8_cmesh_netcdf_ugrid_namespace_t * - namespace_context, int num_extern_netcdf_vars, - t8_netcdf_variable_t * ext_variables[], + t8_cmesh_netcdf_context_t *context, + t8_cmesh_netcdf_ugrid_namespace_t + *namespace_context, int num_extern_netcdf_vars, + t8_netcdf_variable_t *ext_variables[], sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -1063,7 +1063,7 @@ void t8_cmesh_write_netcdf (t8_cmesh_t cmesh, const char *file_prefix, const char *file_title, int dim, int num_extern_netcdf_vars, - t8_netcdf_variable_t * ext_variables[], + t8_netcdf_variable_t *ext_variables[], sc_MPI_Comm comm) { t8_cmesh_netcdf_context_t context; diff --git a/src/t8_cmesh/t8_cmesh_partition.c b/src/t8_cmesh/t8_cmesh_partition.c index 657586dc62..8922fb4e38 100644 --- a/src/t8_cmesh/t8_cmesh_partition.c +++ b/src/t8_cmesh/t8_cmesh_partition.c @@ -1103,7 +1103,7 @@ t8_cmesh_partition_sendloop (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, int *send_last, char ***send_buffer, char **my_buffer, size_t *my_buffer_bytes, - sc_MPI_Request ** requests, sc_MPI_Comm comm) + sc_MPI_Request **requests, sc_MPI_Comm comm) { size_t attr_bytes = 0, tree_neighbor_bytes, ghost_neighbor_bytes, attr_info_bytes, ghost_attribute_bytes, @@ -1364,7 +1364,7 @@ t8_cmesh_partition_sendloop (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, void t8_cmesh_partition_receive_message (t8_cmesh_t cmesh, sc_MPI_Comm comm, - int proc_recv, sc_MPI_Status * status, + int proc_recv, sc_MPI_Status *status, int *local_procid, int recv_first, t8_locidx_t *num_ghosts) { diff --git a/src/t8_cmesh/t8_cmesh_readmshfile.cxx b/src/t8_cmesh/t8_cmesh_readmshfile.cxx index fc183ffa0e..47c6ca26ef 100644 --- a/src/t8_cmesh/t8_cmesh_readmshfile.cxx +++ b/src/t8_cmesh/t8_cmesh_readmshfile.cxx @@ -254,7 +254,7 @@ t8_cmesh_check_version_of_msh_file (FILE *fp) /* Read an open .msh file of version 2 and parse the nodes into a hash table. */ static sc_hash_t * t8_msh_file_2_read_nodes (FILE *fp, t8_locidx_t *num_nodes, - sc_mempool_t ** node_mempool) + sc_mempool_t **node_mempool) { t8_msh_file_node_t *Node; sc_hash_t *node_table = NULL; @@ -357,8 +357,7 @@ t8_msh_file_2_read_nodes (FILE *fp, t8_locidx_t *num_nodes, /* Read an open .msh file of version 4 and parse the nodes into a hash table. */ static sc_hash_t * t8_msh_file_4_read_nodes (FILE *fp, - t8_locidx_t *num_nodes, - sc_mempool_t ** node_mempool) + t8_locidx_t *num_nodes, sc_mempool_t **node_mempool) { t8_msh_file_node_parametric_t *Node; sc_hash_t *node_table = NULL; @@ -535,7 +534,7 @@ t8_msh_file_4_read_nodes (FILE *fp, * They are stored as arrays of long ints. */ static int t8_cmesh_msh_file_2_read_eles (t8_cmesh_t cmesh, FILE *fp, - sc_hash_t * vertices, + sc_hash_t *vertices, sc_array_t **vertex_indices, int dim) { char *line = (char *) malloc (1024), *line_modify; @@ -743,7 +742,7 @@ t8_cmesh_msh_file_2_read_eles (t8_cmesh_t cmesh, FILE *fp, * is not committed yet. */ static int t8_cmesh_msh_file_4_read_eles (t8_cmesh_t cmesh, FILE *fp, - sc_hash_t * vertices, + sc_hash_t *vertices, sc_array_t **vertex_indices, int dim, const t8_geometry_c *linear_geometry_base, @@ -1599,8 +1598,8 @@ t8_msh_file_face_set_boundary (void **face, const void *data) /* Given two faces and the classes of their volume trees, * compute the orientation of the faces to each other */ static int -t8_msh_file_face_orientation (t8_msh_file_face_t * Face_a, - t8_msh_file_face_t * Face_b, +t8_msh_file_face_orientation (t8_msh_file_face_t *Face_a, + t8_msh_file_face_t *Face_b, t8_eclass_t tree_class_a, t8_eclass_t tree_class_b) { diff --git a/src/t8_cmesh/t8_cmesh_refine.cxx b/src/t8_cmesh/t8_cmesh_refine.cxx index 5af37ee652..d27521c043 100644 --- a/src/t8_cmesh/t8_cmesh_refine.cxx +++ b/src/t8_cmesh/t8_cmesh_refine.cxx @@ -51,7 +51,7 @@ typedef struct * We store an additional entry with child_id = -1 at the end, so that * this search terminates when the entry is not found. */ static t8_locidx_t -t8_cmesh_refine_childid_to_localid (t8_child_id_to_local_id ** idarray, +t8_cmesh_refine_childid_to_localid (t8_child_id_to_local_id **idarray, t8_locidx_t lparent_id, int8_t child_id) { int ichild; @@ -85,7 +85,7 @@ t8_cmesh_refine_init_idarray (t8_cmesh_t cmesh_from) * their local ids. */ static t8_locidx_t -t8_cmesh_refine_fill_idarray (t8_child_id_to_local_id ** idarray, +t8_cmesh_refine_fill_idarray (t8_child_id_to_local_id **idarray, t8_locidx_t gparent_id, int8_t child_counted[10], int num_children, t8_locidx_t next_local_id) @@ -113,7 +113,7 @@ t8_cmesh_refine_fill_idarray (t8_child_id_to_local_id ** idarray, } static void -t8_cmesh_refine_destroy_idarray (t8_child_id_to_local_id ** idarray, +t8_cmesh_refine_destroy_idarray (t8_child_id_to_local_id **idarray, t8_locidx_t num_parent_ghosts) { t8_locidx_t lghost; @@ -131,7 +131,7 @@ t8_cmesh_refine_destroy_idarray (t8_child_id_to_local_id ** idarray, static t8_locidx_t t8_cmesh_refine_new_neighborid (t8_cmesh_t cmesh_from, t8_locidx_t parent_id, int child_id, - t8_child_id_to_local_id ** id_array, + t8_child_id_to_local_id **id_array, int factor) { if (parent_id >= cmesh_from->num_local_trees) { @@ -172,7 +172,7 @@ static void t8_cmesh_refine_new_neighbors (t8_cmesh_t cmesh_from, t8_locidx_t parent_id, t8_gloidx_t global_parent_id, t8_eclass_t eclass, - t8_child_id_to_local_id ** id_array, + t8_child_id_to_local_id **id_array, int child_id, t8_locidx_t *neighbor_out, t8_gloidx_t *neighbor_out_ghost, @@ -566,7 +566,7 @@ t8_cmesh_refine_inittree (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, */ static void t8_cmesh_refine_tree (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, - t8_child_id_to_local_id ** id_array, + t8_child_id_to_local_id **id_array, t8_locidx_t treeid, t8_locidx_t firstnewtree, int factor) { @@ -622,7 +622,7 @@ t8_cmesh_refine_tree (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, * faces of the ghost connected to local trees. */ static void t8_cmesh_refine_initghost (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, - t8_child_id_to_local_id ** idarray, + t8_child_id_to_local_id **idarray, t8_locidx_t ghostid, int factor) { t8_cghost_t ghost, newghost; @@ -657,7 +657,7 @@ t8_cmesh_refine_initghost (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, static void t8_cmesh_refine_ghost (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, - t8_child_id_to_local_id ** idarray, + t8_child_id_to_local_id **idarray, t8_locidx_t ghostid, int factor) { t8_cghost_t newghost; @@ -686,7 +686,7 @@ t8_cmesh_refine_ghost (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, static t8_locidx_t t8_cmesh_refine_count_ghost (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, - t8_child_id_to_local_id ** idarray) + t8_child_id_to_local_id **idarray) { t8_cghost_t ghost; t8_gloidx_t *face_neighbor, neighbor; diff --git a/src/t8_cmesh/t8_cmesh_triangle.c b/src/t8_cmesh/t8_cmesh_triangle.c index 27cd2972fa..ad96a49fc2 100644 --- a/src/t8_cmesh/t8_cmesh_triangle.c +++ b/src/t8_cmesh/t8_cmesh_triangle.c @@ -559,9 +559,9 @@ static t8_cmesh_t t8_cmesh_from_tetgen_or_triangle_file_time (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup, - int dim, sc_flopinfo_t * fi, - sc_flopinfo_t * snapshot, - sc_statinfo_t * stats, + int dim, sc_flopinfo_t *fi, + sc_flopinfo_t *snapshot, + sc_statinfo_t *stats, int statindex) { int mpirank, mpisize, mpiret; @@ -659,9 +659,9 @@ t8_cmesh_from_triangle_file (char *fileprefix, int partition, t8_cmesh_t t8_cmesh_from_tetgen_file_time (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup, - sc_flopinfo_t * fi, - sc_flopinfo_t * snapshot, - sc_statinfo_t * stats, int statentry) + sc_flopinfo_t *fi, + sc_flopinfo_t *snapshot, + sc_statinfo_t *stats, int statentry) { return t8_cmesh_from_tetgen_or_triangle_file_time (fileprefix, partition, comm, do_dup, 3, fi, diff --git a/src/t8_forest/t8_forest.h b/src/t8_forest/t8_forest.h index 61cb7aa7ae..12b0f0a0c8 100644 --- a/src/t8_forest/t8_forest.h +++ b/src/t8_forest/t8_forest.h @@ -18,18 +18,18 @@ You should have received a copy of the GNU General Public License along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - +*/ + /** \file t8_forest.h * Includes all headers based on previous t8_forest.h - */ - + */ + #ifndef T8_FOREST_H #define T8_FOREST_H - + #include #include #include #include - + #endif /* !T8_FOREST_H */ diff --git a/src/t8_forest/t8_forest_adapt.cxx b/src/t8_forest/t8_forest_adapt.cxx index 34f11d386a..a7f3c5abbb 100644 --- a/src/t8_forest/t8_forest_adapt.cxx +++ b/src/t8_forest/t8_forest_adapt.cxx @@ -133,7 +133,7 @@ static void t8_forest_adapt_refine_recursive (t8_forest_t forest, t8_locidx_t ltreeid, t8_locidx_t lelement_id, t8_eclass_scheme_c *ts, - sc_list_t * elem_list, + sc_list_t *elem_list, t8_element_array_t *telements, t8_locidx_t *num_inserted, t8_element_t **el_buffer) diff --git a/src/t8_forest/t8_forest_general.h b/src/t8_forest/t8_forest_general.h index ce8b42c6a4..d7f8c42575 100644 --- a/src/t8_forest/t8_forest_general.h +++ b/src/t8_forest/t8_forest_general.h @@ -18,44 +18,43 @@ You should have received a copy of the GNU General Public License along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - +*/ + /** \file t8_forest_general.h * We define the forest of trees in this file. - */ - -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ - + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + #ifndef T8_FOREST_GENERAL_H #define T8_FOREST_GENERAL_H - + #include #include #include - -/** Opaque pointer to a forest implementation. */ + +/** Opaque pointer to a forest implementation. */ typedef struct t8_forest *t8_forest_t; typedef struct t8_tree *t8_tree_t; - + /** This type controls, which neighbors count as ghost elements. * Currently, we support face-neighbors. Vertex and edge neighbors - * will eventually be added. */ -typedef enum -{ T8_GHOST_NONE = 0, /**< Do not create ghost layer. */ - T8_GHOST_FACES, /**< Consider all face (codimension 1) neighbors. */ - T8_GHOST_EDGES, /**< Consider all edge (codimension 2) and face neighbors. */ - T8_GHOST_VERTICES + * will eventually be added. */ +typedef enum +{ T8_GHOST_NONE = 0, /**< Do not create ghost layer. */ + T8_GHOST_FACES, /**< Consider all face (codimension 1) neighbors. */ + T8_GHOST_EDGES, /**< Consider all edge (codimension 2) and face neighbors. */ + T8_GHOST_VERTICES /**< Consider all vertex (codimension 3) and edge and face neighbors. */ - } t8_ghost_type_t; - + /** This typedef is needed as a helper construct to * properly be able to define a function that returns * a pointer to a void fun(void) function. \see t8_forest_get_user_function. - */ + */ typedef void (*t8_generic_function_pointer) (void); - T8_EXTERN_C_BEGIN (); - +T8_EXTERN_C_BEGIN (); + /** Callback function prototype to replace one set of elements with another. * * This is used by the replace routine which can be called after adapt, @@ -84,7 +83,7 @@ typedef void (*t8_generic_function_pointer) (void); * the number of family members and \a num_incoming will be 1. Else \a refine will * be 0 and \a num_outgoing and \a num_incoming will both be 1. * \see t8_forest_iterate_replace - */ + */ typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t which_tree, @@ -93,7 +92,7 @@ typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, t8_locidx_t first_outgoing, int num_incoming, t8_locidx_t first_incoming); - + /** Callback function prototype to decide for refining and coarsening. * If \a is_family equals 1, the first \a num_elements in \a elements * form a family and we decide whether this family should be coarsened @@ -113,9 +112,9 @@ typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, * \return greater zero if the first entry in \a elements should be refined, * smaller zero if the family \a elements shall be coarsened, * zero else. - */ + */ /* TODO: Do we really need the forest argument? Since the forest is not committed yet it - * seems dangerous to expose to the user. */ + * seems dangerous to expose to the user. */ typedef int (*t8_forest_adapt_t) (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, @@ -124,7 +123,7 @@ typedef int (*t8_forest_adapt_t) (t8_forest_t forest, const int is_family, const int num_elements, t8_element_t *elements[]); - + /** Create a new forest with reference count one. * This forest needs to be specialized with the t8_forest_set_* calls. * Currently it is manatory to either call the functions \ref @@ -135,9 +134,9 @@ typedef int (*t8_forest_adapt_t) (t8_forest_t forest, * Then it needs to be set up with \ref t8_forest_commit. * \param [in,out] pforest On input, this pointer must be non-NULL. * On return, this pointer set to the new forest. - */ + */ void t8_forest_init (t8_forest_t *pforest); - + /** Check whether a forest is not NULL, initialized and not committed. * In addition, it asserts that the forest is consistent as much as possible. * \param [in] forest This forest is examined. May be NULL. @@ -145,9 +144,9 @@ void t8_forest_init (t8_forest_t *pforest); * \ref t8_forest_init has been called on it, * but not \ref t8_forest_commit. * False otherwise. - */ + */ int t8_forest_is_initialized (t8_forest_t forest); - + /** Check whether a forest is not NULL, initialized and committed. * In addition, it asserts that the forest is consistent as much as possible. * \param [in] forest This forest is examined. May be NULL. @@ -155,9 +154,9 @@ int t8_forest_is_initialized (t8_forest_t forest); * \ref t8_forest_init has been called on it * as well as \ref t8_forest_commit. * False otherwise. - */ + */ int t8_forest_is_committed (t8_forest_t forest); - + /** Check whether two committed forests have the same local elements. * \param [in] forest_a The first forest. * \param [in] forest_b The second forest. @@ -167,10 +166,10 @@ int t8_forest_is_committed (t8_forest_t forest); * for each pair of elements of \a forest_a and \a forest_b. * \note This function is not collective. It only returns the state on the current * rank. - */ + */ int t8_forest_is_equal (t8_forest_t forest_a, t8_forest_t forest_b); - + /** Set the cmesh associated to a forest. * By default, the forest takes ownership of the cmesh such that it will be * destroyed when the forest is destroyed. To keep ownership of the cmesh, @@ -180,10 +179,10 @@ int t8_forest_is_equal (t8_forest_t forest_a, * \param [in,out] forest The forest whose cmesh variable will be set. * \param [in] cmesh The cmesh to be set. We take ownership. * This can be prevented by referencing \b cmesh. - */ + */ void t8_forest_set_cmesh (t8_forest_t forest, t8_cmesh_t cmesh, sc_MPI_Comm comm); - + /** Set the element scheme associated to a forest. * By default, the forest takes ownership of the scheme such that it will be * destroyed when the forest is destroyed. To keep ownership of the scheme, call @@ -193,10 +192,10 @@ void t8_forest_set_cmesh (t8_forest_t forest, * \param [in,out] forest The forest whose scheme variable will be set. * \param [in] scheme The scheme to be set. We take ownership. * This can be prevented by referencing \b scheme. - */ + */ void t8_forest_set_scheme (t8_forest_t forest, t8_scheme_cxx_t *scheme); - + /** Set the initial refinement level to be used when \b forest is commited. * \param [in,out] forest The forest whose level will be set. * \param [in] level The initial refinement level of \b forest, when @@ -206,9 +205,9 @@ void t8_forest_set_scheme (t8_forest_t forest, * and \ref t8_forest_set_balance) and overwrites any of these settings. * If this function is used, then the forest is created from scratch as a uniform * refinement of the specified cmesh (\ref t8_forest_set_cmesh, \ref t8_forest_set_scheme). - */ + */ void t8_forest_set_level (t8_forest_t forest, int level); - + /** Set a forest as source for copying on commiting. * By default, the forest takes ownership of the source \b from such that it will * be destroyed on calling \ref t8_forest_commit. To keep ownership of \b @@ -221,10 +220,10 @@ void t8_forest_set_level (t8_forest_t forest, int level); * \note This setting cannot be combined with \ref t8_forest_set_adapt, * \ref t8_forest_set_partition, or \ref t8_forest_set_balance and overwrites these * settings. - */ + */ void t8_forest_set_copy (t8_forest_t forest, const t8_forest_t from); - + /** Set a source forest with an adapt function to be adapted on commiting. * By default, the forest takes ownership of the source \b set_from such that it * will be destroyed on calling \ref t8_forest_commit. To keep ownership of \b @@ -246,30 +245,30 @@ void t8_forest_set_copy (t8_forest_t forest, * 1) Adapt 2) Balance 3) Partition * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites * this setting. - */ -/* TODO: make recursive flag to int specifying the number of recursions? */ + */ +/* TODO: make recursive flag to int specifying the number of recursions? */ void t8_forest_set_adapt (t8_forest_t forest, const t8_forest_t set_from, t8_forest_adapt_t adapt_fn, int recursive); - + /** Set the user data of a forest. This can i.e. be used to pass user defined * arguments to the adapt routine. * \param [in,out] forest The forest * \param [in] data A pointer to user data. t8code will never touch the data. * The forest does not need be committed before calling this function. * \see t8_forest_get_user_data - */ + */ void t8_forest_set_user_data (t8_forest_t forest, void *data); - + /** Return the user data pointer associated with a forest. * \param [in] forest The forest. * \return The user data pointer of \a forest. * The forest does not need be committed before calling this function. * \see t8_forest_set_user_data - */ + */ void *t8_forest_get_user_data (t8_forest_t forest); - + /** Set the user function pointer of a forest. This can i.e. be used to pass user defined * functions to the adapt routine. * \param [in,out] forest The forest @@ -279,20 +278,19 @@ void *t8_forest_get_user_data (t8_forest_t forest); * your choice. When accessing it with \ref t8_forest_get_user_function you should cast * it into the proper type. * \see t8_forest_get_user_function - */ + */ void t8_forest_set_user_function (t8_forest_t forest, t8_generic_function_pointer - functrion); - + functrion); + /** Return the user function pointer associated with a forest. * \param [in] forest The forest. * \return The user function pointer of \a forest. * The forest does not need be committed before calling this function. * \see t8_forest_set_user_function - */ - t8_generic_function_pointer t8_forest_get_user_function (t8_forest_t - forest); - + */ +t8_generic_function_pointer t8_forest_get_user_function (t8_forest_t forest); + /** Set a source forest to be partitioned during commit. * The partitioning is done according to the SFC and each rank is assinged * the same (maybe +1) number of elements. @@ -312,11 +310,11 @@ void t8_forest_set_user_function (t8_forest_t forest, * false, it is not neccessary to call \ref t8_forest_set_partition additionally. * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites * this setting. - */ + */ void t8_forest_set_partition (t8_forest_t forest, const t8_forest_t set_from, int set_for_coarsening); - + /** Set a source forest to be balanced during commit. * A forest is said to be balanced if each element has face neighbors of level * at most +1 or -1 of the element's level. @@ -339,11 +337,11 @@ void t8_forest_set_partition (t8_forest_t forest, * 1) Adapt 2) Balance 3) Partition. * \note This setting may not be combined with \ref t8_forest_set_copy and overwrites * this setting. - */ + */ void t8_forest_set_balance (t8_forest_t forest, const t8_forest_t set_from, int no_repartition); - + /** Enable or disable the creation of a layer of ghost elements. * On default no ghosts are created. * \param [in] forest The forest. @@ -351,10 +349,10 @@ void t8_forest_set_balance (t8_forest_t forest, * \param [in] ghost_type Controls which neighbors count as ghost elements, * currently only T8_GHOST_FACES is supported. This value * is ignored if \a do_ghost = 0. - */ + */ void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type); - + /** Like \ref t8_forest_set_ghost but with the additional options to change the * ghost algorithm. This is used for debugging and timing the algorithm. * An application should almost always use \ref t8_forest_set_ghost. @@ -362,29 +360,29 @@ void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, * If 2, the iterativ algorithm for unbalanced forests. * If 3, the top-down search algorithm for unbalanced forests. * \see t8_forest_set_ghost - */ + */ void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type, int ghost_version); - + /* TODO: use assertions and document that the forest_set (..., from) and - * set_load are mutually exclusive. */ + * set_load are mutually exclusive. */ void t8_forest_set_load (t8_forest_t forest, const char *filename); - + /** Compute the global number of elements in a forest as the sum * of the local element counts. * \param [in] forest The forest. - */ + */ void t8_forest_comm_global_num_elements (t8_forest_t forest); - + /** After allocating and adding properties to a forest, commit the changes. * This call sets up the internal state of the forest. * \param [in,out] forest Must be created with \ref t8_forest_init and * specialized with t8_forest_set_* calls first. - */ + */ void t8_forest_commit (t8_forest_t forest); - + /** Return the maximum allowed refinement level for any element in a forest. * \param [in] forest A forest. * \return The maximum level of refinement that is allowed for @@ -395,41 +393,41 @@ void t8_forest_commit (t8_forest_t forest); * For forest with a single element class (non-hybrid) maxlevel is the maximum * refinement level of this element class, whilst for hybrid forests the maxlevel is * the minimum of all maxlevels of the element classes in this forest. - */ + */ int t8_forest_get_maxlevel (t8_forest_t forest); - + /** Return the number of process local elements in the forest. * \param [in] forest A forest. * \return The number of elements on this process in \a forest. * \a forest must be committed before calling this function. - */ + */ t8_locidx_t t8_forest_get_local_num_elements (t8_forest_t forest); - + /** Return the number of global elements in the forest. * \param [in] forest A forest. * \return The number of elements (summed over all processes) in \a forest. * \a forest must be committed before calling this function. - */ + */ t8_gloidx_t t8_forest_get_global_num_elements (t8_forest_t forest); - + /** Return the number of ghost elements of a forest. * \param [in] forest The forest. * \return The number of ghost elements stored in the ghost * structure of \a forest. 0 if no ghosts were constructed. * \see t8_forest_set_ghost * \a forest must be committed before calling this function. - */ + */ t8_locidx_t t8_forest_get_num_ghosts (t8_forest_t forest); - + /** Return the element class of a forest local tree. * \param [in] forest The forest. * \param [in] ltreeid The local id of a tree in \a forest. * \return The element class of the tree \a ltreeid. * \a forest must be committed before calling this function. - */ + */ t8_eclass_t t8_forest_get_eclass (t8_forest_t forest, t8_locidx_t ltreeid); - + /** Given a global tree id compute the forest local id of this tree. * If the tree is a local tree, then the local id is between 0 and the number * of local trees. If the tree is not a local tree, a negative number is returned. @@ -438,10 +436,10 @@ t8_eclass_t t8_forest_get_eclass (t8_forest_t forest, * \return The tree's local id in \a forest, if it is a local tree. * A negative number if not. * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ + */ t8_locidx_t t8_forest_get_local_id (t8_forest_t forest, t8_gloidx_t gtreeid); - + /** Given the local id of a tree in a forest, compute the tree's local id * in the associated cmesh. * \param [in] forest The forest. @@ -450,10 +448,10 @@ t8_locidx_t t8_forest_get_local_id (t8_forest_t forest, * \a forest must be committed before calling this function. * \note For forest local trees, this is the inverse function of \ref t8_forest_cmesh_ltreeid_to_ltreeid. * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ + */ t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, t8_locidx_t ltreeid); - + /** Given the local id of a tree in the coarse mesh of a forest, compute * the tree's local id in the forest. * \param [in] forest The forest. @@ -462,21 +460,20 @@ t8_locidx_t t8_forest_ltreeid_to_cmesh_ltreeid (t8_forest_t forest, * \a forest must be committed before calling this function. * \note For forest local trees, this is the inverse function of \ref t8_forest_ltreeid_to_cmesh_ltreeid. * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ + */ t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, - t8_locidx_t - lctreeid); - + t8_locidx_t lctreeid); + /** Given the local id of a tree in a forest, return the coarse tree of the * cmesh that corresponds to this tree. * \param [in] forest The forest. * \param [in] ltreeid The local id of a tree in the forest. * \return The coarse tree that matches the forest tree with local * id \a ltreeid. - */ - t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, - t8_locidx_t ltreeid); - + */ +t8_ctree_t t8_forest_get_coarse_tree (t8_forest_t forest, + t8_locidx_t ltreeid); + /** Compute the leaf face neighbors of a forest. * \param [in] forest The forest. Must have a valid ghost layer. * \param [in] ltreeid A local tree id. @@ -498,7 +495,7 @@ t8_locidx_t t8_forest_cmesh_ltreeid_to_ltreeid (t8_forest_t forest, * and *pelement_indices = NULL on output. * \note Currently \a forest must be balanced. * \note \a forest must be committed before calling this function. - */ + */ void t8_forest_leaf_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, @@ -512,7 +509,7 @@ void t8_forest_leaf_face_neighbors (t8_forest_t forest, t8_eclass_scheme_c **pneigh_scheme, int forest_is_balanced); - + /** Exchange ghost information of user defined element data. * \param[in] forest The forest. Must be committed. * \param[in] element_data An array of length num_local_elements + num_ghosts @@ -522,16 +519,16 @@ void t8_forest_leaf_face_neighbors (t8_forest_t forest, * the corresponding owning process. * \note This function is collective and hence must be called by all processes in the forest's * MPI Communicator. - */ + */ /* TODO: In \ref t8_forest_ghost_cxx we already implemented a begin and end function * that allow for overlapping communication and computation. We will make them - * available in this interface in the future. */ + * available in this interface in the future. */ void t8_forest_ghost_exchange_data (t8_forest_t forest, sc_array_t *element_data); - -/** Print the ghost structure of a forest. Only used for debugging. */ + +/** Print the ghost structure of a forest. Only used for debugging. */ void t8_forest_ghost_print (t8_forest_t forest); - + /** Change the cmesh associated to a forest to a partitioned cmesh that * is partitioned according to the tree distribution in the forest. * \param [in,out] forest The forest. @@ -540,42 +537,42 @@ void t8_forest_ghost_print (t8_forest_t forest); * \param [in] set_profiling If true, profiling for the new cmesh * will be enabled. \see t8_cmesh_set_profiling, \see t8_cmesh_print_profile * \see t8_cmesh.h - */ + */ void t8_forest_partition_cmesh (t8_forest_t forest, sc_MPI_Comm comm, int set_profiling); - + /** Return the mpi communicator associated to a forest. * \param [in] forest The forest. * \return The mpi communicator of \a forest. * \a forest must be committed before calling this function. - */ - sc_MPI_Comm t8_forest_get_mpicomm (t8_forest_t forest); - + */ +sc_MPI_Comm t8_forest_get_mpicomm (t8_forest_t forest); + /** Return the global id of the first local tree of a forest. * \param [in] forest The forest. * \return The global id of the first local tree in \a forest. - */ + */ t8_gloidx_t t8_forest_get_first_local_tree_id (t8_forest_t forest); - + /** Return the number of local trees of a given forest. * \param [in] forest The forest. * \return The number of local trees of that forest. - */ + */ t8_locidx_t t8_forest_get_num_local_trees (t8_forest_t forest); - + /** Return the number of ghost trees of a given forest. * \param [in] forest The forest. * \return The number of ghost trees of that forest. - */ + */ t8_locidx_t t8_forest_get_num_ghost_trees (t8_forest_t forest); - + /** Return the number of global trees of a given forest. * \param [in] forest The forest. * \return The number of global trees of that forest. - */ + */ t8_gloidx_t t8_forest_get_num_global_trees (t8_forest_t forest); - + /** Return the global id of a local tree or a ghost tree. * \param [in] forest The forest. * \param [in] ltreeid An id 0 <= \a ltreeid < num_local_trees + num_ghosts @@ -583,42 +580,43 @@ t8_gloidx_t t8_forest_get_num_global_trees (t8_forest_t forest); * \return The global id corresponding to the tree with local id \a ltreeid. * \a forest must be committed before calling this function. * \see https://github.com/DLR-AMR/t8code/wiki/Tree-indexing for more details about tree indexing. - */ + */ t8_gloidx_t t8_forest_global_tree_id (t8_forest_t forest, t8_locidx_t ltreeid); - + /** Return a pointer to a tree in a forest. * \param [in] forest The forest. * \param [in] ltree_id The local id of the tree. * \return A pointer to the tree with local id \a ltree_id. * \a forest must be committed before calling this function. - */ - t8_tree_t t8_forest_get_tree (t8_forest_t forest, t8_locidx_t ltree_id); - + */ +t8_tree_t t8_forest_get_tree (t8_forest_t forest, + t8_locidx_t ltree_id); + /** Return a pointer to the vertex coordinates of a tree. * \param [in] forest The forest. * \param [in] ltreeid The id of a local tree. * \return If stored, a pointer to the vertex coordinates of \a tree. * If no coordinates for this tree are found, NULL. - */ + */ double *t8_forest_get_tree_vertices (t8_forest_t forest, t8_locidx_t ltreeid); - + /** Return the array of leaf elements of a local tree in a forest. * \param [in] forest The forest. * \param [in] ltree_id The local id of a local tree of \a forest. * \return An array of t8_element_t * storing all leaf elements * of this tree. - */ + */ t8_element_array_t *t8_forest_tree_get_leafs (t8_forest_t forest, t8_locidx_t ltree_id); - + /** Return a cmesh associated to a forest. * \param [in] forest The forest. * \return The cmesh associated to the forest. - */ + */ t8_cmesh_t t8_forest_get_cmesh (t8_forest_t forest); - + /** Return an element of the forest. * \param [in] forest The forest. * \param [in] lelement_id The local id of an element in \a forest. @@ -627,11 +625,11 @@ t8_cmesh_t t8_forest_get_cmesh (t8_forest_t forest); * \return A pointer to the element. NULL if this element does not exist. * \note This function performs a binary search. For constant access, use \ref t8_forest_get_element_in_tree * \a forest must be committed before calling this function. - */ + */ t8_element_t *t8_forest_get_element (t8_forest_t forest, t8_locidx_t lelement_id, t8_locidx_t *ltreeid); - + /** Return an element of a local tree in a forest. * \param [in] forest The forest. * \param [in] ltreeid An id of a local tree in the forest. @@ -639,19 +637,19 @@ t8_element_t *t8_forest_get_element (t8_forest_t forest, * \return A pointer to the element. * \note If the tree id is know, this function should be preferred over \ref t8_forest_get_element. * \a forest must be committed before calling this function. - */ + */ t8_element_t *t8_forest_get_element_in_tree (t8_forest_t forest, t8_locidx_t ltreeid, t8_locidx_t leid_in_tree); - + /** Return the number of elements of a tree. * \param [in] forest The forest. * \param [in] ltreeid A local id of a tree. * \return The number of elements in the local tree \a ltreeid. - */ + */ t8_locidx_t t8_forest_get_tree_num_elements (t8_forest_t forest, t8_locidx_t ltreeid); - + /** Return the element offset of a local tree, that is the number of elements * in all trees with smaller local treeid. * \param [in] forest The forest. @@ -659,50 +657,50 @@ t8_locidx_t t8_forest_get_tree_num_elements (t8_forest_t forest, * \return The number of leaf elements on all local tree with * id < \a ltreeid. * \note \a forest must be committed before calling this function. - */ + */ t8_locidx_t t8_forest_get_tree_element_offset (t8_forest_t forest, t8_locidx_t ltreeid); - + /** Return the number of elements of a tree. * \param [in] tree A tree in a forest. * \return The number of elements of that tree. - */ + */ t8_locidx_t t8_forest_get_tree_element_count (t8_tree_t tree); - + /** Return the eclass of a tree in a forest. * \param [in] forest The forest. * \param [in] ltreeid The local id of a tree (local or ghost) in \a forest. * \return The element class of the tree with local id \a ltreeid. - */ + */ t8_eclass_t t8_forest_get_tree_class (t8_forest_t forest, t8_locidx_t ltreeid); - + /** Compute the global index of the first local element of a forest. * This function is collective. * \param [in] forest A committed forest, whose first element's index is computed. * \return The global index of \a forest's first local element. * Forest must be committed when calling this function. * This function is collective and must be called on each process. - */ + */ t8_gloidx_t t8_forest_get_first_local_element_id (t8_forest_t forest); - + /** Return the element scheme associated to a forest. * \param [in] forest. A committed forest. * \return The element scheme of the forest. * \see t8_forest_set_scheme - */ + */ t8_scheme_cxx_t *t8_forest_get_scheme (t8_forest_t forest); - + /** Return the eclass scheme of a given element class associated to a forest. * \param [in] forest. A committed forest. * \param [in] eclass. An element class. * \return The eclass scheme of \a eclass associated to forest. * \see t8_forest_set_scheme * \note The forest is not required to have trees of class \a eclass. - */ + */ t8_eclass_scheme_c *t8_forest_get_eclass_scheme (t8_forest_t forest, t8_eclass_t eclass); - + /** Return the eclass of the tree in which a face neighbor of a given element * lies. * \param [in] forest. A committed forest. @@ -711,12 +709,12 @@ t8_eclass_scheme_c *t8_forest_get_eclass_scheme (t8_forest_t forest, * \param [in] face. A face number of \a elem. * \return The local tree id of the tree in which the face * neighbor of \a elem across \a face lies. - */ + */ t8_eclass_t t8_forest_element_neighbor_eclass (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, int face); - + /** Construct the face neighbor of an element, possibly across tree boundaries. * Returns the global tree-id of the tree in which the neighbor element lies in. * @@ -732,7 +730,7 @@ t8_eclass_t t8_forest_element_neighbor_eclass (t8_forest_t forest, * \param [out] neigh_face The number of the face viewed from perspective of \a neigh. * \return The global tree-id of the tree in which \a neigh is in. * -1 if there exists no neighbor across that face. - */ + */ t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t @@ -741,10 +739,10 @@ t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, t8_eclass_scheme_c *neigh_scheme, int face, int *neigh_face); - -/* TODO: implement */ + +/* TODO: implement */ void t8_forest_iterate (t8_forest_t forest); - + /** Query whether a given point lies inside an element or not. For bilinearly interpolated elements. * \note For 2D quadrilateral elements this function is only an approximation. It is correct * if the four vertices lie in the same plane, but it may produce only approximate results if @@ -761,16 +759,16 @@ void t8_forest_iterate (t8_forest_t forest); * The return value is also true if the point lies on the element boundary. * Thus, this function may return true for different leaf elements, if they * are neighbors and the point lies on the common boundary. - */ + */ int t8_forest_element_point_inside (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double point[3], const double tolerance); - + /* TODO: if set level and partition/adapt/balance all give NULL, then - * refine uniformly and partition/adapt/balance the unfiform forest. */ + * refine uniformly and partition/adapt/balance the unfiform forest. */ /** Build a uniformly refined forest on a coarse mesh. * \param [in] cmesh A coarse mesh. * \param [in] scheme An eclass scheme. @@ -781,12 +779,12 @@ int t8_forest_element_point_inside (t8_forest_t forest, * \a scheme and refinement level \a level. * \note This is equivalent to calling \ref t8_forest_init, \ref t8_forest_set_cmesh, * \ref t8_forest_set_scheme, \ref t8_forest_set_level, and \ref t8_forest_commit. - */ + */ t8_forest_t t8_forest_new_uniform (t8_cmesh_t cmesh, t8_scheme_cxx_t *scheme, int level, int do_face_ghost, sc_MPI_Comm comm); - + /** Build a adapted forest from another forest. * \param [in] forest_from The forest to refine * \param [in] adapt_fn Adapt function to use @@ -797,19 +795,19 @@ t8_forest_t t8_forest_new_uniform (t8_cmesh_t cmesh, * \return A new forest that is adapted from \a forest_from. * \note This is equivalent to calling \ref t8_forest_init, \ref t8_forest_set_adapt, * \red t8_forest_set_ghost, and \ref t8_forest_commit - */ -/* TODO: make user_data const. */ + */ +/* TODO: make user_data const. */ t8_forest_t t8_forest_new_adapt (t8_forest_t forest_from, t8_forest_adapt_t adapt_fn, int recursive, int do_face_ghost, void *user_data); - + /** Increase the reference counter of a forest. * \param [in,out] forest On input, this forest must exist with positive * reference count. It may be in any state. - */ + */ void t8_forest_ref (t8_forest_t forest); - + /** Decrease the reference counter of a forest. * If the counter reaches zero, this forest is destroyed. * In this case, the forest dereferences its cmesh and scheme members. @@ -820,8 +818,8 @@ void t8_forest_ref (t8_forest_t forest); * set to NULL. * Otherwise, the pointer is not changed and * the forest is not modified in other ways. - */ + */ void t8_forest_unref (t8_forest_t *pforest); - T8_EXTERN_C_END (); - -#endif /* !T8_FOREST_GENERAL_H */ +T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_GENERAL_H */ diff --git a/src/t8_forest/t8_forest_geometrical.h b/src/t8_forest/t8_forest_geometrical.h index f0a93213df..f3493204a8 100644 --- a/src/t8_forest/t8_forest_geometrical.h +++ b/src/t8_forest/t8_forest_geometrical.h @@ -18,21 +18,21 @@ You should have received a copy of the GNU General Public License along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - +*/ + /** \file t8_forest_geometrical.h * We define the geometrical queries for a forest of trees in this file. - */ - -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ - + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + #ifndef T8_FOREST_GEOMETRICAL_H #define T8_FOREST_GEOMETRICAL_H - + #include #include - T8_EXTERN_C_BEGIN (); - +T8_EXTERN_C_BEGIN (); + /** Compute the coordinates of a given vertex of an element if a geometry * for this tree is registered in the forest's cmesh. * \param [in] forest The forest. @@ -41,14 +41,14 @@ * \param [in] corner_number The corner number, in Z-order, of the vertex which should be computed. * \param [out] coordinates On input an allocated array to store 3 doubles, on output * the x, y and z coordinates of the vertex. - */ + */ void t8_forest_element_coordinate (t8_forest_t forest, t8_locidx_t ltree_id, const t8_element_t *element, int corner_number, double *coordinates); - + /** Compute the coordinates of the centroid of an element if a geometry * for this tree is registered in the forest's cmesh. * The centroid is the sum of all corner vertices divided by the number of corners. @@ -59,12 +59,12 @@ void t8_forest_element_coordinate (t8_forest_t forest, * \param [in] element The element. * \param [out] coordinates On input an allocated array to store 3 doubles, on output * the x, y and z coordinates of the centroid. - */ + */ void t8_forest_element_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, double *coordinates); - + /** Compute the diameter of an element if a geometry * for this tree is registered in the forest's cmesh. * This is only an approximation. @@ -74,11 +74,11 @@ void t8_forest_element_centroid (t8_forest_t forest, * \return The diameter of the element. * \note For lines the value is exact while for other element types it is only * an approximation. - */ + */ double t8_forest_element_diam (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element); - + /** Compute the volume of an element if a geometry * for this tree is registered in the forest's cmesh. * This is only an approximation. @@ -89,11 +89,11 @@ double t8_forest_element_diam (t8_forest_t forest, * \note This function assumes d-linear interpolation for the * tree vertex coordinates. * \a forest must be committed when calling this function. - */ + */ double t8_forest_element_volume (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element); - + /** Compute the area of an element's face if a geometry * for this tree is registered in the forest's cmesh. * Currently implemented for 2D elements only. @@ -104,12 +104,12 @@ double t8_forest_element_volume (t8_forest_t forest, * \param [in] face A face of \a element. * \return The area of \a face. * \a forest must be committed when calling this function. - */ + */ double t8_forest_element_face_area (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face); - + /** Compute the vertex coordinates of the centroid of an element's face if a geometry * for this tree is registered in the forest's cmesh. * \param [in] forest The forest. @@ -118,13 +118,13 @@ double t8_forest_element_face_area (t8_forest_t forest, * \param [in] face A face of \a element. * \param [out] normal On output the centroid of \a face. * \a forest must be committed when calling this function. - */ + */ void t8_forest_element_face_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, double centroid[3]); - + /** Compute the normal vector of an element's face if a geometry * for this tree is registered in the forest's cmesh. * Currently implemented for 2D elements only. @@ -134,12 +134,12 @@ void t8_forest_element_face_centroid (t8_forest_t forest, * \param [in] face A face of \a element. * \param [out] normal On output the normal vector of \a element at \a face. * \a forest must be committed when calling this function. - */ + */ void t8_forest_element_face_normal (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, double normal[3]); - T8_EXTERN_C_END (); - -#endif /* !T8_FOREST_GEOMETRICAL_H */ +T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_GEOMETRICAL_H */ diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index 5271fb119b..19fc3f4b1d 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -917,7 +917,7 @@ t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, */ static t8_ghost_mpi_send_info_t * t8_forest_ghost_send_start (t8_forest_t forest, t8_forest_ghost_t ghost, - sc_MPI_Request ** requests) + sc_MPI_Request **requests) { int proc_index, remote_rank; int num_remotes; @@ -1067,7 +1067,7 @@ t8_forest_ghost_send_start (t8_forest_t forest, t8_forest_ghost_t ghost, static void t8_forest_ghost_send_end (t8_forest_t forest, t8_forest_ghost_t ghost, t8_ghost_mpi_send_info_t *send_info, - sc_MPI_Request * requests) + sc_MPI_Request *requests) { int num_remotes; int proc_pos, mpiret; diff --git a/src/t8_forest/t8_forest_io.h b/src/t8_forest/t8_forest_io.h index f1689651da..e10f3b65c9 100644 --- a/src/t8_forest/t8_forest_io.h +++ b/src/t8_forest/t8_forest_io.h @@ -18,25 +18,25 @@ You should have received a copy of the GNU General Public License along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - +*/ + /** \file t8_forest_general.h * We define the forest of trees in this file. - */ - -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ - + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + #ifndef T8_FOREST_IO_H #define T8_FOREST_IO_H - -/*TODO: Check if all headers are needed */ + +/*TODO: Check if all headers are needed */ #include #include - T8_EXTERN_C_BEGIN (); - -/* TODO: implement */ +T8_EXTERN_C_BEGIN (); + +/* TODO: implement */ void t8_forest_save (t8_forest_t forest); - + /** Write the forest in a parallel vtu format. Extended version. * See \ref t8_forest_write_vtk for the standard version of this function. * Writes one master .pvtu file and each process writes in its own .vtu file. @@ -70,7 +70,7 @@ void t8_forest_save (t8_forest_t forest); * must come first in the array. * \return True if successful, false if not (process local). * See also \ref t8_forest_write_vtk . - */ + */ int t8_forest_write_vtk_ext (t8_forest_t forest, const char *fileprefix, int write_treeid, @@ -82,7 +82,7 @@ int t8_forest_write_vtk_ext (t8_forest_t forest, int do_not_use_API, int num_data, t8_vtk_data_field_t *data); - + /** Write the forest in a parallel vtu format. Writes one master * .pvtu file and each process writes in its own .vtu file. * If linked, the VTK API is used. @@ -97,9 +97,9 @@ int t8_forest_write_vtk_ext (t8_forest_t forest, * and the process with rank r writes in the file * fileprefix_r.vtu. * \return True if successful, false if not (process local). - */ + */ int t8_forest_write_vtk (t8_forest_t forest, const char *fileprefix); - T8_EXTERN_C_END (); - +T8_EXTERN_C_END (); + #endif /* !T8_FOREST_IO_H */ diff --git a/src/t8_forest/t8_forest_netcdf.cxx b/src/t8_forest/t8_forest_netcdf.cxx index 70f1e457b8..7ef59dc959 100644 --- a/src/t8_forest/t8_forest_netcdf.cxx +++ b/src/t8_forest/t8_forest_netcdf.cxx @@ -116,8 +116,8 @@ typedef struct /* The UGRID conventions are applied for dimension and variable descriptions */ static void -t8_forest_init_ugrid_namespace_context (t8_forest_netcdf_ugrid_namespace_t * - namespace_conv, int dim) +t8_forest_init_ugrid_namespace_context (t8_forest_netcdf_ugrid_namespace_t + *namespace_conv, int dim) { if (dim == 2) { /* UGRID 2D Grid name conventions */ @@ -159,9 +159,9 @@ t8_forest_init_ugrid_namespace_context (t8_forest_netcdf_ugrid_namespace_t * /* Define NetCDF-dimesnions */ static void -t8_forest_write_netcdf_dimensions (t8_forest_netcdf_context_t * context, - t8_forest_netcdf_ugrid_namespace_t * - namespace_context) +t8_forest_write_netcdf_dimensions (t8_forest_netcdf_context_t *context, + t8_forest_netcdf_ugrid_namespace_t + *namespace_context) { #if T8_WITH_NETCDF /* *Define dimensions in the NetCDF file.* */ @@ -193,9 +193,9 @@ t8_forest_write_netcdf_dimensions (t8_forest_netcdf_context_t * context, /* Define NetCDF-variables */ static void -t8_forest_write_netcdf_variables (t8_forest_netcdf_context_t * context, - t8_forest_netcdf_ugrid_namespace_t * - namespace_context) +t8_forest_write_netcdf_variables (t8_forest_netcdf_context_t *context, + t8_forest_netcdf_ugrid_namespace_t + *namespace_context) { #if T8_WITH_NETCDF /* *Define variables in the NetCDF file.* */ @@ -424,7 +424,7 @@ t8_forest_write_netcdf_variables (t8_forest_netcdf_context_t * context, static void t8_forest_write_netcdf_data (t8_forest_t forest, - t8_forest_netcdf_context_t * context, + t8_forest_netcdf_context_t *context, sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -526,10 +526,10 @@ t8_forest_write_netcdf_data (t8_forest_t forest, /* Define NetCDF-coordinate-dimension */ static void -t8_forest_write_netcdf_coordinate_dimension (t8_forest_netcdf_context_t * - context, +t8_forest_write_netcdf_coordinate_dimension (t8_forest_netcdf_context_t + *context, t8_forest_netcdf_ugrid_namespace_t - * namespace_context) + *namespace_context) { #if T8_WITH_NETCDF /* Define dimension: number of nodes */ @@ -544,10 +544,10 @@ t8_forest_write_netcdf_coordinate_dimension (t8_forest_netcdf_context_t * /* Define NetCDF-coordinate-variables */ static void -t8_forest_write_netcdf_coordinate_variables (t8_forest_netcdf_context_t * - context, +t8_forest_write_netcdf_coordinate_variables (t8_forest_netcdf_context_t + *context, t8_forest_netcdf_ugrid_namespace_t - * namespace_context) + *namespace_context) { #if T8_WITH_NETCDF /* Define the Mesh_node_x variable. */ @@ -691,11 +691,11 @@ t8_forest_write_netcdf_coordinate_variables (t8_forest_netcdf_context_t * /* Declare the user-defined elementwise NetCDF-variables which were passed to function. */ static void -t8_forest_write_user_netcdf_vars (t8_forest_netcdf_context_t * context, - t8_forest_netcdf_ugrid_namespace_t * - namespace_context, +t8_forest_write_user_netcdf_vars (t8_forest_netcdf_context_t *context, + t8_forest_netcdf_ugrid_namespace_t + *namespace_context, int num_extern_netcdf_vars, - t8_netcdf_variable_t * ext_variables[], + t8_netcdf_variable_t *ext_variables[], sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -783,7 +783,7 @@ t8_forest_write_user_netcdf_vars (t8_forest_netcdf_context_t * context, /* Write the netCDF coordinate data to he file */ static void t8_forest_write_netcdf_coordinate_data (t8_forest_t forest, - t8_forest_netcdf_context_t * context, + t8_forest_netcdf_context_t *context, sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -951,9 +951,9 @@ t8_forest_write_netcdf_coordinate_data (t8_forest_t forest, /* It is only possible to write exactly one value per element per variable */ static void t8_forest_write_user_netcdf_data (t8_forest_t forest, - t8_forest_netcdf_context_t * context, + t8_forest_netcdf_context_t *context, int num_extern_netcdf_vars, - t8_netcdf_variable_t * ext_variables[], + t8_netcdf_variable_t *ext_variables[], sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -1017,10 +1017,10 @@ t8_forest_write_user_netcdf_data (t8_forest_t forest, /* Function that creates the NetCDF-File and fills it */ static void t8_forest_write_netcdf_file (t8_forest_t forest, - t8_forest_netcdf_context_t * context, - t8_forest_netcdf_ugrid_namespace_t * - namespace_context, int num_extern_netcdf_vars, - t8_netcdf_variable_t * ext_variables[], + t8_forest_netcdf_context_t *context, + t8_forest_netcdf_ugrid_namespace_t + *namespace_context, int num_extern_netcdf_vars, + t8_netcdf_variable_t *ext_variables[], sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -1147,7 +1147,7 @@ void t8_forest_write_netcdf_ext (t8_forest_t forest, const char *file_prefix, const char *file_title, int dim, int num_extern_netcdf_vars, - t8_netcdf_variable_t * ext_variables[], + t8_netcdf_variable_t *ext_variables[], sc_MPI_Comm comm, int netcdf_var_storage_mode, int netcdf_mpi_access) { @@ -1247,7 +1247,7 @@ void t8_forest_write_netcdf (t8_forest_t forest, const char *file_prefix, const char *file_title, int dim, int num_extern_netcdf_vars, - t8_netcdf_variable_t * ext_variables[], + t8_netcdf_variable_t *ext_variables[], sc_MPI_Comm comm) { /* Choose NC_CONTIGUOUS as default storage pattern, this is equal to 1 (defined in 'netcdf.h') */ diff --git a/src/t8_forest/t8_forest_partition.cxx b/src/t8_forest/t8_forest_partition.cxx index d2bebf638d..bb501f622b 100644 --- a/src/t8_forest/t8_forest_partition.cxx +++ b/src/t8_forest/t8_forest_partition.cxx @@ -654,7 +654,7 @@ t8_forest_partition_fill_buffer_data (t8_forest_t forest_from, * Returns true if we sent to ourselves. */ static int t8_forest_partition_sendloop (t8_forest_t forest, const int send_first, - const int send_last, sc_MPI_Request ** requests, + const int send_last, sc_MPI_Request **requests, int *num_request_alloc, char ***send_buffer, const int send_data, const sc_array_t *data_in, size_t *byte_to_self) @@ -818,7 +818,7 @@ t8_forest_partition_sendloop (t8_forest_t forest, const int send_first, */ static void t8_forest_partition_recv_message_data (t8_forest_t forest, sc_MPI_Comm comm, - int proc, sc_MPI_Status * status, + int proc, sc_MPI_Status *status, t8_locidx_t *last_loc_elem_recvd, sc_array_t *data_out, char *sent_to_self, @@ -888,7 +888,7 @@ t8_forest_partition_recv_message_data (t8_forest_t forest, sc_MPI_Comm comm, */ static void t8_forest_partition_recv_message (t8_forest_t forest, sc_MPI_Comm comm, - int proc, sc_MPI_Status * status, + int proc, sc_MPI_Status *status, int prev_recvd, char *sent_to_self, size_t byte_to_self) { diff --git a/src/t8_forest/t8_forest_profiling.h b/src/t8_forest/t8_forest_profiling.h index 80e19d60d4..acec133c5b 100644 --- a/src/t8_forest/t8_forest_profiling.h +++ b/src/t8_forest/t8_forest_profiling.h @@ -18,22 +18,22 @@ You should have received a copy of the GNU General Public License along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - +*/ + /** \file t8_forest_profiling.h * We define the forest of trees in this file. - */ - -/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ - + */ + +/* TODO: begin documenting this file: make doxygen 2>&1 | grep t8_forest */ + #ifndef T8_FOREST_PROFILING_H #define T8_FOREST_PROFILING_H - -/*TODO: Check if all headers are needed */ + +/*TODO: Check if all headers are needed */ #include #include - T8_EXTERN_C_BEGIN (); - +T8_EXTERN_C_BEGIN (); + /** Enable or disable profiling for a forest. If profiling is enabled, runtimes * and statistics are collected during forest_commit. * \param [in,out] forest The forest to be updated. @@ -43,33 +43,29 @@ * Profiling is disabled by default. * The forest must not be committed before calling this function. * \see t8_forest_print_profile - */ + */ void t8_forest_set_profiling (t8_forest_t forest, - int set_profiling); - -/* TODO: document */ + int set_profiling); + +/* TODO: document */ void t8_forest_compute_profile (t8_forest_t forest); - const sc_statinfo_t *t8_forest_profile_get_adapt_stats (t8_forest_t - forest); - const sc_statinfo_t *t8_forest_profile_get_ghost_stats (t8_forest_t - forest); - const sc_statinfo_t *t8_forest_profile_get_partition_stats (t8_forest_t - forest); - const sc_statinfo_t *t8_forest_profile_get_commit_stats (t8_forest_t +const sc_statinfo_t *t8_forest_profile_get_adapt_stats (t8_forest_t forest); +const sc_statinfo_t *t8_forest_profile_get_ghost_stats (t8_forest_t forest); +const sc_statinfo_t *t8_forest_profile_get_partition_stats (t8_forest_t forest); - const sc_statinfo_t *t8_forest_profile_get_balance_stats (t8_forest_t - forest); - const sc_statinfo_t - *t8_forest_profile_get_balance_rounds_stats (t8_forest_t forest); - +const sc_statinfo_t *t8_forest_profile_get_commit_stats (t8_forest_t forest); +const sc_statinfo_t *t8_forest_profile_get_balance_stats (t8_forest_t forest); +const sc_statinfo_t + * t8_forest_profile_get_balance_rounds_stats (t8_forest_t forest); + /** Print the collected statistics from a forest profile. * \param [in] forest The forest. * * \a forest must be committed before calling this function. * \see t8_forest_set_profiling - */ + */ void t8_forest_print_profile (t8_forest_t forest); - + /** Get the runtime of the last call to \ref t8_forest_adapt. * \param [in] forest The forest. * \return The runtime of adapt if profiling was activated. @@ -77,9 +73,9 @@ void t8_forest_print_profile (t8_forest_t forest); * \a forest must be committed before calling this function. * \see t8_forest_set_profiling * \see t8_forest_set_adapt - */ + */ double t8_forest_profile_get_adapt_time (t8_forest_t forest); - + /** Get the runtime of the last call to \ref t8_forest_partition. * \param [in] forest The forest. * \param [out] procs_sent On output the number of processes that this rank @@ -90,10 +86,10 @@ double t8_forest_profile_get_adapt_time (t8_forest_t forest); * \a forest must be committed before calling this function. * \see t8_forest_set_profiling * \see t8_forest_set_partition - */ + */ double t8_forest_profile_get_partition_time (t8_forest_t forest, - int *procs_sent); - + int *procs_sent); + /** Get the runtime of the last call to \ref t8_forest_balance. * \param [in] forest The forest. * \param [out] balance_rounts On output the number of rounds in balance @@ -103,11 +99,10 @@ double t8_forest_profile_get_partition_time (t8_forest_t forest, * \a forest must be committed before calling this function. * \see t8_forest_set_profiling * \see t8_forest_set_balance - */ + */ double t8_forest_profile_get_balance_time (t8_forest_t forest, - int - *balance_rounds); - + int *balance_rounds); + /** Get the runtime of the last call to \ref t8_forest_create_ghosts. * \param [in] forest The forest. * \param [out] ghosts_sent On output the number of ghost elements sent to other processes @@ -117,11 +112,11 @@ double t8_forest_profile_get_balance_time (t8_forest_t forest, * \a forest must be committed before calling this function. * \see t8_forest_set_profiling * \see t8_forest_set_ghost - */ + */ double t8_forest_profile_get_ghost_time (t8_forest_t forest, - t8_locidx_t - *ghosts_sent); - + t8_locidx_t + *ghosts_sent); + /** Get the waittime of the last call to \ref t8_forest_ghost_exchange_data. * \param [in] forest The forest. * \return The time of ghost_exchange_data that was spent waiting @@ -130,9 +125,9 @@ double t8_forest_profile_get_ghost_time (t8_forest_t forest, * \a forest must be committed before calling this function. * \see t8_forest_set_profiling * \see t8_forest_ghost_exchange_data - */ + */ double t8_forest_profile_get_ghostexchange_waittime (t8_forest_t - forest); - T8_EXTERN_C_END (); - -#endif /* !T8_FOREST_PROFILING_H */ + forest); +T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_PROFILING_H */ diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_occ.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_occ.cxx index b4d12e0cb7..b0497fc621 100755 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_occ.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_occ.cxx @@ -962,7 +962,7 @@ t8_geometry_occ_new (int dimension, const char *fileprefix, } void -t8_geometry_occ_destroy (t8_geometry_occ_c ** geom) +t8_geometry_occ_destroy (t8_geometry_occ_c **geom) { #ifdef T8_ENABLE_DEBUG t8_geometry_occ_c *pgeom = *geom; diff --git a/src/t8_netcdf.c b/src/t8_netcdf.c index c0002b2b68..3a6a9b385f 100644 --- a/src/t8_netcdf.c +++ b/src/t8_netcdf.c @@ -82,7 +82,7 @@ t8_netcdf_create_double_var (const char *var_name, const char *var_long_name, /* Free the memory of the allocated NetCDF variable */ void -t8_netcdf_variable_destroy (t8_netcdf_variable_t * var_destroy) +t8_netcdf_variable_destroy (t8_netcdf_variable_t *var_destroy) { T8_ASSERT (var_destroy != NULL); T8_FREE (var_destroy); diff --git a/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.cxx b/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.cxx index 5b1a64eb9f..e7e0e59406 100644 --- a/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.cxx @@ -77,7 +77,7 @@ t8_default_scheme_common_c::t8_element_destroy (int length, } static void -t8_default_mempool_alloc (sc_mempool_t * ts_context, int length, +t8_default_mempool_alloc (sc_mempool_t *ts_context, int length, t8_element_t **elem) { int i; @@ -92,7 +92,7 @@ t8_default_mempool_alloc (sc_mempool_t * ts_context, int length, } static void -t8_default_mempool_free (sc_mempool_t * ts_context, int length, +t8_default_mempool_free (sc_mempool_t *ts_context, int length, t8_element_t **elem) { int i; diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c index 6a9aabb1b6..25eecfcd78 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c @@ -502,7 +502,7 @@ t8_dpyramid_get_level (const t8_dpyramid_t *p) * \return int The local-id of the child */ static int -t8_dpyramid_update_index (t8_linearidx_t * id, const t8_dpyramid_type_t type, +t8_dpyramid_update_index (t8_linearidx_t *id, const t8_dpyramid_type_t type, const t8_linearidx_t pyra, const t8_linearidx_t tet) { t8_linearidx_t test = 0; diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx index b6e16435ec..2b0c696e75 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx @@ -62,7 +62,7 @@ t8_default_scheme_quad_c::t8_element_level (const t8_element_t *elem) const } static void -t8_element_copy_surround (const p4est_quadrant_t * q, p4est_quadrant_t * r) +t8_element_copy_surround (const p4est_quadrant_t *q, p4est_quadrant_t *r) { T8_QUAD_SET_TDIM (r, T8_QUAD_GET_TDIM (q)); if (T8_QUAD_GET_TDIM (q) == 3) { diff --git a/tutorials/general/t8_tutorial_search.cxx b/tutorials/general/t8_tutorial_search.cxx index 1f0d99cc7c..e40e72930e 100644 --- a/tutorials/general/t8_tutorial_search.cxx +++ b/tutorials/general/t8_tutorial_search.cxx @@ -233,7 +233,7 @@ t8_tutorial_search_query_callback (t8_forest_t forest, /* Write the forest to vtu files and also write the particles_per_element * data. */ static void -t8_tutorial_search_vtk (t8_forest_t forest, sc_array * particles_per_element, +t8_tutorial_search_vtk (t8_forest_t forest, sc_array *particles_per_element, const char *prefix) { /* Define the additional vtu data that we want to write. */ @@ -253,7 +253,7 @@ t8_tutorial_search_vtk (t8_forest_t forest, sc_array * particles_per_element, /* Perform the actual search and write the forest with the number of particles per element * to vtu files. */ static void -t8_tutorial_search_for_particles (t8_forest_t forest, sc_array * particles) +t8_tutorial_search_for_particles (t8_forest_t forest, sc_array *particles) { sc_array particles_per_element; t8_locidx_t num_local_elements = From 4fd2572cbbfd0aa327ddc252af16f0aee3e3821d Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Tue, 25 Apr 2023 10:51:30 +0200 Subject: [PATCH 126/255] Applied intend script. --- tutorials/general/t8_step2_uniform_forest.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorials/general/t8_step2_uniform_forest.cxx b/tutorials/general/t8_step2_uniform_forest.cxx index 49e8e2895b..97ba933282 100644 --- a/tutorials/general/t8_step2_uniform_forest.cxx +++ b/tutorials/general/t8_step2_uniform_forest.cxx @@ -48,8 +48,8 @@ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ #include /* forest definition and basic interface. */ -#include /* forest definition and general interface. */ -#include /* forest io interface. */ +#include /* forest definition and general interface. */ +#include /* forest io interface. */ #include /* default refinement scheme. */ /* Builds cmesh of 2 prisms that build up a unit cube. From bfd294677e94da2e7ddec6270cd7e101cce810a1 Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Tue, 25 Apr 2023 10:56:34 +0200 Subject: [PATCH 127/255] Removed deprecated header file line. --- tutorials/general/t8_step2_uniform_forest.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/tutorials/general/t8_step2_uniform_forest.cxx b/tutorials/general/t8_step2_uniform_forest.cxx index 97ba933282..d5b70c68c0 100644 --- a/tutorials/general/t8_step2_uniform_forest.cxx +++ b/tutorials/general/t8_step2_uniform_forest.cxx @@ -47,7 +47,6 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ #include /* A collection of exemplary cmeshes */ -#include /* forest definition and basic interface. */ #include /* forest definition and general interface. */ #include /* forest io interface. */ #include /* default refinement scheme. */ From 272a84c2b2c40d1521183ad0707fc5ff19502af5 Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Tue, 25 Apr 2023 11:03:09 +0200 Subject: [PATCH 128/255] Applying indent v2.2.12 reverting the changes from indent v2.2.13. --- .../forest/netcdf/t8_write_forest_netcdf.cxx | 2 +- example/advect/t8_advection.cxx | 43 ++++++++++--------- src/t8_cmesh/t8_cmesh_examples.c | 4 +- src/t8_cmesh/t8_cmesh_netcdf.c | 40 ++++++++--------- src/t8_cmesh/t8_cmesh_partition.c | 4 +- src/t8_cmesh/t8_cmesh_readmshfile.cxx | 13 +++--- src/t8_cmesh/t8_cmesh_refine.cxx | 18 ++++---- src/t8_cmesh/t8_cmesh_triangle.c | 12 +++--- src/t8_forest/t8_forest_adapt.cxx | 2 +- src/t8_forest/t8_forest_ghost.cxx | 4 +- src/t8_forest/t8_forest_netcdf.cxx | 42 +++++++++--------- src/t8_forest/t8_forest_partition.cxx | 6 +-- .../t8_geometry_occ.cxx | 2 +- src/t8_netcdf.c | 2 +- .../t8_default_common_cxx.cxx | 4 +- .../t8_default_pyramid/t8_dpyramid_bits.c | 2 +- .../t8_default_quad/t8_default_quad_cxx.cxx | 2 +- tutorials/general/t8_tutorial_search.cxx | 4 +- 18 files changed, 104 insertions(+), 102 deletions(-) diff --git a/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx b/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx index ffab6271d0..756b8746d6 100644 --- a/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx +++ b/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx @@ -152,7 +152,7 @@ t8_example_time_netcdf_writing_operation (t8_forest_t forest, int netcdf_var_mpi_access, const char *title, int num_additional_vars, - t8_netcdf_variable_t *ext_vars[]) + t8_netcdf_variable_t * ext_vars[]) { #if T8_WITH_NETCDF_PAR double start_time, end_time, duration, global; diff --git a/example/advect/t8_advection.cxx b/example/advect/t8_advection.cxx index d7fe0210b1..4d9c85bc2f 100644 --- a/example/advect/t8_advection.cxx +++ b/example/advect/t8_advection.cxx @@ -158,7 +158,7 @@ typedef struct * 0 <= ielement < num_elements + num_ghosts */ static double -t8_advect_element_get_phi (const t8_advect_problem_t *problem, +t8_advect_element_get_phi (const t8_advect_problem_t * problem, t8_locidx_t ielement) { return *((double *) @@ -167,7 +167,7 @@ t8_advect_element_get_phi (const t8_advect_problem_t *problem, /* Set the phi value of an element to a given entry */ static void -t8_advect_element_set_phi (const t8_advect_problem_t *problem, +t8_advect_element_set_phi (const t8_advect_problem_t * problem, t8_locidx_t ielement, double phi) { *((double *) t8_sc_array_index_locidx (problem->phi_values, ielement)) = @@ -176,7 +176,7 @@ t8_advect_element_set_phi (const t8_advect_problem_t *problem, /* Set the phi value of an element in the adapted forest to a given entry */ static void -t8_advect_element_set_phi_adapt (const t8_advect_problem_t *problem, +t8_advect_element_set_phi_adapt (const t8_advect_problem_t * problem, t8_locidx_t ielement, double phi) { *((double *) t8_sc_array_index_locidx (problem->phi_values_adapt, ielement)) @@ -242,7 +242,7 @@ t8_advect_adapt (t8_forest_t forest, t8_forest_t forest_from, /* Compute the total volume of the elements with negative phi value */ static double -t8_advect_level_set_volume (const t8_advect_problem_t *problem) +t8_advect_level_set_volume (const t8_advect_problem_t * problem) { t8_locidx_t num_local_elements, ielem; t8_advect_element_data_t *elem_data; @@ -267,7 +267,7 @@ t8_advect_level_set_volume (const t8_advect_problem_t *problem) /* Compute the relative l_infty error of the stored phi values compared to a * given analytical function at time problem->t */ static double -t8_advect_l_infty_rel (const t8_advect_problem_t *problem, +t8_advect_l_infty_rel (const t8_advect_problem_t * problem, t8_example_level_set_fn analytical_sol, double distance) { @@ -308,7 +308,7 @@ t8_advect_l_infty_rel (const t8_advect_problem_t *problem, } static double -t8_advect_l_2_rel (const t8_advect_problem_t *problem, +t8_advect_l_2_rel (const t8_advect_problem_t * problem, t8_example_level_set_fn analytical_sol, double distance) { t8_locidx_t num_local_elements, ielem, count = 0; @@ -350,7 +350,7 @@ t8_advect_l_2_rel (const t8_advect_problem_t *problem, } static double -t8_advect_flux_upwind_1d (const t8_advect_problem_t *problem, +t8_advect_flux_upwind_1d (const t8_advect_problem_t * problem, const t8_locidx_t el_plus, const t8_locidx_t el_minus, int face) { @@ -397,7 +397,7 @@ t8_advect_flux_upwind_1d (const t8_advect_problem_t *problem, /* This works also if element_plus hangs on element_minus. * It does not work if it hangs the other way around. */ static double -t8_advect_flux_upwind (const t8_advect_problem_t *problem, +t8_advect_flux_upwind (const t8_advect_problem_t * problem, double el_plus_phi, double el_minus_phi, t8_locidx_t ltreeid, @@ -452,7 +452,7 @@ t8_advect_flux_upwind (const t8_advect_problem_t *problem, */ int a = 0; static double -t8_advect_flux_upwind_hanging (const t8_advect_problem_t *problem, +t8_advect_flux_upwind_hanging (const t8_advect_problem_t * problem, t8_locidx_t iel_hang, t8_locidx_t ltreeid, t8_element_t *element_hang, @@ -536,7 +536,7 @@ t8_advect_flux_upwind_hanging (const t8_advect_problem_t *problem, * We currently set the phi value * to the value of the element itself. */ static void -t8_advect_boundary_set_phi (const t8_advect_problem_t *problem, +t8_advect_boundary_set_phi (const t8_advect_problem_t * problem, t8_locidx_t ielement, double *boundary_phi) { @@ -544,7 +544,8 @@ t8_advect_boundary_set_phi (const t8_advect_problem_t *problem, } static void -t8_advect_advance_element (t8_advect_problem_t *problem, t8_locidx_t lelement) +t8_advect_advance_element (t8_advect_problem_t * problem, + t8_locidx_t lelement) { int iface, ineigh; double flux_sum = 0; @@ -571,8 +572,8 @@ t8_advect_advance_element (t8_advect_problem_t *problem, t8_locidx_t lelement) /* Compute element midpoint and vol and store at element_data field. */ static void -t8_advect_compute_element_data (t8_advect_problem_t *problem, - t8_advect_element_data_t *elem_data, +t8_advect_compute_element_data (t8_advect_problem_t * problem, + t8_advect_element_data_t * elem_data, t8_element_t *element, t8_locidx_t ltreeid, t8_eclass_scheme_c *ts) { @@ -714,7 +715,7 @@ t8_advect_replace (t8_forest_t forest_old, } static void -t8_advect_problem_elements_destroy (t8_advect_problem_t *problem) +t8_advect_problem_elements_destroy (t8_advect_problem_t * problem) { t8_locidx_t lelement, num_local_elem; @@ -747,7 +748,7 @@ t8_advect_problem_elements_destroy (t8_advect_problem_t *problem) /* Adapt the forest and interpolate the phi values to the new grid, * compute the new u values on the grid */ static void -t8_advect_problem_adapt (t8_advect_problem_t *problem, int measure_time) +t8_advect_problem_adapt (t8_advect_problem_t * problem, int measure_time) { t8_locidx_t num_elems_p_ghosts, num_elems; double adapt_time, balance_time = 0, ghost_time; @@ -846,7 +847,7 @@ t8_advect_problem_adapt (t8_advect_problem_t *problem, int measure_time) /* Re-partition the forest and element data of a problem */ static void -t8_advect_problem_partition (t8_advect_problem_t *problem, int measure_time) +t8_advect_problem_partition (t8_advect_problem_t * problem, int measure_time) { t8_forest_t forest_partition; sc_array_t data_view, data_view_new, phi_view, phi_view_new; @@ -1061,7 +1062,7 @@ t8_advect_problem_init (t8_cmesh_t cmesh, /* Project the solution at the last time step to the forest. * Also set the fluxes to invalid */ static void -t8_advect_project_element_data (t8_advect_problem_t *problem) +t8_advect_project_element_data (t8_advect_problem_t * problem) { t8_locidx_t num_local_elements, ielem; t8_advect_element_data_t *elem_data; @@ -1085,7 +1086,7 @@ t8_advect_project_element_data (t8_advect_problem_t *problem) } static void -t8_advect_problem_init_elements (t8_advect_problem_t *problem) +t8_advect_problem_init_elements (t8_advect_problem_t * problem) { t8_locidx_t itree, ielement, idata; t8_locidx_t num_trees, num_elems_in_tree; @@ -1189,7 +1190,7 @@ t8_advect_problem_init_elements (t8_advect_problem_t *problem) } static void -t8_advect_write_vtk (t8_advect_problem_t *problem) +t8_advect_write_vtk (t8_advect_problem_t * problem) { double *u_and_phi_array[4], u_temp[3]; t8_locidx_t num_local_elements, ielem; @@ -1259,7 +1260,7 @@ t8_advect_write_vtk (t8_advect_problem_t *problem) #ifdef T8_ENABLE_DEBUG static void -t8_advect_print_phi (t8_advect_problem_t *problem) +t8_advect_print_phi (t8_advect_problem_t * problem) { t8_locidx_t ielement; t8_locidx_t num_local_els; @@ -1282,7 +1283,7 @@ t8_advect_print_phi (t8_advect_problem_t *problem) #endif static void -t8_advect_problem_destroy (t8_advect_problem_t **pproblem) +t8_advect_problem_destroy (t8_advect_problem_t ** pproblem) { t8_advect_problem_t *problem; diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index c3c5c5f5e1..c6ab38b4ac 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -150,14 +150,14 @@ t8_cmesh_new_from_p4est_ext (void *conn, int dim, } t8_cmesh_t -t8_cmesh_new_from_p4est (p4est_connectivity_t *conn, +t8_cmesh_new_from_p4est (p4est_connectivity_t * conn, sc_MPI_Comm comm, int do_partition) { return t8_cmesh_new_from_p4est_ext (conn, 2, comm, do_partition, 0); } t8_cmesh_t -t8_cmesh_new_from_p8est (p8est_connectivity_t *conn, +t8_cmesh_new_from_p8est (p8est_connectivity_t * conn, sc_MPI_Comm comm, int do_partition) { return t8_cmesh_new_from_p4est_ext (conn, 3, comm, do_partition, 0); diff --git a/src/t8_cmesh/t8_cmesh_netcdf.c b/src/t8_cmesh/t8_cmesh_netcdf.c index 614679e4fe..c8da854671 100644 --- a/src/t8_cmesh/t8_cmesh_netcdf.c +++ b/src/t8_cmesh/t8_cmesh_netcdf.c @@ -98,7 +98,7 @@ typedef struct /* The UGRID conventions are applied for dimension and variable descriptions */ static void t8_cmesh_init_ugrid_namespace_context (t8_cmesh_netcdf_ugrid_namespace_t - *namespace_conv, int dim) + * namespace_conv, int dim) { if (dim == 2) { namespace_conv->mesh = "Mesh2"; @@ -139,9 +139,9 @@ t8_cmesh_init_ugrid_namespace_context (t8_cmesh_netcdf_ugrid_namespace_t /* Define NetCDF-coordinate-dimension */ static void t8_cmesh_write_netcdf_coordinate_dimension (t8_cmesh_netcdf_context_t - *context, + * context, t8_cmesh_netcdf_ugrid_namespace_t - *namespace_context) + * namespace_context) { #if T8_WITH_NETCDF /* Define dimension: number of nodes */ @@ -157,9 +157,9 @@ t8_cmesh_write_netcdf_coordinate_dimension (t8_cmesh_netcdf_context_t /* Define NetCDF-coordinate-variables */ static void t8_cmesh_write_netcdf_coordinate_variables (t8_cmesh_netcdf_context_t - *context, + * context, t8_cmesh_netcdf_ugrid_namespace_t - *namespace_context) + * namespace_context) { #if T8_WITH_NETCDF /* Define the Mesh_node_x variable. */ @@ -309,9 +309,9 @@ t8_cmesh_write_netcdf_coordinate_variables (t8_cmesh_netcdf_context_t /* Define NetCDF-dimesnions */ static void -t8_cmesh_write_netcdf_dimensions (t8_cmesh_netcdf_context_t *context, +t8_cmesh_write_netcdf_dimensions (t8_cmesh_netcdf_context_t * context, t8_cmesh_netcdf_ugrid_namespace_t - *namespace_context) + * namespace_context) { #if T8_WITH_NETCDF /* *Define dimensions in the NetCDF file.* */ @@ -343,9 +343,9 @@ t8_cmesh_write_netcdf_dimensions (t8_cmesh_netcdf_context_t *context, /* Define NetCDF-variables */ static void -t8_cmesh_write_netcdf_variables (t8_cmesh_netcdf_context_t *context, +t8_cmesh_write_netcdf_variables (t8_cmesh_netcdf_context_t * context, t8_cmesh_netcdf_ugrid_namespace_t - *namespace_context) + * namespace_context) { #if T8_WITH_NETCDF /* *Define variables in the NetCDF file.* */ @@ -580,11 +580,11 @@ t8_cmesh_write_netcdf_variables (t8_cmesh_netcdf_context_t *context, /* Declare the user-defined elementwise NetCDF-variables which were passed to function. */ static void -t8_cmesh_write_user_netcdf_vars (t8_cmesh_netcdf_context_t *context, +t8_cmesh_write_user_netcdf_vars (t8_cmesh_netcdf_context_t * context, t8_cmesh_netcdf_ugrid_namespace_t - *namespace_context, + * namespace_context, int num_extern_netcdf_vars, - t8_netcdf_variable_t *ext_variables[], + t8_netcdf_variable_t * ext_variables[], sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -672,7 +672,7 @@ t8_cmesh_write_user_netcdf_vars (t8_cmesh_netcdf_context_t *context, /* Write NetCDF-coordinate data */ static void t8_cmesh_write_netcdf_coordinate_data (t8_cmesh_t cmesh, - t8_cmesh_netcdf_context_t *context, + t8_cmesh_netcdf_context_t * context, sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -800,7 +800,7 @@ t8_cmesh_write_netcdf_coordinate_data (t8_cmesh_t cmesh, static void t8_cmesh_write_netcdf_data (t8_cmesh_t cmesh, - t8_cmesh_netcdf_context_t *context, + t8_cmesh_netcdf_context_t * context, sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -873,9 +873,9 @@ t8_cmesh_write_netcdf_data (t8_cmesh_t cmesh, /* It is only possible to write exactly one value per element per variable */ static void t8_cmesh_write_user_netcdf_data (t8_cmesh_t cmesh, - t8_cmesh_netcdf_context_t *context, + t8_cmesh_netcdf_context_t * context, int num_extern_netcdf_vars, - t8_netcdf_variable_t *ext_variables[], + t8_netcdf_variable_t * ext_variables[], sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -935,10 +935,10 @@ t8_cmesh_write_user_netcdf_data (t8_cmesh_t cmesh, /* Function that creates the NetCDF-File and fills it */ static void t8_cmesh_write_netcdf_file (t8_cmesh_t cmesh, - t8_cmesh_netcdf_context_t *context, + t8_cmesh_netcdf_context_t * context, t8_cmesh_netcdf_ugrid_namespace_t - *namespace_context, int num_extern_netcdf_vars, - t8_netcdf_variable_t *ext_variables[], + * namespace_context, int num_extern_netcdf_vars, + t8_netcdf_variable_t * ext_variables[], sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -1063,7 +1063,7 @@ void t8_cmesh_write_netcdf (t8_cmesh_t cmesh, const char *file_prefix, const char *file_title, int dim, int num_extern_netcdf_vars, - t8_netcdf_variable_t *ext_variables[], + t8_netcdf_variable_t * ext_variables[], sc_MPI_Comm comm) { t8_cmesh_netcdf_context_t context; diff --git a/src/t8_cmesh/t8_cmesh_partition.c b/src/t8_cmesh/t8_cmesh_partition.c index 8922fb4e38..657586dc62 100644 --- a/src/t8_cmesh/t8_cmesh_partition.c +++ b/src/t8_cmesh/t8_cmesh_partition.c @@ -1103,7 +1103,7 @@ t8_cmesh_partition_sendloop (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, int *send_last, char ***send_buffer, char **my_buffer, size_t *my_buffer_bytes, - sc_MPI_Request **requests, sc_MPI_Comm comm) + sc_MPI_Request ** requests, sc_MPI_Comm comm) { size_t attr_bytes = 0, tree_neighbor_bytes, ghost_neighbor_bytes, attr_info_bytes, ghost_attribute_bytes, @@ -1364,7 +1364,7 @@ t8_cmesh_partition_sendloop (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, void t8_cmesh_partition_receive_message (t8_cmesh_t cmesh, sc_MPI_Comm comm, - int proc_recv, sc_MPI_Status *status, + int proc_recv, sc_MPI_Status * status, int *local_procid, int recv_first, t8_locidx_t *num_ghosts) { diff --git a/src/t8_cmesh/t8_cmesh_readmshfile.cxx b/src/t8_cmesh/t8_cmesh_readmshfile.cxx index 47c6ca26ef..fc183ffa0e 100644 --- a/src/t8_cmesh/t8_cmesh_readmshfile.cxx +++ b/src/t8_cmesh/t8_cmesh_readmshfile.cxx @@ -254,7 +254,7 @@ t8_cmesh_check_version_of_msh_file (FILE *fp) /* Read an open .msh file of version 2 and parse the nodes into a hash table. */ static sc_hash_t * t8_msh_file_2_read_nodes (FILE *fp, t8_locidx_t *num_nodes, - sc_mempool_t **node_mempool) + sc_mempool_t ** node_mempool) { t8_msh_file_node_t *Node; sc_hash_t *node_table = NULL; @@ -357,7 +357,8 @@ t8_msh_file_2_read_nodes (FILE *fp, t8_locidx_t *num_nodes, /* Read an open .msh file of version 4 and parse the nodes into a hash table. */ static sc_hash_t * t8_msh_file_4_read_nodes (FILE *fp, - t8_locidx_t *num_nodes, sc_mempool_t **node_mempool) + t8_locidx_t *num_nodes, + sc_mempool_t ** node_mempool) { t8_msh_file_node_parametric_t *Node; sc_hash_t *node_table = NULL; @@ -534,7 +535,7 @@ t8_msh_file_4_read_nodes (FILE *fp, * They are stored as arrays of long ints. */ static int t8_cmesh_msh_file_2_read_eles (t8_cmesh_t cmesh, FILE *fp, - sc_hash_t *vertices, + sc_hash_t * vertices, sc_array_t **vertex_indices, int dim) { char *line = (char *) malloc (1024), *line_modify; @@ -742,7 +743,7 @@ t8_cmesh_msh_file_2_read_eles (t8_cmesh_t cmesh, FILE *fp, * is not committed yet. */ static int t8_cmesh_msh_file_4_read_eles (t8_cmesh_t cmesh, FILE *fp, - sc_hash_t *vertices, + sc_hash_t * vertices, sc_array_t **vertex_indices, int dim, const t8_geometry_c *linear_geometry_base, @@ -1598,8 +1599,8 @@ t8_msh_file_face_set_boundary (void **face, const void *data) /* Given two faces and the classes of their volume trees, * compute the orientation of the faces to each other */ static int -t8_msh_file_face_orientation (t8_msh_file_face_t *Face_a, - t8_msh_file_face_t *Face_b, +t8_msh_file_face_orientation (t8_msh_file_face_t * Face_a, + t8_msh_file_face_t * Face_b, t8_eclass_t tree_class_a, t8_eclass_t tree_class_b) { diff --git a/src/t8_cmesh/t8_cmesh_refine.cxx b/src/t8_cmesh/t8_cmesh_refine.cxx index d27521c043..5af37ee652 100644 --- a/src/t8_cmesh/t8_cmesh_refine.cxx +++ b/src/t8_cmesh/t8_cmesh_refine.cxx @@ -51,7 +51,7 @@ typedef struct * We store an additional entry with child_id = -1 at the end, so that * this search terminates when the entry is not found. */ static t8_locidx_t -t8_cmesh_refine_childid_to_localid (t8_child_id_to_local_id **idarray, +t8_cmesh_refine_childid_to_localid (t8_child_id_to_local_id ** idarray, t8_locidx_t lparent_id, int8_t child_id) { int ichild; @@ -85,7 +85,7 @@ t8_cmesh_refine_init_idarray (t8_cmesh_t cmesh_from) * their local ids. */ static t8_locidx_t -t8_cmesh_refine_fill_idarray (t8_child_id_to_local_id **idarray, +t8_cmesh_refine_fill_idarray (t8_child_id_to_local_id ** idarray, t8_locidx_t gparent_id, int8_t child_counted[10], int num_children, t8_locidx_t next_local_id) @@ -113,7 +113,7 @@ t8_cmesh_refine_fill_idarray (t8_child_id_to_local_id **idarray, } static void -t8_cmesh_refine_destroy_idarray (t8_child_id_to_local_id **idarray, +t8_cmesh_refine_destroy_idarray (t8_child_id_to_local_id ** idarray, t8_locidx_t num_parent_ghosts) { t8_locidx_t lghost; @@ -131,7 +131,7 @@ t8_cmesh_refine_destroy_idarray (t8_child_id_to_local_id **idarray, static t8_locidx_t t8_cmesh_refine_new_neighborid (t8_cmesh_t cmesh_from, t8_locidx_t parent_id, int child_id, - t8_child_id_to_local_id **id_array, + t8_child_id_to_local_id ** id_array, int factor) { if (parent_id >= cmesh_from->num_local_trees) { @@ -172,7 +172,7 @@ static void t8_cmesh_refine_new_neighbors (t8_cmesh_t cmesh_from, t8_locidx_t parent_id, t8_gloidx_t global_parent_id, t8_eclass_t eclass, - t8_child_id_to_local_id **id_array, + t8_child_id_to_local_id ** id_array, int child_id, t8_locidx_t *neighbor_out, t8_gloidx_t *neighbor_out_ghost, @@ -566,7 +566,7 @@ t8_cmesh_refine_inittree (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, */ static void t8_cmesh_refine_tree (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, - t8_child_id_to_local_id **id_array, + t8_child_id_to_local_id ** id_array, t8_locidx_t treeid, t8_locidx_t firstnewtree, int factor) { @@ -622,7 +622,7 @@ t8_cmesh_refine_tree (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, * faces of the ghost connected to local trees. */ static void t8_cmesh_refine_initghost (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, - t8_child_id_to_local_id **idarray, + t8_child_id_to_local_id ** idarray, t8_locidx_t ghostid, int factor) { t8_cghost_t ghost, newghost; @@ -657,7 +657,7 @@ t8_cmesh_refine_initghost (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, static void t8_cmesh_refine_ghost (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, - t8_child_id_to_local_id **idarray, + t8_child_id_to_local_id ** idarray, t8_locidx_t ghostid, int factor) { t8_cghost_t newghost; @@ -686,7 +686,7 @@ t8_cmesh_refine_ghost (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, static t8_locidx_t t8_cmesh_refine_count_ghost (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, - t8_child_id_to_local_id **idarray) + t8_child_id_to_local_id ** idarray) { t8_cghost_t ghost; t8_gloidx_t *face_neighbor, neighbor; diff --git a/src/t8_cmesh/t8_cmesh_triangle.c b/src/t8_cmesh/t8_cmesh_triangle.c index ad96a49fc2..27cd2972fa 100644 --- a/src/t8_cmesh/t8_cmesh_triangle.c +++ b/src/t8_cmesh/t8_cmesh_triangle.c @@ -559,9 +559,9 @@ static t8_cmesh_t t8_cmesh_from_tetgen_or_triangle_file_time (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup, - int dim, sc_flopinfo_t *fi, - sc_flopinfo_t *snapshot, - sc_statinfo_t *stats, + int dim, sc_flopinfo_t * fi, + sc_flopinfo_t * snapshot, + sc_statinfo_t * stats, int statindex) { int mpirank, mpisize, mpiret; @@ -659,9 +659,9 @@ t8_cmesh_from_triangle_file (char *fileprefix, int partition, t8_cmesh_t t8_cmesh_from_tetgen_file_time (char *fileprefix, int partition, sc_MPI_Comm comm, int do_dup, - sc_flopinfo_t *fi, - sc_flopinfo_t *snapshot, - sc_statinfo_t *stats, int statentry) + sc_flopinfo_t * fi, + sc_flopinfo_t * snapshot, + sc_statinfo_t * stats, int statentry) { return t8_cmesh_from_tetgen_or_triangle_file_time (fileprefix, partition, comm, do_dup, 3, fi, diff --git a/src/t8_forest/t8_forest_adapt.cxx b/src/t8_forest/t8_forest_adapt.cxx index a7f3c5abbb..34f11d386a 100644 --- a/src/t8_forest/t8_forest_adapt.cxx +++ b/src/t8_forest/t8_forest_adapt.cxx @@ -133,7 +133,7 @@ static void t8_forest_adapt_refine_recursive (t8_forest_t forest, t8_locidx_t ltreeid, t8_locidx_t lelement_id, t8_eclass_scheme_c *ts, - sc_list_t *elem_list, + sc_list_t * elem_list, t8_element_array_t *telements, t8_locidx_t *num_inserted, t8_element_t **el_buffer) diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index 19fc3f4b1d..5271fb119b 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -917,7 +917,7 @@ t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, */ static t8_ghost_mpi_send_info_t * t8_forest_ghost_send_start (t8_forest_t forest, t8_forest_ghost_t ghost, - sc_MPI_Request **requests) + sc_MPI_Request ** requests) { int proc_index, remote_rank; int num_remotes; @@ -1067,7 +1067,7 @@ t8_forest_ghost_send_start (t8_forest_t forest, t8_forest_ghost_t ghost, static void t8_forest_ghost_send_end (t8_forest_t forest, t8_forest_ghost_t ghost, t8_ghost_mpi_send_info_t *send_info, - sc_MPI_Request *requests) + sc_MPI_Request * requests) { int num_remotes; int proc_pos, mpiret; diff --git a/src/t8_forest/t8_forest_netcdf.cxx b/src/t8_forest/t8_forest_netcdf.cxx index 7ef59dc959..e9ab4ee190 100644 --- a/src/t8_forest/t8_forest_netcdf.cxx +++ b/src/t8_forest/t8_forest_netcdf.cxx @@ -117,7 +117,7 @@ typedef struct /* The UGRID conventions are applied for dimension and variable descriptions */ static void t8_forest_init_ugrid_namespace_context (t8_forest_netcdf_ugrid_namespace_t - *namespace_conv, int dim) + * namespace_conv, int dim) { if (dim == 2) { /* UGRID 2D Grid name conventions */ @@ -159,9 +159,9 @@ t8_forest_init_ugrid_namespace_context (t8_forest_netcdf_ugrid_namespace_t /* Define NetCDF-dimesnions */ static void -t8_forest_write_netcdf_dimensions (t8_forest_netcdf_context_t *context, +t8_forest_write_netcdf_dimensions (t8_forest_netcdf_context_t * context, t8_forest_netcdf_ugrid_namespace_t - *namespace_context) + * namespace_context) { #if T8_WITH_NETCDF /* *Define dimensions in the NetCDF file.* */ @@ -193,9 +193,9 @@ t8_forest_write_netcdf_dimensions (t8_forest_netcdf_context_t *context, /* Define NetCDF-variables */ static void -t8_forest_write_netcdf_variables (t8_forest_netcdf_context_t *context, +t8_forest_write_netcdf_variables (t8_forest_netcdf_context_t * context, t8_forest_netcdf_ugrid_namespace_t - *namespace_context) + * namespace_context) { #if T8_WITH_NETCDF /* *Define variables in the NetCDF file.* */ @@ -424,7 +424,7 @@ t8_forest_write_netcdf_variables (t8_forest_netcdf_context_t *context, static void t8_forest_write_netcdf_data (t8_forest_t forest, - t8_forest_netcdf_context_t *context, + t8_forest_netcdf_context_t * context, sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -527,9 +527,9 @@ t8_forest_write_netcdf_data (t8_forest_t forest, /* Define NetCDF-coordinate-dimension */ static void t8_forest_write_netcdf_coordinate_dimension (t8_forest_netcdf_context_t - *context, + * context, t8_forest_netcdf_ugrid_namespace_t - *namespace_context) + * namespace_context) { #if T8_WITH_NETCDF /* Define dimension: number of nodes */ @@ -545,9 +545,9 @@ t8_forest_write_netcdf_coordinate_dimension (t8_forest_netcdf_context_t /* Define NetCDF-coordinate-variables */ static void t8_forest_write_netcdf_coordinate_variables (t8_forest_netcdf_context_t - *context, + * context, t8_forest_netcdf_ugrid_namespace_t - *namespace_context) + * namespace_context) { #if T8_WITH_NETCDF /* Define the Mesh_node_x variable. */ @@ -691,11 +691,11 @@ t8_forest_write_netcdf_coordinate_variables (t8_forest_netcdf_context_t /* Declare the user-defined elementwise NetCDF-variables which were passed to function. */ static void -t8_forest_write_user_netcdf_vars (t8_forest_netcdf_context_t *context, +t8_forest_write_user_netcdf_vars (t8_forest_netcdf_context_t * context, t8_forest_netcdf_ugrid_namespace_t - *namespace_context, + * namespace_context, int num_extern_netcdf_vars, - t8_netcdf_variable_t *ext_variables[], + t8_netcdf_variable_t * ext_variables[], sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -783,7 +783,7 @@ t8_forest_write_user_netcdf_vars (t8_forest_netcdf_context_t *context, /* Write the netCDF coordinate data to he file */ static void t8_forest_write_netcdf_coordinate_data (t8_forest_t forest, - t8_forest_netcdf_context_t *context, + t8_forest_netcdf_context_t * context, sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -951,9 +951,9 @@ t8_forest_write_netcdf_coordinate_data (t8_forest_t forest, /* It is only possible to write exactly one value per element per variable */ static void t8_forest_write_user_netcdf_data (t8_forest_t forest, - t8_forest_netcdf_context_t *context, + t8_forest_netcdf_context_t * context, int num_extern_netcdf_vars, - t8_netcdf_variable_t *ext_variables[], + t8_netcdf_variable_t * ext_variables[], sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -1017,10 +1017,10 @@ t8_forest_write_user_netcdf_data (t8_forest_t forest, /* Function that creates the NetCDF-File and fills it */ static void t8_forest_write_netcdf_file (t8_forest_t forest, - t8_forest_netcdf_context_t *context, + t8_forest_netcdf_context_t * context, t8_forest_netcdf_ugrid_namespace_t - *namespace_context, int num_extern_netcdf_vars, - t8_netcdf_variable_t *ext_variables[], + * namespace_context, int num_extern_netcdf_vars, + t8_netcdf_variable_t * ext_variables[], sc_MPI_Comm comm) { #if T8_WITH_NETCDF @@ -1147,7 +1147,7 @@ void t8_forest_write_netcdf_ext (t8_forest_t forest, const char *file_prefix, const char *file_title, int dim, int num_extern_netcdf_vars, - t8_netcdf_variable_t *ext_variables[], + t8_netcdf_variable_t * ext_variables[], sc_MPI_Comm comm, int netcdf_var_storage_mode, int netcdf_mpi_access) { @@ -1247,7 +1247,7 @@ void t8_forest_write_netcdf (t8_forest_t forest, const char *file_prefix, const char *file_title, int dim, int num_extern_netcdf_vars, - t8_netcdf_variable_t *ext_variables[], + t8_netcdf_variable_t * ext_variables[], sc_MPI_Comm comm) { /* Choose NC_CONTIGUOUS as default storage pattern, this is equal to 1 (defined in 'netcdf.h') */ diff --git a/src/t8_forest/t8_forest_partition.cxx b/src/t8_forest/t8_forest_partition.cxx index bb501f622b..d2bebf638d 100644 --- a/src/t8_forest/t8_forest_partition.cxx +++ b/src/t8_forest/t8_forest_partition.cxx @@ -654,7 +654,7 @@ t8_forest_partition_fill_buffer_data (t8_forest_t forest_from, * Returns true if we sent to ourselves. */ static int t8_forest_partition_sendloop (t8_forest_t forest, const int send_first, - const int send_last, sc_MPI_Request **requests, + const int send_last, sc_MPI_Request ** requests, int *num_request_alloc, char ***send_buffer, const int send_data, const sc_array_t *data_in, size_t *byte_to_self) @@ -818,7 +818,7 @@ t8_forest_partition_sendloop (t8_forest_t forest, const int send_first, */ static void t8_forest_partition_recv_message_data (t8_forest_t forest, sc_MPI_Comm comm, - int proc, sc_MPI_Status *status, + int proc, sc_MPI_Status * status, t8_locidx_t *last_loc_elem_recvd, sc_array_t *data_out, char *sent_to_self, @@ -888,7 +888,7 @@ t8_forest_partition_recv_message_data (t8_forest_t forest, sc_MPI_Comm comm, */ static void t8_forest_partition_recv_message (t8_forest_t forest, sc_MPI_Comm comm, - int proc, sc_MPI_Status *status, + int proc, sc_MPI_Status * status, int prev_recvd, char *sent_to_self, size_t byte_to_self) { diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_occ.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_occ.cxx index b0497fc621..b4d12e0cb7 100755 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_occ.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_occ.cxx @@ -962,7 +962,7 @@ t8_geometry_occ_new (int dimension, const char *fileprefix, } void -t8_geometry_occ_destroy (t8_geometry_occ_c **geom) +t8_geometry_occ_destroy (t8_geometry_occ_c ** geom) { #ifdef T8_ENABLE_DEBUG t8_geometry_occ_c *pgeom = *geom; diff --git a/src/t8_netcdf.c b/src/t8_netcdf.c index 3a6a9b385f..c0002b2b68 100644 --- a/src/t8_netcdf.c +++ b/src/t8_netcdf.c @@ -82,7 +82,7 @@ t8_netcdf_create_double_var (const char *var_name, const char *var_long_name, /* Free the memory of the allocated NetCDF variable */ void -t8_netcdf_variable_destroy (t8_netcdf_variable_t *var_destroy) +t8_netcdf_variable_destroy (t8_netcdf_variable_t * var_destroy) { T8_ASSERT (var_destroy != NULL); T8_FREE (var_destroy); diff --git a/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.cxx b/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.cxx index e7e0e59406..5b1a64eb9f 100644 --- a/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.cxx @@ -77,7 +77,7 @@ t8_default_scheme_common_c::t8_element_destroy (int length, } static void -t8_default_mempool_alloc (sc_mempool_t *ts_context, int length, +t8_default_mempool_alloc (sc_mempool_t * ts_context, int length, t8_element_t **elem) { int i; @@ -92,7 +92,7 @@ t8_default_mempool_alloc (sc_mempool_t *ts_context, int length, } static void -t8_default_mempool_free (sc_mempool_t *ts_context, int length, +t8_default_mempool_free (sc_mempool_t * ts_context, int length, t8_element_t **elem) { int i; diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c index 25eecfcd78..6a9aabb1b6 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c @@ -502,7 +502,7 @@ t8_dpyramid_get_level (const t8_dpyramid_t *p) * \return int The local-id of the child */ static int -t8_dpyramid_update_index (t8_linearidx_t *id, const t8_dpyramid_type_t type, +t8_dpyramid_update_index (t8_linearidx_t * id, const t8_dpyramid_type_t type, const t8_linearidx_t pyra, const t8_linearidx_t tet) { t8_linearidx_t test = 0; diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx index a699869cd4..c267cdd828 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx @@ -62,7 +62,7 @@ t8_default_scheme_quad_c::t8_element_level (const t8_element_t *elem) const } static void -t8_element_copy_surround (const p4est_quadrant_t *q, p4est_quadrant_t *r) +t8_element_copy_surround (const p4est_quadrant_t * q, p4est_quadrant_t * r) { T8_QUAD_SET_TDIM (r, T8_QUAD_GET_TDIM (q)); if (T8_QUAD_GET_TDIM (q) == 3) { diff --git a/tutorials/general/t8_tutorial_search.cxx b/tutorials/general/t8_tutorial_search.cxx index e40e72930e..1f0d99cc7c 100644 --- a/tutorials/general/t8_tutorial_search.cxx +++ b/tutorials/general/t8_tutorial_search.cxx @@ -233,7 +233,7 @@ t8_tutorial_search_query_callback (t8_forest_t forest, /* Write the forest to vtu files and also write the particles_per_element * data. */ static void -t8_tutorial_search_vtk (t8_forest_t forest, sc_array *particles_per_element, +t8_tutorial_search_vtk (t8_forest_t forest, sc_array * particles_per_element, const char *prefix) { /* Define the additional vtu data that we want to write. */ @@ -253,7 +253,7 @@ t8_tutorial_search_vtk (t8_forest_t forest, sc_array *particles_per_element, /* Perform the actual search and write the forest with the number of particles per element * to vtu files. */ static void -t8_tutorial_search_for_particles (t8_forest_t forest, sc_array *particles) +t8_tutorial_search_for_particles (t8_forest_t forest, sc_array * particles) { sc_array particles_per_element; t8_locidx_t num_local_elements = From 2252fd401e068ec6e962d15b3a32fe09e7df1b53 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Tue, 25 Apr 2023 12:53:11 +0200 Subject: [PATCH 129/255] Add Tutorial to README --- tutorials/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tutorials/README.md b/tutorials/README.md index 4a5e5ffb7e..0753e4d4e1 100644 --- a/tutorials/README.md +++ b/tutorials/README.md @@ -32,6 +32,9 @@ Gather data from element's face neighbors and collect stencils in, e.g., finite [Search](https://github.com/DLR-AMR/t8code/wiki/Tutorial:-Search) - A tutorial for the hierarchical search to identify elements matching a user defined criterion. +[Cmesh](https://github.com/DLR-AMR/t8code/wiki/Build-Cmesh) +Creating a user defined mesh in two- and three dimensions. + ## Features From a455322a4444eb0a44312eba35413090499d255c Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Tue, 25 Apr 2023 13:54:03 +0200 Subject: [PATCH 130/255] Merge main into branch --- tutorials/general/t8_tutorial_build_cmesh.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/general/t8_tutorial_build_cmesh.cxx b/tutorials/general/t8_tutorial_build_cmesh.cxx index 84f3d06aa3..60ec955ecf 100644 --- a/tutorials/general/t8_tutorial_build_cmesh.cxx +++ b/tutorials/general/t8_tutorial_build_cmesh.cxx @@ -39,7 +39,7 @@ #include /* General t8code header, always include this. */ #include /* cmesh definition and basic interface. */ -#include /* forest definition and basic interface. */ +#include /* forest definition and basic interface. */ #include /* default refinement scheme. */ #include /* write file in vtu file */ #include /* linear geometry of the cmesh */ From 5874d46de1076e989a2cd958d1e0dbcd78f169d7 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Tue, 25 Apr 2023 17:13:15 +0200 Subject: [PATCH 131/255] moved vtk files into new t8_vtk folder --- .../t8_cmesh_vtk_polydata.cxx => t8_vtk/t8_vtk_polydata.cxx} | 0 .../t8_cmesh_vtk_polydata.hxx => t8_vtk/t8_vtk_polydata.hxx} | 0 src/{t8_cmesh/t8_cmesh_vtk_to_t8 => t8_vtk}/t8_vtk_types.h | 0 .../t8_vtk_unstructured.cxx} | 0 .../t8_vtk_unstructured.hxx} | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename src/{t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx => t8_vtk/t8_vtk_polydata.cxx} (100%) rename src/{t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx => t8_vtk/t8_vtk_polydata.hxx} (100%) rename src/{t8_cmesh/t8_cmesh_vtk_to_t8 => t8_vtk}/t8_vtk_types.h (100%) rename src/{t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx => t8_vtk/t8_vtk_unstructured.cxx} (100%) rename src/{t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx => t8_vtk/t8_vtk_unstructured.hxx} (100%) diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_vtk/t8_vtk_polydata.cxx similarity index 100% rename from src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx rename to src/t8_vtk/t8_vtk_polydata.cxx diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx b/src/t8_vtk/t8_vtk_polydata.hxx similarity index 100% rename from src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx rename to src/t8_vtk/t8_vtk_polydata.hxx diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_vtk_types.h b/src/t8_vtk/t8_vtk_types.h similarity index 100% rename from src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_vtk_types.h rename to src/t8_vtk/t8_vtk_types.h diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx b/src/t8_vtk/t8_vtk_unstructured.cxx similarity index 100% rename from src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx rename to src/t8_vtk/t8_vtk_unstructured.cxx diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx b/src/t8_vtk/t8_vtk_unstructured.hxx similarity index 100% rename from src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx rename to src/t8_vtk/t8_vtk_unstructured.hxx From 3c8c3af2581f950d8814bc23def4ef455779bd0a Mon Sep 17 00:00:00 2001 From: ililikakis Date: Tue, 25 Apr 2023 17:26:02 +0200 Subject: [PATCH 132/255] fixed header and makefile due to moving files --- src/Makefile.am | 13 ++++++------- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 6 +++--- src/t8_cmesh_vtk_reader.hxx | 2 +- src/t8_vtk/t8_vtk_polydata.cxx | 2 +- src/t8_vtk/t8_vtk_unstructured.cxx | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 702d8d8efc..34e07f4a22 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -74,14 +74,13 @@ libt8_internal_headers = \ src/t8_cmesh/t8_cmesh_types.h src/t8_cmesh/t8_cmesh_partition.h \ src/t8_cmesh/t8_cmesh_refine.h src/t8_cmesh/t8_cmesh_copy.h \ src/t8_cmesh/t8_cmesh_offset.h \ - src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx \ - src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx \ - src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_vtk_types.h \ + src/t8_vtk/t8_vtk_polydata.hxx \ + src/t8_vtk/t8_vtk_unstructured.hxx \ + src/t8_vtk/t8_vtk_types.h \ src/t8_forest/t8_forest_cxx.h \ src/t8_forest/t8_forest_ghost.h \ src/t8_forest/t8_forest_balance.h src/t8_forest/t8_forest_types.h \ - src/t8_forest/t8_forest_private.h \ - src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx + src/t8_forest/t8_forest_private.h libt8_compiled_sources = \ src/t8.c src/t8_eclass.c src/t8_mesh.c \ src/t8_element.c src/t8_element_cxx.cxx \ @@ -117,8 +116,8 @@ libt8_compiled_sources = \ src/t8_element_shape.c \ src/t8_netcdf.c \ src/t8_cmesh/t8_cmesh_testcases.c \ - src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx \ - src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx + src/t8_vtk/t8_vtk_polydata.cxx \ + src/t8_vtk/t8_vtk_unstructured.cxx # this variable is used for headers that are not publicly installed diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index 8ba628bab8..6516896860 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -28,10 +28,10 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include /* To set tree vertices */ #include -#include "t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx" -#include "t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx" +#include +#include +#include #include -#include "t8_cmesh_vtk_to_t8/t8_vtk_types.h" #if T8_WITH_VTK #include diff --git a/src/t8_cmesh_vtk_reader.hxx b/src/t8_cmesh_vtk_reader.hxx index 42f08c0075..4013701858 100644 --- a/src/t8_cmesh_vtk_reader.hxx +++ b/src/t8_cmesh_vtk_reader.hxx @@ -28,7 +28,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #define T8_CMESH_VTK_READER #include -#include "t8_cmesh/t8_cmesh_vtk_to_t8/t8_vtk_types.h" +#include #if T8_WITH_VTK #include diff --git a/src/t8_vtk/t8_vtk_polydata.cxx b/src/t8_vtk/t8_vtk_polydata.cxx index 3feb60079d..64a6608748 100644 --- a/src/t8_vtk/t8_vtk_polydata.cxx +++ b/src/t8_vtk/t8_vtk_polydata.cxx @@ -20,7 +20,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "t8_cmesh_vtk_polydata.hxx" +#include "t8_vtk_polydata.hxx" #include "t8_vtk_types.h" #if T8_WITH_VTK #include diff --git a/src/t8_vtk/t8_vtk_unstructured.cxx b/src/t8_vtk/t8_vtk_unstructured.cxx index 5d07be7e34..1cffb627af 100644 --- a/src/t8_vtk/t8_vtk_unstructured.cxx +++ b/src/t8_vtk/t8_vtk_unstructured.cxx @@ -20,7 +20,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "t8_cmesh_vtk_unstructured.hxx" +#include "t8_vtk_unstructured.hxx" #if T8_WITH_VTK #include From 62df7a3d1c96b9492666a160e772a8951e52f8f5 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> Date: Wed, 26 Apr 2023 08:58:39 +0200 Subject: [PATCH 133/255] Remove branch limitation of release workflow --- .github/workflows/add_release_documentation.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/add_release_documentation.yml b/.github/workflows/add_release_documentation.yml index de0573016d..850d4f4814 100644 --- a/.github/workflows/add_release_documentation.yml +++ b/.github/workflows/add_release_documentation.yml @@ -34,8 +34,6 @@ on: release: types: - created - branches: - - main jobs: add_release_doc: From 604587d21d4c5fae5f828cba69721904ab34e944 Mon Sep 17 00:00:00 2001 From: Pierre Kestener Date: Wed, 26 Apr 2023 09:31:52 +0200 Subject: [PATCH 134/255] Fix linking problems in static mode. See issue #531 It feels more appropriate to rename source file for having c++ extension. --- benchmarks/Makefile.am | 4 ++-- benchmarks/{time_partition.c => time_partition.cxx} | 0 example/IO/cmesh/netcdf/Makefile.am | 2 +- .../{t8_write_cmesh_netcdf.c => t8_write_cmesh_netcdf.cxx} | 0 example/IO/cmesh/tetgen/Makefile.am | 4 ++-- .../{t8_read_tetgen_file.c => t8_read_tetgen_file.cxx} | 0 .../{t8_time_tetgen_file.c => t8_time_tetgen_file.cxx} | 0 tutorials/Makefile.am | 5 ++--- .../{t8_step0_helloworld.c => t8_step0_helloworld.cxx} | 0 .../{t8_step1_coarsemesh.c => t8_step1_coarsemesh.cxx} | 0 10 files changed, 7 insertions(+), 8 deletions(-) rename benchmarks/{time_partition.c => time_partition.cxx} (100%) rename example/IO/cmesh/netcdf/{t8_write_cmesh_netcdf.c => t8_write_cmesh_netcdf.cxx} (100%) rename example/IO/cmesh/tetgen/{t8_read_tetgen_file.c => t8_read_tetgen_file.cxx} (100%) rename example/IO/cmesh/tetgen/{t8_time_tetgen_file.c => t8_time_tetgen_file.cxx} (100%) rename tutorials/general/{t8_step0_helloworld.c => t8_step0_helloworld.cxx} (100%) rename tutorials/general/{t8_step1_coarsemesh.c => t8_step1_coarsemesh.cxx} (100%) diff --git a/benchmarks/Makefile.am b/benchmarks/Makefile.am index ddc4c24aa7..25504301d1 100644 --- a/benchmarks/Makefile.am +++ b/benchmarks/Makefile.am @@ -7,11 +7,11 @@ bin_PROGRAMS += \ benchmarks/t8_time_forest_partition \ benchmarks/t8_time_prism_adapt # benchmarks/t8_time_new_refine \ -# benchmarks/t8_time_refine_type03 +# benchmarks/t8_time_refine_type03 #benchmarks_t8_time_new_refine_SOURCES = benchmarks/time_new_refine.c #benchmarks_t8_time_refine_type03_SOURCES = benchmarks/time_refine_type03.c -benchmarks_t8_time_partition_SOURCES = benchmarks/time_partition.c +benchmarks_t8_time_partition_SOURCES = benchmarks/time_partition.cxx benchmarks_t8_time_forest_partition_SOURCES = benchmarks/time_forest_partition.cxx benchmarks_t8_time_prism_adapt_SOURCES = benchmarks/t8_time_prism_adapt.cxx diff --git a/benchmarks/time_partition.c b/benchmarks/time_partition.cxx similarity index 100% rename from benchmarks/time_partition.c rename to benchmarks/time_partition.cxx diff --git a/example/IO/cmesh/netcdf/Makefile.am b/example/IO/cmesh/netcdf/Makefile.am index 678eba0865..c170778844 100644 --- a/example/IO/cmesh/netcdf/Makefile.am +++ b/example/IO/cmesh/netcdf/Makefile.am @@ -5,4 +5,4 @@ bin_PROGRAMS += \ example/IO/cmesh/netcdf/t8_write_cmesh_netcdf -example_IO_cmesh_netcdf_t8_write_cmesh_netcdf_SOURCES = example/IO/cmesh/netcdf/t8_write_cmesh_netcdf.c +example_IO_cmesh_netcdf_t8_write_cmesh_netcdf_SOURCES = example/IO/cmesh/netcdf/t8_write_cmesh_netcdf.cxx diff --git a/example/IO/cmesh/netcdf/t8_write_cmesh_netcdf.c b/example/IO/cmesh/netcdf/t8_write_cmesh_netcdf.cxx similarity index 100% rename from example/IO/cmesh/netcdf/t8_write_cmesh_netcdf.c rename to example/IO/cmesh/netcdf/t8_write_cmesh_netcdf.cxx diff --git a/example/IO/cmesh/tetgen/Makefile.am b/example/IO/cmesh/tetgen/Makefile.am index 1b8d05302e..49a85864ac 100644 --- a/example/IO/cmesh/tetgen/Makefile.am +++ b/example/IO/cmesh/tetgen/Makefile.am @@ -7,6 +7,6 @@ bin_PROGRAMS += \ example/IO/cmesh/tetgen/t8_time_tetgen \ example/IO/cmesh/tetgen/t8_forest_tetgen -example_IO_cmesh_tetgen_t8_read_tetgen_SOURCES = example/IO/cmesh/tetgen/t8_read_tetgen_file.c -example_IO_cmesh_tetgen_t8_time_tetgen_SOURCES = example/IO/cmesh/tetgen/t8_time_tetgen_file.c +example_IO_cmesh_tetgen_t8_read_tetgen_SOURCES = example/IO/cmesh/tetgen/t8_read_tetgen_file.cxx +example_IO_cmesh_tetgen_t8_time_tetgen_SOURCES = example/IO/cmesh/tetgen/t8_time_tetgen_file.cxx example_IO_cmesh_tetgen_t8_forest_tetgen_SOURCES = example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx diff --git a/example/IO/cmesh/tetgen/t8_read_tetgen_file.c b/example/IO/cmesh/tetgen/t8_read_tetgen_file.cxx similarity index 100% rename from example/IO/cmesh/tetgen/t8_read_tetgen_file.c rename to example/IO/cmesh/tetgen/t8_read_tetgen_file.cxx diff --git a/example/IO/cmesh/tetgen/t8_time_tetgen_file.c b/example/IO/cmesh/tetgen/t8_time_tetgen_file.cxx similarity index 100% rename from example/IO/cmesh/tetgen/t8_time_tetgen_file.c rename to example/IO/cmesh/tetgen/t8_time_tetgen_file.cxx diff --git a/tutorials/Makefile.am b/tutorials/Makefile.am index 1b4e799ba7..97d77dcd76 100644 --- a/tutorials/Makefile.am +++ b/tutorials/Makefile.am @@ -19,9 +19,9 @@ dist_t8data_DATA += \ tutorials/features/t8_features_curved_meshes_generate_cmesh_2d.geo tutorials_general_t8_step0_helloworld_SOURCES = \ - tutorials/general/t8_step0_helloworld.c + tutorials/general/t8_step0_helloworld.cxx tutorials_general_t8_step1_coarsemesh_SOURCES = \ - tutorials/general/t8_step1_coarsemesh.c + tutorials/general/t8_step1_coarsemesh.cxx tutorials_general_t8_step2_uniform_forest_SOURCES = \ tutorials/general/t8_step2_uniform_forest.cxx tutorials_general_t8_step3_adapt_forest_SOURCES = \ @@ -54,4 +54,3 @@ libt8_installed_headers += \ tutorials/general/t8_step4.h \ tutorials/general/t8_step5.h \ tutorials/general/t8_step6.h - diff --git a/tutorials/general/t8_step0_helloworld.c b/tutorials/general/t8_step0_helloworld.cxx similarity index 100% rename from tutorials/general/t8_step0_helloworld.c rename to tutorials/general/t8_step0_helloworld.cxx diff --git a/tutorials/general/t8_step1_coarsemesh.c b/tutorials/general/t8_step1_coarsemesh.cxx similarity index 100% rename from tutorials/general/t8_step1_coarsemesh.c rename to tutorials/general/t8_step1_coarsemesh.cxx From d307c5f54c8e7acfba8f8ff296fbdd0313a02e57 Mon Sep 17 00:00:00 2001 From: Pierre Kestener Date: Wed, 26 Apr 2023 10:21:06 +0200 Subject: [PATCH 135/255] add author file. --- doc/author_kestener.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/author_kestener.txt diff --git a/doc/author_kestener.txt b/doc/author_kestener.txt new file mode 100644 index 0000000000..35b562fda0 --- /dev/null +++ b/doc/author_kestener.txt @@ -0,0 +1 @@ +I place my contributions to t8code under the FreeBSD license. Pierre Kestener From 5940d6f742c5dd1f7545da93f472290edb453edc Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 26 Apr 2023 11:05:57 +0200 Subject: [PATCH 136/255] enabled recursive documentation and removed file patterns --- doc/Doxyfile.in | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index 23de03bf4b..4182e39b4f 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -885,13 +885,12 @@ INPUT_ENCODING = UTF-8 # *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl, # *.ucf, *.qsf and *.ice. -FILE_PATTERNS = *.h - +FILE_PATTERNS = # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. # The default value is: NO. -RECURSIVE = NO +RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a @@ -941,8 +940,7 @@ EXAMPLE_PATH = # *.h) to filter out the source-files in the directories. If left blank all # files are included. -EXAMPLE_PATTERNS = *.c \ - *.h +EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude commands From 6cfa47e1a9511a50ca5258e2ad704f0b76f8f8fc Mon Sep 17 00:00:00 2001 From: ililikakis Date: Wed, 26 Apr 2023 16:18:36 +0200 Subject: [PATCH 137/255] moving functions --- src/Makefile.am | 6 +- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 459 +------------------------ src/t8_cmesh_vtk_reader.hxx | 78 +---- src/t8_vtk/t8_vtk_reader.cxx | 482 +++++++++++++++++++++++++++ src/t8_vtk/t8_vtk_reader.hxx | 131 ++++++++ 5 files changed, 619 insertions(+), 537 deletions(-) create mode 100644 src/t8_vtk/t8_vtk_reader.cxx create mode 100644 src/t8_vtk/t8_vtk_reader.hxx diff --git a/src/Makefile.am b/src/Makefile.am index 34e07f4a22..cd009f1082 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -76,10 +76,11 @@ libt8_internal_headers = \ src/t8_cmesh/t8_cmesh_offset.h \ src/t8_vtk/t8_vtk_polydata.hxx \ src/t8_vtk/t8_vtk_unstructured.hxx \ + src/t8_vtk/t8_vtk_reader.hxx \ src/t8_vtk/t8_vtk_types.h \ src/t8_forest/t8_forest_cxx.h \ src/t8_forest/t8_forest_ghost.h \ - src/t8_forest/t8_forest_balance.h src/t8_forest/t8_forest_types.h \ + src/t8_forest/t8_forest_balance.h src/t8_forest/t8_forest_types.h \ src/t8_forest/t8_forest_private.h libt8_compiled_sources = \ src/t8.c src/t8_eclass.c src/t8_mesh.c \ @@ -117,7 +118,8 @@ libt8_compiled_sources = \ src/t8_netcdf.c \ src/t8_cmesh/t8_cmesh_testcases.c \ src/t8_vtk/t8_vtk_polydata.cxx \ - src/t8_vtk/t8_vtk_unstructured.cxx + src/t8_vtk/t8_vtk_unstructured.cxx \ + src/t8_vtk/t8_vtk_reader.cxx # this variable is used for headers that are not publicly installed diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index 6516896860..c0254159cd 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -25,473 +25,16 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * The functions can only be used when t8code is linked with the vtk-library. */ -#include /* To set tree vertices */ - #include -#include -#include -#include -#include - -#if T8_WITH_VTK -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif T8_EXTERN_C_BEGIN (); -/** - * If the vertices of a tree describe a negative \param, - * permute the tree vertices. - * - * \param[in, out] tree_vertices The vertices of a tree - * \param[in] eclass The eclass of the tree. - */ -void -t8_cmesh_correct_volume (double *tree_vertices, t8_eclass_t eclass) -{ - /* The \param described is negative. We need to change vertices. - * For tets we switch 0 and 3. - * For prisms we switch 0 and 3, 1 and 4, 2 and 5. - * For hexahedra we switch 0 and 4, 1 and 5, 2 and 6, 3 and 7. - * For pyramids we switch 0 and 4 */ - double temp; - int num_switches = 0; - int switch_indices[4] = { 0 }; - int iswitch; - T8_ASSERT (t8_eclass_to_dimension[eclass] == 3); - t8_debugf ("Correcting negative volume.\n"); - switch (eclass) { - case T8_ECLASS_TET: - /* We switch vertex 0 and vertex 3 */ - num_switches = 1; - switch_indices[0] = 3; - break; - case T8_ECLASS_PRISM: - num_switches = 3; - switch_indices[0] = 3; - switch_indices[1] = 4; - switch_indices[2] = 5; - break; - case T8_ECLASS_HEX: - num_switches = 4; - switch_indices[0] = 4; - switch_indices[1] = 5; - switch_indices[2] = 6; - switch_indices[3] = 7; - break; - case T8_ECLASS_PYRAMID: - num_switches = 1; - switch_indices[0] = 4; - break; - default: - SC_ABORT_NOT_REACHED (); - } - - for (iswitch = 0; iswitch < num_switches; ++iswitch) { - /* We switch vertex 0 + iswitch and vertex switch_indices[iswitch] */ - for (int i = 0; i < 3; i++) { - temp = tree_vertices[3 * iswitch + i]; - tree_vertices[3 * iswitch + i] = - tree_vertices[3 * switch_indices[iswitch] + i]; - tree_vertices[3 * switch_indices[iswitch] + i] = temp; - } - } - T8_ASSERT (!t8_cmesh_tree_vertices_negative_volume - (eclass, tree_vertices, t8_eclass_num_vertices[eclass])); -} - -#if T8_WITH_VTK - -vtk_read_success_t -t8_file_to_vtkGrid (const char *filename, - vtkSmartPointer < vtkDataSet > vtkGrid, - const int partition, const int main_proc, - sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type) -{ - vtk_read_success_t main_proc_read_successful = read_failure; - int mpirank; - int mpisize; - int mpiret; - mpiret = sc_MPI_Comm_rank (comm, &mpirank); - SC_CHECK_MPI (mpiret); - mpiret = sc_MPI_Comm_size (comm, &mpisize); - SC_CHECK_MPI (mpiret); - T8_ASSERT (filename != NULL); - T8_ASSERT (0 <= main_proc && main_proc < mpisize); - /* Read the file and set the pointer to the vtkGrid */ - if (!partition || mpirank == main_proc) { - switch (vtk_file_type) { - case VTK_UNSTRUCTURED_FILE: - main_proc_read_successful = t8_read_unstructured (filename, vtkGrid); - break; - case VTK_POLYDATA_FILE: - main_proc_read_successful = t8_read_poly (filename, vtkGrid); - break; - default: - vtkGrid = NULL; - t8_errorf ("Filetype not supported.\n"); - break; - } - if (partition) { - /* Communicate the success/failure of the reading process. */ - sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, - comm); - } - } - if (partition) { - sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, comm); - } - return main_proc_read_successful; -} - -/** - * Get the dimension of a vtkDataSet - * - * \param[in] vtkGrid The vtkDataSet - * \return The dimension of \a vtkGrid. - */ -int -t8_get_dimension (vtkSmartPointer < vtkDataSet > vtkGrid) -{ - /* This array contains the type of each cell */ - vtkSmartPointer < vtkCellTypes > cell_type_of_each_cell = - vtkSmartPointer < vtkCellTypes >::New (); - vtkGrid->GetCellTypes (cell_type_of_each_cell); - vtkSmartPointer < vtkUnsignedCharArray > cell_types = - cell_type_of_each_cell->GetCellTypesArray (); - int max_cell_type = -1; - const vtkIdType num_types = cell_types->GetNumberOfTuples (); - /* Iterate over all types and compare the dimension. They are stored - * in ascending order. */ - for (vtkIdType cell_types_it = 0; cell_types_it < num_types; - cell_types_it++) { - const vtkIdType type = cell_types->GetValue (cell_types_it); - if (type > max_cell_type) { - max_cell_type = type; - } - } - T8_ASSERT (0 <= max_cell_type && max_cell_type < 82); - const int ieclass = t8_cmesh_vtk_type_to_t8_type[max_cell_type]; - T8_ASSERT (ieclass != T8_ECLASS_INVALID); - - return t8_eclass_to_dimension[ieclass]; -} - -/** - * Iterate over all cells of a vtkDataset and construct a cmesh representing - * The vtkGrid. Each cell in the vtkDataSet becomes a tree in the cmesh. This - * function construct a cmesh on a single process. - * - * \param[in] vtkGrid The vtkGrid that gets tranlated - * \param[in, out] cmesh An empty cmesh that is filled with the data. - * \param[in] comm A communicator. - * \return The number of elements that have been read by the process. - */ - -t8_gloidx_t -t8_vtk_iterate_cells (vtkSmartPointer < vtkDataSet > vtkGrid, - t8_cmesh_t cmesh, sc_MPI_Comm comm) -{ - - double *vertices; - double **tuples; - size_t *data_size; - t8_gloidx_t tree_id = 0; - int max_dim = -1; - - vtkCellIterator *cell_it; - vtkSmartPointer < vtkPoints > points; - vtkSmartPointer < vtkCellData > cell_data = vtkGrid->GetCellData (); - const int max_cell_points = vtkGrid->GetMaxCellSize (); - - T8_ASSERT (max_cell_points >= 0); - vertices = T8_ALLOC (double, 3 * max_cell_points); - /* Get cell iterator */ - cell_it = vtkGrid->NewCellIterator (); - /* get the number of data-arrays per cell */ - const int num_data_arrays = cell_data->GetNumberOfArrays (); - T8_ASSERT (num_data_arrays >= 0); - - t8_debugf ("[D] read %i data-arrays\n", num_data_arrays); - /* Prepare attributes */ - if (num_data_arrays > 0) { - size_t tuple_size; - tuples = T8_ALLOC (double *, num_data_arrays); - data_size = T8_ALLOC (size_t, num_data_arrays); - for (int idata = 0; idata < num_data_arrays; idata++) { - vtkDataArray *data = cell_data->GetArray (idata); - tuple_size = data->GetNumberOfComponents (); - data_size[idata] = sizeof (double) * tuple_size; - t8_debugf ("[D] data_size[%i] = %li, tuple_size %li\n", idata, - data_size[idata], tuple_size); - /* Allocate memory for a tuple in array i */ - tuples[idata] = T8_ALLOC (double, tuple_size); - } - } - - /* Iterate over all cells */ - for (cell_it->InitTraversal (); !cell_it->IsDoneWithTraversal (); - cell_it->GoToNextCell ()) { - - /* Set the t8_eclass of the cell */ - const t8_eclass_t cell_type = - t8_cmesh_vtk_type_to_t8_type[cell_it->GetCellType ()]; - SC_CHECK_ABORTF (t8_eclass_is_valid (cell_type), - "vtk-cell-type %i not supported by t8code\n", cell_type); - t8_cmesh_set_tree_class (cmesh, tree_id, cell_type); - /* Get the points of the cell */ - const int num_points = cell_it->GetNumberOfPoints (); - T8_ASSERT (num_points > 0); - points = cell_it->GetPoints (); - - for (int ipoint = 0; ipoint < num_points; ipoint++) { - points->GetPoint (t8_element_shape_vtk_corner_number - (cell_type, ipoint), &vertices[3 * ipoint]); - - } - /* The order of the vertices in vtk might give a tree with negative \param */ - if (t8_cmesh_tree_vertices_negative_volume - (cell_type, vertices, num_points)) { - t8_cmesh_correct_volume (vertices, cell_type); - } - t8_cmesh_set_tree_vertices (cmesh, tree_id, vertices, num_points); - - /* TODO: Avoid magic numbers in the attribute setting. */ - /* Get and set the data of each cell */ - for (int dtype = 0; dtype < num_data_arrays; dtype++) { - const t8_gloidx_t cell_id = cell_it->GetCellId (); - vtkDataArray *data = cell_data->GetArray (dtype); - data->GetTuple (cell_id, tuples[dtype]); - t8_cmesh_set_attribute (cmesh, tree_id, t8_get_package_id (), dtype + 1, - tuples[dtype], data_size[dtype], 0); - } - /* Check geometry-dimension */ - if (max_dim < cell_it->GetCellDimension ()) { - max_dim = cell_it->GetCellDimension (); - } - tree_id++; - } - t8_debugf ("[D] read %li trees\n", tree_id); - - /* Clean-up */ - cell_it->Delete (); - if (num_data_arrays > 0) { - T8_FREE (data_size); - for (int idata = num_data_arrays - 1; idata >= 0; idata--) { - T8_FREE (tuples[idata]); - } - T8_FREE (tuples); - } - T8_FREE (vertices); - return tree_id; -} - -/** - * Given a pointer to a vtkDataSet a cmesh representing the vtkDataSet is - * constructed and can be shared over the processes. - * - * \param[in] vtkGrid A pointer to a vtkDataSet - * \param[in] partition Flag if the cmesh should be partitioned - * \param[in] main_proc The main reading process - * \param[in] comm The communicator. - * \return t8_cmesh_t - */ -t8_cmesh_t -t8_vtkGrid_to_cmesh (vtkSmartPointer < vtkDataSet > vtkGrid, - const int partition, const int main_proc, - sc_MPI_Comm comm) -{ - t8_cmesh_t cmesh; - int mpisize; - int mpirank; - int mpiret; - /* Get the size of the communicator and the rank of the process. */ - mpiret = sc_MPI_Comm_size (comm, &mpisize); - SC_CHECK_MPI (mpiret); - mpiret = sc_MPI_Comm_rank (comm, &mpirank); - SC_CHECK_MPI (mpiret); - - /* Ensure that the main-proc is a valid proc. */ - T8_ASSERT (0 <= main_proc && main_proc < mpisize); - - /* Already declared here, because we might use them during communication */ - t8_gloidx_t num_trees; - int dim; - - t8_cmesh_init (&cmesh); - if (!partition || mpirank == main_proc) { - num_trees = t8_vtk_iterate_cells (vtkGrid, cmesh, comm); - dim = t8_get_dimension (vtkGrid); - t8_cmesh_set_dimension (cmesh, dim); - t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); - t8_cmesh_register_geometry (cmesh, linear_geom); - } - if (partition) { - t8_gloidx_t first_tree; - t8_gloidx_t last_tree; - if (mpirank == main_proc) { - first_tree = 0; - last_tree = num_trees - 1; - } - /* Communicate the dimension to all processes */ - sc_MPI_Bcast (&dim, 1, sc_MPI_INT, main_proc, comm); - t8_debugf ("[D] dim: %i\n", dim); - /* Communicate the number of trees to all processes. - * TODO: This probably crashes when a vtkGrid is distributed in many - * files. */ - sc_MPI_Bcast (&num_trees, 1, T8_MPI_GLOIDX, main_proc, comm); - t8_cmesh_set_dimension (cmesh, dim); - /* Build the partition. */ - if (mpirank < main_proc) { - first_tree = 0; - last_tree = -1; - t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); - t8_cmesh_register_geometry (cmesh, linear_geom); - } - else if (mpirank > main_proc) { - first_tree = num_trees; - last_tree = num_trees - 1; - t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); - t8_cmesh_register_geometry (cmesh, linear_geom); - } - t8_cmesh_set_partition_range (cmesh, 3, first_tree, last_tree); - } - if (cmesh != NULL) { - t8_cmesh_commit (cmesh, comm); - } - return cmesh; -} - -vtkSmartPointer < vtkPointSet > -t8_vtkGrid_to_vtkPointSet (vtkSmartPointer < vtkDataSet > vtkGrid) -{ - /* Set points */ - vtkSmartPointer < vtkPoints > points = vtkSmartPointer < vtkPoints >::New (); - const vtkIdType num_points = vtkGrid->GetNumberOfPoints (); - points->SetDataType (VTK_DOUBLE); - points->SetNumberOfPoints (num_points); - - for (vtkIdType ipoint = 0; ipoint < num_points; ipoint++) { - double vp[3]; - vtkGrid->GetPoint (ipoint, vp); - points->SetPoint (ipoint, vp); - } - points->Modified (); - T8_ASSERT (points->GetNumberOfPoints() == num_points); - vtkSmartPointer < vtkPointSet > cloud = - vtkSmartPointer < vtkPointSet >::New (); - cloud->SetPoints (points); - - /* Map cell data to point data */ - vtkSmartPointer < vtkCellDataToPointData > c2p = vtkCellDataToPointData::New (); - c2p->PassCellDataOff (); - c2p->SetInputData (vtkGrid); - c2p->Update (); - cloud->DeepCopy (c2p->GetOutput ()); - //cloud->DeepCopy (vtkPointSet::SafeDownCast (c2p->GetOutput ())); - - return cloud; -} - -vtkSmartPointer < vtkDataSet > -t8_vtk_reader (const char *filename, const int partition, - const int main_proc, sc_MPI_Comm comm, - const vtk_file_type_t vtk_file_type) -{ - int mpisize; - int mpirank; - int mpiret; - /* Get the size of the communicator and the rank of the process. */ - mpiret = sc_MPI_Comm_size (comm, &mpisize); - SC_CHECK_MPI (mpiret); - mpiret = sc_MPI_Comm_rank (comm, &mpirank); - SC_CHECK_MPI (mpiret); - - /* Ensure that the main-proc is a valid proc. */ - T8_ASSERT (0 <= main_proc && main_proc < mpisize); - T8_ASSERT (filename != NULL); - vtk_read_success_t main_proc_read_successful = read_failure; - - vtkSmartPointer < vtkDataSet > vtkGrid; - switch (vtk_file_type) { - case VTK_UNSTRUCTURED_FILE: - vtkGrid = vtkSmartPointer < vtkUnstructuredGrid >::New (); - break; - case VTK_POLYDATA_FILE: - vtkGrid = vtkSmartPointer < vtkPolyData >::New (); - break; - default: - t8_errorf ("Filetype is not supported.\n"); - break; - } - T8_ASSERT (partition == 0 || (main_proc >= 0 && main_proc < mpisize)); - /* Read the file and set the pointer. */ - main_proc_read_successful = - t8_file_to_vtkGrid (filename, vtkGrid, partition, main_proc, comm, - vtk_file_type); - - if (!main_proc_read_successful) { - t8_global_errorf - ("Main process (Rank %i) did not read the file successfully.\n", - main_proc); - return NULL; - } - else { - return vtkGrid; - } -} -#endif - -vtkSmartPointer < vtkPointSet > -t8_pointSet_vtk_reader (const char *filename, - const int partition, - const int main_proc, - sc_MPI_Comm comm, - const vtk_file_type_t vtk_file_type) -{ -#if T8_WITH_VTK - vtkSmartPointer < vtkDataSet > vtkGrid = - t8_vtk_reader (filename, partition, main_proc, comm, vtk_file_type); - return t8_vtkGrid_to_vtkPointSet (vtkGrid); -#else - /* Return NULL if not linked against vtk */ - t8_global_errorf - ("WARNING: t8code is not linked against the vtk library. Without proper linking t8code cannot use the vtk-reader\n"); -#endif - return NULL; -} - t8_cmesh_t t8_cmesh_vtk_reader (const char *filename, const int partition, const int main_proc, sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type) { -#if T8_WITH_VTK - vtkSmartPointer < vtkDataSet > vtkGrid = - t8_vtk_reader (filename, partition, main_proc, comm, vtk_file_type); - - t8_cmesh_t cmesh = t8_vtkGrid_to_cmesh (vtkGrid, partition, main_proc, comm); - T8_ASSERT (cmesh != NULL); - return cmesh; -#else - /* Return NULL if not linked against vtk */ - t8_global_errorf - ("WARNING: t8code is not linked against the vtk library. Without proper linking t8code cannot use the vtk-reader\n"); -#endif - return NULL; + return t8_vtk_reader_cmesh (filename, partition, main_proc, comm, vtk_file_type); } T8_EXTERN_C_END (); diff --git a/src/t8_cmesh_vtk_reader.hxx b/src/t8_cmesh_vtk_reader.hxx index 4013701858..58c02678a1 100644 --- a/src/t8_cmesh_vtk_reader.hxx +++ b/src/t8_cmesh_vtk_reader.hxx @@ -27,63 +27,10 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #ifndef T8_CMESH_VTK_READER #define T8_CMESH_VTK_READER -#include -#include - -#if T8_WITH_VTK -#include -#include -#include -#include -#endif +#include T8_EXTERN_C_BEGIN (); -#if T8_WITH_VTK - -/** - * Given a pointer to a vtkDataSet a cmesh representing the vtkDataSet is - * constructed and can be shared over the processes. - * - * \param[in] vtkGrid A pointer to a vtkDataSet - * \param[in] partition Flag if the cmesh should be partitioned - * \param[in] main_proc The main reading process - * \param[in] comm The communicator. - * \return t8_cmesh_t - */ -t8_cmesh_t t8_vtkGrid_to_cmesh (vtkSmartPointer < vtkDataSet > - vtkGrid, const int partition, - const int main_proc, - sc_MPI_Comm comm); - -/** - * Given a pointer to a vtkDataSet a vtkPointSet storing a set of points of - * is constructed. The cell data of vtkDataSet is mapt on the points of vtkPointSet. - * - * \param[in] vtkGrid A pointer to a vtkDataSet - * \return A pointer to a vtkPointSet - */ -vtkSmartPointer < vtkPointSet > t8_vtkGrid_to_vtkPointSet (vtkSmartPointer < vtkDataSet > vtkGrid); - -/** - * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and - * construct a abstract class to specify dataset behavior. The file is read and - * stored in a vtkDataSet. - * \note This function is only available if t8code is linked against VTK. - * - * \param[in] filename The name of the file - * \param[in] partition Flag if the constructed mesh should be partitioned - * \param[in] main_proc The main reading processor - * \param[in] comm An mpi-communicator - * \param[in] vtk_file_type A vtk-filetype that is readable by t8code. - * \return Pointer to vtkDataSet - */ -vtkSmartPointer < vtkDataSet > t8_vtk_reader (const char *filename, const int partition, - const int main_proc, sc_MPI_Comm comm, - const vtk_file_type_t vtk_file_type); - -#endif - /** * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and * construct a cmesh. This is a two stage process. First the file is read and @@ -107,29 +54,6 @@ t8_cmesh_t t8_cmesh_vtk_reader (const char *filename, sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type); -/** - * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and - * a set of points is constructed. This is a two stage process. First the file - * is read and stored in a vtkDataSet using \a t8_vtk_reader and - * \a t8_file_to_vtkGrid. In the second stage a vtkPointSet is constructed from - * the vtkDataSet using \a t8_vtkGrid_to_vtkPointSet. - * - * Both stages use the vtk-library, therefore the function is only available if - * t8code is linked against VTK. - * - * \param[in] filename The name of the file - * \param[in] partition Flag if the constructed mesh should be partitioned - * \param[in] main_proc The main reading processor - * \param[in] comm An mpi-communicator - * \param[in] vtk_file_type A vtk-filetype that is readable by t8code. - * \return Pointer to vtkDataSet - */ -vtkSmartPointer < vtkPointSet > t8_pointSet_vtk_reader (const char *filename, - const int partition, - const int main_proc, - sc_MPI_Comm comm, - const vtk_file_type_t vtk_file_type); - T8_EXTERN_C_END (); #endif /* T8_CMESH_VTK_READER */ diff --git a/src/t8_vtk/t8_vtk_reader.cxx b/src/t8_vtk/t8_vtk_reader.cxx new file mode 100644 index 0000000000..fba04928fe --- /dev/null +++ b/src/t8_vtk/t8_vtk_reader.cxx @@ -0,0 +1,482 @@ +/* +This file is part of t8code. +t8code is a C library to manage a collection (a forest) of multiple +connected adaptive space-trees of general element classes in parallel. + +Copyright (C) 2015 the developers + +t8code is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +t8code is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with t8code; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include /* To set tree vertices */ + +#include "t8_vtk_reader.hxx" +#include "t8_vtk_unstructured.hxx" +#include "t8_vtk_polydata.hxx" +#include "t8_vtk_types.h" +#include + +#if T8_WITH_VTK +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +T8_EXTERN_C_BEGIN (); + +/** + * If the vertices of a tree describe a negative \param, + * permute the tree vertices. + * + * \param[in, out] tree_vertices The vertices of a tree + * \param[in] eclass The eclass of the tree. + */ +void +t8_cmesh_correct_volume (double *tree_vertices, t8_eclass_t eclass) +{ + /* The \param described is negative. We need to change vertices. + * For tets we switch 0 and 3. + * For prisms we switch 0 and 3, 1 and 4, 2 and 5. + * For hexahedra we switch 0 and 4, 1 and 5, 2 and 6, 3 and 7. + * For pyramids we switch 0 and 4 */ + double temp; + int num_switches = 0; + int switch_indices[4] = { 0 }; + int iswitch; + T8_ASSERT (t8_eclass_to_dimension[eclass] == 3); + t8_debugf ("Correcting negative volume.\n"); + switch (eclass) { + case T8_ECLASS_TET: + /* We switch vertex 0 and vertex 3 */ + num_switches = 1; + switch_indices[0] = 3; + break; + case T8_ECLASS_PRISM: + num_switches = 3; + switch_indices[0] = 3; + switch_indices[1] = 4; + switch_indices[2] = 5; + break; + case T8_ECLASS_HEX: + num_switches = 4; + switch_indices[0] = 4; + switch_indices[1] = 5; + switch_indices[2] = 6; + switch_indices[3] = 7; + break; + case T8_ECLASS_PYRAMID: + num_switches = 1; + switch_indices[0] = 4; + break; + default: + SC_ABORT_NOT_REACHED (); + } + + for (iswitch = 0; iswitch < num_switches; ++iswitch) { + /* We switch vertex 0 + iswitch and vertex switch_indices[iswitch] */ + for (int i = 0; i < 3; i++) { + temp = tree_vertices[3 * iswitch + i]; + tree_vertices[3 * iswitch + i] = + tree_vertices[3 * switch_indices[iswitch] + i]; + tree_vertices[3 * switch_indices[iswitch] + i] = temp; + } + } + T8_ASSERT (!t8_cmesh_tree_vertices_negative_volume + (eclass, tree_vertices, t8_eclass_num_vertices[eclass])); +} + +#if T8_WITH_VTK + +vtk_read_success_t +t8_file_to_vtkGrid (const char *filename, + vtkSmartPointer < vtkDataSet > vtkGrid, + const int partition, const int main_proc, + sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type) +{ + vtk_read_success_t main_proc_read_successful = read_failure; + int mpirank; + int mpisize; + int mpiret; + mpiret = sc_MPI_Comm_rank (comm, &mpirank); + SC_CHECK_MPI (mpiret); + mpiret = sc_MPI_Comm_size (comm, &mpisize); + SC_CHECK_MPI (mpiret); + T8_ASSERT (filename != NULL); + T8_ASSERT (0 <= main_proc && main_proc < mpisize); + /* Read the file and set the pointer to the vtkGrid */ + if (!partition || mpirank == main_proc) { + switch (vtk_file_type) { + case VTK_UNSTRUCTURED_FILE: + main_proc_read_successful = t8_read_unstructured (filename, vtkGrid); + break; + case VTK_POLYDATA_FILE: + main_proc_read_successful = t8_read_poly (filename, vtkGrid); + break; + default: + vtkGrid = NULL; + t8_errorf ("Filetype not supported.\n"); + break; + } + if (partition) { + /* Communicate the success/failure of the reading process. */ + sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, + comm); + } + } + if (partition) { + sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, comm); + } + return main_proc_read_successful; +} + +/** + * Get the dimension of a vtkDataSet + * + * \param[in] vtkGrid The vtkDataSet + * \return The dimension of \a vtkGrid. + */ +int +t8_get_dimension (vtkSmartPointer < vtkDataSet > vtkGrid) +{ + /* This array contains the type of each cell */ + vtkSmartPointer < vtkCellTypes > cell_type_of_each_cell = + vtkSmartPointer < vtkCellTypes >::New (); + vtkGrid->GetCellTypes (cell_type_of_each_cell); + vtkSmartPointer < vtkUnsignedCharArray > cell_types = + cell_type_of_each_cell->GetCellTypesArray (); + int max_cell_type = -1; + const vtkIdType num_types = cell_types->GetNumberOfTuples (); + /* Iterate over all types and compare the dimension. They are stored + * in ascending order. */ + for (vtkIdType cell_types_it = 0; cell_types_it < num_types; + cell_types_it++) { + const vtkIdType type = cell_types->GetValue (cell_types_it); + if (type > max_cell_type) { + max_cell_type = type; + } + } + T8_ASSERT (0 <= max_cell_type && max_cell_type < 82); + const int ieclass = t8_cmesh_vtk_type_to_t8_type[max_cell_type]; + T8_ASSERT (ieclass != T8_ECLASS_INVALID); + + return t8_eclass_to_dimension[ieclass]; +} + +/** + * Iterate over all cells of a vtkDataset and construct a cmesh representing + * The vtkGrid. Each cell in the vtkDataSet becomes a tree in the cmesh. This + * function construct a cmesh on a single process. + * + * \param[in] vtkGrid The vtkGrid that gets tranlated + * \param[in, out] cmesh An empty cmesh that is filled with the data. + * \param[in] comm A communicator. + * \return The number of elements that have been read by the process. + */ + +t8_gloidx_t +t8_vtk_iterate_cells (vtkSmartPointer < vtkDataSet > vtkGrid, + t8_cmesh_t cmesh, sc_MPI_Comm comm) +{ + + double *vertices; + double **tuples; + size_t *data_size; + t8_gloidx_t tree_id = 0; + int max_dim = -1; + + vtkCellIterator *cell_it; + vtkSmartPointer < vtkPoints > points; + vtkSmartPointer < vtkCellData > cell_data = vtkGrid->GetCellData (); + const int max_cell_points = vtkGrid->GetMaxCellSize (); + + T8_ASSERT (max_cell_points >= 0); + vertices = T8_ALLOC (double, 3 * max_cell_points); + /* Get cell iterator */ + cell_it = vtkGrid->NewCellIterator (); + /* get the number of data-arrays per cell */ + const int num_data_arrays = cell_data->GetNumberOfArrays (); + T8_ASSERT (num_data_arrays >= 0); + + t8_debugf ("[D] read %i data-arrays\n", num_data_arrays); + /* Prepare attributes */ + if (num_data_arrays > 0) { + size_t tuple_size; + tuples = T8_ALLOC (double *, num_data_arrays); + data_size = T8_ALLOC (size_t, num_data_arrays); + for (int idata = 0; idata < num_data_arrays; idata++) { + vtkDataArray *data = cell_data->GetArray (idata); + tuple_size = data->GetNumberOfComponents (); + data_size[idata] = sizeof (double) * tuple_size; + t8_debugf ("[D] data_size[%i] = %li, tuple_size %li\n", idata, + data_size[idata], tuple_size); + /* Allocate memory for a tuple in array i */ + tuples[idata] = T8_ALLOC (double, tuple_size); + } + } + + /* Iterate over all cells */ + for (cell_it->InitTraversal (); !cell_it->IsDoneWithTraversal (); + cell_it->GoToNextCell ()) { + + /* Set the t8_eclass of the cell */ + const t8_eclass_t cell_type = + t8_cmesh_vtk_type_to_t8_type[cell_it->GetCellType ()]; + SC_CHECK_ABORTF (t8_eclass_is_valid (cell_type), + "vtk-cell-type %i not supported by t8code\n", cell_type); + t8_cmesh_set_tree_class (cmesh, tree_id, cell_type); + /* Get the points of the cell */ + const int num_points = cell_it->GetNumberOfPoints (); + T8_ASSERT (num_points > 0); + points = cell_it->GetPoints (); + + for (int ipoint = 0; ipoint < num_points; ipoint++) { + points->GetPoint (t8_element_shape_vtk_corner_number + (cell_type, ipoint), &vertices[3 * ipoint]); + + } + /* The order of the vertices in vtk might give a tree with negative \param */ + if (t8_cmesh_tree_vertices_negative_volume + (cell_type, vertices, num_points)) { + t8_cmesh_correct_volume (vertices, cell_type); + } + t8_cmesh_set_tree_vertices (cmesh, tree_id, vertices, num_points); + + /* TODO: Avoid magic numbers in the attribute setting. */ + /* Get and set the data of each cell */ + for (int dtype = 0; dtype < num_data_arrays; dtype++) { + const t8_gloidx_t cell_id = cell_it->GetCellId (); + vtkDataArray *data = cell_data->GetArray (dtype); + data->GetTuple (cell_id, tuples[dtype]); + t8_cmesh_set_attribute (cmesh, tree_id, t8_get_package_id (), dtype + 1, + tuples[dtype], data_size[dtype], 0); + } + /* Check geometry-dimension */ + if (max_dim < cell_it->GetCellDimension ()) { + max_dim = cell_it->GetCellDimension (); + } + tree_id++; + } + t8_debugf ("[D] read %li trees\n", tree_id); + + /* Clean-up */ + cell_it->Delete (); + if (num_data_arrays > 0) { + T8_FREE (data_size); + for (int idata = num_data_arrays - 1; idata >= 0; idata--) { + T8_FREE (tuples[idata]); + } + T8_FREE (tuples); + } + T8_FREE (vertices); + return tree_id; +} + +t8_cmesh_t +t8_vtkGrid_to_cmesh (vtkSmartPointer < vtkDataSet > vtkGrid, + const int partition, const int main_proc, + sc_MPI_Comm comm) +{ + t8_cmesh_t cmesh; + int mpisize; + int mpirank; + int mpiret; + /* Get the size of the communicator and the rank of the process. */ + mpiret = sc_MPI_Comm_size (comm, &mpisize); + SC_CHECK_MPI (mpiret); + mpiret = sc_MPI_Comm_rank (comm, &mpirank); + SC_CHECK_MPI (mpiret); + + /* Ensure that the main-proc is a valid proc. */ + T8_ASSERT (0 <= main_proc && main_proc < mpisize); + + /* Already declared here, because we might use them during communication */ + t8_gloidx_t num_trees; + int dim; + + t8_cmesh_init (&cmesh); + if (!partition || mpirank == main_proc) { + num_trees = t8_vtk_iterate_cells (vtkGrid, cmesh, comm); + dim = t8_get_dimension (vtkGrid); + t8_cmesh_set_dimension (cmesh, dim); + t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); + t8_cmesh_register_geometry (cmesh, linear_geom); + } + if (partition) { + t8_gloidx_t first_tree; + t8_gloidx_t last_tree; + if (mpirank == main_proc) { + first_tree = 0; + last_tree = num_trees - 1; + } + /* Communicate the dimension to all processes */ + sc_MPI_Bcast (&dim, 1, sc_MPI_INT, main_proc, comm); + t8_debugf ("[D] dim: %i\n", dim); + /* Communicate the number of trees to all processes. + * TODO: This probably crashes when a vtkGrid is distributed in many + * files. */ + sc_MPI_Bcast (&num_trees, 1, T8_MPI_GLOIDX, main_proc, comm); + t8_cmesh_set_dimension (cmesh, dim); + /* Build the partition. */ + if (mpirank < main_proc) { + first_tree = 0; + last_tree = -1; + t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); + t8_cmesh_register_geometry (cmesh, linear_geom); + } + else if (mpirank > main_proc) { + first_tree = num_trees; + last_tree = num_trees - 1; + t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); + t8_cmesh_register_geometry (cmesh, linear_geom); + } + t8_cmesh_set_partition_range (cmesh, 3, first_tree, last_tree); + } + if (cmesh != NULL) { + t8_cmesh_commit (cmesh, comm); + } + return cmesh; +} + +vtkSmartPointer < vtkPointSet > +t8_vtkGrid_to_vtkPointSet (vtkSmartPointer < vtkDataSet > vtkGrid) +{ + /* Set points */ + vtkSmartPointer < vtkPoints > points = vtkSmartPointer < vtkPoints >::New (); + const vtkIdType num_points = vtkGrid->GetNumberOfPoints (); + points->SetDataType (VTK_DOUBLE); + points->SetNumberOfPoints (num_points); + + for (vtkIdType ipoint = 0; ipoint < num_points; ipoint++) { + double vp[3]; + vtkGrid->GetPoint (ipoint, vp); + points->SetPoint (ipoint, vp); + } + points->Modified (); + T8_ASSERT (points->GetNumberOfPoints() == num_points); + vtkSmartPointer < vtkPointSet > cloud = + vtkSmartPointer < vtkPointSet >::New (); + cloud->SetPoints (points); + + /* Map cell data to point data */ + vtkSmartPointer < vtkCellDataToPointData > c2p = vtkCellDataToPointData::New (); + c2p->PassCellDataOff (); + c2p->SetInputData (vtkGrid); + c2p->Update (); + cloud->DeepCopy (c2p->GetOutput ()); + //cloud->DeepCopy (vtkPointSet::SafeDownCast (c2p->GetOutput ())); + + return cloud; +} + +vtkSmartPointer < vtkDataSet > +t8_vtk_reader (const char *filename, const int partition, + const int main_proc, sc_MPI_Comm comm, + const vtk_file_type_t vtk_file_type) +{ + int mpisize; + int mpirank; + int mpiret; + /* Get the size of the communicator and the rank of the process. */ + mpiret = sc_MPI_Comm_size (comm, &mpisize); + SC_CHECK_MPI (mpiret); + mpiret = sc_MPI_Comm_rank (comm, &mpirank); + SC_CHECK_MPI (mpiret); + + /* Ensure that the main-proc is a valid proc. */ + T8_ASSERT (0 <= main_proc && main_proc < mpisize); + T8_ASSERT (filename != NULL); + vtk_read_success_t main_proc_read_successful = read_failure; + + vtkSmartPointer < vtkDataSet > vtkGrid; + switch (vtk_file_type) { + case VTK_UNSTRUCTURED_FILE: + vtkGrid = vtkSmartPointer < vtkUnstructuredGrid >::New (); + break; + case VTK_POLYDATA_FILE: + vtkGrid = vtkSmartPointer < vtkPolyData >::New (); + break; + default: + t8_errorf ("Filetype is not supported.\n"); + break; + } + T8_ASSERT (partition == 0 || (main_proc >= 0 && main_proc < mpisize)); + /* Read the file and set the pointer. */ + main_proc_read_successful = + t8_file_to_vtkGrid (filename, vtkGrid, partition, main_proc, comm, + vtk_file_type); + + if (!main_proc_read_successful) { + t8_global_errorf + ("Main process (Rank %i) did not read the file successfully.\n", + main_proc); + return NULL; + } + else { + return vtkGrid; + } +} +#endif + +vtkSmartPointer < vtkPointSet > +t8_pointSet_vtk_reader (const char *filename, + const int partition, + const int main_proc, + sc_MPI_Comm comm, + const vtk_file_type_t vtk_file_type) +{ +#if T8_WITH_VTK + vtkSmartPointer < vtkDataSet > vtkGrid = + t8_vtk_reader (filename, partition, main_proc, comm, vtk_file_type); + return t8_vtkGrid_to_vtkPointSet (vtkGrid); +#else + /* Return NULL if not linked against vtk */ + t8_global_errorf + ("WARNING: t8code is not linked against the vtk library. Without proper linking t8code cannot use the vtk-reader\n"); +#endif + return NULL; +} + +t8_cmesh_t +t8_vtk_reader_cmesh (const char *filename, const int partition, + const int main_proc, sc_MPI_Comm comm, + const vtk_file_type_t vtk_file_type) +{ +#if T8_WITH_VTK + vtkSmartPointer < vtkDataSet > vtkGrid = + t8_vtk_reader (filename, partition, main_proc, comm, vtk_file_type); + + t8_cmesh_t cmesh = t8_vtkGrid_to_cmesh (vtkGrid, partition, main_proc, comm); + T8_ASSERT (cmesh != NULL); + return cmesh; +#else + /* Return NULL if not linked against vtk */ + t8_global_errorf + ("WARNING: t8code is not linked against the vtk library. Without proper linking t8code cannot use the vtk-reader\n"); +#endif + return NULL; +} + +T8_EXTERN_C_END (); \ No newline at end of file diff --git a/src/t8_vtk/t8_vtk_reader.hxx b/src/t8_vtk/t8_vtk_reader.hxx new file mode 100644 index 0000000000..e80ff32d7b --- /dev/null +++ b/src/t8_vtk/t8_vtk_reader.hxx @@ -0,0 +1,131 @@ +/* +This file is part of t8code. +t8code is a C library to manage a collection (a forest) of multiple +connected adaptive space-trees of general element classes in parallel. + +Copyright (C) 2015 the developers + +t8code is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +t8code is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with t8code; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef T8_VTK_READER +#define T8_VTK_READER + +#include +#include "t8_vtk_types.h" + +#if T8_WITH_VTK +#include +#include +#include +#include +#endif + +T8_EXTERN_C_BEGIN (); + +#if T8_WITH_VTK + +/** + * Given a pointer to a vtkDataSet a cmesh representing the vtkDataSet is + * constructed and can be shared over the processes. + * + * \param[in] vtkGrid A pointer to a vtkDataSet + * \param[in] partition Flag if the cmesh should be partitioned + * \param[in] main_proc The main reading process + * \param[in] comm The communicator. + * \return t8_cmesh_t + */ +t8_cmesh_t t8_vtkGrid_to_cmesh (vtkSmartPointer < vtkDataSet > + vtkGrid, const int partition, + const int main_proc, + sc_MPI_Comm comm); + +/** + * Given a pointer to a vtkDataSet a vtkPointSet storing a set of points of + * is constructed. The cell data of vtkDataSet is mapt on the points of vtkPointSet. + * + * \param[in] vtkGrid A pointer to a vtkDataSet + * \return A pointer to a vtkPointSet + */ +vtkSmartPointer < vtkPointSet > t8_vtkGrid_to_vtkPointSet (vtkSmartPointer < vtkDataSet > vtkGrid); + +/** + * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and + * construct a abstract class to specify dataset behavior. The file is read and + * stored in a vtkDataSet. + * \note This function is only available if t8code is linked against VTK. + * + * \param[in] filename The name of the file + * \param[in] partition Flag if the constructed mesh should be partitioned + * \param[in] main_proc The main reading processor + * \param[in] comm An mpi-communicator + * \param[in] vtk_file_type A vtk-filetype that is readable by t8code. + * \return Pointer to vtkDataSet + */ +vtkSmartPointer < vtkDataSet > t8_vtk_reader (const char *filename, const int partition, + const int main_proc, sc_MPI_Comm comm, + const vtk_file_type_t vtk_file_type); + +#endif + +/** + * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and + * construct a cmesh. This is a two stage process. First the file is read and + * stored in a vtkDataSet using \a t8_vtk_reader and \a t8_file_to_vtkGrid. + * In the second stage a cmesh is constructed from the vtkDataSet using \a t8_vtkGrid_to_cmesh. + * + * Both stages use the vtk-library, therefore the function is only available if + * t8code is linked against VTK. + * + * + * \param[in] filename The name of the file + * \param[in] partition Flag if the constructed mesh should be partitioned + * \param[in] main_proc The main reading processor + * \param[in] comm An mpi-communicator + * \param[in] vtk_file_type A vtk-filetype that is readable by t8code. + * \return A commited cmesh. + */ +t8_cmesh_t t8_vtk_reader_cmesh (const char *filename, + const int partition, + const int main_proc, + sc_MPI_Comm comm, + const vtk_file_type_t vtk_file_type); + +/** + * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and + * a set of points is constructed. This is a two stage process. First the file + * is read and stored in a vtkDataSet using \a t8_vtk_reader and + * \a t8_file_to_vtkGrid. In the second stage a vtkPointSet is constructed from + * the vtkDataSet using \a t8_vtkGrid_to_vtkPointSet. + * + * Both stages use the vtk-library, therefore the function is only available if + * t8code is linked against VTK. + * + * \param[in] filename The name of the file + * \param[in] partition Flag if the constructed mesh should be partitioned + * \param[in] main_proc The main reading processor + * \param[in] comm An mpi-communicator + * \param[in] vtk_file_type A vtk-filetype that is readable by t8code. + * \return Pointer to vtkDataSet + */ +vtkSmartPointer < vtkPointSet > t8_pointSet_vtk_reader (const char *filename, + const int partition, + const int main_proc, + sc_MPI_Comm comm, + const vtk_file_type_t vtk_file_type); + +T8_EXTERN_C_END (); + +#endif /* T8_VTK_READER */ \ No newline at end of file From 0611e49be454c4eb08327dd04cae92cae44b7030 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Wed, 26 Apr 2023 16:37:04 +0200 Subject: [PATCH 138/255] Fix wrong number in comment --- src/t8_cmesh/t8_cmesh_examples.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 3867279c6c..c5c7d134a2 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -69,7 +69,7 @@ t8_cmesh_t t8_cmesh_new_from_p8est (p8est_connectivity_t * conn, * this function is merely for debugging and to show the possibility. * \param [in] comm mpi communicator to be used with the new cmesh. * \param [in] do_partition Flag whether the cmesh should be partitioned or not. - * \param [in] dimension An empty cmesh requires a dimension nevertheless 0 <= \a dimension <= 4. + * \param [in] dimension An empty cmesh requires a dimension nevertheless. 0 <= \a dimension <= 3. * \return A committed t8_cmesh structure that has no trees. */ t8_cmesh_t t8_cmesh_new_empty (sc_MPI_Comm comm, int do_partition, From f2c999dccad93a7fe1da9bec8fa7e2e79661aa35 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Wed, 26 Apr 2023 17:20:09 +0200 Subject: [PATCH 139/255] add link to t8code paper in text. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7db51505c8..f04675af25 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,8 @@ Currently, You find more information on t8code in the [t8code Wiki](https://github.com/DLR-AMR/t8code/wiki). +For a brief introduction in AMR and the algorithms used by t8code we recommend to read our [overview paper](https://elib.dlr.de/194377/1/t8code_overview_IMR2023.pdf). + ### Setup We provide a short guide to install t8code. From 36d8700793bf0ab3bef5816cc7e86ccde4b0d6f9 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Wed, 26 Apr 2023 17:23:55 +0200 Subject: [PATCH 140/255] Add overview paper and make paper titles *italic* --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f04675af25..b22fdc6585 100644 --- a/README.md +++ b/README.md @@ -138,14 +138,18 @@ You can also find the documentation of our releases on the [t8code website](http An (incomplete) list of publications related to t8code: - [1] Johannes Holke, Scalable algorithms for parallel tree-based adaptive mesh refinement with general element types, PhD thesis at University of Bonn, 2018, + [1] Holke, Johannes und Burstedde, Carsten und Knapp, David und Dreyer, Lukas und Elsweijer, Sandro und Ãœnlü, Veli und Markert, Johannes und Lilikakis, Ioannis und Böing, Niklas und Ponnusamy, Prasanna und Basermann, Achim (2023) *t8code v. 1.0 - Modular Adaptive Mesh Refinement in the Exascale Era*. SIAM International Meshing Round Table 2023, 06.03.2023 - 09.03.2023, Amsterdam, Niederlande. + [Full text available](https://elib.dlr.de/194377/1/t8code_overview_IMR2023.pdf) + + + [2] Johannes Holke, *Scalable algorithms for parallel tree-based adaptive mesh refinement with general element types*, PhD thesis at University of Bonn, 2018, [Full text available](https://bonndoc.ulb.uni-bonn.de/xmlui/handle/20.500.11811/7661) - [2] Carsten Burstedde and Johannes Holke, A Tetrahedral Space-Filling Curve for Nonconforming Adaptive Meshes, SIAM Journal on Scientific Computing, 2016, [10.1137/15M1040049](https://epubs.siam.org/doi/10.1137/15M1040049) + [3] Carsten Burstedde and Johannes Holke, *A Tetrahedral Space-Filling Curve for Nonconforming Adaptive Meshes*, SIAM Journal on Scientific Computing, 2016, [10.1137/15M1040049](https://epubs.siam.org/doi/10.1137/15M1040049) - [3] Carsten Burstedde and Johannes Holke, Coarse mesh partitioning for tree-based AMR, SIAM Journal on Scientific Computing, 2017, [10.1137/16M1103518](https://epubs.siam.org/doi/10.1137/16M1103518) + [4] Carsten Burstedde and Johannes Holke, *Coarse mesh partitioning for tree-based AMR*, SIAM Journal on Scientific Computing, 2017, [10.1137/16M1103518](https://epubs.siam.org/doi/10.1137/16M1103518) - [4] Johannes Holke and David Knapp and Carsten Burstedde, An Optimized, Parallel Computation of the Ghost Layer for Adaptive Hybrid Forest Meshes, SIAM Journal on Scientific Computing, 2021, [10.1137/20M1383033](https://epubs.siam.org/doi/abs/10.1137/20M1383033) + [5] Johannes Holke and David Knapp and Carsten Burstedde, *An Optimized, Parallel Computation of the Ghost Layer for Adaptive Hybrid Forest Meshes*, SIAM Journal on Scientific Computing, 2021, [10.1137/20M1383033](https://epubs.siam.org/doi/abs/10.1137/20M1383033) ### Citing t8code From 8371dd07f62cf06d4257944db535517f60bb61fa Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Wed, 26 Apr 2023 17:29:04 +0200 Subject: [PATCH 141/255] Add description of papers in bold --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b22fdc6585..6dc94ff6f9 100644 --- a/README.md +++ b/README.md @@ -140,20 +140,24 @@ You can also find the documentation of our releases on the [t8code website](http [1] Holke, Johannes und Burstedde, Carsten und Knapp, David und Dreyer, Lukas und Elsweijer, Sandro und Ãœnlü, Veli und Markert, Johannes und Lilikakis, Ioannis und Böing, Niklas und Ponnusamy, Prasanna und Basermann, Achim (2023) *t8code v. 1.0 - Modular Adaptive Mesh Refinement in the Exascale Era*. SIAM International Meshing Round Table 2023, 06.03.2023 - 09.03.2023, Amsterdam, Niederlande. [Full text available](https://elib.dlr.de/194377/1/t8code_overview_IMR2023.pdf) - + **Overview Paper** [2] Johannes Holke, *Scalable algorithms for parallel tree-based adaptive mesh refinement with general element types*, PhD thesis at University of Bonn, 2018, [Full text available](https://bonndoc.ulb.uni-bonn.de/xmlui/handle/20.500.11811/7661) + **Original PhD thesis** [3] Carsten Burstedde and Johannes Holke, *A Tetrahedral Space-Filling Curve for Nonconforming Adaptive Meshes*, SIAM Journal on Scientific Computing, 2016, [10.1137/15M1040049](https://epubs.siam.org/doi/10.1137/15M1040049) + **Tetrahedral and triangular Space-filling curve** [4] Carsten Burstedde and Johannes Holke, *Coarse mesh partitioning for tree-based AMR*, SIAM Journal on Scientific Computing, 2017, [10.1137/16M1103518](https://epubs.siam.org/doi/10.1137/16M1103518) + **Coarse mesh partitioning** [5] Johannes Holke and David Knapp and Carsten Burstedde, *An Optimized, Parallel Computation of the Ghost Layer for Adaptive Hybrid Forest Meshes*, SIAM Journal on Scientific Computing, 2021, [10.1137/20M1383033](https://epubs.siam.org/doi/abs/10.1137/20M1383033) + **Ghost computation** ### Citing t8code - If you use t8code in any of your publications, please cite the [github repository](https://doi.org/10.5281/zenodo.7034838) and [1]. For publications specifically related to -- the TM index, please cite [2]. -- coarse mesh partitioning, please cite [3]. -- construction and handling of the ghost layer, please cite [4]. + If you use t8code in any of your publications, please cite the [github repository](https://doi.org/10.5281/zenodo.7034838), [1] and [2]. For publications specifically related to +- the TM index, please cite [3]. +- coarse mesh partitioning, please cite [4]. +- construction and handling of the ghost layer, please cite [5]. From 905c5b6a95029a5d98cd74988aba423ab7c3a656 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Wed, 26 Apr 2023 17:33:49 +0200 Subject: [PATCH 142/255] Add geometry paper --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6dc94ff6f9..d35a2b048d 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,8 @@ You can also find the documentation of our releases on the [t8code website](http [5] Johannes Holke and David Knapp and Carsten Burstedde, *An Optimized, Parallel Computation of the Ghost Layer for Adaptive Hybrid Forest Meshes*, SIAM Journal on Scientific Computing, 2021, [10.1137/20M1383033](https://epubs.siam.org/doi/abs/10.1137/20M1383033) **Ghost computation** + [6] Elsweijer, Sandro und Holke, Johannes und Kleinert, Jan und Reith, Dirk (2022) Constructing a Volume Geometry Map for Hexahedra with Curved Boundary Geometries. In: SIAM International Meshing Roundtable Workshop 2022. SIAM International Meshing Roundtable Workshop 2022, 22. - 25. Feb. 2022, [Full text available](https://elib.dlr.de/186570/1/ConstructingAVolumeGeometryMapForHexahedraWithCurvedBoundaryGeometries.pdf) **Geometry controlled refinement for hexahedra** + ### Citing t8code If you use t8code in any of your publications, please cite the [github repository](https://doi.org/10.5281/zenodo.7034838), [1] and [2]. For publications specifically related to From 97609c3de1f78cb7f7364f23ad2b9015a959099d Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Wed, 26 Apr 2023 17:55:20 +0200 Subject: [PATCH 143/255] Add theses --- README.md | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d35a2b048d..2e46510e88 100644 --- a/README.md +++ b/README.md @@ -155,11 +155,52 @@ You can also find the documentation of our releases on the [t8code website](http [5] Johannes Holke and David Knapp and Carsten Burstedde, *An Optimized, Parallel Computation of the Ghost Layer for Adaptive Hybrid Forest Meshes*, SIAM Journal on Scientific Computing, 2021, [10.1137/20M1383033](https://epubs.siam.org/doi/abs/10.1137/20M1383033) **Ghost computation** - [6] Elsweijer, Sandro und Holke, Johannes und Kleinert, Jan und Reith, Dirk (2022) Constructing a Volume Geometry Map for Hexahedra with Curved Boundary Geometries. In: SIAM International Meshing Roundtable Workshop 2022. SIAM International Meshing Roundtable Workshop 2022, 22. - 25. Feb. 2022, [Full text available](https://elib.dlr.de/186570/1/ConstructingAVolumeGeometryMapForHexahedraWithCurvedBoundaryGeometries.pdf) **Geometry controlled refinement for hexahedra** + [6] Elsweijer, Sandro und Holke, Johannes und Kleinert, Jan und Reith, Dirk (2022) *Constructing a Volume Geometry Map for Hexahedra with Curved Boundary Geometries*. In: SIAM International Meshing Roundtable Workshop 2022. SIAM International Meshing Roundtable Workshop 2022, 22. - 25. Feb. 2022, [Full text available](https://elib.dlr.de/186570/1/ConstructingAVolumeGeometryMapForHexahedraWithCurvedBoundaryGeometries.pdf) **Geometry controlled refinement for hexahedra** +### Theses with t8code relations + + An (incomplete) list of theses written with or about t8code: + + + [A] Knapp, David (2017) *Adaptive Verfeinerung von Prismen*. Bachelor's thesis, Rheinische Friedrich-Wilhems-Universität Bonn. + **Prism space-filling curve** + + [B] Knapp, David (2020) *A space-filling curve for pyramidal adaptive mesh refinement*. Master's thesis, Rheinische Friedrich-Wilhems-Universität Bonn. + **Pyramidal space-filling curve** + + [C] Dreyer, Lukas (2021) *The local discontinuous galerkin method for the advection-diffusion equation on adaptive meshes*. Master's thesis, Rheinische Friedrich-Wilhems-Universität Bonn. + [Full text available] (https://elib.dlr.de/143969/1/masterthesis_dreyer.pdf) + **DG solver based on t8code** + + [D] Elsweijer, Sandro (2021) *Curved Domain Adaptive Mesh Refinement with Hexahedra*. Tech report, Hochschule Bonn-Rhein-Sieg. + [Full text available] (https://elib.dlr.de/186571/1/masterprojekt-2_elsweijer_ABGABEVERSION_TITEL.pdf) + **Geometry controlled refinement for hexahedra (Part 1)** + + [E] Becker, Florian (2021) *Removing hanging faces from tree-based adaptive meshes for numerical simulation*, Master's thesis, Universität zu Köln. + [Full text available](https://elib.dlr.de/187499/1/RemovingHangingFacesFromTreeBasedAMR.pdf) + **Subelement and resolving hanging faces in 2D** + + [F] Spataro, Luca (2021) *Lossy data compression for atmospheric chemistry using adaptive mesh coarsening*. Master's thesis, Technische Universität München. + [Full text available](https://elib.dlr.de/144997/1/master-thesis-final-spataro.pdf) + **Coarsening as post-processing to reduce simulation file size** + + [G] Elsweijer, Sandro (2022) *Evaluation and generic application scenarios for curved hexahedral adaptive mesh refinement*. Master's thesis, Hochschule Bonn-Rhein-Sieg. [10.13140/RG.2.2.34714.11203]() [Full text available](https://elib.dlr.de/186561/1/sandro_elsweijer-evaluation_and_generic_application_scenarios_for_curved_hexahedral_adaptive_mesh_refinement.pdf) + **Geometry controlled refinement for hexahedra (Part 2)** + + [H] Böing, Niklas (2022) *Evaluation of preconditioners for implicit solvers of local DG for the advection-diffusion equation* (*Untersuchung von Präkonditionierern für implizite Löser für das Local DG-Verfahren zur Lösung der Advektions-Diffusionsgleichung*). Master's thesis, Universität zu Köln. +[Full text available](https://elib.dlr.de/186347/1/Untersuchung%20von%20Pr%C3%A4konditionierern%20f%C3%BCr%20implizite%20L%C3%B6ser%20f%C3%BCr%20das%20Local%20DG-Verfahren%20zur%20L%C3%B6sung%20der%20Advektions-Diffusionsgleichung.pdf) + **Multigrid and other preconditioners for DG** + + [I] Lilikakis, Ioannis (2022) *Algorithms for tree-based adaptive meshes with incomplete trees*. Master's thesis, Universität zu Köln. + [Full text may be available in future](https://elib.dlr.de/191968/) + **Removing elements from the mesh (cutting holes)** + ### Citing t8code If you use t8code in any of your publications, please cite the [github repository](https://doi.org/10.5281/zenodo.7034838), [1] and [2]. For publications specifically related to -- the TM index, please cite [3]. -- coarse mesh partitioning, please cite [4]. -- construction and handling of the ghost layer, please cite [5]. +- **the tetrahedral index**, please cite [3]. +- **coarse mesh partitioning**, please cite [4]. +- **construction and handling of the ghost layer**, please cite [5]. +- **Geometry controlled refinement**, please cite [6] + +If you use any functionality described in the theses, we encourage you to cite them as well. From 9e701a62f0ee7e2ee424df25ef8e2389415ba560 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Wed, 26 Apr 2023 17:58:25 +0200 Subject: [PATCH 144/255] Add bold description to front. --- README.md | 64 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 2e46510e88..965030d9c0 100644 --- a/README.md +++ b/README.md @@ -138,62 +138,68 @@ You can also find the documentation of our releases on the [t8code website](http An (incomplete) list of publications related to t8code: - [1] Holke, Johannes und Burstedde, Carsten und Knapp, David und Dreyer, Lukas und Elsweijer, Sandro und Ãœnlü, Veli und Markert, Johannes und Lilikakis, Ioannis und Böing, Niklas und Ponnusamy, Prasanna und Basermann, Achim (2023) *t8code v. 1.0 - Modular Adaptive Mesh Refinement in the Exascale Era*. SIAM International Meshing Round Table 2023, 06.03.2023 - 09.03.2023, Amsterdam, Niederlande. + [1] **Overview Paper**: Holke, Johannes und Burstedde, Carsten und Knapp, David und Dreyer, Lukas und Elsweijer, Sandro und Ãœnlü, Veli und Markert, Johannes und Lilikakis, Ioannis und Böing, Niklas und Ponnusamy, Prasanna und Basermann, Achim (2023) *t8code v. 1.0 - Modular Adaptive Mesh Refinement in the Exascale Era*. SIAM International Meshing Round Table 2023, 06.03.2023 - 09.03.2023, Amsterdam, Niederlande. [Full text available](https://elib.dlr.de/194377/1/t8code_overview_IMR2023.pdf) - **Overview Paper** + - [2] Johannes Holke, *Scalable algorithms for parallel tree-based adaptive mesh refinement with general element types*, PhD thesis at University of Bonn, 2018, + [2] **Original PhD thesis**: Johannes Holke, *Scalable algorithms for parallel tree-based adaptive mesh refinement with general element types*, PhD thesis at University of Bonn, 2018, [Full text available](https://bonndoc.ulb.uni-bonn.de/xmlui/handle/20.500.11811/7661) - **Original PhD thesis** + - [3] Carsten Burstedde and Johannes Holke, *A Tetrahedral Space-Filling Curve for Nonconforming Adaptive Meshes*, SIAM Journal on Scientific Computing, 2016, [10.1137/15M1040049](https://epubs.siam.org/doi/10.1137/15M1040049) - **Tetrahedral and triangular Space-filling curve** + [3] **Tetrahedral and triangular Space-filling curve**: + Carsten Burstedde and Johannes Holke, *A Tetrahedral Space-Filling Curve for Nonconforming Adaptive Meshes*, SIAM Journal on Scientific Computing, 2016, [10.1137/15M1040049](https://epubs.siam.org/doi/10.1137/15M1040049) - [4] Carsten Burstedde and Johannes Holke, *Coarse mesh partitioning for tree-based AMR*, SIAM Journal on Scientific Computing, 2017, [10.1137/16M1103518](https://epubs.siam.org/doi/10.1137/16M1103518) - **Coarse mesh partitioning** - [5] Johannes Holke and David Knapp and Carsten Burstedde, *An Optimized, Parallel Computation of the Ghost Layer for Adaptive Hybrid Forest Meshes*, SIAM Journal on Scientific Computing, 2021, [10.1137/20M1383033](https://epubs.siam.org/doi/abs/10.1137/20M1383033) - **Ghost computation** + [4] **Coarse mesh partitioning**: + Carsten Burstedde and Johannes Holke, *Coarse mesh partitioning for tree-based AMR*, SIAM Journal on Scientific Computing, 2017, [10.1137/16M1103518](https://epubs.siam.org/doi/10.1137/16M1103518) - [6] Elsweijer, Sandro und Holke, Johannes und Kleinert, Jan und Reith, Dirk (2022) *Constructing a Volume Geometry Map for Hexahedra with Curved Boundary Geometries*. In: SIAM International Meshing Roundtable Workshop 2022. SIAM International Meshing Roundtable Workshop 2022, 22. - 25. Feb. 2022, [Full text available](https://elib.dlr.de/186570/1/ConstructingAVolumeGeometryMapForHexahedraWithCurvedBoundaryGeometries.pdf) **Geometry controlled refinement for hexahedra** + + [5] **Ghost computation**: + Johannes Holke and David Knapp and Carsten Burstedde, *An Optimized, Parallel Computation of the Ghost Layer for Adaptive Hybrid Forest Meshes*, SIAM Journal on Scientific Computing, 2021, [10.1137/20M1383033](https://epubs.siam.org/doi/abs/10.1137/20M1383033) + + + [6] **Geometry controlled refinement for hexahedra**: + Elsweijer, Sandro und Holke, Johannes und Kleinert, Jan und Reith, Dirk (2022) *Constructing a Volume Geometry Map for Hexahedra with Curved Boundary Geometries*. In: SIAM International Meshing Roundtable Workshop 2022. SIAM International Meshing Roundtable Workshop 2022, 22. - 25. Feb. 2022, [Full text available](https://elib.dlr.de/186570/1/ConstructingAVolumeGeometryMapForHexahedraWithCurvedBoundaryGeometries.pdf) ### Theses with t8code relations An (incomplete) list of theses written with or about t8code: - [A] Knapp, David (2017) *Adaptive Verfeinerung von Prismen*. Bachelor's thesis, Rheinische Friedrich-Wilhems-Universität Bonn. - **Prism space-filling curve** + [A] **Prism space-filling curve**: + Knapp, David (2017) *Adaptive Verfeinerung von Prismen*. Bachelor's thesis, Rheinische Friedrich-Wilhems-Universität Bonn. + + + [B] **Pyramidal space-filling curve**: + Knapp, David (2020) *A space-filling curve for pyramidal adaptive mesh refinement*. Master's thesis, Rheinische Friedrich-Wilhems-Universität Bonn. - [B] Knapp, David (2020) *A space-filling curve for pyramidal adaptive mesh refinement*. Master's thesis, Rheinische Friedrich-Wilhems-Universität Bonn. - **Pyramidal space-filling curve** - [C] Dreyer, Lukas (2021) *The local discontinuous galerkin method for the advection-diffusion equation on adaptive meshes*. Master's thesis, Rheinische Friedrich-Wilhems-Universität Bonn. + [C] **DG solver based on t8code**: Dreyer, Lukas (2021) *The local discontinuous galerkin method for the advection-diffusion equation on adaptive meshes*. Master's thesis, Rheinische Friedrich-Wilhems-Universität Bonn. [Full text available] (https://elib.dlr.de/143969/1/masterthesis_dreyer.pdf) - **DG solver based on t8code** - [D] Elsweijer, Sandro (2021) *Curved Domain Adaptive Mesh Refinement with Hexahedra*. Tech report, Hochschule Bonn-Rhein-Sieg. + + [D] **Geometry controlled refinement for hexahedra (Part 1)**: Elsweijer, Sandro (2021) *Curved Domain Adaptive Mesh Refinement with Hexahedra*. Tech report, Hochschule Bonn-Rhein-Sieg. [Full text available] (https://elib.dlr.de/186571/1/masterprojekt-2_elsweijer_ABGABEVERSION_TITEL.pdf) - **Geometry controlled refinement for hexahedra (Part 1)** + - [E] Becker, Florian (2021) *Removing hanging faces from tree-based adaptive meshes for numerical simulation*, Master's thesis, Universität zu Köln. + [E] **Subelement and resolving hanging faces in 2D**: Becker, Florian (2021) *Removing hanging faces from tree-based adaptive meshes for numerical simulation*, Master's thesis, Universität zu Köln. [Full text available](https://elib.dlr.de/187499/1/RemovingHangingFacesFromTreeBasedAMR.pdf) - **Subelement and resolving hanging faces in 2D** - [F] Spataro, Luca (2021) *Lossy data compression for atmospheric chemistry using adaptive mesh coarsening*. Master's thesis, Technische Universität München. + + [F] **Coarsening as post-processing to reduce simulation file size**: Spataro, Luca (2021) *Lossy data compression for atmospheric chemistry using adaptive mesh coarsening*. Master's thesis, Technische Universität München. [Full text available](https://elib.dlr.de/144997/1/master-thesis-final-spataro.pdf) - **Coarsening as post-processing to reduce simulation file size** + - [G] Elsweijer, Sandro (2022) *Evaluation and generic application scenarios for curved hexahedral adaptive mesh refinement*. Master's thesis, Hochschule Bonn-Rhein-Sieg. [10.13140/RG.2.2.34714.11203]() [Full text available](https://elib.dlr.de/186561/1/sandro_elsweijer-evaluation_and_generic_application_scenarios_for_curved_hexahedral_adaptive_mesh_refinement.pdf) - **Geometry controlled refinement for hexahedra (Part 2)** + [G] **Geometry controlled refinement for hexahedra (Part 2)**: Elsweijer, Sandro (2022) *Evaluation and generic application scenarios for curved hexahedral adaptive mesh refinement*. Master's thesis, Hochschule Bonn-Rhein-Sieg. [10.13140/RG.2.2.34714.11203]() [Full text available](https://elib.dlr.de/186561/1/sandro_elsweijer-evaluation_and_generic_application_scenarios_for_curved_hexahedral_adaptive_mesh_refinement.pdf) - [H] Böing, Niklas (2022) *Evaluation of preconditioners for implicit solvers of local DG for the advection-diffusion equation* (*Untersuchung von Präkonditionierern für implizite Löser für das Local DG-Verfahren zur Lösung der Advektions-Diffusionsgleichung*). Master's thesis, Universität zu Köln. + + [H] **Multigrid and other preconditioners for DG**: Böing, Niklas (2022) *Evaluation of preconditioners for implicit solvers of local DG for the advection-diffusion equation* (*Untersuchung von Präkonditionierern für implizite Löser für das Local DG-Verfahren zur Lösung der Advektions-Diffusionsgleichung*). Master's thesis, Universität zu Köln. [Full text available](https://elib.dlr.de/186347/1/Untersuchung%20von%20Pr%C3%A4konditionierern%20f%C3%BCr%20implizite%20L%C3%B6ser%20f%C3%BCr%20das%20Local%20DG-Verfahren%20zur%20L%C3%B6sung%20der%20Advektions-Diffusionsgleichung.pdf) - **Multigrid and other preconditioners for DG** + - [I] Lilikakis, Ioannis (2022) *Algorithms for tree-based adaptive meshes with incomplete trees*. Master's thesis, Universität zu Köln. + [I] **Removing elements from the mesh (cutting holes)**: Lilikakis, Ioannis (2022) *Algorithms for tree-based adaptive meshes with incomplete trees*. Master's thesis, Universität zu Köln. [Full text may be available in future](https://elib.dlr.de/191968/) - **Removing elements from the mesh (cutting holes)** + ### Citing t8code From 41da51c1be1d1d4b3450bc68d9cd0800cb462399 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Wed, 26 Apr 2023 18:13:47 +0200 Subject: [PATCH 145/255] und -> and --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 965030d9c0..ccd58aa077 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ You can also find the documentation of our releases on the [t8code website](http An (incomplete) list of publications related to t8code: - [1] **Overview Paper**: Holke, Johannes und Burstedde, Carsten und Knapp, David und Dreyer, Lukas und Elsweijer, Sandro und Ãœnlü, Veli und Markert, Johannes und Lilikakis, Ioannis und Böing, Niklas und Ponnusamy, Prasanna und Basermann, Achim (2023) *t8code v. 1.0 - Modular Adaptive Mesh Refinement in the Exascale Era*. SIAM International Meshing Round Table 2023, 06.03.2023 - 09.03.2023, Amsterdam, Niederlande. + [1] **Overview Paper**: Holke, Johannes and Burstedde, Carsten and Knapp, David and Dreyer, Lukas and Elsweijer, Sandro and Ãœnlü, Veli and Markert, Johannes and Lilikakis, Ioannis and Böing, Niklas and Ponnusamy, Prasanna and Basermann, Achim (2023) *t8code v. 1.0 - Modular Adaptive Mesh Refinement in the Exascale Era*. SIAM International Meshing Round Table 2023, 06.03.2023 - 09.03.2023, Amsterdam, Niederlande. [Full text available](https://elib.dlr.de/194377/1/t8code_overview_IMR2023.pdf) @@ -159,7 +159,7 @@ You can also find the documentation of our releases on the [t8code website](http [6] **Geometry controlled refinement for hexahedra**: - Elsweijer, Sandro und Holke, Johannes und Kleinert, Jan und Reith, Dirk (2022) *Constructing a Volume Geometry Map for Hexahedra with Curved Boundary Geometries*. In: SIAM International Meshing Roundtable Workshop 2022. SIAM International Meshing Roundtable Workshop 2022, 22. - 25. Feb. 2022, [Full text available](https://elib.dlr.de/186570/1/ConstructingAVolumeGeometryMapForHexahedraWithCurvedBoundaryGeometries.pdf) + Elsweijer, Sandro and Holke, Johannes and Kleinert, Jan and Reith, Dirk (2022) *Constructing a Volume Geometry Map for Hexahedra with Curved Boundary Geometries*. In: SIAM International Meshing Roundtable Workshop 2022. SIAM International Meshing Roundtable Workshop 2022, 22. - 25. Feb. 2022, [Full text available](https://elib.dlr.de/186570/1/ConstructingAVolumeGeometryMapForHexahedraWithCurvedBoundaryGeometries.pdf) ### Theses with t8code relations From ae7a4b56ecf4a5f9e325517cc70a54e452815249 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Thu, 27 Apr 2023 08:53:55 +0200 Subject: [PATCH 146/255] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ccd58aa077..ce543f942e 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ t8code uses [Doxygen](https://doxygen.nl/) to generate the code documentation. Y make doxygen ``` -and then find the generated files in the `/doxygen` subfolder. +and then find the generated files in the `/doc` subfolder. You can also find the documentation of our releases on the [t8code website](https://dlr-amr.github.io/t8code/pages/documentation.html). From a1e913c673dd1d2f7f198011e6b1f0844360f136 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Thu, 27 Apr 2023 09:54:59 +0200 Subject: [PATCH 147/255] typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ce543f942e..a7a0240601 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,6 @@ You can also find the documentation of our releases on the [t8code website](http - **the tetrahedral index**, please cite [3]. - **coarse mesh partitioning**, please cite [4]. - **construction and handling of the ghost layer**, please cite [5]. -- **Geometry controlled refinement**, please cite [6] +- **geometry controlled refinement**, please cite [6] If you use any functionality described in the theses, we encourage you to cite them as well. From 422b736289ec2b4ed0d44996b741b686cd4b6f6c Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Thu, 27 Apr 2023 10:01:15 +0200 Subject: [PATCH 148/255] Add line breaks to make raw file more readable. --- README.md | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a7a0240601..e2fcd2c585 100644 --- a/README.md +++ b/README.md @@ -138,11 +138,13 @@ You can also find the documentation of our releases on the [t8code website](http An (incomplete) list of publications related to t8code: - [1] **Overview Paper**: Holke, Johannes and Burstedde, Carsten and Knapp, David and Dreyer, Lukas and Elsweijer, Sandro and Ãœnlü, Veli and Markert, Johannes and Lilikakis, Ioannis and Böing, Niklas and Ponnusamy, Prasanna and Basermann, Achim (2023) *t8code v. 1.0 - Modular Adaptive Mesh Refinement in the Exascale Era*. SIAM International Meshing Round Table 2023, 06.03.2023 - 09.03.2023, Amsterdam, Niederlande. + [1] **Overview Paper**: + Holke, Johannes and Burstedde, Carsten and Knapp, David and Dreyer, Lukas and Elsweijer, Sandro and Ãœnlü, Veli and Markert, Johannes and Lilikakis, Ioannis and Böing, Niklas and Ponnusamy, Prasanna and Basermann, Achim (2023) *t8code v. 1.0 - Modular Adaptive Mesh Refinement in the Exascale Era*. SIAM International Meshing Round Table 2023, 06.03.2023 - 09.03.2023, Amsterdam, Niederlande. [Full text available](https://elib.dlr.de/194377/1/t8code_overview_IMR2023.pdf) - [2] **Original PhD thesis**: Johannes Holke, *Scalable algorithms for parallel tree-based adaptive mesh refinement with general element types*, PhD thesis at University of Bonn, 2018, + [2] **Original PhD thesis**: + Johannes Holke, *Scalable algorithms for parallel tree-based adaptive mesh refinement with general element types*, PhD thesis at University of Bonn, 2018, [Full text available](https://bonndoc.ulb.uni-bonn.de/xmlui/handle/20.500.11811/7661) @@ -174,30 +176,37 @@ You can also find the documentation of our releases on the [t8code website](http Knapp, David (2020) *A space-filling curve for pyramidal adaptive mesh refinement*. Master's thesis, Rheinische Friedrich-Wilhems-Universität Bonn. - [C] **DG solver based on t8code**: Dreyer, Lukas (2021) *The local discontinuous galerkin method for the advection-diffusion equation on adaptive meshes*. Master's thesis, Rheinische Friedrich-Wilhems-Universität Bonn. + [C] **DG solver based on t8code**: + Dreyer, Lukas (2021) *The local discontinuous galerkin method for the advection-diffusion equation on adaptive meshes*. Master's thesis, Rheinische Friedrich-Wilhems-Universität Bonn. [Full text available] (https://elib.dlr.de/143969/1/masterthesis_dreyer.pdf) - [D] **Geometry controlled refinement for hexahedra (Part 1)**: Elsweijer, Sandro (2021) *Curved Domain Adaptive Mesh Refinement with Hexahedra*. Tech report, Hochschule Bonn-Rhein-Sieg. + [D] **Geometry controlled refinement for hexahedra (Part 1)**: + Elsweijer, Sandro (2021) *Curved Domain Adaptive Mesh Refinement with Hexahedra*. Tech report, Hochschule Bonn-Rhein-Sieg. [Full text available] (https://elib.dlr.de/186571/1/masterprojekt-2_elsweijer_ABGABEVERSION_TITEL.pdf) - [E] **Subelement and resolving hanging faces in 2D**: Becker, Florian (2021) *Removing hanging faces from tree-based adaptive meshes for numerical simulation*, Master's thesis, Universität zu Köln. + [E] **Subelement and resolving hanging faces in 2D**: + Becker, Florian (2021) *Removing hanging faces from tree-based adaptive meshes for numerical simulation*, Master's thesis, Universität zu Köln. [Full text available](https://elib.dlr.de/187499/1/RemovingHangingFacesFromTreeBasedAMR.pdf) - [F] **Coarsening as post-processing to reduce simulation file size**: Spataro, Luca (2021) *Lossy data compression for atmospheric chemistry using adaptive mesh coarsening*. Master's thesis, Technische Universität München. + [F] **Coarsening as post-processing to reduce simulation file size**: + Spataro, Luca (2021) *Lossy data compression for atmospheric chemistry using adaptive mesh coarsening*. Master's thesis, Technische Universität München. [Full text available](https://elib.dlr.de/144997/1/master-thesis-final-spataro.pdf) - [G] **Geometry controlled refinement for hexahedra (Part 2)**: Elsweijer, Sandro (2022) *Evaluation and generic application scenarios for curved hexahedral adaptive mesh refinement*. Master's thesis, Hochschule Bonn-Rhein-Sieg. [10.13140/RG.2.2.34714.11203]() [Full text available](https://elib.dlr.de/186561/1/sandro_elsweijer-evaluation_and_generic_application_scenarios_for_curved_hexahedral_adaptive_mesh_refinement.pdf) + [G] **Geometry controlled refinement for hexahedra (Part 2)**: + Elsweijer, Sandro (2022) *Evaluation and generic application scenarios for curved hexahedral adaptive mesh refinement*. Master's thesis, Hochschule Bonn-Rhein-Sieg. [10.13140/RG.2.2.34714.11203]() [Full text available](https://elib.dlr.de/186561/1/sandro_elsweijer-evaluation_and_generic_application_scenarios_for_curved_hexahedral_adaptive_mesh_refinement.pdf) - [H] **Multigrid and other preconditioners for DG**: Böing, Niklas (2022) *Evaluation of preconditioners for implicit solvers of local DG for the advection-diffusion equation* (*Untersuchung von Präkonditionierern für implizite Löser für das Local DG-Verfahren zur Lösung der Advektions-Diffusionsgleichung*). Master's thesis, Universität zu Köln. + [H] **Multigrid and other preconditioners for DG**: + Böing, Niklas (2022) *Evaluation of preconditioners for implicit solvers of local DG for the advection-diffusion equation* (*Untersuchung von Präkonditionierern für implizite Löser für das Local DG-Verfahren zur Lösung der Advektions-Diffusionsgleichung*). Master's thesis, Universität zu Köln. [Full text available](https://elib.dlr.de/186347/1/Untersuchung%20von%20Pr%C3%A4konditionierern%20f%C3%BCr%20implizite%20L%C3%B6ser%20f%C3%BCr%20das%20Local%20DG-Verfahren%20zur%20L%C3%B6sung%20der%20Advektions-Diffusionsgleichung.pdf) - [I] **Removing elements from the mesh (cutting holes)**: Lilikakis, Ioannis (2022) *Algorithms for tree-based adaptive meshes with incomplete trees*. Master's thesis, Universität zu Köln. + [I] **Removing elements from the mesh (cutting holes)**: + Lilikakis, Ioannis (2022) *Algorithms for tree-based adaptive meshes with incomplete trees*. Master's thesis, Universität zu Köln. [Full text may be available in future](https://elib.dlr.de/191968/) From b07f81d6b9f26622804977e87246102881e1073a Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Thu, 27 Apr 2023 11:40:32 +0200 Subject: [PATCH 149/255] Unify first and last name order in README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e2fcd2c585..e7c722d081 100644 --- a/README.md +++ b/README.md @@ -144,20 +144,20 @@ You can also find the documentation of our releases on the [t8code website](http [2] **Original PhD thesis**: - Johannes Holke, *Scalable algorithms for parallel tree-based adaptive mesh refinement with general element types*, PhD thesis at University of Bonn, 2018, + Holke, Johannes *Scalable algorithms for parallel tree-based adaptive mesh refinement with general element types*, PhD thesis at University of Bonn, 2018, [Full text available](https://bonndoc.ulb.uni-bonn.de/xmlui/handle/20.500.11811/7661) [3] **Tetrahedral and triangular Space-filling curve**: - Carsten Burstedde and Johannes Holke, *A Tetrahedral Space-Filling Curve for Nonconforming Adaptive Meshes*, SIAM Journal on Scientific Computing, 2016, [10.1137/15M1040049](https://epubs.siam.org/doi/10.1137/15M1040049) + Burstedde, Carsten and Holke, Johannes *A Tetrahedral Space-Filling Curve for Nonconforming Adaptive Meshes*, SIAM Journal on Scientific Computing, 2016, [10.1137/15M1040049](https://epubs.siam.org/doi/10.1137/15M1040049) [4] **Coarse mesh partitioning**: - Carsten Burstedde and Johannes Holke, *Coarse mesh partitioning for tree-based AMR*, SIAM Journal on Scientific Computing, 2017, [10.1137/16M1103518](https://epubs.siam.org/doi/10.1137/16M1103518) + Burstedde, Carsten and Holke, Johannes *Coarse mesh partitioning for tree-based AMR*, SIAM Journal on Scientific Computing, 2017, [10.1137/16M1103518](https://epubs.siam.org/doi/10.1137/16M1103518) [5] **Ghost computation**: - Johannes Holke and David Knapp and Carsten Burstedde, *An Optimized, Parallel Computation of the Ghost Layer for Adaptive Hybrid Forest Meshes*, SIAM Journal on Scientific Computing, 2021, [10.1137/20M1383033](https://epubs.siam.org/doi/abs/10.1137/20M1383033) + Holke, Johannes and Knapp, David and Burstedde, Carsten *An Optimized, Parallel Computation of the Ghost Layer for Adaptive Hybrid Forest Meshes*, SIAM Journal on Scientific Computing, 2021, [10.1137/20M1383033](https://epubs.siam.org/doi/abs/10.1137/20M1383033) [6] **Geometry controlled refinement for hexahedra**: From c58d6f987e640054ec2951fc17672605e1ddf016 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Wed, 3 May 2023 11:30:33 +0200 Subject: [PATCH 150/255] rename function --- src/t8_vtk/t8_vtk_reader.cxx | 2 +- src/t8_vtk/t8_vtk_reader.hxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_vtk/t8_vtk_reader.cxx b/src/t8_vtk/t8_vtk_reader.cxx index fba04928fe..6c2be712ae 100644 --- a/src/t8_vtk/t8_vtk_reader.cxx +++ b/src/t8_vtk/t8_vtk_reader.cxx @@ -441,7 +441,7 @@ t8_vtk_reader (const char *filename, const int partition, #endif vtkSmartPointer < vtkPointSet > -t8_pointSet_vtk_reader (const char *filename, +t8_vtk_reader_pointSet (const char *filename, const int partition, const int main_proc, sc_MPI_Comm comm, diff --git a/src/t8_vtk/t8_vtk_reader.hxx b/src/t8_vtk/t8_vtk_reader.hxx index e80ff32d7b..9f761693bf 100644 --- a/src/t8_vtk/t8_vtk_reader.hxx +++ b/src/t8_vtk/t8_vtk_reader.hxx @@ -120,7 +120,7 @@ t8_cmesh_t t8_vtk_reader_cmesh (const char *filename, * \param[in] vtk_file_type A vtk-filetype that is readable by t8code. * \return Pointer to vtkDataSet */ -vtkSmartPointer < vtkPointSet > t8_pointSet_vtk_reader (const char *filename, +vtkSmartPointer < vtkPointSet > t8_vtk_reader_pointSet (const char *filename, const int partition, const int main_proc, sc_MPI_Comm comm, From b83c2f0c100abe39fd0a5725495fcb351a0384ec Mon Sep 17 00:00:00 2001 From: ililikakis Date: Wed, 3 May 2023 11:46:04 +0200 Subject: [PATCH 151/255] indent --- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 3 ++- src/t8_vtk/t8_vtk_reader.cxx | 28 +++++++++++++++------------- src/t8_vtk/t8_vtk_reader.hxx | 18 ++++++++++++------ 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index c0254159cd..2bad397c20 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -34,7 +34,8 @@ t8_cmesh_vtk_reader (const char *filename, const int partition, const int main_proc, sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type) { - return t8_vtk_reader_cmesh (filename, partition, main_proc, comm, vtk_file_type); + return t8_vtk_reader_cmesh (filename, partition, main_proc, comm, + vtk_file_type); } T8_EXTERN_C_END (); diff --git a/src/t8_vtk/t8_vtk_reader.cxx b/src/t8_vtk/t8_vtk_reader.cxx index 6c2be712ae..544ec17e10 100644 --- a/src/t8_vtk/t8_vtk_reader.cxx +++ b/src/t8_vtk/t8_vtk_reader.cxx @@ -364,24 +364,26 @@ vtkSmartPointer < vtkPointSet > t8_vtkGrid_to_vtkPointSet (vtkSmartPointer < vtkDataSet > vtkGrid) { /* Set points */ - vtkSmartPointer < vtkPoints > points = vtkSmartPointer < vtkPoints >::New (); - const vtkIdType num_points = vtkGrid->GetNumberOfPoints (); + vtkSmartPointer < vtkPoints > points = + vtkSmartPointer < vtkPoints >::New (); + const vtkIdType num_points = vtkGrid->GetNumberOfPoints (); points->SetDataType (VTK_DOUBLE); points->SetNumberOfPoints (num_points); for (vtkIdType ipoint = 0; ipoint < num_points; ipoint++) { - double vp[3]; + double vp[3]; vtkGrid->GetPoint (ipoint, vp); points->SetPoint (ipoint, vp); } points->Modified (); - T8_ASSERT (points->GetNumberOfPoints() == num_points); - vtkSmartPointer < vtkPointSet > cloud = + T8_ASSERT (points->GetNumberOfPoints () == num_points); + vtkSmartPointer < vtkPointSet > cloud = vtkSmartPointer < vtkPointSet >::New (); cloud->SetPoints (points); /* Map cell data to point data */ - vtkSmartPointer < vtkCellDataToPointData > c2p = vtkCellDataToPointData::New (); + vtkSmartPointer < vtkCellDataToPointData > c2p = + vtkCellDataToPointData::New (); c2p->PassCellDataOff (); c2p->SetInputData (vtkGrid); c2p->Update (); @@ -444,11 +446,10 @@ vtkSmartPointer < vtkPointSet > t8_vtk_reader_pointSet (const char *filename, const int partition, const int main_proc, - sc_MPI_Comm comm, - const vtk_file_type_t vtk_file_type) + sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type) { #if T8_WITH_VTK - vtkSmartPointer < vtkDataSet > vtkGrid = + vtkSmartPointer < vtkDataSet > vtkGrid = t8_vtk_reader (filename, partition, main_proc, comm, vtk_file_type); return t8_vtkGrid_to_vtkPointSet (vtkGrid); #else @@ -465,10 +466,11 @@ t8_vtk_reader_cmesh (const char *filename, const int partition, const vtk_file_type_t vtk_file_type) { #if T8_WITH_VTK - vtkSmartPointer < vtkDataSet > vtkGrid = + vtkSmartPointer < vtkDataSet > vtkGrid = t8_vtk_reader (filename, partition, main_proc, comm, vtk_file_type); - - t8_cmesh_t cmesh = t8_vtkGrid_to_cmesh (vtkGrid, partition, main_proc, comm); + + t8_cmesh_t cmesh = + t8_vtkGrid_to_cmesh (vtkGrid, partition, main_proc, comm); T8_ASSERT (cmesh != NULL); return cmesh; #else @@ -479,4 +481,4 @@ t8_vtk_reader_cmesh (const char *filename, const int partition, return NULL; } -T8_EXTERN_C_END (); \ No newline at end of file +T8_EXTERN_C_END (); diff --git a/src/t8_vtk/t8_vtk_reader.hxx b/src/t8_vtk/t8_vtk_reader.hxx index 9f761693bf..08e65dfa6a 100644 --- a/src/t8_vtk/t8_vtk_reader.hxx +++ b/src/t8_vtk/t8_vtk_reader.hxx @@ -59,7 +59,9 @@ t8_cmesh_t t8_vtkGrid_to_cmesh (vtkSmartPointer < vtkDataSet > * \param[in] vtkGrid A pointer to a vtkDataSet * \return A pointer to a vtkPointSet */ -vtkSmartPointer < vtkPointSet > t8_vtkGrid_to_vtkPointSet (vtkSmartPointer < vtkDataSet > vtkGrid); +vtkSmartPointer < vtkPointSet > t8_vtkGrid_to_vtkPointSet (vtkSmartPointer < + vtkDataSet > + vtkGrid); /** * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and @@ -74,9 +76,12 @@ vtkSmartPointer < vtkPointSet > t8_vtkGrid_to_vtkPointSet (vtkSmartPointer < vtk * \param[in] vtk_file_type A vtk-filetype that is readable by t8code. * \return Pointer to vtkDataSet */ -vtkSmartPointer < vtkDataSet > t8_vtk_reader (const char *filename, const int partition, - const int main_proc, sc_MPI_Comm comm, - const vtk_file_type_t vtk_file_type); +vtkSmartPointer < vtkDataSet > t8_vtk_reader (const char *filename, + const int partition, + const int main_proc, + sc_MPI_Comm comm, + const vtk_file_type_t + vtk_file_type); #endif @@ -124,8 +129,9 @@ vtkSmartPointer < vtkPointSet > t8_vtk_reader_pointSet (const char *filename, const int partition, const int main_proc, sc_MPI_Comm comm, - const vtk_file_type_t vtk_file_type); + const vtk_file_type_t + vtk_file_type); T8_EXTERN_C_END (); -#endif /* T8_VTK_READER */ \ No newline at end of file +#endif /* T8_VTK_READER */ From d6bfdf33e48171b19387a538190331825b664641 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 3 May 2023 16:19:49 +0200 Subject: [PATCH 152/255] Update README.md Added link to my masterthesis and updated some markdown to show all links in the "thesis"-section as "[Full text available]" --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e7c722d081..e917e46dbe 100644 --- a/README.md +++ b/README.md @@ -173,17 +173,17 @@ You can also find the documentation of our releases on the [t8code website](http [B] **Pyramidal space-filling curve**: - Knapp, David (2020) *A space-filling curve for pyramidal adaptive mesh refinement*. Master's thesis, Rheinische Friedrich-Wilhems-Universität Bonn. + Knapp, David (2020) *A space-filling curve for pyramidal adaptive mesh refinement*. Master's thesis, Rheinische Friedrich-Wilhems-Universität Bonn. [Full text available](https://www.researchgate.net/publication/346789160_A_space-filling_curve_for_pyramidal_adaptive_mesh_refinement) [C] **DG solver based on t8code**: Dreyer, Lukas (2021) *The local discontinuous galerkin method for the advection-diffusion equation on adaptive meshes*. Master's thesis, Rheinische Friedrich-Wilhems-Universität Bonn. - [Full text available] (https://elib.dlr.de/143969/1/masterthesis_dreyer.pdf) + [Full text available](https://elib.dlr.de/143969/1/masterthesis_dreyer.pdf) [D] **Geometry controlled refinement for hexahedra (Part 1)**: Elsweijer, Sandro (2021) *Curved Domain Adaptive Mesh Refinement with Hexahedra*. Tech report, Hochschule Bonn-Rhein-Sieg. - [Full text available] (https://elib.dlr.de/186571/1/masterprojekt-2_elsweijer_ABGABEVERSION_TITEL.pdf) + [Full text available](https://elib.dlr.de/186571/1/masterprojekt-2_elsweijer_ABGABEVERSION_TITEL.pdf) [E] **Subelement and resolving hanging faces in 2D**: From 26ffbba293accbbf670caf93d2f05b2d852b16f3 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 4 May 2023 09:31:31 +0200 Subject: [PATCH 153/255] undo add vtkDataSet to vtkPointSet --- src/t8_vtk/t8_vtk_reader.cxx | 53 +----------------------------------- src/t8_vtk/t8_vtk_reader.hxx | 36 ------------------------ 2 files changed, 1 insertion(+), 88 deletions(-) diff --git a/src/t8_vtk/t8_vtk_reader.cxx b/src/t8_vtk/t8_vtk_reader.cxx index 544ec17e10..cc6c01da37 100644 --- a/src/t8_vtk/t8_vtk_reader.cxx +++ b/src/t8_vtk/t8_vtk_reader.cxx @@ -31,7 +31,6 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #if T8_WITH_VTK #include #include -#include #include #include #include @@ -360,39 +359,6 @@ t8_vtkGrid_to_cmesh (vtkSmartPointer < vtkDataSet > vtkGrid, return cmesh; } -vtkSmartPointer < vtkPointSet > -t8_vtkGrid_to_vtkPointSet (vtkSmartPointer < vtkDataSet > vtkGrid) -{ - /* Set points */ - vtkSmartPointer < vtkPoints > points = - vtkSmartPointer < vtkPoints >::New (); - const vtkIdType num_points = vtkGrid->GetNumberOfPoints (); - points->SetDataType (VTK_DOUBLE); - points->SetNumberOfPoints (num_points); - - for (vtkIdType ipoint = 0; ipoint < num_points; ipoint++) { - double vp[3]; - vtkGrid->GetPoint (ipoint, vp); - points->SetPoint (ipoint, vp); - } - points->Modified (); - T8_ASSERT (points->GetNumberOfPoints () == num_points); - vtkSmartPointer < vtkPointSet > cloud = - vtkSmartPointer < vtkPointSet >::New (); - cloud->SetPoints (points); - - /* Map cell data to point data */ - vtkSmartPointer < vtkCellDataToPointData > c2p = - vtkCellDataToPointData::New (); - c2p->PassCellDataOff (); - c2p->SetInputData (vtkGrid); - c2p->Update (); - cloud->DeepCopy (c2p->GetOutput ()); - //cloud->DeepCopy (vtkPointSet::SafeDownCast (c2p->GetOutput ())); - - return cloud; -} - vtkSmartPointer < vtkDataSet > t8_vtk_reader (const char *filename, const int partition, const int main_proc, sc_MPI_Comm comm, @@ -440,25 +406,8 @@ t8_vtk_reader (const char *filename, const int partition, return vtkGrid; } } -#endif -vtkSmartPointer < vtkPointSet > -t8_vtk_reader_pointSet (const char *filename, - const int partition, - const int main_proc, - sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type) -{ -#if T8_WITH_VTK - vtkSmartPointer < vtkDataSet > vtkGrid = - t8_vtk_reader (filename, partition, main_proc, comm, vtk_file_type); - return t8_vtkGrid_to_vtkPointSet (vtkGrid); -#else - /* Return NULL if not linked against vtk */ - t8_global_errorf - ("WARNING: t8code is not linked against the vtk library. Without proper linking t8code cannot use the vtk-reader\n"); -#endif - return NULL; -} +#endif /* T8_WITH_VTK */ t8_cmesh_t t8_vtk_reader_cmesh (const char *filename, const int partition, diff --git a/src/t8_vtk/t8_vtk_reader.hxx b/src/t8_vtk/t8_vtk_reader.hxx index 08e65dfa6a..ef7eb3667e 100644 --- a/src/t8_vtk/t8_vtk_reader.hxx +++ b/src/t8_vtk/t8_vtk_reader.hxx @@ -30,7 +30,6 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include -#include #endif T8_EXTERN_C_BEGIN (); @@ -52,17 +51,6 @@ t8_cmesh_t t8_vtkGrid_to_cmesh (vtkSmartPointer < vtkDataSet > const int main_proc, sc_MPI_Comm comm); -/** - * Given a pointer to a vtkDataSet a vtkPointSet storing a set of points of - * is constructed. The cell data of vtkDataSet is mapt on the points of vtkPointSet. - * - * \param[in] vtkGrid A pointer to a vtkDataSet - * \return A pointer to a vtkPointSet - */ -vtkSmartPointer < vtkPointSet > t8_vtkGrid_to_vtkPointSet (vtkSmartPointer < - vtkDataSet > - vtkGrid); - /** * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and * construct a abstract class to specify dataset behavior. The file is read and @@ -108,30 +96,6 @@ t8_cmesh_t t8_vtk_reader_cmesh (const char *filename, sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type); -/** - * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and - * a set of points is constructed. This is a two stage process. First the file - * is read and stored in a vtkDataSet using \a t8_vtk_reader and - * \a t8_file_to_vtkGrid. In the second stage a vtkPointSet is constructed from - * the vtkDataSet using \a t8_vtkGrid_to_vtkPointSet. - * - * Both stages use the vtk-library, therefore the function is only available if - * t8code is linked against VTK. - * - * \param[in] filename The name of the file - * \param[in] partition Flag if the constructed mesh should be partitioned - * \param[in] main_proc The main reading processor - * \param[in] comm An mpi-communicator - * \param[in] vtk_file_type A vtk-filetype that is readable by t8code. - * \return Pointer to vtkDataSet - */ -vtkSmartPointer < vtkPointSet > t8_vtk_reader_pointSet (const char *filename, - const int partition, - const int main_proc, - sc_MPI_Comm comm, - const vtk_file_type_t - vtk_file_type); - T8_EXTERN_C_END (); #endif /* T8_VTK_READER */ From 32cf48004b2925c5e4d67c3f8a0d03a6443b5e8b Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 4 May 2023 09:40:14 +0200 Subject: [PATCH 154/255] add vtkDataSet to vtkPointSet --- src/t8_vtk/t8_vtk_reader.cxx | 52 ++++++++++++++++++++++++++++++++++++ src/t8_vtk/t8_vtk_reader.hxx | 36 +++++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/src/t8_vtk/t8_vtk_reader.cxx b/src/t8_vtk/t8_vtk_reader.cxx index cc6c01da37..05b829690f 100644 --- a/src/t8_vtk/t8_vtk_reader.cxx +++ b/src/t8_vtk/t8_vtk_reader.cxx @@ -31,6 +31,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #if T8_WITH_VTK #include #include +#include #include #include #include @@ -359,6 +360,39 @@ t8_vtkGrid_to_cmesh (vtkSmartPointer < vtkDataSet > vtkGrid, return cmesh; } +vtkSmartPointer < vtkPointSet > +t8_vtkGrid_to_vtkPointSet (vtkSmartPointer < vtkDataSet > vtkGrid) +{ + /* Set points */ + vtkSmartPointer < vtkPoints > points = + vtkSmartPointer < vtkPoints >::New (); + const vtkIdType num_points = vtkGrid->GetNumberOfPoints (); + points->SetDataType (VTK_DOUBLE); + points->SetNumberOfPoints (num_points); + + for (vtkIdType ipoint = 0; ipoint < num_points; ipoint++) { + double vp[3]; + vtkGrid->GetPoint (ipoint, vp); + points->SetPoint (ipoint, vp); + } + points->Modified (); + T8_ASSERT (points->GetNumberOfPoints () == num_points); + vtkSmartPointer < vtkPointSet > cloud = + vtkSmartPointer < vtkPointSet >::New (); + cloud->SetPoints (points); + + /* Map cell data to point data */ + vtkSmartPointer < vtkCellDataToPointData > c2p = + vtkCellDataToPointData::New (); + c2p->PassCellDataOff (); + c2p->SetInputData (vtkGrid); + c2p->Update (); + cloud->DeepCopy (c2p->GetOutput ()); + //cloud->DeepCopy (vtkPointSet::SafeDownCast (c2p->GetOutput ())); + + return cloud; +} + vtkSmartPointer < vtkDataSet > t8_vtk_reader (const char *filename, const int partition, const int main_proc, sc_MPI_Comm comm, @@ -409,6 +443,24 @@ t8_vtk_reader (const char *filename, const int partition, #endif /* T8_WITH_VTK */ +vtkSmartPointer < vtkPointSet > +t8_vtk_reader_pointSet (const char *filename, + const int partition, + const int main_proc, + sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type) +{ +#if T8_WITH_VTK + vtkSmartPointer < vtkDataSet > vtkGrid = + t8_vtk_reader (filename, partition, main_proc, comm, vtk_file_type); + return t8_vtkGrid_to_vtkPointSet (vtkGrid); +#else + /* Return NULL if not linked against vtk */ + t8_global_errorf + ("WARNING: t8code is not linked against the vtk library. Without proper linking t8code cannot use the vtk-reader\n"); +#endif + return NULL; +} + t8_cmesh_t t8_vtk_reader_cmesh (const char *filename, const int partition, const int main_proc, sc_MPI_Comm comm, diff --git a/src/t8_vtk/t8_vtk_reader.hxx b/src/t8_vtk/t8_vtk_reader.hxx index ef7eb3667e..08e65dfa6a 100644 --- a/src/t8_vtk/t8_vtk_reader.hxx +++ b/src/t8_vtk/t8_vtk_reader.hxx @@ -30,6 +30,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include +#include #endif T8_EXTERN_C_BEGIN (); @@ -51,6 +52,17 @@ t8_cmesh_t t8_vtkGrid_to_cmesh (vtkSmartPointer < vtkDataSet > const int main_proc, sc_MPI_Comm comm); +/** + * Given a pointer to a vtkDataSet a vtkPointSet storing a set of points of + * is constructed. The cell data of vtkDataSet is mapt on the points of vtkPointSet. + * + * \param[in] vtkGrid A pointer to a vtkDataSet + * \return A pointer to a vtkPointSet + */ +vtkSmartPointer < vtkPointSet > t8_vtkGrid_to_vtkPointSet (vtkSmartPointer < + vtkDataSet > + vtkGrid); + /** * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and * construct a abstract class to specify dataset behavior. The file is read and @@ -96,6 +108,30 @@ t8_cmesh_t t8_vtk_reader_cmesh (const char *filename, sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type); +/** + * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and + * a set of points is constructed. This is a two stage process. First the file + * is read and stored in a vtkDataSet using \a t8_vtk_reader and + * \a t8_file_to_vtkGrid. In the second stage a vtkPointSet is constructed from + * the vtkDataSet using \a t8_vtkGrid_to_vtkPointSet. + * + * Both stages use the vtk-library, therefore the function is only available if + * t8code is linked against VTK. + * + * \param[in] filename The name of the file + * \param[in] partition Flag if the constructed mesh should be partitioned + * \param[in] main_proc The main reading processor + * \param[in] comm An mpi-communicator + * \param[in] vtk_file_type A vtk-filetype that is readable by t8code. + * \return Pointer to vtkDataSet + */ +vtkSmartPointer < vtkPointSet > t8_vtk_reader_pointSet (const char *filename, + const int partition, + const int main_proc, + sc_MPI_Comm comm, + const vtk_file_type_t + vtk_file_type); + T8_EXTERN_C_END (); #endif /* T8_VTK_READER */ From fd48a683f6ef8048e18dd785c73181394e76cb1d Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 4 May 2023 11:25:40 +0200 Subject: [PATCH 155/255] extended documentation by example --- src/t8_cmesh/t8_cmesh_examples.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 737eaa89de..8e5900f152 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -117,6 +117,20 @@ t8_cmesh_t t8_cmesh_new_hypercube (t8_eclass_t eclass, * \note Every sub-hypercube contains diffrent number of trees depending on \a eclass. * \note If \a eclass == T8_ECLASS_VERTEX, _LINE, _QUAD or _HEX every sub-hypercube contains * one tree, if _TRIANGLE or _PRISM two trees and if _TET six trees. + * This is done in the same way as in \see t8_cmesh_new_hypercube. + * \example let eclass = T8_ECLASS_TRIANGLE + * boundary coordinates = a(0,0,0), b(3,0,0), c(0,2,0), d(3,2,0) + * polygons_x, _y, _z = 3, 1, 0 + * + * c--f--h--d The hypercube defined by the boundary coordinates + * | | | | is first split into 3 sub-hypercubes. The sub-hypercubes + * | | | | are ordert from left to right (and top to bottom). + * a--e--g--b Coordinates e,f,g,h are (1,0,0),(1,2,0),(2,0,0),(2,2,0). + * + * c--f--h--d Each sub-hypercube is the split into 2 triangle roots. + * |1/|3/|5/| The ordering is the same as in \see t8_cmesh_new_hypercube. + * |/0|/2|/4| Thus, we get 6 trees, which are ordered as shown in the picture. + * a--e--g--b */ t8_cmesh_t t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, sc_MPI_Comm comm, From aebd4e7b2be8daad08088add98ea6110a475ed4e Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 4 May 2023 11:27:47 +0200 Subject: [PATCH 156/255] renamed t8_cmesh_new_hypercube_ext into _extrude --- src/t8_cmesh/t8_cmesh_examples.c | 11 ++++++----- src/t8_cmesh/t8_cmesh_examples.h | 12 ++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 3accc9c58d..0d79df6c8f 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1242,11 +1242,12 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, } t8_cmesh_t -t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, - sc_MPI_Comm comm, - const double *boundary, - t8_locidx_t polygons_x, - t8_locidx_t polygons_y, t8_locidx_t polygons_z) +t8_cmesh_new_hypercube_extrude (const t8_eclass_t eclass, + sc_MPI_Comm comm, + const double *boundary, + t8_locidx_t polygons_x, + t8_locidx_t polygons_y, + t8_locidx_t polygons_z) { SC_CHECK_ABORT (eclass != T8_ECLASS_PYRAMID, "Pyramids are not yet supported."); diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 8e5900f152..9ea498bf9b 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -132,12 +132,12 @@ t8_cmesh_t t8_cmesh_new_hypercube (t8_eclass_t eclass, * |/0|/2|/4| Thus, we get 6 trees, which are ordered as shown in the picture. * a--e--g--b */ -t8_cmesh_t t8_cmesh_new_hypercube_ext (const t8_eclass_t eclass, - sc_MPI_Comm comm, - const double *boundary, - t8_locidx_t polygons_x, - t8_locidx_t polygons_y, - t8_locidx_t polygons_z); +t8_cmesh_t t8_cmesh_new_hypercube_extrude (const t8_eclass_t eclass, + sc_MPI_Comm comm, + const double *boundary, + t8_locidx_t polygons_x, + t8_locidx_t polygons_y, + t8_locidx_t polygons_z); /** Hybercube with 6 Tets, 6 Prism, 4 Hex. * \param [in] comm The mpi communicator to be used. From 8011acad07f1e4afa11afecaf0b78d4f83e4832f Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 4 May 2023 11:29:02 +0200 Subject: [PATCH 157/255] indent --- src/t8_cmesh/t8_cmesh_examples.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 0d79df6c8f..e004bd9572 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1246,7 +1246,7 @@ t8_cmesh_new_hypercube_extrude (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, - t8_locidx_t polygons_y, + t8_locidx_t polygons_y, t8_locidx_t polygons_z) { SC_CHECK_ABORT (eclass != T8_ECLASS_PYRAMID, From f2ca9c837d39233756507e73ec27ca060df5e3b0 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 9 May 2023 09:09:12 +0200 Subject: [PATCH 158/255] Apply suggestions from code review Co-authored-by: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> --- src/Makefile.am | 2 +- src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index d77345acb8..85191c7931 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -77,7 +77,7 @@ libt8_internal_headers = \ src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx \ src/t8_forest/t8_forest_cxx.h \ src/t8_forest/t8_forest_ghost.h \ - src/t8_forest/t8_forest_balance.h src/t8_forest/t8_forest_types.h \ + src/t8_forest/t8_forest_balance.h src/t8_forest/t8_forest_types.h \ src/t8_forest/t8_forest_private.h \ src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx libt8_compiled_sources = \ diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index 4e0c649485..6c91413839 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -33,7 +33,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., void t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) { - char tmp[BUFSIZ], *extension; + char tmp[BUFSIZ]; + char *extension; /* Get the file-extension to decide which reader to use. */ strcpy (tmp, filename); extension = strtok (tmp, "."); From 11e1a4a3452fa04dcba28ea6dbd48b8b3e9f7723 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 9 May 2023 09:10:13 +0200 Subject: [PATCH 159/255] Remove doulbe check of the file-extensions --- .../t8_cmesh_vtk_polydata.cxx | 110 ++++++++---------- 1 file changed, 46 insertions(+), 64 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index 4e0c649485..75eef5fbb0 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -40,7 +40,8 @@ t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) extension = strtok (NULL, "."); T8_ASSERT (strcmp (extension, "")); - /* Read the file depending on the extension */ + /* Read the file depending on the extension. Not all readers have + * a built-in check if the file is readable. */ if (strcmp (extension, "ply") == 0) { vtkNew < vtkPLYReader > reader; reader->SetFileName (filename); @@ -49,72 +50,53 @@ t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) return; } else if (strcmp (extension, "vtp") == 0) { - char tmp[BUFSIZ], *extension; - /* Get the file-extension to decide which reader to use. */ - strcpy (tmp, filename); - extension = strtok (tmp, "."); - extension = strtok (NULL, "."); - T8_ASSERT (strcmp (extension, "")); - - /* Read the file depending on the extension. Not all readers have - * a built-in check if the file is readable. */ - if (strcmp (extension, "ply") == 0) { - vtkNew < vtkPLYReader > reader; - reader->SetFileName (filename); - reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); - return; - } - else if (strcmp (extension, "vtp") == 0) { - vtkNew < vtkXMLPolyDataReader > reader; - reader->SetFileName (filename); - if (!reader->CanReadFile (filename)) { - t8_errorf ("Unable to read file.\n"); - return NULL; - } - reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); - return; - } - else if (strcmp (extension, "obj") == 0) { - vtkNew < vtkOBJReader > reader; - reader->SetFileName (filename); - reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); - return; - } - else if (strcmp (extension, "stl") == 0) { - vtkNew < vtkSTLReader > reader; - reader->SetFileName (filename); - reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); - return; - } - else if (strcmp (extension, "vtk") == 0) { - vtkNew < vtkPolyDataReader > reader; - reader->SetFileName (filename); - reader->Update (); - if (!reader->IsFilePolyData ()) { - t8_errorf - ("File-content is not polydata. If it is a vtkUnstructuredGrid use the unstructured Grid reader."); - return NULL; - } - grid->ShallowCopy (reader->GetOutput ()); - return; - } - else if (strcmp (extension, "g") == 0) { - vtkNew < vtkBYUReader > reader; - reader->SetGeometryFileName (filename); - reader->Update (); - grid->ShallowCopy (reader->GetOutput ()); - return; + vtkNew < vtkXMLPolyDataReader > reader; + reader->SetFileName (filename); + if (!reader->CanReadFile (filename)) { + t8_errorf ("Unable to read file.\n"); + return NULL; } - else { - /* Return NULL if the reader is not used correctly. */ - t8_global_errorf - ("Please use .ply, .vtp, .obj, .stl, .vtk or .g file\n"); + reader->Update (); + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else if (strcmp (extension, "obj") == 0) { + vtkNew < vtkOBJReader > reader; + reader->SetFileName (filename); + reader->Update (); + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else if (strcmp (extension, "stl") == 0) { + vtkNew < vtkSTLReader > reader; + reader->SetFileName (filename); + reader->Update (); + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else if (strcmp (extension, "vtk") == 0) { + vtkNew < vtkPolyDataReader > reader; + reader->SetFileName (filename); + reader->Update (); + if (!reader->IsFilePolyData ()) { + t8_errorf + ("File-content is not polydata. If it is a vtkUnstructuredGrid use the unstructured Grid reader."); return NULL; } + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else if (strcmp (extension, "g") == 0) { + vtkNew < vtkBYUReader > reader; + reader->SetGeometryFileName (filename); + reader->Update (); + grid->ShallowCopy (reader->GetOutput ()); + return; + } + else { + /* Return NULL if the reader is not used correctly. */ + t8_global_errorf ("Please use .ply, .vtp, .obj, .stl, .vtk or .g file\n"); + return NULL; } } #endif From 857bc1b6971a28cf7bcdb0fe935b24a2019e1488 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 9 May 2023 09:11:30 +0200 Subject: [PATCH 160/255] Update comment --- src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index b7aac5fc90..0a0466ac1a 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -42,7 +42,7 @@ t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) T8_ASSERT (strcmp (extension, "")); /* Read the file depending on the extension. Not all readers have - * a built-in check if the file is readable. */ + * a built-in check if the file is readable. */ if (strcmp (extension, "ply") == 0) { vtkNew < vtkPLYReader > reader; reader->SetFileName (filename); From e13dac20a1e37b940182de585490da194e4adec6 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 9 May 2023 09:45:51 +0200 Subject: [PATCH 161/255] Add a check if we can open the file to ensure existance before reading it. --- .../t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index 0a0466ac1a..794b5bd10a 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -37,10 +37,19 @@ t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) char *extension; /* Get the file-extension to decide which reader to use. */ strcpy (tmp, filename); - extension = strtok (tmp, "."); - extension = strtok (NULL, "."); + extension = strchr (tmp, ".") + 1; T8_ASSERT (strcmp (extension, "")); + /* Check if we can open the file. */ + FILE *first_check; + first_check = fopen (filename, "r"); + if (first_check == NULL) { + t8_errorf ("Can not find the file %s\n", filename); + fclose (first_check); + return; + } + fclose (first_check); + /* Read the file depending on the extension. Not all readers have * a built-in check if the file is readable. */ if (strcmp (extension, "ply") == 0) { From 8faf55ad1dd33df2c242b1825180630db75f158d Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 9 May 2023 09:57:49 +0200 Subject: [PATCH 162/255] Change return of polydata-reader --- .../t8_cmesh_vtk_polydata.cxx | 22 +++++++++---------- .../t8_cmesh_vtk_polydata.hxx | 3 ++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index 794b5bd10a..65a46c5195 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -30,7 +30,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include -void +int t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) { char tmp[BUFSIZ]; @@ -46,7 +46,7 @@ t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) if (first_check == NULL) { t8_errorf ("Can not find the file %s\n", filename); fclose (first_check); - return; + return 1; } fclose (first_check); @@ -57,32 +57,32 @@ t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (reader->GetOutput ()); - return; + return 0; } else if (strcmp (extension, "vtp") == 0) { vtkNew < vtkXMLPolyDataReader > reader; reader->SetFileName (filename); if (!reader->CanReadFile (filename)) { t8_errorf ("Unable to read file.\n"); - return NULL; + return 1; } reader->Update (); grid->ShallowCopy (reader->GetOutput ()); - return; + return 0; } else if (strcmp (extension, "obj") == 0) { vtkNew < vtkOBJReader > reader; reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (reader->GetOutput ()); - return; + return 0; } else if (strcmp (extension, "stl") == 0) { vtkNew < vtkSTLReader > reader; reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (reader->GetOutput ()); - return; + return 0; } else if (strcmp (extension, "vtk") == 0) { vtkNew < vtkPolyDataReader > reader; @@ -91,22 +91,22 @@ t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) if (!reader->IsFilePolyData ()) { t8_errorf ("File-content is not polydata. If it is a vtkUnstructuredGrid use the unstructured Grid reader."); - return NULL; + return 1; } grid->ShallowCopy (reader->GetOutput ()); - return; + return 0; } else if (strcmp (extension, "g") == 0) { vtkNew < vtkBYUReader > reader; reader->SetGeometryFileName (filename); reader->Update (); grid->ShallowCopy (reader->GetOutput ()); - return; + return 0; } else { /* Return NULL if the reader is not used correctly. */ t8_global_errorf ("Please use .ply, .vtp, .obj, .stl, .vtk or .g file\n"); - return NULL; + return 1; } } #endif diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx index ad13a46219..91ea419ee1 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx @@ -40,9 +40,10 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * \param[in] filename The name of the file * \param[in, out] grid On input a vtkSmartPointer, that will hold the grid described in * \a filename. + * \return 0 if the file was read successfully, non-zero otherwise. * */ -void t8_read_poly (const char *filename, +int t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid); #endif From 918dcfdf9bfacfd2cbea955a468b0146e4a2fa21 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 9 May 2023 10:09:49 +0200 Subject: [PATCH 163/255] Add filename to error-output --- src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index 65a46c5195..1a41376c42 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -63,7 +63,7 @@ t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) vtkNew < vtkXMLPolyDataReader > reader; reader->SetFileName (filename); if (!reader->CanReadFile (filename)) { - t8_errorf ("Unable to read file.\n"); + t8_errorf ("Unable to read file %s.\n", filename); return 1; } reader->Update (); @@ -105,7 +105,8 @@ t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) } else { /* Return NULL if the reader is not used correctly. */ - t8_global_errorf ("Please use .ply, .vtp, .obj, .stl, .vtk or .g file\n"); + t8_global_errorf + ("Please use .ply, .vtp, .obj, .stl, .vtk or .g file %s\n", filename); return 1; } } From 479299a4690a44be265e5c19f8bfa276c4f14226 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 9 May 2023 10:15:16 +0200 Subject: [PATCH 164/255] strrchr instead of strchr --- src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index 1a41376c42..a3b80c3c27 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -37,7 +37,7 @@ t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) char *extension; /* Get the file-extension to decide which reader to use. */ strcpy (tmp, filename); - extension = strchr (tmp, ".") + 1; + extension = strrchr (tmp, ".") + 1; T8_ASSERT (strcmp (extension, "")); /* Check if we can open the file. */ From c1e2f9e6a1e2f91be927193be8ef006654705bf4 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 9 May 2023 10:48:03 +0200 Subject: [PATCH 165/255] moved hex ref coords to t8_dhex_bits.c --- src/t8_schemes/t8_default/Makefile.am | 5 +- .../t8_default_hex/t8_default_hex_cxx.cxx | 18 +----- .../t8_default_hex/t8_default_hex_cxx.hxx | 2 + .../t8_default/t8_default_hex/t8_dhex.h | 61 +++++++++++++++++++ .../t8_default/t8_default_hex/t8_dhex_bits.c | 47 ++++++++++++++ .../t8_default/t8_default_hex/t8_dhex_bits.h | 50 +++++++++++++++ 6 files changed, 166 insertions(+), 17 deletions(-) create mode 100644 src/t8_schemes/t8_default/t8_default_hex/t8_dhex.h create mode 100644 src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.c create mode 100644 src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.h diff --git a/src/t8_schemes/t8_default/Makefile.am b/src/t8_schemes/t8_default/Makefile.am index a05b594188..d25c12a72f 100644 --- a/src/t8_schemes/t8_default/Makefile.am +++ b/src/t8_schemes/t8_default/Makefile.am @@ -24,7 +24,9 @@ libt8_installed_headers_default_tri += \ src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.h \ src/t8_schemes/t8_default/t8_default_tri/t8_dtri_connectivity.h libt8_installed_headers_default_hex += \ - src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx + src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx \ + src/t8_schemes/t8_default/t8_default_hex/t8_dhex.h \ + src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.h libt8_installed_headers_default_tet += \ src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.hxx \ src/t8_schemes/t8_default/t8_default_tet/t8_dtet.h \ @@ -44,6 +46,7 @@ libt8_compiled_sources += \ src/t8_schemes/t8_default/t8_default_cxx.cxx \ src/t8_schemes/t8_default/t8_default_common/t8_default_common_cxx.cxx \ src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx \ + src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.c \ src/t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.cxx \ src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c \ src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx \ diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx index ffbf356573..b1ab3816bb 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.cxx @@ -667,22 +667,8 @@ t8_default_scheme_hex_c::t8_element_reference_coords (const t8_element_t const { T8_ASSERT (t8_element_is_valid (elem)); - const p8est_quadrant_t *q1 = (const p8est_quadrant_t *) elem; - - /* Get the length of the quadrant */ - const int len = P8EST_QUADRANT_LEN (q1->level); - - /* Compute the x, y and z coordinates of the point depending on the - * reference coordinates */ - out_coords[0] = q1->x + ref_coords[0] * len; - out_coords[1] = q1->y + ref_coords[1] * len; - out_coords[2] = q1->z + ref_coords[2] * len; - - /* We divide the integer coordinates by the root length of the hex - * to obtain the reference coordinates. */ - out_coords[0] /= (double) P8EST_ROOT_LEN; - out_coords[1] /= (double) P8EST_ROOT_LEN; - out_coords[2] /= (double) P8EST_ROOT_LEN; + t8_dhex_compute_reference_coords ((const t8_dhex_t *) elem, ref_coords, + out_coords); } int diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx index 793cd83ada..aea5cdb1ac 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx @@ -28,6 +28,8 @@ #include #include +#include +#include #include /** The structure holding a hexahedral element in the default scheme. diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_dhex.h b/src/t8_schemes/t8_default/t8_default_hex/t8_dhex.h new file mode 100644 index 0000000000..b9ea4a0cc8 --- /dev/null +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_dhex.h @@ -0,0 +1,61 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef T8_DHEX_H +#define T8_DHEX_H + +/** \file t8_dhex.h + * TODO: document this. + */ + +#include + +/** The number of children that a hex is refined into. */ +#define T8_DHEX_CHILDREN 8 + +/** The number of faces of a hex. */ +#define T8_DHEX_FACES 6 + +/** The number of children at a face of a hex. */ +#define T8_DHEX_FACE_CHILDREN 4 + +/** The maximum refinement level allowed for a hex. */ +#define T8_DHEX_MAXLEVEL 21 + +/** The length of the root hex in integer coordinates. */ +#define T8_DHEX_ROOT_LEN (1 << (T8_DHEX_MAXLEVEL)) + +/** The length of a hex at a given level in integer coordinates. */ +#define T8_DHEX_LEN(l) (1 << (T8_DHEX_MAXLEVEL - (l))) + +typedef int32_t t8_dhex_coord_t; + +typedef struct t8_dhex +{ + int8_t level; + t8_dhex_coord_t x; /**< The x integer coordinate of the anchor node. */ + t8_dhex_coord_t y; /**< The y integer coordinate of the anchor node. */ + t8_dhex_coord_t z; /**< The z integer coordinate of the anchor node. */ +} +t8_dhex_t; + +#endif /* T8_DHEX_H */ diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.c b/src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.c new file mode 100644 index 0000000000..bf5d537c57 --- /dev/null +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.c @@ -0,0 +1,47 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include +#include + +void +t8_dhex_compute_reference_coords (const t8_dhex_t * elem, + const double *ref_coords, + double *out_coords) +{ + const p8est_quadrant_t *q1 = (const p8est_quadrant_t *) elem; + + /* Get the length of the quadrant */ + const int len = P8EST_QUADRANT_LEN (q1->level); + + /* Compute the x, y and z coordinates of the point depending on the + * reference coordinates */ + out_coords[0] = q1->x + ref_coords[0] * len; + out_coords[1] = q1->y + ref_coords[1] * len; + out_coords[2] = q1->z + ref_coords[2] * len; + + /* We divide the integer coordinates by the root length of the hex + * to obtain the reference coordinates. */ + out_coords[0] /= (double) T8_DHEX_ROOT_LEN; + out_coords[1] /= (double) T8_DHEX_ROOT_LEN; + out_coords[2] /= (double) T8_DHEX_ROOT_LEN; +} diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.h b/src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.h new file mode 100644 index 0000000000..768b8a457c --- /dev/null +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.h @@ -0,0 +1,50 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** \file t8_dhex_bits.h + * Definitions of hex-specific functions. + */ + +#ifndef T8_DHEX_BITS_H +#define T8_DHEX_BITS_H + +#include +#include + +T8_EXTERN_C_BEGIN (); + +/** Convert a point in the reference space of a hex element to a point in the + * reference space of the tree (level 0) embedded in [0,1]^3. + * \param [in] elem Input hex. + * \param [in] ref_coords The reference coordinate on the hex [0, 1]^3 + * \param [out] out_coords An array of 1 double that + * will be filled with the reference coordinates + * of the point on the hex. + */ +void t8_dhex_compute_reference_coords (const t8_dhex_t * elem, + const double + *ref_coords, + double *out_coords); + +T8_EXTERN_C_END (); + +#endif /* T8_DHEX_BITS_H */ From a0d8321b6c64c7a30628a1aa06a14095f7babb9d Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 9 May 2023 10:48:39 +0200 Subject: [PATCH 166/255] moved quad ref coords to t8_dquad_bits.c --- src/t8_schemes/t8_default/Makefile.am | 5 +- .../t8_default_quad/t8_default_quad_cxx.cxx | 13 +--- .../t8_default_quad/t8_default_quad_cxx.hxx | 2 + .../t8_default/t8_default_quad/t8_dquad.h | 60 +++++++++++++++++++ .../t8_default_quad/t8_dquad_bits.c | 42 +++++++++++++ .../t8_default_quad/t8_dquad_bits.h | 51 ++++++++++++++++ 6 files changed, 161 insertions(+), 12 deletions(-) create mode 100644 src/t8_schemes/t8_default/t8_default_quad/t8_dquad.h create mode 100644 src/t8_schemes/t8_default/t8_default_quad/t8_dquad_bits.c create mode 100644 src/t8_schemes/t8_default/t8_default_quad/t8_dquad_bits.h diff --git a/src/t8_schemes/t8_default/Makefile.am b/src/t8_schemes/t8_default/Makefile.am index d25c12a72f..67c2cc3da2 100644 --- a/src/t8_schemes/t8_default/Makefile.am +++ b/src/t8_schemes/t8_default/Makefile.am @@ -17,7 +17,9 @@ libt8_installed_headers_default_line += \ src/t8_schemes/t8_default/t8_default_line/t8_dline.h \ src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h libt8_installed_headers_default_quad += \ - src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx + src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx \ + src/t8_schemes/t8_default/t8_default_quad/t8_dquad.h \ + src/t8_schemes/t8_default/t8_default_quad/t8_dquad_bits.h libt8_installed_headers_default_tri += \ src/t8_schemes/t8_default/t8_default_tri/t8_default_tri_cxx.hxx \ src/t8_schemes/t8_default/t8_default_tri/t8_dtri.h \ @@ -52,6 +54,7 @@ libt8_compiled_sources += \ src/t8_schemes/t8_default/t8_default_prism/t8_default_prism_cxx.cxx \ src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c \ src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx \ + src/t8_schemes/t8_default/t8_default_quad/t8_dquad_bits.c \ src/t8_schemes/t8_default/t8_default_tet/t8_default_tet_cxx.cxx \ src/t8_schemes/t8_default/t8_default_tet/t8_dtet_bits.c \ src/t8_schemes/t8_default/t8_default_tet/t8_dtet_connectivity.c \ diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx index e5c8e869fe..7d81cf6e4b 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.cxx @@ -800,17 +800,8 @@ t8_default_scheme_quad_c::t8_element_reference_coords (const t8_element_t const { T8_ASSERT (t8_element_is_valid (elem)); - const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) elem; - out_coords[0] = q1->x / (double) P4EST_ROOT_LEN; - out_coords[1] = q1->y / (double) P4EST_ROOT_LEN; - const double len = - P4EST_QUADRANT_LEN (q1->level) / (double) P4EST_ROOT_LEN; - - out_coords[0] += ref_coords[0] * len; - out_coords[1] += ref_coords[1] * len; - - out_coords[0] /= (double) P4EST_ROOT_LEN; - out_coords[1] /= (double) P4EST_ROOT_LEN; + t8_dquad_compute_reference_coords ((const t8_dquad_t *) elem, ref_coords, + out_coords); } void diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx index e21cfb0e2a..fddb6289d6 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad_cxx.hxx @@ -33,6 +33,8 @@ #include #include +#include +#include #include #include diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_dquad.h b/src/t8_schemes/t8_default/t8_default_quad/t8_dquad.h new file mode 100644 index 0000000000..b25d8ca179 --- /dev/null +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_dquad.h @@ -0,0 +1,60 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef T8_DQUAD_H +#define T8_DQUAD_H + +/** \file t8_dquad.h + * TODO: document this. + */ + +#include + +/** The number of children that a quad is refined into. */ +#define T8_DQUAD_CHILDREN 4 + +/** The number of faces of a quad. */ +#define T8_DQUAD_FACES 4 + +/** The number of children at a face of a quad. */ +#define T8_DQUAD_FACE_CHILDREN 2 + +/** The maximum refinement level allowed for a quad. */ +#define T8_DQUAD_MAXLEVEL 29 + +/** The length of the root quad in integer coordinates. */ +#define T8_DQUAD_ROOT_LEN (1 << (T8_DQUAD_MAXLEVEL)) + +/** The length of a quad at a given level in integer coordinates. */ +#define T8_DQUAD_LEN(l) (1 << (T8_DQUAD_MAXLEVEL - (l))) + +typedef int32_t t8_dquad_coord_t; + +typedef struct t8_dquad +{ + int8_t level; + t8_dquad_coord_t x; /**< The x integer coordinate of the anchor node. */ + t8_dquad_coord_t y; /**< The y integer coordinate of the anchor node. */ +} +t8_dquad_t; + +#endif /* T8_DQUAD_H */ diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_dquad_bits.c b/src/t8_schemes/t8_default/t8_default_quad/t8_dquad_bits.c new file mode 100644 index 0000000000..76394ce845 --- /dev/null +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_dquad_bits.c @@ -0,0 +1,42 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include +#include + +void +t8_dquad_compute_reference_coords (const t8_dquad_t * elem, + const double *ref_coords, + double *out_coords) +{ + const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) elem; + out_coords[0] = q1->x / (double) T8_DQUAD_ROOT_LEN; + out_coords[1] = q1->y / (double) T8_DQUAD_ROOT_LEN; + const double len = + P4EST_QUADRANT_LEN (q1->level) / (double) T8_DQUAD_ROOT_LEN; + + out_coords[0] += ref_coords[0] * len; + out_coords[1] += ref_coords[1] * len; + + out_coords[0] /= (double) T8_DQUAD_ROOT_LEN; + out_coords[1] /= (double) T8_DQUAD_ROOT_LEN; +} diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_dquad_bits.h b/src/t8_schemes/t8_default/t8_default_quad/t8_dquad_bits.h new file mode 100644 index 0000000000..ddbf2b717c --- /dev/null +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_dquad_bits.h @@ -0,0 +1,51 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** \file t8_dquad_bits.h + * Definitions of quad-specific functions. + */ + +#ifndef T8_DQUAD_BITS_H +#define T8_DQUAD_BITS_H + +#include +#include + +T8_EXTERN_C_BEGIN (); + +/** Convert a point in the reference space of a quad element to a point in the + * reference space of the tree (level 0) embedded in [0,1]^2. + * \param [in] elem Input quad. + * \param [in] ref_coords The reference coordinate on the quad [0, 1]^2 + * \param [out] out_coords An array of 1 double that + * will be filled with the reference coordinates + * of the point on the quad. + */ +void t8_dquad_compute_reference_coords (const t8_dquad_t * + elem, + const double + *ref_coords, + double *out_coords); + +T8_EXTERN_C_END (); + +#endif /* T8_DQUAD_BITS_H */ From 99a145044cd9516b1d9b125c1eaccd67fc9bdb55 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 9 May 2023 10:48:56 +0200 Subject: [PATCH 167/255] added assertion --- src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c index 613579f57b..3990304e7f 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c @@ -569,6 +569,7 @@ t8_dprism_vertex_ref_coords (const t8_dprism_t *elem, const int vertex, double coords[3]) { int coords_int[3]; + T8_ASSERT (t8_dprism_is_valid (elem)); T8_ASSERT (vertex >= 0 && vertex < 6); /* Compute the integere coordinates in [0, root_len]^3 */ From c2c63df70c4d6ad651432ff42065c61dfce9cb48 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 9 May 2023 11:51:25 +0200 Subject: [PATCH 168/255] Update src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx Co-authored-by: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> --- src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index a3b80c3c27..b7c4286709 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -37,7 +37,7 @@ t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) char *extension; /* Get the file-extension to decide which reader to use. */ strcpy (tmp, filename); - extension = strrchr (tmp, ".") + 1; + extension = strrchr (tmp, '.') + 1; T8_ASSERT (strcmp (extension, "")); /* Check if we can open the file. */ From 5d81849e8da31bd30ea9f8fe72a2425e6b1af035 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 9 May 2023 13:25:07 +0200 Subject: [PATCH 169/255] added headerfiles --- src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx | 2 +- src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index b7c4286709..e930c03a28 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -20,8 +20,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #if T8_WITH_VTK -#include #include #include #include diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx index 91ea419ee1..280a01434b 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx @@ -28,6 +28,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #ifndef T8_CMESH_VTK_POLYDATA #define T8_CMESH_VTK_POLYDATA +#include #if T8_WITH_VTK #include #include From 2f4882fe3382ffcbd21d5cc1a51e9dc57def0b2c Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 9 May 2023 15:28:07 +0200 Subject: [PATCH 170/255] add preprocessor macros for documentation --- doc/Doxyfile.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index 4182e39b4f..744eb5f917 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -2204,7 +2204,12 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = @PACKAGE_PREFIX@_DOXYGEN +PREDEFINED = @PACKAGE_PREFIX@_DOXYGEN \ + T8_ENABL_DEBUG \ + T8_WITH_VTK \ + T8_WITH_OCC \ + T8_WITH_NETCDF \ + T8_WITH_NETCDF_PAR # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The From b5a5cfbae53e344ed114ab2a1f508f73121032ff Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 9 May 2023 16:16:32 +0200 Subject: [PATCH 171/255] Add vtkPolyData to header --- src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx index 280a01434b..b1513497b3 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx @@ -30,6 +30,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #if T8_WITH_VTK +#include #include #include #include From 81089b326cea117d9f7f18ea16e86610b93bb843 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 10 May 2023 09:21:19 +0200 Subject: [PATCH 172/255] Add -lvtkIOPLY to libraries --- config/t8_vtk.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/t8_vtk.m4 b/config/t8_vtk.m4 index c830e9528d..355b00b1d0 100644 --- a/config/t8_vtk.m4 +++ b/config/t8_vtk.m4 @@ -32,7 +32,7 @@ T8_ARG_WITH([vtk], T8_VTK_LIBS="-lvtkIOXML-$t8_vtk_version -lvtkCommonExecutionModel-$t8_vtk_version \ -lvtkCommonDataModel-$t8_vtk_version -lvtkIOXMLParser-$t8_vtk_version \ --lvtkIOParallelXML-$t8_vtk_version -lvtkParallelMPI-$t8_vtk_version \ +-lvtkIOParallelXML-$t8_vtk_version -lvtkParallelMPI-$t8_vtk_version -lvtkIOPLY-$t8_vtk_version \ -lvtkCommonCore-$t8_vtk_version -lvtkzlib-$t8_vtk_version -lvtksys-$t8_vtk_version" if test "x$T8_WITH_VTK" != xyes ; then T8_VTK_LIBS="$T8_WITH_VTK" From d2d16ee93b0ad5bbc71bd4305a8c1184c1d801f7 Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Wed, 10 May 2023 10:24:36 +0200 Subject: [PATCH 173/255] Renamed cmesh example routine and added an example. --- example/cmesh/Makefile.am | 4 +- example/cmesh/t8_cmesh_hypercube_pad.cxx | 81 ++++++++++++++++++++++++ src/t8_cmesh/t8_cmesh_examples.c | 11 ++-- src/t8_cmesh/t8_cmesh_examples.h | 12 ++-- 4 files changed, 95 insertions(+), 13 deletions(-) create mode 100644 example/cmesh/t8_cmesh_hypercube_pad.cxx diff --git a/example/cmesh/Makefile.am b/example/cmesh/Makefile.am index df4b9b87b6..816b7e4738 100644 --- a/example/cmesh/Makefile.am +++ b/example/cmesh/Makefile.am @@ -5,8 +5,10 @@ bin_PROGRAMS += \ example/cmesh/t8_cmesh_partition \ example/cmesh/t8_cmesh_create_partitioned \ - example/cmesh/t8_cmesh_refine + example/cmesh/t8_cmesh_refine \ + example/cmesh/t8_cmesh_hypercube_pad example_cmesh_t8_cmesh_partition_SOURCES = example/cmesh/t8_cmesh_partition.cxx example_cmesh_t8_cmesh_refine_SOURCES = example/cmesh/t8_cmesh_refine.cxx example_cmesh_t8_cmesh_create_partitioned_SOURCES = example/cmesh/t8_cmesh_create_partitioned.cxx +example_cmesh_t8_cmesh_hypercube_pad_SOURCES = example/cmesh/t8_cmesh_hypercube_pad.cxx diff --git a/example/cmesh/t8_cmesh_hypercube_pad.cxx b/example/cmesh/t8_cmesh_hypercube_pad.cxx new file mode 100644 index 0000000000..fbb703f770 --- /dev/null +++ b/example/cmesh/t8_cmesh_hypercube_pad.cxx @@ -0,0 +1,81 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element types in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include +#include + +int +main (int argc, char **argv) +{ + /* The prefix for our output files. */ + const char prefix[BUFSIZ] = "t8_cmesh_hypercube_pad"; + t8_locidx_t local_num_trees; + t8_gloidx_t global_num_trees; + + const double boundary_coords[24] = { + 1, 0, 0, + 4, 0, 0, + 0, 6, 0, + 5, 5, 0, + -1, -2, 8, + 9, 0, 10, + 0, 8, 9, + 10, 10, 10 + }; + + /* Initialize MPI. This has to happen before we initialize sc or t8code. */ + int mpiret = sc_MPI_Init (&argc, &argv); + /* Error check the MPI return value. */ + SC_CHECK_MPI (mpiret); + + /* Initialize the sc library, has to happen before we initialize t8code. */ + sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_ESSENTIAL); + /* Initialize t8code with log level SC_LP_PRODUCTION. See sc.h for more info on the log levels. */ + t8_init (SC_LP_PRODUCTION); + + /* Padd hypercube with given element class. */ + t8_cmesh_t cmesh = + t8_cmesh_new_hypercube_pad (T8_ECLASS_HEX, sc_MPI_COMM_WORLD, + boundary_coords, 3, 3, 3); + + /* Compute local and global number of trees. */ + local_num_trees = t8_cmesh_get_num_local_trees (cmesh); + global_num_trees = t8_cmesh_get_num_trees (cmesh); + t8_global_productionf (" [step1] Created coarse mesh.\n"); + t8_global_productionf (" [step1] Local number of trees:\t%i\n", + local_num_trees); + t8_global_productionf (" [step1] Global number of trees:\t%li\n", + global_num_trees); + + t8_cmesh_vtk_write_file (cmesh, prefix, 1.0); + + t8_cmesh_destroy (&cmesh); + + sc_finalize (); + + mpiret = sc_MPI_Finalize (); + SC_CHECK_MPI (mpiret); + + return 0; +} diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index e004bd9572..06dd4cc7d1 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1242,12 +1242,11 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, } t8_cmesh_t -t8_cmesh_new_hypercube_extrude (const t8_eclass_t eclass, - sc_MPI_Comm comm, - const double *boundary, - t8_locidx_t polygons_x, - t8_locidx_t polygons_y, - t8_locidx_t polygons_z) +t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, + sc_MPI_Comm comm, + const double *boundary, + t8_locidx_t polygons_x, + t8_locidx_t polygons_y, t8_locidx_t polygons_z) { SC_CHECK_ABORT (eclass != T8_ECLASS_PYRAMID, "Pyramids are not yet supported."); diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 9ea498bf9b..559f97759d 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -132,12 +132,12 @@ t8_cmesh_t t8_cmesh_new_hypercube (t8_eclass_t eclass, * |/0|/2|/4| Thus, we get 6 trees, which are ordered as shown in the picture. * a--e--g--b */ -t8_cmesh_t t8_cmesh_new_hypercube_extrude (const t8_eclass_t eclass, - sc_MPI_Comm comm, - const double *boundary, - t8_locidx_t polygons_x, - t8_locidx_t polygons_y, - t8_locidx_t polygons_z); +t8_cmesh_t t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, + sc_MPI_Comm comm, + const double *boundary, + t8_locidx_t polygons_x, + t8_locidx_t polygons_y, + t8_locidx_t polygons_z); /** Hybercube with 6 Tets, 6 Prism, 4 Hex. * \param [in] comm The mpi communicator to be used. From 5056d1acdd8bb0eab395761427c00cdf62c3a24a Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Wed, 10 May 2023 10:28:52 +0200 Subject: [PATCH 174/255] Added reference in documentation. --- src/t8_cmesh/t8_cmesh_examples.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 559f97759d..1e4f2a27c8 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -131,6 +131,8 @@ t8_cmesh_t t8_cmesh_new_hypercube (t8_eclass_t eclass, * |1/|3/|5/| The ordering is the same as in \see t8_cmesh_new_hypercube. * |/0|/2|/4| Thus, we get 6 trees, which are ordered as shown in the picture. * a--e--g--b + * + * See `example/cmesh/t8_cmesh_hypercube_pad.cxx` for a working example. */ t8_cmesh_t t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, From a47452a381ce7302b3a21c47e3ee2f2396554f94 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Wed, 10 May 2023 10:34:24 +0200 Subject: [PATCH 175/255] moved header in Makefile to installed_header --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index cd009f1082..756efcfca2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,6 +27,7 @@ libt8_installed_headers = \ src/t8_cmesh_tetgen.h src/t8_cmesh_readmshfile.h \ src/t8_cmesh_vtk_writer.h \ src/t8_cmesh_vtk_reader.hxx \ + src/t8_vtk/t8_vtk_reader.hxx \ src/t8_forest.h \ src/t8_vec.h \ src/t8_version.h \ @@ -76,7 +77,6 @@ libt8_internal_headers = \ src/t8_cmesh/t8_cmesh_offset.h \ src/t8_vtk/t8_vtk_polydata.hxx \ src/t8_vtk/t8_vtk_unstructured.hxx \ - src/t8_vtk/t8_vtk_reader.hxx \ src/t8_vtk/t8_vtk_types.h \ src/t8_forest/t8_forest_cxx.h \ src/t8_forest/t8_forest_ghost.h \ From 262dbaec1da41a6c1cd93dc8f945058727eff281 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Wed, 10 May 2023 10:49:49 +0200 Subject: [PATCH 176/255] moved header in Makefile --- src/Makefile.am | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 756efcfca2..70e95492b0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,6 +8,7 @@ forestincludedir = $(includedir)/t8_forest geometryincludedir = $(includedir)/t8_geometry geometryimplincludedir = $(geometryincludedir)/t8_geometry_implementations schemesdefaultincludedir = $(includedir)/t8_schemes/t8_default +vtkincludedir = $(includedir)/vtk defaultcommonincludedir = $(schemesdefaultincludedir)/t8_default_common defaultvertexincludedir = $(schemesdefaultincludedir)/t8_default_vertex defaultlineincludedir = $(schemesdefaultincludedir)/t8_default_line @@ -27,7 +28,6 @@ libt8_installed_headers = \ src/t8_cmesh_tetgen.h src/t8_cmesh_readmshfile.h \ src/t8_cmesh_vtk_writer.h \ src/t8_cmesh_vtk_reader.hxx \ - src/t8_vtk/t8_vtk_reader.hxx \ src/t8_forest.h \ src/t8_vec.h \ src/t8_version.h \ @@ -60,6 +60,9 @@ libt8_installed_headers_geometry_impl = \ src/t8_geometry/t8_geometry_implementations/t8_geometry_occ.hxx \ src/t8_geometry/t8_geometry_implementations/t8_geometry_linear.hxx \ src/t8_geometry/t8_geometry_implementations/t8_geometry_zero.hxx +libt8_installed_headers_vtk = \ + src/t8_vtk/t8_vtk_reader.hxx \ + src/t8_vtk/t8_vtk_types.h libt8_installed_headers_schemes_default = libt8_installed_headers_default_common = libt8_installed_headers_default_vertex = @@ -77,7 +80,6 @@ libt8_internal_headers = \ src/t8_cmesh/t8_cmesh_offset.h \ src/t8_vtk/t8_vtk_polydata.hxx \ src/t8_vtk/t8_vtk_unstructured.hxx \ - src/t8_vtk/t8_vtk_types.h \ src/t8_forest/t8_forest_cxx.h \ src/t8_forest/t8_forest_ghost.h \ src/t8_forest/t8_forest_balance.h src/t8_forest/t8_forest_types.h \ @@ -146,6 +148,7 @@ dist_forestinclude_HEADERS = $(libt8_installed_headers_forest) dist_geometryinclude_HEADERS = $(libt8_installed_headers_geometry) dist_geometryimplinclude_HEADERS = $(libt8_installed_headers_geometry_impl) dist_schemesdefaultinclude_HEADERS = $(libt8_installed_headers_schemes_default) +dist_vtkinclude_HEADERS = $(libt8_installed_headers_vtk) dist_defaultcommoninclude_HEADERS = $(libt8_installed_headers_default_common) dist_defaultvertexinclude_HEADERS = $(libt8_installed_headers_default_vertex) dist_defaultlineinclude_HEADERS = $(libt8_installed_headers_default_line) From 5ff7d9cae5fa38fd457aae7c493062c2269834ac Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> Date: Wed, 10 May 2023 11:08:02 +0200 Subject: [PATCH 177/255] typo --- doc/Doxyfile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index 744eb5f917..ebda2d97a7 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -2205,7 +2205,7 @@ INCLUDE_FILE_PATTERNS = # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. PREDEFINED = @PACKAGE_PREFIX@_DOXYGEN \ - T8_ENABL_DEBUG \ + T8_ENABLE_DEBUG \ T8_WITH_VTK \ T8_WITH_OCC \ T8_WITH_NETCDF \ From a2aad6cef3ea9f66fa4e64be601d741299460745 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Wed, 10 May 2023 11:18:24 +0200 Subject: [PATCH 178/255] fixed include error --- example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx b/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx index 2b2bf6e004..755b13c513 100644 --- a/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx +++ b/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx @@ -22,9 +22,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include -#include #include -#include +#include /** * Construct a cmesh read from a VTK-file type supported by our vtk-reader. From 9bc11edb65fb1549477a389e3f9784a127415641 Mon Sep 17 00:00:00 2001 From: Johannes Markert <10619309+jmark@users.noreply.github.com> Date: Wed, 10 May 2023 11:33:48 +0200 Subject: [PATCH 179/255] Update test/t8_cmesh/t8_gtest_multiple_attributes.cxx Co-authored-by: David Knapp --- test/t8_cmesh/t8_gtest_multiple_attributes.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/t8_cmesh/t8_gtest_multiple_attributes.cxx b/test/t8_cmesh/t8_gtest_multiple_attributes.cxx index ad1e204656..71d0d4a829 100644 --- a/test/t8_cmesh/t8_gtest_multiple_attributes.cxx +++ b/test/t8_cmesh/t8_gtest_multiple_attributes.cxx @@ -129,7 +129,7 @@ TEST_P (cmesh_multiple_attributes, multiple_attributes) { EXPECT_EQ(num_local_trees, t8_cmesh_get_num_local_trees(cmesh_mult_at_from_stash)); t8_locidx_t num_ghosts = t8_cmesh_get_num_ghosts(cmesh_mult_at_from_stash); for (t8_locidx_t ltree_id = 0; ltree_id < num_local_trees + num_ghosts; ltree_id++) { - t8_gloidx_t gtree_id = t8_cmesh_get_global_id(cmesh_mult_at_from_stash, ltree_id); + const t8_gloidx_t gtree_id = t8_cmesh_get_global_id(cmesh_mult_at_from_stash, ltree_id); const double *vertices_partition = (double *) t8_cmesh_get_attribute (cmesh_mult_at_from_stash, t8_get_package_id (), T8_CMESH_VERTICES_ATTRIBUTE_KEY, ltree_id); t8_eclass_t eclass = (ltree_id < num_local_trees) ? t8_cmesh_get_tree_class (cmesh_one_at, ltree_id) : t8_cmesh_get_ghost_class (cmesh_one_at, ltree_id - num_local_trees); From f4c57a69f38ef4113c021ca771444b74ae1d2e87 Mon Sep 17 00:00:00 2001 From: Johannes Markert <10619309+jmark@users.noreply.github.com> Date: Wed, 10 May 2023 11:34:02 +0200 Subject: [PATCH 180/255] Update test/t8_cmesh/t8_gtest_multiple_attributes.cxx Co-authored-by: David Knapp --- test/t8_cmesh/t8_gtest_multiple_attributes.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/t8_cmesh/t8_gtest_multiple_attributes.cxx b/test/t8_cmesh/t8_gtest_multiple_attributes.cxx index 71d0d4a829..90a1adb582 100644 --- a/test/t8_cmesh/t8_gtest_multiple_attributes.cxx +++ b/test/t8_cmesh/t8_gtest_multiple_attributes.cxx @@ -132,7 +132,7 @@ TEST_P (cmesh_multiple_attributes, multiple_attributes) { const t8_gloidx_t gtree_id = t8_cmesh_get_global_id(cmesh_mult_at_from_stash, ltree_id); const double *vertices_partition = (double *) t8_cmesh_get_attribute (cmesh_mult_at_from_stash, t8_get_package_id (), T8_CMESH_VERTICES_ATTRIBUTE_KEY, ltree_id); - t8_eclass_t eclass = (ltree_id < num_local_trees) ? t8_cmesh_get_tree_class (cmesh_one_at, ltree_id) : t8_cmesh_get_ghost_class (cmesh_one_at, ltree_id - num_local_trees); + const t8_eclass_t eclass = (ltree_id < num_local_trees) ? t8_cmesh_get_tree_class (cmesh_one_at, ltree_id) : t8_cmesh_get_ghost_class (cmesh_one_at, ltree_id - num_local_trees); EXPECT_EQ(T8_ECLASS_HEX, eclass); /* Compare vertices with reference vertices. */ From 3b22f327d2c34dd565a1b62294fb36533fc76ff6 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 10 May 2023 11:38:55 +0200 Subject: [PATCH 181/255] Add vtkIOGeometry --- config/t8_vtk.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/t8_vtk.m4 b/config/t8_vtk.m4 index 355b00b1d0..f240016aff 100644 --- a/config/t8_vtk.m4 +++ b/config/t8_vtk.m4 @@ -33,7 +33,7 @@ T8_ARG_WITH([vtk], T8_VTK_LIBS="-lvtkIOXML-$t8_vtk_version -lvtkCommonExecutionModel-$t8_vtk_version \ -lvtkCommonDataModel-$t8_vtk_version -lvtkIOXMLParser-$t8_vtk_version \ -lvtkIOParallelXML-$t8_vtk_version -lvtkParallelMPI-$t8_vtk_version -lvtkIOPLY-$t8_vtk_version \ --lvtkCommonCore-$t8_vtk_version -lvtkzlib-$t8_vtk_version -lvtksys-$t8_vtk_version" +-lvtkCommonCore-$t8_vtk_version -lvtkzlib-$t8_vtk_version -lvtksys-$t8_vtk_version -lvtkIOGeometry-$t8_vtk_version" if test "x$T8_WITH_VTK" != xyes ; then T8_VTK_LIBS="$T8_WITH_VTK" dnl AC_MSG_ERROR([Please provide --with-vtk without arguments]) From 16bb62cc03a54b4cca3344cf7d8d736a38e489d4 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 10 May 2023 11:44:44 +0200 Subject: [PATCH 182/255] Add libs for BYU reader --- config/t8_vtk.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/t8_vtk.m4 b/config/t8_vtk.m4 index f240016aff..e3abb32506 100644 --- a/config/t8_vtk.m4 +++ b/config/t8_vtk.m4 @@ -33,7 +33,8 @@ T8_ARG_WITH([vtk], T8_VTK_LIBS="-lvtkIOXML-$t8_vtk_version -lvtkCommonExecutionModel-$t8_vtk_version \ -lvtkCommonDataModel-$t8_vtk_version -lvtkIOXMLParser-$t8_vtk_version \ -lvtkIOParallelXML-$t8_vtk_version -lvtkParallelMPI-$t8_vtk_version -lvtkIOPLY-$t8_vtk_version \ --lvtkCommonCore-$t8_vtk_version -lvtkzlib-$t8_vtk_version -lvtksys-$t8_vtk_version -lvtkIOGeometry-$t8_vtk_version" +-lvtkCommonCore-$t8_vtk_version -lvtkzlib-$t8_vtk_version -lvtksys-$t8_vtk_version \ +-lvtkIOGeometry-$t8_vtk_version -lvtkIOMovie-$t8_vtk_version" if test "x$T8_WITH_VTK" != xyes ; then T8_VTK_LIBS="$T8_WITH_VTK" dnl AC_MSG_ERROR([Please provide --with-vtk without arguments]) From bb3c43c97c5abf01ebd74f46e5c96606ffe44652 Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Wed, 10 May 2023 12:21:41 +0200 Subject: [PATCH 183/255] Removed deprecated unit test file and removed some unneccessary exectuable bits of some files. --- .../t8_geometry_occ.cxx | 0 test/t8_forest/t8_test_user_data.cxx | 160 ------------------ test/t8_geometry/t8_gtest_geometry_occ.cxx | 0 test/testfiles/test_msh_file_vers2_ascii.msh | 0 4 files changed, 160 deletions(-) mode change 100755 => 100644 src/t8_geometry/t8_geometry_implementations/t8_geometry_occ.cxx delete mode 100644 test/t8_forest/t8_test_user_data.cxx mode change 100755 => 100644 test/t8_geometry/t8_gtest_geometry_occ.cxx mode change 100755 => 100644 test/testfiles/test_msh_file_vers2_ascii.msh diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_occ.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_occ.cxx old mode 100755 new mode 100644 diff --git a/test/t8_forest/t8_test_user_data.cxx b/test/t8_forest/t8_test_user_data.cxx deleted file mode 100644 index 7ea39ddb10..0000000000 --- a/test/t8_forest/t8_test_user_data.cxx +++ /dev/null @@ -1,160 +0,0 @@ -/* - This file is part of t8code. - t8code is a C library to manage a collection (a forest) of multiple - connected adaptive space-trees of general element classes in parallel. - - Copyright (C) 2015 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -/* In this test we test the t8_forest_set/get_user_data and - * t8_forest_set/get_user_function functions. - */ - -#include -#include -#include -#include - -/* Test t8_forest_set/get_user_data. - * We build a forest and set user data for it. - * We then retrieve the data and check whether it is the same. - */ -static void -t8_test_user_data (sc_MPI_Comm mpic) -{ - /* Build a forest */ - t8_cmesh_t cmesh = - t8_cmesh_new_hypercube (T8_ECLASS_TRIANGLE, mpic, 0, 0, 0); - t8_scheme_cxx_t *scheme = t8_scheme_new_default_cxx (); - t8_forest_t forest = - t8_forest_new_uniform (cmesh, scheme, 1, 0, mpic); - /* Define user data */ - double data = 42.42; - double *get_data; - int data2 = 42; - int *get_data2; - - /* Set user data of forest */ - t8_forest_set_user_data (forest, (void *) &data); - /* Get pointer to forest user data */ - get_data = (double *) t8_forest_get_user_data (forest); - - /* Check whether retrieved pointer points to data. */ - SC_CHECK_ABORT (get_data == &data, - "Forest returned wrong user data pointer."); - /* Check whether data was unchanged. */ - SC_CHECK_ABORT (*get_data == 42.42, "User data value has changed."); - - /* Add new data and repeat the check */ - - /* Set user data of forest */ - t8_forest_set_user_data (forest, (void *) &data2); - /* Get pointer to forest user data */ - get_data2 = (int *) t8_forest_get_user_data (forest); - - /* Check whether retrieved pointer points to data. */ - SC_CHECK_ABORT (get_data2 == &data2, - "Forest returned wrong user data pointer."); - /* Check whether data was unchanged. */ - SC_CHECK_ABORT (*get_data2 == 42, "User data value has changed."); - - /* Clean up */ - t8_forest_unref (&forest); -} - -/* A test function that we can set for the - * user function pointer of a forest. */ -static double -t8_test_function_42 (int i) -{ - return 42.42 + i; -} - -/* A second test function that we can set for the - * user function pointer of a forest. */ -static void -t8_test_function_second (void) -{ - /* do nothing */ -} - -/* Test t8_forest_set/get_user_function. - * We build a forest and set a user function for it. - * We then retrieve the function and check whether it is the same. - */ -static void -t8_test_user_function (sc_MPI_Comm mpic) -{ - /* Build a forest */ - t8_cmesh_t cmesh = - t8_cmesh_new_hypercube (T8_ECLASS_TRIANGLE, mpic, 0, 0, 0); - t8_scheme_cxx_t *scheme = t8_scheme_new_default_cxx (); - t8_forest_t forest = - t8_forest_new_uniform (cmesh, scheme, 1, 0, mpic); - - double (*funpointer) (int); - void (*funpointer_second) (void); - - /* Set the t8_test_function_42 as user function pointer. */ - t8_forest_set_user_function (forest, (void (*)(void)) &t8_test_function_42); - /* Retrieve the function pointer from the forest. */ - funpointer = (double (*)(int)) t8_forest_get_user_function (forest); - - /* Check whether the function pointer is correct. */ - SC_CHECK_ABORT (funpointer == &t8_test_function_42, - "Forest returned wrong user function pointer."); - /* Additionally call the function and check correct return value. */ - SC_CHECK_ABORT (funpointer (0) == 42.42, - "Forest function pointer returned wrong result."); - - /* Overwrite the function user pointer with a second function. */ - t8_forest_set_user_function (forest, - (void (*)(void)) &t8_test_function_second); - /* Retrieve the function pointer from the forest. */ - funpointer_second = (void (*)(void)) t8_forest_get_user_function (forest); - - /* Check whether the function pointer is correct. */ - SC_CHECK_ABORT (funpointer_second == &t8_test_function_second, - "Forest returned wrong user function pointer."); - - /* clean up */ - t8_forest_unref (&forest); -} - -int -main (int argc, char **argv) -{ - int mpiret; - sc_MPI_Comm mpic; - - mpiret = sc_MPI_Init (&argc, &argv); - SC_CHECK_MPI (mpiret); - - mpic = sc_MPI_COMM_WORLD; - sc_init (mpic, 1, 1, NULL, SC_LP_PRODUCTION); - t8_init (SC_LP_DEFAULT); - - t8_test_user_data (mpic); - t8_test_user_function (mpic); - - sc_finalize (); - - mpiret = sc_MPI_Finalize (); - SC_CHECK_MPI (mpiret); - - return 0; -} diff --git a/test/t8_geometry/t8_gtest_geometry_occ.cxx b/test/t8_geometry/t8_gtest_geometry_occ.cxx old mode 100755 new mode 100644 diff --git a/test/testfiles/test_msh_file_vers2_ascii.msh b/test/testfiles/test_msh_file_vers2_ascii.msh old mode 100755 new mode 100644 From 28204def21c6c024ce7cb2be25ac75e3bf5ffb99 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 10 May 2023 12:54:55 +0200 Subject: [PATCH 184/255] Update src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx Co-authored-by: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> --- src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index e930c03a28..9363d3f653 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -110,4 +110,4 @@ t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid) return 1; } } -#endif +#endif /* T8_WITH_VTK */ From 4f46bd8269f2c36a5596c27c0029a2aa0b893f5b Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 10 May 2023 12:55:56 +0200 Subject: [PATCH 185/255] Update src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx Co-authored-by: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> --- src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx index b1513497b3..3bb0824b6a 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx @@ -48,6 +48,6 @@ along with t8code; if not, write to the Free Software Foundation, Inc., int t8_read_poly (const char *filename, vtkSmartPointer < vtkPolyData > grid); -#endif +#endif /* T8_WITH_VTK */ #endif /* T8_CMESH_VTK_POLYDATA */ From 0fb07b92cac45aad7a7f3697ad09c19146656041 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Wed, 10 May 2023 15:16:01 +0200 Subject: [PATCH 186/255] moved t8_vtk_reader_pointSet inside T8_WITH_VTK macro --- src/t8_vtk/t8_vtk_reader.cxx | 4 +-- src/t8_vtk/t8_vtk_reader.hxx | 47 ++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/t8_vtk/t8_vtk_reader.cxx b/src/t8_vtk/t8_vtk_reader.cxx index 05b829690f..a9c196fb85 100644 --- a/src/t8_vtk/t8_vtk_reader.cxx +++ b/src/t8_vtk/t8_vtk_reader.cxx @@ -441,8 +441,6 @@ t8_vtk_reader (const char *filename, const int partition, } } -#endif /* T8_WITH_VTK */ - vtkSmartPointer < vtkPointSet > t8_vtk_reader_pointSet (const char *filename, const int partition, @@ -461,6 +459,8 @@ t8_vtk_reader_pointSet (const char *filename, return NULL; } +#endif /* T8_WITH_VTK */ + t8_cmesh_t t8_vtk_reader_cmesh (const char *filename, const int partition, const int main_proc, sc_MPI_Comm comm, diff --git a/src/t8_vtk/t8_vtk_reader.hxx b/src/t8_vtk/t8_vtk_reader.hxx index 08e65dfa6a..8277150c5a 100644 --- a/src/t8_vtk/t8_vtk_reader.hxx +++ b/src/t8_vtk/t8_vtk_reader.hxx @@ -83,54 +83,55 @@ vtkSmartPointer < vtkDataSet > t8_vtk_reader (const char *filename, const vtk_file_type_t vtk_file_type); -#endif - /** * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and - * construct a cmesh. This is a two stage process. First the file is read and - * stored in a vtkDataSet using \a t8_vtk_reader and \a t8_file_to_vtkGrid. - * In the second stage a cmesh is constructed from the vtkDataSet using \a t8_vtkGrid_to_cmesh. + * a set of points is constructed. This is a two stage process. First the file + * is read and stored in a vtkDataSet using \a t8_vtk_reader and + * \a t8_file_to_vtkGrid. In the second stage a vtkPointSet is constructed from + * the vtkDataSet using \a t8_vtkGrid_to_vtkPointSet. * * Both stages use the vtk-library, therefore the function is only available if * t8code is linked against VTK. * - * * \param[in] filename The name of the file * \param[in] partition Flag if the constructed mesh should be partitioned * \param[in] main_proc The main reading processor * \param[in] comm An mpi-communicator * \param[in] vtk_file_type A vtk-filetype that is readable by t8code. - * \return A commited cmesh. + * \return Pointer to vtkDataSet */ -t8_cmesh_t t8_vtk_reader_cmesh (const char *filename, - const int partition, - const int main_proc, - sc_MPI_Comm comm, - const vtk_file_type_t vtk_file_type); +vtkSmartPointer < vtkPointSet > t8_vtk_reader_pointSet (const char *filename, + const int partition, + const int main_proc, + sc_MPI_Comm comm, + const vtk_file_type_t + vtk_file_type); + +#endif /** * Given a filename to a vtkUnstructuredGrid or vtkPolyData read the file and - * a set of points is constructed. This is a two stage process. First the file - * is read and stored in a vtkDataSet using \a t8_vtk_reader and - * \a t8_file_to_vtkGrid. In the second stage a vtkPointSet is constructed from - * the vtkDataSet using \a t8_vtkGrid_to_vtkPointSet. + * construct a cmesh. This is a two stage process. First the file is read and + * stored in a vtkDataSet using \a t8_vtk_reader and \a t8_file_to_vtkGrid. + * In the second stage a cmesh is constructed from the vtkDataSet using \a t8_vtkGrid_to_cmesh. * * Both stages use the vtk-library, therefore the function is only available if * t8code is linked against VTK. * + * * \param[in] filename The name of the file * \param[in] partition Flag if the constructed mesh should be partitioned * \param[in] main_proc The main reading processor * \param[in] comm An mpi-communicator * \param[in] vtk_file_type A vtk-filetype that is readable by t8code. - * \return Pointer to vtkDataSet + * \return A commited cmesh. */ -vtkSmartPointer < vtkPointSet > t8_vtk_reader_pointSet (const char *filename, - const int partition, - const int main_proc, - sc_MPI_Comm comm, - const vtk_file_type_t - vtk_file_type); +t8_cmesh_t t8_vtk_reader_cmesh (const char *filename, + const int partition, + const int main_proc, + sc_MPI_Comm comm, + const vtk_file_type_t vtk_file_type); + T8_EXTERN_C_END (); From 6d2352cb0db7db59843790784a7cbe5d20cc2f61 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 10 May 2023 16:21:18 +0200 Subject: [PATCH 187/255] Update ref-coord-computation for hexs --- src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.c b/src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.c index bf5d537c57..78c833985e 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.c +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.c @@ -41,7 +41,7 @@ t8_dhex_compute_reference_coords (const t8_dhex_t * elem, /* We divide the integer coordinates by the root length of the hex * to obtain the reference coordinates. */ - out_coords[0] /= (double) T8_DHEX_ROOT_LEN; - out_coords[1] /= (double) T8_DHEX_ROOT_LEN; - out_coords[2] /= (double) T8_DHEX_ROOT_LEN; + out_coords[0] /= (double) P8EST_ROOT_LEN; + out_coords[1] /= (double) P8EST_ROOT_LEN; + out_coords[2] /= (double) P8EST_ROOT_LEN; } From 9cd8e68563bc5a32a62fa5f97cfbce81761d1159 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 10 May 2023 16:32:41 +0200 Subject: [PATCH 188/255] Update quad-ref-coord computation --- .../t8_default/t8_default_hex/t8_dhex_bits.c | 2 +- .../t8_default/t8_default_quad/t8_dquad_bits.c | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.c b/src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.c index 78c833985e..1a7df64381 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.c +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.c @@ -31,7 +31,7 @@ t8_dhex_compute_reference_coords (const t8_dhex_t * elem, const p8est_quadrant_t *q1 = (const p8est_quadrant_t *) elem; /* Get the length of the quadrant */ - const int len = P8EST_QUADRANT_LEN (q1->level); + const p4est_qcoord_t len = P8EST_QUADRANT_LEN (q1->level); /* Compute the x, y and z coordinates of the point depending on the * reference coordinates */ diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_dquad_bits.c b/src/t8_schemes/t8_default/t8_default_quad/t8_dquad_bits.c index 76394ce845..9fe4d199f1 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_dquad_bits.c +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_dquad_bits.c @@ -29,14 +29,12 @@ t8_dquad_compute_reference_coords (const t8_dquad_t * elem, double *out_coords) { const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) elem; - out_coords[0] = q1->x / (double) T8_DQUAD_ROOT_LEN; - out_coords[1] = q1->y / (double) T8_DQUAD_ROOT_LEN; - const double len = - P4EST_QUADRANT_LEN (q1->level) / (double) T8_DQUAD_ROOT_LEN; - out_coords[0] += ref_coords[0] * len; - out_coords[1] += ref_coords[1] * len; + const p4est_qcoord_t h = P4EST_QUADRANT_LEN (q1->level); - out_coords[0] /= (double) T8_DQUAD_ROOT_LEN; - out_coords[1] /= (double) T8_DQUAD_ROOT_LEN; + out_coords[0] = q1->x + ref_coords[0] * h; + out_coords[1] = q1->y + ref_coords[1] * h; + + out_coords[0] /= (double) P4EST_ROOT_LEN; + out_coords[1] /= (double) P4EST_ROOT_LEN; } From 593a3871fff366685ca7d126bd9c8157df702765 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 11 May 2023 09:11:52 +0200 Subject: [PATCH 189/255] fixed foldernaming for build --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index a52f8f115a..593a0a7e48 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,7 +8,7 @@ forestincludedir = $(includedir)/t8_forest geometryincludedir = $(includedir)/t8_geometry geometryimplincludedir = $(geometryincludedir)/t8_geometry_implementations schemesdefaultincludedir = $(includedir)/t8_schemes/t8_default -vtkincludedir = $(includedir)/vtk +vtkincludedir = $(includedir)/t8_vtk defaultcommonincludedir = $(schemesdefaultincludedir)/t8_default_common defaultvertexincludedir = $(schemesdefaultincludedir)/t8_default_vertex defaultlineincludedir = $(schemesdefaultincludedir)/t8_default_line From 4b397c2b18fa48045e03768ae021bb27c1e2e1bf Mon Sep 17 00:00:00 2001 From: David Knapp Date: Thu, 11 May 2023 09:24:28 +0200 Subject: [PATCH 190/255] Update code to latest changes --- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 8 +++--- .../t8_cmesh_vtk_polydata.hxx | 2 +- .../t8_cmesh_vtk_unstructured.cxx | 27 ++++++++++++------- test/Makefile.am | 11 +++++++- test/t8_IO/t8_gtest_vtk_reader.cxx | 2 +- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index b3156603c8..188c542ad0 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -65,21 +65,23 @@ t8_file_to_vtkGrid (const char *filename, SC_CHECK_MPI (mpiret); T8_ASSERT (filename != NULL); T8_ASSERT (0 <= main_proc && main_proc < mpisize); + int read_success = 1; /* Read the file and set the pointer to the */ if (!partition || mpirank == main_proc) { switch (vtk_file_type) { case VTK_UNSTRUCTURED_FILE: - t8_read_unstructured (filename, vtkGrid); + read_success = t8_read_unstructured (filename, vtkGrid); break; case VTK_POLYDATA_FILE: - t8_read_poly (filename, vtkGrid); + read_success = t8_read_poly (filename, vtkGrid); + break; default: vtkGrid = NULL; t8_errorf ("Filetype not supported.\n"); break; } - if (vtkGrid == NULL) { + if (!read_success) { t8_errorf ("Could not read file\n"); if (partition) { main_proc_read_successful = 0; diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx index f3bdb390c1..ef561406c0 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx @@ -46,7 +46,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * \return 0 if the file was read successfully, non-zero otherwise. * */ -void t8_read_poly (const char *filename, vtkDataSet * grid); +int t8_read_poly (const char *filename, vtkDataSet * grid); #endif /* T8_WITH_VTK */ #endif /* T8_CMESH_VTK_POLYDATA */ diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx index d7796a9883..0de1c312ae 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx @@ -28,14 +28,23 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include -void +int t8_read_unstructured (const char *filename, vtkDataSet * grid) { char tmp[BUFSIZ], *extension; - /* Get the file-extension to decide which reader to use */ strcpy (tmp, filename); - extension = strtok (tmp, "."); - extension = strtok (NULL, "."); + extension = strrchr (tmp, '.') + 1; + T8_ASSERT (strcmp (extension, "")); + + /* Check if we can open the file. */ + FILE *first_check; + first_check = fopen (filename, "r"); + if (first_check == NULL) { + t8_errorf ("Can not find the file %s\n", filename); + fclose (first_check); + return 1; + } + fclose (first_check); /* Chose the vtk-Reader according to the file-ending and read the file */ if (strcmp (extension, "vtu") == 0) { @@ -43,13 +52,13 @@ t8_read_unstructured (const char *filename, vtkDataSet * grid) vtkSmartPointer < vtkXMLUnstructuredGridReader >::New (); if (!reader->CanReadFile (filename)) { t8_errorf ("Unable to read file.\n"); - return; + return 1; } reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); t8_debugf ("Finished reading of file.\n"); - return; + return 0; } else if (strcmp (extension, "vtk") == 0) { vtkSmartPointer < vtkUnstructuredGridReader > reader = @@ -58,17 +67,17 @@ t8_read_unstructured (const char *filename, vtkDataSet * grid) reader->Update (); if (!reader->IsFileUnstructuredGrid ()) { t8_errorf ("File-content is not an unstructured Grid. "); - return; + return 1; } grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); t8_debugf ("Finished reading of file.\n"); - return; + return 0; } else { /* Return NULL if the reader is not used correctly */ t8_global_errorf ("Please use .vtk or .vtu file\n"); - return; + return 1; } } #endif diff --git a/test/Makefile.am b/test/Makefile.am index 284508a038..70dfb28bbe 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -39,7 +39,12 @@ t8code_googletest_programs = \ test/t8_forest/t8_gtest_user_data \ test/t8_forest/t8_gtest_transform \ test/t8_forest/t8_gtest_ghost_exchange \ - test/t8_forest/t8_gtest_ghost_and_owner + test/t8_forest/t8_gtest_ghost_and_owner \ + test/t8_IO/t8_gtest_vtk_reader + +test_t8_IO_t8_gtest_vtk_reader_SOURCES = \ + test/t8_gtest_main.cxx \ + test/t8_IO/t8_gtest_vtk_reader.cxx test_t8_gtest_cmesh_bcast_SOURCES = \ test/t8_gtest_main.cxx \ @@ -347,6 +352,9 @@ test_t8_forest_t8_gtest_ghost_and_owner_LDADD = $(t8_gtest_target_ld_add) test_t8_forest_t8_gtest_ghost_and_owner_LDFLAGS = $(t8_gtest_target_ld_flags) test_t8_forest_t8_gtest_ghost_and_owner_CPPFLAGS = $(t8_gtest_target_cpp_flags) +test_t8_IO_t8_gtest_vtk_reader_LDADD = $(t8_gtest_target_ld_add) +test_t8_IO_t8_gtest_vtk_reader_LDFLAGS = $(t8_gtest_target_ld_flags) +test_t8_IO_t8_gtest_vtk_reader_CPPFLAGS = $(t8_gtest_target_cpp_flags) # If we did not configure t8code with MPI we need to build Googletest # without MPI support. @@ -388,6 +396,7 @@ test_t8_forest_t8_gtest_user_data_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_forest_t8_gtest_transform_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_forest_t8_gtest_ghost_exchange_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_forest_t8_gtest_ghost_and_owner_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) +test_t8_IO_t8_gtest_vtk_reader_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) endif # Build Googletest library diff --git a/test/t8_IO/t8_gtest_vtk_reader.cxx b/test/t8_IO/t8_gtest_vtk_reader.cxx index 7419a007da..a3b6a2d475 100644 --- a/test/t8_IO/t8_gtest_vtk_reader.cxx +++ b/test/t8_IO/t8_gtest_vtk_reader.cxx @@ -32,9 +32,9 @@ along with t8code; if not, write to the Free Software Foundation, Inc., TEST (t8_cmesh_vtk_reader, dummy_test) { #if T8_WITH_VTK -#else t8_cmesh_t cmesh = t8_cmesh_vtk_reader (NULL, 0, 0, sc_MPI_COMM_WORLD, VTK_FILE_ERROR); EXPECT_TRUE (cmesh == NULL); +#else #endif } From 2723b375818cd360164876ea54cc2818bedc38b7 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Thu, 11 May 2023 09:39:40 +0200 Subject: [PATCH 191/255] hotfix of t8_vtk.m4 after merge with main --- config/t8_vtk.m4 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/t8_vtk.m4 b/config/t8_vtk.m4 index e3abb32506..d3ef812005 100644 --- a/config/t8_vtk.m4 +++ b/config/t8_vtk.m4 @@ -30,11 +30,11 @@ T8_ARG_WITH([vtk], AC_DEFINE_UNQUOTED([VTK_VERSION_USED], "$t8_vtk_version", [VTK version t8code is linked against]) ]) - T8_VTK_LIBS="-lvtkIOXML-$t8_vtk_version -lvtkCommonExecutionModel-$t8_vtk_version \ --lvtkCommonDataModel-$t8_vtk_version -lvtkIOXMLParser-$t8_vtk_version \ --lvtkIOParallelXML-$t8_vtk_version -lvtkParallelMPI-$t8_vtk_version -lvtkIOPLY-$t8_vtk_version \ --lvtkCommonCore-$t8_vtk_version -lvtkzlib-$t8_vtk_version -lvtksys-$t8_vtk_version \ --lvtkIOGeometry-$t8_vtk_version -lvtkIOMovie-$t8_vtk_version" + T8_VTK_LIBS="-lvtkIOXML-$t8_vtk_version -lvtkCommonExecutionModel-$t8_vtk_version \ + -lvtkCommonDataModel-$t8_vtk_version -lvtkIOGeometry-$t8_vtk_version -lvtkIOXMLParser-$t8_vtk_version \ + -lvtkIOParallelXML-$t8_vtk_version -lvtkIOPLY-$t8_vtk_version -lvtkParallelMPI-$t8_vtk_version \ + -lvtkFiltersCore-$t8_vtk_version -lvtksys-$t8_vtk_version \ + -lvtkCommonCore-$t8_vtk_version -lvtkzlib-$t8_vtk_version -lvtkIOLegacy-$t8_vtk_version" if test "x$T8_WITH_VTK" != xyes ; then T8_VTK_LIBS="$T8_WITH_VTK" dnl AC_MSG_ERROR([Please provide --with-vtk without arguments]) From b12b17b167664f4e9bca5ffc9632c8d5c0e07713 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Thu, 11 May 2023 11:28:22 +0200 Subject: [PATCH 192/255] update vtk-libs and update cmesh_vtk_reader --- config/t8_vtk.m4 | 10 ++++---- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 9 ++++---- .../t8_cmesh_vtk_polydata.cxx | 23 +++++++++---------- .../t8_cmesh_vtk_polydata.hxx | 2 +- .../t8_cmesh_vtk_unstructured.cxx | 13 +++++------ .../t8_cmesh_vtk_unstructured.hxx | 3 ++- test/t8_IO/t8_gtest_vtk_reader.cxx | 13 ++++++++++- 7 files changed, 42 insertions(+), 31 deletions(-) diff --git a/config/t8_vtk.m4 b/config/t8_vtk.m4 index e3abb32506..d3ef812005 100644 --- a/config/t8_vtk.m4 +++ b/config/t8_vtk.m4 @@ -30,11 +30,11 @@ T8_ARG_WITH([vtk], AC_DEFINE_UNQUOTED([VTK_VERSION_USED], "$t8_vtk_version", [VTK version t8code is linked against]) ]) - T8_VTK_LIBS="-lvtkIOXML-$t8_vtk_version -lvtkCommonExecutionModel-$t8_vtk_version \ --lvtkCommonDataModel-$t8_vtk_version -lvtkIOXMLParser-$t8_vtk_version \ --lvtkIOParallelXML-$t8_vtk_version -lvtkParallelMPI-$t8_vtk_version -lvtkIOPLY-$t8_vtk_version \ --lvtkCommonCore-$t8_vtk_version -lvtkzlib-$t8_vtk_version -lvtksys-$t8_vtk_version \ --lvtkIOGeometry-$t8_vtk_version -lvtkIOMovie-$t8_vtk_version" + T8_VTK_LIBS="-lvtkIOXML-$t8_vtk_version -lvtkCommonExecutionModel-$t8_vtk_version \ + -lvtkCommonDataModel-$t8_vtk_version -lvtkIOGeometry-$t8_vtk_version -lvtkIOXMLParser-$t8_vtk_version \ + -lvtkIOParallelXML-$t8_vtk_version -lvtkIOPLY-$t8_vtk_version -lvtkParallelMPI-$t8_vtk_version \ + -lvtkFiltersCore-$t8_vtk_version -lvtksys-$t8_vtk_version \ + -lvtkCommonCore-$t8_vtk_version -lvtkzlib-$t8_vtk_version -lvtkIOLegacy-$t8_vtk_version" if test "x$T8_WITH_VTK" != xyes ; then T8_VTK_LIBS="$T8_WITH_VTK" dnl AC_MSG_ERROR([Please provide --with-vtk without arguments]) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index 188c542ad0..48ab95bada 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -47,7 +47,7 @@ T8_EXTERN_C_BEGIN (); * \param[in] main_proc The main reading proc. * \param[in] comm A communicator. * \param[in] vtk_file_type The type of the Data in the file. - * \return 0 if the file was read successfully, 1 otherwise. + * \returns non-zero on success, zero if the reading failed. */ int t8_file_to_vtkGrid (const char *filename, @@ -65,7 +65,7 @@ t8_file_to_vtkGrid (const char *filename, SC_CHECK_MPI (mpiret); T8_ASSERT (filename != NULL); T8_ASSERT (0 <= main_proc && main_proc < mpisize); - int read_success = 1; + int read_success = 0; /* Read the file and set the pointer to the */ if (!partition || mpirank == main_proc) { @@ -89,7 +89,9 @@ t8_file_to_vtkGrid (const char *filename, comm); } } - main_proc_read_successful = 1; + else { + main_proc_read_successful = 1; + } } if (partition) { sc_MPI_Bcast (&main_proc_read_successful, 1, sc_MPI_INT, main_proc, comm); @@ -129,7 +131,6 @@ t8_cmesh_vtk_reader (const char *filename, const int partition, t8_global_errorf ("Main process (Rank %i) did not read the file successfully.\n", main_proc); - t8_cmesh_destroy (&cmesh); return NULL; } else { diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx index 2b6643cb8a..5622e677b6 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.cxx @@ -47,8 +47,7 @@ t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) first_check = fopen (filename, "r"); if (first_check == NULL) { t8_errorf ("Can not find the file %s\n", filename); - fclose (first_check); - return 1; + return 0; } fclose (first_check); @@ -59,32 +58,32 @@ t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (reader->GetOutput ()); - return 0; + return 1; } else if (strcmp (extension, "vtp") == 0) { vtkNew < vtkXMLPolyDataReader > reader; reader->SetFileName (filename); if (!reader->CanReadFile (filename)) { t8_errorf ("Unable to read file %s.\n", filename); - return 1; + return 0; } reader->Update (); grid->ShallowCopy (reader->GetOutput ()); - return 0; + return 1; } else if (strcmp (extension, "obj") == 0) { vtkNew < vtkOBJReader > reader; reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (reader->GetOutput ()); - return 0; + return 1; } else if (strcmp (extension, "stl") == 0) { vtkNew < vtkSTLReader > reader; reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (reader->GetOutput ()); - return 0; + return 1; } else if (strcmp (extension, "vtk") == 0) { vtkNew < vtkPolyDataReader > reader; @@ -93,10 +92,10 @@ t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) if (!reader->IsFilePolyData ()) { t8_errorf ("File-content is not polydata. If it is a vtkUnstructuredGrid use the unstructured Grid reader."); - return 1; + return 0; } grid->ShallowCopy (reader->GetOutput ()); - return 0; + return 1; } else if (strcmp (extension, "g") == 0) { vtkNew < vtkBYUReader > reader; @@ -104,12 +103,12 @@ t8_read_poly_ext (const char *filename, vtkSmartPointer < vtkPolyData > grid) reader->Update (); grid->ShallowCopy (reader->GetOutput ()); - return 0; + return 1; } else { /* Return NULL if the reader is not used correctly. */ t8_global_errorf ("Please use .ply, .vtp, .obj, .stl, .vtk or .g file\n"); - return 1; + return 0; } } @@ -136,6 +135,6 @@ t8_read_poly (const char *filename, vtkDataSet * grid) tri_filter->PassLinesOn (); tri_filter->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (tri_filter->GetOutput ())); - return 0; + return 1; } #endif /* T8_WITH_VTK */ diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx index ef561406c0..708d2c1e1b 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_polydata.hxx @@ -43,7 +43,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * \param[in] filename The name of the file * \param[in, out] grid On input a vtkSmartPointer, that will hold the grid described in * \a filename. - * \return 0 if the file was read successfully, non-zero otherwise. + * \returns non-zero on success, zero if the reading failed. * */ int t8_read_poly (const char *filename, vtkDataSet * grid); diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx index 0de1c312ae..8ceffbac0d 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx @@ -41,8 +41,7 @@ t8_read_unstructured (const char *filename, vtkDataSet * grid) first_check = fopen (filename, "r"); if (first_check == NULL) { t8_errorf ("Can not find the file %s\n", filename); - fclose (first_check); - return 1; + return 0; } fclose (first_check); @@ -52,13 +51,13 @@ t8_read_unstructured (const char *filename, vtkDataSet * grid) vtkSmartPointer < vtkXMLUnstructuredGridReader >::New (); if (!reader->CanReadFile (filename)) { t8_errorf ("Unable to read file.\n"); - return 1; + return 0; } reader->SetFileName (filename); reader->Update (); grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); t8_debugf ("Finished reading of file.\n"); - return 0; + return 1; } else if (strcmp (extension, "vtk") == 0) { vtkSmartPointer < vtkUnstructuredGridReader > reader = @@ -67,17 +66,17 @@ t8_read_unstructured (const char *filename, vtkDataSet * grid) reader->Update (); if (!reader->IsFileUnstructuredGrid ()) { t8_errorf ("File-content is not an unstructured Grid. "); - return 1; + return 0; } grid->ShallowCopy (vtkDataSet::SafeDownCast (reader->GetOutput ())); t8_debugf ("Finished reading of file.\n"); - return 0; + return 1; } else { /* Return NULL if the reader is not used correctly */ t8_global_errorf ("Please use .vtk or .vtu file\n"); - return 1; + return 0; } } #endif diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx index b8aec6f1d6..74143cbd39 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx @@ -38,7 +38,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * * \param[in] filename The name of the file * \param[in, out] grid On input a vtkSmartPointer, that will hold the grid described in - * \a filename. + * \a filename. + * \returns non-zero on success, zero if the reading failed. */ int t8_read_unstructured (const char *filename, vtkDataSet * grid); diff --git a/test/t8_IO/t8_gtest_vtk_reader.cxx b/test/t8_IO/t8_gtest_vtk_reader.cxx index a3b6a2d475..c5a0dbab37 100644 --- a/test/t8_IO/t8_gtest_vtk_reader.cxx +++ b/test/t8_IO/t8_gtest_vtk_reader.cxx @@ -33,7 +33,18 @@ TEST (t8_cmesh_vtk_reader, dummy_test) { #if T8_WITH_VTK t8_cmesh_t cmesh = - t8_cmesh_vtk_reader (NULL, 0, 0, sc_MPI_COMM_WORLD, VTK_FILE_ERROR); + t8_cmesh_vtk_reader ("non-existing-file.vtu", 0, 0, sc_MPI_COMM_WORLD, + VTK_FILE_ERROR); + EXPECT_TRUE (cmesh == NULL); + + cmesh = + t8_cmesh_vtk_reader ("non-existing-file.vtu", 0, 0, sc_MPI_COMM_WORLD, + VTK_UNSTRUCTURED_FILE); + EXPECT_TRUE (cmesh == NULL); + + cmesh = + t8_cmesh_vtk_reader ("non-existing-file.vtp", 0, 0, sc_MPI_COMM_WORLD, + VTK_POLYDATA_FILE); EXPECT_TRUE (cmesh == NULL); #else #endif From df9239b712a5e9d2ac190d0cab4b1ff850e35052 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Thu, 11 May 2023 13:34:17 +0200 Subject: [PATCH 193/255] Remove a t8_dtri_is_valid assertion, that gets called with a pyramid-descendant --- src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c index d3eac86179..8186997d41 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_dtri_bits.c @@ -403,7 +403,6 @@ t8_dtri_compute_reference_coords (const t8_dtri_t *elem, * z--> x */ T8_ASSERT (ref_coords != NULL); - T8_ASSERT (t8_dtri_is_valid (elem)); t8_dtri_type_t type; t8_dtri_coord_t h; From bf38d6331f7c3a7f4a3315505799fce8caaa13ca Mon Sep 17 00:00:00 2001 From: David Knapp Date: Thu, 11 May 2023 14:06:06 +0200 Subject: [PATCH 194/255] Update comment --- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index 48ab95bada..239f65983a 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -67,7 +67,7 @@ t8_file_to_vtkGrid (const char *filename, T8_ASSERT (0 <= main_proc && main_proc < mpisize); int read_success = 0; - /* Read the file and set the pointer to the */ + /* Read the file and fill the vtkDataSet pointer. */ if (!partition || mpirank == main_proc) { switch (vtk_file_type) { case VTK_UNSTRUCTURED_FILE: From 94ac60e3982005ce9536fffcb98f9c30fcdd5c70 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Thu, 11 May 2023 18:08:12 +0200 Subject: [PATCH 195/255] Improve vtk-reader testing --- configure.ac | 2 ++ test/t8_IO/t8_gtest_vtk_reader.cxx | 12 ++++++++++++ test/testfiles/test_vtk_cube.vtp | Bin 0 -> 5231 bytes test/testfiles/test_vtk_tri.vtu | Bin 0 -> 11092 bytes 4 files changed, 14 insertions(+) create mode 100644 test/testfiles/test_vtk_cube.vtp create mode 100644 test/testfiles/test_vtk_tri.vtu diff --git a/configure.ac b/configure.ac index 692acbaa82..c3d14cbb65 100644 --- a/configure.ac +++ b/configure.ac @@ -80,6 +80,8 @@ AC_CONFIG_LINKS([test/testfiles/test_msh_file_vers2_ascii.msh:test/testfiles/tes AC_CONFIG_LINKS([test/testfiles/test_msh_file_vers2_bin.msh:test/testfiles/test_msh_file_vers2_bin.msh]) AC_CONFIG_LINKS([test/testfiles/test_msh_file_vers4_ascii.msh:test/testfiles/test_msh_file_vers4_ascii.msh]) AC_CONFIG_LINKS([test/testfiles/test_msh_file_vers4_bin.msh:test/testfiles/test_msh_file_vers4_bin.msh]) +AC_CONFIG_LINKS([test/testfiles/test_vtk_tri.vtu:test/testfiles/test_vtk_tri.vtu]) +AC_CONFIG_LINKS([test/testfiles/test_vtk_cube.vtp:test/testfiles/test_vtk_cube.vtp]) AC_CONFIG_LINKS([example/IO/cmesh/gmsh/circlesquare_hybrid_hole.msh:example/IO/cmesh/gmsh/circlesquare_hybrid_hole.msh]) AC_CONFIG_FILES([tutorials/features/t8_features_curved_meshes_generate_cmesh.geo:tutorials/features/t8_features_curved_meshes_generate_cmesh.geo]) AC_CONFIG_FILES([tutorials/features/t8_features_curved_meshes_generate_cmesh_2d.geo:tutorials/features/t8_features_curved_meshes_generate_cmesh_2d.geo]) diff --git a/test/t8_IO/t8_gtest_vtk_reader.cxx b/test/t8_IO/t8_gtest_vtk_reader.cxx index c5a0dbab37..761207acdc 100644 --- a/test/t8_IO/t8_gtest_vtk_reader.cxx +++ b/test/t8_IO/t8_gtest_vtk_reader.cxx @@ -46,6 +46,18 @@ TEST (t8_cmesh_vtk_reader, dummy_test) t8_cmesh_vtk_reader ("non-existing-file.vtp", 0, 0, sc_MPI_COMM_WORLD, VTK_POLYDATA_FILE); EXPECT_TRUE (cmesh == NULL); + + cmesh = + t8_cmesh_vtk_reader ("test/testfiles/test_vtk_tri.vtu", 0, 0, + sc_MPI_COMM_WORLD, VTK_UNSTRUCTURED_FILE); + EXPECT_FALSE (cmesh == NULL); + t8_cmesh_destroy (&cmesh); + cmesh = + t8_cmesh_vtk_reader ("test/testfiles/test_vtk_cube.vtp", 0, 0, + sc_MPI_COMM_WORLD, VTK_POLYDATA_FILE); + EXPECT_FALSE (cmesh == NULL); + t8_cmesh_destroy (&cmesh); + #else #endif } diff --git a/test/testfiles/test_vtk_cube.vtp b/test/testfiles/test_vtk_cube.vtp new file mode 100644 index 0000000000000000000000000000000000000000..5d4874f62a1dfbd2966d54fe492980440f25b0f7 GIT binary patch literal 5231 zcmds5Sx?(Q5Kiwlz3)D*_6K0+AOy()AqrIl1VkyXkx4dS)v+VT(B>`wto*d@?9Mow zVB%CN)apvBZ+2!pJ2RQR;v66CY_S9CFAN&Iv}AL3GKxhz zjJhIf@LeyCeX$jEJvZR&Ot_NU)}McC263&**NTieWC{i_^h8In)_MO#MEkvi&hKftN4mo12FzUO$`~V5g zjy6M?B*{TSWkUPzz$Y6~~7w=XlF*r2#J!~P%)gi2F|vmQ(qH@G_( zh@dOFoE^Hsso3-2CrWb|Ca6#)^vcT`T4Q`mq9yL^1DqkkyXA_@W~1{%U2fpyz)&gK(l<8 zs-+Xaa&b0=?@uwT zD;#}v(HFA3lGT#Fv1@&~&EwH$E{u$Q-CnBKYIb?KYFAe3$sVuwec0F2<+L!Wxn3A% zXjx^Qy~j^wBFkL~Vc*W_2K_EJ@cj3jO`6ohB>vZrd zoD_b#oC<$sRUSCA&05q;ZDn|q4%Y3IBQJ4KUUJ~xOa40Qf=i>keYFR zG0V$asN|BJ;-Qgb^=j3nE3Y*0%!UEnZuDDTjW+Pv2$vNmf=<}=g3|_%+#mYA)Mj@I z*v7wzDiju?*A4vzXwY8BuIa}DcE^U!&CPKMrl*=YFVNHrW386ND#uDD<5J&%96RVJ zJDP6_XJR}p}#_N;cyCCPg($|qk2s%JhhcWR8O&QUEAfN3d zCq9gUo<-sTpZY8h#?(QFXh0eR5)FLlCXZyqGf}E8-Y#cUX<6Mv{$0fThz}7TAwEES zj95f`iueTa8RB!qmxwPAUm?Che2e%R@g3rO#E*y{5N$;All-B1$v)Zng!*dhF?XA_ NqP)=PKN;7GzX1V_Vr2jT literal 0 HcmV?d00001 diff --git a/test/testfiles/test_vtk_tri.vtu b/test/testfiles/test_vtk_tri.vtu new file mode 100644 index 0000000000000000000000000000000000000000..0e082f285bf5ff895d0710364814ea23d70df1a7 GIT binary patch literal 11092 zcmds-X>1&49mY3p(jz^R-bZ?Dw^!P<@!D~0r(Gvw5<7Jc$K;|d1!rTAlO^`9yWS)X z6=+cr1q5mZ0*XMeT%v-4KtK@{5lbsj5fumo0)apaR7D^V6%hyo0^a}Z^UJ<@eZ>91 zmyR@f{?D;9@60nhn-9+I-Mw|7FcGIK$EM=m%%0+OrF?j_a=09iZ7vtaGU+36dAd+4 z_Ga2wXEW*j$13qisXP{!do$Y#mC8iiUmPpsi<$JnIPcUE9cHjt>FUg^Uz$$m!b6(q z>Vsg3c(gbQ_K-Acl(d00EJ9coj)l1Fix z(Y|sye@vG-Fj2}^)^udjL-|Q})td^_m3(nD-d)-l7b|f&lO8XXC-arwOnz!AE{?_S zKJ3gF55(IG?ncaVa<`bKpMR(~)4e*|-Jb30?rG0@7gHJ^pN`!TXZ^Id)V7mr^~96f z?CT#cO&lwhCJXtA`B&~O$Gd&4mCt(f)2zI6ox5S-<}GsO%5!Zq%E(!Veml9g8A|hE z@Q!@i%eRNem8pkmV`*}#RCGrYQO&6oL`J-Zc_5CILT&tVKv{UdR>i{ip6-eQaDnm9Gm~~ZauO* z2ZpUL{OmrDcSmRE%;&p}HJ@&k&7-)l<$Ukb*%z?T1$K9=o%u?dZ-IN#i!EUo6>#{?cV0vX8Xm=_34+$-VEuuI9eJj6c6-f%K4+sukFZ- zi&Dv!9r$e&zw|=1@`s}=RJj=QB zZE$PYU})TQ^SKUNpPko^XE}#%OE7Bc<~Of*p~tm#EOfngeG9!0cHb6yf9Zq!$MqV9 zz0vh-*PTk$-TE4CPxYlz%iW%Kd)DoCzaqC+-ClEh-R%vxhq=gQBd1s0UUPfh?G3lj zmK%22h359T>_U!bxhc1w?!4rxE<4}){M-PDM zXSv!d$UWKj)DpMi85_@iVni)F^5&{H*Sxvz%?)o(xplGG{b94~@;AH6Yu;S<=7u-h8Y0JSvo$c=ePA}P8ri?i`@o!vTDoP?4Vi1+ zT=(XNH`^M>CtWztHd_O_@mgg6I?de&=2X<0BX6#Hvt@0!tsb@JhBw<9$k-Z~Z4JzP z-q6-icb`u-hs=>TSG~FB&6c&@wno&NZ4KzQ24-6WGoLZEHQ48q%^`E-%~fx%d2`*H z8{TYdFm9Wzf!Wr;oS2T=W^1s|BwOVE)f{^vd-{5kY9q~pUcm_t8PIzIfuIrPQS@!`wn(D@0%hc8z? z)X$QR55H&*{cP#@aBgF$pQAiJ{E|8JbEV_MFP%eQDjgqwS)kJ=JzXvzeua3b(-S`Y zO65bHp77yUDIehy#UzgGEBrzd>)b;^f2J>kQz zS3cC~5g(pb9-ZFk;|BTgjCiQi2R{5ps3WQu$D)4}AD-%7;3A;KOfMKGf6F@!_iio!;o<4*Bpq#Y3Gw@ZqbK4|V#$ zhqoyo>hysR&nh44^nnj=S3cC~10UX@e5lh0K75Vxp-vz8@J{7Jou2UFYn2amdc=o! zDUVKX^wBLJ-Xk9B^nnjwr+lc>2R{5Rwd>hysR?^Qn3=>s3W zUina`4}ACr5V>KBOks|Jk;p}AHGTXP^S-kc)#+YP9OO2 z0p&xTKJek2l@E3Lz=z+Xe5lh0K73I5P^S-k_!i|uJ(7+O-#Uj*kNEIy%A?a8eQcKx z9}*9B`oM?pP(IY@10O!De5lh0KK!-HhdO=W!*?nl>hysR-=%!0(+56$xALJ*Px$aX z%7;3A;KTPSAL{go4}YEV==4S(_sWOgCm!nbfe*i5`B0}1eE92?4|V#$hd-cvsM7~N z{0+*7I(^{7->7`3(+56$MEOvs4}ADOs1= zp?s**BR+gmd31WCkD`2dNj%i)10O!6e5lh0KKw!DL!CbG;brARoj&m4)5?cBec;0@ z%7;2V;lmFrAL{gh4?m)OsM7~N{HXGwPLKHThm=Q;&T0y0N*7I?D}KIknebxaWx^|k zD}>hxZxG%jyj6I+@J?Y?xJK9|Tqn#4HwgLvLcjPu!mUDnS9qWE9_9VTdxr1#K7Eeo zoac_dxz9YWJSX(S{d`!*d8_bk!nX?_6~0^eUg6`y_X|HL{IKw&!jB6-Dg2D^N#W;( zUle{>_*LQ8h0h3&3+uw?gx?i@PxylHhr%BVe=7XB@R!103x6YgQTTh|ABBGwzAQW; z{JZd=E8A zTrcbsZW3-5ZV_%54hwe)_X_V5J|G+s?ia?wgTh0?qVPdsMR-*BX5m|eRpBGTcL?7l ze2?%k;roOi5I!ONi11^=PY6FP{H*YE!Y>HFB>al-Y2i17-xPjJ_^j|d!smtG7ydx_ zBjHbkKNJ2!_$y&U_&ecC!aoTAB>ao;ufo3x{~`RB@IS&uXEdMF#lo|NONAE*mkTcu zUM{>!c#ZISVMchfaHVjSaJ8^q*eUE5-X-i6M#7E40pXx Date: Fri, 12 May 2023 11:22:48 +0200 Subject: [PATCH 196/255] More static functions --- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index 4db948e16d..56f73b970d 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -58,7 +58,7 @@ T8_EXTERN_C_BEGIN (); * \param[in, out] tree_vertices The vertices of a tree * \param[in] eclass The eclass of the tree. */ -void +static void t8_cmesh_correct_volume (double *tree_vertices, t8_eclass_t eclass) { /* The \param described is negative. We need to change vertices. From ba2bc0da46771d6d0dfc1c6d5fa6b25a9b613430 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 12 May 2023 11:23:29 +0200 Subject: [PATCH 197/255] Add option to set a prefix for the output-file --- .../IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx b/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx index cf83768592..e2e4d64bec 100644 --- a/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx +++ b/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx @@ -37,7 +37,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., void t8_forest_construct_from_vtk (const char *prefix, sc_MPI_Comm comm, const int values_per_cell, const int partition, - vtk_file_type_t vtk_file_type) + vtk_file_type_t vtk_file_type, + const char *out_prefix) { /* Read a poly-data file (.ply, .vtp, .obj, .stl, .vtk, .g) and construct a cmesh * representing the mesh. If there is any cell-data, it will be read too. @@ -48,20 +49,23 @@ t8_forest_construct_from_vtk (const char *prefix, sc_MPI_Comm comm, t8_errorf ("Error reading file.\n"); return; } + char out_file[BUFSIZ]; + snprintf (out_file, BUFSIZ - 9, "%s_cmesh_in", out_prefix); + t8_cmesh_vtk_write_file (cmesh_in, out_file, 1.0); t8_cmesh_t cmesh; - t8_cmesh_vtk_write_file (cmesh_in, "t8_cmesh_in", 1.0); + if (partition) { t8_cmesh_init (&cmesh); t8_cmesh_set_derive (cmesh, cmesh_in); t8_cmesh_set_partition_uniform (cmesh, 0, t8_scheme_new_default_cxx ()); t8_cmesh_commit (cmesh, comm); + snprintf (out_file, BUFSIZ - 16, "%s_cmesh_partition", out_prefix); + t8_cmesh_vtk_write_file (cmesh, out_file, 1.0); } else { cmesh = cmesh_in; } - t8_cmesh_vtk_write_file (cmesh, "t8_cmesh_", 1.0); - t8_forest_t forest; /* Initialize the forest */ t8_forest_init (&forest); @@ -103,7 +107,9 @@ t8_forest_construct_from_vtk (const char *prefix, sc_MPI_Comm comm, } /* Write the forest */ - t8_forest_write_vtk_ext (forest, "forest", 1, 1, 1, 1, 1, 0, 1, + snprintf (out_file, BUFSIZ - 7, "%s_forest", out_prefix); + t8_cmesh_vtk_write_file (cmesh_in, out_file, 1.0); + t8_forest_write_vtk_ext (forest, out_file, 1, 1, 1, 1, 1, 0, 1, values_per_cell, vtk_data); /* Free the cell-data */ @@ -122,6 +128,7 @@ main (int argc, char **argv) { int mpiret, helpme = 0, parsed, num_keys; const char *vtk_file; + const char *out_file; sc_options_t *opt; char usage[BUFSIZ], help[BUFSIZ]; int sreturn; @@ -151,6 +158,8 @@ main (int argc, char **argv) "Display a short help message."); sc_options_add_string (opt, 'f', "vtk-file", &vtk_file, "", "The prefix of the .vtk file."); + sc_options_add_string (opt, 'o', "output", &out_file, "output", + "The prefix of the output-file."); sc_options_add_int (opt, 'c', "num_cell_values", &num_keys, 0, "Number of values per cell stored in the vtk-file."); sc_options_add_int (opt, 't', "type_of_file", &vtk_file_type, -1, @@ -170,7 +179,8 @@ main (int argc, char **argv) } else { t8_forest_construct_from_vtk (vtk_file, sc_MPI_COMM_WORLD, num_keys, - partition, (vtk_file_type_t) vtk_file_type); + partition, (vtk_file_type_t) vtk_file_type, + out_file); } sc_options_destroy (opt); sc_finalize (); From 57c8466b43b5220719e3fe7df3132387c5001787 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 12 May 2023 11:29:50 +0200 Subject: [PATCH 198/255] More static functions --- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index 56f73b970d..e82fb96dcb 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -170,7 +170,7 @@ t8_file_to_vtkGrid (const char *filename, * \param[in] vtkGrid The vtkDataSet * \return The dimension of \a vtkGrid. */ -int +static int t8_get_dimension (vtkSmartPointer < vtkDataSet > vtkGrid) { /* This array contains the type of each cell */ @@ -208,7 +208,7 @@ t8_get_dimension (vtkSmartPointer < vtkDataSet > vtkGrid) * \return The number of elements that have been read by the process. */ -t8_gloidx_t +static t8_gloidx_t t8_vtk_iterate_cells (vtkSmartPointer < vtkDataSet > vtkGrid, t8_cmesh_t cmesh, sc_MPI_Comm comm) { From dbd8605f42b92a77798aed5c8fb5d7452736cb0d Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 12 May 2023 11:36:26 +0200 Subject: [PATCH 199/255] remove copy-paste-error --- example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx b/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx index e2e4d64bec..2236c9e13d 100644 --- a/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx +++ b/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx @@ -108,7 +108,6 @@ t8_forest_construct_from_vtk (const char *prefix, sc_MPI_Comm comm, /* Write the forest */ snprintf (out_file, BUFSIZ - 7, "%s_forest", out_prefix); - t8_cmesh_vtk_write_file (cmesh_in, out_file, 1.0); t8_forest_write_vtk_ext (forest, out_file, 1, 1, 1, 1, 1, 0, 1, values_per_cell, vtk_data); From 88e661dfccca1be93612b5c3fca9e5daef6ccfeb Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 12 May 2023 11:53:33 +0200 Subject: [PATCH 200/255] Elaborate comment --- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index e82fb96dcb..f9c1365344 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -358,7 +358,8 @@ t8_vtkGrid_to_cmesh (vtkSmartPointer < vtkDataSet > vtkGrid, t8_debugf ("[D] dim: %i\n", dim); /* Communicate the number of trees to all processes. * TODO: This probably crashes when a vtkGrid is distributed in many - * files. */ + * files. Replace with an sc_MPI_Reduce and compute the ranges per Process + * properly. */ sc_MPI_Bcast (&num_trees, 1, T8_MPI_GLOIDX, main_proc, comm); t8_cmesh_set_dimension (cmesh, dim); /* Build the partition. */ From ee50620e7aca49b2f4aec3a055ec079760d4dda4 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 12 May 2023 12:00:26 +0200 Subject: [PATCH 201/255] Update t8_cmesh_correct_volume --- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index f9c1365344..9a4c4d9427 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -58,7 +58,7 @@ T8_EXTERN_C_BEGIN (); * \param[in, out] tree_vertices The vertices of a tree * \param[in] eclass The eclass of the tree. */ -static void +void t8_cmesh_correct_volume (double *tree_vertices, t8_eclass_t eclass) { /* The \param described is negative. We need to change vertices. From 24675b176ff1d402e0678d97eb450026c6ec3e21 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 12 May 2023 15:57:18 +0200 Subject: [PATCH 202/255] Implementation of a shmem_allgatherv --- src/t8_data/t8_shmem.c | 128 +++++++++++++++++++++++++++++++++++++++++ src/t8_data/t8_shmem.h | 26 +++++++++ 2 files changed, 154 insertions(+) diff --git a/src/t8_data/t8_shmem.c b/src/t8_data/t8_shmem.c index 1b7918e3f0..fd2e71808e 100644 --- a/src/t8_data/t8_shmem.c +++ b/src/t8_data/t8_shmem.c @@ -218,6 +218,134 @@ t8_shmem_array_allgather (const void *sendbuf, int sendcount, recvcount, recvtype, recvarray->comm); } +static void +t8_shmem_array_allgatherv_common (const void *sendbuf, + int sendcount, + sc_MPI_Datatype sendtype, + t8_shmem_array_t recvarray, + sc_MPI_Datatype recvtype, + sc_MPI_Comm comm, sc_MPI_Comm intranode, + sc_MPI_Comm internode) +{ + size_t typesize; + int mpiret, intrarank, intrasize, intersize; + char *noderecvchar = NULL; + + typesize = sc_mpi_sizeof (recvtype); + + mpiret = sc_MPI_Comm_rank (intranode, &intrarank); + SC_CHECK_MPI (mpiret); + mpiret = sc_MPI_Comm_size (intranode, &intrasize); + SC_CHECK_MPI (mpiret); + mpiret = sc_MPI_Comm_size (internode, &intersize); + SC_CHECK_MPI (mpiret); + + /* node root gathers from node */ + int *intra_displ = T8_ALLOC_ZERO (int, intrasize); + int *intra_recvcounts = T8_ALLOC_ZERO (int, intrasize); + + sc_MPI_Allgather ((void *) &sendcount, 1, sc_MPI_INT, intra_recvcounts, + intrasize, sc_MPI_INT, intranode); + SC_CHECK_MPI (mpiret); + int intra_recv_total = intra_recvcounts[0]; + for (int i = 1; i < intersize; i++) { + intra_displ[i] = intra_displ[i - 1] + intra_recvcounts[i - 1]; + intra_recv_total += intra_recvcounts[i]; + } + if (!intrarank) { + noderecvchar = SC_ALLOC (char, intra_recv_total * typesize); + } + mpiret = + sc_MPI_Gatherv (sendbuf, sendcount, sendtype, noderecvchar, + intra_recvcounts, intra_displ, recvtype, 0, intranode); + SC_CHECK_MPI (mpiret); + + int *inter_displ = T8_ALLOC_ZERO (int, intersize); + int *inter_recvcount = T8_ALLOC_ZERO (int, intersize); + + sc_MPI_Allgather ((void *) &intra_recv_total, 1, sc_MPI_INT, + inter_recvcount, intersize, sc_MPI_INT, internode); + SC_CHECK_MPI (mpiret); + for (int i = 1; i < intersize; i++) { + inter_displ[i] = inter_displ[i - 1] + inter_recvcount[i - 1]; + } + + /* node root allgathers between nodes */ + if (sc_shmem_write_start (recvarray->array, comm)) { + mpiret = + sc_MPI_Allgatherv (noderecvchar, intra_recv_total, sendtype, + recvarray->array, inter_recvcount, inter_displ, + recvtype, internode); + SC_CHECK_MPI (mpiret); + SC_FREE (noderecvchar); + } + sc_shmem_write_end (recvarray->array, comm); + T8_FREE (inter_displ); + T8_FREE (inter_recvcount); + T8_FREE (intra_displ); + T8_FREE (intra_recvcounts); +} + +void +t8_shmem_array_allgatherv (const void *sendbuf, + int sendcount, + sc_MPI_Datatype + sendtype, + t8_shmem_array_t + recvarray, + sc_MPI_Datatype recvtype, sc_MPI_Comm comm) +{ + T8_ASSERT (t8_shmem_array_is_initialized (recvarray)); + T8_ASSERT (!t8_shmem_array_is_writing_possible (recvarray)); + sc_shmem_type_t type; + sc_MPI_Comm intranode = sc_MPI_COMM_NULL, internode = + sc_MPI_COMM_NULL; + + type = sc_shmem_get_type (comm); + sc_mpi_comm_get_node_comms (comm, &intranode, &internode); + if (intranode == sc_MPI_COMM_NULL || internode == sc_MPI_COMM_NULL) { + type = SC_SHMEM_BASIC; + } + switch (type) { + case SC_SHMEM_BASIC: + case SC_SHMEM_PRESCAN: + int mpi_size; + int mpiret = sc_MPI_Comm_size (comm, &mpi_size); + SC_CHECK_MPI (mpiret); + int *displ = T8_ALLOC_ZERO (int, mpi_size); + int *recvcounts = T8_ALLOC_ZERO (int, mpi_size); + + mpiret = sc_MPI_Allgather ((void *) &sendcount, 1, sc_MPI_INT, recvcounts, + mpi_size, sc_MPI_INT, intranode); + SC_CHECK_MPI (mpiret); + for (int i = 1; i < mpi_size; i++) { + displ[i] = displ[i - 1] + recvcounts[i - 1]; + } + mpiret = + sc_MPI_Allgatherv ((void *) sendbuf, sendcount, sendtype, + recvarray->array, recvcounts, displ, recvtype, comm); + SC_CHECK_MPI (mpiret); + T8_FREE (recvcounts); + T8_FREE (displ); + break; +#if defined(__bgq__) || defined(SC_ENABLE_MPIWINSHARED) +#if defined(__bgq__) + case SC_SHMEM_BGQ: + case SC_SHMEM_BGQ_PRESCAN: +#endif +#if defined(SC_ENABLE_MPIWINSHARED) + case SC_SHMEM_WINDOW: + case SC_SHMEM_WINDOW_PRESCAN: +#endif + t8_shmem_array_allgatherv_common (sendbuf, sendcount, sendtype, recvarray, + recvtype, comm, intranode, internode); + break; +#endif + default: + SC_ABORT_NOT_REACHED (); + } +} + sc_MPI_Comm t8_shmem_array_get_comm (t8_shmem_array_t array) { diff --git a/src/t8_data/t8_shmem.h b/src/t8_data/t8_shmem.h index 695a724aea..62c70af0b4 100644 --- a/src/t8_data/t8_shmem.h +++ b/src/t8_data/t8_shmem.h @@ -147,6 +147,32 @@ void t8_shmem_array_allgather (const void *sendbuf, int recvcount, sc_MPI_Datatype recvtype); +/** + * Fill a t8_shmem array with an Allgatherv + * Computes the recvcount-array and displacement-array for each rank of a node using the + * sendcount. + * The total number of items of each node is then used to compute the + * recvcount-array and displacement-array between nodes. + * + * \param[in] sendbuf the source from this process + * \param[in] sendcount the number of items to gather + * \param[in] sendtype the type of items ot gather + * \param[in, out] recvarray array of type recvtype where the data gets written to + * \param[in] recvtype the type of items to recieve + * \param[in] comm the mpi communicator + * \param[in] intranode the intranode mpi communicator + * \param[in] internode the internode mpi communicator + * + */ +void t8_shmem_array_allgatherv (const void *sendbuf, + int sendcount, + sc_MPI_Datatype + sendtype, + t8_shmem_array_t + recvarray, + sc_MPI_Datatype + recvtype, sc_MPI_Comm comm); + /** Return the MPI communicator associated with a shmem array. * \param [in] array The shmem_array to be queried. * \return The MPI communicator stored at \a array. From 7ff78a8d3a3003359174e550a777e94884ee794c Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 12 May 2023 20:50:56 +0200 Subject: [PATCH 203/255] Add a t8_shmem_array_algatherv --- src/t8_data/t8_shmem.c | 85 ++++++++++++++++++++++----------- test/t8_data/t8_gtest_shmem.cxx | 70 +++++++++++++++++++++++++++ 2 files changed, 127 insertions(+), 28 deletions(-) diff --git a/src/t8_data/t8_shmem.c b/src/t8_data/t8_shmem.c index fd2e71808e..963484cc71 100644 --- a/src/t8_data/t8_shmem.c +++ b/src/t8_data/t8_shmem.c @@ -218,6 +218,36 @@ t8_shmem_array_allgather (const void *sendbuf, int sendcount, recvcount, recvtype, recvarray->comm); } +/** + * Computes the recvcounter- and displacementarray for + * an MPI_Gatherv + * + * \param[in] sendcount The number of items this proc sends + * \param[in, out] recvcounts On input a zero-initialized array that is going to be filled with the number of elements send by rank i + * \param[in, out] displs On input a zero-initialized array that is going to be filled with the displacements + * \returns The total number of items + */ +static int +t8_compute_recvcounts_displs (int sendcount, int *recvcounts, int *displs, + int elem_size, sc_MPI_Comm comm) +{ + int mpisize; + int mpiret = sc_MPI_Comm_size (comm, &mpisize); + SC_CHECK_MPI (mpiret); + + mpiret = sc_MPI_Allgather ((void *) &sendcount, 1, sc_MPI_INT, recvcounts, + 1, sc_MPI_INT, comm); + SC_CHECK_MPI (mpiret); + + int recv_total = recvcounts[0]; + for (int i = 1; i < mpisize; i++) { + displs[i] = displs[i - 1] + recvcounts[i - 1]; + recv_total += recvcounts[i]; + } + + return recv_total; +} + static void t8_shmem_array_allgatherv_common (const void *sendbuf, int sendcount, @@ -244,14 +274,9 @@ t8_shmem_array_allgatherv_common (const void *sendbuf, int *intra_displ = T8_ALLOC_ZERO (int, intrasize); int *intra_recvcounts = T8_ALLOC_ZERO (int, intrasize); - sc_MPI_Allgather ((void *) &sendcount, 1, sc_MPI_INT, intra_recvcounts, - intrasize, sc_MPI_INT, intranode); - SC_CHECK_MPI (mpiret); - int intra_recv_total = intra_recvcounts[0]; - for (int i = 1; i < intersize; i++) { - intra_displ[i] = intra_displ[i - 1] + intra_recvcounts[i - 1]; - intra_recv_total += intra_recvcounts[i]; - } + int intra_recv_total = + t8_compute_recvcounts_displs (sendcount, intra_recvcounts, intra_displ, + sizeof (sendtype), intranode); if (!intrarank) { noderecvchar = SC_ALLOC (char, intra_recv_total * typesize); } @@ -263,15 +288,11 @@ t8_shmem_array_allgatherv_common (const void *sendbuf, int *inter_displ = T8_ALLOC_ZERO (int, intersize); int *inter_recvcount = T8_ALLOC_ZERO (int, intersize); - sc_MPI_Allgather ((void *) &intra_recv_total, 1, sc_MPI_INT, - inter_recvcount, intersize, sc_MPI_INT, internode); - SC_CHECK_MPI (mpiret); - for (int i = 1; i < intersize; i++) { - inter_displ[i] = inter_displ[i - 1] + inter_recvcount[i - 1]; - } + t8_compute_recvcounts_displs (intra_recv_total, inter_recvcount, + inter_displ, sizeof (sendtype), internode); /* node root allgathers between nodes */ - if (sc_shmem_write_start (recvarray->array, comm)) { + if (t8_shmem_array_start_writing (recvarray)) { mpiret = sc_MPI_Allgatherv (noderecvchar, intra_recv_total, sendtype, recvarray->array, inter_recvcount, inter_displ, @@ -279,7 +300,7 @@ t8_shmem_array_allgatherv_common (const void *sendbuf, SC_CHECK_MPI (mpiret); SC_FREE (noderecvchar); } - sc_shmem_write_end (recvarray->array, comm); + t8_shmem_array_end_writing (recvarray); T8_FREE (inter_displ); T8_FREE (inter_recvcount); T8_FREE (intra_displ); @@ -302,6 +323,10 @@ t8_shmem_array_allgatherv (const void *sendbuf, sc_MPI_COMM_NULL; type = sc_shmem_get_type (comm); + if (type == SC_SHMEM_NOT_SET) { + type = sc_shmem_default_type; + sc_shmem_set_type (comm, type); + } sc_mpi_comm_get_node_comms (comm, &intranode, &internode); if (intranode == sc_MPI_COMM_NULL || internode == sc_MPI_COMM_NULL) { type = SC_SHMEM_BASIC; @@ -309,24 +334,28 @@ t8_shmem_array_allgatherv (const void *sendbuf, switch (type) { case SC_SHMEM_BASIC: case SC_SHMEM_PRESCAN: - int mpi_size; - int mpiret = sc_MPI_Comm_size (comm, &mpi_size); + int mpisize; + int mpirank; + int mpiret; + mpiret = sc_MPI_Comm_size (comm, &mpisize); SC_CHECK_MPI (mpiret); - int *displ = T8_ALLOC_ZERO (int, mpi_size); - int *recvcounts = T8_ALLOC_ZERO (int, mpi_size); - - mpiret = sc_MPI_Allgather ((void *) &sendcount, 1, sc_MPI_INT, recvcounts, - mpi_size, sc_MPI_INT, intranode); + mpiret = sc_MPI_Comm_rank (comm, &mpirank); SC_CHECK_MPI (mpiret); - for (int i = 1; i < mpi_size; i++) { - displ[i] = displ[i - 1] + recvcounts[i - 1]; - } + + int *displs = T8_ALLOC_ZERO (int, mpisize); + int *recvcounts = T8_ALLOC_ZERO (int, mpisize); + + t8_compute_recvcounts_displs (sendcount, recvcounts, displs, + sizeof (sendtype), comm); + mpiret = sc_MPI_Allgatherv ((void *) sendbuf, sendcount, sendtype, - recvarray->array, recvcounts, displ, recvtype, comm); + recvarray->array, recvcounts, displs, recvtype, + comm); SC_CHECK_MPI (mpiret); + T8_FREE (recvcounts); - T8_FREE (displ); + T8_FREE (displs); break; #if defined(__bgq__) || defined(SC_ENABLE_MPIWINSHARED) #if defined(__bgq__) diff --git a/test/t8_data/t8_gtest_shmem.cxx b/test/t8_data/t8_gtest_shmem.cxx index d05d078192..279ca9b96e 100644 --- a/test/t8_data/t8_gtest_shmem.cxx +++ b/test/t8_data/t8_gtest_shmem.cxx @@ -165,6 +165,76 @@ TEST_P(shmem, test_sc_shmem_alloc){ } } +TEST_P(shmem, test_shmem_array_allgatherv){ + const size_t element_size = sizeof (t8_gloidx_t); + int mpirank, mpisize; + int mpiret; + + mpiret = sc_MPI_Comm_rank (comm, &mpirank); + SC_CHECK_MPI (mpiret); + mpiret = sc_MPI_Comm_size (comm, &mpisize); + SC_CHECK_MPI (mpiret); + + t8_debugf("[D] mpirank: %i\n", mpirank); + + const int base_size = 10; + const t8_gloidx_t array_length = (mpirank+1) * base_size; + t8_gloidx_t *sendbuf = T8_ALLOC_ZERO(t8_gloidx_t, array_length); + const t8_gloidx_t first_array_value = base_size * mpirank * (mpirank + 1) / 2; + const int total_size = base_size * mpisize * (mpisize + 1) / 2; + + for(t8_gloidx_t i = 0; i < array_length; i++){ + sendbuf[i] = first_array_value + i; + } + + t8_debugf("[D] total_size: %i\n", total_size); + + for(int shmem_type_int = SC_SHMEM_BASIC; + shmem_type_int < SC_SHMEM_NUM_TYPES; ++shmem_type_int){ + t8_debugf("Checking shared memory type %s.\n", sc_shmem_type_to_string[shmem_type_int]); + + const sc_shmem_type_t shmem_type = (sc_shmem_type_t) shmem_type_int; + + /* setup shared memory usage */ + t8_shmem_init (comm); + t8_shmem_set_type (comm, shmem_type); + +#if T8_ENABLE_MPI + const sc_shmem_type_t control_shmem_type = sc_shmem_get_type (comm); + ASSERT_EQ(shmem_type, control_shmem_type) << "Setting shmem type not succesfull."; +#endif + + t8_shmem_array_t shmem_array; + t8_shmem_array_init(&shmem_array, element_size, total_size, comm); + + sc_MPI_Comm check_comm = t8_shmem_array_get_comm (shmem_array); + /* Check communicator of shared memory array. */ + ASSERT_EQ(comm, check_comm) << "Shared memory array has wrong communicator."; + + /* Check element count of shared memory array. */ + const int check_count = + t8_shmem_array_get_elem_count (shmem_array); + ASSERT_EQ(check_count, total_size) << "shared memory array has wrong element count."; + + /* Check element size of shared memory array. */ + const size_t check_size = + t8_shmem_array_get_elem_size (shmem_array); + ASSERT_EQ(check_size, element_size) << "shared memory has wrong element size."; + + t8_shmem_array_allgatherv((void *) sendbuf, array_length, T8_MPI_GLOIDX, shmem_array, + T8_MPI_GLOIDX, comm); + + for(int i = 0; i < total_size; ++i){ + const int value = t8_shmem_array_get_gloidx(shmem_array, i); + ASSERT_EQ(value, i) << "Value at position " << i << " not correct (expected " << i << " got " << value << ")"; + } + + t8_shmem_array_destroy(&shmem_array); + t8_shmem_finalize(comm); + } + T8_FREE(sendbuf); +} + TEST_P(shmem, test_shmem_array){ const int array_length = 100; const int element_size = sizeof (t8_gloidx_t); From 420dd596bdb6ec8c538a4886acbc6527dd6b5a14 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 15 May 2023 09:22:33 +0200 Subject: [PATCH 204/255] Add t8_shmem_allgatherv_basic for improved code structure --- src/t8_data/t8_shmem.c | 58 +++++++++++++++++++++++++----------------- src/t8_data/t8_shmem.h | 4 +-- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/t8_data/t8_shmem.c b/src/t8_data/t8_shmem.c index 963484cc71..fc873c0e31 100644 --- a/src/t8_data/t8_shmem.c +++ b/src/t8_data/t8_shmem.c @@ -250,7 +250,7 @@ t8_compute_recvcounts_displs (int sendcount, int *recvcounts, int *displs, static void t8_shmem_array_allgatherv_common (const void *sendbuf, - int sendcount, + const int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, sc_MPI_Datatype recvtype, @@ -307,9 +307,39 @@ t8_shmem_array_allgatherv_common (const void *sendbuf, T8_FREE (intra_recvcounts); } +static void +t8_shmem_array_allgatherv_basic (const void *sendbuf, + const int sendcount, + sc_MPI_Datatype sendtype, + t8_shmem_array_t recvarray, + sc_MPI_Datatype recvtype, sc_MPI_Comm comm) +{ + int mpisize; + int mpirank; + int mpiret; + mpiret = sc_MPI_Comm_size (comm, &mpisize); + SC_CHECK_MPI (mpiret); + mpiret = sc_MPI_Comm_rank (comm, &mpirank); + SC_CHECK_MPI (mpiret); + + int *displs = T8_ALLOC_ZERO (int, mpisize); + int *recvcounts = T8_ALLOC_ZERO (int, mpisize); + + t8_compute_recvcounts_displs (sendcount, recvcounts, displs, + sizeof (sendtype), comm); + + mpiret = + sc_MPI_Allgatherv ((void *) sendbuf, sendcount, sendtype, + recvarray->array, recvcounts, displs, recvtype, comm); + SC_CHECK_MPI (mpiret); + + T8_FREE (recvcounts); + T8_FREE (displs); +} + void t8_shmem_array_allgatherv (const void *sendbuf, - int sendcount, + const int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t @@ -334,28 +364,8 @@ t8_shmem_array_allgatherv (const void *sendbuf, switch (type) { case SC_SHMEM_BASIC: case SC_SHMEM_PRESCAN: - int mpisize; - int mpirank; - int mpiret; - mpiret = sc_MPI_Comm_size (comm, &mpisize); - SC_CHECK_MPI (mpiret); - mpiret = sc_MPI_Comm_rank (comm, &mpirank); - SC_CHECK_MPI (mpiret); - - int *displs = T8_ALLOC_ZERO (int, mpisize); - int *recvcounts = T8_ALLOC_ZERO (int, mpisize); - - t8_compute_recvcounts_displs (sendcount, recvcounts, displs, - sizeof (sendtype), comm); - - mpiret = - sc_MPI_Allgatherv ((void *) sendbuf, sendcount, sendtype, - recvarray->array, recvcounts, displs, recvtype, - comm); - SC_CHECK_MPI (mpiret); - - T8_FREE (recvcounts); - T8_FREE (displs); + t8_shmem_array_allgatherv_basic (sendbuf, sendcount, sendtype, recvarray, + recvtype, comm); break; #if defined(__bgq__) || defined(SC_ENABLE_MPIWINSHARED) #if defined(__bgq__) diff --git a/src/t8_data/t8_shmem.h b/src/t8_data/t8_shmem.h index 62c70af0b4..0e9c5d357b 100644 --- a/src/t8_data/t8_shmem.h +++ b/src/t8_data/t8_shmem.h @@ -155,7 +155,7 @@ void t8_shmem_array_allgather (const void *sendbuf, * recvcount-array and displacement-array between nodes. * * \param[in] sendbuf the source from this process - * \param[in] sendcount the number of items to gather + * \param[in] sendcount the number of items to gather on this proc * \param[in] sendtype the type of items ot gather * \param[in, out] recvarray array of type recvtype where the data gets written to * \param[in] recvtype the type of items to recieve @@ -165,7 +165,7 @@ void t8_shmem_array_allgather (const void *sendbuf, * */ void t8_shmem_array_allgatherv (const void *sendbuf, - int sendcount, + const int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t From d4515e4075ed3c44f0e773013936f32ab85eb51a Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 15 May 2023 09:54:22 +0200 Subject: [PATCH 205/255] Remove const from sendbuf as it is not const in sc_MPI_Gatherv --- src/t8_data/t8_shmem.c | 6 +++--- src/t8_data/t8_shmem.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/t8_data/t8_shmem.c b/src/t8_data/t8_shmem.c index fc873c0e31..224ad65ce6 100644 --- a/src/t8_data/t8_shmem.c +++ b/src/t8_data/t8_shmem.c @@ -249,7 +249,7 @@ t8_compute_recvcounts_displs (int sendcount, int *recvcounts, int *displs, } static void -t8_shmem_array_allgatherv_common (const void *sendbuf, +t8_shmem_array_allgatherv_common (void *sendbuf, const int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, @@ -308,7 +308,7 @@ t8_shmem_array_allgatherv_common (const void *sendbuf, } static void -t8_shmem_array_allgatherv_basic (const void *sendbuf, +t8_shmem_array_allgatherv_basic (void *sendbuf, const int sendcount, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, @@ -338,7 +338,7 @@ t8_shmem_array_allgatherv_basic (const void *sendbuf, } void -t8_shmem_array_allgatherv (const void *sendbuf, +t8_shmem_array_allgatherv (void *sendbuf, const int sendcount, sc_MPI_Datatype sendtype, diff --git a/src/t8_data/t8_shmem.h b/src/t8_data/t8_shmem.h index 0e9c5d357b..e26e4abf3a 100644 --- a/src/t8_data/t8_shmem.h +++ b/src/t8_data/t8_shmem.h @@ -164,7 +164,7 @@ void t8_shmem_array_allgather (const void *sendbuf, * \param[in] internode the internode mpi communicator * */ -void t8_shmem_array_allgatherv (const void *sendbuf, +void t8_shmem_array_allgatherv (void *sendbuf, const int sendcount, sc_MPI_Datatype sendtype, From 3233f8325fd14589c4310510533cbd7ca38b83e8 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 15 May 2023 10:18:50 +0200 Subject: [PATCH 206/255] Only compile t8_shmem_array_allgatherv_common when bgq or SC_ENABLE_MPIWINSHARED are defined --- src/t8_data/t8_shmem.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/t8_data/t8_shmem.c b/src/t8_data/t8_shmem.c index 224ad65ce6..218b5d5085 100644 --- a/src/t8_data/t8_shmem.c +++ b/src/t8_data/t8_shmem.c @@ -248,6 +248,7 @@ t8_compute_recvcounts_displs (int sendcount, int *recvcounts, int *displs, return recv_total; } +#if defined(__bgq__) || defined(SC_ENABLE_MPIWINSHARED) static void t8_shmem_array_allgatherv_common (void *sendbuf, const int sendcount, @@ -278,7 +279,7 @@ t8_shmem_array_allgatherv_common (void *sendbuf, t8_compute_recvcounts_displs (sendcount, intra_recvcounts, intra_displ, sizeof (sendtype), intranode); if (!intrarank) { - noderecvchar = SC_ALLOC (char, intra_recv_total * typesize); + noderecvchar = T8_ALLOC (char, intra_recv_total * typesize); } mpiret = sc_MPI_Gatherv (sendbuf, sendcount, sendtype, noderecvchar, @@ -298,7 +299,7 @@ t8_shmem_array_allgatherv_common (void *sendbuf, recvarray->array, inter_recvcount, inter_displ, recvtype, internode); SC_CHECK_MPI (mpiret); - SC_FREE (noderecvchar); + T8_FREE (noderecvchar); } t8_shmem_array_end_writing (recvarray); T8_FREE (inter_displ); @@ -306,6 +307,7 @@ t8_shmem_array_allgatherv_common (void *sendbuf, T8_FREE (intra_displ); T8_FREE (intra_recvcounts); } +#endif /* __bgq__ || SC_ENABLE_MPI_WINSHARED */ static void t8_shmem_array_allgatherv_basic (void *sendbuf, @@ -371,15 +373,15 @@ t8_shmem_array_allgatherv (void *sendbuf, #if defined(__bgq__) case SC_SHMEM_BGQ: case SC_SHMEM_BGQ_PRESCAN: -#endif +#endif /* __bgq__ */ #if defined(SC_ENABLE_MPIWINSHARED) case SC_SHMEM_WINDOW: case SC_SHMEM_WINDOW_PRESCAN: -#endif +#endif /* SC_ENABLE_MPIWINSHARED */ t8_shmem_array_allgatherv_common (sendbuf, sendcount, sendtype, recvarray, recvtype, comm, intranode, internode); break; -#endif +#endif /* __bgq__ || SC_ENABLE_MPI_WINSHARED */ default: SC_ABORT_NOT_REACHED (); } From 1aee673471213e77e19fcad1bb4a84b3b0fa645e Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 15 May 2023 10:30:36 +0200 Subject: [PATCH 207/255] Add more Comments --- src/t8_data/t8_shmem.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/t8_data/t8_shmem.c b/src/t8_data/t8_shmem.c index 218b5d5085..b7fb802b50 100644 --- a/src/t8_data/t8_shmem.c +++ b/src/t8_data/t8_shmem.c @@ -249,6 +249,18 @@ t8_compute_recvcounts_displs (int sendcount, int *recvcounts, int *displs, } #if defined(__bgq__) || defined(SC_ENABLE_MPIWINSHARED) +/** + * Allgathers sendbuffer of various sizes and writes them in the recvarray. + * Can be used for SC_SHMEM_WINDOW, SC_SHMEM_WINDOW_PRESCAN + * SC_SHMEM_BGQ or SC_SHMEMBGQ_PRESCAN (sc_shmem.h) + * + * \param[in] sendbuf The sendbuffer + * \param[in] sendcount The number of items send by this proc + * \param[in] sendtype The type of items to send + * \param[in, out] recvarray The destination + * \param[in] recvtype The type of items to receive + * \param[in] comm The mpicommunicator to use. + */ static void t8_shmem_array_allgatherv_common (void *sendbuf, const int sendcount, @@ -271,10 +283,9 @@ t8_shmem_array_allgatherv_common (void *sendbuf, mpiret = sc_MPI_Comm_size (internode, &intersize); SC_CHECK_MPI (mpiret); - /* node root gathers from node */ + /* intranode-gatherv */ int *intra_displ = T8_ALLOC_ZERO (int, intrasize); int *intra_recvcounts = T8_ALLOC_ZERO (int, intrasize); - int intra_recv_total = t8_compute_recvcounts_displs (sendcount, intra_recvcounts, intra_displ, sizeof (sendtype), intranode); @@ -286,13 +297,11 @@ t8_shmem_array_allgatherv_common (void *sendbuf, intra_recvcounts, intra_displ, recvtype, 0, intranode); SC_CHECK_MPI (mpiret); +/* internode-allgatherv */ int *inter_displ = T8_ALLOC_ZERO (int, intersize); int *inter_recvcount = T8_ALLOC_ZERO (int, intersize); - t8_compute_recvcounts_displs (intra_recv_total, inter_recvcount, inter_displ, sizeof (sendtype), internode); - - /* node root allgathers between nodes */ if (t8_shmem_array_start_writing (recvarray)) { mpiret = sc_MPI_Allgatherv (noderecvchar, intra_recv_total, sendtype, @@ -302,6 +311,7 @@ t8_shmem_array_allgatherv_common (void *sendbuf, T8_FREE (noderecvchar); } t8_shmem_array_end_writing (recvarray); + T8_FREE (inter_displ); T8_FREE (inter_recvcount); T8_FREE (intra_displ); @@ -309,6 +319,17 @@ t8_shmem_array_allgatherv_common (void *sendbuf, } #endif /* __bgq__ || SC_ENABLE_MPI_WINSHARED */ +/** + * Allgathers sendbuffer of various sizes and writes them in the recvarray. + * Can be used for Basic or Prescan shared memory (sc_shmem.h) + * + * \param[in] sendbuf The sendbuffer + * \param[in] sendcount The number of items send by this proc + * \param[in] sendtype The type of items to send + * \param[in, out] recvarray The destination + * \param[in] recvtype The type of items to receive + * \param[in] comm The mpicommunicator to use. + */ static void t8_shmem_array_allgatherv_basic (void *sendbuf, const int sendcount, @@ -354,15 +375,20 @@ t8_shmem_array_allgatherv (void *sendbuf, sc_MPI_Comm intranode = sc_MPI_COMM_NULL, internode = sc_MPI_COMM_NULL; + /* Get the type of the used shared memory. */ type = sc_shmem_get_type (comm); if (type == SC_SHMEM_NOT_SET) { type = sc_shmem_default_type; sc_shmem_set_type (comm, type); } + + /* Get the intra- and internode communicator. */ sc_mpi_comm_get_node_comms (comm, &intranode, &internode); if (intranode == sc_MPI_COMM_NULL || internode == sc_MPI_COMM_NULL) { type = SC_SHMEM_BASIC; } + + /* Choose the type of allgatherv depending on the used shmem type. */ switch (type) { case SC_SHMEM_BASIC: case SC_SHMEM_PRESCAN: From 17cc0a2692580fea7d72c02046ece7bda71c6a6b Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Mon, 22 May 2023 10:24:51 +0200 Subject: [PATCH 208/255] Add tutorial step7 - interpolation --- tutorials/Makefile.am | 8 +- tutorials/general/t8_step7.h | 49 +++ tutorials/general/t8_step7_interpolation.cxx | 421 +++++++++++++++++++ tutorials/general/t8_step7_main.cxx | 34 ++ 4 files changed, 511 insertions(+), 1 deletion(-) create mode 100644 tutorials/general/t8_step7.h create mode 100644 tutorials/general/t8_step7_interpolation.cxx create mode 100644 tutorials/general/t8_step7_main.cxx diff --git a/tutorials/Makefile.am b/tutorials/Makefile.am index 1b4e799ba7..69c5465379 100644 --- a/tutorials/Makefile.am +++ b/tutorials/Makefile.am @@ -11,6 +11,7 @@ bin_PROGRAMS += \ tutorials/general/t8_step5_element_data \ tutorials/general/t8_step5_element_data_c_interface \ tutorials/general/t8_step6_stencil \ + tutorials/general/t8_step7_interpolation \ tutorials/general/t8_tutorial_search \ tutorials/features/t8_features_curved_meshes @@ -43,6 +44,10 @@ tutorials_general_t8_step6_stencil_SOURCES = \ tutorials/general/t8_step3_adapt_forest.cxx \ tutorials/general/t8_step6_stencil.cxx \ tutorials/general/t8_step6_main.cxx +tutorials_general_t8_step7_interpolation_SOURCES = \ + tutorials/general/t8_step3_adapt_forest.cxx \ + tutorials/general/t8_step7_interpolation.cxx \ + tutorials/general/t8_step7_main.cxx tutorials_general_t8_tutorial_search_SOURCES = \ tutorials/general/t8_tutorial_search.cxx \ tutorials/general/t8_step3_adapt_forest.cxx @@ -53,5 +58,6 @@ libt8_installed_headers += \ tutorials/general/t8_step3.h \ tutorials/general/t8_step4.h \ tutorials/general/t8_step5.h \ - tutorials/general/t8_step6.h + tutorials/general/t8_step6.h \ + tutorials/general/t8_step7.h diff --git a/tutorials/general/t8_step7.h b/tutorials/general/t8_step7.h new file mode 100644 index 0000000000..39103e1900 --- /dev/null +++ b/tutorials/general/t8_step7.h @@ -0,0 +1,49 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** file t8_step7.h + */ + +#ifndef T8_STEP7_H +#define T8_STEP7_H + +#include + +T8_EXTERN_C_BEGIN (); + +/* This is our own defined data that we will pass on to the + * adaptation callback. */ +struct t8_step7_adapt_data +{ + double midpoint[3]; /* The midpoint of our sphere. */ + double refine_if_inside_radius; /* if an element's center is smaller than this value, we refine the element. */ + double coarsen_if_outside_radius; /* if an element's center is larger this value, we coarsen its family. */ + double *element_data; +}; + +/** This is the main program of this example. + */ +int t8_step7_main (int argc, char **argv); + +T8_EXTERN_C_END (); + +#endif /* !T8_STEP7_H */ diff --git a/tutorials/general/t8_step7_interpolation.cxx b/tutorials/general/t8_step7_interpolation.cxx new file mode 100644 index 0000000000..3bdfb6f800 --- /dev/null +++ b/tutorials/general/t8_step7_interpolation.cxx @@ -0,0 +1,421 @@ +#include +#include +#include +#include +#include +#include +#include /* geometrical information of the forest */ +#include +#include +#include +#include +#include +#include "t8_cmesh/t8_cmesh_testcases.h" +#include + +#include + +T8_EXTERN_C_BEGIN (); + +/* The data that we want to store for each element. +In this tutorial we will store the distance to the centroid in the data. +You can store more than one element here (see for example tutorial - step 5). */ +struct t8_step7_element_data_t +{ + /* Storage for ourelemet values. */ + double values; + +}; + +/* This is our own defined data that we will pass on to the + * adaptation callback. */ +struct t8_step7_adapt_data +{ + double midpoint[3]; /* The midpoint of our sphere. */ + double refine_if_inside_radius; /* if an element's center is smaller than this value, we refine the element. */ + double coarsen_if_outside_radius; /* if an element's center is larger this value, we coarsen its family. */ + t8_step7_element_data_t *element_data; +}; + +/* This is our own defined data that we will pass on to the + * adaptation callback. */ + +/* The adaptation callback function. This function will be called once for each element + * and the return value decides whether this element should be refined or not. + * return > 0 -> This element should get refined. + * return = 0 -> This element should not get refined. + * If the current element is the first element of a family (= all level l elements that arise from refining + * the same level l-1 element) then this function is called with the whole family of elements + * as input and the return value additionally decides whether the whole family should get coarsened. + * return > 0 -> The first element should get refined. + * return = 0 -> The first element should not get refined. + * return < 0 -> The whole family should get coarsened. + * + * \param [in] forest The current forest that is in construction. + * \param [in] forest_from The forest from which we adapt the current forest (in our case, the uniform forest) + * \param [in] which_tree The process local id of the current tree. + * \param [in] lelement_id The tree local index of the current element (or the first of the family). + * \param [in] ts The refinement scheme for this tree's element class. + * \param [in] is_family if 1, the first \a num_elements entries in \a elements form a family. If 0, they do not. + * \param [in] num_elements The number of entries in \a elements elements that are defined. + * \param [in] elements The element or family of elements to consider for refinement/coarsening. + */ +int +t8_step7_adapt_callback (t8_forest_t forest, + t8_forest_t forest_from, + t8_locidx_t which_tree, + t8_locidx_t lelement_id, + t8_eclass_scheme_c *ts, + const int is_family, + const int num_elements, t8_element_t *elements[]) +{ + /* Our adaptation criterion is to look at the midpoint coordinates of the current element and if + * they are inside a sphere around a given midpoint we refine, if they are outside, we coarsen. */ + double centroid[3]; /* Will hold the element midpoint. */ + /* In t8_step3_adapt_forest we pass a t8_step3_adapt_data pointer as user data to the + * t8_forest_new_adapt function. This pointer is stored as the used data of the new forest + * and we can now access it with t8_forest_get_user_data (forest). */ + const struct t8_step7_adapt_data *adapt_data = + (const struct t8_step7_adapt_data *) t8_forest_get_user_data (forest); + double dist; /* Will store the distance of the element's midpoint and the sphere midpoint. */ + + /* You can use T8_ASSERT for assertions that are active in debug mode (when configured with --enable-debug). + * If the condition is not true, then the code will abort. + * In this case, we want to make sure that we actually did set a user pointer to forest and thus + * did not get the NULL pointer from t8_forest_get_user_data. + */ + T8_ASSERT (adapt_data != NULL); + + /* Compute the element's centroid coordinates. */ + t8_forest_element_centroid (forest_from, which_tree, elements[0], centroid); + + /* Compute the distance to our sphere midpoint. */ + dist = t8_vec_dist (centroid, adapt_data->midpoint); + if (dist < adapt_data->refine_if_inside_radius) { + /* Refine this element. */ + return 1; + } + else if (is_family && dist > adapt_data->coarsen_if_outside_radius) { + /* Coarsen this family. Note that we check for is_family before, since returning < 0 + * if we do not have a family as input is illegal. */ + return -1; + } + /* Do not change this element. */ + return 0; +} + +/* Callback function, where no element is refined or coarsened. + */ +int +t8_adapt_non (t8_forest_t forest, + t8_forest_t forest_from, + t8_locidx_t which_tree, + t8_locidx_t lelement_id, + t8_eclass_scheme_c *ts, + const int is_family, + const int num_elements, t8_element_t *elements[]) +{ + return 0; +} + +/* Adapt a forest according to a callback function. + * This will create a new forest and return it. + * Create a new forest that is adapted from \a forest with our adaptation callback. + * We provide the adapt_data as user data that is stored as the used_data pointer of the + * new forest (see also t8_forest_set_user_data). + * The 0, 0 arguments are flags that control + * \param [in] forest_from Forest that should be adapted + * \param [in] adapt_fn Function that defines how to adapt the forest - Callback function + * \param [in] do_partition If non-zero the new_forest should partition the existing forest. As the second parameter + is set to NULL, a previously (or later) set forest will be taken + (\ref t8_forest_set_adapt, \ref t8_forest_set_balance). + * \param [in] recursive If non-zero adaptation is recursive, thus if an element is adapted the children + * or parents are plugged into the callback again recursively until the forest does not + * change any more. If you use this you should ensure that refinement will stop eventually. + * One way is to check the element's level against a given maximum level. + * \param [in] do_face_ghost If non-zero additionally a layer of ghost elements is created for the forest. + * We will discuss ghost in later steps of the tutorial. + * \param [in] user_data User defined data array to store on the forest + */ +t8_forest_t +t8_adapt_forest (t8_forest_t forest_from, t8_forest_adapt_t adapt_fn, + int do_partition, int recursive, int do_face_ghost, void *user_data) +{ + t8_forest_t forest_new; + + t8_forest_init (&forest_new); + /* Adapt the forest */ + t8_forest_set_adapt (forest_new, forest_from, adapt_fn, recursive); + + /* Set user data for the adapted forest */ + if (user_data != NULL) { + t8_forest_set_user_data (forest_new, user_data); + } + /* Create ghost elements */ + t8_forest_set_ghost (forest_new, do_face_ghost, T8_GHOST_FACES); + if (do_partition) { + t8_forest_set_partition (forest_new, NULL, 0); + } + /* Commit the adapted forest */ + t8_forest_commit (forest_new); + + return forest_new; +} + +/* Replace callback to decide how to interpolate a refined or coarsened element. + * If an element is refined, each child gets the phi value of its parent. + * If elements are coarsened, the parent gets the average phi value of the children. + * Outgoing are the old elements and incoming the new ones + * \param [in] forest_old non adapted forest + * \param [in] forest_new adapted forest + * \param [in] which_tree tree_id of the analyzed element + * \param [in] ts eclass sheme + * \param [in] refine ==0 - do nothing, == -1 - coarsen, == 1 - refine + * \param [in] num_outgoing number of the elements not refined forest + * \param [in] first_outgoing index of the old element + * \param [in] num_incoming number of the elements corresponding to the element of the not refined forest + * \param [in] first_incoming index of the new element + */ +void +t8_forest_replace (t8_forest_t forest_old, + t8_forest_t forest_new, + t8_locidx_t which_tree, + t8_eclass_scheme_c *ts, + int refine, + int num_outgoing, + t8_locidx_t first_outgoing, + int num_incoming, + t8_locidx_t first_incoming) +{ + int i; + const struct t8_step7_adapt_data *adapt_data_new = + (const struct t8_step7_adapt_data *) t8_forest_get_user_data (forest_new); + const struct t8_step7_adapt_data *adapt_data_old = + (const struct t8_step7_adapt_data *) t8_forest_get_user_data (forest_old); + + /* get the index of the data array corresponding to the old and the adapted forest */ + for (t8_locidx_t t = 0; t < which_tree; t++) + { + first_incoming += t8_forest_get_tree_num_elements (forest_new, t); + first_outgoing += t8_forest_get_tree_num_elements (forest_old, t); + } + /* Do not adapt or coarsen */ + if (refine == 0) { + adapt_data_new->element_data[first_incoming] = + adapt_data_old->element_data[first_outgoing]; + } + /* The old element is refined, we copy the element values */ + else if (refine == 1) { + for (i = 0; i < num_incoming; i++) { + adapt_data_new->element_data[first_incoming + i] = adapt_data_old->element_data[first_outgoing]; + } + } + /* Old element is coarsened */ + else if (refine == -1) { + adapt_data_new->element_data[first_incoming].values = 0; + for (t8_locidx_t i = 0; i < num_outgoing; i++) { + adapt_data_old->element_data[first_outgoing+i].values; + adapt_data_new->element_data[first_incoming].values += + adapt_data_old->element_data[first_outgoing+i].values; + } + adapt_data_new->element_data[first_incoming].values /= num_outgoing; + } +} + +/* Each process has computed the data entries for its local elements. + * In order to get the values for the ghost elements, we use t8_forest_ghost_exchange_data. + * Calling this function will fill all the ghost entries of our element data array with the + * value on the process that owns the corresponding element. */ +static void +t8_step7_exchange_ghost_data (t8_forest_t forest, + struct t8_step7_element_data_t *data) +{ + sc_array *sc_array_wrapper; + t8_locidx_t num_elements = + t8_forest_get_local_num_elements (forest); + t8_locidx_t num_ghosts = t8_forest_get_num_ghosts (forest); + + /* t8_forest_ghost_exchange_data expects an sc_array (of length num_local_elements + num_ghosts). + * We wrap our data array to an sc_array. */ + sc_array_wrapper = + sc_array_new_data (data, sizeof (struct t8_step7_element_data_t), + num_elements + num_ghosts); + + /* Carry out the data exchange. The entries with indices > num_local_elements will get overwritten. */ + t8_forest_ghost_exchange_data (forest, sc_array_wrapper); + + /* Destroy the wrapper array. This will not free the data memory since we used sc_array_new_data. */ + sc_array_destroy (sc_array_wrapper); +} + +/* Write the forest and the data corresponding to the forest in a vtu file. + * + * \param [in] forest Forest that should written in the vtu file + * \param [in] data Data corresponding to the forest + * \param [in] prefix Prefix to define the file name + */ +static void +t8_write_vtu (t8_forest_t forest, + struct t8_step7_adapt_data *data, + const char *prefix) +{ + t8_locidx_t num_elements = + t8_forest_get_local_num_elements (forest); + t8_locidx_t ielem; + /* We need to allocate a new array to store the volumes on their own. + * This array has one entry per local element. */ + double *element_data = T8_ALLOC (double, num_elements); + /* The number of user defined data fields to write. */ + int num_data = 1; + t8_vtk_data_field_t vtk_data; + vtk_data.type = T8_VTK_SCALAR; + strcpy (vtk_data.description, "Element own data"); + vtk_data.data = element_data; + /* Copy the elment's data from the data array to the output array. */ + for (ielem = 0; ielem < num_elements; ++ielem) { + element_data[ielem] = (data->element_data[ielem]).values; + } + + { + /* To write user defined data, we need to extended output function t8_forest_vtk_write_file + * from t8_forest_vtk.h. Despite writin user data, it also offers more control over which + * properties of the forest to write. */ + int write_treeid = 1; + int write_mpirank = 1; + int write_level = 1; + int write_element_id = 1; + int write_ghosts = 0; + t8_forest_write_vtk_ext (forest, prefix, write_treeid, write_mpirank, + write_level, write_element_id, write_ghosts, + 0, 0, num_data, &vtk_data); + } + T8_FREE (element_data); +} + +/* In this function the interpolation is described. In a first step a + * hypercubic cmesh and then a forest is created. + * We create a data array with the distance to the centroid of each cell. + * The forest is adapted and the data array is interpolated corresponding to + * the adapted forest. + * We write the uniform and the adapted forest to a vtu file. + */ +void +t8_interpolation() { + int level = 4; + t8_cmesh_t cmesh; + t8_forest_t forest_adapt, forest; + t8_scheme_cxx_t *scheme; + t8_step7_element_data_t *data, *data_adapt; + t8_locidx_t numElem; + t8_locidx_t numTrees; + int itree, ielemTree, ielem; + t8_element_t *element; + double centroid[3]; + double midpoint[3] = {0.5, 0.5, 1}; + + scheme = t8_scheme_new_default_cxx (); + + /* Construct a cmesh */ + cmesh = t8_cmesh_new_hypercube (T8_ECLASS_PYRAMID, sc_MPI_COMM_WORLD, 0, 0, 0); + + forest = t8_forest_new_uniform (cmesh, scheme, level, 0, sc_MPI_COMM_WORLD); + + /* Build initial data array and set data for the local elements. */ + data = T8_ALLOC (t8_step7_element_data_t, t8_forest_get_local_num_elements (forest)); + for (t8_locidx_t i = 0; i < t8_forest_get_local_num_elements (forest); i++) { + + } + + numTrees = t8_forest_get_num_local_trees( forest ); + /* Loop over all trees. The index of the data array is independent of the tree + * index. Thus, we set the index of the tree index to zero and add one in each + * loop step of the inner loop. + */ + for( itree=0, ielem=0; itree + +int +main (int argc, char **argv) +{ + return t8_step7_main (argc, argv); +} From cc3d507ebe307ce5275f5de786fd341e9d7e5717 Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Mon, 22 May 2023 16:37:45 +0200 Subject: [PATCH 209/255] Make indent scripts runnable from repo root directory. --- scripts/check_if_all_files_indented.scp | 10 ++++++-- scripts/check_if_file_indented.scp | 34 ++++++++++++++++--------- scripts/find_all_source_files.scp | 10 ++++++-- scripts/indent_all_files.scp | 10 ++++++-- 4 files changed, 46 insertions(+), 18 deletions(-) diff --git a/scripts/check_if_all_files_indented.scp b/scripts/check_if_all_files_indented.scp index b9b13c4dad..bca1fa6fa4 100755 --- a/scripts/check_if_all_files_indented.scp +++ b/scripts/check_if_all_files_indented.scp @@ -32,8 +32,14 @@ # if [ `basename $PWD` != scripts ] then - echo ERROR: Must be executed from within the scripts/ subfolder. 2>&1 - exit 1 + if [ -d scripts ] + then + # The directory stack is automatically reset on script exit. + pushd scripts/ > /dev/null + else + echo ERROR: scripts/ directory not found. + exit 1 + fi fi # Find all files with the appropriate suffix. diff --git a/scripts/check_if_file_indented.scp b/scripts/check_if_file_indented.scp index 83036efa9b..9e0f7a750c 100755 --- a/scripts/check_if_file_indented.scp +++ b/scripts/check_if_file_indented.scp @@ -29,7 +29,6 @@ # file is properly indented and not 0 if it is not. # - usage="$0 FILENAME [INDENT_SCRIPT]" # @@ -37,31 +36,42 @@ usage="$0 FILENAME [INDENT_SCRIPT]" # if [ `basename $PWD` != scripts ] then - echo ERROR: Must be executed from whitin the scripts/ subfolder. 2>&1 - exit 1 + if [ -d scripts ] + then + # The directory stack is automatically reset on script exit. + pushd scripts/ > /dev/null + else + echo ERROR: scripts/ directory not found. + exit 1 + fi fi - # Check if first argument given -if [ x$1 = x ] +if [ ${1-x} = x ] then - echo ERROR: Need to provide a file as first argument. 2>&1 + echo ERROR: Need to provide a file as first argument. echo $usage exit 1 fi # Check if first argument is a file and store it in variable -if [ -f $1 ] +if [ -f "$1" ] then - file=$1 + file="$1" else - echo ERROR: Non existing file. - echo $usage - exit 1 + # Try from folder above. + if [ -f "../$1" ] + then + file="../$1" + else + echo "ERROR: Non existing file: $1" + echo $usage + exit 1 + fi fi # Check if second argument given and set indent script -if [ x$2 = x ] +if [ ${2-x} = x ] then # Set default indent script INDENT=./t8indent diff --git a/scripts/find_all_source_files.scp b/scripts/find_all_source_files.scp index ca8eb7eb12..28c6df8442 100755 --- a/scripts/find_all_source_files.scp +++ b/scripts/find_all_source_files.scp @@ -29,8 +29,14 @@ # if [ `basename $PWD` != scripts ] then - echo ERROR: Must be executed from whitin the scripts/ subfolder. - exit 1 + if [ -d scripts ] + then + # The directory stack is automatically reset on script exit. + pushd scripts/ > /dev/null + else + echo ERROR: scripts/ directory not found. + exit 1 + fi fi # All valid file suffixes. diff --git a/scripts/indent_all_files.scp b/scripts/indent_all_files.scp index 1eda680548..63a174bf7c 100755 --- a/scripts/indent_all_files.scp +++ b/scripts/indent_all_files.scp @@ -31,8 +31,14 @@ # if [ `basename $PWD` != scripts ] then - echo ERROR: Must be executed from whitin the scripts/ subfolder. - exit 1 + if [ -d scripts ] + then + # The directory stack is automatically reset on script exit. + pushd scripts/ > /dev/null + else + echo ERROR: scripts/ directory not found. + exit 1 + fi fi # Find all files with the appropriate suffix. From eb4abf3156e86cd91a653b58fd6eebbaeaf24953 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Mon, 22 May 2023 20:49:23 +0200 Subject: [PATCH 210/255] Indent files --- tutorials/general/t8_tutorial_build_cmesh.cxx | 1060 ++++++++--------- tutorials/general/t8_tutorial_build_cmesh.h | 78 +- .../general/t8_tutorial_build_cmesh_main.cxx | 69 +- 3 files changed, 601 insertions(+), 606 deletions(-) diff --git a/tutorials/general/t8_tutorial_build_cmesh.cxx b/tutorials/general/t8_tutorial_build_cmesh.cxx index 60ec955ecf..0c693a40f8 100644 --- a/tutorials/general/t8_tutorial_build_cmesh.cxx +++ b/tutorials/general/t8_tutorial_build_cmesh.cxx @@ -1,532 +1,528 @@ -/* - This file is part of t8code. - t8code is a C library to manage a collection (a forest) of multiple - connected adaptive space-trees of general element types in parallel. - - Copyright (C) 2023 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -/* See also: https://github.com/DLR-AMR/t8code/wiki/Step-6-Computing-stencils - * - * This is step8 of the t8code tutorials using the C++ interface of t8code. - * In the following we will create two user defined meshes. - * The first example is given by a periodic two dimensional mesh using linear - * geometry consisting of four triangles and and two quads. - * The second example is given by a non-periodic three dimensional mesh - * with linear geometry constructed using one tetrahedron, two prisms and one - * hexaedron. - * - * How you can experiment here: - * - Look at the paraview output files of the different meshes. - * - Change the element types of the mesh. - * - Change the face connections between the different elements. - * - Create an own mesh. - * */ - -#include /* General t8code header, always include this. */ -#include /* cmesh definition and basic interface. */ -#include /* forest definition and basic interface. */ -#include /* default refinement scheme. */ -#include /* write file in vtu file */ -#include /* linear geometry of the cmesh */ - -T8_EXTERN_C_BEGIN (); - -/* Different steps of creating a cmesh - * 1. Defining an array with all vertices - * The vertices are ordered in a listing for each cell. - * Thus, there can be duplicates in the List. - * Example: double vertices[numberOfValues] = { - * //point values for cell 1 - * x_1,y_1,z_1 //(x,y,z) of first point of cell 1 - * x_2,y_2,z_2 //(x,y,z) of second point of cell 1 - * . - * . - * . - * x_n,y_n,z_n //(x,y,z) of nth point (last point) of cell 1 - * - * //point values for cell 2 - * x_1,y_1,z_1 //(x,y,z) of first point of cell 2 - * x_2,y_2,z_2 //(x,y,z) of second point of cell 2 - * . - * . - * . - * x_m,y_m,z_m //(x,y,z) of nth point (last point) of cell 2 - * - * . - * . - * . - * - * //point values for the last cell - * x_1,y_1,z_1 //(x,y,z) of first point of the last cell - * x_2,y_2,z_2 //(x,y,z) of second point of the last cell - * . - * . - * . - * x_o,y_o,z_o //(x,y,z) of nth point (last point) of the last cell - * }; - * - * 2. Initialization of the mesh - * Example: t8_cmesh_t cmesh; - * t8_cmesh_init (&cmesh); - * - * - * 3. Definition of the geometry - * t8_geometry_c *linear_geom = [defineTheGeometry]; - * - * 4. Definition of the classes of the different trees - each tree is defined by one cell - * Example: //Class of the first tree - * t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_[TYPE]); - * //Class of the second tree - * t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_[TYPE]); - * . - * . - * . - * //Class of the last tree - * t8_cmesh_set_tree_class (cmesh, x, T8_ECLASS_[TYPE]); - * - * 5. Classification of the vertices for each tree - * // Vertices of the first tree - * t8_cmesh_set_tree_vertices (cmesh, 0, [pointerToVerticesOfTreeOne], [numberOfVerticesTreeOne]); - * // Vertices of the second tree - * t8_cmesh_set_tree_vertices (cmesh, 1, [pointerToVerticesOfTreeTwo] , [numberOfVerticesTreeTwo]); - * . - * . - * . - * // Vertices of the last tree - * t8_cmesh_set_tree_vertices (cmesh, x, [pointerToVerticesOfTree(x+1)] , [numberOfVerticesTree(x+1)]); - * - * 6. Definition of the face neighboors between the different trees - * // List of all face neighboor connections - * t8_cmesh_set_join (cmesh, [treeId1], [treeId2], [faceIdInTree1], [faceIdInTree2], [orientation]); - * t8_cmesh_set_join (cmesh, [treeId1], [treeId2], [faceIdInTree1], [faceIdInTree2], [orientation]); - * . - * . - * . - * t8_cmesh_set_join (cmesh, [treeId1], [treeId2], [faceIdInTree1], [faceIdInTree2], [orientation]); - * - * 7. Commit the mesh - * t8_cmesh_commit (cmesh, comm); - * */ - - -/* Definition of a two dimensional mesh with linear geometry and periodic boundaries. - * The mesh consists of four triangles and two quads. - * - * This is how the cmesh looks like. The numbers are the tree numbers: - * - * +---+---+ - * | |5 /| - * | 3 | / | - * | |/ 4| - * +---+---+ - * |1 /| | - * | / | 2 | - * |/0 | | - * +---+---+ - * */ -t8_cmesh_t -t8_cmesh_new_periodic_hybrid_2d (sc_MPI_Comm comm) -{ - - /* 1. Defining an array with all vertices */ - /* Just all vertices of all trees. partly duplicated */ - double vertices[60] = { - 0, 0, 0, /* tree 0, triangle */ - 0.5, 0, 0, - 0.5, 0.5, 0, - 0, 0, 0, /* tree 1, triangle */ - 0.5, 0.5, 0, - 0, 0.5, 0, - 0.5, 0, 0, /* tree 2, quad */ - 1, 0, 0, - 0.5, 0.5, 0, - 1, 0.5, 0, - 0, 0.5, 0, /* tree 3, quad */ - 0.5, 0.5, 0, - 0, 1, 0, - 0.5, 1, 0, - 0.5, 0.5, 0, /* tree 4, triangle */ - 1, 0.5, 0, - 1, 1, 0, - 0.5, 0.5, 0, /* tree 5, triangle */ - 1, 1, 0, - 0.5, 1, 0 - }; - - /* 2. Initialization of the mesh */ - t8_cmesh_t cmesh; - t8_cmesh_init (&cmesh); - - /* 3. Definition of the geometry */ - t8_geometry_c *linear_geom = t8_geometry_linear_new (2); - t8_cmesh_register_geometry (cmesh, linear_geom); /* Use linear geometry */ - - - /* 4. Definition of the classes of the different trees */ - t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_TRIANGLE); - t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_TRIANGLE); - t8_cmesh_set_tree_class (cmesh, 2, T8_ECLASS_QUAD); - t8_cmesh_set_tree_class (cmesh, 3, T8_ECLASS_QUAD); - t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_TRIANGLE); - t8_cmesh_set_tree_class (cmesh, 5, T8_ECLASS_TRIANGLE); - - /* 5. Classification of the vertices for each tree */ - t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 3); - t8_cmesh_set_tree_vertices (cmesh, 1, vertices + 9, 3); - t8_cmesh_set_tree_vertices (cmesh, 2, vertices + 18, 4); - t8_cmesh_set_tree_vertices (cmesh, 3, vertices + 30, 4); - t8_cmesh_set_tree_vertices (cmesh, 4, vertices + 42, 3); - t8_cmesh_set_tree_vertices (cmesh, 5, vertices + 51, 3); - - /* 6. Definition of the face neighboors between the different trees */ - t8_cmesh_set_join (cmesh, 0, 1, 1, 2, 0); - t8_cmesh_set_join (cmesh, 0, 2, 0, 0, 0); - t8_cmesh_set_join (cmesh, 0, 3, 2, 3, 0); - - t8_cmesh_set_join (cmesh, 1, 3, 0, 2, 1); - t8_cmesh_set_join (cmesh, 1, 2, 1, 1, 0); - - t8_cmesh_set_join (cmesh, 2, 4, 3, 2, 0); - t8_cmesh_set_join (cmesh, 2, 5, 2, 0, 1); - - t8_cmesh_set_join (cmesh, 3, 5, 1, 1, 0); - t8_cmesh_set_join (cmesh, 3, 4, 0, 0, 0); - - t8_cmesh_set_join (cmesh, 4, 5, 1, 2, 0); - - /* 7. Commit the mesh */ - t8_cmesh_commit (cmesh, comm); - - return cmesh; -} - -/* Definition of a three dimensional mesh with linear geometry. - * The mesh consists of two tetrahedra, two prisms and one hexahedron. - * */ -t8_cmesh_t -t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) -{ - /* Definition of the mesh according to the above scheme - * // 1. Defining an array with all vertices - * double vertices[ ] = - * { - * 0.43, 0, 2, // Tetrahedron 1 vertices - 0, 0, 1, - 0.86, -0.5, 1, - 0.86, 0.5, 1, - - 2.29, 0, 2, // Tetrahedron 2 vertices - 1.86, -0.5, 1, - 2.72, 0, 1, - 1.86, 0.5, 1, - - 0, 0, 0, // Prism 1 vertices - 0.86, -0.5, 0, - 0.86, 0.5, 0, - 0, 0, 1, - 0.86, -0.5, 1, - 0.86, 0.5, 1, - - 1.86, -0.5, 0, // Prism 2 vertices - 2.72, 0, 0, - 1.86, 0.5, 0, - 1.86, -0.5, 1, - 2.72, 0, 1, - 1.86, 0.5, 1, - - 0.86, -0.5, 0, // Pyramid coordinates - 1.86, -0.5, 0, - 0.86, 0.5, 0, - 1.86, 0.5, 0, - 1.29, 0, 0, - - 0.86, -0.5, 0, // Hex coordinates - 1.86, -0.5, 0, - 0.86, 0.5, 0, - 1.86, 0.5, 0, - 0.86, -0.5, 1, - 1.86, -0.5, 1, - 0.86, 0.5, 1, - 1.86, 0.5, 1 - - * } - * // 2. Initialization of the mesh - * t8_cmesh_t cmesh; - * t8_cmesh_init (&cmesh); - * - * // 3. Definition of the geometry - * t8_geometry_c *linear_geom = t8_geometry_linear_new (3); - * t8_cmesh_register_geometry (cmesh, linear_geom); // Use linear geometry - * - * // 4. Definition of the classes of the different trees - * t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_TET); - * t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_TET); - * t8_cmesh_set_tree_class (cmesh, 2, T8_ECLASS_PRISM); - * t8_cmesh_set_tree_class (cmesh, 3, T8_ECLASS_PRISM); - * t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_PYRAMID); - * t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_HEX); - * - * // 5. Classification of the vertices for each tree - * t8_cmesh_set_tree_vertices (cmesh, 0, vertices + 12, 4); - * t8_cmesh_set_tree_vertices (cmesh, 1, vertices + 24, 4); - * t8_cmesh_set_tree_vertices (cmesh, 2, vertices + 42, 6); - * t8_cmesh_set_tree_vertices (cmesh, 3, vertices + 60, 6); - * t8_cmesh_set_tree_vertices (cmesh, 4, vertices + 78, 5); - * t8_cmesh_set_tree_vertices (cmesh, 5, vertices + 93, 8); - * - * // 6. Definition of the face neighboors between the different trees - * t8_cmesh_set_join (cmesh, 0, 2, 0, 4, 0); - * t8_cmesh_set_join (cmesh, 1, 3, 0, 4, 0); - * t8_cmesh_set_join (cmesh, 2, 5, 0, 0, 0); - * t8_cmesh_set_join (cmesh, 3, 5, 1, 1, 0); - * t8_cmesh_set_join (cmesh, 4, 5, 4, 2, 0); - * - * // 7. Commit the mesh - * t8_cmesh_commit (cmesh, comm); - * - * return cmesh; - * */ - - /* In many cases the points of the different trees are dependent of these of the previous trees - * or of these of the same tree. Then it is reasonable to define the different vertices dependent - * of each other. - * Also the order of the sheme is not fixed. The definition of the face neighboors can be - * before the definition of the vertices. - * In the following example the tree classes are defined, then the face neighboors are set. - * After that the vertices are defined for each tree separate. - * */ - - double vertices[24]; - int i; - t8_geometry_c *linear_geom = t8_geometry_linear_new (3); - - /* Initialization of the mesh */ - t8_cmesh_t cmesh; - t8_cmesh_init (&cmesh); - - /* Definition of the geometry */ - t8_cmesh_register_geometry (cmesh, linear_geom); /* Use linear geometry */ - - /* Defitition of the classes of the different trees */ - t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_TET); - t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_TET); - t8_cmesh_set_tree_class (cmesh, 2, T8_ECLASS_PRISM); - t8_cmesh_set_tree_class (cmesh, 3, T8_ECLASS_PRISM); - t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_PYRAMID); - t8_cmesh_set_tree_class (cmesh, 5, T8_ECLASS_HEX); - - /* Classification of the vertices for each tree */ - t8_cmesh_set_join (cmesh, 0, 2, 0, 4, 0); - t8_cmesh_set_join (cmesh, 1, 3, 0, 4, 0); - t8_cmesh_set_join (cmesh, 2, 5, 0, 0, 0); - t8_cmesh_set_join (cmesh, 3, 5, 1, 1, 0); - t8_cmesh_set_join (cmesh, 4, 5, 4, 2, 0); - - /* - * Definition of the first tree - */ - /* Tetrahedron 1 vertices */ - vertices[0] = 0.43; - vertices[1] = 0; - vertices[2] = 2; - - vertices[3] = 0; - vertices[4] = 0; - vertices[5] = 1; - - vertices[6] = 0.86; - vertices[7] = -0.5; - vertices[8] = 1; - - vertices[9] = 0.86; - vertices[10] = 0.5; - vertices[11] = 1; - - /* Classification of the vertices for the first tree */ - t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 4); - - /* - * Definition of the second tree - */ - /* Tetrahedron 2 vertices */ - for (i = 0; i < 3; i++) { - - vertices[i] = vertices[i] + (i == 0 ? 1 + 0.86 : 0); - vertices[3 + i] = vertices[6 + i] + (i == 0 ? 1 : 0); - vertices[9 + i] = vertices[9 + i] + (i == 0 ? 1 : 0); - } - - - vertices[6] = 1 + 2 * 0.86; - vertices[7] = 0; - vertices[8] = 1; - - /* Classification of the vertices for the second tree */ - t8_cmesh_set_tree_vertices (cmesh, 1, vertices, 4); - - /* - * Definition of the third tree - */ - /* Prism 1 vertices */ - vertices[0] = 0; - vertices[1] = 0; - vertices[2] = 0; - - vertices[3] = 0.86; - vertices[4] = -0.5; - vertices[5] = 0; - - vertices[6] = 0.86; - vertices[7] = 0.5; - vertices[8] = 0; - - /* Translate +1 in z-axis for the upper vertices */ - for (i = 0; i < 3; i++) { - vertices[9 + 3 * i] = vertices[3 * i]; - vertices[9 + 3 * i + 1] = vertices[3 * i + 1]; - vertices[9 + 3 * i + 2] = vertices[3 * i + 2] + 1; - } - - /* Classification of the vertices for the third tree */ - t8_cmesh_set_tree_vertices (cmesh, 2, vertices, 6); - - /* - * Definition of the fourth tree - */ - /* Prism 2 vertices */ - for (i = 0; i < 3; i++) { - vertices[3 + i] = vertices[i] + (i == 0 ? 1 + 2 * 0.86 : 0); - vertices[6 + i] = vertices[6 + i] + (i == 0 ? 1 : 0); - } - - vertices[0] = 0.86 + 1; - vertices[1] = -0.5; - vertices[2] = 0; - - /* Translate +1 in z-axis for the upper vertices */ - for (i = 0; i < 3; i++) { - vertices[9 + 3 * i] = vertices[3 * i]; - vertices[9 + 3 * i + 1] = vertices[3 * i + 1]; - vertices[9 + 3 * i + 2] = vertices[3 * i + 2] + 1; - } - - /* Classification of the vertices for the fourth tree */ - t8_cmesh_set_tree_vertices (cmesh, 3, vertices, 6); - - - /* - * Definition of the fifth tree - */ - /* Pyramid vertices */ - - vertices[0] = 0.86; - vertices[1] = -0.5; - vertices[2] = 0; - - vertices[3] = 1.86; - vertices[4] = -0.5; - vertices[5] = 0; - - vertices[6] = 0.86; - vertices[7] = 0.5; - vertices[8] = 0; - - vertices[9] = 1.86; - vertices[10] = 0.5; - vertices[11] = 0; - - vertices[12] = 1.36; - vertices[13] = 0; - vertices[14] = -0.5; - - /* Classification of the vertices for the fifth tree */ - t8_cmesh_set_tree_vertices (cmesh, 4, vertices, 5); - - /* - * Definition of the sixth tree - */ - /* Hex coordinates */ - /* Translate +1 in z-axis for the upper vertices */ - for (i = 0; i < 4; i++) { - vertices[12 + 3 * i] = vertices[3 * i]; - vertices[12 + 3 * i + 1] = vertices[3 * i + 1]; - vertices[12 + 3 * i + 2] = vertices[3 * i + 2] + 1; - } - - /* Classification of the vertices for the fifth tree */ - t8_cmesh_set_tree_vertices (cmesh, 5, vertices, 8); - - /* Commit the mesh */ - t8_cmesh_commit (cmesh, comm); - return cmesh; -} - -int -t8_step8_main (int argc, char **argv) -{ - int mpiret; - sc_MPI_Comm comm; - t8_cmesh_t cmesh_2D; - t8_cmesh_t cmesh_3D; - - /* The prefix for our output files. */ - const char *prefix_2D = "t8_step8_user_defined_mesh_2D"; - const char *prefix_3D = "t8_step8_user_defined_mesh_3D"; - - /* - * Initialization. - */ - - /* Initialize MPI. This has to happen before we initialize sc or t8code. */ - mpiret = sc_MPI_Init (&argc, &argv); - /* Error check the MPI return value. */ - SC_CHECK_MPI (mpiret); - - /* Initialize the sc library, has to happen before we initialize t8code. */ - sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_ESSENTIAL); - /* Initialize t8code with log level SC_LP_PRODUCTION. See sc.h for more info on the log levels. */ - t8_init (SC_LP_PRODUCTION); - - /* We will use MPI_COMM_WORLD as a communicator. */ - comm = sc_MPI_COMM_WORLD; - - /* - * Definition of the meshes. - */ - /* Creation of a two dimensional cmesh with periodic boundaries. */ - cmesh_2D = t8_cmesh_new_periodic_hybrid_2d(comm); - - /* Creation of a three dimensional cmesh */ - cmesh_3D = t8_cmesh_new_hybrid_gate_3d(comm); - - /* Output the meshes to vtu files. */ - t8_cmesh_vtk_write_file(cmesh_2D, prefix_2D, 1.0); - t8_cmesh_vtk_write_file(cmesh_3D, prefix_3D, 1.0); - - /* - * Clean-up - */ - sc_finalize (); - - mpiret = sc_MPI_Finalize (); - SC_CHECK_MPI (mpiret); - - return 0; -} - -T8_EXTERN_C_END (); +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element types in parallel. + + Copyright (C) 2023 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/* See also: https://github.com/DLR-AMR/t8code/wiki/Step-6-Computing-stencils + * + * This is step8 of the t8code tutorials using the C++ interface of t8code. + * In the following we will create two user defined meshes. + * The first example is given by a periodic two dimensional mesh using linear + * geometry consisting of four triangles and and two quads. + * The second example is given by a non-periodic three dimensional mesh + * with linear geometry constructed using one tetrahedron, two prisms and one + * hexaedron. + * + * How you can experiment here: + * - Look at the paraview output files of the different meshes. + * - Change the element types of the mesh. + * - Change the face connections between the different elements. + * - Create an own mesh. + * */ + +#include /* General t8code header, always include this. */ +#include /* cmesh definition and basic interface. */ +#include /* forest definition and basic interface. */ +#include /* default refinement scheme. */ +#include /* write file in vtu file */ +#include /* linear geometry of the cmesh */ + +T8_EXTERN_C_BEGIN (); + +/* Different steps of creating a cmesh + * 1. Defining an array with all vertices + * The vertices are ordered in a listing for each cell. + * Thus, there can be duplicates in the List. + * Example: double vertices[numberOfValues] = { + * //point values for cell 1 + * x_1,y_1,z_1 //(x,y,z) of first point of cell 1 + * x_2,y_2,z_2 //(x,y,z) of second point of cell 1 + * . + * . + * . + * x_n,y_n,z_n //(x,y,z) of nth point (last point) of cell 1 + * + * //point values for cell 2 + * x_1,y_1,z_1 //(x,y,z) of first point of cell 2 + * x_2,y_2,z_2 //(x,y,z) of second point of cell 2 + * . + * . + * . + * x_m,y_m,z_m //(x,y,z) of nth point (last point) of cell 2 + * + * . + * . + * . + * + * //point values for the last cell + * x_1,y_1,z_1 //(x,y,z) of first point of the last cell + * x_2,y_2,z_2 //(x,y,z) of second point of the last cell + * . + * . + * . + * x_o,y_o,z_o //(x,y,z) of nth point (last point) of the last cell + * }; + * + * 2. Initialization of the mesh + * Example: t8_cmesh_t cmesh; + * t8_cmesh_init (&cmesh); + * + * + * 3. Definition of the geometry + * t8_geometry_c *linear_geom = [defineTheGeometry]; + * + * 4. Definition of the classes of the different trees - each tree is defined by one cell + * Example: //Class of the first tree + * t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_[TYPE]); + * //Class of the second tree + * t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_[TYPE]); + * . + * . + * . + * //Class of the last tree + * t8_cmesh_set_tree_class (cmesh, x, T8_ECLASS_[TYPE]); + * + * 5. Classification of the vertices for each tree + * // Vertices of the first tree + * t8_cmesh_set_tree_vertices (cmesh, 0, [pointerToVerticesOfTreeOne], [numberOfVerticesTreeOne]); + * // Vertices of the second tree + * t8_cmesh_set_tree_vertices (cmesh, 1, [pointerToVerticesOfTreeTwo] , [numberOfVerticesTreeTwo]); + * . + * . + * . + * // Vertices of the last tree + * t8_cmesh_set_tree_vertices (cmesh, x, [pointerToVerticesOfTree(x+1)] , [numberOfVerticesTree(x+1)]); + * + * 6. Definition of the face neighboors between the different trees + * // List of all face neighboor connections + * t8_cmesh_set_join (cmesh, [treeId1], [treeId2], [faceIdInTree1], [faceIdInTree2], [orientation]); + * t8_cmesh_set_join (cmesh, [treeId1], [treeId2], [faceIdInTree1], [faceIdInTree2], [orientation]); + * . + * . + * . + * t8_cmesh_set_join (cmesh, [treeId1], [treeId2], [faceIdInTree1], [faceIdInTree2], [orientation]); + * + * 7. Commit the mesh + * t8_cmesh_commit (cmesh, comm); + * */ + +/* Definition of a two dimensional mesh with linear geometry and periodic boundaries. + * The mesh consists of four triangles and two quads. + * + * This is how the cmesh looks like. The numbers are the tree numbers: + * + * +---+---+ + * | |5 /| + * | 3 | / | + * | |/ 4| + * +---+---+ + * |1 /| | + * | / | 2 | + * |/0 | | + * +---+---+ + * */ +t8_cmesh_t +t8_cmesh_new_periodic_hybrid_2d (sc_MPI_Comm comm) +{ + + /* 1. Defining an array with all vertices */ + /* Just all vertices of all trees. partly duplicated */ + double vertices[60] = { + 0, 0, 0, /* tree 0, triangle */ + 0.5, 0, 0, + 0.5, 0.5, 0, + 0, 0, 0, /* tree 1, triangle */ + 0.5, 0.5, 0, + 0, 0.5, 0, + 0.5, 0, 0, /* tree 2, quad */ + 1, 0, 0, + 0.5, 0.5, 0, + 1, 0.5, 0, + 0, 0.5, 0, /* tree 3, quad */ + 0.5, 0.5, 0, + 0, 1, 0, + 0.5, 1, 0, + 0.5, 0.5, 0, /* tree 4, triangle */ + 1, 0.5, 0, + 1, 1, 0, + 0.5, 0.5, 0, /* tree 5, triangle */ + 1, 1, 0, + 0.5, 1, 0 + }; + + /* 2. Initialization of the mesh */ + t8_cmesh_t cmesh; + t8_cmesh_init (&cmesh); + + /* 3. Definition of the geometry */ + t8_geometry_c *linear_geom = t8_geometry_linear_new (2); + t8_cmesh_register_geometry (cmesh, linear_geom); /* Use linear geometry */ + + /* 4. Definition of the classes of the different trees */ + t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_TRIANGLE); + t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_TRIANGLE); + t8_cmesh_set_tree_class (cmesh, 2, T8_ECLASS_QUAD); + t8_cmesh_set_tree_class (cmesh, 3, T8_ECLASS_QUAD); + t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_TRIANGLE); + t8_cmesh_set_tree_class (cmesh, 5, T8_ECLASS_TRIANGLE); + + /* 5. Classification of the vertices for each tree */ + t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 3); + t8_cmesh_set_tree_vertices (cmesh, 1, vertices + 9, 3); + t8_cmesh_set_tree_vertices (cmesh, 2, vertices + 18, 4); + t8_cmesh_set_tree_vertices (cmesh, 3, vertices + 30, 4); + t8_cmesh_set_tree_vertices (cmesh, 4, vertices + 42, 3); + t8_cmesh_set_tree_vertices (cmesh, 5, vertices + 51, 3); + + /* 6. Definition of the face neighboors between the different trees */ + t8_cmesh_set_join (cmesh, 0, 1, 1, 2, 0); + t8_cmesh_set_join (cmesh, 0, 2, 0, 0, 0); + t8_cmesh_set_join (cmesh, 0, 3, 2, 3, 0); + + t8_cmesh_set_join (cmesh, 1, 3, 0, 2, 1); + t8_cmesh_set_join (cmesh, 1, 2, 1, 1, 0); + + t8_cmesh_set_join (cmesh, 2, 4, 3, 2, 0); + t8_cmesh_set_join (cmesh, 2, 5, 2, 0, 1); + + t8_cmesh_set_join (cmesh, 3, 5, 1, 1, 0); + t8_cmesh_set_join (cmesh, 3, 4, 0, 0, 0); + + t8_cmesh_set_join (cmesh, 4, 5, 1, 2, 0); + + /* 7. Commit the mesh */ + t8_cmesh_commit (cmesh, comm); + + return cmesh; +} + +/* Definition of a three dimensional mesh with linear geometry. + * The mesh consists of two tetrahedra, two prisms and one hexahedron. + * */ +t8_cmesh_t +t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) +{ + /* Definition of the mesh according to the above scheme + * // 1. Defining an array with all vertices + * double vertices[ ] = + * { + * 0.43, 0, 2, // Tetrahedron 1 vertices + 0, 0, 1, + 0.86, -0.5, 1, + 0.86, 0.5, 1, + + 2.29, 0, 2, // Tetrahedron 2 vertices + 1.86, -0.5, 1, + 2.72, 0, 1, + 1.86, 0.5, 1, + + 0, 0, 0, // Prism 1 vertices + 0.86, -0.5, 0, + 0.86, 0.5, 0, + 0, 0, 1, + 0.86, -0.5, 1, + 0.86, 0.5, 1, + + 1.86, -0.5, 0, // Prism 2 vertices + 2.72, 0, 0, + 1.86, 0.5, 0, + 1.86, -0.5, 1, + 2.72, 0, 1, + 1.86, 0.5, 1, + + 0.86, -0.5, 0, // Pyramid coordinates + 1.86, -0.5, 0, + 0.86, 0.5, 0, + 1.86, 0.5, 0, + 1.29, 0, 0, + + 0.86, -0.5, 0, // Hex coordinates + 1.86, -0.5, 0, + 0.86, 0.5, 0, + 1.86, 0.5, 0, + 0.86, -0.5, 1, + 1.86, -0.5, 1, + 0.86, 0.5, 1, + 1.86, 0.5, 1 + + * } + * // 2. Initialization of the mesh + * t8_cmesh_t cmesh; + * t8_cmesh_init (&cmesh); + * + * // 3. Definition of the geometry + * t8_geometry_c *linear_geom = t8_geometry_linear_new (3); + * t8_cmesh_register_geometry (cmesh, linear_geom); // Use linear geometry + * + * // 4. Definition of the classes of the different trees + * t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_TET); + * t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_TET); + * t8_cmesh_set_tree_class (cmesh, 2, T8_ECLASS_PRISM); + * t8_cmesh_set_tree_class (cmesh, 3, T8_ECLASS_PRISM); + * t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_PYRAMID); + * t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_HEX); + * + * // 5. Classification of the vertices for each tree + * t8_cmesh_set_tree_vertices (cmesh, 0, vertices + 12, 4); + * t8_cmesh_set_tree_vertices (cmesh, 1, vertices + 24, 4); + * t8_cmesh_set_tree_vertices (cmesh, 2, vertices + 42, 6); + * t8_cmesh_set_tree_vertices (cmesh, 3, vertices + 60, 6); + * t8_cmesh_set_tree_vertices (cmesh, 4, vertices + 78, 5); + * t8_cmesh_set_tree_vertices (cmesh, 5, vertices + 93, 8); + * + * // 6. Definition of the face neighboors between the different trees + * t8_cmesh_set_join (cmesh, 0, 2, 0, 4, 0); + * t8_cmesh_set_join (cmesh, 1, 3, 0, 4, 0); + * t8_cmesh_set_join (cmesh, 2, 5, 0, 0, 0); + * t8_cmesh_set_join (cmesh, 3, 5, 1, 1, 0); + * t8_cmesh_set_join (cmesh, 4, 5, 4, 2, 0); + * + * // 7. Commit the mesh + * t8_cmesh_commit (cmesh, comm); + * + * return cmesh; + * */ + + /* In many cases the points of the different trees are dependent of these of the previous trees + * or of these of the same tree. Then it is reasonable to define the different vertices dependent + * of each other. + * Also the order of the sheme is not fixed. The definition of the face neighboors can be + * before the definition of the vertices. + * In the following example the tree classes are defined, then the face neighboors are set. + * After that the vertices are defined for each tree separate. + * */ + + double vertices[24]; + int i; + t8_geometry_c *linear_geom = t8_geometry_linear_new (3); + + /* Initialization of the mesh */ + t8_cmesh_t cmesh; + t8_cmesh_init (&cmesh); + + /* Definition of the geometry */ + t8_cmesh_register_geometry (cmesh, linear_geom); /* Use linear geometry */ + + /* Defitition of the classes of the different trees */ + t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_TET); + t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_TET); + t8_cmesh_set_tree_class (cmesh, 2, T8_ECLASS_PRISM); + t8_cmesh_set_tree_class (cmesh, 3, T8_ECLASS_PRISM); + t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_PYRAMID); + t8_cmesh_set_tree_class (cmesh, 5, T8_ECLASS_HEX); + + /* Classification of the vertices for each tree */ + t8_cmesh_set_join (cmesh, 0, 2, 0, 4, 0); + t8_cmesh_set_join (cmesh, 1, 3, 0, 4, 0); + t8_cmesh_set_join (cmesh, 2, 5, 0, 0, 0); + t8_cmesh_set_join (cmesh, 3, 5, 1, 1, 0); + t8_cmesh_set_join (cmesh, 4, 5, 4, 2, 0); + + /* + * Definition of the first tree + */ + /* Tetrahedron 1 vertices */ + vertices[0] = 0.43; + vertices[1] = 0; + vertices[2] = 2; + + vertices[3] = 0; + vertices[4] = 0; + vertices[5] = 1; + + vertices[6] = 0.86; + vertices[7] = -0.5; + vertices[8] = 1; + + vertices[9] = 0.86; + vertices[10] = 0.5; + vertices[11] = 1; + + /* Classification of the vertices for the first tree */ + t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 4); + + /* + * Definition of the second tree + */ + /* Tetrahedron 2 vertices */ + for (i = 0; i < 3; i++) { + + vertices[i] = vertices[i] + (i == 0 ? 1 + 0.86 : 0); + vertices[3 + i] = vertices[6 + i] + (i == 0 ? 1 : 0); + vertices[9 + i] = vertices[9 + i] + (i == 0 ? 1 : 0); + } + + vertices[6] = 1 + 2 * 0.86; + vertices[7] = 0; + vertices[8] = 1; + + /* Classification of the vertices for the second tree */ + t8_cmesh_set_tree_vertices (cmesh, 1, vertices, 4); + + /* + * Definition of the third tree + */ + /* Prism 1 vertices */ + vertices[0] = 0; + vertices[1] = 0; + vertices[2] = 0; + + vertices[3] = 0.86; + vertices[4] = -0.5; + vertices[5] = 0; + + vertices[6] = 0.86; + vertices[7] = 0.5; + vertices[8] = 0; + + /* Translate +1 in z-axis for the upper vertices */ + for (i = 0; i < 3; i++) { + vertices[9 + 3 * i] = vertices[3 * i]; + vertices[9 + 3 * i + 1] = vertices[3 * i + 1]; + vertices[9 + 3 * i + 2] = vertices[3 * i + 2] + 1; + } + + /* Classification of the vertices for the third tree */ + t8_cmesh_set_tree_vertices (cmesh, 2, vertices, 6); + + /* + * Definition of the fourth tree + */ + /* Prism 2 vertices */ + for (i = 0; i < 3; i++) { + vertices[3 + i] = vertices[i] + (i == 0 ? 1 + 2 * 0.86 : 0); + vertices[6 + i] = vertices[6 + i] + (i == 0 ? 1 : 0); + } + + vertices[0] = 0.86 + 1; + vertices[1] = -0.5; + vertices[2] = 0; + + /* Translate +1 in z-axis for the upper vertices */ + for (i = 0; i < 3; i++) { + vertices[9 + 3 * i] = vertices[3 * i]; + vertices[9 + 3 * i + 1] = vertices[3 * i + 1]; + vertices[9 + 3 * i + 2] = vertices[3 * i + 2] + 1; + } + + /* Classification of the vertices for the fourth tree */ + t8_cmesh_set_tree_vertices (cmesh, 3, vertices, 6); + + /* + * Definition of the fifth tree + */ + /* Pyramid vertices */ + + vertices[0] = 0.86; + vertices[1] = -0.5; + vertices[2] = 0; + + vertices[3] = 1.86; + vertices[4] = -0.5; + vertices[5] = 0; + + vertices[6] = 0.86; + vertices[7] = 0.5; + vertices[8] = 0; + + vertices[9] = 1.86; + vertices[10] = 0.5; + vertices[11] = 0; + + vertices[12] = 1.36; + vertices[13] = 0; + vertices[14] = -0.5; + + /* Classification of the vertices for the fifth tree */ + t8_cmesh_set_tree_vertices (cmesh, 4, vertices, 5); + + /* + * Definition of the sixth tree + */ + /* Hex coordinates */ + /* Translate +1 in z-axis for the upper vertices */ + for (i = 0; i < 4; i++) { + vertices[12 + 3 * i] = vertices[3 * i]; + vertices[12 + 3 * i + 1] = vertices[3 * i + 1]; + vertices[12 + 3 * i + 2] = vertices[3 * i + 2] + 1; + } + + /* Classification of the vertices for the fifth tree */ + t8_cmesh_set_tree_vertices (cmesh, 5, vertices, 8); + + /* Commit the mesh */ + t8_cmesh_commit (cmesh, comm); + return cmesh; +} + +int +t8_step8_main (int argc, char **argv) +{ + int mpiret; + sc_MPI_Comm comm; + t8_cmesh_t cmesh_2D; + t8_cmesh_t cmesh_3D; + + /* The prefix for our output files. */ + const char *prefix_2D = "t8_step8_user_defined_mesh_2D"; + const char *prefix_3D = "t8_step8_user_defined_mesh_3D"; + + /* + * Initialization. + */ + + /* Initialize MPI. This has to happen before we initialize sc or t8code. */ + mpiret = sc_MPI_Init (&argc, &argv); + /* Error check the MPI return value. */ + SC_CHECK_MPI (mpiret); + + /* Initialize the sc library, has to happen before we initialize t8code. */ + sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_ESSENTIAL); + /* Initialize t8code with log level SC_LP_PRODUCTION. See sc.h for more info on the log levels. */ + t8_init (SC_LP_PRODUCTION); + + /* We will use MPI_COMM_WORLD as a communicator. */ + comm = sc_MPI_COMM_WORLD; + + /* + * Definition of the meshes. + */ + /* Creation of a two dimensional cmesh with periodic boundaries. */ + cmesh_2D = t8_cmesh_new_periodic_hybrid_2d (comm); + + /* Creation of a three dimensional cmesh */ + cmesh_3D = t8_cmesh_new_hybrid_gate_3d (comm); + + /* Output the meshes to vtu files. */ + t8_cmesh_vtk_write_file (cmesh_2D, prefix_2D, 1.0); + t8_cmesh_vtk_write_file (cmesh_3D, prefix_3D, 1.0); + + /* + * Clean-up + */ + sc_finalize (); + + mpiret = sc_MPI_Finalize (); + SC_CHECK_MPI (mpiret); + + return 0; +} + +T8_EXTERN_C_END (); diff --git a/tutorials/general/t8_tutorial_build_cmesh.h b/tutorials/general/t8_tutorial_build_cmesh.h index 88552ec9a5..31c9936897 100644 --- a/tutorials/general/t8_tutorial_build_cmesh.h +++ b/tutorials/general/t8_tutorial_build_cmesh.h @@ -1,39 +1,39 @@ -/* - This file is part of t8code. - t8code is a C library to manage a collection (a forest) of multiple - connected adaptive space-trees of general element classes in parallel. - - Copyright (C) 2015 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -/** file t8_step8.h - */ - -#ifndef T8_STEP8_H -#define T8_STEP8_H - -#include - -T8_EXTERN_C_BEGIN (); - -/** This is the main program of this example. - */ -int t8_step8_main (int argc, char **argv); - -T8_EXTERN_C_END (); - -#endif /* !T8_STEP8_H */ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** file t8_step8.h + */ + +#ifndef T8_STEP8_H +#define T8_STEP8_H + +#include + +T8_EXTERN_C_BEGIN (); + +/** This is the main program of this example. + */ +int t8_step8_main (int argc, char **argv); + +T8_EXTERN_C_END (); + +#endif /* !T8_STEP8_H */ diff --git a/tutorials/general/t8_tutorial_build_cmesh_main.cxx b/tutorials/general/t8_tutorial_build_cmesh_main.cxx index f2eba66831..58b96337a9 100644 --- a/tutorials/general/t8_tutorial_build_cmesh_main.cxx +++ b/tutorials/general/t8_tutorial_build_cmesh_main.cxx @@ -1,35 +1,34 @@ -/* - This file is part of t8code. - t8code is a C library to manage a collection (a forest) of multiple - connected adaptive space-trees of general element types in parallel. - - Copyright (C) 2023 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -/* This file is part of the step6 example of t8code. - * Here, we only wrap the main function. See t8_step8_user_defined_mesh.cxx for the documentation of - * the step8 example. - */ - -#include - -int -main (int argc, char **argv) -{ - return t8_step8_main (argc, argv); -} - \ No newline at end of file +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element types in parallel. + + Copyright (C) 2023 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/* This file is part of the step6 example of t8code. + * Here, we only wrap the main function. See t8_step8_user_defined_mesh.cxx for the documentation of + * the step8 example. + */ + +#include + +int +main (int argc, char **argv) +{ + return t8_step8_main (argc, argv); +} From cd20d80b712db6dcefe6324c4981fc9e39c95fe4 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Mon, 22 May 2023 22:37:22 +0200 Subject: [PATCH 211/255] Indent files --- tutorials/general/t8_step7.h | 2 +- tutorials/general/t8_step7_interpolation.cxx | 838 +++++++++---------- 2 files changed, 418 insertions(+), 422 deletions(-) diff --git a/tutorials/general/t8_step7.h b/tutorials/general/t8_step7.h index 39103e1900..9ef9374aa8 100644 --- a/tutorials/general/t8_step7.h +++ b/tutorials/general/t8_step7.h @@ -37,7 +37,7 @@ struct t8_step7_adapt_data double midpoint[3]; /* The midpoint of our sphere. */ double refine_if_inside_radius; /* if an element's center is smaller than this value, we refine the element. */ double coarsen_if_outside_radius; /* if an element's center is larger this value, we coarsen its family. */ - double *element_data; + double *element_data; }; /** This is the main program of this example. diff --git a/tutorials/general/t8_step7_interpolation.cxx b/tutorials/general/t8_step7_interpolation.cxx index 3bdfb6f800..8ca1e806d5 100644 --- a/tutorials/general/t8_step7_interpolation.cxx +++ b/tutorials/general/t8_step7_interpolation.cxx @@ -1,421 +1,417 @@ -#include -#include -#include -#include -#include -#include -#include /* geometrical information of the forest */ -#include -#include -#include -#include -#include -#include "t8_cmesh/t8_cmesh_testcases.h" -#include - -#include - -T8_EXTERN_C_BEGIN (); - -/* The data that we want to store for each element. -In this tutorial we will store the distance to the centroid in the data. -You can store more than one element here (see for example tutorial - step 5). */ -struct t8_step7_element_data_t -{ - /* Storage for ourelemet values. */ - double values; - -}; - -/* This is our own defined data that we will pass on to the - * adaptation callback. */ -struct t8_step7_adapt_data -{ - double midpoint[3]; /* The midpoint of our sphere. */ - double refine_if_inside_radius; /* if an element's center is smaller than this value, we refine the element. */ - double coarsen_if_outside_radius; /* if an element's center is larger this value, we coarsen its family. */ - t8_step7_element_data_t *element_data; -}; - -/* This is our own defined data that we will pass on to the - * adaptation callback. */ - -/* The adaptation callback function. This function will be called once for each element - * and the return value decides whether this element should be refined or not. - * return > 0 -> This element should get refined. - * return = 0 -> This element should not get refined. - * If the current element is the first element of a family (= all level l elements that arise from refining - * the same level l-1 element) then this function is called with the whole family of elements - * as input and the return value additionally decides whether the whole family should get coarsened. - * return > 0 -> The first element should get refined. - * return = 0 -> The first element should not get refined. - * return < 0 -> The whole family should get coarsened. - * - * \param [in] forest The current forest that is in construction. - * \param [in] forest_from The forest from which we adapt the current forest (in our case, the uniform forest) - * \param [in] which_tree The process local id of the current tree. - * \param [in] lelement_id The tree local index of the current element (or the first of the family). - * \param [in] ts The refinement scheme for this tree's element class. - * \param [in] is_family if 1, the first \a num_elements entries in \a elements form a family. If 0, they do not. - * \param [in] num_elements The number of entries in \a elements elements that are defined. - * \param [in] elements The element or family of elements to consider for refinement/coarsening. - */ -int -t8_step7_adapt_callback (t8_forest_t forest, - t8_forest_t forest_from, - t8_locidx_t which_tree, - t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, - const int is_family, - const int num_elements, t8_element_t *elements[]) -{ - /* Our adaptation criterion is to look at the midpoint coordinates of the current element and if - * they are inside a sphere around a given midpoint we refine, if they are outside, we coarsen. */ - double centroid[3]; /* Will hold the element midpoint. */ - /* In t8_step3_adapt_forest we pass a t8_step3_adapt_data pointer as user data to the - * t8_forest_new_adapt function. This pointer is stored as the used data of the new forest - * and we can now access it with t8_forest_get_user_data (forest). */ - const struct t8_step7_adapt_data *adapt_data = - (const struct t8_step7_adapt_data *) t8_forest_get_user_data (forest); - double dist; /* Will store the distance of the element's midpoint and the sphere midpoint. */ - - /* You can use T8_ASSERT for assertions that are active in debug mode (when configured with --enable-debug). - * If the condition is not true, then the code will abort. - * In this case, we want to make sure that we actually did set a user pointer to forest and thus - * did not get the NULL pointer from t8_forest_get_user_data. - */ - T8_ASSERT (adapt_data != NULL); - - /* Compute the element's centroid coordinates. */ - t8_forest_element_centroid (forest_from, which_tree, elements[0], centroid); - - /* Compute the distance to our sphere midpoint. */ - dist = t8_vec_dist (centroid, adapt_data->midpoint); - if (dist < adapt_data->refine_if_inside_radius) { - /* Refine this element. */ - return 1; - } - else if (is_family && dist > adapt_data->coarsen_if_outside_radius) { - /* Coarsen this family. Note that we check for is_family before, since returning < 0 - * if we do not have a family as input is illegal. */ - return -1; - } - /* Do not change this element. */ - return 0; -} - -/* Callback function, where no element is refined or coarsened. - */ -int -t8_adapt_non (t8_forest_t forest, - t8_forest_t forest_from, - t8_locidx_t which_tree, - t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, - const int is_family, - const int num_elements, t8_element_t *elements[]) -{ - return 0; -} - -/* Adapt a forest according to a callback function. - * This will create a new forest and return it. - * Create a new forest that is adapted from \a forest with our adaptation callback. - * We provide the adapt_data as user data that is stored as the used_data pointer of the - * new forest (see also t8_forest_set_user_data). - * The 0, 0 arguments are flags that control - * \param [in] forest_from Forest that should be adapted - * \param [in] adapt_fn Function that defines how to adapt the forest - Callback function - * \param [in] do_partition If non-zero the new_forest should partition the existing forest. As the second parameter - is set to NULL, a previously (or later) set forest will be taken - (\ref t8_forest_set_adapt, \ref t8_forest_set_balance). - * \param [in] recursive If non-zero adaptation is recursive, thus if an element is adapted the children - * or parents are plugged into the callback again recursively until the forest does not - * change any more. If you use this you should ensure that refinement will stop eventually. - * One way is to check the element's level against a given maximum level. - * \param [in] do_face_ghost If non-zero additionally a layer of ghost elements is created for the forest. - * We will discuss ghost in later steps of the tutorial. - * \param [in] user_data User defined data array to store on the forest - */ -t8_forest_t -t8_adapt_forest (t8_forest_t forest_from, t8_forest_adapt_t adapt_fn, - int do_partition, int recursive, int do_face_ghost, void *user_data) -{ - t8_forest_t forest_new; - - t8_forest_init (&forest_new); - /* Adapt the forest */ - t8_forest_set_adapt (forest_new, forest_from, adapt_fn, recursive); - - /* Set user data for the adapted forest */ - if (user_data != NULL) { - t8_forest_set_user_data (forest_new, user_data); - } - /* Create ghost elements */ - t8_forest_set_ghost (forest_new, do_face_ghost, T8_GHOST_FACES); - if (do_partition) { - t8_forest_set_partition (forest_new, NULL, 0); - } - /* Commit the adapted forest */ - t8_forest_commit (forest_new); - - return forest_new; -} - -/* Replace callback to decide how to interpolate a refined or coarsened element. - * If an element is refined, each child gets the phi value of its parent. - * If elements are coarsened, the parent gets the average phi value of the children. - * Outgoing are the old elements and incoming the new ones - * \param [in] forest_old non adapted forest - * \param [in] forest_new adapted forest - * \param [in] which_tree tree_id of the analyzed element - * \param [in] ts eclass sheme - * \param [in] refine ==0 - do nothing, == -1 - coarsen, == 1 - refine - * \param [in] num_outgoing number of the elements not refined forest - * \param [in] first_outgoing index of the old element - * \param [in] num_incoming number of the elements corresponding to the element of the not refined forest - * \param [in] first_incoming index of the new element - */ -void -t8_forest_replace (t8_forest_t forest_old, - t8_forest_t forest_new, - t8_locidx_t which_tree, - t8_eclass_scheme_c *ts, - int refine, - int num_outgoing, - t8_locidx_t first_outgoing, - int num_incoming, - t8_locidx_t first_incoming) -{ - int i; - const struct t8_step7_adapt_data *adapt_data_new = - (const struct t8_step7_adapt_data *) t8_forest_get_user_data (forest_new); - const struct t8_step7_adapt_data *adapt_data_old = - (const struct t8_step7_adapt_data *) t8_forest_get_user_data (forest_old); - - /* get the index of the data array corresponding to the old and the adapted forest */ - for (t8_locidx_t t = 0; t < which_tree; t++) - { - first_incoming += t8_forest_get_tree_num_elements (forest_new, t); - first_outgoing += t8_forest_get_tree_num_elements (forest_old, t); - } - /* Do not adapt or coarsen */ - if (refine == 0) { - adapt_data_new->element_data[first_incoming] = - adapt_data_old->element_data[first_outgoing]; - } - /* The old element is refined, we copy the element values */ - else if (refine == 1) { - for (i = 0; i < num_incoming; i++) { - adapt_data_new->element_data[first_incoming + i] = adapt_data_old->element_data[first_outgoing]; - } - } - /* Old element is coarsened */ - else if (refine == -1) { - adapt_data_new->element_data[first_incoming].values = 0; - for (t8_locidx_t i = 0; i < num_outgoing; i++) { - adapt_data_old->element_data[first_outgoing+i].values; - adapt_data_new->element_data[first_incoming].values += - adapt_data_old->element_data[first_outgoing+i].values; - } - adapt_data_new->element_data[first_incoming].values /= num_outgoing; - } -} - -/* Each process has computed the data entries for its local elements. - * In order to get the values for the ghost elements, we use t8_forest_ghost_exchange_data. - * Calling this function will fill all the ghost entries of our element data array with the - * value on the process that owns the corresponding element. */ -static void -t8_step7_exchange_ghost_data (t8_forest_t forest, - struct t8_step7_element_data_t *data) -{ - sc_array *sc_array_wrapper; - t8_locidx_t num_elements = - t8_forest_get_local_num_elements (forest); - t8_locidx_t num_ghosts = t8_forest_get_num_ghosts (forest); - - /* t8_forest_ghost_exchange_data expects an sc_array (of length num_local_elements + num_ghosts). - * We wrap our data array to an sc_array. */ - sc_array_wrapper = - sc_array_new_data (data, sizeof (struct t8_step7_element_data_t), - num_elements + num_ghosts); - - /* Carry out the data exchange. The entries with indices > num_local_elements will get overwritten. */ - t8_forest_ghost_exchange_data (forest, sc_array_wrapper); - - /* Destroy the wrapper array. This will not free the data memory since we used sc_array_new_data. */ - sc_array_destroy (sc_array_wrapper); -} - -/* Write the forest and the data corresponding to the forest in a vtu file. - * - * \param [in] forest Forest that should written in the vtu file - * \param [in] data Data corresponding to the forest - * \param [in] prefix Prefix to define the file name - */ -static void -t8_write_vtu (t8_forest_t forest, - struct t8_step7_adapt_data *data, - const char *prefix) -{ - t8_locidx_t num_elements = - t8_forest_get_local_num_elements (forest); - t8_locidx_t ielem; - /* We need to allocate a new array to store the volumes on their own. - * This array has one entry per local element. */ - double *element_data = T8_ALLOC (double, num_elements); - /* The number of user defined data fields to write. */ - int num_data = 1; - t8_vtk_data_field_t vtk_data; - vtk_data.type = T8_VTK_SCALAR; - strcpy (vtk_data.description, "Element own data"); - vtk_data.data = element_data; - /* Copy the elment's data from the data array to the output array. */ - for (ielem = 0; ielem < num_elements; ++ielem) { - element_data[ielem] = (data->element_data[ielem]).values; - } - - { - /* To write user defined data, we need to extended output function t8_forest_vtk_write_file - * from t8_forest_vtk.h. Despite writin user data, it also offers more control over which - * properties of the forest to write. */ - int write_treeid = 1; - int write_mpirank = 1; - int write_level = 1; - int write_element_id = 1; - int write_ghosts = 0; - t8_forest_write_vtk_ext (forest, prefix, write_treeid, write_mpirank, - write_level, write_element_id, write_ghosts, - 0, 0, num_data, &vtk_data); - } - T8_FREE (element_data); -} - -/* In this function the interpolation is described. In a first step a - * hypercubic cmesh and then a forest is created. - * We create a data array with the distance to the centroid of each cell. - * The forest is adapted and the data array is interpolated corresponding to - * the adapted forest. - * We write the uniform and the adapted forest to a vtu file. - */ -void -t8_interpolation() { - int level = 4; - t8_cmesh_t cmesh; - t8_forest_t forest_adapt, forest; - t8_scheme_cxx_t *scheme; - t8_step7_element_data_t *data, *data_adapt; - t8_locidx_t numElem; - t8_locidx_t numTrees; - int itree, ielemTree, ielem; - t8_element_t *element; - double centroid[3]; - double midpoint[3] = {0.5, 0.5, 1}; - - scheme = t8_scheme_new_default_cxx (); - - /* Construct a cmesh */ - cmesh = t8_cmesh_new_hypercube (T8_ECLASS_PYRAMID, sc_MPI_COMM_WORLD, 0, 0, 0); - - forest = t8_forest_new_uniform (cmesh, scheme, level, 0, sc_MPI_COMM_WORLD); - - /* Build initial data array and set data for the local elements. */ - data = T8_ALLOC (t8_step7_element_data_t, t8_forest_get_local_num_elements (forest)); - for (t8_locidx_t i = 0; i < t8_forest_get_local_num_elements (forest); i++) { - - } - - numTrees = t8_forest_get_num_local_trees( forest ); - /* Loop over all trees. The index of the data array is independent of the tree - * index. Thus, we set the index of the tree index to zero and add one in each - * loop step of the inner loop. - */ - for( itree=0, ielem=0; itree +#include +#include +#include +#include +#include +#include /* geometrical information of the forest */ +#include +#include +#include +#include +#include +#include "t8_cmesh/t8_cmesh_testcases.h" +#include + +#include + +T8_EXTERN_C_BEGIN (); + +/* The data that we want to store for each element. +In this tutorial we will store the distance to the centroid in the data. +You can store more than one element here (see for example tutorial - step 5). */ +struct t8_step7_element_data_t +{ + /* Storage for our elemet values. */ + double values; + +}; + +/* This is our own defined data that we will pass on to the + * adaptation callback. */ +struct t8_step7_adapt_data +{ + double midpoint[3]; /* The midpoint of our sphere. */ + double refine_if_inside_radius; /* if an element's center is smaller than this value, we refine the element. */ + double coarsen_if_outside_radius; /* if an element's center is larger this value, we coarsen its family. */ + t8_step7_element_data_t *element_data; +}; + +/* This is our own defined data that we will pass on to the + * adaptation callback. */ + +/* The adaptation callback function. This function will be called once for each element + * and the return value decides whether this element should be refined or not. + * return > 0 -> This element should get refined. + * return = 0 -> This element should not get refined. + * If the current element is the first element of a family (= all level l elements that arise from refining + * the same level l-1 element) then this function is called with the whole family of elements + * as input and the return value additionally decides whether the whole family should get coarsened. + * return > 0 -> The first element should get refined. + * return = 0 -> The first element should not get refined. + * return < 0 -> The whole family should get coarsened. + * + * \param [in] forest The current forest that is in construction. + * \param [in] forest_from The forest from which we adapt the current forest (in our case, the uniform forest) + * \param [in] which_tree The process local id of the current tree. + * \param [in] lelement_id The tree local index of the current element (or the first of the family). + * \param [in] ts The refinement scheme for this tree's element class. + * \param [in] is_family if 1, the first \a num_elements entries in \a elements form a family. If 0, they do not. + * \param [in] num_elements The number of entries in \a elements elements that are defined. + * \param [in] elements The element or family of elements to consider for refinement/coarsening. + */ +int +t8_step7_adapt_callback (t8_forest_t forest, + t8_forest_t forest_from, + t8_locidx_t which_tree, + t8_locidx_t lelement_id, + t8_eclass_scheme_c *ts, + const int is_family, + const int num_elements, t8_element_t *elements[]) +{ + /* Our adaptation criterion is to look at the midpoint coordinates of the current element and if + * they are inside a sphere around a given midpoint we refine, if they are outside, we coarsen. */ + double centroid[3]; /* Will hold the element midpoint. */ + /* In t8_step3_adapt_forest we pass a t8_step3_adapt_data pointer as user data to the + * t8_forest_new_adapt function. This pointer is stored as the used data of the new forest + * and we can now access it with t8_forest_get_user_data (forest). */ + const struct t8_step7_adapt_data *adapt_data = + (const struct t8_step7_adapt_data *) t8_forest_get_user_data (forest); + double dist; /* Will store the distance of the element's midpoint and the sphere midpoint. */ + + /* You can use T8_ASSERT for assertions that are active in debug mode (when configured with --enable-debug). + * If the condition is not true, then the code will abort. + * In this case, we want to make sure that we actually did set a user pointer to forest and thus + * did not get the NULL pointer from t8_forest_get_user_data. + */ + T8_ASSERT (adapt_data != NULL); + + /* Compute the element's centroid coordinates. */ + t8_forest_element_centroid (forest_from, which_tree, elements[0], centroid); + + /* Compute the distance to our sphere midpoint. */ + dist = t8_vec_dist (centroid, adapt_data->midpoint); + if (dist < adapt_data->refine_if_inside_radius) { + /* Refine this element. */ + return 1; + } + else if (is_family && dist > adapt_data->coarsen_if_outside_radius) { + /* Coarsen this family. Note that we check for is_family before, since returning < 0 + * if we do not have a family as input is illegal. */ + return -1; + } + /* Do not change this element. */ + return 0; +} + +/* Callback function, where no element is refined or coarsened. + */ +int +t8_adapt_non (t8_forest_t forest, + t8_forest_t forest_from, + t8_locidx_t which_tree, + t8_locidx_t lelement_id, + t8_eclass_scheme_c *ts, + const int is_family, + const int num_elements, t8_element_t *elements[]) +{ + return 0; +} + +/* Adapt a forest according to a callback function. + * This will create a new forest and return it. + * Create a new forest that is adapted from \a forest with our adaptation callback. + * We provide the adapt_data as user data that is stored as the used_data pointer of the + * new forest (see also t8_forest_set_user_data). + * The 0, 0 arguments are flags that control + * \param [in] forest_from Forest that should be adapted + * \param [in] adapt_fn Function that defines how to adapt the forest - Callback function + * \param [in] do_partition If non-zero the new_forest should partition the existing forest. As the second parameter + is set to NULL, a previously (or later) set forest will be taken + (\ref t8_forest_set_adapt, \ref t8_forest_set_balance). + * \param [in] recursive If non-zero adaptation is recursive, thus if an element is adapted the children + * or parents are plugged into the callback again recursively until the forest does not + * change any more. If you use this you should ensure that refinement will stop eventually. + * One way is to check the element's level against a given maximum level. + * \param [in] do_face_ghost If non-zero additionally a layer of ghost elements is created for the forest. + * We will discuss ghost in later steps of the tutorial. + * \param [in] user_data User defined data array to store on the forest + */ +t8_forest_t +t8_adapt_forest (t8_forest_t forest_from, t8_forest_adapt_t adapt_fn, + int do_partition, int recursive, int do_face_ghost, + void *user_data) +{ + t8_forest_t forest_new; + + t8_forest_init (&forest_new); + /* Adapt the forest */ + t8_forest_set_adapt (forest_new, forest_from, adapt_fn, recursive); + + /* Set user data for the adapted forest */ + if (user_data != NULL) { + t8_forest_set_user_data (forest_new, user_data); + } + /* Create ghost elements */ + t8_forest_set_ghost (forest_new, do_face_ghost, T8_GHOST_FACES); + if (do_partition) { + t8_forest_set_partition (forest_new, NULL, 0); + } + /* Commit the adapted forest */ + t8_forest_commit (forest_new); + + return forest_new; +} + +/* Replace callback to decide how to interpolate a refined or coarsened element. + * If an element is refined, each child gets the phi value of its parent. + * If elements are coarsened, the parent gets the average phi value of the children. + * Outgoing are the old elements and incoming the new ones + * \param [in] forest_old non adapted forest + * \param [in] forest_new adapted forest + * \param [in] which_tree tree_id of the analyzed element + * \param [in] ts eclass sheme + * \param [in] refine ==0 - do nothing, == -1 - coarsen, == 1 - refine + * \param [in] num_outgoing number of the elements not refined forest + * \param [in] first_outgoing index of the old element + * \param [in] num_incoming number of the elements corresponding to the element of the not refined forest + * \param [in] first_incoming index of the new element + */ +void +t8_forest_replace (t8_forest_t forest_old, + t8_forest_t forest_new, + t8_locidx_t which_tree, + t8_eclass_scheme_c *ts, + int refine, + int num_outgoing, + t8_locidx_t first_outgoing, + int num_incoming, t8_locidx_t first_incoming) +{ + int i; + const struct t8_step7_adapt_data *adapt_data_new = + (const struct t8_step7_adapt_data *) t8_forest_get_user_data (forest_new); + const struct t8_step7_adapt_data *adapt_data_old = + (const struct t8_step7_adapt_data *) t8_forest_get_user_data (forest_old); + + /* get the index of the data array corresponding to the old and the adapted forest */ + for (t8_locidx_t t = 0; t < which_tree; t++) { + first_incoming += t8_forest_get_tree_num_elements (forest_new, t); + first_outgoing += t8_forest_get_tree_num_elements (forest_old, t); + } + /* Do not adapt or coarsen */ + if (refine == 0) { + adapt_data_new->element_data[first_incoming] = + adapt_data_old->element_data[first_outgoing]; + } + /* The old element is refined, we copy the element values */ + else if (refine == 1) { + for (i = 0; i < num_incoming; i++) { + adapt_data_new->element_data[first_incoming + i] = + adapt_data_old->element_data[first_outgoing]; + } + } + /* Old element is coarsened */ + else if (refine == -1) { + adapt_data_new->element_data[first_incoming].values = 0; + for (t8_locidx_t i = 0; i < num_outgoing; i++) { + adapt_data_old->element_data[first_outgoing + i].values; + adapt_data_new->element_data[first_incoming].values += + adapt_data_old->element_data[first_outgoing + i].values; + } + adapt_data_new->element_data[first_incoming].values /= num_outgoing; + } +} + +/* Each process has computed the data entries for its local elements. + * In order to get the values for the ghost elements, we use t8_forest_ghost_exchange_data. + * Calling this function will fill all the ghost entries of our element data array with the + * value on the process that owns the corresponding element. */ +static void +t8_step7_exchange_ghost_data (t8_forest_t forest, + struct t8_step7_element_data_t *data) +{ + sc_array *sc_array_wrapper; + t8_locidx_t num_elements = + t8_forest_get_local_num_elements (forest); + t8_locidx_t num_ghosts = t8_forest_get_num_ghosts (forest); + + /* t8_forest_ghost_exchange_data expects an sc_array (of length num_local_elements + num_ghosts). + * We wrap our data array to an sc_array. */ + sc_array_wrapper = + sc_array_new_data (data, sizeof (struct t8_step7_element_data_t), + num_elements + num_ghosts); + + /* Carry out the data exchange. The entries with indices > num_local_elements will get overwritten. */ + t8_forest_ghost_exchange_data (forest, sc_array_wrapper); + + /* Destroy the wrapper array. This will not free the data memory since we used sc_array_new_data. */ + sc_array_destroy (sc_array_wrapper); +} + +/* Write the forest and the data corresponding to the forest in a vtu file. + * + * \param [in] forest Forest that should written in the vtu file + * \param [in] data Data corresponding to the forest + * \param [in] prefix Prefix to define the file name + */ +static void +t8_write_vtu (t8_forest_t forest, + struct t8_step7_adapt_data *data, const char *prefix) +{ + t8_locidx_t num_elements = + t8_forest_get_local_num_elements (forest); + t8_locidx_t ielem; + /* We need to allocate a new array to store the volumes on their own. + * This array has one entry per local element. */ + double *element_data = T8_ALLOC (double, num_elements); + /* The number of user defined data fields to write. */ + int num_data = 1; + t8_vtk_data_field_t vtk_data; + vtk_data.type = T8_VTK_SCALAR; + strcpy (vtk_data.description, "Element own data"); + vtk_data.data = element_data; + /* Copy the elment's data from the data array to the output array. */ + for (ielem = 0; ielem < num_elements; ++ielem) { + element_data[ielem] = (data->element_data[ielem]).values; + } + + { + /* To write user defined data, we need to extended output function t8_forest_vtk_write_file + * from t8_forest_vtk.h. Despite writin user data, it also offers more control over which + * properties of the forest to write. */ + int write_treeid = 1; + int write_mpirank = 1; + int write_level = 1; + int write_element_id = 1; + int write_ghosts = 0; + t8_forest_write_vtk_ext (forest, prefix, write_treeid, write_mpirank, + write_level, write_element_id, write_ghosts, + 0, 0, num_data, &vtk_data); + } + T8_FREE (element_data); +} + +/* In this function the interpolation is described. In a first step a + * hypercubic cmesh and then a forest is created. + * We create a data array with the distance to the centroid of each cell. + * The forest is adapted and the data array is interpolated corresponding to + * the adapted forest. + * We write the uniform and the adapted forest to a vtu file. + */ +void +t8_interpolation () +{ + int level = 4; + t8_cmesh_t cmesh; + t8_forest_t forest_adapt, forest; + t8_scheme_cxx_t *scheme; + t8_step7_element_data_t *data, *data_adapt; + t8_locidx_t numElem; + t8_locidx_t numTrees; + int itree, ielemTree, ielem; + t8_element_t *element; + double centroid[3]; + double midpoint[3] = { 0.5, 0.5, 1 }; + + scheme = t8_scheme_new_default_cxx (); + + /* Construct a cmesh */ + cmesh = + t8_cmesh_new_hypercube (T8_ECLASS_PYRAMID, sc_MPI_COMM_WORLD, 0, 0, 0); + + forest = t8_forest_new_uniform (cmesh, scheme, level, 0, sc_MPI_COMM_WORLD); + + /* Build initial data array and set data for the local elements. */ + data = + T8_ALLOC (t8_step7_element_data_t, + t8_forest_get_local_num_elements (forest)); + + numTrees = t8_forest_get_num_local_trees (forest); + /* Loop over all trees. The index of the data array is independent of the tree + * index. Thus, we set the index of the tree index to zero and add one in each + * loop step of the inner loop. + */ + for (itree = 0, ielem = 0; itree < numTrees; itree++) { + numElem = t8_forest_get_tree_num_elements (forest, itree); + /* Inner loop: Iteration over the elements of the local tree */ + for (ielemTree = 0; ielemTree < numElem; ielemTree++, ielem++) { + /* To calculate the distance to the centroid of an element the element is saved */ + element = t8_forest_get_element_in_tree (forest, itree, ielemTree); + + /* Get the centroid of the local element. */ + t8_forest_element_centroid (forest, 0, element, centroid); + /* Calculation of the distance to the centroid for the referenced element */ + data[ielem].values = t8_vec_dist (centroid, midpoint); + + } + } + + /* The data to adapt the forest and the data on the forest is saved in a variable saved on the forest */ + struct t8_step7_adapt_data adapt_data = { + {0.5, 0.5, 1}, /* Midpoints of the sphere. */ + 0.2, /* Refine if inside this radius. */ + 0.4, /* Coarsen if outside this radius. */ + data /* Data array */ + }; + /* Save the data on the forest - do not adapt the forest */ + forest = t8_adapt_forest (forest, t8_adapt_non, 0, 0, 0, &adapt_data); + + /* Write vtu file */ + t8_write_vtu (forest, &adapt_data, "t8_step7_uniform_forest"); + + /* Ghost exchange data */ + t8_step7_exchange_ghost_data (forest, data); + + /* Build a second forest to store the adapted forest - keep the old one */ + t8_forest_ref (forest); + t8_forest_init (&forest_adapt); + + /* Adapt the forest correponding tho the callback function (distance to the centroid) */ + forest_adapt = + t8_adapt_forest (forest, t8_step7_adapt_callback, 0, 0, 0, &adapt_data); + /* Calculate/Interpolate the data array for the adapted forest */ + t8_forest_iterate_replace (forest_adapt, forest, t8_forest_replace); + + /* Write the adapted forest to a vtu file */ + t8_write_vtu (forest_adapt, &adapt_data, "t8_step7_adapt_forest"); + + /* Save the new forest as old forest */ + forest = forest_adapt; + data = data_adapt; + + /* As the forest and the data of the adapted forest are now saved as forest, we dont need the variables forest_adapt and data_adapt */ + T8_FREE (data_adapt); + t8_forest_unref (&forest_adapt); + + /* Now you could continue working with the forest. */ + T8_FREE (data); + t8_forest_unref (&forest); +} + +int +t8_step7_main (int argc, char **argv) +{ + int mpiret; + + /* Initialize MPI. This has to happen before we initialize sc or t8code. */ + mpiret = sc_MPI_Init (&argc, &argv); + /* Error check the MPI return value. */ + SC_CHECK_MPI (mpiret); + + /* Initialize the sc library, has to happen before we initialize t8code. */ + sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_PRODUCTION); + /* Initialize t8code with log level SC_LP_PRODUCTION. See sc.h for more info on the log levels. */ + t8_init (SC_LP_DEFAULT); + + /* Create forest, define data on forest, adapt forest, interpolate data */ + t8_interpolation (); + + sc_finalize (); + + mpiret = sc_MPI_Finalize (); + SC_CHECK_MPI (mpiret); + + return 0; +} + +T8_EXTERN_C_END (); From 73dfe370a1d59cdeb04f4f68150e2a773d35d7b1 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Wed, 24 May 2023 09:45:19 +0200 Subject: [PATCH 212/255] Add review changes --- tutorials/general/t8_tutorial_build_cmesh.cxx | 21 +++++++++---------- tutorials/general/t8_tutorial_build_cmesh.h | 2 +- .../general/t8_tutorial_build_cmesh_main.cxx | 8 +++---- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/tutorials/general/t8_tutorial_build_cmesh.cxx b/tutorials/general/t8_tutorial_build_cmesh.cxx index 0c693a40f8..d0cb1cadc9 100644 --- a/tutorials/general/t8_tutorial_build_cmesh.cxx +++ b/tutorials/general/t8_tutorial_build_cmesh.cxx @@ -20,14 +20,14 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* See also: https://github.com/DLR-AMR/t8code/wiki/Step-6-Computing-stencils +/* See also: https://github.com/DLR-AMR/t8code/wiki/Build-Cmesh * - * This is step8 of the t8code tutorials using the C++ interface of t8code. + * This is a tutorial regarding the creation of a cmesh using the C++ interface of t8code. * In the following we will create two user defined meshes. * The first example is given by a periodic two dimensional mesh using linear * geometry consisting of four triangles and and two quads. * The second example is given by a non-periodic three dimensional mesh - * with linear geometry constructed using one tetrahedron, two prisms and one + * with linear geometry constructed using two tetrahedra, two prisms, one pyramid, and one * hexaedron. * * How you can experiment here: @@ -191,7 +191,7 @@ t8_cmesh_new_periodic_hybrid_2d (sc_MPI_Comm comm) t8_cmesh_set_tree_vertices (cmesh, 4, vertices + 42, 3); t8_cmesh_set_tree_vertices (cmesh, 5, vertices + 51, 3); - /* 6. Definition of the face neighboors between the different trees */ + /* 6. Definition of the face neighbors between the different trees */ t8_cmesh_set_join (cmesh, 0, 1, 1, 2, 0); t8_cmesh_set_join (cmesh, 0, 2, 0, 0, 0); t8_cmesh_set_join (cmesh, 0, 3, 2, 3, 0); @@ -214,7 +214,7 @@ t8_cmesh_new_periodic_hybrid_2d (sc_MPI_Comm comm) } /* Definition of a three dimensional mesh with linear geometry. - * The mesh consists of two tetrahedra, two prisms and one hexahedron. + * The mesh consists of two tetrahedra, two prisms, one pyramid, and one hexahedron. * */ t8_cmesh_t t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) @@ -429,21 +429,20 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) * Definition of the fifth tree */ /* Pyramid vertices */ - vertices[0] = 0.86; - vertices[1] = -0.5; + vertices[1] = 0.5; vertices[2] = 0; vertices[3] = 1.86; - vertices[4] = -0.5; + vertices[4] = 0.5; vertices[5] = 0; vertices[6] = 0.86; - vertices[7] = 0.5; + vertices[7] = -0.5; vertices[8] = 0; vertices[9] = 1.86; - vertices[10] = 0.5; + vertices[10] = -0.5; vertices[11] = 0; vertices[12] = 1.36; @@ -473,7 +472,7 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) } int -t8_step8_main (int argc, char **argv) +t8_tutorial_build_cmesh_main (int argc, char **argv) { int mpiret; sc_MPI_Comm comm; diff --git a/tutorials/general/t8_tutorial_build_cmesh.h b/tutorials/general/t8_tutorial_build_cmesh.h index 31c9936897..72f4b6f1e0 100644 --- a/tutorials/general/t8_tutorial_build_cmesh.h +++ b/tutorials/general/t8_tutorial_build_cmesh.h @@ -32,7 +32,7 @@ T8_EXTERN_C_BEGIN (); /** This is the main program of this example. */ -int t8_step8_main (int argc, char **argv); +int t8_tutorial_build_cmesh_main (int argc, char **argv); T8_EXTERN_C_END (); diff --git a/tutorials/general/t8_tutorial_build_cmesh_main.cxx b/tutorials/general/t8_tutorial_build_cmesh_main.cxx index 58b96337a9..55ef3c5a1f 100644 --- a/tutorials/general/t8_tutorial_build_cmesh_main.cxx +++ b/tutorials/general/t8_tutorial_build_cmesh_main.cxx @@ -20,9 +20,9 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* This file is part of the step6 example of t8code. - * Here, we only wrap the main function. See t8_step8_user_defined_mesh.cxx for the documentation of - * the step8 example. +/* This file is part of the t8code tutorial regarding the creation of a scmesh. + * Here, we only wrap the main function. See t8_tutorial_build_cmesh.cxx for the documentation of + * the 'build-cmesh'-tutorial */ #include @@ -30,5 +30,5 @@ int main (int argc, char **argv) { - return t8_step8_main (argc, argv); + return t8_tutorial_build_cmesh_main (argc, argv); } From dcf67ed339592647c2dd8a6ff476b2ec9e8c6964 Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Wed, 24 May 2023 10:22:01 +0200 Subject: [PATCH 213/255] Added a newline. --- src/t8_cmesh/t8_cmesh_examples.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index b0debfacd2..1f11022147 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -60,7 +60,7 @@ t8_cmesh_new_from_p4est_ext (void *conn, int dim, * and raise a warning. */ if (!sc_package_is_registered (p4est_package_id)) { t8_global_errorf - ("WARNING: p4est is not yet initialized. Doing it now for you."); + ("WARNING: p4est is not yet initialized. Doing it now for you.\n"); p4est_init (NULL, SC_LP_ESSENTIAL); } From 915db1c09b89dd94f73efbc7cd0035cc69460e06 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 24 May 2023 11:07:43 +0200 Subject: [PATCH 214/255] fix pyramid element ref coords --- .../t8_default/t8_default_pyramid/t8_dpyramid_bits.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c index 67ac00bfed..26af2c8ef3 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_dpyramid_bits.c @@ -1761,8 +1761,8 @@ t8_dpyramid_compute_reference_coords (const t8_dpyramid_t *elem, out_coords[2] += ref_coords[2] * length; } else { - out_coords[0] += ref_coords[0] * length * (1 - ref_coords[2]); - out_coords[1] += ref_coords[1] * length * (1 - ref_coords[2]); + out_coords[0] += (ref_coords[0] - ref_coords[2]) * length; + out_coords[1] += (ref_coords[1] - ref_coords[2]) * length; out_coords[2] += (1 - ref_coords[2]) * length; } From 0cd6d257f8db553a08a86bd638efca55bb240447 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 15 May 2023 10:57:26 +0200 Subject: [PATCH 215/255] Initialize last_tree --- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 4 ++-- src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index 9a4c4d9427..3dd5bdc257 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -347,8 +347,8 @@ t8_vtkGrid_to_cmesh (vtkSmartPointer < vtkDataSet > vtkGrid, t8_cmesh_register_geometry (cmesh, linear_geom); } if (partition) { - t8_gloidx_t first_tree; - t8_gloidx_t last_tree; + t8_gloidx_t first_tree = 0; + t8_gloidx_t last_tree = 0; if (mpirank == main_proc) { first_tree = 0; last_tree = num_trees - 1; diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx index ce048f65f9..f5ec877a28 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.hxx @@ -32,6 +32,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include "t8_vtk_types.h" #if T8_WITH_VTK #include +#include /** * Given a filename to a file containing an vtkUnstructured Grid, read From 6732e1a3be41a93e3910a08048132a9bc77a8650 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 15 May 2023 14:18:33 +0200 Subject: [PATCH 216/255] Initialize pointers --- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index 3dd5bdc257..3ee7446c18 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -213,9 +213,9 @@ t8_vtk_iterate_cells (vtkSmartPointer < vtkDataSet > vtkGrid, t8_cmesh_t cmesh, sc_MPI_Comm comm) { - double *vertices; - double **tuples; - size_t *data_size; + double *vertices = NULL; + double **tuples = NULL; + size_t *data_size = NULL; t8_gloidx_t tree_id = 0; int max_dim = -1; From 076f55c20d41f8cd88fc7667dfb745a4e2181afa Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 24 May 2023 11:30:04 +0200 Subject: [PATCH 217/255] remove redundant header --- src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx index 229104255a..95bb68f551 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_to_t8/t8_cmesh_vtk_unstructured.cxx @@ -26,7 +26,6 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include -#include vtk_read_success_t t8_read_unstructured (const char *filename, From 1a228ea08f18147e4bffeccc918c1cfdf06c0878 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Wed, 24 May 2023 12:53:40 +0200 Subject: [PATCH 218/255] Clean up --- tutorials/general/t8_tutorial_build_cmesh.cxx | 40 +++++++++++++------ tutorials/general/t8_tutorial_build_cmesh.h | 8 ++-- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/tutorials/general/t8_tutorial_build_cmesh.cxx b/tutorials/general/t8_tutorial_build_cmesh.cxx index d0cb1cadc9..813f0bb773 100644 --- a/tutorials/general/t8_tutorial_build_cmesh.cxx +++ b/tutorials/general/t8_tutorial_build_cmesh.cxx @@ -262,7 +262,7 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) 0.86, 0.5, 1, 1.86, 0.5, 1 - * } + * }; * // 2. Initialization of the mesh * t8_cmesh_t cmesh; * t8_cmesh_init (&cmesh); @@ -277,17 +277,17 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) * t8_cmesh_set_tree_class (cmesh, 2, T8_ECLASS_PRISM); * t8_cmesh_set_tree_class (cmesh, 3, T8_ECLASS_PRISM); * t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_PYRAMID); - * t8_cmesh_set_tree_class (cmesh, 4, T8_ECLASS_HEX); + * t8_cmesh_set_tree_class (cmesh, 5, T8_ECLASS_HEX); * * // 5. Classification of the vertices for each tree - * t8_cmesh_set_tree_vertices (cmesh, 0, vertices + 12, 4); - * t8_cmesh_set_tree_vertices (cmesh, 1, vertices + 24, 4); - * t8_cmesh_set_tree_vertices (cmesh, 2, vertices + 42, 6); - * t8_cmesh_set_tree_vertices (cmesh, 3, vertices + 60, 6); - * t8_cmesh_set_tree_vertices (cmesh, 4, vertices + 78, 5); - * t8_cmesh_set_tree_vertices (cmesh, 5, vertices + 93, 8); + * t8_cmesh_set_tree_vertices (cmesh, 0, vertices , 4); + * t8_cmesh_set_tree_vertices (cmesh, 1, vertices + 12, 4); + * t8_cmesh_set_tree_vertices (cmesh, 2, vertices + 24, 6); + * t8_cmesh_set_tree_vertices (cmesh, 3, vertices + 42, 6); + * t8_cmesh_set_tree_vertices (cmesh, 4, vertices + 60, 5); + * t8_cmesh_set_tree_vertices (cmesh, 5, vertices + 75, 8); * - * // 6. Definition of the face neighboors between the different trees + * // 6. Definition of the face neighbors between the different trees * t8_cmesh_set_join (cmesh, 0, 2, 0, 4, 0); * t8_cmesh_set_join (cmesh, 1, 3, 0, 4, 0); * t8_cmesh_set_join (cmesh, 2, 5, 0, 0, 0); @@ -303,10 +303,10 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) /* In many cases the points of the different trees are dependent of these of the previous trees * or of these of the same tree. Then it is reasonable to define the different vertices dependent * of each other. - * Also the order of the sheme is not fixed. The definition of the face neighboors can be + * Also the order of the scheme is not fixed. The definition of the face neighbors can be * before the definition of the vertices. - * In the following example the tree classes are defined, then the face neighboors are set. - * After that the vertices are defined for each tree separate. + * In the following example the tree classes are defined, then the face neighbors are set. + * After that the vertices are defined for each tree separately. * */ double vertices[24]; @@ -506,16 +506,32 @@ t8_tutorial_build_cmesh_main (int argc, char **argv) /* Creation of a two dimensional cmesh with periodic boundaries. */ cmesh_2D = t8_cmesh_new_periodic_hybrid_2d (comm); + t8_global_productionf + ("[tutorial] A 2D hybrid cmesh with periodic boundaries has been created.\n"); + /* Creation of a three dimensional cmesh */ cmesh_3D = t8_cmesh_new_hybrid_gate_3d (comm); + t8_global_productionf + ("[tutorial] A 3D hybrid cmesh (in style of a gate) has been created.\n"); + /* Output the meshes to vtu files. */ t8_cmesh_vtk_write_file (cmesh_2D, prefix_2D, 1.0); + t8_global_productionf ("[tutorial] Wrote the 2D cmesh to vtu files.\n"); t8_cmesh_vtk_write_file (cmesh_3D, prefix_3D, 1.0); + t8_global_productionf ("[tutorial] Wrote the 3D cmesh to vtu files.\n"); /* * Clean-up */ + /* Deallocate the cmeshes */ + t8_cmesh_destroy (&cmesh_2D); + t8_global_productionf ("[tutorial] The 2D cmesh has been deallocated.\n"); + + t8_cmesh_destroy (&cmesh_3D); + t8_global_productionf ("[tutorial] The 3D cmesh has been deallocated.\n"); + + /* Finalize the sc library */ sc_finalize (); mpiret = sc_MPI_Finalize (); diff --git a/tutorials/general/t8_tutorial_build_cmesh.h b/tutorials/general/t8_tutorial_build_cmesh.h index 72f4b6f1e0..52b623c3f6 100644 --- a/tutorials/general/t8_tutorial_build_cmesh.h +++ b/tutorials/general/t8_tutorial_build_cmesh.h @@ -20,11 +20,11 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/** file t8_step8.h +/** file t8_tutorial_build_cmesh.h */ -#ifndef T8_STEP8_H -#define T8_STEP8_H +#ifndef T8_TUTORIAL_BUILD_CMESH_H +#define T8_TUTORIAL_BUILD_CMESH_H #include @@ -36,4 +36,4 @@ int t8_tutorial_build_cmesh_main (int argc, char **argv); T8_EXTERN_C_END (); -#endif /* !T8_STEP8_H */ +#endif /* !T8_TUTORIAL_BUILD_CMESH_H */ From de07cd63efd6f83c2faa44bd1006c7b38f5fa2fc Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Wed, 24 May 2023 13:58:14 +0200 Subject: [PATCH 219/255] Coding guidelines --- tutorials/general/t8_tutorial_build_cmesh.cxx | 53 +++++++++---------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/tutorials/general/t8_tutorial_build_cmesh.cxx b/tutorials/general/t8_tutorial_build_cmesh.cxx index 813f0bb773..67153f1fd7 100644 --- a/tutorials/general/t8_tutorial_build_cmesh.cxx +++ b/tutorials/general/t8_tutorial_build_cmesh.cxx @@ -310,7 +310,6 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) * */ double vertices[24]; - int i; t8_geometry_c *linear_geom = t8_geometry_linear_new (3); /* Initialization of the mesh */ @@ -362,11 +361,11 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) * Definition of the second tree */ /* Tetrahedron 2 vertices */ - for (i = 0; i < 3; i++) { + for (int itet = 0; itet < 3; itet++) { - vertices[i] = vertices[i] + (i == 0 ? 1 + 0.86 : 0); - vertices[3 + i] = vertices[6 + i] + (i == 0 ? 1 : 0); - vertices[9 + i] = vertices[9 + i] + (i == 0 ? 1 : 0); + vertices[itet] = vertices[itet] + (itet == 0 ? 1 + 0.86 : 0); + vertices[3 + itet] = vertices[6 + itet] + (itet == 0 ? 1 : 0); + vertices[9 + itet] = vertices[9 + itet] + (itet == 0 ? 1 : 0); } vertices[6] = 1 + 2 * 0.86; @@ -393,10 +392,10 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) vertices[8] = 0; /* Translate +1 in z-axis for the upper vertices */ - for (i = 0; i < 3; i++) { - vertices[9 + 3 * i] = vertices[3 * i]; - vertices[9 + 3 * i + 1] = vertices[3 * i + 1]; - vertices[9 + 3 * i + 2] = vertices[3 * i + 2] + 1; + for (int iprism1 = 0; iprism1 < 3; iprism1++) { + vertices[9 + 3 * iprism1] = vertices[3 * iprism1]; + vertices[9 + 3 * iprism1 + 1] = vertices[3 * iprism1 + 1]; + vertices[9 + 3 * iprism1 + 2] = vertices[3 * iprism1 + 2] + 1; } /* Classification of the vertices for the third tree */ @@ -406,9 +405,10 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) * Definition of the fourth tree */ /* Prism 2 vertices */ - for (i = 0; i < 3; i++) { - vertices[3 + i] = vertices[i] + (i == 0 ? 1 + 2 * 0.86 : 0); - vertices[6 + i] = vertices[6 + i] + (i == 0 ? 1 : 0); + for (int iprism2 = 0; iprism2 < 3; iprism2++) { + vertices[3 + iprism2] = + vertices[iprism2] + (iprism2 == 0 ? 1 + 2 * 0.86 : 0); + vertices[6 + iprism2] = vertices[6 + iprism2] + (iprism2 == 0 ? 1 : 0); } vertices[0] = 0.86 + 1; @@ -416,10 +416,10 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) vertices[2] = 0; /* Translate +1 in z-axis for the upper vertices */ - for (i = 0; i < 3; i++) { - vertices[9 + 3 * i] = vertices[3 * i]; - vertices[9 + 3 * i + 1] = vertices[3 * i + 1]; - vertices[9 + 3 * i + 2] = vertices[3 * i + 2] + 1; + for (int iprism2 = 0; iprism2 < 3; iprism2++) { + vertices[9 + 3 * iprism2] = vertices[3 * iprism2]; + vertices[9 + 3 * iprism2 + 1] = vertices[3 * iprism2 + 1]; + vertices[9 + 3 * iprism2 + 2] = vertices[3 * iprism2 + 2] + 1; } /* Classification of the vertices for the fourth tree */ @@ -457,10 +457,10 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) */ /* Hex coordinates */ /* Translate +1 in z-axis for the upper vertices */ - for (i = 0; i < 4; i++) { - vertices[12 + 3 * i] = vertices[3 * i]; - vertices[12 + 3 * i + 1] = vertices[3 * i + 1]; - vertices[12 + 3 * i + 2] = vertices[3 * i + 2] + 1; + for (int hex = 0; hex < 4; hex++) { + vertices[12 + 3 * hex] = vertices[3 * hex]; + vertices[12 + 3 * hex + 1] = vertices[3 * hex + 1]; + vertices[12 + 3 * hex + 2] = vertices[3 * hex + 2] + 1; } /* Classification of the vertices for the fifth tree */ @@ -474,11 +474,6 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) int t8_tutorial_build_cmesh_main (int argc, char **argv) { - int mpiret; - sc_MPI_Comm comm; - t8_cmesh_t cmesh_2D; - t8_cmesh_t cmesh_3D; - /* The prefix for our output files. */ const char *prefix_2D = "t8_step8_user_defined_mesh_2D"; const char *prefix_3D = "t8_step8_user_defined_mesh_3D"; @@ -488,7 +483,7 @@ t8_tutorial_build_cmesh_main (int argc, char **argv) */ /* Initialize MPI. This has to happen before we initialize sc or t8code. */ - mpiret = sc_MPI_Init (&argc, &argv); + int mpiret = sc_MPI_Init (&argc, &argv); /* Error check the MPI return value. */ SC_CHECK_MPI (mpiret); @@ -498,19 +493,19 @@ t8_tutorial_build_cmesh_main (int argc, char **argv) t8_init (SC_LP_PRODUCTION); /* We will use MPI_COMM_WORLD as a communicator. */ - comm = sc_MPI_COMM_WORLD; + sc_MPI_Comm comm = sc_MPI_COMM_WORLD; /* * Definition of the meshes. */ /* Creation of a two dimensional cmesh with periodic boundaries. */ - cmesh_2D = t8_cmesh_new_periodic_hybrid_2d (comm); + t8_cmesh_t cmesh_2D = t8_cmesh_new_periodic_hybrid_2d (comm); t8_global_productionf ("[tutorial] A 2D hybrid cmesh with periodic boundaries has been created.\n"); /* Creation of a three dimensional cmesh */ - cmesh_3D = t8_cmesh_new_hybrid_gate_3d (comm); + t8_cmesh_t cmesh_3D = t8_cmesh_new_hybrid_gate_3d (comm); t8_global_productionf ("[tutorial] A 3D hybrid cmesh (in style of a gate) has been created.\n"); From 9740b55542d383a284bae466f002086125c6bf03 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 26 May 2023 09:28:56 +0200 Subject: [PATCH 220/255] Code improvements --- src/t8_data/t8_shmem.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/t8_data/t8_shmem.c b/src/t8_data/t8_shmem.c index b7fb802b50..ba6c2ac767 100644 --- a/src/t8_data/t8_shmem.c +++ b/src/t8_data/t8_shmem.c @@ -267,20 +267,24 @@ t8_shmem_array_allgatherv_common (void *sendbuf, sc_MPI_Datatype sendtype, t8_shmem_array_t recvarray, sc_MPI_Datatype recvtype, - sc_MPI_Comm comm, sc_MPI_Comm intranode, - sc_MPI_Comm internode) + sc_MPI_Comm comm, + sc_MPI_Comm intranode_comm, + sc_MPI_Comm internode_comm) { size_t typesize; - int mpiret, intrarank, intrasize, intersize; + int mpiret; + int intrarank; /* The rank in the intranode communicator */ + int intrasize; /* The size of the intranode communicator */ + int intersize; /* The size of the internode communicator */ char *noderecvchar = NULL; typesize = sc_mpi_sizeof (recvtype); - mpiret = sc_MPI_Comm_rank (intranode, &intrarank); + mpiret = sc_MPI_Comm_rank (intranode_comm, &intrarank); SC_CHECK_MPI (mpiret); - mpiret = sc_MPI_Comm_size (intranode, &intrasize); + mpiret = sc_MPI_Comm_size (intranode_comm, &intrasize); SC_CHECK_MPI (mpiret); - mpiret = sc_MPI_Comm_size (internode, &intersize); + mpiret = sc_MPI_Comm_size (internode_comm, &intersize); SC_CHECK_MPI (mpiret); /* intranode-gatherv */ @@ -288,25 +292,27 @@ t8_shmem_array_allgatherv_common (void *sendbuf, int *intra_recvcounts = T8_ALLOC_ZERO (int, intrasize); int intra_recv_total = t8_compute_recvcounts_displs (sendcount, intra_recvcounts, intra_displ, - sizeof (sendtype), intranode); + sizeof (sendtype), intranode_comm); if (!intrarank) { noderecvchar = T8_ALLOC (char, intra_recv_total * typesize); } mpiret = sc_MPI_Gatherv (sendbuf, sendcount, sendtype, noderecvchar, - intra_recvcounts, intra_displ, recvtype, 0, intranode); + intra_recvcounts, intra_displ, recvtype, 0, + intranode_comm); SC_CHECK_MPI (mpiret); /* internode-allgatherv */ int *inter_displ = T8_ALLOC_ZERO (int, intersize); int *inter_recvcount = T8_ALLOC_ZERO (int, intersize); t8_compute_recvcounts_displs (intra_recv_total, inter_recvcount, - inter_displ, sizeof (sendtype), internode); + inter_displ, sizeof (sendtype), + internode_comm); if (t8_shmem_array_start_writing (recvarray)) { mpiret = sc_MPI_Allgatherv (noderecvchar, intra_recv_total, sendtype, recvarray->array, inter_recvcount, inter_displ, - recvtype, internode); + recvtype, internode_comm); SC_CHECK_MPI (mpiret); T8_FREE (noderecvchar); } @@ -372,8 +378,8 @@ t8_shmem_array_allgatherv (void *sendbuf, T8_ASSERT (t8_shmem_array_is_initialized (recvarray)); T8_ASSERT (!t8_shmem_array_is_writing_possible (recvarray)); sc_shmem_type_t type; - sc_MPI_Comm intranode = sc_MPI_COMM_NULL, internode = - sc_MPI_COMM_NULL; + sc_MPI_Comm intranode_comm = sc_MPI_COMM_NULL; + sc_MPI_Comm internode_comm = sc_MPI_COMM_NULL; /* Get the type of the used shared memory. */ type = sc_shmem_get_type (comm); @@ -383,8 +389,9 @@ t8_shmem_array_allgatherv (void *sendbuf, } /* Get the intra- and internode communicator. */ - sc_mpi_comm_get_node_comms (comm, &intranode, &internode); - if (intranode == sc_MPI_COMM_NULL || internode == sc_MPI_COMM_NULL) { + sc_mpi_comm_get_node_comms (comm, &intranode_comm, &internode_comm); + if (intranode_comm == sc_MPI_COMM_NULL + || intranode_comm == sc_MPI_COMM_NULL) { type = SC_SHMEM_BASIC; } @@ -405,7 +412,8 @@ t8_shmem_array_allgatherv (void *sendbuf, case SC_SHMEM_WINDOW_PRESCAN: #endif /* SC_ENABLE_MPIWINSHARED */ t8_shmem_array_allgatherv_common (sendbuf, sendcount, sendtype, recvarray, - recvtype, comm, intranode, internode); + recvtype, comm, intranode_comm, + internode_comm); break; #endif /* __bgq__ || SC_ENABLE_MPI_WINSHARED */ default: From f1da67c644b9cd6db6fdbbbad2156dd517210623 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 26 May 2023 09:31:02 +0200 Subject: [PATCH 221/255] Remove whitespace --- src/t8_data/t8_shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_data/t8_shmem.c b/src/t8_data/t8_shmem.c index ba6c2ac767..5757614bc5 100644 --- a/src/t8_data/t8_shmem.c +++ b/src/t8_data/t8_shmem.c @@ -224,7 +224,7 @@ t8_shmem_array_allgather (const void *sendbuf, int sendcount, * * \param[in] sendcount The number of items this proc sends * \param[in, out] recvcounts On input a zero-initialized array that is going to be filled with the number of elements send by rank i - * \param[in, out] displs On input a zero-initialized array that is going to be filled with the displacements + * \param[in, out] displs On input a zero-initialized array that is going to be filled with the displacements * \returns The total number of items */ static int From de8d63cf30439f053dd66be467dc687fee60e24a Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 26 May 2023 09:32:03 +0200 Subject: [PATCH 222/255] compare intrarank with main-rank --- src/t8_data/t8_shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_data/t8_shmem.c b/src/t8_data/t8_shmem.c index 5757614bc5..eaf15d157f 100644 --- a/src/t8_data/t8_shmem.c +++ b/src/t8_data/t8_shmem.c @@ -293,7 +293,7 @@ t8_shmem_array_allgatherv_common (void *sendbuf, int intra_recv_total = t8_compute_recvcounts_displs (sendcount, intra_recvcounts, intra_displ, sizeof (sendtype), intranode_comm); - if (!intrarank) { + if (intrarank == 0) { noderecvchar = T8_ALLOC (char, intra_recv_total * typesize); } mpiret = From 177ddc4b3dce3d73256114c40f9aed2f4df314a1 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 26 May 2023 09:37:50 +0200 Subject: [PATCH 223/255] Typo-fix --- src/t8_data/t8_shmem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/t8_data/t8_shmem.c b/src/t8_data/t8_shmem.c index eaf15d157f..b5dca6ee39 100644 --- a/src/t8_data/t8_shmem.c +++ b/src/t8_data/t8_shmem.c @@ -219,7 +219,7 @@ t8_shmem_array_allgather (const void *sendbuf, int sendcount, } /** - * Computes the recvcounter- and displacementarray for + * Computes the recvcounter- and displacement array for * an MPI_Gatherv * * \param[in] sendcount The number of items this proc sends @@ -316,6 +316,9 @@ t8_shmem_array_allgatherv_common (void *sendbuf, SC_CHECK_MPI (mpiret); T8_FREE (noderecvchar); } + else { + t8_errorf ("Can not write shmem-array.\n"); + } t8_shmem_array_end_writing (recvarray); T8_FREE (inter_displ); From 91dccf3045edf698a3308653ff325b1d8b30fd4d Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 26 May 2023 09:39:00 +0200 Subject: [PATCH 224/255] Coding guidelines --- test/t8_data/t8_gtest_shmem.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/t8_data/t8_gtest_shmem.cxx b/test/t8_data/t8_gtest_shmem.cxx index 279ca9b96e..52ee4f25f7 100644 --- a/test/t8_data/t8_gtest_shmem.cxx +++ b/test/t8_data/t8_gtest_shmem.cxx @@ -167,7 +167,8 @@ TEST_P(shmem, test_sc_shmem_alloc){ TEST_P(shmem, test_shmem_array_allgatherv){ const size_t element_size = sizeof (t8_gloidx_t); - int mpirank, mpisize; + int mpirank; + int mpisize; int mpiret; mpiret = sc_MPI_Comm_rank (comm, &mpirank); From 5100827fd9ddcf8747d58326190a5c5ceb6e0336 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 26 May 2023 09:40:33 +0200 Subject: [PATCH 225/255] Add comment --- test/t8_data/t8_gtest_shmem.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/t8_data/t8_gtest_shmem.cxx b/test/t8_data/t8_gtest_shmem.cxx index 52ee4f25f7..097abd7437 100644 --- a/test/t8_data/t8_gtest_shmem.cxx +++ b/test/t8_data/t8_gtest_shmem.cxx @@ -178,6 +178,8 @@ TEST_P(shmem, test_shmem_array_allgatherv){ t8_debugf("[D] mpirank: %i\n", mpirank); + /* Each process fills an array of size mpirank * 10, where the elements + * in the arrays increase, such that in the shmem we have a contiguous increase. */ const int base_size = 10; const t8_gloidx_t array_length = (mpirank+1) * base_size; t8_gloidx_t *sendbuf = T8_ALLOC_ZERO(t8_gloidx_t, array_length); From f71206c19839319e7e7bccf083c09d9b312c633e Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 26 May 2023 09:54:06 +0200 Subject: [PATCH 226/255] Code improvement --- src/t8_data/t8_shmem.c | 6 +++--- src/t8_data/t8_shmem.h | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/t8_data/t8_shmem.c b/src/t8_data/t8_shmem.c index b5dca6ee39..58ae7fcb24 100644 --- a/src/t8_data/t8_shmem.c +++ b/src/t8_data/t8_shmem.c @@ -240,9 +240,9 @@ t8_compute_recvcounts_displs (int sendcount, int *recvcounts, int *displs, SC_CHECK_MPI (mpiret); int recv_total = recvcounts[0]; - for (int i = 1; i < mpisize; i++) { - displs[i] = displs[i - 1] + recvcounts[i - 1]; - recv_total += recvcounts[i]; + for (int irank = 1; irank < mpisize; irank++) { + displs[irank] = displs[irank - 1] + recvcounts[irank - 1]; + recv_total += recvcounts[irank]; } return recv_total; diff --git a/src/t8_data/t8_shmem.h b/src/t8_data/t8_shmem.h index e26e4abf3a..bdf7056878 100644 --- a/src/t8_data/t8_shmem.h +++ b/src/t8_data/t8_shmem.h @@ -160,8 +160,6 @@ void t8_shmem_array_allgather (const void *sendbuf, * \param[in, out] recvarray array of type recvtype where the data gets written to * \param[in] recvtype the type of items to recieve * \param[in] comm the mpi communicator - * \param[in] intranode the intranode mpi communicator - * \param[in] internode the internode mpi communicator * */ void t8_shmem_array_allgatherv (void *sendbuf, From ea5f2b4cc0cadeb6a93eef54645ce546eeff4fa1 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 26 May 2023 10:25:47 +0200 Subject: [PATCH 227/255] Apply suggestions from code review Co-authored-by: Johannes Markert <10619309+jmark@users.noreply.github.com> --- src/t8_forest/t8_forest_to_vtkUnstructured.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_forest/t8_forest_to_vtkUnstructured.hxx b/src/t8_forest/t8_forest_to_vtkUnstructured.hxx index b8832fde90..812c9a0c6d 100644 --- a/src/t8_forest/t8_forest_to_vtkUnstructured.hxx +++ b/src/t8_forest/t8_forest_to_vtkUnstructured.hxx @@ -21,9 +21,9 @@ along with t8code; if not, write to the Free Software Foundation, Inc., */ #ifndef T8_FOREST_VTK_API_HXX -#define T8_FOREST_VTK_API_HXX +#define T8_FOREST_VTK_UNSTRUCTURED_API_HXX -#include +#include #include #if T8_WITH_VTK From 8339e8319955a952773aab0e4ed178ed151e0efd Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 26 May 2023 12:58:49 +0200 Subject: [PATCH 228/255] Add documentation --- src/t8_data/t8_shmem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/t8_data/t8_shmem.c b/src/t8_data/t8_shmem.c index 58ae7fcb24..9695330487 100644 --- a/src/t8_data/t8_shmem.c +++ b/src/t8_data/t8_shmem.c @@ -260,6 +260,8 @@ t8_compute_recvcounts_displs (int sendcount, int *recvcounts, int *displs, * \param[in, out] recvarray The destination * \param[in] recvtype The type of items to receive * \param[in] comm The mpicommunicator to use. + * \param[in] intranode_comm The intranode communicator to use. + * \param[in] internode_comm The internode communicator to use. */ static void t8_shmem_array_allgatherv_common (void *sendbuf, From 4c97b48e24cd0508b202b25d62414ba4994a9488 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 26 May 2023 14:40:42 +0200 Subject: [PATCH 229/255] Apply suggestions from code review Co-authored-by: Johannes Markert <10619309+jmark@users.noreply.github.com> --- src/t8_forest/t8_forest_to_vtkUnstructured.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_forest/t8_forest_to_vtkUnstructured.hxx b/src/t8_forest/t8_forest_to_vtkUnstructured.hxx index 812c9a0c6d..e42247b928 100644 --- a/src/t8_forest/t8_forest_to_vtkUnstructured.hxx +++ b/src/t8_forest/t8_forest_to_vtkUnstructured.hxx @@ -20,7 +20,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef T8_FOREST_VTK_API_HXX +#ifndef T8_FOREST_VTK_UNSTRUCTURED_API_HXX #define T8_FOREST_VTK_UNSTRUCTURED_API_HXX #include @@ -70,4 +70,4 @@ void t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, T8_EXTERN_C_END (); -#endif /* T8_FOREST_VTK_API_HXX */ +#endif /* T8_FOREST_VTK_UNSTRUCTURED_API_HXX */ From 3c5c6f379d96ca82d9b742e20a25560129c33a3f Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Fri, 26 May 2023 14:41:30 +0200 Subject: [PATCH 230/255] Correct negative volume --- tutorials/general/t8_tutorial_build_cmesh.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tutorials/general/t8_tutorial_build_cmesh.cxx b/tutorials/general/t8_tutorial_build_cmesh.cxx index 67153f1fd7..950073e59d 100644 --- a/tutorials/general/t8_tutorial_build_cmesh.cxx +++ b/tutorials/general/t8_tutorial_build_cmesh.cxx @@ -456,11 +456,11 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) * Definition of the sixth tree */ /* Hex coordinates */ - /* Translate +1 in z-axis for the upper vertices */ for (int hex = 0; hex < 4; hex++) { - vertices[12 + 3 * hex] = vertices[3 * hex]; - vertices[12 + 3 * hex + 1] = vertices[3 * hex + 1]; - vertices[12 + 3 * hex + 2] = vertices[3 * hex + 2] + 1; + vertices[3 * hex + 1] = vertices[3 * hex + 1] * (-1); + vertices[3 * hex + 12] = vertices[3 * hex]; + vertices[3 * hex + 13] = vertices[3 * hex + 1]; + vertices[3 * hex + 14] = vertices[3 * hex + 2] + 1; } /* Classification of the vertices for the fifth tree */ @@ -488,7 +488,7 @@ t8_tutorial_build_cmesh_main (int argc, char **argv) SC_CHECK_MPI (mpiret); /* Initialize the sc library, has to happen before we initialize t8code. */ - sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_ESSENTIAL); + sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_PRODUCTION); /* Initialize t8code with log level SC_LP_PRODUCTION. See sc.h for more info on the log levels. */ t8_init (SC_LP_PRODUCTION); From 710face1ef487eafded720a90ab0dbfbc30451e7 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Mon, 29 May 2023 01:28:46 +0200 Subject: [PATCH 231/255] Change to sc_array --- tutorials/general/t8_step7_interpolation.cxx | 236 ++++++++++--------- 1 file changed, 119 insertions(+), 117 deletions(-) diff --git a/tutorials/general/t8_step7_interpolation.cxx b/tutorials/general/t8_step7_interpolation.cxx index 8ca1e806d5..5aac0aceef 100644 --- a/tutorials/general/t8_step7_interpolation.cxx +++ b/tutorials/general/t8_step7_interpolation.cxx @@ -29,13 +29,44 @@ struct t8_step7_element_data_t /* This is our own defined data that we will pass on to the * adaptation callback. */ -struct t8_step7_adapt_data +typedef struct t8_step7_adapt_data { double midpoint[3]; /* The midpoint of our sphere. */ double refine_if_inside_radius; /* if an element's center is smaller than this value, we refine the element. */ double coarsen_if_outside_radius; /* if an element's center is larger this value, we coarsen its family. */ - t8_step7_element_data_t *element_data; -}; + sc_array_t *element_data; +} t8_step7_adapt_data; + +/* Set the value of an element to a given entry */ +static void +t8_element_set_value (const t8_step7_adapt_data * adapt_data, + t8_locidx_t ielement, double value) +{ + t8_step7_element_data_t elem_data; + elem_data.values = value; + *((t8_step7_element_data_t *) + t8_sc_array_index_locidx (adapt_data->element_data, ielement)) = + elem_data; +} + +/* Set the value of an element to a given entry */ +static void +t8_element_set_element (const t8_step7_adapt_data * adapt_data, + t8_locidx_t ielement, t8_step7_element_data_t element) +{ + *((t8_step7_element_data_t *) + t8_sc_array_index_locidx (adapt_data->element_data, ielement)) = element; +} + +/* Get the value of an element to a given entry + */ +static t8_step7_element_data_t +t8_element_get_value (const t8_step7_adapt_data * adapt_data, + t8_locidx_t ielement) +{ + return *((t8_step7_element_data_t *) + t8_sc_array_index_locidx ((adapt_data->element_data), ielement)); +} /* This is our own defined data that we will pass on to the * adaptation callback. */ @@ -104,20 +135,6 @@ t8_step7_adapt_callback (t8_forest_t forest, return 0; } -/* Callback function, where no element is refined or coarsened. - */ -int -t8_adapt_non (t8_forest_t forest, - t8_forest_t forest_from, - t8_locidx_t which_tree, - t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, - const int is_family, - const int num_elements, t8_element_t *elements[]) -{ - return 0; -} - /* Adapt a forest according to a callback function. * This will create a new forest and return it. * Create a new forest that is adapted from \a forest with our adaptation callback. @@ -164,8 +181,8 @@ t8_adapt_forest (t8_forest_t forest_from, t8_forest_adapt_t adapt_fn, } /* Replace callback to decide how to interpolate a refined or coarsened element. - * If an element is refined, each child gets the phi value of its parent. - * If elements are coarsened, the parent gets the average phi value of the children. + * If an element is refined, each child gets the value of its parent. + * If elements are coarsened, the parent gets the average value of the children. * Outgoing are the old elements and incoming the new ones * \param [in] forest_old non adapted forest * \param [in] forest_new adapted forest @@ -187,65 +204,41 @@ t8_forest_replace (t8_forest_t forest_old, t8_locidx_t first_outgoing, int num_incoming, t8_locidx_t first_incoming) { - int i; - const struct t8_step7_adapt_data *adapt_data_new = - (const struct t8_step7_adapt_data *) t8_forest_get_user_data (forest_new); + struct t8_step7_adapt_data *adapt_data_new = + (struct t8_step7_adapt_data *) t8_forest_get_user_data (forest_new); const struct t8_step7_adapt_data *adapt_data_old = (const struct t8_step7_adapt_data *) t8_forest_get_user_data (forest_old); /* get the index of the data array corresponding to the old and the adapted forest */ - for (t8_locidx_t t = 0; t < which_tree; t++) { - first_incoming += t8_forest_get_tree_num_elements (forest_new, t); - first_outgoing += t8_forest_get_tree_num_elements (forest_old, t); + for (int itree = 0; itree < which_tree; itree++) { + first_incoming += t8_forest_get_tree_num_elements (forest_new, itree); + first_outgoing += t8_forest_get_tree_num_elements (forest_old, itree); } /* Do not adapt or coarsen */ if (refine == 0) { - adapt_data_new->element_data[first_incoming] = - adapt_data_old->element_data[first_outgoing]; + t8_element_set_element (adapt_data_new, first_incoming, + t8_element_get_value (adapt_data_old, + first_outgoing)); } /* The old element is refined, we copy the element values */ else if (refine == 1) { - for (i = 0; i < num_incoming; i++) { - adapt_data_new->element_data[first_incoming + i] = - adapt_data_old->element_data[first_outgoing]; + for (int i = 0; i < num_incoming; i++) { + t8_element_set_element (adapt_data_new, first_incoming + i, + t8_element_get_value (adapt_data_old, + first_outgoing)); } } /* Old element is coarsened */ else if (refine == -1) { - adapt_data_new->element_data[first_incoming].values = 0; + double tmpValue = 0; for (t8_locidx_t i = 0; i < num_outgoing; i++) { - adapt_data_old->element_data[first_outgoing + i].values; - adapt_data_new->element_data[first_incoming].values += - adapt_data_old->element_data[first_outgoing + i].values; + tmpValue += + t8_element_get_value (adapt_data_old, first_outgoing + i).values; } - adapt_data_new->element_data[first_incoming].values /= num_outgoing; + t8_element_set_value (adapt_data_new, first_incoming, + tmpValue / num_outgoing); } -} - -/* Each process has computed the data entries for its local elements. - * In order to get the values for the ghost elements, we use t8_forest_ghost_exchange_data. - * Calling this function will fill all the ghost entries of our element data array with the - * value on the process that owns the corresponding element. */ -static void -t8_step7_exchange_ghost_data (t8_forest_t forest, - struct t8_step7_element_data_t *data) -{ - sc_array *sc_array_wrapper; - t8_locidx_t num_elements = - t8_forest_get_local_num_elements (forest); - t8_locidx_t num_ghosts = t8_forest_get_num_ghosts (forest); - - /* t8_forest_ghost_exchange_data expects an sc_array (of length num_local_elements + num_ghosts). - * We wrap our data array to an sc_array. */ - sc_array_wrapper = - sc_array_new_data (data, sizeof (struct t8_step7_element_data_t), - num_elements + num_ghosts); - - /* Carry out the data exchange. The entries with indices > num_local_elements will get overwritten. */ - t8_forest_ghost_exchange_data (forest, sc_array_wrapper); - - /* Destroy the wrapper array. This will not free the data memory since we used sc_array_new_data. */ - sc_array_destroy (sc_array_wrapper); + t8_forest_set_user_data (forest_new, adapt_data_new); } /* Write the forest and the data corresponding to the forest in a vtu file. @@ -258,7 +251,7 @@ static void t8_write_vtu (t8_forest_t forest, struct t8_step7_adapt_data *data, const char *prefix) { - t8_locidx_t num_elements = + const t8_locidx_t num_elements = t8_forest_get_local_num_elements (forest); t8_locidx_t ielem; /* We need to allocate a new array to store the volumes on their own. @@ -272,22 +265,20 @@ t8_write_vtu (t8_forest_t forest, vtk_data.data = element_data; /* Copy the elment's data from the data array to the output array. */ for (ielem = 0; ielem < num_elements; ++ielem) { - element_data[ielem] = (data->element_data[ielem]).values; + element_data[ielem] = t8_element_get_value (data, ielem).values; } - { - /* To write user defined data, we need to extended output function t8_forest_vtk_write_file - * from t8_forest_vtk.h. Despite writin user data, it also offers more control over which - * properties of the forest to write. */ - int write_treeid = 1; - int write_mpirank = 1; - int write_level = 1; - int write_element_id = 1; - int write_ghosts = 0; - t8_forest_write_vtk_ext (forest, prefix, write_treeid, write_mpirank, - write_level, write_element_id, write_ghosts, - 0, 0, num_data, &vtk_data); - } + /* To write user defined data, we need to extended output function t8_forest_vtk_write_file + * from t8_forest_vtk.h. Despite writin user data, it also offers more control over which + * properties of the forest to write. */ + int write_treeid = 1; + int write_mpirank = 1; + int write_level = 1; + int write_element_id = 1; + int write_ghosts = 0; + t8_forest_write_vtk_ext (forest, prefix, write_treeid, write_mpirank, + write_level, write_element_id, write_ghosts, + 0, 0, num_data, &vtk_data); T8_FREE (element_data); } @@ -302,65 +293,65 @@ void t8_interpolation () { int level = 4; - t8_cmesh_t cmesh; - t8_forest_t forest_adapt, forest; - t8_scheme_cxx_t *scheme; - t8_step7_element_data_t *data, *data_adapt; - t8_locidx_t numElem; - t8_locidx_t numTrees; - int itree, ielemTree, ielem; - t8_element_t *element; + t8_forest_t forest_adapt; + t8_step7_element_data_t *elem_data; + t8_step7_adapt_data *data; double centroid[3]; - double midpoint[3] = { 0.5, 0.5, 1 }; + const double midpoint[3] = { 0.5, 0.5, 1 }; - scheme = t8_scheme_new_default_cxx (); + t8_scheme_cxx_t *scheme = t8_scheme_new_default_cxx (); /* Construct a cmesh */ - cmesh = + t8_cmesh_t cmesh = t8_cmesh_new_hypercube (T8_ECLASS_PYRAMID, sc_MPI_COMM_WORLD, 0, 0, 0); - forest = t8_forest_new_uniform (cmesh, scheme, level, 0, sc_MPI_COMM_WORLD); - + t8_forest_t forest = + t8_forest_new_uniform (cmesh, scheme, level, 0, sc_MPI_COMM_WORLD); /* Build initial data array and set data for the local elements. */ - data = - T8_ALLOC (t8_step7_element_data_t, - t8_forest_get_local_num_elements (forest)); + data = T8_ALLOC (t8_step7_adapt_data, 1); + elem_data = T8_ALLOC (t8_step7_element_data_t, 1); + data->element_data = + sc_array_new_count (sizeof (t8_step7_element_data_t), + t8_forest_get_local_num_elements (forest)); - numTrees = t8_forest_get_num_local_trees (forest); + const t8_locidx_t numTrees = t8_forest_get_num_local_trees (forest); /* Loop over all trees. The index of the data array is independent of the tree * index. Thus, we set the index of the tree index to zero and add one in each * loop step of the inner loop. */ + int itree; + int ielem; for (itree = 0, ielem = 0; itree < numTrees; itree++) { - numElem = t8_forest_get_tree_num_elements (forest, itree); + const t8_locidx_t numElem = + t8_forest_get_tree_num_elements (forest, itree); /* Inner loop: Iteration over the elements of the local tree */ - for (ielemTree = 0; ielemTree < numElem; ielemTree++, ielem++) { + + for (t8_locidx_t ielemTree = 0; ielemTree < numElem; ielemTree++, ielem++) { /* To calculate the distance to the centroid of an element the element is saved */ - element = t8_forest_get_element_in_tree (forest, itree, ielemTree); + const t8_element_t *element = + t8_forest_get_element_in_tree (forest, itree, ielemTree); /* Get the centroid of the local element. */ t8_forest_element_centroid (forest, 0, element, centroid); + /* Calculation of the distance to the centroid for the referenced element */ - data[ielem].values = t8_vec_dist (centroid, midpoint); + elem_data->values = t8_vec_dist (centroid, midpoint); + t8_element_set_element (data, ielem, *elem_data); } } - /* The data to adapt the forest and the data on the forest is saved in a variable saved on the forest */ - struct t8_step7_adapt_data adapt_data = { - {0.5, 0.5, 1}, /* Midpoints of the sphere. */ - 0.2, /* Refine if inside this radius. */ - 0.4, /* Coarsen if outside this radius. */ - data /* Data array */ - }; + data->midpoint[0] = 0.5; + data->midpoint[1] = 0.5; + data->midpoint[2] = 1; + data->refine_if_inside_radius = 0.2; + data->coarsen_if_outside_radius = 0.4; + /* Save the data on the forest - do not adapt the forest */ - forest = t8_adapt_forest (forest, t8_adapt_non, 0, 0, 0, &adapt_data); + t8_forest_set_user_data (forest, data); /* Write vtu file */ - t8_write_vtu (forest, &adapt_data, "t8_step7_uniform_forest"); - - /* Ghost exchange data */ - t8_step7_exchange_ghost_data (forest, data); + t8_write_vtu (forest, data, "t8_step7_uniform_forest"); /* Build a second forest to store the adapted forest - keep the old one */ t8_forest_ref (forest); @@ -368,21 +359,32 @@ t8_interpolation () /* Adapt the forest correponding tho the callback function (distance to the centroid) */ forest_adapt = - t8_adapt_forest (forest, t8_step7_adapt_callback, 0, 0, 0, &adapt_data); + t8_adapt_forest (forest, t8_step7_adapt_callback, 0, 0, 0, data); /* Calculate/Interpolate the data array for the adapted forest */ + + struct t8_step7_adapt_data *adapt_data = T8_ALLOC (t8_step7_adapt_data, 1); + adapt_data->element_data = + sc_array_new_count (sizeof (t8_step7_element_data_t), + t8_forest_get_local_num_elements (forest_adapt)); + + (*adapt_data).midpoint[0] = (*data).midpoint[0]; + (*adapt_data).midpoint[1] = (*data).midpoint[1]; + (*adapt_data).midpoint[2] = (*data).midpoint[2]; + (*adapt_data).refine_if_inside_radius = (*data).refine_if_inside_radius; + (*adapt_data).coarsen_if_outside_radius = (*data).coarsen_if_outside_radius; + t8_forest_iterate_replace (forest_adapt, forest, t8_forest_replace); /* Write the adapted forest to a vtu file */ - t8_write_vtu (forest_adapt, &adapt_data, "t8_step7_adapt_forest"); + adapt_data = + (struct t8_step7_adapt_data *) t8_forest_get_user_data (forest_adapt); + t8_write_vtu (forest_adapt, adapt_data, "t8_step7_adapt_forest"); /* Save the new forest as old forest */ forest = forest_adapt; - data = data_adapt; - - /* As the forest and the data of the adapted forest are now saved as forest, we dont need the variables forest_adapt and data_adapt */ - T8_FREE (data_adapt); - t8_forest_unref (&forest_adapt); + data = adapt_data; + printf ("1\n"); /* Now you could continue working with the forest. */ T8_FREE (data); t8_forest_unref (&forest); @@ -401,7 +403,7 @@ t8_step7_main (int argc, char **argv) /* Initialize the sc library, has to happen before we initialize t8code. */ sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_PRODUCTION); /* Initialize t8code with log level SC_LP_PRODUCTION. See sc.h for more info on the log levels. */ - t8_init (SC_LP_DEFAULT); + t8_init (SC_LP_PRODUCTION); /* Create forest, define data on forest, adapt forest, interpolate data */ t8_interpolation (); From 37aa1307cef2a080f2db18a2d19e4ced199016ef Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Mon, 29 May 2023 11:02:47 +0200 Subject: [PATCH 232/255] Cleanup --- tutorials/general/t8_step7_interpolation.cxx | 22 ++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/tutorials/general/t8_step7_interpolation.cxx b/tutorials/general/t8_step7_interpolation.cxx index 5aac0aceef..d7c0c90150 100644 --- a/tutorials/general/t8_step7_interpolation.cxx +++ b/tutorials/general/t8_step7_interpolation.cxx @@ -150,14 +150,11 @@ t8_step7_adapt_callback (t8_forest_t forest, * or parents are plugged into the callback again recursively until the forest does not * change any more. If you use this you should ensure that refinement will stop eventually. * One way is to check the element's level against a given maximum level. - * \param [in] do_face_ghost If non-zero additionally a layer of ghost elements is created for the forest. - * We will discuss ghost in later steps of the tutorial. * \param [in] user_data User defined data array to store on the forest */ t8_forest_t t8_adapt_forest (t8_forest_t forest_from, t8_forest_adapt_t adapt_fn, - int do_partition, int recursive, int do_face_ghost, - void *user_data) + int do_partition, int recursive, void *user_data) { t8_forest_t forest_new; @@ -169,11 +166,6 @@ t8_adapt_forest (t8_forest_t forest_from, t8_forest_adapt_t adapt_fn, if (user_data != NULL) { t8_forest_set_user_data (forest_new, user_data); } - /* Create ghost elements */ - t8_forest_set_ghost (forest_new, do_face_ghost, T8_GHOST_FACES); - if (do_partition) { - t8_forest_set_partition (forest_new, NULL, 0); - } /* Commit the adapted forest */ t8_forest_commit (forest_new); @@ -298,15 +290,16 @@ t8_interpolation () t8_step7_adapt_data *data; double centroid[3]; const double midpoint[3] = { 0.5, 0.5, 1 }; - t8_scheme_cxx_t *scheme = t8_scheme_new_default_cxx (); /* Construct a cmesh */ t8_cmesh_t cmesh = t8_cmesh_new_hypercube (T8_ECLASS_PYRAMID, sc_MPI_COMM_WORLD, 0, 0, 0); + /* Construct a forest with one tree */ t8_forest_t forest = t8_forest_new_uniform (cmesh, scheme, level, 0, sc_MPI_COMM_WORLD); + /* Build initial data array and set data for the local elements. */ data = T8_ALLOC (t8_step7_adapt_data, 1); elem_data = T8_ALLOC (t8_step7_element_data_t, 1); @@ -341,13 +334,14 @@ t8_interpolation () } } + /* Set the data elements which will be set as user elements on the forest */ data->midpoint[0] = 0.5; data->midpoint[1] = 0.5; data->midpoint[2] = 1; data->refine_if_inside_radius = 0.2; data->coarsen_if_outside_radius = 0.4; - /* Save the data on the forest - do not adapt the forest */ + /* Set the user data (values for callback and element values) */ t8_forest_set_user_data (forest, data); /* Write vtu file */ @@ -359,20 +353,23 @@ t8_interpolation () /* Adapt the forest correponding tho the callback function (distance to the centroid) */ forest_adapt = - t8_adapt_forest (forest, t8_step7_adapt_callback, 0, 0, 0, data); + t8_adapt_forest (forest, t8_step7_adapt_callback, 0, 0, data); /* Calculate/Interpolate the data array for the adapted forest */ + /* Create user_data element for the adapted forest */ struct t8_step7_adapt_data *adapt_data = T8_ALLOC (t8_step7_adapt_data, 1); adapt_data->element_data = sc_array_new_count (sizeof (t8_step7_element_data_t), t8_forest_get_local_num_elements (forest_adapt)); + /* Initialize user_data element for the adapted forest */ (*adapt_data).midpoint[0] = (*data).midpoint[0]; (*adapt_data).midpoint[1] = (*data).midpoint[1]; (*adapt_data).midpoint[2] = (*data).midpoint[2]; (*adapt_data).refine_if_inside_radius = (*data).refine_if_inside_radius; (*adapt_data).coarsen_if_outside_radius = (*data).coarsen_if_outside_radius; + t8_forest_set_user_data (forest_adapt, adapt_data); t8_forest_iterate_replace (forest_adapt, forest, t8_forest_replace); /* Write the adapted forest to a vtu file */ @@ -384,7 +381,6 @@ t8_interpolation () forest = forest_adapt; data = adapt_data; - printf ("1\n"); /* Now you could continue working with the forest. */ T8_FREE (data); t8_forest_unref (&forest); From c2e0a3f564da1196333fa7429dcae0c80d81c441 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Mon, 29 May 2023 12:40:02 +0200 Subject: [PATCH 233/255] Change vertices in comment --- tutorials/general/t8_tutorial_build_cmesh.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tutorials/general/t8_tutorial_build_cmesh.cxx b/tutorials/general/t8_tutorial_build_cmesh.cxx index 950073e59d..6e7ef21ece 100644 --- a/tutorials/general/t8_tutorial_build_cmesh.cxx +++ b/tutorials/general/t8_tutorial_build_cmesh.cxx @@ -247,11 +247,11 @@ t8_cmesh_new_hybrid_gate_3d (sc_MPI_Comm comm) 2.72, 0, 1, 1.86, 0.5, 1, - 0.86, -0.5, 0, // Pyramid coordinates - 1.86, -0.5, 0, - 0.86, 0.5, 0, + 0.86, 0.5, 0, // Pyramid coordinates 1.86, 0.5, 0, - 1.29, 0, 0, + 0.86, -0.5, 0, + 1.86, -0.5, 0, + 1.36, 0, -0.5, 0.86, -0.5, 0, // Hex coordinates 1.86, -0.5, 0, From 05e634b419ef668e4840009eae023cbb642cfa43 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Tue, 30 May 2023 20:22:16 +0200 Subject: [PATCH 234/255] Comments Review --- tutorials/general/t8_step7.h | 10 ------ tutorials/general/t8_step7_interpolation.cxx | 32 +++++++++++--------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/tutorials/general/t8_step7.h b/tutorials/general/t8_step7.h index 9ef9374aa8..7fcb5cbe50 100644 --- a/tutorials/general/t8_step7.h +++ b/tutorials/general/t8_step7.h @@ -30,16 +30,6 @@ T8_EXTERN_C_BEGIN (); -/* This is our own defined data that we will pass on to the - * adaptation callback. */ -struct t8_step7_adapt_data -{ - double midpoint[3]; /* The midpoint of our sphere. */ - double refine_if_inside_radius; /* if an element's center is smaller than this value, we refine the element. */ - double coarsen_if_outside_radius; /* if an element's center is larger this value, we coarsen its family. */ - double *element_data; -}; - /** This is the main program of this example. */ int t8_step7_main (int argc, char **argv); diff --git a/tutorials/general/t8_step7_interpolation.cxx b/tutorials/general/t8_step7_interpolation.cxx index d7c0c90150..0884ce8e76 100644 --- a/tutorials/general/t8_step7_interpolation.cxx +++ b/tutorials/general/t8_step7_interpolation.cxx @@ -202,10 +202,11 @@ t8_forest_replace (t8_forest_t forest_old, (const struct t8_step7_adapt_data *) t8_forest_get_user_data (forest_old); /* get the index of the data array corresponding to the old and the adapted forest */ - for (int itree = 0; itree < which_tree; itree++) { - first_incoming += t8_forest_get_tree_num_elements (forest_new, itree); - first_outgoing += t8_forest_get_tree_num_elements (forest_old, itree); - } + first_incoming += + t8_forest_get_tree_element_offset (forest_new, which_tree); + first_outgoing += + t8_forest_get_tree_element_offset (forest_old, which_tree); + /* Do not adapt or coarsen */ if (refine == 0) { t8_element_set_element (adapt_data_new, first_incoming, @@ -222,13 +223,13 @@ t8_forest_replace (t8_forest_t forest_old, } /* Old element is coarsened */ else if (refine == -1) { - double tmpValue = 0; + double tmp_value = 0; for (t8_locidx_t i = 0; i < num_outgoing; i++) { - tmpValue += + tmp_value += t8_element_get_value (adapt_data_old, first_outgoing + i).values; } t8_element_set_value (adapt_data_new, first_incoming, - tmpValue / num_outgoing); + tmp_value / num_outgoing); } t8_forest_set_user_data (forest_new, adapt_data_new); } @@ -245,7 +246,6 @@ t8_write_vtu (t8_forest_t forest, { const t8_locidx_t num_elements = t8_forest_get_local_num_elements (forest); - t8_locidx_t ielem; /* We need to allocate a new array to store the volumes on their own. * This array has one entry per local element. */ double *element_data = T8_ALLOC (double, num_elements); @@ -256,7 +256,7 @@ t8_write_vtu (t8_forest_t forest, strcpy (vtk_data.description, "Element own data"); vtk_data.data = element_data; /* Copy the elment's data from the data array to the output array. */ - for (ielem = 0; ielem < num_elements; ++ielem) { + for (t8_locidx_t ielem = 0; ielem < num_elements; ++ielem) { element_data[ielem] = t8_element_get_value (data, ielem).values; } @@ -294,7 +294,7 @@ t8_interpolation () /* Construct a cmesh */ t8_cmesh_t cmesh = - t8_cmesh_new_hypercube (T8_ECLASS_PYRAMID, sc_MPI_COMM_WORLD, 0, 0, 0); + t8_cmesh_new_from_class (T8_ECLASS_HEX, sc_MPI_COMM_WORLD); /* Construct a forest with one tree */ t8_forest_t forest = @@ -307,22 +307,23 @@ t8_interpolation () sc_array_new_count (sizeof (t8_step7_element_data_t), t8_forest_get_local_num_elements (forest)); - const t8_locidx_t numTrees = t8_forest_get_num_local_trees (forest); + const t8_locidx_t num_trees = t8_forest_get_num_local_trees (forest); /* Loop over all trees. The index of the data array is independent of the tree * index. Thus, we set the index of the tree index to zero and add one in each * loop step of the inner loop. */ int itree; int ielem; - for (itree = 0, ielem = 0; itree < numTrees; itree++) { - const t8_locidx_t numElem = + for (itree = 0, ielem = 0; itree < num_trees; itree++) { + const t8_locidx_t num_elem = t8_forest_get_tree_num_elements (forest, itree); /* Inner loop: Iteration over the elements of the local tree */ - for (t8_locidx_t ielemTree = 0; ielemTree < numElem; ielemTree++, ielem++) { + for (t8_locidx_t ielem_tree = 0; ielem_tree < num_elem; + ielem_tree++, ielem++) { /* To calculate the distance to the centroid of an element the element is saved */ const t8_element_t *element = - t8_forest_get_element_in_tree (forest, itree, ielemTree); + t8_forest_get_element_in_tree (forest, itree, ielem_tree); /* Get the centroid of the local element. */ t8_forest_element_centroid (forest, 0, element, centroid); @@ -380,6 +381,7 @@ t8_interpolation () /* Save the new forest as old forest */ forest = forest_adapt; data = adapt_data; + t8_forest_unref (&forest_adapt); /* Now you could continue working with the forest. */ T8_FREE (data); From 34f90a2d2d3361617ca2be7b4813259b09bada27 Mon Sep 17 00:00:00 2001 From: Evgenii Andreev Date: Tue, 30 May 2023 22:45:55 +0200 Subject: [PATCH 235/255] Added constness to flags --- doc/author_andreev.txt | 1 + src/t8_forest/t8_forest.c | 14 +++++++------- src/t8_forest/t8_forest_io.h | 14 +++++++------- 3 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 doc/author_andreev.txt diff --git a/doc/author_andreev.txt b/doc/author_andreev.txt new file mode 100644 index 0000000000..8e0717150c --- /dev/null +++ b/doc/author_andreev.txt @@ -0,0 +1 @@ +I place my contributions to t8code under the FreeBSD license. Evgenii Andreev (edirab@yandex.ru) \ No newline at end of file diff --git a/src/t8_forest/t8_forest.c b/src/t8_forest/t8_forest.c index 74efcdcaf7..287f71df7c 100644 --- a/src/t8_forest/t8_forest.c +++ b/src/t8_forest/t8_forest.c @@ -1445,14 +1445,14 @@ t8_forest_compute_elements_offset (t8_forest_t forest) int t8_forest_write_vtk_ext (t8_forest_t forest, const char *fileprefix, - int write_treeid, - int write_mpirank, - int write_level, - int write_element_id, - int write_ghosts, - int write_curved, + const int write_treeid, + const int write_mpirank, + const int write_level, + const int write_element_id, + const int write_ghosts, + const int write_curved, int do_not_use_API, - int num_data, t8_vtk_data_field_t *data) + const int num_data, t8_vtk_data_field_t *data) { T8_ASSERT (forest != NULL); T8_ASSERT (forest->rc.refcount > 0); diff --git a/src/t8_forest/t8_forest_io.h b/src/t8_forest/t8_forest_io.h index e10f3b65c9..ea4f4316cd 100644 --- a/src/t8_forest/t8_forest_io.h +++ b/src/t8_forest/t8_forest_io.h @@ -73,14 +73,14 @@ void t8_forest_save (t8_forest_t forest); */ int t8_forest_write_vtk_ext (t8_forest_t forest, const char *fileprefix, - int write_treeid, - int write_mpirank, - int write_level, - int write_element_id, - int write_ghosts, - int write_curved, + const int write_treeid, + const int write_mpirank, + const int write_level, + const int write_element_id, + const int write_ghosts, + const int write_curved, int do_not_use_API, - int num_data, + const int num_data, t8_vtk_data_field_t *data); /** Write the forest in a parallel vtu format. Writes one master From b2f4bcde01369fc1b1e58170deb9d97ddfe9df02 Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Wed, 31 May 2023 21:48:55 +0200 Subject: [PATCH 236/255] Correct element calculations --- tutorials/general/t8_step7_interpolation.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/general/t8_step7_interpolation.cxx b/tutorials/general/t8_step7_interpolation.cxx index 0884ce8e76..d28f3aa649 100644 --- a/tutorials/general/t8_step7_interpolation.cxx +++ b/tutorials/general/t8_step7_interpolation.cxx @@ -326,7 +326,7 @@ t8_interpolation () t8_forest_get_element_in_tree (forest, itree, ielem_tree); /* Get the centroid of the local element. */ - t8_forest_element_centroid (forest, 0, element, centroid); + t8_forest_element_centroid (forest, itree, element, centroid); /* Calculation of the distance to the centroid for the referenced element */ elem_data->values = t8_vec_dist (centroid, midpoint); From d6b07a73b958a28357687bb1e4ebd2016843f53c Mon Sep 17 00:00:00 2001 From: Evgenii Andreev Date: Wed, 31 May 2023 23:49:27 +0200 Subject: [PATCH 237/255] Added constancy to flags in t8_forest_replace_t --- src/t8_forest/t8_forest_general.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/t8_forest/t8_forest_general.h b/src/t8_forest/t8_forest_general.h index d7f8c42575..f11e6e1c60 100644 --- a/src/t8_forest/t8_forest_general.h +++ b/src/t8_forest/t8_forest_general.h @@ -88,10 +88,11 @@ typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t which_tree, t8_eclass_scheme_c *ts, - int refine, int num_outgoing, - t8_locidx_t first_outgoing, - int num_incoming, - t8_locidx_t first_incoming); + const int refine, + const int num_outgoing, + const t8_locidx_t first_outgoing, + const int num_incoming, + const t8_locidx_t first_incoming); /** Callback function prototype to decide for refining and coarsening. * If \a is_family equals 1, the first \a num_elements in \a elements From c2137c0b69238daeca75b331280c32c57ad0cd42 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Thu, 1 Jun 2023 16:33:09 +0200 Subject: [PATCH 238/255] Fix a typo --- src/t8_forest/t8_forest_iterate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_forest/t8_forest_iterate.h b/src/t8_forest/t8_forest_iterate.h index 59e5a24081..ea36db2c33 100644 --- a/src/t8_forest/t8_forest_iterate.h +++ b/src/t8_forest/t8_forest_iterate.h @@ -103,7 +103,7 @@ void t8_forest_search (t8_forest_t forest, t8_forest_search_query_fn query_fn, sc_array_t *queries); -/** Given two forest where the elemnts in one forest are either direct children or +/** Given two forest where the elements in one forest are either direct children or * parents of the elements in the other forest * compare the two forests and for each refined element or coarsened * family in the old one, call a callback function providing the local indices From 1b764e3890d74941817669caafcaa862ced3c84d Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 2 Jun 2023 09:17:49 +0200 Subject: [PATCH 239/255] Add Comment --- src/t8_data/t8_shmem.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/t8_data/t8_shmem.h b/src/t8_data/t8_shmem.h index bdf7056878..0f1a9e017b 100644 --- a/src/t8_data/t8_shmem.h +++ b/src/t8_data/t8_shmem.h @@ -153,6 +153,7 @@ void t8_shmem_array_allgather (const void *sendbuf, * sendcount. * The total number of items of each node is then used to compute the * recvcount-array and displacement-array between nodes. + * Use t8_shmem_array_allgather if the sendcount is equal on all procs for better scaling. * * \param[in] sendbuf the source from this process * \param[in] sendcount the number of items to gather on this proc From b29fb2765aca42e165199f40a846426f7cd7604f Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Fri, 2 Jun 2023 15:05:43 +0200 Subject: [PATCH 240/255] Check memory --- tutorials/general/t8_step7_interpolation.cxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tutorials/general/t8_step7_interpolation.cxx b/tutorials/general/t8_step7_interpolation.cxx index d28f3aa649..2346aadb03 100644 --- a/tutorials/general/t8_step7_interpolation.cxx +++ b/tutorials/general/t8_step7_interpolation.cxx @@ -318,7 +318,6 @@ t8_interpolation () const t8_locidx_t num_elem = t8_forest_get_tree_num_elements (forest, itree); /* Inner loop: Iteration over the elements of the local tree */ - for (t8_locidx_t ielem_tree = 0; ielem_tree < num_elem; ielem_tree++, ielem++) { /* To calculate the distance to the centroid of an element the element is saved */ @@ -350,7 +349,6 @@ t8_interpolation () /* Build a second forest to store the adapted forest - keep the old one */ t8_forest_ref (forest); - t8_forest_init (&forest_adapt); /* Adapt the forest correponding tho the callback function (distance to the centroid) */ forest_adapt = @@ -379,13 +377,14 @@ t8_interpolation () t8_write_vtu (forest_adapt, adapt_data, "t8_step7_adapt_forest"); /* Save the new forest as old forest */ + t8_forest_unref (&forest); forest = forest_adapt; - data = adapt_data; + *data = *adapt_data; t8_forest_unref (&forest_adapt); /* Now you could continue working with the forest. */ T8_FREE (data); - t8_forest_unref (&forest); + T8_FREE (adapt_data); } int @@ -399,9 +398,9 @@ t8_step7_main (int argc, char **argv) SC_CHECK_MPI (mpiret); /* Initialize the sc library, has to happen before we initialize t8code. */ - sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_PRODUCTION); + sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_DEBUG); /* Initialize t8code with log level SC_LP_PRODUCTION. See sc.h for more info on the log levels. */ - t8_init (SC_LP_PRODUCTION); + t8_init (SC_LP_DEBUG); /* Create forest, define data on forest, adapt forest, interpolate data */ t8_interpolation (); From 7992247bfa50de183d15d6beaf701699cbff420d Mon Sep 17 00:00:00 2001 From: Chiara Hergl Date: Fri, 2 Jun 2023 15:07:11 +0200 Subject: [PATCH 241/255] Change from debug --- tutorials/general/t8_step7_interpolation.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorials/general/t8_step7_interpolation.cxx b/tutorials/general/t8_step7_interpolation.cxx index 2346aadb03..6a6f275398 100644 --- a/tutorials/general/t8_step7_interpolation.cxx +++ b/tutorials/general/t8_step7_interpolation.cxx @@ -398,9 +398,9 @@ t8_step7_main (int argc, char **argv) SC_CHECK_MPI (mpiret); /* Initialize the sc library, has to happen before we initialize t8code. */ - sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_DEBUG); + sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_PRODUCTION); /* Initialize t8code with log level SC_LP_PRODUCTION. See sc.h for more info on the log levels. */ - t8_init (SC_LP_DEBUG); + t8_init (SC_LP_PRODUCTION); /* Create forest, define data on forest, adapt forest, interpolate data */ t8_interpolation (); From f4f72816c38f2c78c53ce42fc3f8ab808d027497 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 2 Jun 2023 15:45:07 +0200 Subject: [PATCH 242/255] Fix memory-leaks --- tutorials/general/t8_step7_interpolation.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tutorials/general/t8_step7_interpolation.cxx b/tutorials/general/t8_step7_interpolation.cxx index 6a6f275398..3589cc874f 100644 --- a/tutorials/general/t8_step7_interpolation.cxx +++ b/tutorials/general/t8_step7_interpolation.cxx @@ -376,6 +376,10 @@ t8_interpolation () (struct t8_step7_adapt_data *) t8_forest_get_user_data (forest_adapt); t8_write_vtu (forest_adapt, adapt_data, "t8_step7_adapt_forest"); + /* Free the memory */ + sc_array_destroy (adapt_data->element_data); + sc_array_destroy (data->element_data); + /* Save the new forest as old forest */ t8_forest_unref (&forest); forest = forest_adapt; @@ -385,6 +389,7 @@ t8_interpolation () /* Now you could continue working with the forest. */ T8_FREE (data); T8_FREE (adapt_data); + T8_FREE (elem_data); } int From 74866ac8d69a12182bcd38bc1999f24c55990073 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 12 Jun 2023 14:25:04 +0200 Subject: [PATCH 243/255] Delete error-message, as behaviour is steared correctly in sc_shmem_write_start --- src/t8_data/t8_shmem.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/t8_data/t8_shmem.c b/src/t8_data/t8_shmem.c index 9695330487..19fd360a2f 100644 --- a/src/t8_data/t8_shmem.c +++ b/src/t8_data/t8_shmem.c @@ -310,6 +310,7 @@ t8_shmem_array_allgatherv_common (void *sendbuf, t8_compute_recvcounts_displs (intra_recv_total, inter_recvcount, inter_displ, sizeof (sendtype), internode_comm); + if (t8_shmem_array_start_writing (recvarray)) { mpiret = sc_MPI_Allgatherv (noderecvchar, intra_recv_total, sendtype, @@ -318,9 +319,6 @@ t8_shmem_array_allgatherv_common (void *sendbuf, SC_CHECK_MPI (mpiret); T8_FREE (noderecvchar); } - else { - t8_errorf ("Can not write shmem-array.\n"); - } t8_shmem_array_end_writing (recvarray); T8_FREE (inter_displ); From fe5fb312fd4678b5a71cd1f5ecc059c0c20ce4af Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 13 Jun 2023 09:30:23 +0200 Subject: [PATCH 244/255] delete non-used variables --- src/t8_forest/t8_forest_vtk.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index 4b544ff03b..da953a41f3 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -361,7 +361,6 @@ t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, long int point_id = 0; /* The id of the point in the points Object. */ double coordinates[3]; - double vertex_coords[3] = { 0, 0, 0 }; const t8_gloidx_t offset = t8_forest_get_first_local_element_id (forest); t8_gloidx_t elem_id = offset; @@ -428,8 +427,6 @@ t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, vtkDoubleArray **dataArrays; dataArrays = T8_ALLOC (vtkDoubleArray *, num_data); - t8_cmesh_t cmesh = t8_forest_get_cmesh (forest); - const t8_locidx_t num_local_trees = t8_forest_get_num_local_trees (forest); From ec2bea8cfda2a531260a23088beb102511034f2f Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 13 Jun 2023 11:20:19 +0200 Subject: [PATCH 245/255] Delete obsolete includes --- src/t8_forest/t8_forest_vtk.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index da953a41f3..a742f823fd 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -23,11 +23,9 @@ #include #include #include -#include #include #include #include -#include "t8_cmesh/t8_cmesh_trees.h" #include "t8_forest_types.h" #if T8_WITH_VTK #include From ef412ed0ba48cf9f463695b9ae374aa6d68247c6 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 20 Jun 2023 15:51:43 +0200 Subject: [PATCH 246/255] switched to t8_forest_write_vtk_ext to be able to write ghost cells --- tutorials/general/t8_step4_partition_balance_ghost.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/general/t8_step4_partition_balance_ghost.cxx b/tutorials/general/t8_step4_partition_balance_ghost.cxx index 4e7b3a6b81..8503805b94 100644 --- a/tutorials/general/t8_step4_partition_balance_ghost.cxx +++ b/tutorials/general/t8_step4_partition_balance_ghost.cxx @@ -281,7 +281,7 @@ t8_step4_main (int argc, char **argv) (" [step4] Repartitioned forest and built ghost layer.\n"); t8_step3_print_forest_information (forest); /* Write forest to vtu files. */ - t8_forest_write_vtk (forest, prefix_partition_ghost); + t8_forest_write_vtk_ext (forest, prefix_partition_ghost, 1, 1, 1, 1, 1, 0, 0, 0, NULL); /* * Balance From 03a35e3137fe1e7d667a5a80cd98ee70141934f7 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 20 Jun 2023 17:59:38 +0200 Subject: [PATCH 247/255] added BSD statement --- doc/author_geihe.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/author_geihe.txt diff --git a/doc/author_geihe.txt b/doc/author_geihe.txt new file mode 100644 index 0000000000..9411959925 --- /dev/null +++ b/doc/author_geihe.txt @@ -0,0 +1 @@ +I place my contributions to t8code under the FreeBSD license. Benedict Geihe (bgeihe@uni-koeln.de) From 9d45f266f217ab54926b49ece8fb0c9236329bdb Mon Sep 17 00:00:00 2001 From: bgeihe <135045760+bgeihe@users.noreply.github.com> Date: Wed, 21 Jun 2023 16:11:24 +0200 Subject: [PATCH 248/255] Disable VK API Since the export of ghost elements is not supported with the VTK API, we have to disable it Co-authored-by: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> --- tutorials/general/t8_step4_partition_balance_ghost.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/general/t8_step4_partition_balance_ghost.cxx b/tutorials/general/t8_step4_partition_balance_ghost.cxx index 8503805b94..b87faa4111 100644 --- a/tutorials/general/t8_step4_partition_balance_ghost.cxx +++ b/tutorials/general/t8_step4_partition_balance_ghost.cxx @@ -281,7 +281,7 @@ t8_step4_main (int argc, char **argv) (" [step4] Repartitioned forest and built ghost layer.\n"); t8_step3_print_forest_information (forest); /* Write forest to vtu files. */ - t8_forest_write_vtk_ext (forest, prefix_partition_ghost, 1, 1, 1, 1, 1, 0, 0, 0, NULL); + t8_forest_write_vtk_ext (forest, prefix_partition_ghost, 1, 1, 1, 1, 1, 0, 1, 0, NULL); /* * Balance From 9de12a9dd182263b97f805c86cc40a010ade619a Mon Sep 17 00:00:00 2001 From: David Knapp Date: Thu, 22 Jun 2023 12:19:24 +0200 Subject: [PATCH 249/255] Indentation --- src/t8_vtk/t8_vtk_reader.hxx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/t8_vtk/t8_vtk_reader.hxx b/src/t8_vtk/t8_vtk_reader.hxx index 8277150c5a..0f1045a6c9 100644 --- a/src/t8_vtk/t8_vtk_reader.hxx +++ b/src/t8_vtk/t8_vtk_reader.hxx @@ -132,7 +132,6 @@ t8_cmesh_t t8_vtk_reader_cmesh (const char *filename, sc_MPI_Comm comm, const vtk_file_type_t vtk_file_type); - T8_EXTERN_C_END (); #endif /* T8_VTK_READER */ From 34cd5106558c575addf213da01db200cd5f58480 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Thu, 22 Jun 2023 13:56:53 +0200 Subject: [PATCH 250/255] ran indent --- tutorials/general/t8_step4_partition_balance_ghost.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tutorials/general/t8_step4_partition_balance_ghost.cxx b/tutorials/general/t8_step4_partition_balance_ghost.cxx index 8503805b94..7478e8dddf 100644 --- a/tutorials/general/t8_step4_partition_balance_ghost.cxx +++ b/tutorials/general/t8_step4_partition_balance_ghost.cxx @@ -281,7 +281,8 @@ t8_step4_main (int argc, char **argv) (" [step4] Repartitioned forest and built ghost layer.\n"); t8_step3_print_forest_information (forest); /* Write forest to vtu files. */ - t8_forest_write_vtk_ext (forest, prefix_partition_ghost, 1, 1, 1, 1, 1, 0, 0, 0, NULL); + t8_forest_write_vtk_ext (forest, prefix_partition_ghost, 1, 1, 1, 1, 1, 0, + 0, 0, NULL); /* * Balance From 688d8d2c9d2a5007f5e973955eefcd499c1ba659 Mon Sep 17 00:00:00 2001 From: ililikakis Date: Sun, 25 Jun 2023 15:48:47 +0200 Subject: [PATCH 251/255] reduced num testscases for LESS-TESTS --- src/t8_cmesh/t8_cmesh_testcases.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_testcases.c b/src/t8_cmesh/t8_cmesh_testcases.c index e9977550e0..c2edf2ff83 100644 --- a/src/t8_cmesh/t8_cmesh_testcases.c +++ b/src/t8_cmesh/t8_cmesh_testcases.c @@ -29,19 +29,15 @@ #include #include -#ifdef T8_ENABLE_LESS_TESTS -#define T8_CMESH_TEST_NUM_COMMS 1 -#define T8_CMESH_BINARY 2 -#define T8_CMESH_DIM_RANGE 4 -#define T8_CMESH_MAX_TEST_DIMS 3 -#define T8_CMESH_MAX_NUM_OF_TREES 20 -#define T8_CMESH_MAX_NUM_OF_PRISMS 20 -#define T8_CMESH_MAX_NUM_XYZ_TREES 5 -#else #define T8_CMESH_TEST_NUM_COMMS 1 #define T8_CMESH_BINARY 2 #define T8_CMESH_DIM_RANGE 4 /* this is the dim range for hypercube hybrid and empty cmesh */ #define T8_CMESH_MAX_TEST_DIMS 3 +#ifdef T8_ENABLE_LESS_TESTS +#define T8_CMESH_MAX_NUM_OF_TREES 5 +#define T8_CMESH_MAX_NUM_OF_PRISMS 5 +#define T8_CMESH_MAX_NUM_XYZ_TREES 3 +#else #define T8_CMESH_MAX_NUM_OF_TREES 10 #define T8_CMESH_MAX_NUM_OF_PRISMS 10 #define T8_CMESH_MAX_NUM_XYZ_TREES 5 From 7cfc233ce30e7a79ca5a49b2b36a4bb83ad2bf2a Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 26 Jun 2023 13:38:49 +0200 Subject: [PATCH 252/255] Parametrized comms --- test/t8_data/t8_gtest_shmem.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/t8_data/t8_gtest_shmem.cxx b/test/t8_data/t8_gtest_shmem.cxx index 097abd7437..0441da91c6 100644 --- a/test/t8_data/t8_gtest_shmem.cxx +++ b/test/t8_data/t8_gtest_shmem.cxx @@ -29,15 +29,14 @@ /* *INDENT-OFF* */ #define T8_TEST_SHMEM_NUM_COMMS 2 -class shmem : public testing::TestWithParam{ +class shmem : public testing::TestWithParam>{ protected: void SetUp() override { - icomm = GetParam(); - comm = test_comms[icomm]; + icomm = std::get<0>(GetParam()); + comm = std::get<1>(GetParam()); } int icomm; sc_MPI_Comm comm; - sc_MPI_Comm test_comms[T8_TEST_SHMEM_NUM_COMMS] = { sc_MPI_COMM_WORLD, sc_MPI_COMM_SELF }; const char *test_comms_names[T8_TEST_SHMEM_NUM_COMMS] = { "comm world", "comm self" }; }; @@ -332,5 +331,5 @@ TEST_P(shmem, test_shmem_array){ } } -INSTANTIATE_TEST_SUITE_P(t8_gtest_shmem, shmem, testing::Range(0, T8_TEST_SHMEM_NUM_COMMS)); +INSTANTIATE_TEST_SUITE_P(t8_gtest_shmem, shmem, testing::Combine(testing::Range(0, T8_TEST_SHMEM_NUM_COMMS), testing::Values(sc_MPI_COMM_WORLD, sc_MPI_COMM_SELF ))); /* *INDENT-ON* */ From f099c647df2f08dc9a75b4334d935dcb9faf616b Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 26 Jun 2023 13:39:46 +0200 Subject: [PATCH 253/255] Remove old debug output --- test/t8_data/t8_gtest_shmem.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/t8_data/t8_gtest_shmem.cxx b/test/t8_data/t8_gtest_shmem.cxx index 0441da91c6..62bc0e3b60 100644 --- a/test/t8_data/t8_gtest_shmem.cxx +++ b/test/t8_data/t8_gtest_shmem.cxx @@ -174,8 +174,6 @@ TEST_P(shmem, test_shmem_array_allgatherv){ SC_CHECK_MPI (mpiret); mpiret = sc_MPI_Comm_size (comm, &mpisize); SC_CHECK_MPI (mpiret); - - t8_debugf("[D] mpirank: %i\n", mpirank); /* Each process fills an array of size mpirank * 10, where the elements * in the arrays increase, such that in the shmem we have a contiguous increase. */ From c4403a35ccc79ee746ed4af958921a000e4c3ce0 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 26 Jun 2023 13:41:49 +0200 Subject: [PATCH 254/255] More debug output removed --- test/t8_data/t8_gtest_shmem.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/t8_data/t8_gtest_shmem.cxx b/test/t8_data/t8_gtest_shmem.cxx index 62bc0e3b60..5e9556eb8f 100644 --- a/test/t8_data/t8_gtest_shmem.cxx +++ b/test/t8_data/t8_gtest_shmem.cxx @@ -187,8 +187,6 @@ TEST_P(shmem, test_shmem_array_allgatherv){ sendbuf[i] = first_array_value + i; } - t8_debugf("[D] total_size: %i\n", total_size); - for(int shmem_type_int = SC_SHMEM_BASIC; shmem_type_int < SC_SHMEM_NUM_TYPES; ++shmem_type_int){ t8_debugf("Checking shared memory type %s.\n", sc_shmem_type_to_string[shmem_type_int]); From 6d6f139376437fafa08fd63b5c0d6f4f3e0e884d Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 26 Jun 2023 14:14:14 +0200 Subject: [PATCH 255/255] Parametrize shmem_type --- test/t8_data/t8_gtest_shmem.cxx | 297 ++++++++++++++++---------------- 1 file changed, 148 insertions(+), 149 deletions(-) diff --git a/test/t8_data/t8_gtest_shmem.cxx b/test/t8_data/t8_gtest_shmem.cxx index 5e9556eb8f..c1ad2f6e44 100644 --- a/test/t8_data/t8_gtest_shmem.cxx +++ b/test/t8_data/t8_gtest_shmem.cxx @@ -29,14 +29,20 @@ /* *INDENT-OFF* */ #define T8_TEST_SHMEM_NUM_COMMS 2 -class shmem : public testing::TestWithParam>{ +class shmem : public testing::TestWithParam>{ protected: void SetUp() override { icomm = std::get<0>(GetParam()); comm = std::get<1>(GetParam()); + shmem_type_int = std::get<2>(GetParam()); + shmem_type = (sc_shmem_type_t) shmem_type; + } int icomm; sc_MPI_Comm comm; + int shmem_type_int; + sc_shmem_type_t shmem_type; + const char *test_comms_names[T8_TEST_SHMEM_NUM_COMMS] = { "comm world", "comm self" }; }; @@ -100,68 +106,65 @@ TEST_P(shmem, test_sc_shmem_alloc){ srand (0); /* Checking shared memory type */ - for (int shmem_type_int = SC_SHMEM_BASIC; - shmem_type_int < SC_SHMEM_NUM_TYPES; ++shmem_type_int) { - const sc_shmem_type_t shmem_type = (sc_shmem_type_t) shmem_type_int; - int intrasize, intrarank; - t8_debugf("Checking shared memory type %s.\n", sc_shmem_type_to_string[shmem_type]); + const sc_shmem_type_t shmem_type = (sc_shmem_type_t) shmem_type_int; + int intrasize, intrarank; + t8_debugf("Checking shared memory type %s.\n", sc_shmem_type_to_string[shmem_type]); - /* setup shared memory usage */ - t8_shmem_init (comm); - t8_shmem_set_type (comm, shmem_type); + /* setup shared memory usage */ + t8_shmem_init (comm); + t8_shmem_set_type (comm, shmem_type); #if T8_ENABLE_MPI - const sc_shmem_type_t control_shmem_type = sc_shmem_get_type (comm); - ASSERT_EQ(shmem_type, control_shmem_type) << "Setting shmem type not succesfull."; + const sc_shmem_type_t control_shmem_type = sc_shmem_get_type (comm); + ASSERT_EQ(shmem_type, control_shmem_type) << "Setting shmem type not succesfull."; #endif - sc_mpi_comm_get_node_comms (comm, &intranode, &internode); + sc_mpi_comm_get_node_comms (comm, &intranode, &internode); #if T8_ENABLE_MPI - ASSERT_NE(intranode, sc_MPI_COMM_NULL) << "intra node communicator not set."; - ASSERT_NE(internode, sc_MPI_COMM_NULL) << "inter node communicator not set."; + ASSERT_NE(intranode, sc_MPI_COMM_NULL) << "intra node communicator not set."; + ASSERT_NE(internode, sc_MPI_COMM_NULL) << "inter node communicator not set."; #endif - /* Get the size and rank on the shared memory region (intranode) */ - mpiret = sc_MPI_Comm_size (intranode, &intrasize); - SC_CHECK_MPI (mpiret); - mpiret = sc_MPI_Comm_rank (intranode, &intrarank); - SC_CHECK_MPI (mpiret); - - /* Allocate one integer */ - int *shared_int = - (int *) sc_shmem_malloc (t8_get_package_id (), sizeof (int), intrasize, - comm); - t8_debugf("Allocated %i integers at pos %p.\n", intrasize, (void *) shared_int); - - /* Write something into the array */ - const int random_number = rand (); - if (sc_shmem_write_start (shared_int, comm)) { - if ( + /* Get the size and rank on the shared memory region (intranode) */ + mpiret = sc_MPI_Comm_size (intranode, &intrasize); + SC_CHECK_MPI (mpiret); + mpiret = sc_MPI_Comm_rank (intranode, &intrarank); + SC_CHECK_MPI (mpiret); + + /* Allocate one integer */ + int *shared_int = + (int *) sc_shmem_malloc (t8_get_package_id (), sizeof (int), intrasize, + comm); + t8_debugf("Allocated %i integers at pos %p.\n", intrasize, (void *) shared_int); + + /* Write something into the array */ + const int random_number = rand (); + if (sc_shmem_write_start (shared_int, comm)) { + if ( #if defined(SC_ENABLE_MPIWINSHARED) - shmem_type == SC_SHMEM_WINDOW - || shmem_type == SC_SHMEM_WINDOW_PRESCAN || + shmem_type == SC_SHMEM_WINDOW + || shmem_type == SC_SHMEM_WINDOW_PRESCAN || #endif #if defined(__bgq__) - shmem_type == SC_SHMEM_BGQ || shmem_type == SC_SHMEM_BGQ_PRESCAN || + shmem_type == SC_SHMEM_BGQ || shmem_type == SC_SHMEM_BGQ_PRESCAN || #endif - 0 /* If neither SC_ENABLE_MPIWINSHARED or __bgq__ are defined, we neet a condition in this if - * but do not want to execute any code. Hence, 0. */ - ) { - ASSERT_EQ(intrarank, 0) << "Type is one of window, window_prescan, bgq or bgq_prescan and this process should not have write permissions.\n"; - } - t8_debugf("I have write permissions\n"); - shared_int[0] = random_number; + 0 /* If neither SC_ENABLE_MPIWINSHARED or __bgq__ are defined, we neet a condition in this if + * but do not want to execute any code. Hence, 0. */ + ) { + ASSERT_EQ(intrarank, 0) << "Type is one of window, window_prescan, bgq or bgq_prescan and this process should not have write permissions.\n"; } - sc_shmem_write_end (shared_int, comm); + t8_debugf("I have write permissions\n"); + shared_int[0] = random_number; + } + sc_shmem_write_end (shared_int, comm); - ASSERT_EQ(shared_int[0], random_number) << "shared integer was not assigned correctly at position 0."; + ASSERT_EQ(shared_int[0], random_number) << "shared integer was not assigned correctly at position 0."; - /* Free the memory */ - sc_shmem_free (t8_get_package_id (), shared_int, comm); - /* Finalize shmem usage so that we can use a different shmem type - * in the next loop iteration. */ - t8_shmem_finalize (comm); - } + /* Free the memory */ + sc_shmem_free (t8_get_package_id (), shared_int, comm); + /* Finalize shmem usage so that we can use a different shmem type + * in the next loop iteration. */ + t8_shmem_finalize (comm); } TEST_P(shmem, test_shmem_array_allgatherv){ @@ -187,49 +190,46 @@ TEST_P(shmem, test_shmem_array_allgatherv){ sendbuf[i] = first_array_value + i; } - for(int shmem_type_int = SC_SHMEM_BASIC; - shmem_type_int < SC_SHMEM_NUM_TYPES; ++shmem_type_int){ - t8_debugf("Checking shared memory type %s.\n", sc_shmem_type_to_string[shmem_type_int]); + t8_debugf("Checking shared memory type %s.\n", sc_shmem_type_to_string[shmem_type_int]); - const sc_shmem_type_t shmem_type = (sc_shmem_type_t) shmem_type_int; - - /* setup shared memory usage */ - t8_shmem_init (comm); - t8_shmem_set_type (comm, shmem_type); + const sc_shmem_type_t shmem_type = (sc_shmem_type_t) shmem_type_int; + + /* setup shared memory usage */ + t8_shmem_init (comm); + t8_shmem_set_type (comm, shmem_type); #if T8_ENABLE_MPI - const sc_shmem_type_t control_shmem_type = sc_shmem_get_type (comm); - ASSERT_EQ(shmem_type, control_shmem_type) << "Setting shmem type not succesfull."; + const sc_shmem_type_t control_shmem_type = sc_shmem_get_type (comm); + ASSERT_EQ(shmem_type, control_shmem_type) << "Setting shmem type not succesfull."; #endif - t8_shmem_array_t shmem_array; - t8_shmem_array_init(&shmem_array, element_size, total_size, comm); + t8_shmem_array_t shmem_array; + t8_shmem_array_init(&shmem_array, element_size, total_size, comm); - sc_MPI_Comm check_comm = t8_shmem_array_get_comm (shmem_array); - /* Check communicator of shared memory array. */ - ASSERT_EQ(comm, check_comm) << "Shared memory array has wrong communicator."; + sc_MPI_Comm check_comm = t8_shmem_array_get_comm (shmem_array); + /* Check communicator of shared memory array. */ + ASSERT_EQ(comm, check_comm) << "Shared memory array has wrong communicator."; - /* Check element count of shared memory array. */ - const int check_count = - t8_shmem_array_get_elem_count (shmem_array); - ASSERT_EQ(check_count, total_size) << "shared memory array has wrong element count."; + /* Check element count of shared memory array. */ + const int check_count = + t8_shmem_array_get_elem_count (shmem_array); + ASSERT_EQ(check_count, total_size) << "shared memory array has wrong element count."; - /* Check element size of shared memory array. */ - const size_t check_size = - t8_shmem_array_get_elem_size (shmem_array); - ASSERT_EQ(check_size, element_size) << "shared memory has wrong element size."; + /* Check element size of shared memory array. */ + const size_t check_size = + t8_shmem_array_get_elem_size (shmem_array); + ASSERT_EQ(check_size, element_size) << "shared memory has wrong element size."; - t8_shmem_array_allgatherv((void *) sendbuf, array_length, T8_MPI_GLOIDX, shmem_array, - T8_MPI_GLOIDX, comm); + t8_shmem_array_allgatherv((void *) sendbuf, array_length, T8_MPI_GLOIDX, shmem_array, + T8_MPI_GLOIDX, comm); - for(int i = 0; i < total_size; ++i){ - const int value = t8_shmem_array_get_gloidx(shmem_array, i); - ASSERT_EQ(value, i) << "Value at position " << i << " not correct (expected " << i << " got " << value << ")"; - } - - t8_shmem_array_destroy(&shmem_array); - t8_shmem_finalize(comm); + for(int i = 0; i < total_size; ++i){ + const int value = t8_shmem_array_get_gloidx(shmem_array, i); + ASSERT_EQ(value, i) << "Value at position " << i << " not correct (expected " << i << " got " << value << ")"; } + + t8_shmem_array_destroy(&shmem_array); + t8_shmem_finalize(comm); T8_FREE(sendbuf); } @@ -248,84 +248,83 @@ TEST_P(shmem, test_shmem_array){ srand (0); /* Checking shared memory type */ - for (int shmem_type_int = SC_SHMEM_BASIC; - shmem_type_int < SC_SHMEM_NUM_TYPES; ++shmem_type_int) { - const sc_shmem_type_t shmem_type = (sc_shmem_type_t) shmem_type_int; - - /* setup shared memory usage */ - t8_shmem_init (comm); - t8_shmem_set_type (comm, shmem_type); + const sc_shmem_type_t shmem_type = (sc_shmem_type_t) shmem_type_int; + + /* setup shared memory usage */ + t8_shmem_init (comm); + t8_shmem_set_type (comm, shmem_type); #if T8_ENABLE_MPI - const sc_shmem_type_t control_shmem_type = sc_shmem_get_type (comm); - ASSERT_EQ(shmem_type, control_shmem_type) << "Setting shmem type not succesfull."; + const sc_shmem_type_t control_shmem_type = sc_shmem_get_type (comm); + ASSERT_EQ(shmem_type, control_shmem_type) << "Setting shmem type not succesfull."; #endif - /* Allocate one integer */ - t8_shmem_array_t shmem_array; - t8_shmem_array_init (&shmem_array, element_size, array_length, comm); - - sc_MPI_Comm check_comm = t8_shmem_array_get_comm (shmem_array); - /* Check communicator of shared memory array. */ - ASSERT_EQ(comm, check_comm) << "Shared memory array has wrong communicator."; - - /* Check element count of shared memory array. */ - const int check_count = - t8_shmem_array_get_elem_count (shmem_array); - ASSERT_EQ(check_count, array_length) << "shared memory array has wrong element count."; - - /* Check element size of shared memory array. */ - const int check_size = - t8_shmem_array_get_elem_size (shmem_array); - ASSERT_EQ(check_size, element_size) << "shared memory has wrong element size."; - - /* Write into array */ - /* In the first half we use the t8_shmem_array_set_gloidx function, - * we then use a standard store to write - * and at the end we use t8_shmem_array_index_for_writing. - */ - if (t8_shmem_array_start_writing (shmem_array)) { - /* Double check that array_length is big enough so that each of the three cases - * is covered. */ - ASSERT_TRUE(0 < array_length / 3 - && array_length / 3 < (int) (2. / 3 * array_length) - && (int) (2. / 3 * array_length) < array_length) << "Please choose a larger value for array length."; - - t8_gloidx_t *array = - t8_shmem_array_get_gloidx_array_for_writing (shmem_array); - for (int i = 0; i < array_length / 3; ++i) { - t8_shmem_array_set_gloidx (shmem_array, i, i); - } - for (int i = array_length / 3; i < 2. / 3 * array_length; ++i) { - array[i] = i; - } - for (int i = 2. / 3 * array_length; i < array_length; ++i) { - t8_gloidx_t *index = - (t8_gloidx_t *) t8_shmem_array_index_for_writing (shmem_array, i); - *index = i; - } + /* Allocate one integer */ + t8_shmem_array_t shmem_array; + t8_shmem_array_init (&shmem_array, element_size, array_length, comm); + + sc_MPI_Comm check_comm = t8_shmem_array_get_comm (shmem_array); + /* Check communicator of shared memory array. */ + ASSERT_EQ(comm, check_comm) << "Shared memory array has wrong communicator."; + + /* Check element count of shared memory array. */ + const int check_count = + t8_shmem_array_get_elem_count (shmem_array); + ASSERT_EQ(check_count, array_length) << "shared memory array has wrong element count."; + + /* Check element size of shared memory array. */ + const int check_size = + t8_shmem_array_get_elem_size (shmem_array); + ASSERT_EQ(check_size, element_size) << "shared memory has wrong element size."; + + /* Write into array */ + /* In the first half we use the t8_shmem_array_set_gloidx function, + * we then use a standard store to write + * and at the end we use t8_shmem_array_index_for_writing. + */ + if (t8_shmem_array_start_writing (shmem_array)) { + /* Double check that array_length is big enough so that each of the three cases + * is covered. */ + ASSERT_TRUE(0 < array_length / 3 + && array_length / 3 < (int) (2. / 3 * array_length) + && (int) (2. / 3 * array_length) < array_length) << "Please choose a larger value for array length."; + + t8_gloidx_t *array = + t8_shmem_array_get_gloidx_array_for_writing (shmem_array); + for (int i = 0; i < array_length / 3; ++i) { + t8_shmem_array_set_gloidx (shmem_array, i, i); } - t8_shmem_array_end_writing (shmem_array); - - /* Check value at each position */ - for (int i = 0; i < array_length; ++i) { - t8_gloidx_t value = t8_shmem_array_get_gloidx (shmem_array, i); - ASSERT_EQ(value, i) << "Value at position " << i << " not correct (expected " << i << " got " << value << ")"; + for (int i = array_length / 3; i < 2. / 3 * array_length; ++i) { + array[i] = i; } + for (int i = 2. / 3 * array_length; i < array_length; ++i) { + t8_gloidx_t *index = + (t8_gloidx_t *) t8_shmem_array_index_for_writing (shmem_array, i); + *index = i; + } + } + t8_shmem_array_end_writing (shmem_array); - /* Copy */ - t8_shmem_array_t copy_array; - t8_shmem_array_init (©_array, element_size, array_length, comm); - t8_shmem_array_copy (copy_array, shmem_array); - /* Check equality of arrays after copying. */ - ASSERT_TRUE(t8_shmem_array_is_equal (copy_array, shmem_array)) << "Arrays are not equal after copy."; + /* Check value at each position */ + for (int i = 0; i < array_length; ++i) { + t8_gloidx_t value = t8_shmem_array_get_gloidx (shmem_array, i); + ASSERT_EQ(value, i) << "Value at position " << i << " not correct (expected " << i << " got " << value << ")"; + } - t8_shmem_array_destroy (&shmem_array); - t8_shmem_array_destroy (©_array); + /* Copy */ + t8_shmem_array_t copy_array; + t8_shmem_array_init (©_array, element_size, array_length, comm); + t8_shmem_array_copy (copy_array, shmem_array); + /* Check equality of arrays after copying. */ + ASSERT_TRUE(t8_shmem_array_is_equal (copy_array, shmem_array)) << "Arrays are not equal after copy."; - t8_shmem_finalize (comm); - } + t8_shmem_array_destroy (&shmem_array); + t8_shmem_array_destroy (©_array); + + t8_shmem_finalize (comm); } -INSTANTIATE_TEST_SUITE_P(t8_gtest_shmem, shmem, testing::Combine(testing::Range(0, T8_TEST_SHMEM_NUM_COMMS), testing::Values(sc_MPI_COMM_WORLD, sc_MPI_COMM_SELF ))); +INSTANTIATE_TEST_SUITE_P(t8_gtest_shmem, shmem, testing::Combine(testing::Range(0, T8_TEST_SHMEM_NUM_COMMS), + testing::Values(sc_MPI_COMM_WORLD, sc_MPI_COMM_SELF ), + testing::Range((int)SC_SHMEM_BASIC, (int) SC_SHMEM_NUM_TYPES))); /* *INDENT-ON* */