Skip to content

Commit

Permalink
Merge pull request #694 from DLR-AMR/udpate-t8_cmesh_occ
Browse files Browse the repository at this point in the history
Update t8_cmesh_occ.cxx
  • Loading branch information
chiaraMaHe authored Aug 22, 2023
2 parents b8945ef + 1f12aef commit eaff7ba
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 43 deletions.
5 changes: 0 additions & 5 deletions src/t8_cmesh/t8_cmesh_occ.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ t8_cmesh_new_hollow_cylinder (sc_MPI_Comm comm, int num_tangential_trees, int nu
t8_cmesh_set_tree_class (
cmesh, (i_tangential_trees * num_axial_trees + i_axial_trees) * num_radial_trees + i_radial_trees,
T8_ECLASS_HEX);

/* *INDENT-OFF* */
const int current_tree_vertices
= ((i_tangential_trees * num_axial_trees + i_axial_trees) * num_radial_trees + i_radial_trees) * 24;
vertices[current_tree_vertices + 0]
Expand Down Expand Up @@ -160,7 +158,6 @@ t8_cmesh_new_hollow_cylinder (sc_MPI_Comm comm, int num_tangential_trees, int nu
vertices[current_tree_vertices + 21] = cos (i_tangential_trees * dphi) * (radius_inner + i_radial_trees * dr);
vertices[current_tree_vertices + 22] = sin (i_tangential_trees * dphi) * (radius_inner + i_radial_trees * dr);
vertices[current_tree_vertices + 23] = -0.5 + (i_axial_trees + 1) * dh;
/* *INDENT-ON* */

t8_cmesh_set_tree_vertices (
cmesh, (i_tangential_trees * num_axial_trees + i_axial_trees) * num_radial_trees + i_radial_trees,
Expand All @@ -173,7 +170,6 @@ t8_cmesh_new_hollow_cylinder (sc_MPI_Comm comm, int num_tangential_trees, int nu
/* Calculate parameters if cell lies on boundary */
const int current_tree_parameters = (i_tangential_trees * num_axial_trees + i_axial_trees) * 8;
if (i_radial_trees == 0 || i_radial_trees == num_radial_trees - 1) {
/* *INDENT-OFF* */
parameters[current_tree_parameters + 0] = (i_tangential_trees + 1) * dphi;
parameters[current_tree_parameters + 1] = 0.5 - i_axial_trees * dh;
parameters[current_tree_parameters + 2] = i_tangential_trees * dphi;
Expand All @@ -182,7 +178,6 @@ t8_cmesh_new_hollow_cylinder (sc_MPI_Comm comm, int num_tangential_trees, int nu
parameters[current_tree_parameters + 5] = 0.5 + -(i_axial_trees + 1) * dh;
parameters[current_tree_parameters + 6] = i_tangential_trees * dphi;
parameters[current_tree_parameters + 7] = 0.5 - (i_axial_trees + 1) * dh;
/* *INDENT-ON* */
}
int edges[24] = { 0 };

Expand Down
32 changes: 15 additions & 17 deletions src/t8_cmesh/t8_cmesh_readmshfile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,22 @@
#define T8_NUM_GMSH_ELEM_CLASSES 15
/* look-up table to translate the gmsh tree class to a t8code tree class.
*/
/* clang-format off */
const t8_eclass_t t8_msh_tree_type_to_eclass[T8_NUM_GMSH_ELEM_CLASSES + 1] = {
T8_ECLASS_COUNT, /* 0 is not valid */
T8_ECLASS_LINE, /* 1 */
T8_ECLASS_TRIANGLE, T8_ECLASS_QUAD, T8_ECLASS_TET, T8_ECLASS_HEX, /* 5 */
T8_ECLASS_PRISM, T8_ECLASS_PYRAMID, /* 7 This is the last first order tree type,
except the Point, which is type 15 */
T8_ECLASS_COUNT, /* 0 is not valid */
T8_ECLASS_LINE, /* 1 */
T8_ECLASS_TRIANGLE,
T8_ECLASS_QUAD,
T8_ECLASS_TET,
T8_ECLASS_HEX, /* 5 */
T8_ECLASS_PRISM,
T8_ECLASS_PYRAMID, /* 7 This is the last first order tree type, except the Point, which is type 15 */
/* We do not support type 8 to 14 */
T8_ECLASS_COUNT, T8_ECLASS_COUNT, T8_ECLASS_COUNT, T8_ECLASS_COUNT, T8_ECLASS_COUNT, T8_ECLASS_COUNT, T8_ECLASS_COUNT,
T8_ECLASS_VERTEX /* 15 */
T8_ECLASS_COUNT, T8_ECLASS_COUNT, T8_ECLASS_COUNT, T8_ECLASS_COUNT,
T8_ECLASS_COUNT, T8_ECLASS_COUNT, T8_ECLASS_COUNT,
T8_ECLASS_VERTEX /* 15 */
};
/* clang-format on */

/* translate the msh file vertex number to the t8code vertex number.
* See also http://gmsh.info/doc/texinfo/gmsh.html#Node-ordering */
Expand Down Expand Up @@ -997,11 +1003,6 @@ t8_cmesh_msh_file_4_read_eles (t8_cmesh_t cmesh, FILE *fp, sc_hash_t *vertices,
*(long **) sc_array_push (*vertex_indices) = stored_indices;
}

/* The following code contains many long function names and some c++,
* which gets unreadable when limited to 80 characters. We therefore
* deactivate the automatic indentation.
* TODO: Indent after switching to other indentation rules */
/* *INDENT-OFF* */
if (!use_occ_geometry) {
/* Set the geometry of the tree to be linear.
* If we use an occ geometry, we set the geometry in accordance,
Expand Down Expand Up @@ -1349,8 +1350,7 @@ t8_cmesh_msh_file_4_read_eles (t8_cmesh_t cmesh, FILE *fp, sc_hash_t *vertices,
/* Some error checking */
if (edge_nodes[i_edge_node].entity_dim == 2
&& edge_nodes[i_edge_node].entity_tag != edge_geometry_tag) {
t8_global_errorf ("Error: Node %i should lie on a specific face, "
"but it lies on another face.\n",
t8_global_errorf ("Error: Node %i should lie on a specific face, but it lies on another face.\n",
edge_nodes[i_edge_node].index);
goto die_ele;
}
Expand Down Expand Up @@ -1437,7 +1437,6 @@ t8_cmesh_msh_file_4_read_eles (t8_cmesh_t cmesh, FILE *fp, sc_hash_t *vertices,
SC_ABORTF ("OCC not linked");
#endif /* T8_WITH_OCC */
}
/* *INDENT-ON* */
}
}
}
Expand Down Expand Up @@ -1806,8 +1805,7 @@ t8_cmesh_from_msh_file (const char *fileprefix, int partition, sc_MPI_Comm comm,
case 2:
if (use_occ_geometry) {
fclose (file);
t8_errorf ("WARNING: The occ geometry is only supported for msh files of "
"version 4\n");
t8_errorf ("WARNING: The occ geometry is only supported for msh files of version 4\n");
t8_cmesh_destroy (&cmesh);
if (partition) {
/* Communicate to the other processes that reading failed. */
Expand Down
2 changes: 0 additions & 2 deletions src/t8_cmesh/t8_cmesh_refine.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -604,11 +604,9 @@ t8_cmesh_refine_ghost (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, t8_child_id_to_l
lghost_id = idarray[ghostid][ichild].local_id;
newghost = t8_cmesh_trees_get_ghost_ext (cmesh->trees, lghost_id, &nghost_neighbors, &nttf);
/* Set all face_neighbors of the child ghost */
/* *INDENT-OFF* */
t8_cmesh_refine_new_neighbors (cmesh_from, ghostid,
t8_cmesh_get_global_id (cmesh_from, cmesh_from->num_local_trees + ghostid),
newghost->eclass, idarray, (int) child_id, NULL, nghost_neighbors, nttf, factor);
/* *INDENT-ON* */
child_id = idarray[ghostid][ichild + 1].child_id;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/t8_cmesh/t8_cmesh_save.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,7 @@ t8_cmesh_save_trees (t8_cmesh_t cmesh, FILE *fp)
/* TODO: We currently do not support saving of attributes different
* to the tree vertices */
fclose (fp);
t8_errorf ("We do not support saving cmeshes with trees that "
"have attributes different to the tree vertices.\n");
t8_errorf ("We do not support saving cmeshes with trees that have attributes different to the tree vertices.\n");
return 0;
}
ret = fprintf (fp, "num_attributes %i\nSize of attributes %zd\n\n", tree->num_attributes,
Expand Down
3 changes: 0 additions & 3 deletions src/t8_cmesh/t8_cmesh_stash.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,8 @@ t8_stash_add_facejoin (t8_stash_t stash, t8_gloidx_t gid1, t8_gloidx_t gid2, int
* the two ids */
sjoin->face1 = gid1 <= gid2 ? face1 : face2;
sjoin->face2 = gid1 <= gid2 ? face2 : face1;
;
sjoin->id1 = gid1 <= gid2 ? gid1 : gid2;
;
sjoin->id2 = gid1 <= gid2 ? gid2 : gid1;
;
sjoin->orientation = orientation;
}

Expand Down
27 changes: 13 additions & 14 deletions src/t8_cmesh/t8_cmesh_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ typedef struct t8_cprofile t8_cprofile_t; /* Defined below */
#define T8_CMESH_OCC_EDGE_PARAMETERS_ATTRIBUTE_KEY 3 /* Used to store edge parameters */
#define T8_CMESH_OCC_FACE_ATTRIBUTE_KEY \
T8_CMESH_OCC_EDGE_PARAMETERS_ATTRIBUTE_KEY \
+ T8_ECLASS_MAX_EDGES /* Used to store which face is linked to which surface */
+T8_ECLASS_MAX_EDGES /* Used to store which face is linked to which surface */
#define T8_CMESH_OCC_FACE_PARAMETERS_ATTRIBUTE_KEY \
T8_CMESH_OCC_FACE_ATTRIBUTE_KEY + 1 /* Used to store face parameters */
#define T8_CMESH_NEXT_POSSIBLE_KEY \
Expand Down Expand Up @@ -101,19 +101,19 @@ typedef struct t8_cmesh
refinement pattern. See \ref t8_cmesh_set_refine. */
t8_scheme_cxx_t *set_partition_scheme; /**< If the cmesh is to be partitioned according to a uniform level,
the scheme that describes the refinement pattern. See \ref t8_cmesh_set_partition. */
int8_t set_partition_level; /**< Non-negative if the cmesh should be partitioned from an already existing cmesh
int8_t set_partition_level; /**< Non-negative if the cmesh should be partitioned from an already existing cmesh
with an assumed \a level uniform mesh underneath. */
struct t8_cmesh *set_from; /**< If this cmesh shall be derived from an
struct t8_cmesh *set_from; /**< If this cmesh shall be derived from an
existing cmesh by copy or more elaborate
modification, we store a pointer to this
other cmesh here. */
int mpirank; /**< Number of this MPI process. */
int mpisize; /**< Number of MPI processes. */
t8_refcount_t rc; /**< The reference count of the cmesh. */
t8_gloidx_t num_trees; /**< The global number of trees */
t8_locidx_t
num_local_trees; /**< If partitioned the number of trees on this process. Otherwise the global number of trees. */
t8_locidx_t num_ghosts; /**< If partitioned the number of neighbor trees
int mpirank; /**< Number of this MPI process. */
int mpisize; /**< Number of MPI processes. */
t8_refcount_t rc; /**< The reference count of the cmesh. */
t8_gloidx_t num_trees; /**< The global number of trees */
t8_locidx_t num_local_trees; /**< If partitioned the number of trees on this process.
Otherwise the global number of trees. */
t8_locidx_t num_ghosts; /**< If partitioned the number of neighbor trees
owned by different processes. */
/* TODO: wouldnt a local num_trees_per_eclass be better?
* only as an additional info. we need the global count. i.e. for forest_maxlevel computation.
Expand All @@ -127,12 +127,11 @@ typedef struct t8_cmesh

t8_cmesh_trees_t trees; /**< structure that holds all local trees and ghosts */

t8_gloidx_t first_tree; /**< The global index of the first local tree on this process.
t8_gloidx_t first_tree; /**< The global index of the first local tree on this process.
Zero if the cmesh is not partitioned. -1 if this processor is empty.
See also https://github.com/DLR-AMR/t8code/wiki/Tree-indexing */
int8_t
first_tree_shared; /**< If partitioned true if the first tree on this process is also the last tree on the next process.
Always zero if num_local_trees = 0 */
int8_t first_tree_shared; /**< If partitioned true if the first tree on this process is also the last tree
on the next process. Always zero if num_local_trees = 0 */

t8_shmem_array_t tree_offsets; /**< If partitioned for each process the global index of its first local tree
or -(first local tree) - 1
Expand Down

0 comments on commit eaff7ba

Please sign in to comment.