From 84a145bf74223afcb39b398260f0a1147b03ef39 Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 18:34:59 +0200 Subject: [PATCH 01/87] fix override warnings --- .../t8_geometry_analytic.hxx | 22 ++++++------- .../t8_geometry_zero.hxx | 22 ++++++------- .../t8_default_common/t8_default_common.hxx | 32 +++++++++---------- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_analytic.hxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_analytic.hxx index 53331b82d9..67011ff790 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_analytic.hxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_analytic.hxx @@ -70,7 +70,7 @@ struct t8_geometry_analytic: public t8_geometry * \return The type. */ inline t8_geometry_type_t - t8_geom_get_type () const + t8_geom_get_type () const override { return T8_GEOMETRY_TYPE_ANALYTIC; }; @@ -83,9 +83,9 @@ struct t8_geometry_analytic: public t8_geometry * \param [in] num_coords Amount of points of \f$ \mathrm{dim} \f$ to map. * \param [out] out_coords The mapped coordinates in physical space of \a ref_coords. The length is \a num_coords * 3. */ - virtual void + void t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, - double *out_coords) const; + double *out_coords) const override; /** * Compute the jacobian of the \a t8_geom_evaluate map at a point in the reference space \f$ [0,1]^\mathrm{dim} \f$. @@ -100,9 +100,9 @@ struct t8_geometry_analytic: public t8_geometry * dim 1: J = (0) dim 2: J = (0 1) dim 3: J = (0 1 0) * (0) (0 0) (0 0 1) */ - virtual void + void t8_geom_evaluate_jacobian (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, - double *jacobian) const; + double *jacobian) const override; /** * \param[in] forest The forest of the element. @@ -113,10 +113,10 @@ struct t8_geometry_analytic: public t8_geometry * \param[in, out] is_inside Array to fill with flags whether the point is inside or not * \param[in] tolerance Tolerance of the inside-check */ - virtual void + void t8_geom_point_batch_inside_element (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *points, const int num_points, int *is_inside, - const double tolerance) + const double tolerance) const override { SC_ABORTF ("Function not yet implemented"); } @@ -125,8 +125,8 @@ struct t8_geometry_analytic: public t8_geometry * Check if the currently active tree has a negative volume * \return True (non-zero) if the currently loaded tree has a negative volume. 0 otherwise. */ - virtual bool - t8_geom_tree_negative_volume () const; + bool + t8_geom_tree_negative_volume () const override; /** Update a possible internal data buffer for per tree data. * This function is called before the first coordinates in a new tree are @@ -135,8 +135,8 @@ struct t8_geometry_analytic: public t8_geometry * \param [in] cmesh The cmesh. * \param [in] gtreeid The global tree. */ - virtual void - t8_geom_load_tree_data (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); + void + t8_geom_load_tree_data (t8_cmesh_t cmesh, t8_gloidx_t gtreeid) override; inline const void * t8_geom_analytic_get_user_data () diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_zero.hxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_zero.hxx index 94b56ecb7c..24366040c5 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_zero.hxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_zero.hxx @@ -49,8 +49,8 @@ struct t8_geometry_zero: public t8_geometry * Check if the currently active tree has a negative volume * \return True (non-zero) if the currently loaded tree has a negative volume. 0 otherwise. */ - virtual bool - t8_geom_tree_negative_volume () const + bool + t8_geom_tree_negative_volume () const override { return 0; }; @@ -65,7 +65,7 @@ struct t8_geometry_zero: public t8_geometry * \return The type. */ inline t8_geometry_type_t - t8_geom_get_type () const + t8_geom_get_type () const override { return T8_GEOMETRY_TYPE_ZERO; }; @@ -79,9 +79,9 @@ struct t8_geometry_zero: public t8_geometry * \param [out] out_coords The mapped coordinates in physical space of \a ref_coords. The length is \a num_coords * 3. * \note All entries in out_coords will be set to 0. */ - virtual void + void t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, - double *out_coords) const; + double *out_coords) const override; /** * Compute the jacobian of the \a t8_geom_evaluate map at a point in the reference space \f$ [0,1]^\mathrm{dim} \f$. @@ -93,9 +93,9 @@ struct t8_geometry_zero: public t8_geometry * correspond to the \f$ i \f$-th column of the jacobian (Entry \f$ 3 \cdot i + j \f$ is \f$ \frac{\partial f_j}{\partial x_i} \f$). * \note All entries in \a jacobian will be set to zero. */ - virtual void + void t8_geom_evaluate_jacobian (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, - double *jacobian) const; + double *jacobian) const override; /** * \param[in] forest The forest of the element. @@ -106,10 +106,10 @@ struct t8_geometry_zero: public t8_geometry * \param[in, out] is_inside Array to fill with flags whether the point is inside or not * \param[in] tolerance Tolerance of the inside-check */ - virtual void + void t8_geom_point_batch_inside_element (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *points, const int num_points, int *is_inside, - const double tolerance) + const double tolerance) const override { const double zeros[3] = { 0 }; for (int i_point = 0; i_point < num_points; ++i_point) { @@ -125,8 +125,8 @@ struct t8_geometry_zero: public t8_geometry * \param [in] cmesh The cmesh. * \param [in] gtreeid The global tree. */ - virtual inline void - t8_geom_load_tree_data (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); + inline void + t8_geom_load_tree_data (t8_cmesh_t cmesh, t8_gloidx_t gtreeid) override; }; #endif /* !T8_GEOMETRY_ZERO_HXX */ diff --git a/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx b/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx index 528840d8d0..e40861ca88 100644 --- a/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx +++ b/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx @@ -41,20 +41,20 @@ class t8_default_scheme_common_c: public t8_eclass_scheme_c { t8_element_deinit (int length, t8_element_t *elem) const override; /** Compute the number of corners of a given element. */ - virtual int - t8_element_num_corners (const t8_element_t *elem) const; + int + t8_element_num_corners (const t8_element_t *elem) const override; /** Allocate space for a bunch of elements. */ - virtual void - t8_element_new (int length, t8_element_t **elem) const; + void + t8_element_new (int length, t8_element_t **elem) const override; /** Deallocate space for a bunch of elements. */ - virtual void - t8_element_destroy (int length, t8_element_t **elem) const; + void + t8_element_destroy (int length, t8_element_t **elem) const override; /** Return the shape of an element */ - virtual t8_element_shape_t - t8_element_shape (const t8_element_t *elem) const; + t8_element_shape_t + t8_element_shape (const t8_element_t *elem) const override; /** Count how many leaf descendants of a given uniform level an element would produce. * \param [in] t The element to be checked. @@ -64,8 +64,8 @@ class t8_default_scheme_common_c: public t8_eclass_scheme_c { * Each default element (except pyramids) refines into 2^{dim * (level - level(t))} * children. */ - virtual t8_gloidx_t - t8_element_count_leaves (const t8_element_t *t, int level) const; + t8_gloidx_t + t8_element_count_leaves (const t8_element_t *t, int level) const override; /** Compute the number of siblings of an element. That is the number of * Children of its parent. @@ -73,16 +73,16 @@ class t8_default_scheme_common_c: public t8_eclass_scheme_c { * \return The number of siblings of \a element. * Note that this number is >= 1, since we count the element itself as a sibling. */ - virtual int - t8_element_num_siblings (const t8_element_t *elem) const; + int + t8_element_num_siblings (const t8_element_t *elem) const override; /** Count how many leaf descendants of a given uniform level the root element will produce. * \param [in] level A refinement level. * \return The value of \ref t8_element_count_leaves if the input element * is the root (level 0) element. */ - virtual t8_gloidx_t - t8_element_count_leaves_from_root (int level) const; + t8_gloidx_t + t8_element_count_leaves_from_root (int level) const override; /** Compute the integer coordinates of a given element vertex. * The default scheme implements the Morton type SFCs. In these SFCs the @@ -108,9 +108,9 @@ class t8_default_scheme_common_c: public t8_eclass_scheme_c { * \param [out] out_coords The coordinates of the points in the * reference space of the tree. */ - virtual void + void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, - double *out_coords) const + double *out_coords) const override = 0; /** Get the integer coordinates of the anchor node of an element. From 3c254f0af3374a4aa93b15e5d7a72d69d84e2254 Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 18:42:51 +0200 Subject: [PATCH 02/87] fix cast errors --- src/t8_cmesh/t8_cmesh_geometry.cxx | 2 +- src/t8_cmesh/t8_cmesh_partition.cxx | 2 +- src/t8_cmesh/t8_cmesh_readmshfile.cxx | 4 ++-- src/t8_cmesh/t8_cmesh_triangle.cxx | 2 +- src/t8_cmesh/t8_cmesh_vtk_writer.c | 2 +- src/t8_geometry/t8_geometry_handler.cxx | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_geometry.cxx b/src/t8_cmesh/t8_cmesh_geometry.cxx index 10bdcc05fc..539ecf8a2c 100644 --- a/src/t8_cmesh/t8_cmesh_geometry.cxx +++ b/src/t8_cmesh/t8_cmesh_geometry.cxx @@ -97,7 +97,7 @@ t8_cmesh_get_tree_geom_hash (t8_cmesh_t cmesh, t8_gloidx_t gtreeid) const size_t *hash = (const size_t *) t8_cmesh_get_attribute (cmesh, t8_get_package_id (), T8_CMESH_GEOMETRY_ATTRIBUTE_KEY, ltreeid); if (hash == nullptr) { - SC_ABORTF ("Could not find geometry for tree %ld.", gtreeid); + SC_ABORTF ("Could not find geometry for tree %ld.", static_cast(gtreeid)); } return *hash; } diff --git a/src/t8_cmesh/t8_cmesh_partition.cxx b/src/t8_cmesh/t8_cmesh_partition.cxx index c4654fe0be..1f65890d72 100644 --- a/src/t8_cmesh/t8_cmesh_partition.cxx +++ b/src/t8_cmesh/t8_cmesh_partition.cxx @@ -387,7 +387,7 @@ t8_cmesh_partition_sendrange (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, int *send ret--; } - t8_debugf ("%s_first = %i, %s_last = %i, last_tree = %li\n", "send", *send_first, "send", *send_last, ret); + t8_debugf ("%s_first = %i, %s_last = %i, last_tree = %li\n", "send", *send_first, "send", *send_last, static_cast(ret)); T8_ASSERT (*send_first >= 0); //TODO:reactivate T8_ASSERT (*send_last >= 0); diff --git a/src/t8_cmesh/t8_cmesh_readmshfile.cxx b/src/t8_cmesh/t8_cmesh_readmshfile.cxx index 0319619367..a107601106 100644 --- a/src/t8_cmesh/t8_cmesh_readmshfile.cxx +++ b/src/t8_cmesh/t8_cmesh_readmshfile.cxx @@ -623,7 +623,7 @@ t8_cmesh_msh_file_2_read_eles (t8_cmesh_t cmesh, FILE *fp, sc_hash_t *vertices, int switch_indices[4] = { 0 }; int iswitch; T8_ASSERT (t8_eclass_to_dimension[eclass] > 1); - t8_debugf ("Correcting negative volume of tree %li\n", tree_count); + t8_debugf ("Correcting negative volume of tree %li\n", static_cast(tree_count)); switch (eclass) { case T8_ECLASS_TRIANGLE: case T8_ECLASS_QUAD: @@ -956,7 +956,7 @@ t8_cmesh_msh_file_4_read_eles (t8_cmesh_t cmesh, FILE *fp, sc_hash_t *vertices, int switch_indices[4] = { 0 }; int iswitch; T8_ASSERT (t8_eclass_to_dimension[eclass] > 1); - t8_debugf ("Correcting negative volume of tree %li\n", tree_count); + t8_debugf ("Correcting negative volume of tree %li\n", static_cast(tree_count)); switch (eclass) { case T8_ECLASS_TRIANGLE: case T8_ECLASS_QUAD: diff --git a/src/t8_cmesh/t8_cmesh_triangle.cxx b/src/t8_cmesh/t8_cmesh_triangle.cxx index ba45711c1d..4651dd5c59 100644 --- a/src/t8_cmesh/t8_cmesh_triangle.cxx +++ b/src/t8_cmesh/t8_cmesh_triangle.cxx @@ -262,7 +262,7 @@ t8_cmesh_triangle_read_eles (t8_cmesh_t cmesh, int corner_offset, char *filename double temp; T8_ASSERT (dim == 3); - t8_debugf ("Correcting negative volume of tree %li\n", (long) triangle - triangle_offset); + t8_debugf ("Correcting negative volume of tree %li\n", static_cast(triangle - triangle_offset)); /* We switch vertex 0 and vertex 1 */ for (i = 0; i < 3; i++) { temp = tree_vertices[i]; diff --git a/src/t8_cmesh/t8_cmesh_vtk_writer.c b/src/t8_cmesh/t8_cmesh_vtk_writer.c index 53bf54b0f4..e96b464223 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_writer.c +++ b/src/t8_cmesh/t8_cmesh_vtk_writer.c @@ -250,7 +250,7 @@ t8_cmesh_vtk_write_file_ext (t8_cmesh_t cmesh, const char *fileprefix, int write /* TODO: We switched to 32 Bit because Paraview could not handle 64 well enough. */ T8_ASSERT (tree->treeid + cmesh->first_tree == (t8_gloidx_t) ((long) tree->treeid + cmesh->first_tree)); - fprintf (vtufile, " %ld", (long) tree->treeid + cmesh->first_tree); + fprintf (vtufile, " %ld", (long)(tree->treeid + cmesh->first_tree)); if (!(sk % 8)) fprintf (vtufile, "\n "); } diff --git a/src/t8_geometry/t8_geometry_handler.cxx b/src/t8_geometry/t8_geometry_handler.cxx index e1fd87e423..3eb644edb1 100644 --- a/src/t8_geometry/t8_geometry_handler.cxx +++ b/src/t8_geometry/t8_geometry_handler.cxx @@ -62,7 +62,7 @@ t8_geometry_handler::update_tree (t8_cmesh_t cmesh, t8_gloidx_t gtreeid) active_geometry = get_geometry (geom_hash); SC_CHECK_ABORTF (active_geometry != nullptr, "Could not find geometry with hash %zu or tree %ld has no registered geometry.", geom_hash, - gtreeid); + static_cast(gtreeid)); } /* Get the user data for this geometry and this tree. */ active_geometry->t8_geom_load_tree_data (cmesh, gtreeid); From 4b8e8f90f460205d2cc7b80378ca4b1f5035297a Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 18:51:35 +0200 Subject: [PATCH 03/87] fix unitialized variables --- src/t8_cmesh/t8_cmesh_partition.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_partition.cxx b/src/t8_cmesh/t8_cmesh_partition.cxx index 1f65890d72..57d37e4a5a 100644 --- a/src/t8_cmesh/t8_cmesh_partition.cxx +++ b/src/t8_cmesh/t8_cmesh_partition.cxx @@ -1436,7 +1436,9 @@ t8_cmesh_partition_given (t8_cmesh_t cmesh, const struct t8_cmesh *cmesh_from, c size_t my_buffer_bytes = -1; char **send_buffer = NULL, *my_buffer = NULL; - int fs, ls, fr, lr; + int fs, ls; + int fr = 0; // is it a good default though? + int lr = 0; // to discuss before merging sc_MPI_Request *requests = NULL; t8_locidx_t num_ghosts, itree, num_trees; From 57ce3175196bc4ea80c003c2375fbe57801cca4e Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 18:54:54 +0200 Subject: [PATCH 04/87] fix potential out of bounds access --- src/t8_cmesh/t8_cmesh_readmshfile.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_readmshfile.cxx b/src/t8_cmesh/t8_cmesh_readmshfile.cxx index a107601106..d46a1d74cc 100644 --- a/src/t8_cmesh/t8_cmesh_readmshfile.cxx +++ b/src/t8_cmesh/t8_cmesh_readmshfile.cxx @@ -179,7 +179,7 @@ t8_cmesh_check_version_of_msh_file (FILE *fp) /* Search for the line starting with "$MeshFormat". */ while (!feof (fp) && strcmp (first_word, "$MeshFormat")) { (void) t8_cmesh_msh_read_next_line (&line, &linen, fp); - retval = sscanf (line, "%2048s", first_word); + retval = sscanf (line, "%2047s", first_word); /* Checking for read/write error */ if (retval != 1) { @@ -258,7 +258,7 @@ t8_msh_file_2_read_nodes (FILE *fp, t8_locidx_t *num_nodes, sc_mempool_t **node_ while (!feof (fp) && strcmp (first_word, "$Nodes")) { (void) t8_cmesh_msh_read_next_line (&line, &linen, fp); /* Get the first word of this line */ - retval = sscanf (line, "%2048s", first_word); + retval = sscanf (line, "%2047s", first_word); /* Checking for read/write error */ if (retval != 1) { @@ -358,7 +358,7 @@ t8_msh_file_4_read_nodes (FILE *fp, t8_locidx_t *num_nodes, sc_mempool_t **node_ while (!feof (fp) && strcmp (first_word, "$Nodes")) { (void) t8_cmesh_msh_read_next_line (&line, &linen, fp); /* Get the first word of this line */ - retval = sscanf (line, "%2048s", first_word); + retval = sscanf (line, "%2047s", first_word); /* Checking for read/write error */ if (retval != 1) { t8_global_errorf ("Premature end of line while reading nodes.\n"); @@ -519,7 +519,7 @@ t8_cmesh_msh_file_2_read_eles (t8_cmesh_t cmesh, FILE *fp, sc_hash_t *vertices, while (!feof (fp) && strcmp (first_word, "$Elements")) { (void) t8_cmesh_msh_read_next_line (&line, &linen, fp); /* Get the first word of this line */ - retval = sscanf (line, "%2048s", first_word); + retval = sscanf (line, "%2047s", first_word); /* Checking for read/write error */ if (retval != 1) { @@ -836,7 +836,7 @@ t8_cmesh_msh_file_4_read_eles (t8_cmesh_t cmesh, FILE *fp, sc_hash_t *vertices, while (!feof (fp) && strcmp (first_word, "$Elements")) { (void) t8_cmesh_msh_read_next_line (&line, &linen, fp); /* Get the first word of this line */ - retval = sscanf (line, "%2048s", first_word); + retval = sscanf (line, "%2047s", first_word); /* Checking for read/write error */ if (retval != 1) { From 945057fbec227f8e1fa1fd7e3e312dc48735d887 Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:12:05 +0200 Subject: [PATCH 05/87] fix unused variables --- src/t8_forest/t8_forest_partition.cxx | 4 +--- src/t8_forest/t8_forest_vtk.cxx | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/t8_forest/t8_forest_partition.cxx b/src/t8_forest/t8_forest_partition.cxx index f9f79223ae..e3b67d9705 100644 --- a/src/t8_forest/t8_forest_partition.cxx +++ b/src/t8_forest/t8_forest_partition.cxx @@ -1025,7 +1025,7 @@ static void t8_forest_partition_recvloop (t8_forest_t forest, int recv_first, int recv_last, const int recv_data, sc_array_t *data_out, char *sent_to_self, size_t byte_to_self) { - int iproc, num_receive, prev_recvd; + int iproc, prev_recvd; t8_locidx_t last_received_local_element = 0; t8_forest_t forest_from; int mpiret; @@ -1045,7 +1045,6 @@ t8_forest_partition_recvloop (t8_forest_t forest, int recv_first, int recv_last, /* In order of their ranks, receive the trees and elements from the other processes. */ - num_receive = 0; prev_recvd = 0; if (!recv_data) { forest->local_num_elements = 0; @@ -1053,7 +1052,6 @@ t8_forest_partition_recvloop (t8_forest_t forest, int recv_first, int recv_last, for (iproc = recv_first; iproc <= recv_last; iproc++) { if (!t8_forest_partition_empty (offset_from, iproc)) { /* We receive from each nonempty rank between recv_first and recv_last */ - num_receive++; if (iproc != forest->mpirank) { /* Probe for the message */ mpiret = sc_MPI_Probe (iproc, T8_MPI_PARTITION_FOREST, comm, &status); diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index c97044ef88..7f726a72c0 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -114,10 +114,10 @@ typedef int (*t8_forest_vtk_cell_data_kernel) (t8_forest_t forest, const t8_loci #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 }; +[[maybe_unused]] 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 */ -const int t8_curved_eclass_vtk_type[T8_ECLASS_COUNT] = { 1, 21, 23, 22, 25, 24, 26, 27 }; +[[maybe_unused]] const int t8_curved_eclass_vtk_type[T8_ECLASS_COUNT] = { 1, 21, 23, 22, 25, 24, 26, 27 }; /** Map vtk element corners to element reference coordinates. The reference * coordinates are defined in such a way, that the linear vtk corners are listed From 3ec21ebacafbb8d44bbfb56546f7d5a240b4c063 Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:16:59 +0200 Subject: [PATCH 06/87] fix dangling pointer --- src/t8_geometry/t8_geometry_base.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_geometry/t8_geometry_base.hxx b/src/t8_geometry/t8_geometry_base.hxx index df848cb2e3..43a7e01c43 100644 --- a/src/t8_geometry/t8_geometry_base.hxx +++ b/src/t8_geometry/t8_geometry_base.hxx @@ -156,7 +156,7 @@ struct t8_geometry * Get the name of this geometry. * \return The name. */ - inline const std::string + inline const std::string& t8_geom_get_name () const { return name; From f5cece6f84e1344a3b599633cca52203bbe31e40 Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:23:44 +0200 Subject: [PATCH 07/87] removed call to deprecated sprintf --- src/t8_cmesh/t8_cmesh_partition.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_partition.cxx b/src/t8_cmesh/t8_cmesh_partition.cxx index 57d37e4a5a..ebdcc1337b 100644 --- a/src/t8_cmesh/t8_cmesh_partition.cxx +++ b/src/t8_cmesh/t8_cmesh_partition.cxx @@ -1406,7 +1406,7 @@ t8_cmesh_partition_debug_listprocs (t8_cmesh_t cmesh, t8_cmesh_t cmesh_from, sc_ } } t8_debugf ("I send to: %s\n", out); - sprintf (out, " "); + std::strcpy(out, " "); if (cmesh_from->set_partition) { for (p = 0; p < mpisize; p++) { if (t8_offset_sendsto (p, mpirank, from, to)) { From a7a3e55cd5a73c8231ef0d966a2c8fb71668cffa Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:26:54 +0200 Subject: [PATCH 08/87] removed useless branch --- src/t8_forest/t8_forest_ghost.cxx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index f53b4806c7..ebdcde905b 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -595,11 +595,7 @@ t8_forest_ghost_search_boundary (t8_forest_t forest, t8_locidx_t ltreeid, const /* Store the new bounds at the entry for this element */ new_bounds[iface * 2] = lower; new_bounds[iface * 2 + 1] = upper; - if (lower == upper && lower == forest->mpirank) { - /* All neighbor leaves at this face are owned by the current rank */ - faces_totally_owned = faces_totally_owned && 1; - } - else { + if (lower != upper or lower != forest->mpirank) { faces_totally_owned = 0; } } From ca865201250b347e48df52ac85c0ca8fd39af40d Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:36:37 +0200 Subject: [PATCH 09/87] add missing include --- src/t8_cmesh/t8_cmesh_partition.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/t8_cmesh/t8_cmesh_partition.cxx b/src/t8_cmesh/t8_cmesh_partition.cxx index ebdcc1337b..a5bab77bac 100644 --- a/src/t8_cmesh/t8_cmesh_partition.cxx +++ b/src/t8_cmesh/t8_cmesh_partition.cxx @@ -25,6 +25,8 @@ * TODO: document this file */ +#include + #include #include #include From 9c38762ad0ff9fb7418427ab9abc709718442a1a Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 17 Jul 2024 10:40:06 +0200 Subject: [PATCH 10/87] Encapsulate VTK-API specific functions --- src/t8_vtk/t8_vtk_writer.hxx | 23 ++++++++++++++++++- tutorials/general/t8_step1_coarsemesh.cxx | 2 +- tutorials/general/t8_step2_uniform_forest.cxx | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/t8_vtk/t8_vtk_writer.hxx b/src/t8_vtk/t8_vtk_writer.hxx index 2a2b76b64e..9621b53e39 100644 --- a/src/t8_vtk/t8_vtk_writer.hxx +++ b/src/t8_vtk/t8_vtk_writer.hxx @@ -95,6 +95,7 @@ class vtk_writer { write_ghosts (write_ghosts), curved_flag (curved_flag), fileprefix (fileprefix), num_data (num_data), data (data), comm (comm) {}; +#if T8_WITH_VTK /** * A vtk-writer function that uses the vtk API * @@ -103,12 +104,27 @@ class vtk_writer { * \return false */ bool - write (const grid_t grid) + write_with_API (const grid_t grid) { return write_vtk (grid); } +#endif + + /** + * A vtk-writer function that uses the vtk API + * + * \param[in] grid The forest or cmesh that is translated + * \return true + * \return false + */ + bool + write_ASCII (const grid_t grid) + { + return false; + } private: +#if T8_WITH_VTK /** * Translate a single element from the forest into a vtkCell and fill the vtkArrays with * the data related to the element (not element_data). @@ -385,6 +401,8 @@ class vtk_writer { return; } +#endif + /** * Write a vtk file given a forest or a cmesh * @@ -495,6 +513,7 @@ class vtk_writer { sc_MPI_Comm comm; }; +#if T8_WITH_VTK /** * \brief template specialization for forests. * @@ -555,4 +574,6 @@ vtk_writer::t8_grid_tree_to_vtk_cells ( (*elem_id)++; return; } +#endif + #endif /* T8_VTK_WRITER_HXX */ \ No newline at end of file diff --git a/tutorials/general/t8_step1_coarsemesh.cxx b/tutorials/general/t8_step1_coarsemesh.cxx index 27eba34563..3462a865d5 100644 --- a/tutorials/general/t8_step1_coarsemesh.cxx +++ b/tutorials/general/t8_step1_coarsemesh.cxx @@ -79,7 +79,7 @@ t8_step1_write_cmesh_vtk (t8_cmesh_t cmesh, const char *prefix) //t8_cmesh_vtk_write_file (cmesh, prefix); vtk_writer writer (true, true, true, false, true, false, std::string (prefix), 0, NULL, sc_MPI_COMM_WORLD); - writer.write (cmesh); + writer.write_with_API (cmesh); } /* Destroy a cmesh. This will free all allocated memory. diff --git a/tutorials/general/t8_step2_uniform_forest.cxx b/tutorials/general/t8_step2_uniform_forest.cxx index e5720c9f85..33b8e09535 100644 --- a/tutorials/general/t8_step2_uniform_forest.cxx +++ b/tutorials/general/t8_step2_uniform_forest.cxx @@ -106,7 +106,7 @@ t8_step2_write_forest_vtk (t8_forest_t forest, const char *prefix) //t8_forest_write_vtk (forest, prefix); //t8_write_vtk_via_API (forest, std::string (prefix), 1, 1, 1, 1, 0, 1, 0, NULL, comm); vtk_writer writer (true, true, true, true, true, false, std::string (prefix), 0, NULL, comm); - writer.write (forest); + writer.write_with_API (forest); } /* Destroy a forest. This will free all allocated memory. From 1e877a0c861af72f25374b607ce896298228e84f Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 17 Jul 2024 10:52:19 +0200 Subject: [PATCH 11/87] Add ASCII writer to the class --- src/t8_vtk/t8_vtk_writer.hxx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/t8_vtk/t8_vtk_writer.hxx b/src/t8_vtk/t8_vtk_writer.hxx index 9621b53e39..bff510627a 100644 --- a/src/t8_vtk/t8_vtk_writer.hxx +++ b/src/t8_vtk/t8_vtk_writer.hxx @@ -35,6 +35,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include +#include +#include #if T8_WITH_VTK #include @@ -120,7 +122,7 @@ class vtk_writer { bool write_ASCII (const grid_t grid) { - return false; + return write_ASCII (grid); } private: @@ -576,4 +578,20 @@ vtk_writer::t8_grid_tree_to_vtk_cells ( } #endif +template <> +bool +vtk_writer::write_ASCII (const t8_forest_t forest) +{ + return t8_forest_vtk_write_file (forest, this->fileprefix.c_str (), this->write_treeid, this->write_mpirank, + this->write_level, this->write_element_id, this->write_ghosts, this->num_data, + this->data); +} + +template <> +bool +vtk_writer::write_ASCII (const t8_cmesh_t forest) +{ + return t8_cmesh_vtk_write_file (forest, this->fileprefix.c_str ()); +} + #endif /* T8_VTK_WRITER_HXX */ \ No newline at end of file From 9e76567ff6af0923e3881bea17a09b9e0763e191 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 17 Jul 2024 13:14:42 +0200 Subject: [PATCH 12/87] Introduce a c-interface for the vtk-writer --- src/Makefile.am | 6 +- src/t8_vtk/t8_vtk_writer.hxx | 36 +++++--- src/t8_vtk/t8_vtk_writer_c_interface.cxx | 65 +++++++++++++ src/t8_vtk/t8_vtk_writer_c_interface.h | 111 +++++++++++++++++++++++ 4 files changed, 203 insertions(+), 15 deletions(-) create mode 100644 src/t8_vtk/t8_vtk_writer_c_interface.cxx create mode 100644 src/t8_vtk/t8_vtk_writer_c_interface.h diff --git a/src/Makefile.am b/src/Makefile.am index f1a5a1027a..edc0b0f551 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -82,7 +82,8 @@ libt8_installed_headers_geometry_impl = \ libt8_installed_headers_vtk = \ src/t8_vtk/t8_vtk_reader.hxx \ src/t8_vtk/t8_vtk_writer.hxx \ - src/t8_vtk/t8_vtk_types.h + src/t8_vtk/t8_vtk_types.h \ + src/t8_vtk/t8_vtk_writer_c_interface.h libt8_installed_headers_schemes_default = libt8_installed_headers_default_common = libt8_installed_headers_default_vertex = @@ -148,7 +149,8 @@ libt8_compiled_sources = \ src/t8_vtk/t8_vtk_polydata.cxx \ src/t8_vtk/t8_vtk_unstructured.cxx \ src/t8_vtk/t8_vtk_parallel.cxx \ - src/t8_vtk/t8_vtk_reader.cxx + src/t8_vtk/t8_vtk_reader.cxx \ + src/t8_vtk/t8_vtk_writer_c_interface.ccc # this variable is used for headers that are not publicly installed diff --git a/src/t8_vtk/t8_vtk_writer.hxx b/src/t8_vtk/t8_vtk_writer.hxx index bff510627a..70f13b0a11 100644 --- a/src/t8_vtk/t8_vtk_writer.hxx +++ b/src/t8_vtk/t8_vtk_writer.hxx @@ -79,25 +79,36 @@ class vtk_writer { * Construct a new vtk writer object. All parameters are set to false by default. By default no data is used and * \a num_data is set to zero. A default \a fileprefix is NOT given. * - * \param write_treeid True, if we want to write the tree id of every element - * \param write_mpirank True, if we want to write the mpirankof every element - * \param write_level True, if we want to write the level of every element. Uses level 0 if used for a cmesh. - * \param write_element_id True, if we want to write the element id of every element. Ignored if used for a cmesh. - * \param write_ghosts True, if we want to write the ghost elements, too. - * \param curved_flag True, if we want to use quadratic vtk cells. Uses the geometry of the grid to evaluate points between corners. - * \param fileprefix The prefix of the output-file - * \param num_data The number of data-fields to print - * \param data The data to use - * \param comm The communicator for parallel output + * \param[in] write_treeid True, if we want to write the tree id of every element + * \param[in] write_mpirank True, if we want to write the mpirankof every element + * \param[in] write_level True, if we want to write the level of every element. Uses level 0 if used for a cmesh. + * \param[in] write_element_id True, if we want to write the element id of every element. Ignored if used for a cmesh. + * \param[in] write_ghosts True, if we want to write the ghost elements, too. + * \param[in] curved_flag True, if we want to use quadratic vtk cells. Uses the geometry of the grid to evaluate points between corners. + * \param[in] fileprefix The prefix of the output-file + * \param[in] num_data The number of data-fields to print + * \param[in] data The data to use + * \param[in] comm The communicator for parallel output */ vtk_writer (const bool write_treeid, const bool write_mpirank, const bool write_level, const bool write_element_id, const bool write_ghosts, const bool curved_flag, std::string fileprefix, const int num_data, t8_vtk_data_field_t *data, sc_MPI_Comm comm) : write_treeid (write_treeid), write_mpirank (write_mpirank), write_level (write_level), write_ghosts (write_ghosts), curved_flag (curved_flag), fileprefix (fileprefix), num_data (num_data), data (data), - comm (comm) {}; + comm (comm) + { + } + + /** + * Construct a new vtk writer object. All parameters are set to false. + * + * \param[in] fileprefix + * \param[in] comm + */ + vtk_writer (std::string fileprefix, sc_MPI_Comm comm): fileprefix (fileprefix), comm (comm) + { + } -#if T8_WITH_VTK /** * A vtk-writer function that uses the vtk API * @@ -110,7 +121,6 @@ class vtk_writer { { return write_vtk (grid); } -#endif /** * A vtk-writer function that uses the vtk API diff --git a/src/t8_vtk/t8_vtk_writer_c_interface.cxx b/src/t8_vtk/t8_vtk_writer_c_interface.cxx new file mode 100644 index 0000000000..5f4ff1f873 --- /dev/null +++ b/src/t8_vtk/t8_vtk_writer_c_interface.cxx @@ -0,0 +1,65 @@ +/* +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) 2024 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 + +T8_EXTERN_C_BEGIN (); + +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 write_ghosts, const int num_data, + t8_vtk_data_field_t *data) +{ + vtk_writer writer (write_treeid, write_mpirank, write_element_id, write_ghosts, curved_flag, + std::string (fileprefix), num_data, data, t8_forest_get_mpicomm (forest)); + return writer.write_with_API (forest); +} + +int +t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, + const int write_level, const int write_element_id, int write_ghosts, const int num_data, + t8_vtk_data_field_t *data) +{ + vtk_writer writer (write_treeid, write_mpirank, write_element_id, write_ghosts, curved_flag, + std::string (fileprefix), num_data, data, t8_forest_get_mpicomm (forest)); + return writer.write_ASCII (forest); +} + +int +t8_cmesh_vtk_write_file_via_API (t8_cmesh_t cmesh, const char *fileprefix, sc_MPI_Comm comm) +{ + vtk_writer writer (std::string (fileprefix), comm); + return writer.write_with_API (cmesh); +} + +int +t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix) +{ + /* No mpi Communicator is needed for ASCII output*/ + vtk_writer writer (std::string (fileprefix), sc_MPI_COMM_NULL); + return writer.write_ASCII (cmesh); +} + +T8_EXTERN_C_END (); \ No newline at end of file diff --git a/src/t8_vtk/t8_vtk_writer_c_interface.h b/src/t8_vtk/t8_vtk_writer_c_interface.h new file mode 100644 index 0000000000..8fadf4739e --- /dev/null +++ b/src/t8_vtk/t8_vtk_writer_c_interface.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) 2024 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_WRITER_C_INTERFACE_H +#define T8_VTK_WRITER_C_INTERFACE_H + +#include +#include +#include + +/** 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] write_ghosts If true, write out ghost elements as well. + * \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 write_ghosts, 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 + * t8code is not configure with "--with-vtk" and + * \ref t8_forest_vtk_write_file_via_API is not available. + * \param [in] forest The forest. + * \param [in] fileprefix The prefix of the output files. + * \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] 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 used 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). + */ +int +t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, + const int write_level, const int write_element_id, int write_ghosts, const int num_data, + t8_vtk_data_field_t *data); + +/** + * Write the cmesh 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. + * + * \param[in] cmesh The cmesh + * \param[in] fileprefix The prefix of the output files + * \param[in] comm The communicator to use + * \return int + * \note If t8code was not configured with vtk, use \ref t8_cmesh_vtk_write_file + */ +int +t8_cmesh_vtk_write_file_via_API (t8_cmesh_t cmesh, const char *fileprefix, sc_MPI_Comm comm); + +/** + * Write the cmesh 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 + * t8code is not configure with "--with-vtk" and + * \ref t8_cmesh_vtk_write_file_via_API is not available. + * + * \param[in] cmesh The cmesh + * \param[in] fileprefix The prefix of the output files + * \return int + */ +int +t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix); + +#endif /* T8_VTK_WRITER_C_INTERFACE_H */ \ No newline at end of file From f31411b3a204de1a0cd36b6997bbb0d801c7512e Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 17 Jul 2024 14:54:02 +0200 Subject: [PATCH 13/87] Intermediate push --- src/t8_vtk/t8_vtk_writer.hxx | 8 ++++++++ src/t8_vtk/t8_vtk_writer_c_interface.h | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/t8_vtk/t8_vtk_writer.hxx b/src/t8_vtk/t8_vtk_writer.hxx index 70f13b0a11..92d5555d3c 100644 --- a/src/t8_vtk/t8_vtk_writer.hxx +++ b/src/t8_vtk/t8_vtk_writer.hxx @@ -109,6 +109,14 @@ class vtk_writer { { } +#if T8_WITH_VTK + void + grid_to_vtkUnstructuredGrid (const grid_t grid, vtkSmartPointer unstructuredGrid) + { + this->t8_grid_to_vtkUnstructuredGrid (grid, unstructuredGrid); + } +#endif + /** * A vtk-writer function that uses the vtk API * diff --git a/src/t8_vtk/t8_vtk_writer_c_interface.h b/src/t8_vtk/t8_vtk_writer_c_interface.h index 8fadf4739e..4ac1ff53d9 100644 --- a/src/t8_vtk/t8_vtk_writer_c_interface.h +++ b/src/t8_vtk/t8_vtk_writer_c_interface.h @@ -108,4 +108,10 @@ t8_cmesh_vtk_write_file_via_API (t8_cmesh_t cmesh, const char *fileprefix, sc_MP int t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix); +void +t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, vtkSmartPointer unstructuredGrid, + const int write_treeid, const int write_mpirank, const int write_level, + const int write_element_id, const int write_ghosts, const int curved_flag, + const int num_data, t8_vtk_data_field_t *data); + #endif /* T8_VTK_WRITER_C_INTERFACE_H */ \ No newline at end of file From 21ec04be1463fc1f35b478ba471e02a67dd8fc14 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 17 Jul 2024 15:47:13 +0200 Subject: [PATCH 14/87] Finalize Interface --- src/t8_vtk/t8_vtk_writer_c_interface.cxx | 13 +++++++++++++ src/t8_vtk/t8_vtk_writer_c_interface.h | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/t8_vtk/t8_vtk_writer_c_interface.cxx b/src/t8_vtk/t8_vtk_writer_c_interface.cxx index 5f4ff1f873..147a5fd941 100644 --- a/src/t8_vtk/t8_vtk_writer_c_interface.cxx +++ b/src/t8_vtk/t8_vtk_writer_c_interface.cxx @@ -62,4 +62,17 @@ t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix) return writer.write_ASCII (cmesh); } +#if T8_WITH_VTK +void +t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, vtkSmartPointer unstructuredGrid, + const int write_treeid, const int write_mpirank, const int write_level, + const int write_element_id, const int write_ghosts, const int curved_flag, + const int num_data, t8_vtk_data_field_t *data) +{ + vtk_writer writer (write_treeid, write_mpirank, write_element_id, write_ghosts, curved_flag, + std::string (fileprefix), num_data, data, t8_forest_get_mpicomm (forest)); + writer.grid_to_vtkUnstructuredGrid(forest, unstructuredGrid); +} +#endif + T8_EXTERN_C_END (); \ No newline at end of file diff --git a/src/t8_vtk/t8_vtk_writer_c_interface.h b/src/t8_vtk/t8_vtk_writer_c_interface.h index 4ac1ff53d9..c9aad539e9 100644 --- a/src/t8_vtk/t8_vtk_writer_c_interface.h +++ b/src/t8_vtk/t8_vtk_writer_c_interface.h @@ -108,10 +108,11 @@ t8_cmesh_vtk_write_file_via_API (t8_cmesh_t cmesh, const char *fileprefix, sc_MP int t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix); +#if T8_WITH_VTK void t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, vtkSmartPointer unstructuredGrid, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int write_ghosts, const int curved_flag, const int num_data, t8_vtk_data_field_t *data); - +#endif #endif /* T8_VTK_WRITER_C_INTERFACE_H */ \ No newline at end of file From 663ce2f0e41e4a267a8cec2dac9376f5e6f64913 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 17 Jul 2024 17:27:49 +0200 Subject: [PATCH 15/87] Remove old functions --- benchmarks/ExtremeScaling/bunny.cxx | 3 +- benchmarks/time_forest_partition.cxx | 3 +- benchmarks/time_partition.cxx | 3 +- example/IO/cmesh/gmsh/t8_read_msh_file.cxx | 2 +- example/IO/cmesh/t8_cmesh_load_save.cxx | 4 +- .../IO/cmesh/tetgen/t8_forest_from_tetgen.cxx | 2 +- .../IO/cmesh/tetgen/t8_read_tetgen_file.cxx | 2 +- .../cmesh/triangle/t8_read_triangle_file.cxx | 2 +- .../IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx | 2 +- example/advect/t8_advection.cxx | 2 +- example/cmesh/t8_cmesh_create_partitioned.cxx | 2 +- example/cmesh/t8_cmesh_geometry_examples.cxx | 3 +- example/cmesh/t8_cmesh_hypercube_pad.cxx | 5 +- example/cmesh/t8_cmesh_partition.cxx | 3 +- example/forest/t8_test_face_iterate.cxx | 2 +- example/forest/t8_test_ghost.cxx | 2 +- .../forest/t8_test_ghost_large_level_diff.cxx | 2 +- src/Makefile.am | 8 +- src/t8_cmesh/t8_cmesh_vtk_writer.c | 289 ---- src/t8_cmesh_vtk_writer.h | 4 - src/t8_forest/t8_forest.cxx | 2 +- .../t8_forest_to_vtkUnstructured.hxx | 42 - src/t8_forest/t8_forest_vtk.cxx | 1311 ----------------- src/t8_forest/t8_forest_vtk.h | 60 - src/t8_vtk/t8_vtk_writer.hxx | 11 +- src/t8_vtk/t8_vtk_writer_c_interface.cxx | 12 +- src/t8_vtk/t8_vtk_writer_c_interface.h | 7 + src/t8_vtk/t8_vtk_writer_helper.hxx | 1 + .../t8_gtest_geometry_cad.cxx | 6 +- .../t8_gtest_geometry_lagrange.cxx | 3 +- tutorials/general/t8_tutorial_build_cmesh.cxx | 2 +- 31 files changed, 58 insertions(+), 1744 deletions(-) diff --git a/benchmarks/ExtremeScaling/bunny.cxx b/benchmarks/ExtremeScaling/bunny.cxx index 278f6c20fb..622f6c65c3 100644 --- a/benchmarks/ExtremeScaling/bunny.cxx +++ b/benchmarks/ExtremeScaling/bunny.cxx @@ -24,7 +24,8 @@ #include #include #include -#include +#include + #include #include #include diff --git a/benchmarks/time_forest_partition.cxx b/benchmarks/time_forest_partition.cxx index 6aac6af1a2..2ff943cccd 100644 --- a/benchmarks/time_forest_partition.cxx +++ b/benchmarks/time_forest_partition.cxx @@ -28,7 +28,8 @@ #include #include #include -#include +#include + #include #include #include diff --git a/benchmarks/time_partition.cxx b/benchmarks/time_partition.cxx index df5c8704bf..c6d608c051 100644 --- a/benchmarks/time_partition.cxx +++ b/benchmarks/time_partition.cxx @@ -26,7 +26,8 @@ #include #include #include -#include +#include + #include #include "t8_cmesh/t8_cmesh_types.h" #include diff --git a/example/IO/cmesh/gmsh/t8_read_msh_file.cxx b/example/IO/cmesh/gmsh/t8_read_msh_file.cxx index d8a662474a..4de9119624 100644 --- a/example/IO/cmesh/gmsh/t8_read_msh_file.cxx +++ b/example/IO/cmesh/gmsh/t8_read_msh_file.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/example/IO/cmesh/t8_cmesh_load_save.cxx b/example/IO/cmesh/t8_cmesh_load_save.cxx index 45f2bfcfc8..6059063fb8 100644 --- a/example/IO/cmesh/t8_cmesh_load_save.cxx +++ b/example/IO/cmesh/t8_cmesh_load_save.cxx @@ -22,9 +22,9 @@ #include #include -#include -#include +#include #include +#include #include static void diff --git a/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx b/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx index 313be2947c..d667f0bdb7 100644 --- a/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx +++ b/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/example/IO/cmesh/tetgen/t8_read_tetgen_file.cxx b/example/IO/cmesh/tetgen/t8_read_tetgen_file.cxx index 824722f64a..628300ff51 100644 --- a/example/IO/cmesh/tetgen/t8_read_tetgen_file.cxx +++ b/example/IO/cmesh/tetgen/t8_read_tetgen_file.cxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include void t8_read_tetgen_file_build_cmesh (const char *prefix, int do_dup, int do_partition) diff --git a/example/IO/cmesh/triangle/t8_read_triangle_file.cxx b/example/IO/cmesh/triangle/t8_read_triangle_file.cxx index c38498e0fc..e18695cfb2 100644 --- a/example/IO/cmesh/triangle/t8_read_triangle_file.cxx +++ b/example/IO/cmesh/triangle/t8_read_triangle_file.cxx @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include void 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 af3a6c2713..6ed3c34b45 100644 --- a/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx +++ b/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx @@ -17,7 +17,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., */ #include -#include +#include #include #include #include diff --git a/example/advect/t8_advection.cxx b/example/advect/t8_advection.cxx index 5239dafee1..a2ceccf1f0 100644 --- a/example/advect/t8_advection.cxx +++ b/example/advect/t8_advection.cxx @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include diff --git a/example/cmesh/t8_cmesh_create_partitioned.cxx b/example/cmesh/t8_cmesh_create_partitioned.cxx index 0f889e72dd..fc5e159dd5 100644 --- a/example/cmesh/t8_cmesh_create_partitioned.cxx +++ b/example/cmesh/t8_cmesh_create_partitioned.cxx @@ -20,7 +20,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include +#include /* Create a coarse mesh that is partitioned across two processes * (if mpisize >= 2). diff --git a/example/cmesh/t8_cmesh_geometry_examples.cxx b/example/cmesh/t8_cmesh_geometry_examples.cxx index 588109d04a..df4a4cb5ce 100644 --- a/example/cmesh/t8_cmesh_geometry_examples.cxx +++ b/example/cmesh/t8_cmesh_geometry_examples.cxx @@ -27,7 +27,8 @@ #include /* Forest definition and basic interface. */ #include /* Forest-related geometry operations. */ #include /* Default refinement scheme. */ -#include /* Write file in vtu file */ +#include +/* Write file in vtu file */ #include #include diff --git a/example/cmesh/t8_cmesh_hypercube_pad.cxx b/example/cmesh/t8_cmesh_hypercube_pad.cxx index 14c3222052..5bcac31666 100644 --- a/example/cmesh/t8_cmesh_hypercube_pad.cxx +++ b/example/cmesh/t8_cmesh_hypercube_pad.cxx @@ -22,11 +22,12 @@ #include #include -#include +#include + #include #include #include -#include +#include int main (int argc, char **argv) { diff --git a/example/cmesh/t8_cmesh_partition.cxx b/example/cmesh/t8_cmesh_partition.cxx index a2dec53aa0..8d7a30faaf 100644 --- a/example/cmesh/t8_cmesh_partition.cxx +++ b/example/cmesh/t8_cmesh_partition.cxx @@ -23,7 +23,8 @@ #include #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 6dacc5ecc1..905894d669 100644 --- a/example/forest/t8_test_face_iterate.cxx +++ b/example/forest/t8_test_face_iterate.cxx @@ -31,9 +31,9 @@ #include #include #include -#include #include #include +#include typedef struct { diff --git a/example/forest/t8_test_ghost.cxx b/example/forest/t8_test_ghost.cxx index cc3833d0cb..03cb952ced 100644 --- a/example/forest/t8_test_ghost.cxx +++ b/example/forest/t8_test_ghost.cxx @@ -30,7 +30,7 @@ #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 e2e93a40c9..2ccaac7c1b 100644 --- a/example/forest/t8_test_ghost_large_level_diff.cxx +++ b/example/forest/t8_test_ghost_large_level_diff.cxx @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/Makefile.am b/src/Makefile.am index edc0b0f551..14cb234e9e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -106,14 +106,15 @@ libt8_internal_headers = \ src/t8_forest/t8_forest_private.h \ src/t8_windows.h \ src/t8_vtk/t8_vtk_writer_impl.hxx \ - src/t8_vtk/t8_vtk_writer_helper.hxx + src/t8_vtk/t8_vtk_writer_helper.hxx \ + src/t8_vtk/t8_vtk_write_ASCII.hxx libt8_compiled_sources = \ src/t8.c src/t8_eclass.c src/t8_mesh.c \ src/t8_element.cxx \ src/t8_element_c_interface.cxx \ src/t8_refcount.c src/t8_cmesh/t8_cmesh.cxx \ src/t8_cmesh/t8_cmesh_cad.cxx src/t8_cmesh/t8_cmesh_triangle.cxx \ - src/t8_cmesh/t8_cmesh_vtk_writer.c src/t8_cmesh/t8_cmesh_stash.c \ + src/t8_cmesh/t8_cmesh_stash.c \ src/t8_cmesh/t8_cmesh_vtk_reader.cxx \ src/t8_cmesh/t8_cmesh_save.cxx \ src/t8_cmesh/t8_cmesh_netcdf.c \ @@ -150,7 +151,8 @@ libt8_compiled_sources = \ src/t8_vtk/t8_vtk_unstructured.cxx \ src/t8_vtk/t8_vtk_parallel.cxx \ src/t8_vtk/t8_vtk_reader.cxx \ - src/t8_vtk/t8_vtk_writer_c_interface.ccc + src/t8_vtk/t8_vtk_writer_c_interface.cxx \ + src/t8_vtk/t8_vtk_write_ASCII.cxx # this variable is used for headers that are not publicly installed diff --git a/src/t8_cmesh/t8_cmesh_vtk_writer.c b/src/t8_cmesh/t8_cmesh_vtk_writer.c index bed01ef3f4..fdb7d2e33d 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_writer.c +++ b/src/t8_cmesh/t8_cmesh_vtk_writer.c @@ -19,292 +19,3 @@ 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 "t8_cmesh_trees.h" -#include "t8_cmesh_types.h" - -/* Return the local number of vertices in a cmesh. - * \param [in] cmesh The cmesh to be considered. - * \param [in] count_ghosts If true, we also count the vertices of the ghost trees. - * \return The number of vertices associated to \a cmesh. - * \a cmesh must be committed before calling this function. - */ -static t8_gloidx_t -t8_cmesh_get_num_vertices (const t8_cmesh_t cmesh, const int count_ghosts) -{ - int iclass; - t8_eclass_t ghost_class; - t8_gloidx_t num_vertices = 0; - t8_locidx_t ighost; - T8_ASSERT (cmesh != NULL); - T8_ASSERT (cmesh->committed); - - for (iclass = T8_ECLASS_ZERO; iclass < T8_ECLASS_COUNT; iclass++) { - num_vertices += t8_eclass_num_vertices[iclass] * cmesh->num_local_trees_per_eclass[iclass]; - } - if (count_ghosts) { - /* Also count the vertices of the ghost trees */ - for (ighost = 0; ighost < t8_cmesh_get_num_ghosts (cmesh); ighost++) { - ghost_class = t8_cmesh_get_ghost_class (cmesh, ighost); - num_vertices += t8_eclass_num_vertices[ghost_class]; - } - } - - return num_vertices; -} - -static int -t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, const int write_ghosts) -{ - T8_ASSERT (cmesh != NULL); - T8_ASSERT (t8_cmesh_is_committed (cmesh)); - T8_ASSERT (fileprefix != NULL); - - if (cmesh->mpirank == 0) { - /* Write the pvtu header file. */ - int num_ranks_that_write = cmesh->set_partition ? cmesh->mpisize : 1; - if (t8_write_pvtu (fileprefix, num_ranks_that_write, 1, 1, 0, 0, 0, NULL)) { - SC_ABORTF ("Error when writing file %s.pvtu\n", fileprefix); - } - } - /* If the cmesh is replicated only rank 0 prints it, - * otherwise each process prints its part of the cmesh.*/ - if (cmesh->mpirank == 0 || cmesh->set_partition) { - char vtufilename[BUFSIZ]; - FILE *vtufile; - t8_locidx_t num_vertices, ivertex; - t8_locidx_t num_trees; - t8_ctree_t tree; - double x, y, z; - double *vertices, *vertex; - int k, sk; - long long offset, count_vertices; - t8_locidx_t ighost, num_ghosts = 0, num_loc_trees; -#ifdef T8_ENABLE_DEBUG - t8_cghost_t ghost; -#endif - t8_eclass_t eclass; - - num_vertices = t8_cmesh_get_num_vertices (cmesh, write_ghosts); - num_trees = t8_cmesh_get_num_local_trees (cmesh); - if (write_ghosts) { - num_trees += t8_cmesh_get_num_ghosts (cmesh); - } - - snprintf (vtufilename, BUFSIZ, "%s_%04d.vtu", fileprefix, cmesh->mpirank); - vtufile = fopen (vtufilename, "wb"); - if (vtufile == NULL) { - t8_global_errorf ("Could not open file %s for output.\n", vtufilename); - return -1; - } - fprintf (vtufile, "\n"); - fprintf (vtufile, "\n"); -#else - fprintf (vtufile, " byte_order=\"LittleEndian\">\n"); -#endif - fprintf (vtufile, " \n"); - fprintf (vtufile, " \n", (long long) num_vertices, - (long long) num_trees); - fprintf (vtufile, " \n"); - - /* write point position data */ - fprintf (vtufile, - " \n", - T8_VTK_FLOAT_NAME, T8_VTK_FORMAT_STRING); - - for (tree = t8_cmesh_get_first_tree (cmesh); tree != NULL; tree = t8_cmesh_get_next_tree (cmesh, tree)) { - /* TODO: Use new geometry here. Need cmesh_get_reference coords function. */ - vertices = t8_cmesh_get_tree_vertices (cmesh, tree->treeid); - for (ivertex = 0; ivertex < t8_eclass_num_vertices[tree->eclass]; ivertex++) { - vertex = vertices + 3 * t8_eclass_t8_to_vtk_corner_number[tree->eclass][ivertex]; - x = vertex[0]; - y = vertex[1]; - z = vertex[2]; -#ifdef T8_VTK_DOUBLES - fprintf (vtufile, " %24.16e %24.16e %24.16e\n", x, y, z); -#else - fprintf (vtufile, " %16.8e %16.8e %16.8e\n", x, y, z); -#endif - } - } /* end tree loop */ - if (write_ghosts) { - - /* Write the vertices of the ghost trees */ - num_ghosts = t8_cmesh_get_num_ghosts (cmesh); - num_loc_trees = t8_cmesh_get_num_local_trees (cmesh); - for (ighost = 0; ighost < num_ghosts; ighost++) { - /* Get the eclass of this ghost */ - eclass = t8_cmesh_get_ghost_class (cmesh, ighost); - /* Get a pointer to this ghosts vertices */ - vertices = (double *) t8_cmesh_get_attribute (cmesh, t8_get_package_id (), 0, ighost + num_loc_trees); - T8_ASSERT (vertices != NULL); - /* TODO: This code is duplicated above */ - for (ivertex = 0; ivertex < t8_eclass_num_vertices[eclass]; ivertex++) { - vertex = vertices + 3 * t8_eclass_vtk_to_t8_corner_number[eclass][ivertex]; - x = vertex[0]; - y = vertex[1]; - z = vertex[2]; -#ifdef T8_VTK_DOUBLES - fprintf (vtufile, " %24.16e %24.16e %24.16e\n", x, y, z); -#else - fprintf (vtufile, " %16.8e %16.8e %16.8e\n", x, y, z); -#endif - } - } /* end ghost loop */ - } - fprintf (vtufile, " \n"); - fprintf (vtufile, " \n"); - fprintf (vtufile, " \n"); - - /* write connectivity data */ - fprintf (vtufile, - " \n", - T8_VTK_LOCIDX, T8_VTK_FORMAT_STRING); - for (tree = t8_cmesh_get_first_tree (cmesh), count_vertices = 0; tree != NULL; - tree = t8_cmesh_get_next_tree (cmesh, tree)) { - fprintf (vtufile, " "); - for (k = 0; k < t8_eclass_num_vertices[tree->eclass]; ++k, count_vertices++) { - fprintf (vtufile, " %lld", count_vertices); - } - fprintf (vtufile, "\n"); - } - if (write_ghosts) { - /* Write the ghost connectivity */ - for (ighost = 0; ighost < num_ghosts; ighost++) { - eclass = t8_cmesh_get_ghost_class (cmesh, ighost); - fprintf (vtufile, " "); - for (k = 0; k < t8_eclass_num_vertices[eclass]; ++k, count_vertices++) { - fprintf (vtufile, " %lld", count_vertices); - } - fprintf (vtufile, "\n"); - } - } - fprintf (vtufile, " \n"); - - /* write offset data */ - fprintf (vtufile, - " \n", - T8_VTK_LOCIDX, T8_VTK_FORMAT_STRING); - fprintf (vtufile, " "); - for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1, offset = 0; tree != NULL; - tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { - offset += t8_eclass_num_vertices[tree->eclass]; - fprintf (vtufile, " %lld", offset); - if (!(sk % 8)) - fprintf (vtufile, "\n "); - } - if (write_ghosts) { - /* ghost offset data */ - for (ighost = 0; ighost < num_ghosts; ighost++, ++sk) { - eclass = t8_cmesh_get_ghost_class (cmesh, ighost); - offset += t8_eclass_num_vertices[eclass]; - fprintf (vtufile, " %lld", offset); - if (!(sk % 8)) - fprintf (vtufile, "\n "); - } - } - fprintf (vtufile, "\n"); - fprintf (vtufile, " \n"); - /* write type data */ - fprintf (vtufile, - " \n", - T8_VTK_FORMAT_STRING); - fprintf (vtufile, " "); - for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1; tree != NULL; - tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { - fprintf (vtufile, " %d", t8_eclass_vtk_type[tree->eclass]); - if (!(sk % 20) && tree->treeid != (cmesh->num_local_trees - 1)) - fprintf (vtufile, "\n "); - } - if (write_ghosts) { - /* ghost offset types */ - for (ighost = 0; ighost < num_ghosts; ighost++, ++sk) { - eclass = t8_cmesh_get_ghost_class (cmesh, ighost); - fprintf (vtufile, " %d", t8_eclass_vtk_type[eclass]); - if (!(sk % 20) && ighost != (num_ghosts - 1)) - fprintf (vtufile, "\n "); - } - } - fprintf (vtufile, "\n"); - fprintf (vtufile, " \n"); - fprintf (vtufile, " \n"); - /* write treeif data */ - fprintf (vtufile, " \n"); - fprintf (vtufile, - " \n", - T8_VTK_GLOIDX, T8_VTK_FORMAT_STRING); - fprintf (vtufile, " "); - for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1, offset = 0; tree != NULL; - tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { - /* Since tree_id is actually 64 Bit but we store it as 32, we have to check - * that we do not get into conversion errors */ - /* TODO: We switched to 32 Bit because Paraview could not handle 64 well enough. - */ - T8_ASSERT (tree->treeid + cmesh->first_tree == (t8_gloidx_t) ((long) tree->treeid + cmesh->first_tree)); - fprintf (vtufile, " %ld", (long) tree->treeid + cmesh->first_tree); - if (!(sk % 8)) - fprintf (vtufile, "\n "); - } - if (write_ghosts) { - /* ghost offset types */ - for (ighost = 0; ighost < num_ghosts; ighost++, ++sk) { -#ifdef T8_ENABLE_DEBUG - ghost = t8_cmesh_trees_get_ghost (cmesh->trees, ighost); - /* Check for conversion errors */ - T8_ASSERT (ghost->treeid == (t8_gloidx_t) ((long) ghost->treeid)); -#endif - /* Write -1 as tree_id so that we can distinguish ghosts from normal trees - * in the vtk file */ - fprintf (vtufile, " %ld", (long) -1); - if (!(sk % 8)) - fprintf (vtufile, "\n "); - } - } - fprintf (vtufile, "\n"); - fprintf (vtufile, " \n"); - /* write mpirank data */ - fprintf (vtufile, - " \n", - "Int32", T8_VTK_FORMAT_STRING); - fprintf (vtufile, " "); - for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1, offset = 0; tree != NULL; - tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { - fprintf (vtufile, " %i", cmesh->mpirank); - if (!(sk % 8)) - fprintf (vtufile, "\n "); - } - if (write_ghosts) { - /* write our rank for each ghost */ - for (ighost = 0; ighost < num_ghosts; ighost++, ++sk) { - fprintf (vtufile, " %i", cmesh->mpirank); - if (!(sk % 8)) - fprintf (vtufile, "\n "); - } - } - fprintf (vtufile, "\n"); - fprintf (vtufile, " \n"); - fprintf (vtufile, " \n"); - /* write type data */ - fprintf (vtufile, " \n"); - fprintf (vtufile, " \n"); - fprintf (vtufile, "\n"); - fclose (vtufile); - } - return 0; -} - -int -t8_cmesh_vtk_write_file (const t8_cmesh_t cmesh, const char *fileprefix) -{ - return t8_cmesh_vtk_write_file_ext (cmesh, fileprefix, 1); -} diff --git a/src/t8_cmesh_vtk_writer.h b/src/t8_cmesh_vtk_writer.h index 7283bc7471..5e73159f1a 100644 --- a/src/t8_cmesh_vtk_writer.h +++ b/src/t8_cmesh_vtk_writer.h @@ -34,10 +34,6 @@ T8_EXTERN_C_BEGIN (); /* function declarations */ -/* TODO: document this function */ -int -t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix); - T8_EXTERN_C_END (); #endif /* !T8_CMESH_VTK_H */ diff --git a/src/t8_forest/t8_forest.cxx b/src/t8_forest/t8_forest.cxx index 63b407f01a..68edb31bb0 100644 --- a/src/t8_forest/t8_forest.cxx +++ b/src/t8_forest/t8_forest.cxx @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #if T8_ENABLE_DEBUG #include diff --git a/src/t8_forest/t8_forest_to_vtkUnstructured.hxx b/src/t8_forest/t8_forest_to_vtkUnstructured.hxx index 450f0fcf5d..2ea42306a2 100644 --- a/src/t8_forest/t8_forest_to_vtkUnstructured.hxx +++ b/src/t8_forest/t8_forest_to_vtkUnstructured.hxx @@ -23,46 +23,4 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #ifndef T8_FOREST_VTK_UNSTRUCTURED_API_HXX #define T8_FOREST_VTK_UNSTRUCTURED_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] write_ghosts If true, write ghost elements. - * \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 unstructuredGrid, - const int write_treeid, const int write_mpirank, const int write_level, - const int write_element_id, const int curved_flag, const int write_ghosts, - const int num_data, t8_vtk_data_field_t *data); - -#endif - -T8_EXTERN_C_END (); - #endif /* T8_FOREST_VTK_UNSTRUCTURED_API_HXX */ diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index c97044ef88..de0fbd25bf 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -63,1315 +63,4 @@ /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); -/* TODO: Currently we only use ASCII mode and no data compression. - * We also do not use sc_io to buffer our output stream. */ - -/* There are different cell data to write, e.g. connectivity, type, vertices, ... - * The structure is always the same: - * Iterate over the trees, - * iterate over the elements of that tree - * execute an element dependent part to write in the file. - * In order to simplify writing this code, we put all the parts that are - * repetitive in the function - * t8_forest_vtk_write_cell_data. - * This function accepts a callback function, which is then executed for - * each element. The callback function is defined below. - */ -/* TODO: As soon as we have element iterators we should restructure this concept - * appropriately. */ -typedef enum { T8_VTK_KERNEL_INIT, T8_VTK_KERNEL_EXECUTE, T8_VTK_KERNEL_CLEANUP } T8_VTK_KERNEL_MODUS; - -/** Callback function prototype for writing cell data. - * The function is executed for each element. - * The callback can run in three different modi: - * INIT - Called once, to (possibly) initialize the data pointer - * EXECUTE - Called for each element, the actual writing happens here. - * CLEANUP - Called once after all elements. Used to cleanup any memory - * allocated during INIT. - * \param [in] forest The forest. - * \param [in] ltree_id A local treeid. - * \param [in] tree The local tree of the forest with id \a ltree_id. - * \param [in] element_index An index of an element inside \a tree. - * \param [in] element A pointer to the current element. - * \param [in] ts The eclass scheme of the current element. - * \param [in] is_ghost Non-zero if the current element is a ghost element. - * In this cas \a tree is NULL. - * All ghost element will be traversed after all elements are - * \param [in,out] vtufile The open file stream to which we write the forest. - * \param [in,out] columns An integer counting the number of written columns. - * The callback should increase this value by the number - * of values written to the file. - * \param [in,out] data A pointer that the callback can modify at will. - * Between modi INIT and CLEANUP, \a data will not be - * modified outside of this callback. - * \param [in] modus The modus in which the callback is called. See above. - * \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, 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); - -#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 */ -const int t8_curved_eclass_vtk_type[T8_ECLASS_COUNT] = { 1, 21, 23, 22, 25, 24, 26, 27 }; - -/** 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_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, 0, 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_HEX */ - { 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 }, - { 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, 0, 0 }, { 1, 1, 0 }, { 0, 0, 1 }, { 1, 0, 1 }, { 1, 1, 1 }, { 0.5, 0, 0 }, - { 1, 0.5, 0 }, { 0.5, 0.5, 0 }, { 0.5, 0, 1 }, { 1, 0.5, 1 }, { 0.5, 0.5, 1 }, { 0, 0, 0.5 }, { 1, 0, 0.5 }, - { 1, 1, 0.5 }, { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 } }, - { /* T8_ECLASS_PYRAMID */ - { 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 } } }; - -/* depending on whether we want to write curved or non-curved elements - * we need the right number of points, so we choose the right lookup table - */ -#if T8_WITH_VTK -static int -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) { - return t8_curved_eclass_num_nodes[eclass]; - } - return t8_eclass_num_vertices[eclass]; -} -#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, - const int curved_flag, double *out_coords) -{ - 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_element_ref_coords[element_shape][vertex]; - const int num_node = t8_get_number_of_vtk_nodes (element_shape, curved_flag); - t8_forest_element_from_ref_coords (forest, ltreeid, element, ref_coords, num_node, out_coords); -} - -/** - * Translate a single element from the forest into a vtkCell and fill the vtkArrays with - * the data related to the element (not element_data). - */ -static void -t8_forest_element_to_vtk_cell ( - t8_forest_t forest, const t8_element_t *element, t8_eclass_scheme_c *scheme, const t8_locidx_t itree, - const t8_gloidx_t offset, const int write_treeid, const int write_mpirank, const int write_level, - const int write_element_id, const int curved_flag, const int is_ghost, const int elem_id, long int *point_id, - int *cellTypes, vtkSmartPointer points, vtkSmartPointer cellArray, - vtkSmartPointer vtk_treeid, vtkSmartPointer vtk_mpirank, - vtkSmartPointer vtk_level, vtkSmartPointer vtk_element_id) -{ - vtkSmartPointer pvtkCell = NULL; - - 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) { - case T8_ECLASS_VERTEX: - pvtkCell = vtkSmartPointer::New (); - break; - case T8_ECLASS_LINE: - pvtkCell = vtkSmartPointer::New (); - break; - case T8_ECLASS_QUAD: - pvtkCell = vtkSmartPointer::New (); - break; - case T8_ECLASS_TRIANGLE: - pvtkCell = vtkSmartPointer::New (); - break; - case T8_ECLASS_HEX: - pvtkCell = vtkSmartPointer::New (); - break; - case T8_ECLASS_TET: - pvtkCell = vtkSmartPointer::New (); - break; - case T8_ECLASS_PRISM: - pvtkCell = vtkSmartPointer::New (); - break; - case T8_ECLASS_PYRAMID: - pvtkCell = vtkSmartPointer::New (); - break; - default: - SC_ABORT_NOT_REACHED (); - } - } - else { /* curved_flag != 0 */ - switch (element_shape) { - case T8_ECLASS_VERTEX: - pvtkCell = vtkSmartPointer::New (); - break; - case T8_ECLASS_LINE: - pvtkCell = vtkSmartPointer::New (); - break; - case T8_ECLASS_QUAD: - pvtkCell = vtkSmartPointer::New (); - break; - case T8_ECLASS_TRIANGLE: - pvtkCell = vtkSmartPointer::New (); - break; - case T8_ECLASS_HEX: - pvtkCell = vtkSmartPointer::New (); - break; - case T8_ECLASS_TET: - pvtkCell = vtkSmartPointer::New (); - break; - case T8_ECLASS_PRISM: - pvtkCell = vtkSmartPointer::New (); - break; - case T8_ECLASS_PYRAMID: - pvtkCell = vtkSmartPointer::New (); - break; - default: - SC_ABORT_NOT_REACHED (); - } - } - double *coordinates = T8_ALLOC (double, 3 * num_node); - /* Compute coordinates for all vertices inside the domain. */ - t8_forest_vtk_get_element_nodes (forest, itree, element, 0, curved_flag, coordinates); - /* For each element we iterate over all points */ - for (int ivertex = 0; ivertex < num_node; ivertex++, (*point_id)++) { - const size_t offset_3d = 3 * ivertex; - /* Insert point in the points array */ - points->InsertNextPoint (coordinates[offset_3d], coordinates[offset_3d + 1], coordinates[offset_3d + 2]); - - pvtkCell->GetPointIds ()->SetId (ivertex, *point_id); - } - T8_FREE (coordinates); - /* We insert the next cell in the cell array */ - cellArray->InsertNextCell (pvtkCell); - /* - * Write current cell Type in the cell Types array at the elem_id index. - * Depending on the values of the binary inputs write_treeid, - * write_mpirank and write_element_id we also fill the corresponding - * arrays with the data we want(treeid,mpirank,element_id). - * To get the element id, we have to add the local id in the tree - * plus theo - */ - if (curved_flag == 0) { - cellTypes[elem_id - offset] = t8_eclass_vtk_type[element_shape]; - } - else { - cellTypes[elem_id - offset] = t8_curved_eclass_vtk_type[element_shape]; - } - if (write_treeid == 1) { - const t8_gloidx_t gtree_id = t8_forest_global_tree_id (forest, itree); - if (is_ghost) { - vtk_treeid->InsertNextValue (-1); - } - else { - vtk_treeid->InsertNextValue (gtree_id); - } - } - if (write_mpirank == 1) { - vtk_mpirank->InsertNextValue (forest->mpirank); - } - if (write_level == 1) { - vtk_level->InsertNextValue (scheme->t8_element_level (element)); - } - if (write_element_id == 1) { - vtk_element_id->InsertNextValue (elem_id); - } -} -#endif - -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 write_ghosts, const int num_data, - 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 unstructuredGrid = vtkSmartPointer::New (); - t8_forest_to_vtkUnstructuredGrid (forest, unstructuredGrid, write_treeid, write_mpirank, write_level, - write_element_id, curved_flag, write_ghosts, 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 pwriterObj = vtkSmartPointer::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 vtk_comm = vtkSmartPointer::New (); - vtkMPICommunicatorOpaqueComm vtk_opaque_comm (&forest->mpicomm); - vtk_comm->InitializeExternal (&vtk_opaque_comm); - - vtkSmartPointer vtk_mpi_ctrl = vtkSmartPointer::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 unstructuredGrid, - const int write_treeid, const int write_mpirank, const int write_level, - const int write_element_id, const int write_ghosts, 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 committed */ - T8_ASSERT (forest != NULL); - T8_ASSERT (forest->rc.refcount > 0); - T8_ASSERT (forest->committed); - - long int point_id = 0; /* The id of the point in the points Object. */ - - const t8_gloidx_t offset = t8_forest_get_first_local_element_id (forest); - t8_gloidx_t elem_id = offset; - - vtkSmartPointer cellArray = vtkSmartPointer::New (); - - vtkSmartPointer points = vtkSmartPointer::New (); - - int ghosts = write_ghosts; - if (forest->ghosts == NULL || forest->ghosts->num_ghosts_elements == 0) { - /* Never write ghost elements if there aren't any */ - ghosts = 0; - } - T8_ASSERT (forest->ghosts != NULL || !ghosts); - /* - * The cellTypes Array stores the element types as integers(see vtk doc). - */ - t8_locidx_t num_elements = t8_forest_get_local_num_elements (forest); - if (ghosts) { - num_elements += t8_forest_get_num_ghosts (forest); - } - int *cellTypes = T8_ALLOC (int, num_elements); - - /* - * We need the vertex coords array to be of the - * correct dim. Since it is always the same - * in one mesh, we take the dim of one element. - * We add 1 if we look at a vertext(dim=0) because - * an array of size 0 is not allowed. - * Then we allocate memory, because we do not know - * beforehand how many entries the array needs. - */ - - /* - * We have to define the vtkTypeInt64Array that hold - * metadata if wanted. - */ - - vtkSmartPointer vtk_treeid = vtkSmartPointer::New (); - vtkSmartPointer vtk_mpirank = vtkSmartPointer::New (); - vtkSmartPointer vtk_level = vtkSmartPointer::New (); - vtkSmartPointer vtk_element_id = vtkSmartPointer::New (); - - /* - * We need the dataArray for writing double valued user defined data in the vtu files. - * We want to write num_data many timesteps/arrays. - * We need num_data many vtkDoubleArrays, so we need to allocate storage. - * Later we call the constructor with: dataArrays[idata]=vtkDoubleArray::New() - */ - vtkDoubleArray **dataArrays; - dataArrays = T8_ALLOC (vtkDoubleArray *, num_data); - - const t8_locidx_t num_local_trees = t8_forest_get_num_local_trees (forest); - - /* We iterate over all local trees*/ - for (t8_locidx_t itree = 0; itree < num_local_trees; itree++) { - /* - * We get the current tree, the scheme for this tree - * and the number of elements in this tree. We need the vertices of - * the tree to get the coordinates of the elements later. We need - * the number of elements in this tree to iterate over all of them. - */ - t8_eclass_scheme_c *scheme = t8_forest_get_eclass_scheme (forest, t8_forest_get_tree_class (forest, itree)); - const t8_locidx_t elems_in_tree = t8_forest_get_tree_num_elements (forest, itree); - /* We iterate over all elements in the tree */ - 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); - - t8_forest_element_to_vtk_cell (forest, element, scheme, itree, offset, write_treeid, write_mpirank, write_level, - write_element_id, curved_flag, 0, elem_id, &point_id, cellTypes, points, cellArray, - vtk_treeid, vtk_mpirank, vtk_level, vtk_element_id); - - elem_id++; - } /* end of loop over elements */ - } /* end of loop over local trees */ - if (ghosts) { - /* Get number of ghost-trees */ - const t8_locidx_t num_ghost_trees = t8_forest_ghost_num_trees (forest); - for (t8_locidx_t itree_ghost = 0; itree_ghost < num_ghost_trees; itree_ghost++) { - /* Get Tree scheme of the ghost tree */ - t8_eclass_scheme_c *scheme - = t8_forest_get_eclass_scheme (forest, t8_forest_ghost_get_tree_class (forest, itree_ghost)); - const t8_locidx_t num_ghosts = t8_forest_ghost_tree_num_elements (forest, itree_ghost); - for (t8_locidx_t ielem_ghost = 0; ielem_ghost < num_ghosts; ielem_ghost++) { - const t8_element_t *element = t8_forest_ghost_get_element (forest, itree_ghost, ielem_ghost); - t8_forest_element_to_vtk_cell (forest, element, scheme, itree_ghost + num_local_trees, offset, write_treeid, - write_mpirank, write_level, write_element_id, curved_flag, 1, elem_id, &point_id, - cellTypes, points, cellArray, vtk_treeid, vtk_mpirank, vtk_level, - vtk_element_id); - elem_id++; - } - } - } - - unstructuredGrid->SetPoints (points); - unstructuredGrid->SetCells (cellTypes, cellArray); - - if (write_treeid) { - vtk_treeid->SetName ("treeid"); - unstructuredGrid->GetCellData ()->AddArray (vtk_treeid); - } - if (write_mpirank) { - vtk_mpirank->SetName ("mpirank"); - unstructuredGrid->GetCellData ()->AddArray (vtk_mpirank); - } - if (write_level) { - vtk_level->SetName ("level"); - unstructuredGrid->GetCellData ()->AddArray (vtk_level); - } - if (write_element_id) { - vtk_element_id->SetName ("element_id"); - unstructuredGrid->GetCellData ()->AddArray (vtk_element_id); - } - - /* 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 (); - const int num_components = data[idata].type == T8_VTK_SCALAR ? 1 : 3; - dataArrays[idata]->SetName (data[idata].description); /* Set the name of the array */ - dataArrays[idata]->SetNumberOfTuples (num_elements); /* We want number of tuples=number of elements */ - dataArrays[idata]->SetNumberOfComponents (num_components); /* Each tuples has 3 values */ - dataArrays[idata]->SetVoidArray (data[idata].data, num_elements * num_components, 1); - unstructuredGrid->GetCellData ()->AddArray (dataArrays[idata]); - } - - /* We have to free the allocated memory for the cellTypes Array and the other arrays we allocated memory for. */ - for (int idata = 0; idata < num_data; idata++) { - dataArrays[idata]->Delete (); - } - - T8_FREE (cellTypes); - T8_FREE (dataArrays); -} -#endif - -static t8_locidx_t -t8_forest_num_points (t8_forest_t forest, const int count_ghosts) -{ - 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 */ - t8_tree_t tree = (t8_tree_t) t8_sc_array_index_locidx (forest->trees, itree); - /* Get the scheme of the current tree */ - 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); - } - } - if (count_ghosts) { - T8_ASSERT (forest->ghosts != NULL); - /* We also count the points of the ghost cells */ - 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 */ - 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); - } - } - } - return num_points; -} - -static int -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, const int is_ghost, FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) -{ - double element_coordinates[3]; - int num_el_vertices, ivertex; - int freturn; - t8_element_shape_t element_shape; - - if (modus != T8_VTK_KERNEL_EXECUTE) { - /* Nothing to do if we are in Init or clean up mode */ - return 1; - } - - /* TODO: be careful with pyramid class here. - * does this work too over tree->class or do we need something else? - */ - - element_shape = ts->t8_element_shape (element); - num_el_vertices = t8_eclass_num_vertices[element_shape]; - for (ivertex = 0; ivertex < num_el_vertices; ivertex++) { - const double *ref_coords = t8_forest_vtk_point_to_element_ref_coords[element_shape][ivertex]; - t8_forest_element_from_ref_coords (forest, ltree_id, element, ref_coords, 1, element_coordinates); - freturn = fprintf (vtufile, " "); - if (freturn <= 0) { - return 0; - } -#ifdef T8_VTK_DOUBLES - freturn = fprintf (vtufile, " %24.16e %24.16e %24.16e\n", element_coordinates[0], element_coordinates[1], - element_coordinates[2]); -#else - freturn = fprintf (vtufile, " %16.8e %16.8e %16.8e\n", element_coordinates[0], element_coordinates[1], - element_coordinates[2]); -#endif - if (freturn <= 0) { - return 0; - } - /* We switch of the column control of the surrounding function - * by keeping the columns value constant. */ - *columns = 1; - } - return 1; -} - -static int -t8_forest_vtk_cells_connectivity_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 ivertex, num_vertices; - int freturn; - t8_locidx_t *count_vertices; - t8_element_shape_t element_shape; - - if (modus == T8_VTK_KERNEL_INIT) { - /* We use data to count the number of written vertices */ - *data = T8_ALLOC_ZERO (t8_locidx_t, 1); - return 1; - } - else if (modus == T8_VTK_KERNEL_CLEANUP) { - T8_FREE (*data); - return 1; - } - T8_ASSERT (modus == T8_VTK_KERNEL_EXECUTE); - - count_vertices = (t8_locidx_t *) *data; - 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); - if (freturn <= 0) { - return 0; - } - } - *columns += t8_eclass_num_vertices[element_shape]; - return 1; -} - -static int -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; - int num_vertices; - - if (modus == T8_VTK_KERNEL_INIT) { - *data = T8_ALLOC_ZERO (long long, 1); - return 1; - } - else if (modus == T8_VTK_KERNEL_CLEANUP) { - T8_FREE (*data); - return 1; - } - T8_ASSERT (modus == T8_VTK_KERNEL_EXECUTE); - - offset = (long long *) *data; - - num_vertices = t8_eclass_num_vertices[ts->t8_element_shape (element)]; - *offset += num_vertices; - freturn = fprintf (vtufile, " %lld", *offset); - if (freturn <= 0) { - return 0; - } - *columns += 1; - - return 1; -} - -static int -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) { - /* print the vtk type of the element */ - freturn = fprintf (vtufile, " %d", t8_eclass_vtk_type[ts->t8_element_shape (element)]); - if (freturn <= 0) { - return 0; - } - *columns += 1; - } - return 1; -} - -static int -t8_forest_vtk_cells_level_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) -{ - if (modus == T8_VTK_KERNEL_EXECUTE) { - fprintf (vtufile, "%i ", ts->t8_element_level (element)); - *columns += 1; - } - return 1; -} - -static int -t8_forest_vtk_cells_rank_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) -{ - if (modus == T8_VTK_KERNEL_EXECUTE) { - fprintf (vtufile, "%i ", forest->mpirank); - *columns += 1; - } - return 1; -} - -static int -t8_forest_vtk_cells_treeid_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) -{ - if (modus == T8_VTK_KERNEL_EXECUTE) { - long long tree_id; - if (is_ghost) { - /* For ghost elements we write -1 as the tree is */ - tree_id = -1; - } - else { - /* Otherwise the global tree id */ - tree_id = (long long) ltree_id + forest->first_local_tree; - } - fprintf (vtufile, "%lli ", tree_id); - *columns += 1; - } - return 1; -} - -static int -t8_forest_vtk_cells_elementid_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) -{ - if (modus == T8_VTK_KERNEL_EXECUTE) { - if (!is_ghost) { - fprintf (vtufile, "%lli ", - element_index + tree->elements_offset + (long long) t8_forest_get_first_local_element_id (forest)); - } - else { - fprintf (vtufile, "%lli ", (long long) -1); - } - *columns += 1; - } - return 1; -} - -static int -t8_forest_vtk_cells_scalar_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) -{ - double element_value = 0; - t8_locidx_t scalar_index; - - if (modus == T8_VTK_KERNEL_EXECUTE) { - /* For local elements access the data array, for ghosts, write 0 */ - if (!is_ghost) { - scalar_index = t8_forest_get_tree_element_offset (forest, ltree_id) + element_index; - element_value = ((double *) *data)[scalar_index]; - } - else { - element_value = 0; - } - fprintf (vtufile, "%g ", element_value); - *columns += 1; - } - return 1; -} - -static int -t8_forest_vtk_cells_vector_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) -{ - double *element_values, null_vec[3] = { 0, 0, 0 }; - int dim, idim; - t8_locidx_t tree_offset; - - if (modus == T8_VTK_KERNEL_EXECUTE) { - dim = 3; - T8_ASSERT (forest->dimension <= 3); - /* For local elements access the data array, for ghosts, write 0 */ - if (!is_ghost) { - tree_offset = t8_forest_get_tree_element_offset (forest, ltree_id); - /* Get a pointer to the start of the element's vector data */ - element_values = ((double *) *data) + (tree_offset + element_index) * dim; - } - else { - element_values = null_vec; - } - for (idim = 0; idim < dim; idim++) { - fprintf (vtufile, "%g ", element_values[idim]); - } - *columns += dim; - } - return 1; -} - -/* The point data version of the scalar kernel */ -static int -t8_forest_vtk_vertices_scalar_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) -{ - double element_value = 0; - int num_vertex, ivertex; - t8_locidx_t scalar_index; - - if (modus == T8_VTK_KERNEL_EXECUTE) { - num_vertex = ts->t8_element_num_corners (element); - - for (ivertex = 0; ivertex < num_vertex; ivertex++) { - /* For local elements access the data array, for ghosts, write 0 */ - if (!is_ghost) { - scalar_index = t8_forest_get_tree_element_offset (forest, ltree_id) + element_index; - element_value = ((double *) *data)[scalar_index]; - } - else { - element_value = 0; - } - fprintf (vtufile, "%g ", element_value); - *columns += 1; - } - } - return 1; -} - -/* The point data version of the vector kernel */ -static int -t8_forest_vtk_vertices_vector_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) -{ - double *element_values, null_vec[3] = { 0, 0, 0 }; - int dim, idim; - int num_vertex, ivertex; - t8_locidx_t tree_offset; - - if (modus == T8_VTK_KERNEL_EXECUTE) { - num_vertex = ts->t8_element_num_corners (element); - for (ivertex = 0; ivertex < num_vertex; ivertex++) { - dim = 3; - T8_ASSERT (forest->dimension <= 3); - /* For local elements access the data array, for ghosts, write 0 */ - if (!is_ghost) { - tree_offset = t8_forest_get_tree_element_offset (forest, ltree_id); - /* Get a pointer to the start of the element's vector data */ - element_values = ((double *) *data) + (tree_offset + element_index) * dim; - } - else { - element_values = null_vec; - } - for (idim = 0; idim < dim; idim++) { - fprintf (vtufile, "%g ", element_values[idim]); - } - *columns += dim; - } - } - return 1; -} - -/* Iterate over all cells and write cell data to the file using - * the cell_data_kernel as callback */ -static int -t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *dataname, const char *datatype, - const char *component_string, const int max_columns, - t8_forest_vtk_cell_data_kernel kernel, const int write_ghosts, void *udata) -{ - int freturn; - int countcols; - t8_tree_t tree; - t8_locidx_t itree, ighost; - t8_locidx_t element_index, elems_in_tree; - t8_locidx_t num_local_trees, num_ghost_trees; - t8_element_t *element; - t8_eclass_scheme_c *ts; - void *data = NULL; - - /* Write the connectivity information. - * Thus for each tree we write the indices of its corner vertices. */ - freturn = fprintf (vtufile, - " \n ", - datatype, dataname, component_string); - if (freturn <= 0) { - return 0; - } - - /* if udata != NULL, use it as the data pointer, in this case, the kernel - * should not modify it */ - if (udata != NULL) { - data = udata; - } - - /* Call the kernel in initialization modus to possibly initialize the - * data pointer */ - kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_INIT); - /* We iterate over the trees and count each trees vertices, - * we add this to the already counted vertices and write it to the file */ - /* TODO: replace with an element iterator */ - num_local_trees = t8_forest_get_num_local_trees (forest); - for (itree = 0, countcols = 0; itree < num_local_trees; itree++) { - /* Get the tree that stores the elements */ - tree = t8_forest_get_tree (forest, itree); - /* Get the eclass scheme of the tree */ - ts = t8_forest_get_eclass_scheme (forest, t8_forest_get_tree_class (forest, itree)); - elems_in_tree = (t8_locidx_t) t8_element_array_get_count (&tree->elements); - for (element_index = 0; element_index < elems_in_tree; element_index++) { - /* Get a pointer to the element */ - element = t8_forest_get_element (forest, tree->elements_offset + element_index, NULL); - T8_ASSERT (element != NULL); - /* Execute the given callback on each element */ - if (!kernel (forest, itree, tree, element_index, element, ts, 0, vtufile, &countcols, &data, - T8_VTK_KERNEL_EXECUTE)) { - /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return 0; - } - /* After max_columns we break the line */ - if (!(countcols % max_columns)) { - freturn = fprintf (vtufile, "\n "); - if (freturn <= 0) { - /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return 0; - } - } - } /* element loop ends here */ - if (freturn <= 0) { - /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return 0; - } - } /* tree loop ends here */ - - if (write_ghosts) { - t8_locidx_t num_ghosts_in_tree; - /* Iterate over the ghost elements */ - /* TODO: replace with an element iterator */ - num_ghost_trees = t8_forest_ghost_num_trees (forest); - for (ighost = 0; ighost < num_ghost_trees; ighost++) { - /* Get the eclass scheme of the ghost tree */ - ts = t8_forest_get_eclass_scheme (forest, t8_forest_ghost_get_tree_class (forest, ighost)); - /* The number of ghosts in this tree */ - num_ghosts_in_tree = t8_forest_ghost_tree_num_elements (forest, ighost); - for (element_index = 0; element_index < num_ghosts_in_tree; element_index++) { - /* Get a pointer to the element */ - element = t8_forest_ghost_get_element (forest, ighost, element_index); - /* Execute the given callback on each element */ - if (!kernel (forest, ighost + num_local_trees, NULL, element_index, element, ts, 1, vtufile, &countcols, &data, - T8_VTK_KERNEL_EXECUTE)) { - /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, NULL, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return 0; - } - /* After max_columns we break the line */ - if (!(countcols % max_columns)) { - freturn = fprintf (vtufile, "\n "); - if (freturn <= 0) { - /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, NULL, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return 0; - } - } - } /* element loop ends here */ - if (freturn <= 0) { - /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, NULL, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return 0; - } - } /* ghost loop ends here */ - } /* write_ghosts ends here */ - /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - freturn = fprintf (vtufile, "\n \n"); - if (freturn <= 0) { - return 0; - } - - return 1; -} - -/* Write the cell data to an open file stream. - * Returns true on success and zero otherwise. - * After completion the file will remain open, whether writing - * cells was successful or not. */ -static int -t8_forest_vtk_write_cells (t8_forest_t forest, FILE *vtufile, 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; - int idata; - - T8_ASSERT (t8_forest_is_committed (forest)); - T8_ASSERT (vtufile != NULL); - - freturn = fprintf (vtufile, " \n"); - if (freturn <= 0) { - goto t8_forest_vtk_cell_failure; - } - - /* Write the connectivity information. - * Thus for each tree we write the indices of its corner vertices. */ - freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "connectivity", T8_VTK_LOCIDX, "", 8, - t8_forest_vtk_cells_connectivity_kernel, write_ghosts, NULL); - if (!freturn) { - goto t8_forest_vtk_cell_failure; - } - /* Done with writing the connectivity */ - - /* Write the offsets, that is for each tree the index of the first entry - * in the connectivity output that - * does not refer to a vertex of the tree anymore. - * For example if the trees are a square and a triangle, the offsets would - * be 4 and 7, since indices 0,1,2,3 refer to the vertices of the square - * and indices 4,5,6 to the indices of the triangle. */ - freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "offsets", T8_VTK_LOCIDX, "", 8, - t8_forest_vtk_cells_offset_kernel, write_ghosts, NULL); - if (!freturn) { - goto t8_forest_vtk_cell_failure; - } - /* Done with writing the offsets */ - - /* Write the element types. The type specifies the element class, thus - * square/triangle/tet etc. */ - - freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "types", "Int32", "", 8, t8_forest_vtk_cells_type_kernel, - write_ghosts, NULL); - - if (!freturn) { - goto t8_forest_vtk_cell_failure; - } - /* Done with writing the types */ - freturn = fprintf (vtufile, " \n"); - if (freturn <= 0) { - goto t8_forest_vtk_cell_failure; - } - /* clang-format off */ - freturn = fprintf (vtufile, " \n", "treeid,mpirank,level", - (write_element_id ? "id" : "")); - /* clang-format on */ - if (freturn <= 0) { - goto t8_forest_vtk_cell_failure; - } - - if (write_treeid) { - /* Write the tree ids. */ - - freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "treeid", T8_VTK_GLOIDX, "", 8, - t8_forest_vtk_cells_treeid_kernel, write_ghosts, NULL); - if (!freturn) { - goto t8_forest_vtk_cell_failure; - } - /* Done with writing the tree ids */ - } - if (write_mpirank) { - /* Write the mpiranks. */ - - freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "mpirank", "Int32", "", 8, - t8_forest_vtk_cells_rank_kernel, write_ghosts, NULL); - if (!freturn) { - goto t8_forest_vtk_cell_failure; - } - /* Done with writing the mpiranks */ - } - if (write_level) { - /* Write the element refinement levels. */ - - freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "level", "Int32", "", 8, t8_forest_vtk_cells_level_kernel, - write_ghosts, NULL); - if (!freturn) { - goto t8_forest_vtk_cell_failure; - } - /* Done with writing the levels */ - } - - if (write_element_id) { - /* Write the element ids. */ - const char *datatype; - - /* Use 32 bit ints if the global element count fits, 64 bit otherwise. */ - datatype = forest->global_num_elements > T8_LOCIDX_MAX ? T8_VTK_GLOIDX : T8_VTK_LOCIDX; - freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "element_id", datatype, "", 8, - t8_forest_vtk_cells_elementid_kernel, write_ghosts, NULL); - if (!freturn) { - goto t8_forest_vtk_cell_failure; - } - - /* Done with writing the element ids */ - } - /* Write the user defined data fields per element */ - for (idata = 0; idata < num_data; idata++) { - if (data[idata].type == T8_VTK_SCALAR) { - freturn = t8_forest_vtk_write_cell_data (forest, vtufile, data[idata].description, T8_VTK_FLOAT_NAME, "", 8, - t8_forest_vtk_cells_scalar_kernel, write_ghosts, data[idata].data); - } - else { - char component_string[BUFSIZ]; - T8_ASSERT (data[idata].type == T8_VTK_VECTOR); - snprintf (component_string, BUFSIZ, "NumberOfComponents=\"3\""); - freturn = t8_forest_vtk_write_cell_data (forest, vtufile, data[idata].description, T8_VTK_FLOAT_NAME, - component_string, 8 * forest->dimension, - t8_forest_vtk_cells_vector_kernel, write_ghosts, data[idata].data); - } - if (!freturn) { - goto t8_forest_vtk_cell_failure; - } - } - - freturn = fprintf (vtufile, " \n"); - if (freturn <= 0) { - goto t8_forest_vtk_cell_failure; - } - - /* Function completed successfully */ - return 1; -t8_forest_vtk_cell_failure: - /* Something went wrong */ - t8_errorf ("Error when writing cell data to forest vtk file.\n"); - return 0; -} - -/* Write the cell data to an open file stream. - * Returns true on success and zero otherwise. - * After completion the file will remain open, whether writing - * cells was successful or not. */ -static int -t8_forest_vtk_write_points (t8_forest_t forest, FILE *vtufile, const int write_ghosts, const int num_data, - t8_vtk_data_field_t *data) -{ - int freturn; - int sreturn; - int idata; - char description[BUFSIZ]; - - T8_ASSERT (t8_forest_is_committed (forest)); - T8_ASSERT (vtufile != NULL); - - /* Write the vertex coordinates */ - - freturn = fprintf (vtufile, " \n"); - if (freturn <= 0) { - goto t8_forest_vtk_cell_failure; - } - freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "Position", T8_VTK_FLOAT_NAME, "NumberOfComponents=\"3\"", - 8, t8_forest_vtk_cells_vertices_kernel, write_ghosts, NULL); - if (!freturn) { - goto t8_forest_vtk_cell_failure; - } - freturn = fprintf (vtufile, " \n"); - if (freturn <= 0) { - goto t8_forest_vtk_cell_failure; - } - /* Done writing vertex coordinates */ - - /* Write the user defined data fields per element */ - if (num_data > 0) { - freturn = fprintf (vtufile, " \n"); - for (idata = 0; idata < num_data; idata++) { - if (data[idata].type == T8_VTK_SCALAR) { - /* Write the description string. */ - sreturn = snprintf (description, BUFSIZ, "%s_%s", data[idata].description, "points"); - - if (sreturn >= BUFSIZ) { - /* The output was truncated */ - t8_debugf ("Warning: Truncated vtk point data description to '%s'\n", description); - } - freturn = t8_forest_vtk_write_cell_data (forest, vtufile, description, T8_VTK_FLOAT_NAME, "", 8, - t8_forest_vtk_vertices_scalar_kernel, write_ghosts, data[idata].data); - } - else { - char component_string[BUFSIZ]; - T8_ASSERT (data[idata].type == T8_VTK_VECTOR); - snprintf (component_string, BUFSIZ, "NumberOfComponents=\"3\""); - /* Write the description string. */ - sreturn = snprintf (description, BUFSIZ, "%s_%s", data[idata].description, "points"); - - if (sreturn >= BUFSIZ) { - /* The output was truncated */ - /* Note: gcc >= 7.1 prints a warning if we - * do not check the return value of snprintf. */ - t8_debugf ("Warning: Truncated vtk point data description to '%s'\n", description); - } - - freturn = t8_forest_vtk_write_cell_data (forest, vtufile, description, T8_VTK_FLOAT_NAME, component_string, - 8 * forest->dimension, t8_forest_vtk_vertices_vector_kernel, - write_ghosts, data[idata].data); - } - if (!freturn) { - goto t8_forest_vtk_cell_failure; - } - } - freturn = fprintf (vtufile, " \n"); - } - /* Function completed successfully */ - return 1; -t8_forest_vtk_cell_failure: - /* Something went wrong */ - t8_errorf ("Error when writing cell data to forest vtk file.\n"); - return 0; -} - -int -t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, - const int write_level, const int write_element_id, int write_ghosts, const int num_data, - t8_vtk_data_field_t *data) -{ - FILE *vtufile = NULL; - t8_locidx_t num_elements, num_points; - char vtufilename[BUFSIZ]; - int freturn; - - T8_ASSERT (forest != NULL); - T8_ASSERT (t8_forest_is_committed (forest)); - T8_ASSERT (fileprefix != NULL); - if (forest->ghosts == NULL || forest->ghosts->num_ghosts_elements == 0) { - /* Never write ghost elements if there aren't any */ - write_ghosts = 0; - } - T8_ASSERT (forest->ghosts != NULL || !write_ghosts); - - /* process 0 creates the .pvtu file */ - if (forest->mpirank == 0) { - if (t8_write_pvtu (fileprefix, forest->mpisize, write_treeid, write_mpirank, write_level, write_element_id, - num_data, data)) { - t8_errorf ("Error when writing file %s.pvtu\n", fileprefix); - goto t8_forest_vtk_failure; - } - } - - /* The local number of elements */ - num_elements = t8_forest_get_local_num_elements (forest); - if (write_ghosts) { - num_elements += t8_forest_get_num_ghosts (forest); - } - /* The local number of points, counted with multiplicity */ - num_points = t8_forest_num_points (forest, write_ghosts); - - /* The filename for this processes file */ - freturn = snprintf (vtufilename, BUFSIZ, "%s_%04d.vtu", fileprefix, forest->mpirank); - if (freturn >= BUFSIZ) { - t8_errorf ("Error when writing vtu file. Filename too long.\n"); - goto t8_forest_vtk_failure; - } - - /* Open the vtufile to write to */ - vtufile = fopen (vtufilename, "w"); - if (vtufile == NULL) { - t8_errorf ("Error when opening file %s\n", vtufilename); - goto t8_forest_vtk_failure; - } - /* Write the header information in the .vtu file. - * xml type, Unstructured grid and number of points and elements. */ - freturn = fprintf (vtufile, "\n"); - if (freturn <= 0) { - goto t8_forest_vtk_failure; - } - freturn = fprintf (vtufile, "\n"); -#else - freturn = fprintf (vtufile, " byte_order=\"LittleEndian\">\n"); -#endif - if (freturn <= 0) { - goto t8_forest_vtk_failure; - } - freturn = fprintf (vtufile, " \n"); - if (freturn <= 0) { - goto t8_forest_vtk_failure; - } - freturn = fprintf (vtufile, " \n", (long long) num_points, - (long long) num_elements); - if (freturn <= 0) { - goto t8_forest_vtk_failure; - } - /* write the point data */ - if (!t8_forest_vtk_write_points (forest, vtufile, write_ghosts, num_data, data)) { - /* writings points was not successful */ - goto t8_forest_vtk_failure; - } - /* write the cell data */ - if (!t8_forest_vtk_write_cells (forest, vtufile, write_treeid, write_mpirank, write_level, write_element_id, - write_ghosts, num_data, data)) { - /* Writing cells was not successful */ - goto t8_forest_vtk_failure; - } - - freturn = fprintf (vtufile, " \n" - " \n" - "\n"); - if (freturn <= 0) { - goto t8_forest_vtk_failure; - } - - freturn = fclose (vtufile); - /* We set it not NULL, even if fclose was not successful, since then any - * following call to fclose would result in undefined behaviour. */ - vtufile = NULL; - if (freturn != 0) { - /* Closing failed, this usually means that the final write operation could - * not be completed. */ - t8_global_errorf ("Error when closing file %s\n", vtufilename); - goto t8_forest_vtk_failure; - } - /* Writing was successful */ - return 1; -t8_forest_vtk_failure: - if (vtufile != NULL) { - fclose (vtufile); - } - t8_errorf ("Error when writing vtk file.\n"); - return 0; -} - T8_EXTERN_C_END (); diff --git a/src/t8_forest/t8_forest_vtk.h b/src/t8_forest/t8_forest_vtk.h index 5a3fdd225f..3a4e7cd891 100644 --- a/src/t8_forest/t8_forest_vtk.h +++ b/src/t8_forest/t8_forest_vtk.h @@ -39,66 +39,6 @@ T8_EXTERN_C_BEGIN (); /* function declarations */ -#if T8_WITH_VTK -void -t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, vtkSmartPointer unstructuredGrid, - const int write_treeid, const int write_mpirank, const int write_level, - const int write_element_id, const int write_ghosts, 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] write_ghosts If true, write out ghost elements as well. - * \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 write_ghosts, 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 - * t8code is not configure with "--with-vtk" and - * \ref t8_forest_vtk_write_file_via_API is not available. - * \param [in] forest The forest. - * \param [in] fileprefix The prefix of the output files. - * \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] 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 used 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). - */ -int -t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, - const int write_level, const int write_element_id, int write_ghosts, const int num_data, - t8_vtk_data_field_t *data); - T8_EXTERN_C_END (); #endif /* !T8_FOREST_VTK_H */ diff --git a/src/t8_vtk/t8_vtk_writer.hxx b/src/t8_vtk/t8_vtk_writer.hxx index 92d5555d3c..e31196ea9f 100644 --- a/src/t8_vtk/t8_vtk_writer.hxx +++ b/src/t8_vtk/t8_vtk_writer.hxx @@ -30,13 +30,12 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include "t8_forest/t8_forest_types.h" #include "t8_vtk/t8_vtk_writer_helper.hxx" +#include "t8_vtk/t8_vtk_write_ASCII.hxx" #include #include #include #include -#include -#include #if T8_WITH_VTK #include @@ -600,16 +599,16 @@ template <> bool vtk_writer::write_ASCII (const t8_forest_t forest) { - return t8_forest_vtk_write_file (forest, this->fileprefix.c_str (), this->write_treeid, this->write_mpirank, - this->write_level, this->write_element_id, this->write_ghosts, this->num_data, - this->data); + return t8_forest_vtk_write_ASCII (forest, this->fileprefix.c_str (), this->write_treeid, this->write_mpirank, + this->write_level, this->write_element_id, this->write_ghosts, this->num_data, + this->data); } template <> bool vtk_writer::write_ASCII (const t8_cmesh_t forest) { - return t8_cmesh_vtk_write_file (forest, this->fileprefix.c_str ()); + return t8_cmesh_vtk_write_ASCII (forest, this->fileprefix.c_str ()); } #endif /* T8_VTK_WRITER_HXX */ \ No newline at end of file diff --git a/src/t8_vtk/t8_vtk_writer_c_interface.cxx b/src/t8_vtk/t8_vtk_writer_c_interface.cxx index 147a5fd941..8ba610da22 100644 --- a/src/t8_vtk/t8_vtk_writer_c_interface.cxx +++ b/src/t8_vtk/t8_vtk_writer_c_interface.cxx @@ -23,6 +23,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include +#include +#include T8_EXTERN_C_BEGIN (); @@ -32,7 +34,7 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, co const int curved_flag, const int write_ghosts, const int num_data, t8_vtk_data_field_t *data) { - vtk_writer writer (write_treeid, write_mpirank, write_element_id, write_ghosts, curved_flag, + vtk_writer writer (write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, curved_flag, std::string (fileprefix), num_data, data, t8_forest_get_mpicomm (forest)); return writer.write_with_API (forest); } @@ -42,7 +44,7 @@ t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, const int const int write_level, const int write_element_id, int write_ghosts, const int num_data, t8_vtk_data_field_t *data) { - vtk_writer writer (write_treeid, write_mpirank, write_element_id, write_ghosts, curved_flag, + vtk_writer writer (write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, false, std::string (fileprefix), num_data, data, t8_forest_get_mpicomm (forest)); return writer.write_ASCII (forest); } @@ -69,9 +71,9 @@ t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, vtkSmartPointer writer (write_treeid, write_mpirank, write_element_id, write_ghosts, curved_flag, - std::string (fileprefix), num_data, data, t8_forest_get_mpicomm (forest)); - writer.grid_to_vtkUnstructuredGrid(forest, unstructuredGrid); + vtk_writer writer (write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, curved_flag, + std::string (""), num_data, data, t8_forest_get_mpicomm (forest)); + writer.grid_to_vtkUnstructuredGrid (forest, unstructuredGrid); } #endif diff --git a/src/t8_vtk/t8_vtk_writer_c_interface.h b/src/t8_vtk/t8_vtk_writer_c_interface.h index c9aad539e9..720b191485 100644 --- a/src/t8_vtk/t8_vtk_writer_c_interface.h +++ b/src/t8_vtk/t8_vtk_writer_c_interface.h @@ -27,6 +27,11 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include +#if T8_WITH_VTK +#include +#endif +T8_EXTERN_C_BEGIN (); + /** 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 @@ -115,4 +120,6 @@ t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, vtkSmartPointer #include +#include #define T8_FOREST_VTK_QUADRATIC_ELEMENT_MAX_CORNERS 20 /** Lookup table for number of nodes for curved eclasses. */ diff --git a/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_cad.cxx b/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_cad.cxx index d420e61048..ef2d465ac8 100644 --- a/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_cad.cxx +++ b/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_cad.cxx @@ -30,7 +30,8 @@ #include #include #include -#include +#include + #include #include #include @@ -48,7 +49,8 @@ #include #include #include -#include +#include + #include #endif diff --git a/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_lagrange.cxx b/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_lagrange.cxx index 121a599bc9..ce80a7538a 100644 --- a/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_lagrange.cxx +++ b/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_lagrange.cxx @@ -36,7 +36,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include -#include +#include + #include #include #include diff --git a/tutorials/general/t8_tutorial_build_cmesh.cxx b/tutorials/general/t8_tutorial_build_cmesh.cxx index d6606f0a3c..1f04db127e 100644 --- a/tutorials/general/t8_tutorial_build_cmesh.cxx +++ b/tutorials/general/t8_tutorial_build_cmesh.cxx @@ -41,7 +41,7 @@ #include /* cmesh definition and basic interface. */ #include /* forest definition and basic interface. */ #include /* default refinement scheme. */ -#include /* write file in vtu file */ +#include /* write file in vtu file */ #include /* linear geometry of the cmesh */ T8_EXTERN_C_BEGIN (); From 21d49343d966fe36ccae32bfa3df899bdeb82e16 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 17 Jul 2024 17:32:09 +0200 Subject: [PATCH 16/87] Remove old files --- src/Makefile.am | 4 +- src/t8_cmesh/t8_cmesh_vtk_writer.c | 21 - src/t8_cmesh_vtk_writer.h | 39 - .../t8_forest_to_vtkUnstructured.hxx | 26 - src/t8_forest/t8_forest_vtk.cxx | 66 - src/t8_forest/t8_forest_vtk.h | 44 - src/t8_vtk/t8_vtk_write_ASCII.cxx | 1174 +++++++++++++++++ src/t8_vtk/t8_vtk_write_ASCII.hxx | 57 + 8 files changed, 1232 insertions(+), 199 deletions(-) delete mode 100644 src/t8_cmesh/t8_cmesh_vtk_writer.c delete mode 100644 src/t8_cmesh_vtk_writer.h delete mode 100644 src/t8_forest/t8_forest_to_vtkUnstructured.hxx delete mode 100644 src/t8_forest/t8_forest_vtk.cxx delete mode 100644 src/t8_forest/t8_forest_vtk.h create mode 100644 src/t8_vtk/t8_vtk_write_ASCII.cxx create mode 100644 src/t8_vtk/t8_vtk_write_ASCII.hxx diff --git a/src/Makefile.am b/src/Makefile.am index 14cb234e9e..91bd7cd4aa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -53,8 +53,6 @@ libt8_installed_headers_forest = \ 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_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 \ @@ -140,7 +138,7 @@ libt8_compiled_sources = \ src/t8_geometry/t8_geometry_implementations/t8_geometry_zero.cxx \ src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx \ src/t8_forest/t8_forest_partition.cxx src/t8_forest/t8_forest.cxx \ - src/t8_forest/t8_forest_private.c src/t8_forest/t8_forest_vtk.cxx \ + src/t8_forest/t8_forest_private.c \ src/t8_forest/t8_forest_ghost.cxx src/t8_forest/t8_forest_iterate.cxx \ src/t8_version.c \ src/t8_vtk.c src/t8_forest/t8_forest_balance.cxx \ diff --git a/src/t8_cmesh/t8_cmesh_vtk_writer.c b/src/t8_cmesh/t8_cmesh_vtk_writer.c deleted file mode 100644 index fdb7d2e33d..0000000000 --- a/src/t8_cmesh/t8_cmesh_vtk_writer.c +++ /dev/null @@ -1,21 +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. -*/ diff --git a/src/t8_cmesh_vtk_writer.h b/src/t8_cmesh_vtk_writer.h deleted file mode 100644 index 5e73159f1a..0000000000 --- a/src/t8_cmesh_vtk_writer.h +++ /dev/null @@ -1,39 +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_cmesh_vtk.h - */ -/* TODO: document this file */ - -#ifndef T8_CMESH_VTK_H -#define T8_CMESH_VTK_H - -#include - -/* typedef and macros */ - -T8_EXTERN_C_BEGIN (); -/* function declarations */ - -T8_EXTERN_C_END (); - -#endif /* !T8_CMESH_VTK_H */ diff --git a/src/t8_forest/t8_forest_to_vtkUnstructured.hxx b/src/t8_forest/t8_forest_to_vtkUnstructured.hxx deleted file mode 100644 index 2ea42306a2..0000000000 --- a/src/t8_forest/t8_forest_to_vtkUnstructured.hxx +++ /dev/null @@ -1,26 +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. -*/ - -#ifndef T8_FOREST_VTK_UNSTRUCTURED_API_HXX -#define T8_FOREST_VTK_UNSTRUCTURED_API_HXX - -#endif /* T8_FOREST_VTK_UNSTRUCTURED_API_HXX */ diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx deleted file mode 100644 index de0fbd25bf..0000000000 --- a/src/t8_forest/t8_forest_vtk.cxx +++ /dev/null @@ -1,66 +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. -*/ - -#include -#include -#include -#include -#include -#include -#include "t8_forest_types.h" -#if T8_WITH_VTK -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if T8_ENABLE_MPI -#include -#include -#include -#endif -#endif -#include -#include -#include -#include - -/* We want to export the whole implementation to be callable from "C" */ -T8_EXTERN_C_BEGIN (); - -T8_EXTERN_C_END (); diff --git a/src/t8_forest/t8_forest_vtk.h b/src/t8_forest/t8_forest_vtk.h deleted file mode 100644 index 3a4e7cd891..0000000000 --- a/src/t8_forest/t8_forest_vtk.h +++ /dev/null @@ -1,44 +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_vtk.h - */ - -/* TODO: Document this file */ - -#ifndef T8_FOREST_VTK_H -#define T8_FOREST_VTK_H - -#include -#include -#include - -#if T8_WITH_VTK -#include -#endif - -T8_EXTERN_C_BEGIN (); -/* function declarations */ - -T8_EXTERN_C_END (); - -#endif /* !T8_FOREST_VTK_H */ diff --git a/src/t8_vtk/t8_vtk_write_ASCII.cxx b/src/t8_vtk/t8_vtk_write_ASCII.cxx new file mode 100644 index 0000000000..05359a4bd4 --- /dev/null +++ b/src/t8_vtk/t8_vtk_write_ASCII.cxx @@ -0,0 +1,1174 @@ +/* +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) 2024 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 "t8_vtk/t8_vtk_write_ASCII.hxx" +#include "t8_vtk/t8_vtk_writer_helper.hxx" +#include +#include +#include +#include +#include "t8_forest/t8_forest_types.h" +#include "t8_cmesh/t8_cmesh_trees.h" +#include "t8_cmesh/t8_cmesh_types.h" + +/* TODO: Currently we only use ASCII mode and no data compression. + * We also do not use sc_io to buffer our output stream. */ + +/* There are different cell data to write, e.g. connectivity, type, vertices, ... + * The structure is always the same: + * Iterate over the trees, + * iterate over the elements of that tree + * execute an element dependent part to write in the file. + * In order to simplify writing this code, we put all the parts that are + * repetitive in the function + * t8_forest_vtk_write_cell_data. + * This function accepts a callback function, which is then executed for + * each element. The callback function is defined below. + */ +/* TODO: As soon as we have element iterators we should restructure this concept + * appropriately. */ +typedef enum { T8_VTK_KERNEL_INIT, T8_VTK_KERNEL_EXECUTE, T8_VTK_KERNEL_CLEANUP } T8_VTK_KERNEL_MODUS; + +/** Callback function prototype for writing cell data. + * The function is executed for each element. + * The callback can run in three different modi: + * INIT - Called once, to (possibly) initialize the data pointer + * EXECUTE - Called for each element, the actual writing happens here. + * CLEANUP - Called once after all elements. Used to cleanup any memory + * allocated during INIT. + * \param [in] forest The forest. + * \param [in] ltree_id A local treeid. + * \param [in] tree The local tree of the forest with id \a ltree_id. + * \param [in] element_index An index of an element inside \a tree. + * \param [in] element A pointer to the current element. + * \param [in] ts The eclass scheme of the current element. + * \param [in] is_ghost Non-zero if the current element is a ghost element. + * In this cas \a tree is NULL. + * All ghost element will be traversed after all elements are + * \param [in,out] vtufile The open file stream to which we write the forest. + * \param [in,out] columns An integer counting the number of written columns. + * The callback should increase this value by the number + * of values written to the file. + * \param [in,out] data A pointer that the callback can modify at will. + * Between modi INIT and CLEANUP, \a data will not be + * modified outside of this callback. + * \param [in] modus The modus in which the callback is called. See above. + * \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, 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); + +static t8_locidx_t +t8_forest_num_points (t8_forest_t forest, const int count_ghosts) +{ + 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 */ + t8_tree_t tree = (t8_tree_t) t8_sc_array_index_locidx (forest->trees, itree); + /* Get the scheme of the current tree */ + 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); + } + } + if (count_ghosts) { + T8_ASSERT (forest->ghosts != NULL); + /* We also count the points of the ghost cells */ + 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 */ + 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); + } + } + } + return num_points; +} + +static int +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, const int is_ghost, FILE *vtufile, int *columns, + void **data, T8_VTK_KERNEL_MODUS modus) +{ + double element_coordinates[3]; + int num_el_vertices, ivertex; + int freturn; + t8_element_shape_t element_shape; + + if (modus != T8_VTK_KERNEL_EXECUTE) { + /* Nothing to do if we are in Init or clean up mode */ + return 1; + } + + /* TODO: be careful with pyramid class here. + * does this work too over tree->class or do we need something else? + */ + + element_shape = ts->t8_element_shape (element); + num_el_vertices = t8_eclass_num_vertices[element_shape]; + for (ivertex = 0; ivertex < num_el_vertices; ivertex++) { + const double *ref_coords = t8_forest_vtk_point_to_element_ref_coords[element_shape][ivertex]; + t8_forest_element_from_ref_coords (forest, ltree_id, element, ref_coords, 1, element_coordinates); + freturn = fprintf (vtufile, " "); + if (freturn <= 0) { + return 0; + } +#ifdef T8_VTK_DOUBLES + freturn = fprintf (vtufile, " %24.16e %24.16e %24.16e\n", element_coordinates[0], element_coordinates[1], + element_coordinates[2]); +#else + freturn = fprintf (vtufile, " %16.8e %16.8e %16.8e\n", element_coordinates[0], element_coordinates[1], + element_coordinates[2]); +#endif + if (freturn <= 0) { + return 0; + } + /* We switch of the column control of the surrounding function + * by keeping the columns value constant. */ + *columns = 1; + } + return 1; +} + +static int +t8_forest_vtk_cells_connectivity_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 ivertex, num_vertices; + int freturn; + t8_locidx_t *count_vertices; + t8_element_shape_t element_shape; + + if (modus == T8_VTK_KERNEL_INIT) { + /* We use data to count the number of written vertices */ + *data = T8_ALLOC_ZERO (t8_locidx_t, 1); + return 1; + } + else if (modus == T8_VTK_KERNEL_CLEANUP) { + T8_FREE (*data); + return 1; + } + T8_ASSERT (modus == T8_VTK_KERNEL_EXECUTE); + + count_vertices = (t8_locidx_t *) *data; + 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); + if (freturn <= 0) { + return 0; + } + } + *columns += t8_eclass_num_vertices[element_shape]; + return 1; +} + +static int +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; + int num_vertices; + + if (modus == T8_VTK_KERNEL_INIT) { + *data = T8_ALLOC_ZERO (long long, 1); + return 1; + } + else if (modus == T8_VTK_KERNEL_CLEANUP) { + T8_FREE (*data); + return 1; + } + T8_ASSERT (modus == T8_VTK_KERNEL_EXECUTE); + + offset = (long long *) *data; + + num_vertices = t8_eclass_num_vertices[ts->t8_element_shape (element)]; + *offset += num_vertices; + freturn = fprintf (vtufile, " %lld", *offset); + if (freturn <= 0) { + return 0; + } + *columns += 1; + + return 1; +} + +static int +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) { + /* print the vtk type of the element */ + freturn = fprintf (vtufile, " %d", t8_eclass_vtk_type[ts->t8_element_shape (element)]); + if (freturn <= 0) { + return 0; + } + *columns += 1; + } + return 1; +} + +static int +t8_forest_vtk_cells_level_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) +{ + if (modus == T8_VTK_KERNEL_EXECUTE) { + fprintf (vtufile, "%i ", ts->t8_element_level (element)); + *columns += 1; + } + return 1; +} + +static int +t8_forest_vtk_cells_rank_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) +{ + if (modus == T8_VTK_KERNEL_EXECUTE) { + fprintf (vtufile, "%i ", forest->mpirank); + *columns += 1; + } + return 1; +} + +static int +t8_forest_vtk_cells_treeid_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) +{ + if (modus == T8_VTK_KERNEL_EXECUTE) { + long long tree_id; + if (is_ghost) { + /* For ghost elements we write -1 as the tree is */ + tree_id = -1; + } + else { + /* Otherwise the global tree id */ + tree_id = (long long) ltree_id + forest->first_local_tree; + } + fprintf (vtufile, "%lli ", tree_id); + *columns += 1; + } + return 1; +} + +static int +t8_forest_vtk_cells_elementid_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) +{ + if (modus == T8_VTK_KERNEL_EXECUTE) { + if (!is_ghost) { + fprintf (vtufile, "%lli ", + element_index + tree->elements_offset + (long long) t8_forest_get_first_local_element_id (forest)); + } + else { + fprintf (vtufile, "%lli ", (long long) -1); + } + *columns += 1; + } + return 1; +} + +static int +t8_forest_vtk_cells_scalar_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) +{ + double element_value = 0; + t8_locidx_t scalar_index; + + if (modus == T8_VTK_KERNEL_EXECUTE) { + /* For local elements access the data array, for ghosts, write 0 */ + if (!is_ghost) { + scalar_index = t8_forest_get_tree_element_offset (forest, ltree_id) + element_index; + element_value = ((double *) *data)[scalar_index]; + } + else { + element_value = 0; + } + fprintf (vtufile, "%g ", element_value); + *columns += 1; + } + return 1; +} + +static int +t8_forest_vtk_cells_vector_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) +{ + double *element_values, null_vec[3] = { 0, 0, 0 }; + int dim, idim; + t8_locidx_t tree_offset; + + if (modus == T8_VTK_KERNEL_EXECUTE) { + dim = 3; + T8_ASSERT (forest->dimension <= 3); + /* For local elements access the data array, for ghosts, write 0 */ + if (!is_ghost) { + tree_offset = t8_forest_get_tree_element_offset (forest, ltree_id); + /* Get a pointer to the start of the element's vector data */ + element_values = ((double *) *data) + (tree_offset + element_index) * dim; + } + else { + element_values = null_vec; + } + for (idim = 0; idim < dim; idim++) { + fprintf (vtufile, "%g ", element_values[idim]); + } + *columns += dim; + } + return 1; +} + +/* The point data version of the scalar kernel */ +static int +t8_forest_vtk_vertices_scalar_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) +{ + double element_value = 0; + int num_vertex, ivertex; + t8_locidx_t scalar_index; + + if (modus == T8_VTK_KERNEL_EXECUTE) { + num_vertex = ts->t8_element_num_corners (element); + + for (ivertex = 0; ivertex < num_vertex; ivertex++) { + /* For local elements access the data array, for ghosts, write 0 */ + if (!is_ghost) { + scalar_index = t8_forest_get_tree_element_offset (forest, ltree_id) + element_index; + element_value = ((double *) *data)[scalar_index]; + } + else { + element_value = 0; + } + fprintf (vtufile, "%g ", element_value); + *columns += 1; + } + } + return 1; +} + +/* The point data version of the vector kernel */ +static int +t8_forest_vtk_vertices_vector_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) +{ + double *element_values, null_vec[3] = { 0, 0, 0 }; + int dim, idim; + int num_vertex, ivertex; + t8_locidx_t tree_offset; + + if (modus == T8_VTK_KERNEL_EXECUTE) { + num_vertex = ts->t8_element_num_corners (element); + for (ivertex = 0; ivertex < num_vertex; ivertex++) { + dim = 3; + T8_ASSERT (forest->dimension <= 3); + /* For local elements access the data array, for ghosts, write 0 */ + if (!is_ghost) { + tree_offset = t8_forest_get_tree_element_offset (forest, ltree_id); + /* Get a pointer to the start of the element's vector data */ + element_values = ((double *) *data) + (tree_offset + element_index) * dim; + } + else { + element_values = null_vec; + } + for (idim = 0; idim < dim; idim++) { + fprintf (vtufile, "%g ", element_values[idim]); + } + *columns += dim; + } + } + return 1; +} + +/* Iterate over all cells and write cell data to the file using + * the cell_data_kernel as callback */ +static int +t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *dataname, const char *datatype, + const char *component_string, const int max_columns, + t8_forest_vtk_cell_data_kernel kernel, const int write_ghosts, void *udata) +{ + int freturn; + int countcols; + t8_tree_t tree; + t8_locidx_t itree, ighost; + t8_locidx_t element_index, elems_in_tree; + t8_locidx_t num_local_trees, num_ghost_trees; + t8_element_t *element; + t8_eclass_scheme_c *ts; + void *data = NULL; + + /* Write the connectivity information. + * Thus for each tree we write the indices of its corner vertices. */ + freturn = fprintf (vtufile, + " \n ", + datatype, dataname, component_string); + if (freturn <= 0) { + return 0; + } + + /* if udata != NULL, use it as the data pointer, in this case, the kernel + * should not modify it */ + if (udata != NULL) { + data = udata; + } + + /* Call the kernel in initialization modus to possibly initialize the + * data pointer */ + kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_INIT); + /* We iterate over the trees and count each trees vertices, + * we add this to the already counted vertices and write it to the file */ + /* TODO: replace with an element iterator */ + num_local_trees = t8_forest_get_num_local_trees (forest); + for (itree = 0, countcols = 0; itree < num_local_trees; itree++) { + /* Get the tree that stores the elements */ + tree = t8_forest_get_tree (forest, itree); + /* Get the eclass scheme of the tree */ + ts = t8_forest_get_eclass_scheme (forest, t8_forest_get_tree_class (forest, itree)); + elems_in_tree = (t8_locidx_t) t8_element_array_get_count (&tree->elements); + for (element_index = 0; element_index < elems_in_tree; element_index++) { + /* Get a pointer to the element */ + element = t8_forest_get_element (forest, tree->elements_offset + element_index, NULL); + T8_ASSERT (element != NULL); + /* Execute the given callback on each element */ + if (!kernel (forest, itree, tree, element_index, element, ts, 0, vtufile, &countcols, &data, + T8_VTK_KERNEL_EXECUTE)) { + /* call the kernel in clean-up modus */ + kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + return 0; + } + /* After max_columns we break the line */ + if (!(countcols % max_columns)) { + freturn = fprintf (vtufile, "\n "); + if (freturn <= 0) { + /* call the kernel in clean-up modus */ + kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + return 0; + } + } + } /* element loop ends here */ + if (freturn <= 0) { + /* call the kernel in clean-up modus */ + kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + return 0; + } + } /* tree loop ends here */ + + if (write_ghosts) { + t8_locidx_t num_ghosts_in_tree; + /* Iterate over the ghost elements */ + /* TODO: replace with an element iterator */ + num_ghost_trees = t8_forest_ghost_num_trees (forest); + for (ighost = 0; ighost < num_ghost_trees; ighost++) { + /* Get the eclass scheme of the ghost tree */ + ts = t8_forest_get_eclass_scheme (forest, t8_forest_ghost_get_tree_class (forest, ighost)); + /* The number of ghosts in this tree */ + num_ghosts_in_tree = t8_forest_ghost_tree_num_elements (forest, ighost); + for (element_index = 0; element_index < num_ghosts_in_tree; element_index++) { + /* Get a pointer to the element */ + element = t8_forest_ghost_get_element (forest, ighost, element_index); + /* Execute the given callback on each element */ + if (!kernel (forest, ighost + num_local_trees, NULL, element_index, element, ts, 1, vtufile, &countcols, &data, + T8_VTK_KERNEL_EXECUTE)) { + /* call the kernel in clean-up modus */ + kernel (NULL, 0, NULL, 0, NULL, NULL, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + return 0; + } + /* After max_columns we break the line */ + if (!(countcols % max_columns)) { + freturn = fprintf (vtufile, "\n "); + if (freturn <= 0) { + /* call the kernel in clean-up modus */ + kernel (NULL, 0, NULL, 0, NULL, NULL, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + return 0; + } + } + } /* element loop ends here */ + if (freturn <= 0) { + /* call the kernel in clean-up modus */ + kernel (NULL, 0, NULL, 0, NULL, NULL, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + return 0; + } + } /* ghost loop ends here */ + } /* write_ghosts ends here */ + /* call the kernel in clean-up modus */ + kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + freturn = fprintf (vtufile, "\n \n"); + if (freturn <= 0) { + return 0; + } + + return 1; +} + +/* Write the cell data to an open file stream. + * Returns true on success and zero otherwise. + * After completion the file will remain open, whether writing + * cells was successful or not. */ +static int +t8_forest_vtk_write_cells (t8_forest_t forest, FILE *vtufile, 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; + int idata; + + T8_ASSERT (t8_forest_is_committed (forest)); + T8_ASSERT (vtufile != NULL); + + freturn = fprintf (vtufile, " \n"); + if (freturn <= 0) { + goto t8_forest_vtk_cell_failure; + } + + /* Write the connectivity information. + * Thus for each tree we write the indices of its corner vertices. */ + freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "connectivity", T8_VTK_LOCIDX, "", 8, + t8_forest_vtk_cells_connectivity_kernel, write_ghosts, NULL); + if (!freturn) { + goto t8_forest_vtk_cell_failure; + } + /* Done with writing the connectivity */ + + /* Write the offsets, that is for each tree the index of the first entry + * in the connectivity output that + * does not refer to a vertex of the tree anymore. + * For example if the trees are a square and a triangle, the offsets would + * be 4 and 7, since indices 0,1,2,3 refer to the vertices of the square + * and indices 4,5,6 to the indices of the triangle. */ + freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "offsets", T8_VTK_LOCIDX, "", 8, + t8_forest_vtk_cells_offset_kernel, write_ghosts, NULL); + if (!freturn) { + goto t8_forest_vtk_cell_failure; + } + /* Done with writing the offsets */ + + /* Write the element types. The type specifies the element class, thus + * square/triangle/tet etc. */ + + freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "types", "Int32", "", 8, t8_forest_vtk_cells_type_kernel, + write_ghosts, NULL); + + if (!freturn) { + goto t8_forest_vtk_cell_failure; + } + /* Done with writing the types */ + freturn = fprintf (vtufile, " \n"); + if (freturn <= 0) { + goto t8_forest_vtk_cell_failure; + } + /* clang-format off */ + freturn = fprintf (vtufile, " \n", "treeid,mpirank,level", + (write_element_id ? "id" : "")); + /* clang-format on */ + if (freturn <= 0) { + goto t8_forest_vtk_cell_failure; + } + + if (write_treeid) { + /* Write the tree ids. */ + + freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "treeid", T8_VTK_GLOIDX, "", 8, + t8_forest_vtk_cells_treeid_kernel, write_ghosts, NULL); + if (!freturn) { + goto t8_forest_vtk_cell_failure; + } + /* Done with writing the tree ids */ + } + if (write_mpirank) { + /* Write the mpiranks. */ + + freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "mpirank", "Int32", "", 8, + t8_forest_vtk_cells_rank_kernel, write_ghosts, NULL); + if (!freturn) { + goto t8_forest_vtk_cell_failure; + } + /* Done with writing the mpiranks */ + } + if (write_level) { + /* Write the element refinement levels. */ + + freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "level", "Int32", "", 8, t8_forest_vtk_cells_level_kernel, + write_ghosts, NULL); + if (!freturn) { + goto t8_forest_vtk_cell_failure; + } + /* Done with writing the levels */ + } + + if (write_element_id) { + /* Write the element ids. */ + const char *datatype; + + /* Use 32 bit ints if the global element count fits, 64 bit otherwise. */ + datatype = forest->global_num_elements > T8_LOCIDX_MAX ? T8_VTK_GLOIDX : T8_VTK_LOCIDX; + freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "element_id", datatype, "", 8, + t8_forest_vtk_cells_elementid_kernel, write_ghosts, NULL); + if (!freturn) { + goto t8_forest_vtk_cell_failure; + } + + /* Done with writing the element ids */ + } + /* Write the user defined data fields per element */ + for (idata = 0; idata < num_data; idata++) { + if (data[idata].type == T8_VTK_SCALAR) { + freturn = t8_forest_vtk_write_cell_data (forest, vtufile, data[idata].description, T8_VTK_FLOAT_NAME, "", 8, + t8_forest_vtk_cells_scalar_kernel, write_ghosts, data[idata].data); + } + else { + char component_string[BUFSIZ]; + T8_ASSERT (data[idata].type == T8_VTK_VECTOR); + snprintf (component_string, BUFSIZ, "NumberOfComponents=\"3\""); + freturn = t8_forest_vtk_write_cell_data (forest, vtufile, data[idata].description, T8_VTK_FLOAT_NAME, + component_string, 8 * forest->dimension, + t8_forest_vtk_cells_vector_kernel, write_ghosts, data[idata].data); + } + if (!freturn) { + goto t8_forest_vtk_cell_failure; + } + } + + freturn = fprintf (vtufile, " \n"); + if (freturn <= 0) { + goto t8_forest_vtk_cell_failure; + } + + /* Function completed successfully */ + return 1; +t8_forest_vtk_cell_failure: + /* Something went wrong */ + t8_errorf ("Error when writing cell data to forest vtk file.\n"); + return 0; +} + +/* Write the cell data to an open file stream. + * Returns true on success and zero otherwise. + * After completion the file will remain open, whether writing + * cells was successful or not. */ +static int +t8_forest_vtk_write_points (t8_forest_t forest, FILE *vtufile, const int write_ghosts, const int num_data, + t8_vtk_data_field_t *data) +{ + int freturn; + int sreturn; + int idata; + char description[BUFSIZ]; + + T8_ASSERT (t8_forest_is_committed (forest)); + T8_ASSERT (vtufile != NULL); + + /* Write the vertex coordinates */ + + freturn = fprintf (vtufile, " \n"); + if (freturn <= 0) { + goto t8_forest_vtk_cell_failure; + } + freturn = t8_forest_vtk_write_cell_data (forest, vtufile, "Position", T8_VTK_FLOAT_NAME, "NumberOfComponents=\"3\"", + 8, t8_forest_vtk_cells_vertices_kernel, write_ghosts, NULL); + if (!freturn) { + goto t8_forest_vtk_cell_failure; + } + freturn = fprintf (vtufile, " \n"); + if (freturn <= 0) { + goto t8_forest_vtk_cell_failure; + } + /* Done writing vertex coordinates */ + + /* Write the user defined data fields per element */ + if (num_data > 0) { + freturn = fprintf (vtufile, " \n"); + for (idata = 0; idata < num_data; idata++) { + if (data[idata].type == T8_VTK_SCALAR) { + /* Write the description string. */ + sreturn = snprintf (description, BUFSIZ, "%s_%s", data[idata].description, "points"); + + if (sreturn >= BUFSIZ) { + /* The output was truncated */ + t8_debugf ("Warning: Truncated vtk point data description to '%s'\n", description); + } + freturn = t8_forest_vtk_write_cell_data (forest, vtufile, description, T8_VTK_FLOAT_NAME, "", 8, + t8_forest_vtk_vertices_scalar_kernel, write_ghosts, data[idata].data); + } + else { + char component_string[BUFSIZ]; + T8_ASSERT (data[idata].type == T8_VTK_VECTOR); + snprintf (component_string, BUFSIZ, "NumberOfComponents=\"3\""); + /* Write the description string. */ + sreturn = snprintf (description, BUFSIZ, "%s_%s", data[idata].description, "points"); + + if (sreturn >= BUFSIZ) { + /* The output was truncated */ + /* Note: gcc >= 7.1 prints a warning if we + * do not check the return value of snprintf. */ + t8_debugf ("Warning: Truncated vtk point data description to '%s'\n", description); + } + + freturn = t8_forest_vtk_write_cell_data (forest, vtufile, description, T8_VTK_FLOAT_NAME, component_string, + 8 * forest->dimension, t8_forest_vtk_vertices_vector_kernel, + write_ghosts, data[idata].data); + } + if (!freturn) { + goto t8_forest_vtk_cell_failure; + } + } + freturn = fprintf (vtufile, " \n"); + } + /* Function completed successfully */ + return 1; +t8_forest_vtk_cell_failure: + /* Something went wrong */ + t8_errorf ("Error when writing cell data to forest vtk file.\n"); + return 0; +} + +int +t8_forest_vtk_write_ASCII (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, + const int write_level, const int write_element_id, int write_ghosts, const int num_data, + t8_vtk_data_field_t *data) +{ + FILE *vtufile = NULL; + t8_locidx_t num_elements, num_points; + char vtufilename[BUFSIZ]; + int freturn; + + T8_ASSERT (forest != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); + T8_ASSERT (fileprefix != NULL); + if (forest->ghosts == NULL || forest->ghosts->num_ghosts_elements == 0) { + /* Never write ghost elements if there aren't any */ + write_ghosts = 0; + } + T8_ASSERT (forest->ghosts != NULL || !write_ghosts); + + /* process 0 creates the .pvtu file */ + if (forest->mpirank == 0) { + if (t8_write_pvtu (fileprefix, forest->mpisize, write_treeid, write_mpirank, write_level, write_element_id, + num_data, data)) { + t8_errorf ("Error when writing file %s.pvtu\n", fileprefix); + goto t8_forest_vtk_failure; + } + } + + /* The local number of elements */ + num_elements = t8_forest_get_local_num_elements (forest); + if (write_ghosts) { + num_elements += t8_forest_get_num_ghosts (forest); + } + /* The local number of points, counted with multiplicity */ + num_points = t8_forest_num_points (forest, write_ghosts); + + /* The filename for this processes file */ + freturn = snprintf (vtufilename, BUFSIZ, "%s_%04d.vtu", fileprefix, forest->mpirank); + if (freturn >= BUFSIZ) { + t8_errorf ("Error when writing vtu file. Filename too long.\n"); + goto t8_forest_vtk_failure; + } + + /* Open the vtufile to write to */ + vtufile = fopen (vtufilename, "w"); + if (vtufile == NULL) { + t8_errorf ("Error when opening file %s\n", vtufilename); + goto t8_forest_vtk_failure; + } + /* Write the header information in the .vtu file. + * xml type, Unstructured grid and number of points and elements. */ + freturn = fprintf (vtufile, "\n"); + if (freturn <= 0) { + goto t8_forest_vtk_failure; + } + freturn = fprintf (vtufile, "\n"); +#else + freturn = fprintf (vtufile, " byte_order=\"LittleEndian\">\n"); +#endif + if (freturn <= 0) { + goto t8_forest_vtk_failure; + } + freturn = fprintf (vtufile, " \n"); + if (freturn <= 0) { + goto t8_forest_vtk_failure; + } + freturn = fprintf (vtufile, " \n", (long long) num_points, + (long long) num_elements); + if (freturn <= 0) { + goto t8_forest_vtk_failure; + } + /* write the point data */ + if (!t8_forest_vtk_write_points (forest, vtufile, write_ghosts, num_data, data)) { + /* writings points was not successful */ + goto t8_forest_vtk_failure; + } + /* write the cell data */ + if (!t8_forest_vtk_write_cells (forest, vtufile, write_treeid, write_mpirank, write_level, write_element_id, + write_ghosts, num_data, data)) { + /* Writing cells was not successful */ + goto t8_forest_vtk_failure; + } + + freturn = fprintf (vtufile, " \n" + " \n" + "\n"); + if (freturn <= 0) { + goto t8_forest_vtk_failure; + } + + freturn = fclose (vtufile); + /* We set it not NULL, even if fclose was not successful, since then any + * following call to fclose would result in undefined behaviour. */ + vtufile = NULL; + if (freturn != 0) { + /* Closing failed, this usually means that the final write operation could + * not be completed. */ + t8_global_errorf ("Error when closing file %s\n", vtufilename); + goto t8_forest_vtk_failure; + } + /* Writing was successful */ + return 1; +t8_forest_vtk_failure: + if (vtufile != NULL) { + fclose (vtufile); + } + t8_errorf ("Error when writing vtk file.\n"); + return 0; +} + +/* Return the local number of vertices in a cmesh. + * \param [in] cmesh The cmesh to be considered. + * \param [in] count_ghosts If true, we also count the vertices of the ghost trees. + * \return The number of vertices associated to \a cmesh. + * \a cmesh must be committed before calling this function. + */ +static t8_gloidx_t +t8_cmesh_get_num_vertices (const t8_cmesh_t cmesh, const int count_ghosts) +{ + int iclass; + t8_eclass_t ghost_class; + t8_gloidx_t num_vertices = 0; + t8_locidx_t ighost; + T8_ASSERT (cmesh != NULL); + T8_ASSERT (cmesh->committed); + + for (iclass = T8_ECLASS_ZERO; iclass < T8_ECLASS_COUNT; iclass++) { + num_vertices += t8_eclass_num_vertices[iclass] * cmesh->num_local_trees_per_eclass[iclass]; + } + if (count_ghosts) { + /* Also count the vertices of the ghost trees */ + for (ighost = 0; ighost < t8_cmesh_get_num_ghosts (cmesh); ighost++) { + ghost_class = t8_cmesh_get_ghost_class (cmesh, ighost); + num_vertices += t8_eclass_num_vertices[ghost_class]; + } + } + + return num_vertices; +} + +static int +t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, const int write_ghosts) +{ + T8_ASSERT (cmesh != NULL); + T8_ASSERT (t8_cmesh_is_committed (cmesh)); + T8_ASSERT (fileprefix != NULL); + + if (cmesh->mpirank == 0) { + /* Write the pvtu header file. */ + int num_ranks_that_write = cmesh->set_partition ? cmesh->mpisize : 1; + if (t8_write_pvtu (fileprefix, num_ranks_that_write, 1, 1, 0, 0, 0, NULL)) { + SC_ABORTF ("Error when writing file %s.pvtu\n", fileprefix); + } + } + /* If the cmesh is replicated only rank 0 prints it, + * otherwise each process prints its part of the cmesh.*/ + if (cmesh->mpirank == 0 || cmesh->set_partition) { + char vtufilename[BUFSIZ]; + FILE *vtufile; + t8_locidx_t num_vertices, ivertex; + t8_locidx_t num_trees; + t8_ctree_t tree; + double x, y, z; + double *vertices, *vertex; + int k, sk; + long long offset, count_vertices; + t8_locidx_t ighost, num_ghosts = 0, num_loc_trees; +#ifdef T8_ENABLE_DEBUG + t8_cghost_t ghost; +#endif + t8_eclass_t eclass; + + num_vertices = t8_cmesh_get_num_vertices (cmesh, write_ghosts); + num_trees = t8_cmesh_get_num_local_trees (cmesh); + if (write_ghosts) { + num_trees += t8_cmesh_get_num_ghosts (cmesh); + } + + snprintf (vtufilename, BUFSIZ, "%s_%04d.vtu", fileprefix, cmesh->mpirank); + vtufile = fopen (vtufilename, "wb"); + if (vtufile == NULL) { + t8_global_errorf ("Could not open file %s for output.\n", vtufilename); + return -1; + } + fprintf (vtufile, "\n"); + fprintf (vtufile, "\n"); +#else + fprintf (vtufile, " byte_order=\"LittleEndian\">\n"); +#endif + fprintf (vtufile, " \n"); + fprintf (vtufile, " \n", (long long) num_vertices, + (long long) num_trees); + fprintf (vtufile, " \n"); + + /* write point position data */ + fprintf (vtufile, + " \n", + T8_VTK_FLOAT_NAME, T8_VTK_FORMAT_STRING); + + for (tree = t8_cmesh_get_first_tree (cmesh); tree != NULL; tree = t8_cmesh_get_next_tree (cmesh, tree)) { + /* TODO: Use new geometry here. Need cmesh_get_reference coords function. */ + vertices = t8_cmesh_get_tree_vertices (cmesh, tree->treeid); + for (ivertex = 0; ivertex < t8_eclass_num_vertices[tree->eclass]; ivertex++) { + vertex = vertices + 3 * t8_eclass_t8_to_vtk_corner_number[tree->eclass][ivertex]; + x = vertex[0]; + y = vertex[1]; + z = vertex[2]; +#ifdef T8_VTK_DOUBLES + fprintf (vtufile, " %24.16e %24.16e %24.16e\n", x, y, z); +#else + fprintf (vtufile, " %16.8e %16.8e %16.8e\n", x, y, z); +#endif + } + } /* end tree loop */ + if (write_ghosts) { + + /* Write the vertices of the ghost trees */ + num_ghosts = t8_cmesh_get_num_ghosts (cmesh); + num_loc_trees = t8_cmesh_get_num_local_trees (cmesh); + for (ighost = 0; ighost < num_ghosts; ighost++) { + /* Get the eclass of this ghost */ + eclass = t8_cmesh_get_ghost_class (cmesh, ighost); + /* Get a pointer to this ghosts vertices */ + vertices = (double *) t8_cmesh_get_attribute (cmesh, t8_get_package_id (), 0, ighost + num_loc_trees); + T8_ASSERT (vertices != NULL); + /* TODO: This code is duplicated above */ + for (ivertex = 0; ivertex < t8_eclass_num_vertices[eclass]; ivertex++) { + vertex = vertices + 3 * t8_eclass_vtk_to_t8_corner_number[eclass][ivertex]; + x = vertex[0]; + y = vertex[1]; + z = vertex[2]; +#ifdef T8_VTK_DOUBLES + fprintf (vtufile, " %24.16e %24.16e %24.16e\n", x, y, z); +#else + fprintf (vtufile, " %16.8e %16.8e %16.8e\n", x, y, z); +#endif + } + } /* end ghost loop */ + } + fprintf (vtufile, " \n"); + fprintf (vtufile, " \n"); + fprintf (vtufile, " \n"); + + /* write connectivity data */ + fprintf (vtufile, + " \n", + T8_VTK_LOCIDX, T8_VTK_FORMAT_STRING); + for (tree = t8_cmesh_get_first_tree (cmesh), count_vertices = 0; tree != NULL; + tree = t8_cmesh_get_next_tree (cmesh, tree)) { + fprintf (vtufile, " "); + for (k = 0; k < t8_eclass_num_vertices[tree->eclass]; ++k, count_vertices++) { + fprintf (vtufile, " %lld", count_vertices); + } + fprintf (vtufile, "\n"); + } + if (write_ghosts) { + /* Write the ghost connectivity */ + for (ighost = 0; ighost < num_ghosts; ighost++) { + eclass = t8_cmesh_get_ghost_class (cmesh, ighost); + fprintf (vtufile, " "); + for (k = 0; k < t8_eclass_num_vertices[eclass]; ++k, count_vertices++) { + fprintf (vtufile, " %lld", count_vertices); + } + fprintf (vtufile, "\n"); + } + } + fprintf (vtufile, " \n"); + + /* write offset data */ + fprintf (vtufile, + " \n", + T8_VTK_LOCIDX, T8_VTK_FORMAT_STRING); + fprintf (vtufile, " "); + for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1, offset = 0; tree != NULL; + tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { + offset += t8_eclass_num_vertices[tree->eclass]; + fprintf (vtufile, " %lld", offset); + if (!(sk % 8)) + fprintf (vtufile, "\n "); + } + if (write_ghosts) { + /* ghost offset data */ + for (ighost = 0; ighost < num_ghosts; ighost++, ++sk) { + eclass = t8_cmesh_get_ghost_class (cmesh, ighost); + offset += t8_eclass_num_vertices[eclass]; + fprintf (vtufile, " %lld", offset); + if (!(sk % 8)) + fprintf (vtufile, "\n "); + } + } + fprintf (vtufile, "\n"); + fprintf (vtufile, " \n"); + /* write type data */ + fprintf (vtufile, + " \n", + T8_VTK_FORMAT_STRING); + fprintf (vtufile, " "); + for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1; tree != NULL; + tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { + fprintf (vtufile, " %d", t8_eclass_vtk_type[tree->eclass]); + if (!(sk % 20) && tree->treeid != (cmesh->num_local_trees - 1)) + fprintf (vtufile, "\n "); + } + if (write_ghosts) { + /* ghost offset types */ + for (ighost = 0; ighost < num_ghosts; ighost++, ++sk) { + eclass = t8_cmesh_get_ghost_class (cmesh, ighost); + fprintf (vtufile, " %d", t8_eclass_vtk_type[eclass]); + if (!(sk % 20) && ighost != (num_ghosts - 1)) + fprintf (vtufile, "\n "); + } + } + fprintf (vtufile, "\n"); + fprintf (vtufile, " \n"); + fprintf (vtufile, " \n"); + /* write treeif data */ + fprintf (vtufile, " \n"); + fprintf (vtufile, + " \n", + T8_VTK_GLOIDX, T8_VTK_FORMAT_STRING); + fprintf (vtufile, " "); + for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1, offset = 0; tree != NULL; + tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { + /* Since tree_id is actually 64 Bit but we store it as 32, we have to check + * that we do not get into conversion errors */ + /* TODO: We switched to 32 Bit because Paraview could not handle 64 well enough. + */ + T8_ASSERT (tree->treeid + cmesh->first_tree == (t8_gloidx_t) ((long) tree->treeid + cmesh->first_tree)); + fprintf (vtufile, " %ld", (long) tree->treeid + cmesh->first_tree); + if (!(sk % 8)) + fprintf (vtufile, "\n "); + } + if (write_ghosts) { + /* ghost offset types */ + for (ighost = 0; ighost < num_ghosts; ighost++, ++sk) { +#ifdef T8_ENABLE_DEBUG + ghost = t8_cmesh_trees_get_ghost (cmesh->trees, ighost); + /* Check for conversion errors */ + T8_ASSERT (ghost->treeid == (t8_gloidx_t) ((long) ghost->treeid)); +#endif + /* Write -1 as tree_id so that we can distinguish ghosts from normal trees + * in the vtk file */ + fprintf (vtufile, " %ld", (long) -1); + if (!(sk % 8)) + fprintf (vtufile, "\n "); + } + } + fprintf (vtufile, "\n"); + fprintf (vtufile, " \n"); + /* write mpirank data */ + fprintf (vtufile, + " \n", + "Int32", T8_VTK_FORMAT_STRING); + fprintf (vtufile, " "); + for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1, offset = 0; tree != NULL; + tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { + fprintf (vtufile, " %i", cmesh->mpirank); + if (!(sk % 8)) + fprintf (vtufile, "\n "); + } + if (write_ghosts) { + /* write our rank for each ghost */ + for (ighost = 0; ighost < num_ghosts; ighost++, ++sk) { + fprintf (vtufile, " %i", cmesh->mpirank); + if (!(sk % 8)) + fprintf (vtufile, "\n "); + } + } + fprintf (vtufile, "\n"); + fprintf (vtufile, " \n"); + fprintf (vtufile, " \n"); + /* write type data */ + fprintf (vtufile, " \n"); + fprintf (vtufile, " \n"); + fprintf (vtufile, "\n"); + fclose (vtufile); + } + return 0; +} + +int +t8_cmesh_vtk_write_ASCII (const t8_cmesh_t cmesh, const char *fileprefix) +{ + return t8_cmesh_vtk_write_file_ext (cmesh, fileprefix, 1); +} diff --git a/src/t8_vtk/t8_vtk_write_ASCII.hxx b/src/t8_vtk/t8_vtk_write_ASCII.hxx new file mode 100644 index 0000000000..009365ddb3 --- /dev/null +++ b/src/t8_vtk/t8_vtk_write_ASCII.hxx @@ -0,0 +1,57 @@ +/* +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) 2024 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_WRITE_ASCII_HXX +#define T8_VTK_WRITE_ASCII_HXX + +#include "t8_forest/t8_forest_types.h" +#include "t8_vtk.h" + +/** 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 + * t8code is not configure with "--with-vtk" and + * \ref t8_forest_vtk_write_file_via_API is not available. + * \param [in] forest The forest. + * \param [in] fileprefix The prefix of the output files. + * \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] 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 used 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). + */ +int +t8_forest_vtk_write_ASCII (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, + const int write_level, const int write_element_id, int write_ghosts, const int num_data, + t8_vtk_data_field_t *data); + +int +t8_cmesh_vtk_write_ASCII (t8_cmesh_t cmesh, const char *fileprefix); + +#endif /* T8_VTK_WRITE_ASCII_HXX */ \ No newline at end of file From 56eef4552da36ca506665e9013cd0b05096964ea Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 19 Jul 2024 11:35:51 +0200 Subject: [PATCH 17/87] update c_interface forgot some include errors in Makefile --- src/Makefile.am | 2 +- src/t8_vtk/t8_vtk_writer.hxx | 17 +---------------- src/t8_vtk/t8_vtk_writer_c_interface.cxx | 22 +++++++++++++--------- src/t8_vtk/t8_vtk_writer_c_interface.h | 4 ++++ test/t8_IO/t8_gtest_vtk_writer.cxx | 7 ++++--- 5 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 4a8515da16..2931818692 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -149,7 +149,7 @@ libt8_compiled_sources = \ src/t8_vtk/t8_vtk_unstructured.cxx \ src/t8_vtk/t8_vtk_parallel.cxx \ src/t8_vtk/t8_vtk_reader.cxx \ - src/t8_vtk/t8_vtk_writer_c_interface.ccc + src/t8_vtk/t8_vtk_writer_c_interface.cxx # this variable is used for headers that are not publicly installed diff --git a/src/t8_vtk/t8_vtk_writer.hxx b/src/t8_vtk/t8_vtk_writer.hxx index 77456b51c0..c1b025b634 100644 --- a/src/t8_vtk/t8_vtk_writer.hxx +++ b/src/t8_vtk/t8_vtk_writer.hxx @@ -79,18 +79,6 @@ class vtk_writer { * Construct a new vtk writer object. All parameters are set to false by default. By default no data is used and * \a num_data is set to zero. A default \a fileprefix is NOT given. * -<<<<<<< HEAD - * \param[in] write_treeid True, if we want to write the tree id of every element - * \param[in] write_mpirank True, if we want to write the mpirankof every element - * \param[in] write_level True, if we want to write the level of every element. Uses level 0 if used for a cmesh. - * \param[in] write_element_id True, if we want to write the element id of every element. Ignored if used for a cmesh. - * \param[in] write_ghosts True, if we want to write the ghost elements, too. - * \param[in] curved_flag True, if we want to use quadratic vtk cells. Uses the geometry of the grid to evaluate points between corners. - * \param[in] fileprefix The prefix of the output-file - * \param[in] num_data The number of data-fields to print - * \param[in] data The data to use - * \param[in] comm The communicator for parallel output -======= * \param write_treeid True, if we want to write the tree id of every element. * \param write_mpirank True, if we want to write the mpirankof every element. * \param write_level True, if we want to write the level of every element. Uses level 0 if used for a cmesh. @@ -101,7 +89,6 @@ class vtk_writer { * \param num_data The number of data-fields to print. * \param data The data to use. * \param comm The communicator for parallel output. ->>>>>>> more_const_cmesh_vtk_writer */ vtk_writer (const bool write_treeid, const bool write_mpirank, const bool write_level, const bool write_element_id, const bool write_ghosts, const bool curved_flag, std::string fileprefix, const int num_data, @@ -605,7 +592,7 @@ vtk_writer::t8_grid_tree_to_vtk_cells ( (*elem_id)++; return; } -#endif +#endif /* T8_VTK_WRITER_HXX */ template <> bool @@ -622,5 +609,3 @@ vtk_writer::write_ASCII (const t8_cmesh_t forest) { return t8_cmesh_vtk_write_file (forest, this->fileprefix.c_str ()); } - -#endif /* T8_VTK_WRITER_HXX */ \ No newline at end of file diff --git a/src/t8_vtk/t8_vtk_writer_c_interface.cxx b/src/t8_vtk/t8_vtk_writer_c_interface.cxx index 147a5fd941..cc2ba9040c 100644 --- a/src/t8_vtk/t8_vtk_writer_c_interface.cxx +++ b/src/t8_vtk/t8_vtk_writer_c_interface.cxx @@ -24,10 +24,14 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include +#if T8_WITH_VTK +#include +#endif + T8_EXTERN_C_BEGIN (); int -t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, const int write_treeid, +t8_forest_vtk_write_file_via_API (const 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 write_ghosts, const int num_data, t8_vtk_data_field_t *data) @@ -38,9 +42,9 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, co } int -t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, - const int write_level, const int write_element_id, int write_ghosts, const int num_data, - t8_vtk_data_field_t *data) +t8_forest_vtk_write_file (const t8_forest_t forest, const char *fileprefix, const int write_treeid, + const int write_mpirank, const int write_level, const int write_element_id, int write_ghosts, + const int num_data, t8_vtk_data_field_t *data) { vtk_writer writer (write_treeid, write_mpirank, write_element_id, write_ghosts, curved_flag, std::string (fileprefix), num_data, data, t8_forest_get_mpicomm (forest)); @@ -48,14 +52,14 @@ t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, const int } int -t8_cmesh_vtk_write_file_via_API (t8_cmesh_t cmesh, const char *fileprefix, sc_MPI_Comm comm) +t8_cmesh_vtk_write_file_via_API (const t8_cmesh_t cmesh, const char *fileprefix, sc_MPI_Comm comm) { vtk_writer writer (std::string (fileprefix), comm); return writer.write_with_API (cmesh); } int -t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix) +t8_cmesh_vtk_write_file (const t8_cmesh_t cmesh, const char *fileprefix) { /* No mpi Communicator is needed for ASCII output*/ vtk_writer writer (std::string (fileprefix), sc_MPI_COMM_NULL); @@ -64,14 +68,14 @@ t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix) #if T8_WITH_VTK void -t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, vtkSmartPointer unstructuredGrid, +t8_forest_to_vtkUnstructuredGrid (const t8_forest_t forest, vtkSmartPointer unstructuredGrid, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int write_ghosts, const int curved_flag, const int num_data, t8_vtk_data_field_t *data) { - vtk_writer writer (write_treeid, write_mpirank, write_element_id, write_ghosts, curved_flag, + vtk_writer writer (write_treeid, write_mpirank, write_element_id, write_ghosts, curved_flag, std::string (fileprefix), num_data, data, t8_forest_get_mpicomm (forest)); - writer.grid_to_vtkUnstructuredGrid(forest, unstructuredGrid); + writer.grid_to_vtkUnstructuredGrid (forest, unstructuredGrid); } #endif diff --git a/src/t8_vtk/t8_vtk_writer_c_interface.h b/src/t8_vtk/t8_vtk_writer_c_interface.h index c9aad539e9..06979bc1b3 100644 --- a/src/t8_vtk/t8_vtk_writer_c_interface.h +++ b/src/t8_vtk/t8_vtk_writer_c_interface.h @@ -27,6 +27,10 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include +#if T8_WITH_VTK +#include +#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 diff --git a/test/t8_IO/t8_gtest_vtk_writer.cxx b/test/t8_IO/t8_gtest_vtk_writer.cxx index 64fd36d95b..92f2a1aea7 100644 --- a/test/t8_IO/t8_gtest_vtk_writer.cxx +++ b/test/t8_IO/t8_gtest_vtk_writer.cxx @@ -26,6 +26,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include +#include + /** * Create a hybrid forest or a cmesh * @@ -109,12 +111,11 @@ TYPED_TEST_SUITE_P (vtk_writer_test); */ TYPED_TEST_P (vtk_writer_test, write_vtk) { - int success = this->writer->write (this->grid); #if T8_WITH_VTK - EXPECT_TRUE (success); + EXPECT_TRUE (this->writer->write_with_API (this->grid)); #else - EXPECT_FALSE (success); + EXPECT_TRUE (this->writer->write_ASCII (this->grid)); #endif } From 4da7c63a5910d35e404f291f5f861bf5c2a74783 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 19 Jul 2024 15:35:15 +0200 Subject: [PATCH 18/87] Move template specializations into seperate cxx file to avoid linker error Linker found multiple definitions --- src/CMakeLists.txt | 2 - src/Makefile.am | 2 +- src/t8_vtk/t8_vtk_writer.hxx | 95 ++-------------------- test/t8_IO/t8_gtest_vtk_writer.cxx | 81 +++++++++--------- test/t8_geometry/t8_gtest_point_inside.cxx | 1 - 5 files changed, 52 insertions(+), 129 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c1657b64a9..b2d2f11a84 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -86,7 +86,6 @@ target_sources( T8 PRIVATE t8_cmesh/t8_cmesh.cxx t8_cmesh/t8_cmesh_cad.cxx t8_cmesh/t8_cmesh_triangle.cxx - t8_cmesh/t8_cmesh_vtk_writer.c t8_cmesh/t8_cmesh_stash.c t8_cmesh/t8_cmesh_vtk_reader.cxx t8_cmesh/t8_cmesh_save.cxx @@ -178,7 +177,6 @@ install( FILES t8_cmesh_tetgen.h t8_cmesh_triangle.h t8_cmesh_vtk_reader.hxx - t8_cmesh_vtk_writer.h t8_eclass.h t8_element.h t8_element_c_interface.h diff --git a/src/Makefile.am b/src/Makefile.am index a000bf590b..b4b6c6e98d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,7 +26,6 @@ libt8_installed_headers = \ src/t8_element_c_interface.h \ src/t8_refcount.h src/t8_cmesh.hxx src/t8_cmesh.h src/t8_cmesh_triangle.h \ src/t8_cmesh_tetgen.h src/t8_cmesh_readmshfile.h \ - src/t8_cmesh_vtk_writer.h \ src/t8_cmesh_vtk_reader.hxx \ src/t8_vec.h \ src/t8_mat.h \ @@ -148,6 +147,7 @@ libt8_compiled_sources = \ src/t8_vtk/t8_vtk_unstructured.cxx \ src/t8_vtk/t8_vtk_parallel.cxx \ src/t8_vtk/t8_vtk_reader.cxx \ + src/t8_vtk/t8_vtk_writer.cxx \ src/t8_vtk/t8_vtk_writer_c_interface.cxx \ src/t8_vtk/t8_vtk_write_ASCII.cxx \ src/t8_vtk/t8_vtk_writer_helper.cxx diff --git a/src/t8_vtk/t8_vtk_writer.hxx b/src/t8_vtk/t8_vtk_writer.hxx index 761970defa..42024f58bd 100644 --- a/src/t8_vtk/t8_vtk_writer.hxx +++ b/src/t8_vtk/t8_vtk_writer.hxx @@ -63,8 +63,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include -#endif -#endif +#endif /* T8_ENABLE_MPI */ +#endif /* T8_WITH_VTK */ /** * A class that controls the writing of vtk files for cmeshes or forests. @@ -114,7 +114,7 @@ class vtk_writer { { this->t8_grid_to_vtkUnstructuredGrid (grid, unstructuredGrid); } -#endif +#endif /* T8_WITH_VTK */ /** * A vtk-writer function that uses the vtk API. @@ -419,8 +419,6 @@ class vtk_writer { } #endif /* T8_WITH_VTK */ -#endif - /** * Write a vtk file given a forest or a cmesh. * @@ -476,7 +474,7 @@ class vtk_writer { vtk_mpi_ctrl->SetCommunicator (vtk_comm); pwriterObj->SetController (vtk_mpi_ctrl); -#endif +#endif /* T8_ENABLE_MPI */ /* * We set the number of pieces as the number of mpi processes, * since we want to write a file for each process. We also @@ -512,9 +510,9 @@ class vtk_writer { return false; #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 false; + 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 false; #endif } @@ -530,81 +528,4 @@ class vtk_writer { sc_MPI_Comm comm; }; -#if T8_WITH_VTK -/** - * \brief template specialization for forests. - * - */ -template <> -void -vtk_writer::t8_grid_tree_to_vtk_cells ( - const t8_forest_t forest, vtkSmartPointer unstructuredGrid, - vtkSmartPointer vtk_treeid, vtkSmartPointer vtk_mpirank, - vtkSmartPointer vtk_level, vtkSmartPointer vtk_element_id, - vtkSmartPointer cellArray, vtkSmartPointer points, int *cellTypes, - const t8_locidx_t num_local_trees, t8_gloidx_t *elem_id, long int *point_id, const t8_gloidx_t offset, - const bool ghosts, const t8_locidx_t itree) -{ - /* For both ghosts and pure-local trees iterate over all elements and translate them into a vtk cell. */ - if (ghosts) { - const t8_locidx_t num_ghosts = t8_forest_ghost_tree_num_elements (forest, itree); - for (t8_locidx_t ielem_ghost = 0; ielem_ghost < num_ghosts; ielem_ghost++) { - const t8_element_t *element = t8_forest_ghost_get_element (forest, itree, ielem_ghost); - this->t8_grid_element_to_vtk_cell (forest, element, itree + num_local_trees, offset, true, *elem_id, point_id, - cellTypes, points, cellArray, vtk_treeid, vtk_mpirank, vtk_level, - vtk_element_id); - (*elem_id)++; - } - } - else { - const t8_locidx_t elems_in_tree = t8_forest_get_tree_num_elements (forest, itree); - /* We iterate over all elements in the tree */ - 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); - this->t8_grid_element_to_vtk_cell (forest, element, itree, offset, true, *elem_id, point_id, cellTypes, points, - cellArray, vtk_treeid, vtk_mpirank, vtk_level, vtk_element_id); - (*elem_id)++; - - } /* end of loop over elements */ - } - return; -} - -/** - * \brief template specialization for cmeshes. - * - */ -template <> -void -vtk_writer::t8_grid_tree_to_vtk_cells ( - const t8_cmesh_t cmesh, vtkSmartPointer unstructuredGrid, - vtkSmartPointer vtk_treeid, vtkSmartPointer vtk_mpirank, - vtkSmartPointer vtk_level, vtkSmartPointer vtk_element_id, - vtkSmartPointer cellArray, vtkSmartPointer points, int *cellTypes, - const t8_locidx_t num_local_trees, t8_gloidx_t *elem_id, long int *point_id, const t8_gloidx_t offset, - const bool ghosts, const t8_locidx_t itree) -{ - /* A cmesh does not have any further elements, we can call the translatore directly. */ - this->t8_grid_element_to_vtk_cell (cmesh, NULL, itree, offset, ghosts, *elem_id, point_id, cellTypes, points, - cellArray, vtk_treeid, vtk_mpirank, vtk_level, vtk_element_id); - (*elem_id)++; - return; -} -#endif /* T8_VTK_WRITER_HXX */ - -template <> -bool -vtk_writer::write_ASCII (const t8_forest_t forest) -{ - return t8_forest_vtk_write_ASCII (forest, this->fileprefix.c_str (), this->write_treeid, this->write_mpirank, - this->write_level, this->write_element_id, this->write_ghosts, this->num_data, - this->data); -} - -template <> -bool -vtk_writer::write_ASCII (const t8_cmesh_t forest) -{ - return t8_cmesh_vtk_write_ASCII (forest, this->fileprefix.c_str ()); -} +#endif /* T8_VTK_WRITER_HXX */ \ No newline at end of file diff --git a/test/t8_IO/t8_gtest_vtk_writer.cxx b/test/t8_IO/t8_gtest_vtk_writer.cxx index ed84659434..2582f93f12 100644 --- a/test/t8_IO/t8_gtest_vtk_writer.cxx +++ b/test/t8_IO/t8_gtest_vtk_writer.cxx @@ -77,6 +77,42 @@ destroy_grid (t8_forest_t *forest) t8_forest_unref (forest); } +template +int +use_c_interface (const grid_t grid, 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 write_ghosts, + const int num_data, t8_vtk_data_field_t *data, sc_MPI_Comm comm); + +template <> +int +use_c_interface (const t8_forest_t grid, 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 write_ghosts, const int num_data, + t8_vtk_data_field_t *data, sc_MPI_Comm comm) +{ +#if T8_WITH_VTK + return t8_forest_vtk_write_file_via_API (grid, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, + curved_flag, write_ghosts, num_data, data); +#else + return t8_forest_vtk_write_file (grid, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, + curved_flag, write_ghosts, num_data, data); +#endif +} + +template <> +int +use_c_interface (const t8_cmesh_t grid, 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 write_ghosts, const int num_data, + t8_vtk_data_field_t *data, sc_MPI_Comm comm) +{ +#if T8_WITH_VTK + return t8_cmesh_vtk_write_file_via_API (grid, fileprefix, comm); +#else + return t8_cmesh_vtk_write_file (grid, fileprefix); +#endif +} + /** * Templated class to test the vtk writer for forests and cmeshes. * @@ -93,6 +129,12 @@ class vtk_writer_test: public testing::Test { sc_MPI_COMM_WORLD); } + int + grid_c_interface () + { + return use_c_interface (grid, "test_vtk", 1, 1, 1, 1, 1, 1, 0, NULL, sc_MPI_COMM_WORLD); + } + void TearDown () override { @@ -111,7 +153,6 @@ TYPED_TEST_SUITE_P (vtk_writer_test); */ TYPED_TEST_P (vtk_writer_test, write_vtk) { - #if T8_WITH_VTK EXPECT_TRUE (this->writer->write_with_API (this->grid)); #else @@ -119,45 +160,9 @@ TYPED_TEST_P (vtk_writer_test, write_vtk) #endif } -template -int -use_c_interface (const grid_t grid, 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 write_ghosts, - const int num_data, t8_vtk_data_field_t *data, sc_MPI_Comm comm); - -template <> -int -use_c_interface (const t8_forest_t grid, 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 write_ghosts, const int num_data, - t8_vtk_data_field_t *data, sc_MPI_Comm comm) -{ -#if T8_WITH_VTK - return t8_forest_vtk_write_file_via_API (grid, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, - curved_flag, write_ghosts, num_data, data); -#else - return t8_forest_vtk_write_file (grid, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, - curved_flag, write_ghosts, num_data, data); -#endif -} - -template <> -int -use_c_interface (const t8_cmesh_t grid, 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 write_ghosts, const int num_data, - t8_vtk_data_field_t *data, sc_MPI_Comm comm) -{ -#if T8_WITH_VTK - return t8_cmesh_vtk_write_file_via_API (grid, fileprefix, comm); -#else - return t8_cmesh_vtk_write_file (grid, fileprefix); -#endif -} - TYPED_TEST_P (vtk_writer_test, c_interface) { - use_c_interface (this->grid, std::string ("test_vtk"), 1, 1, 1, 1, 1, 1, 0, NULL); + EXPECT_TRUE (this->grid_c_interface ()); } REGISTER_TYPED_TEST_SUITE_P (vtk_writer_test, write_vtk, c_interface); diff --git a/test/t8_geometry/t8_gtest_point_inside.cxx b/test/t8_geometry/t8_gtest_point_inside.cxx index c312c10a64..4cfbf7288d 100644 --- a/test/t8_geometry/t8_gtest_point_inside.cxx +++ b/test/t8_geometry/t8_gtest_point_inside.cxx @@ -34,7 +34,6 @@ #include #include #include -#include /* In this test we define a triangle in the x-y plane * and a point that lies in a triangle that is parallel From e26380cae059843e2eb42fd29b66c56cbede1f8e Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 19 Jul 2024 15:38:36 +0200 Subject: [PATCH 19/87] Give c-output different name --- test/t8_IO/t8_gtest_vtk_writer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/t8_IO/t8_gtest_vtk_writer.cxx b/test/t8_IO/t8_gtest_vtk_writer.cxx index 2582f93f12..9144280a03 100644 --- a/test/t8_IO/t8_gtest_vtk_writer.cxx +++ b/test/t8_IO/t8_gtest_vtk_writer.cxx @@ -132,7 +132,7 @@ class vtk_writer_test: public testing::Test { int grid_c_interface () { - return use_c_interface (grid, "test_vtk", 1, 1, 1, 1, 1, 1, 0, NULL, sc_MPI_COMM_WORLD); + return use_c_interface (grid, "test_vtk_c_interface", 1, 1, 1, 1, 1, 1, 0, NULL, sc_MPI_COMM_WORLD); } void From 674ddd50449faaf8ff7ba929810040dfa4451193 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 19 Jul 2024 15:53:36 +0200 Subject: [PATCH 20/87] Add files --- src/t8_vtk/t8_vtk_writer.cxx | 103 ++++++++++++++ src/t8_vtk/t8_vtk_writer_helper.cxx | 208 ++++++++++++++++++++++++++++ 2 files changed, 311 insertions(+) create mode 100644 src/t8_vtk/t8_vtk_writer.cxx create mode 100644 src/t8_vtk/t8_vtk_writer_helper.cxx diff --git a/src/t8_vtk/t8_vtk_writer.cxx b/src/t8_vtk/t8_vtk_writer.cxx new file mode 100644 index 0000000000..614a17549c --- /dev/null +++ b/src/t8_vtk/t8_vtk_writer.cxx @@ -0,0 +1,103 @@ +/* +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) 2024 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 + +#if T8_WITH_VTK +/** + * \brief template specialization for forests. + * + */ +template <> +void +vtk_writer::t8_grid_tree_to_vtk_cells ( + const t8_forest_t forest, vtkSmartPointer unstructuredGrid, + vtkSmartPointer vtk_treeid, vtkSmartPointer vtk_mpirank, + vtkSmartPointer vtk_level, vtkSmartPointer vtk_element_id, + vtkSmartPointer cellArray, vtkSmartPointer points, int *cellTypes, + const t8_locidx_t num_local_trees, t8_gloidx_t *elem_id, long int *point_id, const t8_gloidx_t offset, + const bool ghosts, const t8_locidx_t itree) +{ + /* For both ghosts and pure-local trees iterate over all elements and translate them into a vtk cell. */ + if (ghosts) { + const t8_locidx_t num_ghosts = t8_forest_ghost_tree_num_elements (forest, itree); + for (t8_locidx_t ielem_ghost = 0; ielem_ghost < num_ghosts; ielem_ghost++) { + const t8_element_t *element = t8_forest_ghost_get_element (forest, itree, ielem_ghost); + this->t8_grid_element_to_vtk_cell (forest, element, itree + num_local_trees, offset, true, *elem_id, point_id, + cellTypes, points, cellArray, vtk_treeid, vtk_mpirank, vtk_level, + vtk_element_id); + (*elem_id)++; + } + } + else { + const t8_locidx_t elems_in_tree = t8_forest_get_tree_num_elements (forest, itree); + /* We iterate over all elements in the tree */ + 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); + this->t8_grid_element_to_vtk_cell (forest, element, itree, offset, true, *elem_id, point_id, cellTypes, points, + cellArray, vtk_treeid, vtk_mpirank, vtk_level, vtk_element_id); + (*elem_id)++; + + } /* end of loop over elements */ + } + return; +} + +#endif /* T8_WITH_VTK */ + +/** + * \brief template specialization for cmeshes. + * + */ +template <> +void +vtk_writer::t8_grid_tree_to_vtk_cells ( + const t8_cmesh_t cmesh, vtkSmartPointer unstructuredGrid, + vtkSmartPointer vtk_treeid, vtkSmartPointer vtk_mpirank, + vtkSmartPointer vtk_level, vtkSmartPointer vtk_element_id, + vtkSmartPointer cellArray, vtkSmartPointer points, int *cellTypes, + const t8_locidx_t num_local_trees, t8_gloidx_t *elem_id, long int *point_id, const t8_gloidx_t offset, + const bool ghosts, const t8_locidx_t itree) +{ + /* A cmesh does not have any further elements, we can call the translatore directly. */ + this->t8_grid_element_to_vtk_cell (cmesh, NULL, itree, offset, ghosts, *elem_id, point_id, cellTypes, points, + cellArray, vtk_treeid, vtk_mpirank, vtk_level, vtk_element_id); + (*elem_id)++; + return; +} + +template <> +bool +vtk_writer::write_ASCII (const t8_forest_t forest) +{ + return t8_forest_vtk_write_ASCII (forest, this->fileprefix.c_str (), this->write_treeid, this->write_mpirank, + this->write_level, this->write_element_id, this->write_ghosts, this->num_data, + this->data); +} + +template <> +bool +vtk_writer::write_ASCII (const t8_cmesh_t forest) +{ + return t8_cmesh_vtk_write_ASCII (forest, this->fileprefix.c_str ()); +} \ No newline at end of file diff --git a/src/t8_vtk/t8_vtk_writer_helper.cxx b/src/t8_vtk/t8_vtk_writer_helper.cxx new file mode 100644 index 0000000000..b2491e1a3b --- /dev/null +++ b/src/t8_vtk/t8_vtk_writer_helper.cxx @@ -0,0 +1,208 @@ +/* +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) 2024 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 +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) { + return t8_curved_eclass_num_nodes[eclass]; + } + return t8_eclass_num_vertices[eclass]; +} + +void +t8_forest_vtk_get_element_nodes (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const int vertex, + const int curved_flag, double *out_coords) +{ + 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_element_ref_coords[element_shape][vertex]; + const int num_node = t8_get_number_of_vtk_nodes (element_shape, curved_flag); + t8_forest_element_from_ref_coords (forest, ltreeid, element, ref_coords, num_node, out_coords); +} + +template <> +t8_locidx_t +grid_local_num_elements (const t8_forest_t grid) +{ + return t8_forest_get_local_num_elements (grid); +} + +template <> +t8_locidx_t +grid_local_num_elements (const t8_cmesh_t grid) +{ + return t8_cmesh_get_num_local_trees (grid); +} + +template <> +t8_locidx_t +grid_local_num_trees (const t8_forest_t grid) +{ + return t8_forest_get_num_local_trees (grid); +} + +template <> +t8_locidx_t +grid_local_num_trees (const t8_cmesh_t grid) +{ + return t8_cmesh_get_num_local_trees (grid); +} + +template <> +t8_locidx_t +grid_local_num_ghost_trees (const t8_forest_t grid) +{ + return t8_forest_get_num_ghost_trees (grid); +} + +template <> +t8_locidx_t +grid_local_num_ghost_trees (const t8_cmesh_t grid) +{ + return t8_cmesh_get_num_ghosts (grid); +} + +template <> +t8_gloidx_t +grid_first_local_id (const t8_forest_t grid) +{ + return t8_forest_get_first_local_element_id (grid); +} + +template <> +t8_gloidx_t +grid_first_local_id (const t8_cmesh_t grid) +{ + return t8_cmesh_get_first_treeid (grid); +} + +template <> +t8_gloidx_t +tree_local_to_global_id (const t8_forest_t grid, t8_locidx_t ltree) +{ + return t8_forest_global_tree_id (grid, ltree); +} + +template <> +t8_gloidx_t +tree_local_to_global_id (const t8_cmesh_t grid, t8_locidx_t ltree) +{ + return t8_cmesh_get_global_id (grid, ltree); +} + +template <> +bool +grid_do_ghosts (const t8_forest_t grid, const int write_ghosts) +{ + bool ghosts = write_ghosts; + if (grid->ghosts == NULL || grid->ghosts->num_ghosts_elements == 0) { + /* Never write ghost elements if there aren't any */ + ghosts = false; + } + T8_ASSERT (grid->ghosts != NULL || !ghosts); + return ghosts; +} + +template <> +bool +grid_do_ghosts (const t8_cmesh_t grid, const int write_ghosts) +{ + bool ghosts = write_ghosts; + if (t8_cmesh_get_num_ghosts (grid) == 0) { + /* Never write ghost elements if there aren't any */ + ghosts = false; + } + return ghosts; +} + +template <> +t8_locidx_t +num_cells_to_write (const t8_forest_t grid, const int write_ghosts) +{ + return grid_local_num_elements (grid) + (write_ghosts ? t8_forest_get_num_ghost_trees (grid) : 0); +} + +template <> +t8_locidx_t +num_cells_to_write (const t8_cmesh_t grid, const int write_ghosts) +{ + return grid_local_num_elements (grid) + (write_ghosts ? t8_cmesh_get_num_ghosts (grid) : 0); +} + +template <> +t8_element_shape_t +grid_element_shape (const t8_forest_t grid, const t8_locidx_t itree, const t8_element_t *element) +{ + const t8_eclass_t eclass = t8_forest_get_eclass (grid, itree); + t8_eclass_scheme *scheme = t8_forest_get_eclass_scheme (grid, eclass); + return scheme->t8_element_shape (element); +} + +template <> +t8_element_shape_t +grid_element_shape (const t8_cmesh_t grid, const t8_locidx_t itree, const t8_element_t *element) +{ + return t8_cmesh_get_tree_class (grid, itree); +} + +template <> +void +grid_element_to_coords (const t8_forest_t grid, const t8_locidx_t itree, const t8_element_t *element, + const int curved_flag, double *coordinates, const int num_node, + const t8_element_shape_t shape) +{ + t8_forest_vtk_get_element_nodes (grid, itree, element, 0, curved_flag, coordinates); +} + +template <> +void +grid_element_to_coords (const t8_cmesh_t grid, const t8_locidx_t itree, const t8_element_t *element, + const int curved_flag, double *coordinates, const int num_node, + const t8_element_shape_t shape) +{ + const double *ref_coords = t8_forest_vtk_point_to_element_ref_coords[shape][curved_flag]; + const t8_gloidx_t gtree_id = t8_cmesh_get_global_id (grid, itree); + t8_geometry_evaluate (grid, gtree_id, ref_coords, num_node, coordinates); +} + +template <> +int +grid_element_level (const t8_forest_t grid, const t8_locidx_t itree, const t8_element_t *element) +{ + const t8_eclass_t eclass = t8_forest_get_eclass (grid, itree); + t8_eclass_scheme *scheme = t8_forest_get_eclass_scheme (grid, eclass); + return scheme->t8_element_level (element); +} +template <> +int +grid_element_level (const t8_cmesh_t grid, const t8_locidx_t itree, const t8_element_t *element) +{ + return 0; +} \ No newline at end of file From 67afb459c575efb84a0a2a1fe7f1c7a2b3fc63ae Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Fri, 26 Jul 2024 10:41:08 +0200 Subject: [PATCH 21/87] Update src/t8_cmesh/t8_cmesh_partition.cxx Co-authored-by: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> --- src/t8_cmesh/t8_cmesh_partition.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_partition.cxx b/src/t8_cmesh/t8_cmesh_partition.cxx index 956b37a7a8..8199a539cd 100644 --- a/src/t8_cmesh/t8_cmesh_partition.cxx +++ b/src/t8_cmesh/t8_cmesh_partition.cxx @@ -1443,8 +1443,8 @@ t8_cmesh_partition_given (const t8_cmesh_t cmesh, const t8_cmesh_t cmesh_from, c char **send_buffer = NULL, *my_buffer = NULL; int fs, ls; - int fr = 0; // is it a good default though? - int lr = 0; // to discuss before merging + int fr = 0; + int lr = 0; sc_MPI_Request *requests = NULL; t8_locidx_t num_ghosts, itree, num_trees; From dc3f4752509286b7268e023da81ca8e2c6347392 Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Fri, 26 Jul 2024 10:41:30 +0200 Subject: [PATCH 22/87] Update src/t8_cmesh/t8_cmesh_vtk_writer.c Co-authored-by: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> --- src/t8_cmesh/t8_cmesh_vtk_writer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_writer.c b/src/t8_cmesh/t8_cmesh_vtk_writer.c index e96b464223..29f45c41c0 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_writer.c +++ b/src/t8_cmesh/t8_cmesh_vtk_writer.c @@ -250,7 +250,8 @@ t8_cmesh_vtk_write_file_ext (t8_cmesh_t cmesh, const char *fileprefix, int write /* TODO: We switched to 32 Bit because Paraview could not handle 64 well enough. */ T8_ASSERT (tree->treeid + cmesh->first_tree == (t8_gloidx_t) ((long) tree->treeid + cmesh->first_tree)); - fprintf (vtufile, " %ld", (long)(tree->treeid + cmesh->first_tree)); + T8_ASSERT (tree->treeid + cmesh->first_tree == tree->treeid + (t8_locidx_t) cmesh->first_tree); + fprintf (vtufile, " %ld", tree->treeid + (t8_locidx_t) cmesh->first_tree); if (!(sk % 8)) fprintf (vtufile, "\n "); } From 0eea5c87c36f42da5423c674f5e558240cdddd38 Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 18:34:59 +0200 Subject: [PATCH 23/87] fix override warnings --- .../t8_geometry_analytic.hxx | 22 ++++++------- .../t8_geometry_zero.hxx | 22 ++++++------- .../t8_default_common/t8_default_common.hxx | 32 +++++++++---------- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_analytic.hxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_analytic.hxx index 53331b82d9..67011ff790 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_analytic.hxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_analytic.hxx @@ -70,7 +70,7 @@ struct t8_geometry_analytic: public t8_geometry * \return The type. */ inline t8_geometry_type_t - t8_geom_get_type () const + t8_geom_get_type () const override { return T8_GEOMETRY_TYPE_ANALYTIC; }; @@ -83,9 +83,9 @@ struct t8_geometry_analytic: public t8_geometry * \param [in] num_coords Amount of points of \f$ \mathrm{dim} \f$ to map. * \param [out] out_coords The mapped coordinates in physical space of \a ref_coords. The length is \a num_coords * 3. */ - virtual void + void t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, - double *out_coords) const; + double *out_coords) const override; /** * Compute the jacobian of the \a t8_geom_evaluate map at a point in the reference space \f$ [0,1]^\mathrm{dim} \f$. @@ -100,9 +100,9 @@ struct t8_geometry_analytic: public t8_geometry * dim 1: J = (0) dim 2: J = (0 1) dim 3: J = (0 1 0) * (0) (0 0) (0 0 1) */ - virtual void + void t8_geom_evaluate_jacobian (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, - double *jacobian) const; + double *jacobian) const override; /** * \param[in] forest The forest of the element. @@ -113,10 +113,10 @@ struct t8_geometry_analytic: public t8_geometry * \param[in, out] is_inside Array to fill with flags whether the point is inside or not * \param[in] tolerance Tolerance of the inside-check */ - virtual void + void t8_geom_point_batch_inside_element (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *points, const int num_points, int *is_inside, - const double tolerance) + const double tolerance) const override { SC_ABORTF ("Function not yet implemented"); } @@ -125,8 +125,8 @@ struct t8_geometry_analytic: public t8_geometry * Check if the currently active tree has a negative volume * \return True (non-zero) if the currently loaded tree has a negative volume. 0 otherwise. */ - virtual bool - t8_geom_tree_negative_volume () const; + bool + t8_geom_tree_negative_volume () const override; /** Update a possible internal data buffer for per tree data. * This function is called before the first coordinates in a new tree are @@ -135,8 +135,8 @@ struct t8_geometry_analytic: public t8_geometry * \param [in] cmesh The cmesh. * \param [in] gtreeid The global tree. */ - virtual void - t8_geom_load_tree_data (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); + void + t8_geom_load_tree_data (t8_cmesh_t cmesh, t8_gloidx_t gtreeid) override; inline const void * t8_geom_analytic_get_user_data () diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_zero.hxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_zero.hxx index 94b56ecb7c..24366040c5 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_zero.hxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_zero.hxx @@ -49,8 +49,8 @@ struct t8_geometry_zero: public t8_geometry * Check if the currently active tree has a negative volume * \return True (non-zero) if the currently loaded tree has a negative volume. 0 otherwise. */ - virtual bool - t8_geom_tree_negative_volume () const + bool + t8_geom_tree_negative_volume () const override { return 0; }; @@ -65,7 +65,7 @@ struct t8_geometry_zero: public t8_geometry * \return The type. */ inline t8_geometry_type_t - t8_geom_get_type () const + t8_geom_get_type () const override { return T8_GEOMETRY_TYPE_ZERO; }; @@ -79,9 +79,9 @@ struct t8_geometry_zero: public t8_geometry * \param [out] out_coords The mapped coordinates in physical space of \a ref_coords. The length is \a num_coords * 3. * \note All entries in out_coords will be set to 0. */ - virtual void + void t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, - double *out_coords) const; + double *out_coords) const override; /** * Compute the jacobian of the \a t8_geom_evaluate map at a point in the reference space \f$ [0,1]^\mathrm{dim} \f$. @@ -93,9 +93,9 @@ struct t8_geometry_zero: public t8_geometry * correspond to the \f$ i \f$-th column of the jacobian (Entry \f$ 3 \cdot i + j \f$ is \f$ \frac{\partial f_j}{\partial x_i} \f$). * \note All entries in \a jacobian will be set to zero. */ - virtual void + void t8_geom_evaluate_jacobian (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, - double *jacobian) const; + double *jacobian) const override; /** * \param[in] forest The forest of the element. @@ -106,10 +106,10 @@ struct t8_geometry_zero: public t8_geometry * \param[in, out] is_inside Array to fill with flags whether the point is inside or not * \param[in] tolerance Tolerance of the inside-check */ - virtual void + void t8_geom_point_batch_inside_element (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const double *points, const int num_points, int *is_inside, - const double tolerance) + const double tolerance) const override { const double zeros[3] = { 0 }; for (int i_point = 0; i_point < num_points; ++i_point) { @@ -125,8 +125,8 @@ struct t8_geometry_zero: public t8_geometry * \param [in] cmesh The cmesh. * \param [in] gtreeid The global tree. */ - virtual inline void - t8_geom_load_tree_data (t8_cmesh_t cmesh, t8_gloidx_t gtreeid); + inline void + t8_geom_load_tree_data (t8_cmesh_t cmesh, t8_gloidx_t gtreeid) override; }; #endif /* !T8_GEOMETRY_ZERO_HXX */ diff --git a/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx b/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx index 528840d8d0..e40861ca88 100644 --- a/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx +++ b/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx @@ -41,20 +41,20 @@ class t8_default_scheme_common_c: public t8_eclass_scheme_c { t8_element_deinit (int length, t8_element_t *elem) const override; /** Compute the number of corners of a given element. */ - virtual int - t8_element_num_corners (const t8_element_t *elem) const; + int + t8_element_num_corners (const t8_element_t *elem) const override; /** Allocate space for a bunch of elements. */ - virtual void - t8_element_new (int length, t8_element_t **elem) const; + void + t8_element_new (int length, t8_element_t **elem) const override; /** Deallocate space for a bunch of elements. */ - virtual void - t8_element_destroy (int length, t8_element_t **elem) const; + void + t8_element_destroy (int length, t8_element_t **elem) const override; /** Return the shape of an element */ - virtual t8_element_shape_t - t8_element_shape (const t8_element_t *elem) const; + t8_element_shape_t + t8_element_shape (const t8_element_t *elem) const override; /** Count how many leaf descendants of a given uniform level an element would produce. * \param [in] t The element to be checked. @@ -64,8 +64,8 @@ class t8_default_scheme_common_c: public t8_eclass_scheme_c { * Each default element (except pyramids) refines into 2^{dim * (level - level(t))} * children. */ - virtual t8_gloidx_t - t8_element_count_leaves (const t8_element_t *t, int level) const; + t8_gloidx_t + t8_element_count_leaves (const t8_element_t *t, int level) const override; /** Compute the number of siblings of an element. That is the number of * Children of its parent. @@ -73,16 +73,16 @@ class t8_default_scheme_common_c: public t8_eclass_scheme_c { * \return The number of siblings of \a element. * Note that this number is >= 1, since we count the element itself as a sibling. */ - virtual int - t8_element_num_siblings (const t8_element_t *elem) const; + int + t8_element_num_siblings (const t8_element_t *elem) const override; /** Count how many leaf descendants of a given uniform level the root element will produce. * \param [in] level A refinement level. * \return The value of \ref t8_element_count_leaves if the input element * is the root (level 0) element. */ - virtual t8_gloidx_t - t8_element_count_leaves_from_root (int level) const; + t8_gloidx_t + t8_element_count_leaves_from_root (int level) const override; /** Compute the integer coordinates of a given element vertex. * The default scheme implements the Morton type SFCs. In these SFCs the @@ -108,9 +108,9 @@ class t8_default_scheme_common_c: public t8_eclass_scheme_c { * \param [out] out_coords The coordinates of the points in the * reference space of the tree. */ - virtual void + void t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, - double *out_coords) const + double *out_coords) const override = 0; /** Get the integer coordinates of the anchor node of an element. From 37e24c124dfa94e3482c400a5f7427cf37856482 Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 18:42:51 +0200 Subject: [PATCH 24/87] fix cast errors --- src/t8_cmesh/t8_cmesh_geometry.cxx | 2 +- src/t8_cmesh/t8_cmesh_partition.cxx | 2 +- src/t8_cmesh/t8_cmesh_readmshfile.cxx | 4 ++-- src/t8_cmesh/t8_cmesh_triangle.cxx | 2 +- src/t8_cmesh/t8_cmesh_vtk_writer.c | 2 +- src/t8_geometry/t8_geometry_handler.cxx | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_geometry.cxx b/src/t8_cmesh/t8_cmesh_geometry.cxx index 1fd599ea88..68a15da36f 100644 --- a/src/t8_cmesh/t8_cmesh_geometry.cxx +++ b/src/t8_cmesh/t8_cmesh_geometry.cxx @@ -97,7 +97,7 @@ t8_cmesh_get_tree_geom_hash (const t8_cmesh_t cmesh, const t8_gloidx_t gtreeid) const size_t *hash = (const size_t *) t8_cmesh_get_attribute (cmesh, t8_get_package_id (), T8_CMESH_GEOMETRY_ATTRIBUTE_KEY, ltreeid); if (hash == nullptr) { - SC_ABORTF ("Could not find geometry for tree %ld.", gtreeid); + SC_ABORTF ("Could not find geometry for tree %ld.", static_cast(gtreeid)); } return *hash; } diff --git a/src/t8_cmesh/t8_cmesh_partition.cxx b/src/t8_cmesh/t8_cmesh_partition.cxx index 41f48c6638..4dc1bfbecd 100644 --- a/src/t8_cmesh/t8_cmesh_partition.cxx +++ b/src/t8_cmesh/t8_cmesh_partition.cxx @@ -389,7 +389,7 @@ t8_cmesh_partition_sendrange (const t8_cmesh_t cmesh, const t8_cmesh_t cmesh_fro ret--; } - t8_debugf ("%s_first = %i, %s_last = %i, last_tree = %li\n", "send", *send_first, "send", *send_last, ret); + t8_debugf ("%s_first = %i, %s_last = %i, last_tree = %li\n", "send", *send_first, "send", *send_last, static_cast(ret)); T8_ASSERT (*send_first >= 0); //TODO:reactivate T8_ASSERT (*send_last >= 0); diff --git a/src/t8_cmesh/t8_cmesh_readmshfile.cxx b/src/t8_cmesh/t8_cmesh_readmshfile.cxx index de8f05b34e..054ec0d919 100644 --- a/src/t8_cmesh/t8_cmesh_readmshfile.cxx +++ b/src/t8_cmesh/t8_cmesh_readmshfile.cxx @@ -634,7 +634,7 @@ t8_cmesh_msh_file_2_read_eles (t8_cmesh_t cmesh, FILE *fp, sc_hash_t *vertices, int switch_indices[4] = { 0 }; int iswitch; T8_ASSERT (t8_eclass_to_dimension[eclass] > 1); - t8_debugf ("Correcting negative volume of tree %li\n", tree_count); + t8_debugf ("Correcting negative volume of tree %li\n", static_cast(tree_count)); switch (eclass) { case T8_ECLASS_TRIANGLE: case T8_ECLASS_QUAD: @@ -973,7 +973,7 @@ t8_cmesh_msh_file_4_read_eles (t8_cmesh_t cmesh, FILE *fp, sc_hash_t *vertices, int switch_indices[4] = { 0 }; int iswitch; T8_ASSERT (t8_eclass_to_dimension[eclass] > 1); - t8_debugf ("Correcting negative volume of tree %li\n", tree_count); + t8_debugf ("Correcting negative volume of tree %li\n", static_cast(tree_count)); switch (eclass) { case T8_ECLASS_TRIANGLE: case T8_ECLASS_QUAD: diff --git a/src/t8_cmesh/t8_cmesh_triangle.cxx b/src/t8_cmesh/t8_cmesh_triangle.cxx index ba45711c1d..4651dd5c59 100644 --- a/src/t8_cmesh/t8_cmesh_triangle.cxx +++ b/src/t8_cmesh/t8_cmesh_triangle.cxx @@ -262,7 +262,7 @@ t8_cmesh_triangle_read_eles (t8_cmesh_t cmesh, int corner_offset, char *filename double temp; T8_ASSERT (dim == 3); - t8_debugf ("Correcting negative volume of tree %li\n", (long) triangle - triangle_offset); + t8_debugf ("Correcting negative volume of tree %li\n", static_cast(triangle - triangle_offset)); /* We switch vertex 0 and vertex 1 */ for (i = 0; i < 3; i++) { temp = tree_vertices[i]; diff --git a/src/t8_cmesh/t8_cmesh_vtk_writer.c b/src/t8_cmesh/t8_cmesh_vtk_writer.c index bed01ef3f4..4c9d5bc7fc 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_writer.c +++ b/src/t8_cmesh/t8_cmesh_vtk_writer.c @@ -250,7 +250,7 @@ t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, con /* TODO: We switched to 32 Bit because Paraview could not handle 64 well enough. */ T8_ASSERT (tree->treeid + cmesh->first_tree == (t8_gloidx_t) ((long) tree->treeid + cmesh->first_tree)); - fprintf (vtufile, " %ld", (long) tree->treeid + cmesh->first_tree); + fprintf (vtufile, " %ld", (long)(tree->treeid + cmesh->first_tree)); if (!(sk % 8)) fprintf (vtufile, "\n "); } diff --git a/src/t8_geometry/t8_geometry_handler.cxx b/src/t8_geometry/t8_geometry_handler.cxx index e22b55f2c1..a64fc47412 100644 --- a/src/t8_geometry/t8_geometry_handler.cxx +++ b/src/t8_geometry/t8_geometry_handler.cxx @@ -62,7 +62,7 @@ t8_geometry_handler::update_tree (t8_cmesh_t cmesh, t8_gloidx_t gtreeid) active_geometry = get_geometry (geom_hash); SC_CHECK_ABORTF (active_geometry != nullptr, "Could not find geometry with hash %zu or tree %ld has no registered geometry.", geom_hash, - gtreeid); + static_cast(gtreeid)); } /* Get the user data for this geometry and this tree. */ active_geometry->t8_geom_load_tree_data (cmesh, gtreeid); From 2ad40390cd120236440d6d29326991a74fd1318f Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 18:51:35 +0200 Subject: [PATCH 25/87] fix unitialized variables --- src/t8_cmesh/t8_cmesh_partition.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_partition.cxx b/src/t8_cmesh/t8_cmesh_partition.cxx index 4dc1bfbecd..d5fb3c31d0 100644 --- a/src/t8_cmesh/t8_cmesh_partition.cxx +++ b/src/t8_cmesh/t8_cmesh_partition.cxx @@ -1440,7 +1440,9 @@ t8_cmesh_partition_given (const t8_cmesh_t cmesh, const t8_cmesh_t cmesh_from, c size_t my_buffer_bytes = -1; char **send_buffer = NULL, *my_buffer = NULL; - int fs, ls, fr, lr; + int fs, ls; + int fr = 0; // is it a good default though? + int lr = 0; // to discuss before merging sc_MPI_Request *requests = NULL; t8_locidx_t num_ghosts, itree, num_trees; From 02b942135b484ee64c18570ce98173ed99638164 Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 18:54:54 +0200 Subject: [PATCH 26/87] fix potential out of bounds access --- src/t8_cmesh/t8_cmesh_readmshfile.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_readmshfile.cxx b/src/t8_cmesh/t8_cmesh_readmshfile.cxx index 054ec0d919..094e25622d 100644 --- a/src/t8_cmesh/t8_cmesh_readmshfile.cxx +++ b/src/t8_cmesh/t8_cmesh_readmshfile.cxx @@ -179,7 +179,7 @@ t8_cmesh_check_version_of_msh_file (FILE *fp) /* Search for the line starting with "$MeshFormat". */ while (!feof (fp) && strcmp (first_word, "$MeshFormat")) { (void) t8_cmesh_msh_read_next_line (&line, &linen, fp); - retval = sscanf (line, "%2048s", first_word); + retval = sscanf (line, "%2047s", first_word); /* Checking for read/write error */ if (retval != 1) { @@ -258,7 +258,7 @@ t8_msh_file_2_read_nodes (FILE *fp, t8_locidx_t *num_nodes, sc_mempool_t **node_ while (!feof (fp) && strcmp (first_word, "$Nodes")) { (void) t8_cmesh_msh_read_next_line (&line, &linen, fp); /* Get the first word of this line */ - retval = sscanf (line, "%2048s", first_word); + retval = sscanf (line, "%2047s", first_word); /* Checking for read/write error */ if (retval != 1) { @@ -358,7 +358,7 @@ t8_msh_file_4_read_nodes (FILE *fp, t8_locidx_t *num_nodes, sc_mempool_t **node_ while (!feof (fp) && strcmp (first_word, "$Nodes")) { (void) t8_cmesh_msh_read_next_line (&line, &linen, fp); /* Get the first word of this line */ - retval = sscanf (line, "%2048s", first_word); + retval = sscanf (line, "%2047s", first_word); /* Checking for read/write error */ if (retval != 1) { t8_global_errorf ("Premature end of line while reading nodes.\n"); @@ -524,7 +524,7 @@ t8_cmesh_msh_file_2_read_eles (t8_cmesh_t cmesh, FILE *fp, sc_hash_t *vertices, while (!feof (fp) && strcmp (first_word, "$Elements")) { (void) t8_cmesh_msh_read_next_line (&line, &linen, fp); /* Get the first word of this line */ - retval = sscanf (line, "%2048s", first_word); + retval = sscanf (line, "%2047s", first_word); /* Checking for read/write error */ if (retval != 1) { @@ -847,7 +847,7 @@ t8_cmesh_msh_file_4_read_eles (t8_cmesh_t cmesh, FILE *fp, sc_hash_t *vertices, while (!feof (fp) && strcmp (first_word, "$Elements")) { (void) t8_cmesh_msh_read_next_line (&line, &linen, fp); /* Get the first word of this line */ - retval = sscanf (line, "%2048s", first_word); + retval = sscanf (line, "%2047s", first_word); /* Checking for read/write error */ if (retval != 1) { From 627f9a721c92ae65747c66d77137be70852bb763 Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:12:05 +0200 Subject: [PATCH 27/87] fix unused variables --- src/t8_forest/t8_forest_partition.cxx | 4 +--- src/t8_forest/t8_forest_vtk.cxx | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/t8_forest/t8_forest_partition.cxx b/src/t8_forest/t8_forest_partition.cxx index 8826af7f3a..eb77317fa4 100644 --- a/src/t8_forest/t8_forest_partition.cxx +++ b/src/t8_forest/t8_forest_partition.cxx @@ -1044,7 +1044,7 @@ static void t8_forest_partition_recvloop (t8_forest_t forest, int recv_first, int recv_last, const int recv_data, sc_array_t *data_out, char *sent_to_self, size_t byte_to_self) { - int iproc, num_receive, prev_recvd; + int iproc, prev_recvd; t8_locidx_t last_received_local_element = 0; t8_forest_t forest_from; int mpiret; @@ -1064,7 +1064,6 @@ t8_forest_partition_recvloop (t8_forest_t forest, int recv_first, int recv_last, /* In order of their ranks, receive the trees and elements from the other processes. */ - num_receive = 0; prev_recvd = 0; if (!recv_data) { forest->local_num_elements = 0; @@ -1072,7 +1071,6 @@ t8_forest_partition_recvloop (t8_forest_t forest, int recv_first, int recv_last, for (iproc = recv_first; iproc <= recv_last; iproc++) { if (!t8_forest_partition_empty (offset_from, iproc)) { /* We receive from each nonempty rank between recv_first and recv_last */ - num_receive++; if (iproc != forest->mpirank) { /* Probe for the message */ mpiret = sc_MPI_Probe (iproc, T8_MPI_PARTITION_FOREST, comm, &status); diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index c97044ef88..7f726a72c0 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -114,10 +114,10 @@ typedef int (*t8_forest_vtk_cell_data_kernel) (t8_forest_t forest, const t8_loci #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 }; +[[maybe_unused]] 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 */ -const int t8_curved_eclass_vtk_type[T8_ECLASS_COUNT] = { 1, 21, 23, 22, 25, 24, 26, 27 }; +[[maybe_unused]] const int t8_curved_eclass_vtk_type[T8_ECLASS_COUNT] = { 1, 21, 23, 22, 25, 24, 26, 27 }; /** Map vtk element corners to element reference coordinates. The reference * coordinates are defined in such a way, that the linear vtk corners are listed From e159a714bcebd519ac827906f5a1668fb44eeb1f Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:16:59 +0200 Subject: [PATCH 28/87] fix dangling pointer --- src/t8_geometry/t8_geometry_base.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_geometry/t8_geometry_base.hxx b/src/t8_geometry/t8_geometry_base.hxx index df848cb2e3..43a7e01c43 100644 --- a/src/t8_geometry/t8_geometry_base.hxx +++ b/src/t8_geometry/t8_geometry_base.hxx @@ -156,7 +156,7 @@ struct t8_geometry * Get the name of this geometry. * \return The name. */ - inline const std::string + inline const std::string& t8_geom_get_name () const { return name; From 78213f66dfbef65d80f6c439a0b85c4f51605a42 Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:23:44 +0200 Subject: [PATCH 29/87] removed call to deprecated sprintf --- src/t8_cmesh/t8_cmesh_partition.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_partition.cxx b/src/t8_cmesh/t8_cmesh_partition.cxx index d5fb3c31d0..2e1ad65b27 100644 --- a/src/t8_cmesh/t8_cmesh_partition.cxx +++ b/src/t8_cmesh/t8_cmesh_partition.cxx @@ -1410,7 +1410,7 @@ t8_cmesh_partition_debug_listprocs (const t8_cmesh_t cmesh, const t8_cmesh_t cme } } t8_debugf ("I send to: %s\n", out); - sprintf (out, " "); + std::strcpy(out, " "); if (cmesh_from->set_partition) { for (p = 0; p < mpisize; p++) { if (t8_offset_sendsto (p, mpirank, from, to)) { From efa1b37e1cc737e9436b58aed9b1518332dd7fd2 Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:26:54 +0200 Subject: [PATCH 30/87] removed useless branch --- src/t8_forest/t8_forest_ghost.cxx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index f53b4806c7..ebdcde905b 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -595,11 +595,7 @@ t8_forest_ghost_search_boundary (t8_forest_t forest, t8_locidx_t ltreeid, const /* Store the new bounds at the entry for this element */ new_bounds[iface * 2] = lower; new_bounds[iface * 2 + 1] = upper; - if (lower == upper && lower == forest->mpirank) { - /* All neighbor leaves at this face are owned by the current rank */ - faces_totally_owned = faces_totally_owned && 1; - } - else { + if (lower != upper or lower != forest->mpirank) { faces_totally_owned = 0; } } From 87b36139afc65eee8569b08a1704ec095308aab3 Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:36:37 +0200 Subject: [PATCH 31/87] add missing include --- src/t8_cmesh/t8_cmesh_partition.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/t8_cmesh/t8_cmesh_partition.cxx b/src/t8_cmesh/t8_cmesh_partition.cxx index 2e1ad65b27..956b37a7a8 100644 --- a/src/t8_cmesh/t8_cmesh_partition.cxx +++ b/src/t8_cmesh/t8_cmesh_partition.cxx @@ -25,6 +25,8 @@ * TODO: document this file */ +#include + #include #include #include From 669debc5185eed5a935805b36084f3e5fe613ec4 Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:05:57 +0200 Subject: [PATCH 32/87] fix new warning --- src/t8_cmesh/t8_cmesh_vtk_writer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_writer.c b/src/t8_cmesh/t8_cmesh_vtk_writer.c index 22a4cfee13..1d38c47e16 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_writer.c +++ b/src/t8_cmesh/t8_cmesh_vtk_writer.c @@ -251,7 +251,7 @@ t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, con */ T8_ASSERT (tree->treeid + cmesh->first_tree == (t8_gloidx_t) ((long) tree->treeid + cmesh->first_tree)); T8_ASSERT (tree->treeid + cmesh->first_tree == tree->treeid + (t8_locidx_t) cmesh->first_tree); - fprintf (vtufile, " %ld", tree->treeid + (t8_locidx_t) cmesh->first_tree); + fprintf (vtufile, " %ld", (long)(tree->treeid + (t8_locidx_t) cmesh->first_tree)); if (!(sk % 8)) fprintf (vtufile, "\n "); } From f981d8c7b0b917b797b4a899f5b17c28ee056aef Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Fri, 26 Jul 2024 16:21:42 +0200 Subject: [PATCH 33/87] Refactored quadr./cubed sphere meshes. --- src/t8_cmesh/t8_cmesh_examples.cxx | 97 ++++++++++++- .../t8_geometry_examples.cxx | 129 ++++++++++++------ 2 files changed, 180 insertions(+), 46 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.cxx b/src/t8_cmesh/t8_cmesh_examples.cxx index 45260908cc..a579cea6b9 100644 --- a/src/t8_cmesh/t8_cmesh_examples.cxx +++ b/src/t8_cmesh/t8_cmesh_examples.cxx @@ -3319,12 +3319,101 @@ t8_cmesh_new_prismed_spherical_shell_octahedron (const double inner_radius, cons } t8_cmesh_t -t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shell_thickness, const int num_levels, +t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shell_thickness, const int num_trees, const int num_layers, sc_MPI_Comm comm) { - return t8_cmesh_new_spherical_shell (T8_ECLASS_HEX, new t8_geometry_cubed_spherical_shell (), - t8_cmesh_new_quadrangulated_spherical_surface, inner_radius, shell_thickness, - num_levels, num_layers, comm); + /* Initialization of the mesh */ + t8_cmesh_t cmesh; + t8_cmesh_init (&cmesh); + + t8_cmesh_register_geometry (cmesh); /* Use spherical geometry */ + + /* clang-format off */ + const int nrotas = t8_eclass_num_faces[T8_ECLASS_HEX]; /* Number of 3D cmesh elements resp. trees. */ + const int ntrees = nrotas * num_trees * num_trees * num_layers; /* Number of 3D cmesh elements resp. trees. */ + const int nverts = t8_eclass_num_vertices[T8_ECLASS_HEX]; /* Number of vertices per cmesh element. */ + + /* Arrays for the face connectivity computations via vertices. */ + double all_verts[ntrees * T8_ECLASS_MAX_CORNERS * T8_ECLASS_MAX_DIM]; + t8_eclass_t all_eclasses[ntrees]; + + /* Defitition of the tree class. */ + for (int itree = 0; itree < ntrees; itree++) { + t8_cmesh_set_tree_class (cmesh, itree, T8_ECLASS_HEX); + all_eclasses[itree] = T8_ECLASS_HEX; + } + + const double outer_radius = inner_radius + shell_thickness; + + const double _SQRT3 = 1.7320508075688772; + const double r = inner_radius / _SQRT3; + const double R = outer_radius / _SQRT3; + + // Vertices of the template hex. + const double vertices[nverts][3] = { + { -r, -r, r }, { r, -r, r }, { -r, r, r }, { r, r, r }, + { -R, -R, R }, { R, -R, R }, { -R, R, R }, { R, R, R } + }; + + const double angles[nrotas] = { 0.0 , 0.5 * M_PI, 0.5 * M_PI, M_PI, -0.5 * M_PI, -0.5 * M_PI }; + const int rot_axis[nrotas] = { 0, 0, 1, 1, 0, 1 }; + + const double h = 1.0 / num_layers; + const double w = 1.0 / num_trees; + const double l = 1.0 / num_trees; + + int itree = 0; + for (int irot = 0; irot < nrotas; irot++) { + + double rot_mat[3][3]; + + if (rot_axis[irot] == 0) { + t8_mat_init_xrot (rot_mat, angles[irot]); + } + else { + t8_mat_init_yrot (rot_mat, angles[irot]); + } + + for (int k = 0; k < num_layers; k++) { + for (int j = 0; j < num_trees; j++) { + for (int i = 0; i < num_trees; i++) { + const double I = i + 1; + const double J = j + 1; + const double K = k + 1; + double ref_coords[nverts][3] = { + { i*w, j*l, k*h }, { I*w, j*l, k*h }, { i*w, J*l, k*h }, { I*w, J*l, k*h }, + { i*w, j*l, K*h }, { I*w, j*l, K*h }, { i*w, J*l, K*h }, { I*w, J*l, K*h } + }; + + double tile_vertices[nverts][3]; + t8_geom_compute_linear_geometry (T8_ECLASS_HEX, (double *) vertices, (double *) ref_coords, nverts, (double *) tile_vertices); + + double rot_vertices[nverts][3]; + for (int ivert = 0; ivert < nverts; ivert++) { + t8_mat_mult_vec (rot_mat, &(tile_vertices[ivert][0]), &(rot_vertices[ivert][0])); + } + + t8_cmesh_set_tree_vertices (cmesh, itree, (double *) rot_vertices, nverts); + + for (int ivert = 0; ivert < nverts; ivert++) { + for (int icoord = 0; icoord < T8_ECLASS_MAX_DIM; icoord++) { + all_verts[T8_3D_TO_1D (ntrees, T8_ECLASS_MAX_CORNERS, T8_ECLASS_MAX_DIM, itree, ivert, icoord)] + = rot_vertices[ivert][icoord]; + } + } + + ++itree; + } + } + } + } + + /* Face connectivity. */ + t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, NULL, 0); + + /* Commit the mesh */ + t8_cmesh_commit (cmesh, comm); + return cmesh; } t8_cmesh_t diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx index f20da58850..46904bbf3d 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx @@ -264,32 +264,56 @@ t8_geometry_quadrangulated_spherical_surface::t8_geom_evaluate (t8_cmesh_t cmesh { double position[3]; /* Position vector in the element. */ + double normal[3]; /* Position vector in the element. */ + + double tangent1[3]; /* Position vector in the element. */ + double tangent2[3]; /* Position vector in the element. */ + + double origin[3]; + + const double _SQRT3 = 1.7320508075688772; + + t8_vec_tri_normal (active_tree_vertices, active_tree_vertices + 3, active_tree_vertices + 6, normal); + t8_vec_normalize (normal); + + const double R = std::abs(t8_vec_dot (active_tree_vertices, normal)); + + const double radius = R * _SQRT3; + + tangent1[0] = normal[1]; + tangent1[1] = normal[2]; + tangent1[2] = -normal[0]; + + t8_vec_axpy (normal, tangent1, -t8_vec_dot(normal, tangent1)); + t8_vec_cross (normal, tangent1, tangent2); + + t8_vec_normalize (tangent1); + t8_vec_normalize (tangent2); + + t8_vec_axy (normal, origin, R); + /* All elements are aligned such that the face normal follows the * outward radial direction of the sphere. */ - const double radius = t8_vec_norm (active_tree_vertices); - for (size_t i_coord = 0; i_coord < num_coords; i_coord++) { const size_t offset_2d = 2 * i_coord; const size_t offset_3d = 3 * i_coord; - double corr_ref_coords[3]; /* Corrected reference coordinates. */ + double local_pos[3]; + double out_pos[3]; + + t8_geom_linear_interpolation (ref_coords + offset_2d, active_tree_vertices, 3, 2, position); + t8_vec_diff (position, origin, local_pos); - /* Shorthand for code readability. `ref_coords` go from 0 to 1. */ - const double x = ref_coords[offset_2d + 0]; - const double y = ref_coords[offset_2d + 1]; + const double alpha1 = R * tan (0.25 * M_PI * t8_vec_dot (tangent1, local_pos) / R); + const double alpha2 = R * tan (0.25 * M_PI * t8_vec_dot (tangent2, local_pos) / R); - /* tldr: Correction in order to rectify elements near the corners. - * This is necessary, since due to the transformation from the unit cube - * to the sphere elements near the face centers expand while near the - * corners they shrink. Following correction alleviates this. - */ - corr_ref_coords[0] = tan (0.5 * M_PI * (x - 0.5)) * 0.5 + 0.5; - corr_ref_coords[1] = tan (0.5 * M_PI * (y - 0.5)) * 0.5 + 0.5; - corr_ref_coords[2] = 0; + t8_vec_copy (origin, out_pos); + t8_vec_axpy (tangent1, out_pos, alpha1); + t8_vec_axpy (tangent2, out_pos, alpha2); - t8_geom_linear_interpolation (corr_ref_coords, active_tree_vertices, 3, 2, position); - t8_vec_normalize (position); - t8_vec_axy (position, out_coords + offset_3d, radius); + t8_vec_rescale (out_pos, radius); + + t8_vec_copy (out_pos, out_coords + offset_3d); } } @@ -306,34 +330,55 @@ t8_geometry_cubed_spherical_shell::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx { double position[3]; /* Position vector in the element. */ - /* All elements are aligned such that the reference z-direction follows the - * outward radial direction of the sphere. Hence the element height is equal to - * the shell thickness. */ - const double inner_radius = t8_vec_norm (active_tree_vertices); - const double shell_thickness = t8_vec_norm (active_tree_vertices + 4 * 3) - inner_radius; + double normal[3]; /* Position vector in the element. */ + + double tangent1[3]; /* Position vector in the element. */ + double tangent2[3]; /* Position vector in the element. */ + + double origin[3]; + const double _SQRT3 = 1.7320508075688772; + + t8_vec_tri_normal (active_tree_vertices, active_tree_vertices + 3, active_tree_vertices + 6, normal); + t8_vec_normalize (normal); + + const double R = std::abs(t8_vec_dot (active_tree_vertices, normal)); + + const double inner_radius = R * _SQRT3; + const double shell_thickness = std::abs(t8_vec_dot (active_tree_vertices + 4*3, normal)) * _SQRT3 - inner_radius; + + tangent1[0] = normal[1]; + tangent1[1] = normal[2]; + tangent1[2] = -normal[0]; + + t8_vec_axpy (normal, tangent1, -t8_vec_dot(normal, tangent1)); + t8_vec_cross (normal, tangent1, tangent2); + + t8_vec_normalize (tangent1); + t8_vec_normalize (tangent2); + t8_vec_axy (normal, origin, R); + + /* All elements are aligned such that the face normal follows the + * outward radial direction of the sphere. */ for (size_t i_coord = 0; i_coord < num_coords; i_coord++) { - const size_t offset = 3 * i_coord; + const size_t offset_3d = 3 * i_coord; + + double local_pos[3]; + double out_pos[3]; + + t8_geom_linear_interpolation (ref_coords + offset_3d, active_tree_vertices, 3, 2, position); + t8_vec_diff (position, origin, local_pos); + + const double alpha1 = R * tan (0.25 * M_PI * t8_vec_dot (tangent1, local_pos) / R); + const double alpha2 = R * tan (0.25 * M_PI * t8_vec_dot (tangent2, local_pos) / R); + + t8_vec_copy (origin, out_pos); + t8_vec_axpy (tangent1, out_pos, alpha1); + t8_vec_axpy (tangent2, out_pos, alpha2); + + t8_vec_rescale (out_pos, inner_radius + ref_coords[offset_3d + 2] * shell_thickness); - double corr_ref_coords[3]; /* Corrected reference coordinates. */ - - /* Shorthand for code readability. `ref_coords` go from 0 to 1. */ - const double x = ref_coords[offset + 0]; - const double y = ref_coords[offset + 1]; - const double z = ref_coords[offset + 2]; - - /* tldr: Correction in order to rectify elements near the corners. - * This is necessary, since due to the transformation from the unit cube - * to the sphere elements near the face centers expand while near the - * corners they shrink. Following correction alleviates this. - */ - corr_ref_coords[0] = tan (0.5 * M_PI * (x - 0.5)) * 0.5 + 0.5; - corr_ref_coords[1] = tan (0.5 * M_PI * (y - 0.5)) * 0.5 + 0.5; - corr_ref_coords[2] = z; - - t8_geom_linear_interpolation (corr_ref_coords, active_tree_vertices, 3, 3, position); - t8_vec_normalize (position); - t8_vec_axy (position, out_coords + offset, inner_radius + z * shell_thickness); + t8_vec_copy (out_pos, out_coords + offset_3d); } } From 3b294c5e3aee764b5072959417593a6bf136d9fc Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Fri, 2 Aug 2024 10:53:48 +0200 Subject: [PATCH 34/87] Adding triangulated spherical surface cubed version. --- example/cmesh/t8_cmesh_geometry_examples.cxx | 20 ++++ src/t8_cmesh/t8_cmesh_examples.cxx | 104 ++++++++++++++++-- src/t8_cmesh/t8_cmesh_examples.h | 8 ++ .../t8_geometry_examples.cxx | 13 ++- 4 files changed, 130 insertions(+), 15 deletions(-) diff --git a/example/cmesh/t8_cmesh_geometry_examples.cxx b/example/cmesh/t8_cmesh_geometry_examples.cxx index 588109d04a..1265e7bb70 100644 --- a/example/cmesh/t8_cmesh_geometry_examples.cxx +++ b/example/cmesh/t8_cmesh_geometry_examples.cxx @@ -169,6 +169,26 @@ main (int argc, char **argv) t8_forest_unref (&forest); } + { + const char *prefix_cmesh = "t8_triangulated_spherical_surface_cube_cmesh"; + const char *prefix_forest = "t8_triangulated_spherical_surface_cube_forest"; + + const int uniform_level = 4; + const double radius = 42.0; + + t8_cmesh_t cmesh = t8_cmesh_new_triangulated_spherical_surface_cube (radius, comm); + + t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); + + t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); + t8_global_productionf ("Wrote %s.\n", prefix_cmesh); + + t8_write_forest_to_vtu (forest, prefix_forest); + t8_global_productionf ("Wrote %s.\n\n", prefix_forest); + + t8_forest_unref (&forest); + } + { const char *prefix_cmesh = "t8_quadrangulated_spherical_surface_cmesh"; const char *prefix_forest = "t8_quadrangulated_spherical_surface_forest"; diff --git a/src/t8_cmesh/t8_cmesh_examples.cxx b/src/t8_cmesh/t8_cmesh_examples.cxx index a579cea6b9..11be5ee34d 100644 --- a/src/t8_cmesh/t8_cmesh_examples.cxx +++ b/src/t8_cmesh/t8_cmesh_examples.cxx @@ -3114,6 +3114,90 @@ t8_cmesh_new_triangulated_spherical_surface_icosahedron (const double radius, sc return cmesh; } +t8_cmesh_t +t8_cmesh_new_triangulated_spherical_surface_cube (const double radius, sc_MPI_Comm comm) +{ + // Initialization of the mesh. + t8_cmesh_t cmesh; + t8_cmesh_init (&cmesh); + + t8_cmesh_register_geometry (cmesh); + + const int nface_rot = 4; // Four triangles create a cube's face. + const int ncube_rot = 6; // Six rotations of the four trinagles to the six cube's faces. + + const int ntrees = nface_rot*ncube_rot; // Number of cmesh elements resp. trees. + const int nverts = 3; // Number of cmesh element (triangle) vertices. + + // Arrays for the face connectivity computations via vertices. + double all_verts[ntrees * T8_ECLASS_MAX_CORNERS * T8_ECLASS_MAX_DIM]; + t8_eclass_t all_eclasses[ntrees]; + + // Defitition of the tree class. + for (int itree = 0; itree < ntrees; itree++) { + t8_cmesh_set_tree_class (cmesh, itree, T8_ECLASS_TRIANGLE); + all_eclasses[itree] = T8_ECLASS_TRIANGLE; + } + + constexpr double _CBRT = std::cbrt(1.0); + const double r = radius / _CBRT; + + const double vertices[3][3] = { { -r, -r, r }, { r, -r, r }, { 0.0, 0.0, r } }; + + const double face_angles[] = { 0.0, 0.5 * M_PI, M_PI, 1.5*M_PI }; + const double cube_angles[] = { 0.0, 0.5 * M_PI, 0.5 * M_PI, M_PI, -0.5 * M_PI, -0.5 * M_PI }; + const int cube_rot_axis[] = { 0, 0, 1, 1, 0, 1 }; + + // Set the vertices. + int itree = 0; + for (int icube_rot = 0; icube_rot < ncube_rot; ++icube_rot) { + double cube_rot_mat[3][3]; + double cube_rot_vertices[3][3]; + + if (cube_rot_axis[icube_rot] == 0) { + t8_mat_init_xrot (cube_rot_mat, cube_angles[icube_rot]); + } + else { + t8_mat_init_yrot (cube_rot_mat, cube_angles[icube_rot]); + } + + for (int iface_rot = 0; iface_rot < nface_rot; ++iface_rot) { + double face_rot_mat[3][3]; + double face_rot_vertices[3][3]; + + t8_mat_init_zrot (face_rot_mat, face_angles[iface_rot]); + + // Rotate around z-axis to create a quadratic face. + for (int ivert = 0; ivert < nverts; ivert++) { + t8_mat_mult_vec (face_rot_mat, &(vertices[ivert][0]), &(face_rot_vertices[ivert][0])); + } + + // Rotate to one of the cube's faces. + for (int ivert = 0; ivert < nverts; ivert++) { + t8_mat_mult_vec (cube_rot_mat, &(face_rot_vertices[ivert][0]), &(cube_rot_vertices[ivert][0])); + } + + t8_cmesh_set_tree_vertices (cmesh, itree, (double *) cube_rot_vertices, nverts); + + for (int ivert = 0; ivert < nverts; ivert++) { + for (int icoord = 0; icoord < T8_ECLASS_MAX_DIM; icoord++) { + all_verts[T8_3D_TO_1D (ntrees, T8_ECLASS_MAX_CORNERS, T8_ECLASS_MAX_DIM, itree, ivert, icoord)] + = cube_rot_vertices[ivert][icoord]; + } + } + + ++itree; + } + } + + // Face connectivity. + t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, NULL, 0); + + // Commit the mesh. + t8_cmesh_commit (cmesh, comm); + return cmesh; +} + t8_cmesh_t t8_cmesh_new_quadrangulated_spherical_surface (const double radius, sc_MPI_Comm comm) { @@ -3136,8 +3220,8 @@ t8_cmesh_new_quadrangulated_spherical_surface (const double radius, sc_MPI_Comm all_eclasses[itree] = T8_ECLASS_QUAD; } - const double _SQRT3 = 1.7320508075688772; - const double r = radius / _SQRT3; + constexpr double _CBRT = std::cbrt(1.0); + const double r = radius / _CBRT; const double vertices[4][3] = { { -r, -r, r }, { r, -r, r }, { -r, r, r }, { r, r, r } }; @@ -3326,7 +3410,7 @@ t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shel t8_cmesh_t cmesh; t8_cmesh_init (&cmesh); - t8_cmesh_register_geometry (cmesh); /* Use spherical geometry */ + t8_cmesh_register_geometry (cmesh); /* Use spherical geometry. */ /* clang-format off */ const int nrotas = t8_eclass_num_faces[T8_ECLASS_HEX]; /* Number of 3D cmesh elements resp. trees. */ @@ -3345,9 +3429,10 @@ t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shel const double outer_radius = inner_radius + shell_thickness; - const double _SQRT3 = 1.7320508075688772; - const double r = inner_radius / _SQRT3; - const double R = outer_radius / _SQRT3; + const double _CBRT = 1.7320508075688772; + + const double r = inner_radius / _CBRT; + const double R = outer_radius / _CBRT; // Vertices of the template hex. const double vertices[nverts][3] = { @@ -3426,12 +3511,13 @@ t8_cmesh_new_cubed_sphere (const double radius, sc_MPI_Comm comm) const double inner_radius = 0.6 * radius; const double outer_radius = radius; - const double SQRT3 = 1.7320508075688772; - const double inner_x = inner_radius / SQRT3; + constexpr double _CBRT = std::cbrt(1.0); + + const double inner_x = inner_radius / _CBRT; const double inner_y = inner_x; const double inner_z = inner_x; - const double outer_x = outer_radius / SQRT3; + const double outer_x = outer_radius / _CBRT; const double outer_y = outer_x; const double outer_z = outer_x; diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 2047f4df20..238cb2e996 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -406,6 +406,14 @@ t8_cmesh_new_triangulated_spherical_surface_octahedron (const double radius, sc_ t8_cmesh_t t8_cmesh_new_triangulated_spherical_surface_icosahedron (const double radius, sc_MPI_Comm comm); +/** Construct a triangulated spherical surface of given radius: cube version. + * \param [in] radius Radius of the sphere. + * \param [in] comm The MPI communicator used to commit the cmesh + * \return A cmesh representing the spherical surface. + */ +t8_cmesh_t +t8_cmesh_new_triangulated_spherical_surface_cube (const double radius, sc_MPI_Comm comm); + /** Construct a quadrangulated spherical surface of given radius. * \param [in] radius Radius of the sphere. * \param [in] comm The MPI communicator used to commit the cmesh diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx index 46904bbf3d..f68d097465 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx @@ -271,14 +271,14 @@ t8_geometry_quadrangulated_spherical_surface::t8_geom_evaluate (t8_cmesh_t cmesh double origin[3]; - const double _SQRT3 = 1.7320508075688772; + constexpr double _CBRT = std::cbrt(1.0); t8_vec_tri_normal (active_tree_vertices, active_tree_vertices + 3, active_tree_vertices + 6, normal); t8_vec_normalize (normal); const double R = std::abs(t8_vec_dot (active_tree_vertices, normal)); - const double radius = R * _SQRT3; + const double radius = R * _CBRT; tangent1[0] = normal[1]; tangent1[1] = normal[2]; @@ -301,7 +301,8 @@ t8_geometry_quadrangulated_spherical_surface::t8_geom_evaluate (t8_cmesh_t cmesh double local_pos[3]; double out_pos[3]; - t8_geom_linear_interpolation (ref_coords + offset_2d, active_tree_vertices, 3, 2, position); + t8_geom_compute_linear_geometry (active_tree_class, active_tree_vertices, ref_coords + offset_2d, 1, position); + t8_vec_diff (position, origin, local_pos); const double alpha1 = R * tan (0.25 * M_PI * t8_vec_dot (tangent1, local_pos) / R); @@ -337,15 +338,15 @@ t8_geometry_cubed_spherical_shell::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx double origin[3]; - const double _SQRT3 = 1.7320508075688772; + constexpr double _CBRT = std::cbrt(1.0); t8_vec_tri_normal (active_tree_vertices, active_tree_vertices + 3, active_tree_vertices + 6, normal); t8_vec_normalize (normal); const double R = std::abs(t8_vec_dot (active_tree_vertices, normal)); - const double inner_radius = R * _SQRT3; - const double shell_thickness = std::abs(t8_vec_dot (active_tree_vertices + 4*3, normal)) * _SQRT3 - inner_radius; + const double inner_radius = R * _CBRT; + const double shell_thickness = std::abs(t8_vec_dot (active_tree_vertices + 4*3, normal)) * _CBRT - inner_radius; tangent1[0] = normal[1]; tangent1[1] = normal[2]; From d92ec73959e30c5a8ac3ffe104237e6c946941b7 Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Fri, 2 Aug 2024 15:45:06 +0200 Subject: [PATCH 35/87] Code cleanup. --- src/t8_cmesh/t8_cmesh_examples.cxx | 23 +-- .../t8_geometry_examples.cxx | 166 +++++++++--------- src/t8_vec.h | 19 ++ 3 files changed, 118 insertions(+), 90 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.cxx b/src/t8_cmesh/t8_cmesh_examples.cxx index 11be5ee34d..a53d39ce5b 100644 --- a/src/t8_cmesh/t8_cmesh_examples.cxx +++ b/src/t8_cmesh/t8_cmesh_examples.cxx @@ -3124,9 +3124,9 @@ t8_cmesh_new_triangulated_spherical_surface_cube (const double radius, sc_MPI_Co t8_cmesh_register_geometry (cmesh); const int nface_rot = 4; // Four triangles create a cube's face. - const int ncube_rot = 6; // Six rotations of the four trinagles to the six cube's faces. + const int ncube_rot = 6; // Six rotations of the four triangles to the six cube's faces. - const int ntrees = nface_rot*ncube_rot; // Number of cmesh elements resp. trees. + constexpr int ntrees = nface_rot*ncube_rot; // Number of cmesh elements resp. trees. const int nverts = 3; // Number of cmesh element (triangle) vertices. // Arrays for the face connectivity computations via vertices. @@ -3418,8 +3418,8 @@ t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shel const int nverts = t8_eclass_num_vertices[T8_ECLASS_HEX]; /* Number of vertices per cmesh element. */ /* Arrays for the face connectivity computations via vertices. */ - double all_verts[ntrees * T8_ECLASS_MAX_CORNERS * T8_ECLASS_MAX_DIM]; - t8_eclass_t all_eclasses[ntrees]; + double *all_verts = T8_ALLOC(double, ntrees * T8_ECLASS_MAX_CORNERS * T8_ECLASS_MAX_DIM); + t8_eclass_t *all_eclasses = T8_ALLOC(t8_eclass_t, ntrees); /* Defitition of the tree class. */ for (int itree = 0; itree < ntrees; itree++) { @@ -3435,13 +3435,13 @@ t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shel const double R = outer_radius / _CBRT; // Vertices of the template hex. - const double vertices[nverts][3] = { + const double vertices[][3] = { { -r, -r, r }, { r, -r, r }, { -r, r, r }, { r, r, r }, { -R, -R, R }, { R, -R, R }, { -R, R, R }, { R, R, R } }; - const double angles[nrotas] = { 0.0 , 0.5 * M_PI, 0.5 * M_PI, M_PI, -0.5 * M_PI, -0.5 * M_PI }; - const int rot_axis[nrotas] = { 0, 0, 1, 1, 0, 1 }; + const double angles[] = { 0.0 , 0.5 * M_PI, 0.5 * M_PI, M_PI, -0.5 * M_PI, -0.5 * M_PI }; + const int rot_axis[] = { 0, 0, 1, 1, 0, 1 }; const double h = 1.0 / num_layers; const double w = 1.0 / num_trees; @@ -3465,15 +3465,15 @@ t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shel const double I = i + 1; const double J = j + 1; const double K = k + 1; - double ref_coords[nverts][3] = { + double ref_coords[][3] = { { i*w, j*l, k*h }, { I*w, j*l, k*h }, { i*w, J*l, k*h }, { I*w, J*l, k*h }, { i*w, j*l, K*h }, { I*w, j*l, K*h }, { i*w, J*l, K*h }, { I*w, J*l, K*h } }; - double tile_vertices[nverts][3]; + double tile_vertices[8][3]; t8_geom_compute_linear_geometry (T8_ECLASS_HEX, (double *) vertices, (double *) ref_coords, nverts, (double *) tile_vertices); - double rot_vertices[nverts][3]; + double rot_vertices[8][3]; for (int ivert = 0; ivert < nverts; ivert++) { t8_mat_mult_vec (rot_mat, &(tile_vertices[ivert][0]), &(rot_vertices[ivert][0])); } @@ -3496,6 +3496,9 @@ t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shel /* Face connectivity. */ t8_cmesh_set_join_by_vertices (cmesh, ntrees, all_eclasses, all_verts, NULL, 0); + T8_FREE (all_verts); + T8_FREE (all_eclasses); + /* Commit the mesh */ t8_cmesh_commit (cmesh, comm); return cmesh; diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx index a263a487f0..8bbae686d7 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx @@ -160,59 +160,55 @@ t8_geometry_quadrangulated_spherical_surface::t8_geom_evaluate (t8_cmesh_t cmesh const double *ref_coords, const size_t num_coords, double *out_coords) const { - double position[3]; /* Position vector in the element. */ + // Note, all elements are aligned such that the face normal follows the + // outward radial direction of the sphere. - double normal[3]; /* Position vector in the element. */ - - double tangent1[3]; /* Position vector in the element. */ - double tangent2[3]; /* Position vector in the element. */ - - double origin[3]; - - constexpr double _CBRT = std::cbrt(1.0); + // These three vectors resemble a tripod. + double normal[3]; // Normal vector. + double tangent1[3]; // First tangent vector. + double tangent2[3]; // Second tangent vector. + // Compute normal vector of the current cmesh cell. t8_vec_tri_normal (active_tree_vertices, active_tree_vertices + 3, active_tree_vertices + 6, normal); t8_vec_normalize (normal); - const double R = std::abs(t8_vec_dot (active_tree_vertices, normal)); + // Compute sphere's radius over cube root which is the shortest distance to the origin (0,0,0). + const double distance = std::abs(t8_vec_dot (active_tree_vertices, normal)); - const double radius = R * _CBRT; + // Compute actual radius of the sphere. + const double radius = distance * std::cbrt(1.0); - tangent1[0] = normal[1]; - tangent1[1] = normal[2]; - tangent1[2] = -normal[0]; + // Compute orthogonal coordinate system anchored on the cmesh element. + t8_vec_orthogonal_tripod (normal, tangent1, tangent2); - t8_vec_axpy (normal, tangent1, -t8_vec_dot(normal, tangent1)); - t8_vec_cross (normal, tangent1, tangent2); - - t8_vec_normalize (tangent1); - t8_vec_normalize (tangent2); + // Compute anchor of the tripod on the cmesh element's plane. + double anchor[3]; + t8_vec_axy (normal, anchor, distance); - t8_vec_axy (normal, origin, R); - - /* All elements are aligned such that the face normal follows the - * outward radial direction of the sphere. */ + // Loop over given reference coordinates. for (size_t i_coord = 0; i_coord < num_coords; i_coord++) { const size_t offset_2d = 2 * i_coord; const size_t offset_3d = 3 * i_coord; - double local_pos[3]; - double out_pos[3]; - + // Compute the the position vector in the cmesh element. + double position[3]; t8_geom_compute_linear_geometry (active_tree_class, active_tree_vertices, ref_coords + offset_2d, 1, position); - t8_vec_diff (position, origin, local_pos); - - const double alpha1 = R * tan (0.25 * M_PI * t8_vec_dot (tangent1, local_pos) / R); - const double alpha2 = R * tan (0.25 * M_PI * t8_vec_dot (tangent2, local_pos) / R); - - t8_vec_copy (origin, out_pos); - t8_vec_axpy (tangent1, out_pos, alpha1); - t8_vec_axpy (tangent2, out_pos, alpha2); - - t8_vec_rescale (out_pos, radius); - - t8_vec_copy (out_pos, out_coords + offset_3d); + // Compute difference vector between position and tripod's anchor. + double diff_vec[3]; + t8_vec_diff (position, anchor, diff_vec); + + // Compute the coefficients of the difference vector in the local + // coordinate system of the tripod and apply equi-angular correction. + const double alpha1 = distance * tan (0.25 * M_PI * t8_vec_dot (tangent1, diff_vec) / distance); + const double alpha2 = distance * tan (0.25 * M_PI * t8_vec_dot (tangent2, diff_vec) / distance); + + // Compute the final transformed coordinates. + double *out_vec = out_coords + offset_3d; + t8_vec_copy (anchor, out_vec); + t8_vec_axpy (tangent1, out_vec, alpha1); + t8_vec_axpy (tangent2, out_vec, alpha2); + t8_vec_rescale (out_vec, radius); } } @@ -227,57 +223,67 @@ void t8_geometry_cubed_spherical_shell::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *out_coords) const { - double position[3]; /* Position vector in the element. */ - - double normal[3]; /* Position vector in the element. */ - - double tangent1[3]; /* Position vector in the element. */ - double tangent2[3]; /* Position vector in the element. */ + // Note, all elements are aligned such that the face normal follows the + // outward radial direction of the sphere. - double origin[3]; - - constexpr double _CBRT = std::cbrt(1.0); + // These three vectors resemble a tripod. + double normal[3]; // Normal vector. + double tangent1[3]; // First tangent vector. + double tangent2[3]; // Second tangent vector. + // Compute normal vector of the current cmesh cell. t8_vec_tri_normal (active_tree_vertices, active_tree_vertices + 3, active_tree_vertices + 6, normal); t8_vec_normalize (normal); - const double R = std::abs(t8_vec_dot (active_tree_vertices, normal)); - - const double inner_radius = R * _CBRT; - const double shell_thickness = std::abs(t8_vec_dot (active_tree_vertices + 4*3, normal)) * _CBRT - inner_radius; - - tangent1[0] = normal[1]; - tangent1[1] = normal[2]; - tangent1[2] = -normal[0]; - - t8_vec_axpy (normal, tangent1, -t8_vec_dot(normal, tangent1)); - t8_vec_cross (normal, tangent1, tangent2); - - t8_vec_normalize (tangent1); - t8_vec_normalize (tangent2); - t8_vec_axy (normal, origin, R); + // Compute sphere's radius over cube root which is the shortest distance to the origin (0,0,0). + const double distance = std::abs(t8_vec_dot (active_tree_vertices, normal)); + + // Compute actual radius of the sphere. + constexpr double CBRT = std::cbrt(1.0); + const double inner_radius = distance * CBRT; + const double shell_thickness = std::abs(t8_vec_dot (active_tree_vertices + t8_eclass_num_vertices[active_tree_class]*3/2, normal)) * CBRT - inner_radius; + + // Compute orthogonal coordinate system anchored on the cmesh element. + t8_vec_orthogonal_tripod (normal, tangent1, tangent2); + + // Compute anchor of the tripod on the cmesh element's plane. + double anchor[3]; + t8_vec_axy (normal, anchor, distance); + + t8_eclass_t interpolation_eclass; + switch (active_tree_class) { + case T8_ECLASS_HEX: + interpolation_eclass = T8_ECLASS_QUAD; + break; + case T8_ECLASS_PRISM: + interpolation_eclass = T8_ECLASS_TRIANGLE; + break; + default: + SC_ABORT_NOT_REACHED (); + } - /* All elements are aligned such that the face normal follows the - * outward radial direction of the sphere. */ for (size_t i_coord = 0; i_coord < num_coords; i_coord++) { const size_t offset_3d = 3 * i_coord; - double local_pos[3]; - double out_pos[3]; - - t8_geom_linear_interpolation (ref_coords + offset_3d, active_tree_vertices, 3, 2, position); - t8_vec_diff (position, origin, local_pos); - - const double alpha1 = R * tan (0.25 * M_PI * t8_vec_dot (tangent1, local_pos) / R); - const double alpha2 = R * tan (0.25 * M_PI * t8_vec_dot (tangent2, local_pos) / R); - - t8_vec_copy (origin, out_pos); - t8_vec_axpy (tangent1, out_pos, alpha1); - t8_vec_axpy (tangent2, out_pos, alpha2); - - t8_vec_rescale (out_pos, inner_radius + ref_coords[offset_3d + 2] * shell_thickness); - - t8_vec_copy (out_pos, out_coords + offset_3d); + // Compute the the position vector in the cmesh element. + double position[3]; + t8_geom_compute_linear_geometry (interpolation_eclass, active_tree_vertices, ref_coords + offset_3d, 1, position); + + // Compute difference vector between position and tripod's anchor. + double diff_vec[3]; + t8_vec_diff (position, anchor, diff_vec); + + // Compute the coefficients of the difference vector in the local + // coordinate system of the tripod and apply equi-angular correction. + const double alpha1 = distance * tan (0.25 * M_PI * t8_vec_dot (tangent1, diff_vec) / distance); + const double alpha2 = distance * tan (0.25 * M_PI * t8_vec_dot (tangent2, diff_vec) / distance); + + // Compute the final transformed coordinates. + double *out_vec = out_coords + offset_3d; + t8_vec_copy (anchor, out_vec); + t8_vec_axpy (tangent1, out_vec, alpha1); + t8_vec_axpy (tangent2, out_vec, alpha2); + t8_vec_rescale (out_vec, inner_radius + ref_coords[offset_3d + 2] * shell_thickness); } } diff --git a/src/t8_vec.h b/src/t8_vec.h index eaa534bc3a..e3439b8f70 100644 --- a/src/t8_vec.h +++ b/src/t8_vec.h @@ -245,6 +245,25 @@ t8_vec_tri_normal (const double p1[3], const double p2[3], const double p3[3], d t8_vec_cross (a, b, normal); } +/** Compute an orthogonal coordinate system from a given vector. + * \param [in] v1 3D vector. + * \param [out] v2 3D vector. + * \param [out] v3 3D vector. + */ +static inline void +t8_vec_orthogonal_tripod (const double v1[3], double v2[3], double v3[3]) +{ + v2[0] = v1[1]; + v2[1] = v1[2]; + v2[2] = -v1[0]; + + t8_vec_axpy (v1, v2, -t8_vec_dot(v1, v2)); + t8_vec_cross (v1, v2, v3); + + t8_vec_normalize (v2); + t8_vec_normalize (v3); +} + /** Swap the components of two vectors. * \param [in,out] p1 A 3D vector. * \param [in,out] p2 A 3D vector. From 8f130e8f13d588c5562dcf97f7d7302784359676 Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Fri, 2 Aug 2024 15:47:01 +0200 Subject: [PATCH 36/87] Applied formatter. --- src/t8_cmesh/t8_cmesh_examples.cxx | 14 +++---- .../t8_geometry_examples.cxx | 42 ++++++++++--------- src/t8_vec.h | 4 +- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.cxx b/src/t8_cmesh/t8_cmesh_examples.cxx index a53d39ce5b..0ec97e60c6 100644 --- a/src/t8_cmesh/t8_cmesh_examples.cxx +++ b/src/t8_cmesh/t8_cmesh_examples.cxx @@ -3123,11 +3123,11 @@ t8_cmesh_new_triangulated_spherical_surface_cube (const double radius, sc_MPI_Co t8_cmesh_register_geometry (cmesh); - const int nface_rot = 4; // Four triangles create a cube's face. - const int ncube_rot = 6; // Six rotations of the four triangles to the six cube's faces. + const int nface_rot = 4; // Four triangles create a cube's face. + const int ncube_rot = 6; // Six rotations of the four triangles to the six cube's faces. - constexpr int ntrees = nface_rot*ncube_rot; // Number of cmesh elements resp. trees. - const int nverts = 3; // Number of cmesh element (triangle) vertices. + constexpr int ntrees = nface_rot * ncube_rot; // Number of cmesh elements resp. trees. + const int nverts = 3; // Number of cmesh element (triangle) vertices. // Arrays for the face connectivity computations via vertices. double all_verts[ntrees * T8_ECLASS_MAX_CORNERS * T8_ECLASS_MAX_DIM]; @@ -3139,12 +3139,12 @@ t8_cmesh_new_triangulated_spherical_surface_cube (const double radius, sc_MPI_Co all_eclasses[itree] = T8_ECLASS_TRIANGLE; } - constexpr double _CBRT = std::cbrt(1.0); + constexpr double _CBRT = std::cbrt (1.0); const double r = radius / _CBRT; const double vertices[3][3] = { { -r, -r, r }, { r, -r, r }, { 0.0, 0.0, r } }; - const double face_angles[] = { 0.0, 0.5 * M_PI, M_PI, 1.5*M_PI }; + const double face_angles[] = { 0.0, 0.5 * M_PI, M_PI, 1.5 * M_PI }; const double cube_angles[] = { 0.0, 0.5 * M_PI, 0.5 * M_PI, M_PI, -0.5 * M_PI, -0.5 * M_PI }; const int cube_rot_axis[] = { 0, 0, 1, 1, 0, 1 }; @@ -3220,7 +3220,7 @@ t8_cmesh_new_quadrangulated_spherical_surface (const double radius, sc_MPI_Comm all_eclasses[itree] = T8_ECLASS_QUAD; } - constexpr double _CBRT = std::cbrt(1.0); + constexpr double _CBRT = std::cbrt (1.0); const double r = radius / _CBRT; const double vertices[4][3] = { { -r, -r, r }, { r, -r, r }, { -r, r, r }, { r, r, r } }; diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx index 8bbae686d7..52bdb42c78 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx @@ -164,19 +164,19 @@ t8_geometry_quadrangulated_spherical_surface::t8_geom_evaluate (t8_cmesh_t cmesh // outward radial direction of the sphere. // These three vectors resemble a tripod. - double normal[3]; // Normal vector. - double tangent1[3]; // First tangent vector. - double tangent2[3]; // Second tangent vector. + double normal[3]; // Normal vector. + double tangent1[3]; // First tangent vector. + double tangent2[3]; // Second tangent vector. // Compute normal vector of the current cmesh cell. t8_vec_tri_normal (active_tree_vertices, active_tree_vertices + 3, active_tree_vertices + 6, normal); t8_vec_normalize (normal); // Compute sphere's radius over cube root which is the shortest distance to the origin (0,0,0). - const double distance = std::abs(t8_vec_dot (active_tree_vertices, normal)); + const double distance = std::abs (t8_vec_dot (active_tree_vertices, normal)); // Compute actual radius of the sphere. - const double radius = distance * std::cbrt(1.0); + const double radius = distance * std::cbrt (1.0); // Compute orthogonal coordinate system anchored on the cmesh element. t8_vec_orthogonal_tripod (normal, tangent1, tangent2); @@ -190,7 +190,7 @@ t8_geometry_quadrangulated_spherical_surface::t8_geom_evaluate (t8_cmesh_t cmesh const size_t offset_2d = 2 * i_coord; const size_t offset_3d = 3 * i_coord; - // Compute the the position vector in the cmesh element. + // Compute the the position vector in the cmesh element. double position[3]; t8_geom_compute_linear_geometry (active_tree_class, active_tree_vertices, ref_coords + offset_2d, 1, position); @@ -227,21 +227,23 @@ t8_geometry_cubed_spherical_shell::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx // outward radial direction of the sphere. // These three vectors resemble a tripod. - double normal[3]; // Normal vector. - double tangent1[3]; // First tangent vector. - double tangent2[3]; // Second tangent vector. + double normal[3]; // Normal vector. + double tangent1[3]; // First tangent vector. + double tangent2[3]; // Second tangent vector. // Compute normal vector of the current cmesh cell. t8_vec_tri_normal (active_tree_vertices, active_tree_vertices + 3, active_tree_vertices + 6, normal); t8_vec_normalize (normal); // Compute sphere's radius over cube root which is the shortest distance to the origin (0,0,0). - const double distance = std::abs(t8_vec_dot (active_tree_vertices, normal)); + const double distance = std::abs (t8_vec_dot (active_tree_vertices, normal)); // Compute actual radius of the sphere. - constexpr double CBRT = std::cbrt(1.0); + constexpr double CBRT = std::cbrt (1.0); const double inner_radius = distance * CBRT; - const double shell_thickness = std::abs(t8_vec_dot (active_tree_vertices + t8_eclass_num_vertices[active_tree_class]*3/2, normal)) * CBRT - inner_radius; + const double shell_thickness + = std::abs (t8_vec_dot (active_tree_vertices + t8_eclass_num_vertices[active_tree_class] * 3 / 2, normal)) * CBRT + - inner_radius; // Compute orthogonal coordinate system anchored on the cmesh element. t8_vec_orthogonal_tripod (normal, tangent1, tangent2); @@ -252,14 +254,14 @@ t8_geometry_cubed_spherical_shell::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx t8_eclass_t interpolation_eclass; switch (active_tree_class) { - case T8_ECLASS_HEX: - interpolation_eclass = T8_ECLASS_QUAD; - break; - case T8_ECLASS_PRISM: - interpolation_eclass = T8_ECLASS_TRIANGLE; - break; - default: - SC_ABORT_NOT_REACHED (); + case T8_ECLASS_HEX: + interpolation_eclass = T8_ECLASS_QUAD; + break; + case T8_ECLASS_PRISM: + interpolation_eclass = T8_ECLASS_TRIANGLE; + break; + default: + SC_ABORT_NOT_REACHED (); } for (size_t i_coord = 0; i_coord < num_coords; i_coord++) { diff --git a/src/t8_vec.h b/src/t8_vec.h index e3439b8f70..6db681486f 100644 --- a/src/t8_vec.h +++ b/src/t8_vec.h @@ -257,9 +257,9 @@ t8_vec_orthogonal_tripod (const double v1[3], double v2[3], double v3[3]) v2[1] = v1[2]; v2[2] = -v1[0]; - t8_vec_axpy (v1, v2, -t8_vec_dot(v1, v2)); + t8_vec_axpy (v1, v2, -t8_vec_dot (v1, v2)); t8_vec_cross (v1, v2, v3); - + t8_vec_normalize (v2); t8_vec_normalize (v3); } From 7a38c3511b65f2c44e75ed39449915d02347ed7b Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Mon, 5 Aug 2024 10:21:44 +0200 Subject: [PATCH 37/87] Updated header file documentation. --- src/t8_cmesh/t8_cmesh_examples.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 238cb2e996..0a4c80f51b 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -449,14 +449,13 @@ t8_cmesh_new_prismed_spherical_shell_icosahedron (const double inner_radius, con /** Construct a cubed spherical shell of given inner radius and thickness. * \param [in] inner_radius Radius of the inner side of the shell. * \param [in] shell_thickness Thickness of the shell. - * \param [in] num_levels Number of trees per patch in longitudinal and latitudinal direction - given as level of refinement: 4^num_levels. + * \param [in] num_trees Number of trees per patch in longitudinal and latitudinal direction. * \param [in] num_layers Number of layers of the shell. * \param [in] comm The MPI communicator used to commit the cmesh * \return A cmesh representing the spherical surface. */ t8_cmesh_t -t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shell_thickness, const int num_levels, +t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shell_thickness, const int num_trees, const int num_layers, sc_MPI_Comm comm); /** Construct a cubed sphere of given radius. From 08532b3e8089111973f3ceac13853f877348131d Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Tue, 6 Aug 2024 14:02:36 +0200 Subject: [PATCH 38/87] Add first triangular interpolation test --- test/CMakeLists.txt | 1 + test/Makefile.am | 10 +++ ...test_geometry_triangular_interpolation.cxx | 65 +++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3a77b03211..23b994ac79 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -71,6 +71,7 @@ add_t8_test( NAME t8_gtest_empty_global_tree SOURCES t8_gtest_main.cxx t8_forest add_t8_test( NAME t8_gtest_geometry_cad SOURCES t8_gtest_main.cxx t8_geometry/t8_geometry_implementations/t8_gtest_geometry_cad.cxx ) add_t8_test( NAME t8_gtest_geometry_linear SOURCES t8_gtest_main.cxx t8_geometry/t8_geometry_implementations/t8_gtest_geometry_linear.cxx ) add_t8_test( NAME t8_gtest_geometry_lagrange SOURCES t8_gtest_main.cxx t8_geometry/t8_geometry_implementations/t8_gtest_geometry_lagrange.cxx ) +add_t8_test( NAME t8_gtest_geometry_triangular_interpolation SOURCES t8_gtest_main.cxx t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx ) add_t8_test( NAME t8_gtest_geometry_handling SOURCES t8_gtest_main.cxx t8_geometry/t8_gtest_geometry_handling.cxx ) add_t8_test( NAME t8_gtest_point_inside SOURCES t8_gtest_main.cxx t8_geometry/t8_gtest_point_inside.cxx ) diff --git a/test/Makefile.am b/test/Makefile.am index 0dc6b221d1..6ee6f4d17a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -45,6 +45,7 @@ t8code_googletest_programs = \ test/t8_cmesh/t8_gtest_hypercube \ test/t8_schemes/t8_gtest_element_count_leaves \ test/t8_schemes/t8_gtest_element_ref_coords \ + test/t8_geometry/t8_gtest_geometry_triangular_interpolation \ test/t8_geometry/t8_gtest_geometry_handling \ test/t8_schemes/t8_gtest_descendant \ test/t8_schemes/t8_gtest_find_parent \ @@ -177,6 +178,10 @@ test_t8_schemes_t8_gtest_element_ref_coords_SOURCES = \ test/t8_gtest_main.cxx \ test/t8_schemes/t8_gtest_element_ref_coords.cxx +test_t8_geometry_t8_gtest_geometry_triangular_interpolation_SOURCES = \ + test/t8_gtest_main.cxx \ + test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx + test_t8_geometry_t8_gtest_geometry_handling_SOURCES = \ test/t8_gtest_main.cxx \ test/t8_geometry/t8_gtest_geometry_handling.cxx @@ -441,6 +446,10 @@ test_t8_schemes_t8_gtest_element_ref_coords_LDADD = $(t8_gtest_target_ld_add) test_t8_schemes_t8_gtest_element_ref_coords_LDFLAGS = $(t8_gtest_target_ld_flags) test_t8_schemes_t8_gtest_element_ref_coords_CPPFLAGS = $(t8_gtest_target_cpp_flags) +test_t8_geometry_t8_gtest_geometry_triangular_interpolation_LDADD = $(t8_gtest_target_ld_add) +test_t8_geometry_t8_gtest_geometry_triangular_interpolation_LDFLAGS = $(t8_gtest_target_ld_flags) +test_t8_geometry_t8_gtest_geometry_triangular_interpolation_CPPFLAGS = $(t8_gtest_target_cpp_flags) + test_t8_geometry_t8_gtest_geometry_handling_LDADD = $(t8_gtest_target_ld_add) test_t8_geometry_t8_gtest_geometry_handling_LDFLAGS = $(t8_gtest_target_ld_flags) test_t8_geometry_t8_gtest_geometry_handling_CPPFLAGS = $(t8_gtest_target_cpp_flags) @@ -642,6 +651,7 @@ test_t8_cmesh_t8_gtest_hypercube_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_cmesh_t8_gtest_cmesh_set_join_by_vertices_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_schemes_t8_gtest_element_count_leaves_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_schemes_t8_gtest_element_ref_coords_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) +test_t8_geometry_t8_gtest_geometry_triangular_interpolation_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_geometry_t8_gtest_geometry_handling_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_schemes_t8_gtest_descendant_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_schemes_t8_gtest_find_parent_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) diff --git a/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx b/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx new file mode 100644 index 0000000000..b2a8b00441 --- /dev/null +++ b/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx @@ -0,0 +1,65 @@ +/* + 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) 2010 The University of Texas System + Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac + + 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 + +TEST_F (triangular_interpolation, corners_map_to_corners){ + const double eps = 1e-14; + + const double coeff_A[3] = {0, 0}; + const double coeff_B[3] = {0, 1}; + const double coeff_C[3] = {1, 1}; + const double coeff_D[3] = {1, 1}; + + const double corner_values[] = + { + 1, 2, // corner A + 3, 4, // corner B + 5, 6 // corner C + }; + + const double *cornerA = corner_values; + const double *cornerB = corner_values + 2; + const double *cornerC = corner_values + 4; + + double result[2]; + + // Check corner A + t8_geom_triangular_interpolation (coeff_A, corner_values, 2, 2, result); + EXPECT_NEAR (cornerA[0], result[0], eps); + EXPECT_NEAR (cornerA[1], result[1], eps); + + // Check corner B + t8_geom_triangular_interpolation (coeff_B, corner_values, 2, 2, result); + EXPECT_NEAR (cornerB[0], result[0], eps); + EXPECT_NEAR (cornerB[1], result[1], eps); + + // Check corner C + t8_geom_triangular_interpolation (coeff_C, corner_values, 2, 2, result); + EXPECT_NEAR (cornerC[0], result[0], eps); + EXPECT_NEAR (cornerC[1], result[1], eps); +} \ No newline at end of file From 3bb57bde160f863902b9cbc46d2d403c6abb7122 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Tue, 6 Aug 2024 14:04:35 +0200 Subject: [PATCH 39/87] Add comments --- ...test_geometry_triangular_interpolation.cxx | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx b/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx index b2a8b00441..d09c53eb8e 100644 --- a/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx +++ b/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx @@ -27,19 +27,27 @@ #include #include -TEST_F (triangular_interpolation, corners_map_to_corners){ +/* TODO: - Check interpolation dim 3 + * - Check corner_value_dim > 1 + * - Check different coefficient coordinates (for example midpoint) + * - Check different corner values */ + +/* Check that the corner interpolation coordinates are + * mapped to the corners of a triangle. */ + +TEST_F (triangular_interpolation, corners_map_to_corners) +{ const double eps = 1e-14; - const double coeff_A[3] = {0, 0}; - const double coeff_B[3] = {0, 1}; - const double coeff_C[3] = {1, 1}; - const double coeff_D[3] = {1, 1}; + const double coeff_A[3] = { 0, 0 }; + const double coeff_B[3] = { 0, 1 }; + const double coeff_C[3] = { 1, 1 }; + const double coeff_D[3] = { 1, 1 }; - const double corner_values[] = - { - 1, 2, // corner A - 3, 4, // corner B - 5, 6 // corner C + const double corner_values[] = { + 1, 2, // corner A + 3, 4, // corner B + 5, 6 // corner C }; const double *cornerA = corner_values; @@ -62,4 +70,4 @@ TEST_F (triangular_interpolation, corners_map_to_corners){ t8_geom_triangular_interpolation (coeff_C, corner_values, 2, 2, result); EXPECT_NEAR (cornerC[0], result[0], eps); EXPECT_NEAR (cornerC[1], result[1], eps); -} \ No newline at end of file +} From 4412c7188b12c27cbdb1d067b958352e7dac98c2 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Tue, 6 Aug 2024 14:34:48 +0200 Subject: [PATCH 40/87] Add 3D test case --- ...test_geometry_triangular_interpolation.cxx | 98 ++++++++++++++++--- 1 file changed, 83 insertions(+), 15 deletions(-) diff --git a/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx b/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx index d09c53eb8e..d0b59be6b0 100644 --- a/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx +++ b/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx @@ -27,47 +27,115 @@ #include #include -/* TODO: - Check interpolation dim 3 +/* In this file we test the functionality of t8_geom_triangular_interpolation. + * The function maps reference coordinates inside the reference triangle or tetrahedron + * to the coordinate space of a triagle or tetrahedron given by its corner coordinates. + * We currently check that the reference coordinates of the corners are mapped correctly + * to the corners of the interpolated triangle/tet. */ + +/* TODO: * - Check corner_value_dim > 1 * - Check different coefficient coordinates (for example midpoint) - * - Check different corner values */ + * - Check different corner values + * - The 2d and 3d example contain a lot of nearly duplicate code. + * Can we simplify? + */ /* Check that the corner interpolation coordinates are * mapped to the corners of a triangle. */ - -TEST_F (triangular_interpolation, corners_map_to_corners) +TEST (triangular_interpolation, corners_map_to_corners_2d) { const double eps = 1e-14; - const double coeff_A[3] = { 0, 0 }; - const double coeff_B[3] = { 0, 1 }; - const double coeff_C[3] = { 1, 1 }; - const double coeff_D[3] = { 1, 1 }; + const double coeff_A[2] = { 0, 0 }; + const double coeff_B[2] = { 0, 1 }; + const double coeff_C[2] = { 1, 1 }; - const double corner_values[] = { + const double corner_values_2d[] = { 1, 2, // corner A 3, 4, // corner B 5, 6 // corner C }; - const double *cornerA = corner_values; - const double *cornerB = corner_values + 2; - const double *cornerC = corner_values + 4; + const double *cornerA = corner_values_2d; + const double *cornerB = corner_values_2d + 2; + const double *cornerC = corner_values_2d + 4; + + const double dimension = 2; double result[2]; // Check corner A - t8_geom_triangular_interpolation (coeff_A, corner_values, 2, 2, result); + // 2D + t8_geom_triangular_interpolation (coeff_A, corner_values_2d, 2, dimension, result); EXPECT_NEAR (cornerA[0], result[0], eps); EXPECT_NEAR (cornerA[1], result[1], eps); // Check corner B - t8_geom_triangular_interpolation (coeff_B, corner_values, 2, 2, result); + // 2D + t8_geom_triangular_interpolation (coeff_B, corner_values_2d, 2, dimension, result); EXPECT_NEAR (cornerB[0], result[0], eps); EXPECT_NEAR (cornerB[1], result[1], eps); // Check corner C - t8_geom_triangular_interpolation (coeff_C, corner_values, 2, 2, result); + // 2D + t8_geom_triangular_interpolation (coeff_C, corner_values_2d, 2, dimension, result); EXPECT_NEAR (cornerC[0], result[0], eps); EXPECT_NEAR (cornerC[1], result[1], eps); } + +/* Check that the corner interpolation coordinates are + * mapped to the corners of a tetrahedron. */ +TEST (triangular_interpolation, corners_map_to_corners_3d) +{ + const double eps = 1e-14; + + const double coeff_A[3] = { 0, 0, 0 }; + const double coeff_B[3] = { 0, 1, 0 }; + const double coeff_C[3] = { 1, 1, 0 }; + const double coeff_D[3] = { 1, 1, 1 }; + + const double corner_values_3d[] = { + 1, 2, 3, // corner A + 4, 5, 6, // corner B + 7, 8, 9, // corner C + 10, 11, 12, // corner D + }; + + const double *cornerA = corner_values_3d; + const double *cornerB = corner_values_3d + 3; + const double *cornerC = corner_values_3d + 6; + const double *cornerD = corner_values_3d + 9; + + const double dimension = 3; + + double result[3]; + + // Check corner A + // 3D + t8_geom_triangular_interpolation (coeff_A, corner_values_3d, 3, dimension, result); + EXPECT_NEAR (cornerA[0], result[0], eps); + EXPECT_NEAR (cornerA[1], result[1], eps); + EXPECT_NEAR (cornerA[2], result[2], eps); + + // Check corner B + // 3D + t8_geom_triangular_interpolation (coeff_B, corner_values_3d, 3, dimension, result); + EXPECT_NEAR (cornerB[0], result[0], eps); + EXPECT_NEAR (cornerB[1], result[1], eps); + EXPECT_NEAR (cornerB[2], result[2], eps); + + // Check corner C + // 3D + t8_geom_triangular_interpolation (coeff_C, corner_values_3d, 3, dimension, result); + EXPECT_NEAR (cornerC[0], result[0], eps); + EXPECT_NEAR (cornerC[1], result[1], eps); + EXPECT_NEAR (cornerC[2], result[2], eps); + + // Check corner D + // 3D + t8_geom_triangular_interpolation (coeff_D, corner_values_3d, 3, dimension, result); + EXPECT_NEAR (cornerD[0], result[0], eps); + EXPECT_NEAR (cornerD[1], result[1], eps); + EXPECT_NEAR (cornerD[2], result[2], eps); +} From 7545c1298294d6d419c0f1e6adf9573ed49960b0 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 7 Aug 2024 10:16:44 +0200 Subject: [PATCH 41/87] indent files --- src/t8_vtk/t8_vtk_write_ASCII.hxx | 2 +- src/t8_vtk/t8_vtk_writer.cxx | 2 +- src/t8_vtk/t8_vtk_writer.hxx | 1 - src/t8_vtk/t8_vtk_writer_c_interface.cxx | 2 +- src/t8_vtk/t8_vtk_writer_c_interface.h | 2 +- src/t8_vtk/t8_vtk_writer_helper.cxx | 2 +- src/t8_vtk/t8_vtk_writer_helper.hxx | 1 - 7 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/t8_vtk/t8_vtk_write_ASCII.hxx b/src/t8_vtk/t8_vtk_write_ASCII.hxx index 009365ddb3..114e32b868 100644 --- a/src/t8_vtk/t8_vtk_write_ASCII.hxx +++ b/src/t8_vtk/t8_vtk_write_ASCII.hxx @@ -54,4 +54,4 @@ t8_forest_vtk_write_ASCII (t8_forest_t forest, const char *fileprefix, const int int t8_cmesh_vtk_write_ASCII (t8_cmesh_t cmesh, const char *fileprefix); -#endif /* T8_VTK_WRITE_ASCII_HXX */ \ No newline at end of file +#endif /* T8_VTK_WRITE_ASCII_HXX */ diff --git a/src/t8_vtk/t8_vtk_writer.cxx b/src/t8_vtk/t8_vtk_writer.cxx index 614a17549c..af3fc13107 100644 --- a/src/t8_vtk/t8_vtk_writer.cxx +++ b/src/t8_vtk/t8_vtk_writer.cxx @@ -100,4 +100,4 @@ bool vtk_writer::write_ASCII (const t8_cmesh_t forest) { return t8_cmesh_vtk_write_ASCII (forest, this->fileprefix.c_str ()); -} \ No newline at end of file +} diff --git a/src/t8_vtk/t8_vtk_writer.hxx b/src/t8_vtk/t8_vtk_writer.hxx index e22df04c36..abbe756cc9 100644 --- a/src/t8_vtk/t8_vtk_writer.hxx +++ b/src/t8_vtk/t8_vtk_writer.hxx @@ -528,7 +528,6 @@ class vtk_writer { sc_MPI_Comm comm; }; - #if T8_WITH_VTK /** * \brief template specialization for forests. diff --git a/src/t8_vtk/t8_vtk_writer_c_interface.cxx b/src/t8_vtk/t8_vtk_writer_c_interface.cxx index 93a186db33..37e7322507 100644 --- a/src/t8_vtk/t8_vtk_writer_c_interface.cxx +++ b/src/t8_vtk/t8_vtk_writer_c_interface.cxx @@ -81,4 +81,4 @@ t8_forest_to_vtkUnstructuredGrid (const t8_forest_t forest, vtkSmartPointer (const t8_cmesh_t grid, const t8_locidx_t itree, const t8_element_t *element) { return 0; -} \ No newline at end of file +} diff --git a/src/t8_vtk/t8_vtk_writer_helper.hxx b/src/t8_vtk/t8_vtk_writer_helper.hxx index 1e094fb9ab..d978062995 100644 --- a/src/t8_vtk/t8_vtk_writer_helper.hxx +++ b/src/t8_vtk/t8_vtk_writer_helper.hxx @@ -224,7 +224,6 @@ template int grid_element_level (const grid_t grid, const t8_locidx_t itree, const t8_element_t *element); - template <> int grid_element_level (const t8_forest_t grid, const t8_locidx_t itree, const t8_element_t *element) From 52ae546d0092ca96eaa11c28b28c85da420503f9 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 7 Aug 2024 10:31:58 +0200 Subject: [PATCH 42/87] clean up after merge --- src/t8_vtk/t8_vtk_writer.hxx | 63 ----------------------------- src/t8_vtk/t8_vtk_writer_helper.hxx | 15 ------- 2 files changed, 78 deletions(-) diff --git a/src/t8_vtk/t8_vtk_writer.hxx b/src/t8_vtk/t8_vtk_writer.hxx index abbe756cc9..abeeb5c42b 100644 --- a/src/t8_vtk/t8_vtk_writer.hxx +++ b/src/t8_vtk/t8_vtk_writer.hxx @@ -528,67 +528,4 @@ class vtk_writer { sc_MPI_Comm comm; }; -#if T8_WITH_VTK -/** - * \brief template specialization for forests. - * - */ -template <> -void -vtk_writer::t8_grid_tree_to_vtk_cells ( - const t8_forest_t forest, vtkSmartPointer unstructuredGrid, - vtkSmartPointer vtk_treeid, vtkSmartPointer vtk_mpirank, - vtkSmartPointer vtk_level, vtkSmartPointer vtk_element_id, - vtkSmartPointer cellArray, vtkSmartPointer points, int *cellTypes, - const t8_locidx_t num_local_trees, t8_gloidx_t *elem_id, long int *point_id, const t8_gloidx_t offset, - const bool ghosts, const t8_locidx_t itree) -{ - /* For both ghosts and pure-local trees iterate over all elements and translate them into a vtk cell. */ - if (ghosts) { - const t8_locidx_t num_ghosts = t8_forest_ghost_tree_num_elements (forest, itree); - for (t8_locidx_t ielem_ghost = 0; ielem_ghost < num_ghosts; ielem_ghost++) { - const t8_element_t *element = t8_forest_ghost_get_element (forest, itree, ielem_ghost); - this->t8_grid_element_to_vtk_cell (forest, element, itree + num_local_trees, offset, true, *elem_id, point_id, - cellTypes, points, cellArray, vtk_treeid, vtk_mpirank, vtk_level, - vtk_element_id); - (*elem_id)++; - } - } - else { - const t8_locidx_t elems_in_tree = t8_forest_get_tree_num_elements (forest, itree); - /* We iterate over all elements in the tree */ - 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); - this->t8_grid_element_to_vtk_cell (forest, element, itree, offset, true, *elem_id, point_id, cellTypes, points, - cellArray, vtk_treeid, vtk_mpirank, vtk_level, vtk_element_id); - (*elem_id)++; - - } /* end of loop over elements */ - } - return; -} - -/** - * \brief template specialization for cmeshes. - * - */ -template <> -void -vtk_writer::t8_grid_tree_to_vtk_cells ( - const t8_cmesh_t cmesh, vtkSmartPointer unstructuredGrid, - vtkSmartPointer vtk_treeid, vtkSmartPointer vtk_mpirank, - vtkSmartPointer vtk_level, vtkSmartPointer vtk_element_id, - vtkSmartPointer cellArray, vtkSmartPointer points, int *cellTypes, - const t8_locidx_t num_local_trees, t8_gloidx_t *elem_id, long int *point_id, const t8_gloidx_t offset, - const bool ghosts, const t8_locidx_t itree) -{ - /* A cmesh does not have any further elements, we can call the translatore directly. */ - this->t8_grid_element_to_vtk_cell (cmesh, NULL, itree, offset, ghosts, *elem_id, point_id, cellTypes, points, - cellArray, vtk_treeid, vtk_mpirank, vtk_level, vtk_element_id); - (*elem_id)++; - return; -} -#endif /* T8_WITH_VTK */ - #endif /* T8_VTK_WRITER_HXX */ diff --git a/src/t8_vtk/t8_vtk_writer_helper.hxx b/src/t8_vtk/t8_vtk_writer_helper.hxx index d978062995..c980dbad52 100644 --- a/src/t8_vtk/t8_vtk_writer_helper.hxx +++ b/src/t8_vtk/t8_vtk_writer_helper.hxx @@ -224,19 +224,4 @@ template int grid_element_level (const grid_t grid, const t8_locidx_t itree, const t8_element_t *element); -template <> -int -grid_element_level (const t8_forest_t grid, const t8_locidx_t itree, const t8_element_t *element) -{ - const t8_eclass_t eclass = t8_forest_get_eclass (grid, itree); - t8_eclass_scheme *scheme = t8_forest_get_eclass_scheme (grid, eclass); - return scheme->t8_element_level (element); -} -template <> -int -grid_element_level (const t8_cmesh_t grid, const t8_locidx_t itree, const t8_element_t *element) -{ - return 0; -} - #endif /* T8_VTK_WRITER_HELPER */ From 73b67ff727f6c6727d8b3bc43305c3d6623069df Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 7 Aug 2024 10:41:40 +0200 Subject: [PATCH 43/87] More static --- test/t8_IO/t8_gtest_vtk_writer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/t8_IO/t8_gtest_vtk_writer.cxx b/test/t8_IO/t8_gtest_vtk_writer.cxx index 3c90faad29..6d2a9ec153 100644 --- a/test/t8_IO/t8_gtest_vtk_writer.cxx +++ b/test/t8_IO/t8_gtest_vtk_writer.cxx @@ -78,7 +78,7 @@ destroy_grid (t8_forest_t *forest) } template -int +static int use_c_interface (const grid_t grid, 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 write_ghosts, const int num_data, t8_vtk_data_field_t *data, sc_MPI_Comm comm); From d7dae9b517e6593834e775312e6754bdda7f56e4 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 7 Aug 2024 11:08:39 +0200 Subject: [PATCH 44/87] Rename file and adapt includes to the new filename --- benchmarks/ExtremeScaling/bunny.cxx | 2 +- benchmarks/time_forest_partition.cxx | 2 +- benchmarks/time_partition.cxx | 2 +- example/IO/cmesh/gmsh/t8_read_msh_file.cxx | 2 +- example/IO/cmesh/t8_cmesh_load_save.cxx | 2 +- example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx | 2 +- example/IO/cmesh/tetgen/t8_read_tetgen_file.cxx | 2 +- example/IO/cmesh/triangle/t8_read_triangle_file.cxx | 3 ++- example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx | 2 +- example/advect/t8_advection.cxx | 2 +- example/cmesh/t8_cmesh_create_partitioned.cxx | 2 +- example/cmesh/t8_cmesh_geometry_examples.cxx | 2 +- example/cmesh/t8_cmesh_hypercube_pad.cxx | 3 +-- example/cmesh/t8_cmesh_partition.cxx | 2 +- example/forest/t8_test_face_iterate.cxx | 2 +- example/forest/t8_test_ghost.cxx | 2 +- example/forest/t8_test_ghost_large_level_diff.cxx | 2 +- src/Makefile.am | 2 +- src/t8_forest/t8_forest.cxx | 2 +- .../{t8_vtk_writer_c_interface.h => t8_vtk_writer.h} | 0 src/t8_vtk/t8_vtk_writer_c_interface.cxx | 2 +- test/t8_IO/t8_gtest_vtk_writer.cxx | 2 +- .../t8_geometry_implementations/t8_gtest_geometry_cad.cxx | 3 +-- .../t8_gtest_geometry_lagrange.cxx | 2 +- tutorials/general/t8_step1_coarsemesh.cxx | 8 ++++---- tutorials/general/t8_tutorial_build_cmesh.cxx | 2 +- 26 files changed, 29 insertions(+), 30 deletions(-) rename src/t8_vtk/{t8_vtk_writer_c_interface.h => t8_vtk_writer.h} (100%) diff --git a/benchmarks/ExtremeScaling/bunny.cxx b/benchmarks/ExtremeScaling/bunny.cxx index 622f6c65c3..25a53a3f9c 100644 --- a/benchmarks/ExtremeScaling/bunny.cxx +++ b/benchmarks/ExtremeScaling/bunny.cxx @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include diff --git a/benchmarks/time_forest_partition.cxx b/benchmarks/time_forest_partition.cxx index 2ff943cccd..a8a11a0b0d 100644 --- a/benchmarks/time_forest_partition.cxx +++ b/benchmarks/time_forest_partition.cxx @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include diff --git a/benchmarks/time_partition.cxx b/benchmarks/time_partition.cxx index c6d608c051..0a37576257 100644 --- a/benchmarks/time_partition.cxx +++ b/benchmarks/time_partition.cxx @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include "t8_cmesh/t8_cmesh_types.h" diff --git a/example/IO/cmesh/gmsh/t8_read_msh_file.cxx b/example/IO/cmesh/gmsh/t8_read_msh_file.cxx index 4de9119624..48616cf92f 100644 --- a/example/IO/cmesh/gmsh/t8_read_msh_file.cxx +++ b/example/IO/cmesh/gmsh/t8_read_msh_file.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/example/IO/cmesh/t8_cmesh_load_save.cxx b/example/IO/cmesh/t8_cmesh_load_save.cxx index 6059063fb8..c4d2aa8a5d 100644 --- a/example/IO/cmesh/t8_cmesh_load_save.cxx +++ b/example/IO/cmesh/t8_cmesh_load_save.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx b/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx index d667f0bdb7..b6a86273c7 100644 --- a/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx +++ b/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/example/IO/cmesh/tetgen/t8_read_tetgen_file.cxx b/example/IO/cmesh/tetgen/t8_read_tetgen_file.cxx index 628300ff51..4089c31dac 100644 --- a/example/IO/cmesh/tetgen/t8_read_tetgen_file.cxx +++ b/example/IO/cmesh/tetgen/t8_read_tetgen_file.cxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include void t8_read_tetgen_file_build_cmesh (const char *prefix, int do_dup, int do_partition) diff --git a/example/IO/cmesh/triangle/t8_read_triangle_file.cxx b/example/IO/cmesh/triangle/t8_read_triangle_file.cxx index e18695cfb2..b1a21c6c08 100644 --- a/example/IO/cmesh/triangle/t8_read_triangle_file.cxx +++ b/example/IO/cmesh/triangle/t8_read_triangle_file.cxx @@ -24,7 +24,8 @@ #include #include #include -#include +#include + #include void 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 6ed3c34b45..05a742f18f 100644 --- a/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx +++ b/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx @@ -17,7 +17,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., */ #include -#include +#include #include #include #include diff --git a/example/advect/t8_advection.cxx b/example/advect/t8_advection.cxx index a2ceccf1f0..e72603eb68 100644 --- a/example/advect/t8_advection.cxx +++ b/example/advect/t8_advection.cxx @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include diff --git a/example/cmesh/t8_cmesh_create_partitioned.cxx b/example/cmesh/t8_cmesh_create_partitioned.cxx index fc5e159dd5..319ab07a5a 100644 --- a/example/cmesh/t8_cmesh_create_partitioned.cxx +++ b/example/cmesh/t8_cmesh_create_partitioned.cxx @@ -20,7 +20,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include +#include /* Create a coarse mesh that is partitioned across two processes * (if mpisize >= 2). diff --git a/example/cmesh/t8_cmesh_geometry_examples.cxx b/example/cmesh/t8_cmesh_geometry_examples.cxx index df4a4cb5ce..40815be59f 100644 --- a/example/cmesh/t8_cmesh_geometry_examples.cxx +++ b/example/cmesh/t8_cmesh_geometry_examples.cxx @@ -27,7 +27,7 @@ #include /* Forest definition and basic interface. */ #include /* Forest-related geometry operations. */ #include /* Default refinement scheme. */ -#include +#include /* Write file in vtu file */ #include #include diff --git a/example/cmesh/t8_cmesh_hypercube_pad.cxx b/example/cmesh/t8_cmesh_hypercube_pad.cxx index 5bcac31666..8e9ca6021b 100644 --- a/example/cmesh/t8_cmesh_hypercube_pad.cxx +++ b/example/cmesh/t8_cmesh_hypercube_pad.cxx @@ -22,12 +22,11 @@ #include #include -#include +#include #include #include #include -#include int main (int argc, char **argv) { diff --git a/example/cmesh/t8_cmesh_partition.cxx b/example/cmesh/t8_cmesh_partition.cxx index 8d7a30faaf..fe2d8d7755 100644 --- a/example/cmesh/t8_cmesh_partition.cxx +++ b/example/cmesh/t8_cmesh_partition.cxx @@ -23,7 +23,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 905894d669..b469afbc0f 100644 --- a/example/forest/t8_test_face_iterate.cxx +++ b/example/forest/t8_test_face_iterate.cxx @@ -33,7 +33,7 @@ #include #include #include -#include +#include typedef struct { diff --git a/example/forest/t8_test_ghost.cxx b/example/forest/t8_test_ghost.cxx index 03cb952ced..63468d9faa 100644 --- a/example/forest/t8_test_ghost.cxx +++ b/example/forest/t8_test_ghost.cxx @@ -30,7 +30,7 @@ #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 2ccaac7c1b..02481ff90a 100644 --- a/example/forest/t8_test_ghost_large_level_diff.cxx +++ b/example/forest/t8_test_ghost_large_level_diff.cxx @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/Makefile.am b/src/Makefile.am index b4b6c6e98d..fea58ebbe0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -80,7 +80,7 @@ libt8_installed_headers_vtk = \ src/t8_vtk/t8_vtk_reader.hxx \ src/t8_vtk/t8_vtk_writer.hxx \ src/t8_vtk/t8_vtk_types.h \ - src/t8_vtk/t8_vtk_writer_c_interface.h + src/t8_vtk/t8_vtk_writer.h libt8_installed_headers_schemes_default = libt8_installed_headers_default_common = libt8_installed_headers_default_vertex = diff --git a/src/t8_forest/t8_forest.cxx b/src/t8_forest/t8_forest.cxx index ecf62eb410..41fb758b67 100644 --- a/src/t8_forest/t8_forest.cxx +++ b/src/t8_forest/t8_forest.cxx @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #if T8_ENABLE_DEBUG #include diff --git a/src/t8_vtk/t8_vtk_writer_c_interface.h b/src/t8_vtk/t8_vtk_writer.h similarity index 100% rename from src/t8_vtk/t8_vtk_writer_c_interface.h rename to src/t8_vtk/t8_vtk_writer.h diff --git a/src/t8_vtk/t8_vtk_writer_c_interface.cxx b/src/t8_vtk/t8_vtk_writer_c_interface.cxx index 37e7322507..9bbb942498 100644 --- a/src/t8_vtk/t8_vtk_writer_c_interface.cxx +++ b/src/t8_vtk/t8_vtk_writer_c_interface.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 +#include #include #include #include diff --git a/test/t8_IO/t8_gtest_vtk_writer.cxx b/test/t8_IO/t8_gtest_vtk_writer.cxx index 6d2a9ec153..61ec42f6da 100644 --- a/test/t8_IO/t8_gtest_vtk_writer.cxx +++ b/test/t8_IO/t8_gtest_vtk_writer.cxx @@ -26,7 +26,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include -#include +#include /** * Create a hybrid forest or a cmesh diff --git a/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_cad.cxx b/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_cad.cxx index ef2d465ac8..843a6a74d6 100644 --- a/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_cad.cxx +++ b/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_cad.cxx @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include @@ -49,7 +49,6 @@ #include #include #include -#include #include #endif diff --git a/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_lagrange.cxx b/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_lagrange.cxx index ce80a7538a..7b8cf7e5aa 100644 --- a/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_lagrange.cxx +++ b/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_lagrange.cxx @@ -36,7 +36,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include -#include +#include #include #include diff --git a/tutorials/general/t8_step1_coarsemesh.cxx b/tutorials/general/t8_step1_coarsemesh.cxx index e2f524f756..8723922c89 100644 --- a/tutorials/general/t8_step1_coarsemesh.cxx +++ b/tutorials/general/t8_step1_coarsemesh.cxx @@ -35,10 +35,10 @@ * from t8_cmesh.h to create a different cmesh. */ -#include /* General t8code header, always include this. */ -#include /* cmesh definition and basic interface. */ -#include /* cmesh-writer interface. */ -#include /* A collection of exemplary cmeshes */ +#include /* General t8code header, always include this. */ +#include /* cmesh definition and basic interface. */ +#include /* cmesh-writer interface. */ +#include /* A collection of exemplary cmeshes */ /* Builds cmesh of 6 tetrahedra that build up a unit cube. * \param [in] comm MPI Communicator to use. diff --git a/tutorials/general/t8_tutorial_build_cmesh.cxx b/tutorials/general/t8_tutorial_build_cmesh.cxx index 1f04db127e..3ca1c67f79 100644 --- a/tutorials/general/t8_tutorial_build_cmesh.cxx +++ b/tutorials/general/t8_tutorial_build_cmesh.cxx @@ -41,7 +41,7 @@ #include /* cmesh definition and basic interface. */ #include /* forest definition and basic interface. */ #include /* default refinement scheme. */ -#include /* write file in vtu file */ +#include /* write file in vtu file */ #include /* linear geometry of the cmesh */ T8_EXTERN_C_BEGIN (); From 2776ef6ba42f31b9fa154ff445213fb3f38e3584 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 7 Aug 2024 11:12:13 +0200 Subject: [PATCH 45/87] Move code to the c++ part --- src/t8_vtk/t8_vtk_writer.cxx | 57 ++++++++++++++++++++++++ src/t8_vtk/t8_vtk_writer_c_interface.cxx | 57 ------------------------ 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/t8_vtk/t8_vtk_writer.cxx b/src/t8_vtk/t8_vtk_writer.cxx index af3fc13107..69a4b9b93d 100644 --- a/src/t8_vtk/t8_vtk_writer.cxx +++ b/src/t8_vtk/t8_vtk_writer.cxx @@ -22,6 +22,10 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include +#if T8_WITH_VTK +#include +#endif + #if T8_WITH_VTK /** * \brief template specialization for forests. @@ -101,3 +105,56 @@ vtk_writer::write_ASCII (const t8_cmesh_t forest) { return t8_cmesh_vtk_write_ASCII (forest, this->fileprefix.c_str ()); } + +T8_EXTERN_C_BEGIN (); + +int +t8_forest_vtk_write_file_via_API (const 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 write_ghosts, const int num_data, + t8_vtk_data_field_t *data) +{ + vtk_writer writer (write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, curved_flag, + std::string (fileprefix), num_data, data, t8_forest_get_mpicomm (forest)); + return writer.write_with_API (forest); +} + +int +t8_forest_vtk_write_file (const t8_forest_t forest, const char *fileprefix, const int write_treeid, + const int write_mpirank, const int write_level, const int write_element_id, int write_ghosts, + const int num_data, t8_vtk_data_field_t *data) +{ + vtk_writer writer (write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, false, + std::string (fileprefix), num_data, data, t8_forest_get_mpicomm (forest)); + return writer.write_ASCII (forest); +} + +int +t8_cmesh_vtk_write_file_via_API (const t8_cmesh_t cmesh, const char *fileprefix, sc_MPI_Comm comm) +{ + vtk_writer writer (std::string (fileprefix), comm); + return writer.write_with_API (cmesh); +} + +int +t8_cmesh_vtk_write_file (const t8_cmesh_t cmesh, const char *fileprefix) +{ + /* No mpi Communicator is needed for ASCII output*/ + vtk_writer writer (std::string (fileprefix), sc_MPI_COMM_NULL); + return writer.write_ASCII (cmesh); +} + +#if T8_WITH_VTK +void +t8_forest_to_vtkUnstructuredGrid (const t8_forest_t forest, vtkSmartPointer unstructuredGrid, + const int write_treeid, const int write_mpirank, const int write_level, + const int write_element_id, const int write_ghosts, const int curved_flag, + const int num_data, t8_vtk_data_field_t *data) +{ + vtk_writer writer (write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, curved_flag, + std::string (""), num_data, data, t8_forest_get_mpicomm (forest)); + writer.grid_to_vtkUnstructuredGrid (forest, unstructuredGrid); +} +#endif + +T8_EXTERN_C_END (); diff --git a/src/t8_vtk/t8_vtk_writer_c_interface.cxx b/src/t8_vtk/t8_vtk_writer_c_interface.cxx index 9bbb942498..b38b401c1b 100644 --- a/src/t8_vtk/t8_vtk_writer_c_interface.cxx +++ b/src/t8_vtk/t8_vtk_writer_c_interface.cxx @@ -25,60 +25,3 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include - -#if T8_WITH_VTK -#include -#endif - -T8_EXTERN_C_BEGIN (); - -int -t8_forest_vtk_write_file_via_API (const 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 write_ghosts, const int num_data, - t8_vtk_data_field_t *data) -{ - vtk_writer writer (write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, curved_flag, - std::string (fileprefix), num_data, data, t8_forest_get_mpicomm (forest)); - return writer.write_with_API (forest); -} - -int -t8_forest_vtk_write_file (const t8_forest_t forest, const char *fileprefix, const int write_treeid, - const int write_mpirank, const int write_level, const int write_element_id, int write_ghosts, - const int num_data, t8_vtk_data_field_t *data) -{ - vtk_writer writer (write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, false, - std::string (fileprefix), num_data, data, t8_forest_get_mpicomm (forest)); - return writer.write_ASCII (forest); -} - -int -t8_cmesh_vtk_write_file_via_API (const t8_cmesh_t cmesh, const char *fileprefix, sc_MPI_Comm comm) -{ - vtk_writer writer (std::string (fileprefix), comm); - return writer.write_with_API (cmesh); -} - -int -t8_cmesh_vtk_write_file (const t8_cmesh_t cmesh, const char *fileprefix) -{ - /* No mpi Communicator is needed for ASCII output*/ - vtk_writer writer (std::string (fileprefix), sc_MPI_COMM_NULL); - return writer.write_ASCII (cmesh); -} - -#if T8_WITH_VTK -void -t8_forest_to_vtkUnstructuredGrid (const t8_forest_t forest, vtkSmartPointer unstructuredGrid, - const int write_treeid, const int write_mpirank, const int write_level, - const int write_element_id, const int write_ghosts, const int curved_flag, - const int num_data, t8_vtk_data_field_t *data) -{ - vtk_writer writer (write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, curved_flag, - std::string (""), num_data, data, t8_forest_get_mpicomm (forest)); - writer.grid_to_vtkUnstructuredGrid (forest, unstructuredGrid); -} -#endif - -T8_EXTERN_C_END (); From 2cac782828477b590cefb23d36cd0d947dd5c5ef Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 7 Aug 2024 11:26:03 +0200 Subject: [PATCH 46/87] adapt makefile and add comments --- src/Makefile.am | 1 - src/t8_vtk/t8_vtk_writer.cxx | 1 + src/t8_vtk/t8_vtk_writer_c_interface.cxx | 27 ------------------------ 3 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 src/t8_vtk/t8_vtk_writer_c_interface.cxx diff --git a/src/Makefile.am b/src/Makefile.am index fea58ebbe0..1079fe8f21 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -148,7 +148,6 @@ libt8_compiled_sources = \ src/t8_vtk/t8_vtk_parallel.cxx \ src/t8_vtk/t8_vtk_reader.cxx \ src/t8_vtk/t8_vtk_writer.cxx \ - src/t8_vtk/t8_vtk_writer_c_interface.cxx \ src/t8_vtk/t8_vtk_write_ASCII.cxx \ src/t8_vtk/t8_vtk_writer_helper.cxx diff --git a/src/t8_vtk/t8_vtk_writer.cxx b/src/t8_vtk/t8_vtk_writer.cxx index 69a4b9b93d..69165eee20 100644 --- a/src/t8_vtk/t8_vtk_writer.cxx +++ b/src/t8_vtk/t8_vtk_writer.cxx @@ -106,6 +106,7 @@ vtk_writer::write_ASCII (const t8_cmesh_t forest) return t8_cmesh_vtk_write_ASCII (forest, this->fileprefix.c_str ()); } +/* Implementation of the c-interface */ T8_EXTERN_C_BEGIN (); int diff --git a/src/t8_vtk/t8_vtk_writer_c_interface.cxx b/src/t8_vtk/t8_vtk_writer_c_interface.cxx deleted file mode 100644 index b38b401c1b..0000000000 --- a/src/t8_vtk/t8_vtk_writer_c_interface.cxx +++ /dev/null @@ -1,27 +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) 2024 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 From e1500eeff7527e0dc335ef1014e5f14d73b77c8b Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 7 Aug 2024 12:43:24 +0200 Subject: [PATCH 47/87] use true-false instead of 0-1 logic in implementation --- src/t8_vtk/t8_vtk_write_ASCII.cxx | 114 ++++++++++++++--------------- src/t8_vtk/t8_vtk_write_ASCII.hxx | 4 +- src/t8_vtk/t8_vtk_writer.cxx | 3 +- test/t8_IO/t8_gtest_vtk_writer.cxx | 2 +- 4 files changed, 61 insertions(+), 62 deletions(-) diff --git a/src/t8_vtk/t8_vtk_write_ASCII.cxx b/src/t8_vtk/t8_vtk_write_ASCII.cxx index 05359a4bd4..2dba2c9cab 100644 --- a/src/t8_vtk/t8_vtk_write_ASCII.cxx +++ b/src/t8_vtk/t8_vtk_write_ASCII.cxx @@ -74,10 +74,10 @@ typedef enum { T8_VTK_KERNEL_INIT, T8_VTK_KERNEL_EXECUTE, T8_VTK_KERNEL_CLEANUP * \param [in] modus The modus in which the callback is called. See above. * \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, 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); +typedef bool (*t8_forest_vtk_cell_data_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); static t8_locidx_t t8_forest_num_points (t8_forest_t forest, const int count_ghosts) @@ -114,7 +114,7 @@ t8_forest_num_points (t8_forest_t forest, const int count_ghosts) return num_points; } -static int +static bool 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, const int is_ghost, FILE *vtufile, int *columns, @@ -127,7 +127,7 @@ t8_forest_vtk_cells_vertices_kernel (t8_forest_t forest, const t8_locidx_t ltree if (modus != T8_VTK_KERNEL_EXECUTE) { /* Nothing to do if we are in Init or clean up mode */ - return 1; + return true; } /* TODO: be careful with pyramid class here. @@ -141,7 +141,7 @@ t8_forest_vtk_cells_vertices_kernel (t8_forest_t forest, const t8_locidx_t ltree t8_forest_element_from_ref_coords (forest, ltree_id, element, ref_coords, 1, element_coordinates); freturn = fprintf (vtufile, " "); if (freturn <= 0) { - return 0; + return false; } #ifdef T8_VTK_DOUBLES freturn = fprintf (vtufile, " %24.16e %24.16e %24.16e\n", element_coordinates[0], element_coordinates[1], @@ -151,16 +151,16 @@ t8_forest_vtk_cells_vertices_kernel (t8_forest_t forest, const t8_locidx_t ltree element_coordinates[2]); #endif if (freturn <= 0) { - return 0; + return false; } /* We switch of the column control of the surrounding function * by keeping the columns value constant. */ *columns = 1; } - return 1; + return true; } -static int +static bool t8_forest_vtk_cells_connectivity_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, @@ -174,11 +174,11 @@ t8_forest_vtk_cells_connectivity_kernel (t8_forest_t forest, const t8_locidx_t l if (modus == T8_VTK_KERNEL_INIT) { /* We use data to count the number of written vertices */ *data = T8_ALLOC_ZERO (t8_locidx_t, 1); - return 1; + return true; } else if (modus == T8_VTK_KERNEL_CLEANUP) { T8_FREE (*data); - return 1; + return true; } T8_ASSERT (modus == T8_VTK_KERNEL_EXECUTE); @@ -188,14 +188,14 @@ t8_forest_vtk_cells_connectivity_kernel (t8_forest_t forest, const t8_locidx_t l for (ivertex = 0; ivertex < num_vertices; ++ivertex, (*count_vertices)++) { freturn = fprintf (vtufile, " %ld", (long) *count_vertices); if (freturn <= 0) { - return 0; + return false; } } *columns += t8_eclass_num_vertices[element_shape]; - return 1; + return true; } -static int +static bool 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, @@ -225,10 +225,10 @@ t8_forest_vtk_cells_offset_kernel (t8_forest_t forest, const t8_locidx_t ltree_i } *columns += 1; - return 1; + return true; } -static int +static bool 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, @@ -243,10 +243,10 @@ t8_forest_vtk_cells_type_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, } *columns += 1; } - return 1; + return true; } -static int +static bool t8_forest_vtk_cells_level_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, @@ -256,10 +256,10 @@ t8_forest_vtk_cells_level_kernel (t8_forest_t forest, const t8_locidx_t ltree_id fprintf (vtufile, "%i ", ts->t8_element_level (element)); *columns += 1; } - return 1; + return true; } -static int +static bool t8_forest_vtk_cells_rank_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, @@ -269,10 +269,10 @@ t8_forest_vtk_cells_rank_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, fprintf (vtufile, "%i ", forest->mpirank); *columns += 1; } - return 1; + return true; } -static int +static bool t8_forest_vtk_cells_treeid_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, @@ -291,10 +291,10 @@ t8_forest_vtk_cells_treeid_kernel (t8_forest_t forest, const t8_locidx_t ltree_i fprintf (vtufile, "%lli ", tree_id); *columns += 1; } - return 1; + return true; } -static int +static bool t8_forest_vtk_cells_elementid_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, @@ -310,10 +310,10 @@ t8_forest_vtk_cells_elementid_kernel (t8_forest_t forest, const t8_locidx_t ltre } *columns += 1; } - return 1; + return true; } -static int +static bool t8_forest_vtk_cells_scalar_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, @@ -334,10 +334,10 @@ t8_forest_vtk_cells_scalar_kernel (t8_forest_t forest, const t8_locidx_t ltree_i fprintf (vtufile, "%g ", element_value); *columns += 1; } - return 1; + return true; } -static int +static bool t8_forest_vtk_cells_vector_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, @@ -364,11 +364,11 @@ t8_forest_vtk_cells_vector_kernel (t8_forest_t forest, const t8_locidx_t ltree_i } *columns += dim; } - return 1; + return true; } /* The point data version of the scalar kernel */ -static int +static bool t8_forest_vtk_vertices_scalar_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, @@ -394,11 +394,11 @@ t8_forest_vtk_vertices_scalar_kernel (t8_forest_t forest, const t8_locidx_t ltre *columns += 1; } } - return 1; + return true; } /* The point data version of the vector kernel */ -static int +static bool t8_forest_vtk_vertices_vector_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, @@ -429,12 +429,12 @@ t8_forest_vtk_vertices_vector_kernel (t8_forest_t forest, const t8_locidx_t ltre *columns += dim; } } - return 1; + return true; } /* Iterate over all cells and write cell data to the file using * the cell_data_kernel as callback */ -static int +static bool t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *dataname, const char *datatype, const char *component_string, const int max_columns, t8_forest_vtk_cell_data_kernel kernel, const int write_ghosts, void *udata) @@ -456,7 +456,7 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da "Name=\"%s\" %s format=\"ascii\">\n ", datatype, dataname, component_string); if (freturn <= 0) { - return 0; + return false; } /* if udata != NULL, use it as the data pointer, in this case, the kernel @@ -487,7 +487,7 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da T8_VTK_KERNEL_EXECUTE)) { /* call the kernel in clean-up modus */ kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return 0; + return false; } /* After max_columns we break the line */ if (!(countcols % max_columns)) { @@ -495,14 +495,14 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da if (freturn <= 0) { /* call the kernel in clean-up modus */ kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return 0; + return false; } } } /* element loop ends here */ if (freturn <= 0) { /* call the kernel in clean-up modus */ kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return 0; + return false; } } /* tree loop ends here */ @@ -524,7 +524,7 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da T8_VTK_KERNEL_EXECUTE)) { /* call the kernel in clean-up modus */ kernel (NULL, 0, NULL, 0, NULL, NULL, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return 0; + return false; } /* After max_columns we break the line */ if (!(countcols % max_columns)) { @@ -532,14 +532,14 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da if (freturn <= 0) { /* call the kernel in clean-up modus */ kernel (NULL, 0, NULL, 0, NULL, NULL, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return 0; + return false; } } } /* element loop ends here */ if (freturn <= 0) { /* call the kernel in clean-up modus */ kernel (NULL, 0, NULL, 0, NULL, NULL, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return 0; + return false; } } /* ghost loop ends here */ } /* write_ghosts ends here */ @@ -547,17 +547,17 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); freturn = fprintf (vtufile, "\n \n"); if (freturn <= 0) { - return 0; + return false; } - return 1; + return true; } /* Write the cell data to an open file stream. * Returns true on success and zero otherwise. * After completion the file will remain open, whether writing * cells was successful or not. */ -static int +static bool t8_forest_vtk_write_cells (t8_forest_t forest, FILE *vtufile, 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) @@ -687,18 +687,18 @@ t8_forest_vtk_write_cells (t8_forest_t forest, FILE *vtufile, const int write_tr } /* Function completed successfully */ - return 1; + return true; t8_forest_vtk_cell_failure: /* Something went wrong */ t8_errorf ("Error when writing cell data to forest vtk file.\n"); - return 0; + return false; } /* Write the cell data to an open file stream. * Returns true on success and zero otherwise. * After completion the file will remain open, whether writing * cells was successful or not. */ -static int +static bool t8_forest_vtk_write_points (t8_forest_t forest, FILE *vtufile, const int write_ghosts, const int num_data, t8_vtk_data_field_t *data) { @@ -767,14 +767,14 @@ t8_forest_vtk_write_points (t8_forest_t forest, FILE *vtufile, const int write_g freturn = fprintf (vtufile, " \n"); } /* Function completed successfully */ - return 1; + return true; t8_forest_vtk_cell_failure: /* Something went wrong */ t8_errorf ("Error when writing cell data to forest vtk file.\n"); - return 0; + return false; } -int +bool t8_forest_vtk_write_ASCII (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, int write_ghosts, const int num_data, t8_vtk_data_field_t *data) @@ -880,13 +880,13 @@ t8_forest_vtk_write_ASCII (t8_forest_t forest, const char *fileprefix, const int goto t8_forest_vtk_failure; } /* Writing was successful */ - return 1; + return true; t8_forest_vtk_failure: if (vtufile != NULL) { fclose (vtufile); } t8_errorf ("Error when writing vtk file.\n"); - return 0; + return false; } /* Return the local number of vertices in a cmesh. @@ -919,7 +919,7 @@ t8_cmesh_get_num_vertices (const t8_cmesh_t cmesh, const int count_ghosts) return num_vertices; } -static int +static bool t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, const int write_ghosts) { T8_ASSERT (cmesh != NULL); @@ -961,7 +961,7 @@ t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, con vtufile = fopen (vtufilename, "wb"); if (vtufile == NULL) { t8_global_errorf ("Could not open file %s for output.\n", vtufilename); - return -1; + return false; } fprintf (vtufile, "\n"); fprintf (vtufile, "\n"); fclose (vtufile); } - return 0; + return true; } -int +bool t8_cmesh_vtk_write_ASCII (const t8_cmesh_t cmesh, const char *fileprefix) { return t8_cmesh_vtk_write_file_ext (cmesh, fileprefix, 1); diff --git a/src/t8_vtk/t8_vtk_write_ASCII.hxx b/src/t8_vtk/t8_vtk_write_ASCII.hxx index 114e32b868..5ed0de95cc 100644 --- a/src/t8_vtk/t8_vtk_write_ASCII.hxx +++ b/src/t8_vtk/t8_vtk_write_ASCII.hxx @@ -46,12 +46,12 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * must come first in the array. * \return True if successful, false if not (process local). */ -int +bool t8_forest_vtk_write_ASCII (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, int write_ghosts, const int num_data, t8_vtk_data_field_t *data); -int +bool t8_cmesh_vtk_write_ASCII (t8_cmesh_t cmesh, const char *fileprefix); #endif /* T8_VTK_WRITE_ASCII_HXX */ diff --git a/src/t8_vtk/t8_vtk_writer.cxx b/src/t8_vtk/t8_vtk_writer.cxx index 69165eee20..5ad3a79f45 100644 --- a/src/t8_vtk/t8_vtk_writer.cxx +++ b/src/t8_vtk/t8_vtk_writer.cxx @@ -67,8 +67,6 @@ vtk_writer::t8_grid_tree_to_vtk_cells ( return; } -#endif /* T8_WITH_VTK */ - /** * \brief template specialization for cmeshes. * @@ -89,6 +87,7 @@ vtk_writer::t8_grid_tree_to_vtk_cells ( (*elem_id)++; return; } +#endif /* T8_WITH_VTK */ template <> bool diff --git a/test/t8_IO/t8_gtest_vtk_writer.cxx b/test/t8_IO/t8_gtest_vtk_writer.cxx index 61ec42f6da..68195037ac 100644 --- a/test/t8_IO/t8_gtest_vtk_writer.cxx +++ b/test/t8_IO/t8_gtest_vtk_writer.cxx @@ -95,7 +95,7 @@ use_c_interface (const t8_forest_t grid, const char *fileprefix, co curved_flag, write_ghosts, num_data, data); #else return t8_forest_vtk_write_file (grid, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, - curved_flag, write_ghosts, num_data, data); + write_ghosts, num_data, data); #endif } From c24f637a1c8bc217a82f3c533f3c6f8f06d3ec9b Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 7 Aug 2024 13:27:52 +0200 Subject: [PATCH 48/87] update missing function --- src/t8_vtk/t8_vtk_write_ASCII.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/t8_vtk/t8_vtk_write_ASCII.cxx b/src/t8_vtk/t8_vtk_write_ASCII.cxx index 2dba2c9cab..3226511140 100644 --- a/src/t8_vtk/t8_vtk_write_ASCII.cxx +++ b/src/t8_vtk/t8_vtk_write_ASCII.cxx @@ -207,11 +207,11 @@ t8_forest_vtk_cells_offset_kernel (t8_forest_t forest, const t8_locidx_t ltree_i if (modus == T8_VTK_KERNEL_INIT) { *data = T8_ALLOC_ZERO (long long, 1); - return 1; + return true; } else if (modus == T8_VTK_KERNEL_CLEANUP) { T8_FREE (*data); - return 1; + return true; } T8_ASSERT (modus == T8_VTK_KERNEL_EXECUTE); @@ -221,7 +221,7 @@ t8_forest_vtk_cells_offset_kernel (t8_forest_t forest, const t8_locidx_t ltree_i *offset += num_vertices; freturn = fprintf (vtufile, " %lld", *offset); if (freturn <= 0) { - return 0; + return false; } *columns += 1; From c2c2ac1d300965df8b4a61435d3bb87b30e930c3 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 7 Aug 2024 14:26:07 +0200 Subject: [PATCH 49/87] Revert "use true-false instead of 0-1 logic in implementation" This reverts commit e1500eeff7527e0dc335ef1014e5f14d73b77c8b. --- src/t8_vtk/t8_vtk_write_ASCII.cxx | 114 ++++++++++++++--------------- src/t8_vtk/t8_vtk_write_ASCII.hxx | 4 +- src/t8_vtk/t8_vtk_writer.cxx | 3 +- test/t8_IO/t8_gtest_vtk_writer.cxx | 2 +- 4 files changed, 62 insertions(+), 61 deletions(-) diff --git a/src/t8_vtk/t8_vtk_write_ASCII.cxx b/src/t8_vtk/t8_vtk_write_ASCII.cxx index 3226511140..bc8351a5d5 100644 --- a/src/t8_vtk/t8_vtk_write_ASCII.cxx +++ b/src/t8_vtk/t8_vtk_write_ASCII.cxx @@ -74,10 +74,10 @@ typedef enum { T8_VTK_KERNEL_INIT, T8_VTK_KERNEL_EXECUTE, T8_VTK_KERNEL_CLEANUP * \param [in] modus The modus in which the callback is called. See above. * \return True if successful, false if not (i.e. file i/o error). */ -typedef bool (*t8_forest_vtk_cell_data_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); +typedef int (*t8_forest_vtk_cell_data_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); static t8_locidx_t t8_forest_num_points (t8_forest_t forest, const int count_ghosts) @@ -114,7 +114,7 @@ t8_forest_num_points (t8_forest_t forest, const int count_ghosts) return num_points; } -static bool +static int 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, const int is_ghost, FILE *vtufile, int *columns, @@ -127,7 +127,7 @@ t8_forest_vtk_cells_vertices_kernel (t8_forest_t forest, const t8_locidx_t ltree if (modus != T8_VTK_KERNEL_EXECUTE) { /* Nothing to do if we are in Init or clean up mode */ - return true; + return 1; } /* TODO: be careful with pyramid class here. @@ -141,7 +141,7 @@ t8_forest_vtk_cells_vertices_kernel (t8_forest_t forest, const t8_locidx_t ltree t8_forest_element_from_ref_coords (forest, ltree_id, element, ref_coords, 1, element_coordinates); freturn = fprintf (vtufile, " "); if (freturn <= 0) { - return false; + return 0; } #ifdef T8_VTK_DOUBLES freturn = fprintf (vtufile, " %24.16e %24.16e %24.16e\n", element_coordinates[0], element_coordinates[1], @@ -151,16 +151,16 @@ t8_forest_vtk_cells_vertices_kernel (t8_forest_t forest, const t8_locidx_t ltree element_coordinates[2]); #endif if (freturn <= 0) { - return false; + return 0; } /* We switch of the column control of the surrounding function * by keeping the columns value constant. */ *columns = 1; } - return true; + return 1; } -static bool +static int t8_forest_vtk_cells_connectivity_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, @@ -174,11 +174,11 @@ t8_forest_vtk_cells_connectivity_kernel (t8_forest_t forest, const t8_locidx_t l if (modus == T8_VTK_KERNEL_INIT) { /* We use data to count the number of written vertices */ *data = T8_ALLOC_ZERO (t8_locidx_t, 1); - return true; + return 1; } else if (modus == T8_VTK_KERNEL_CLEANUP) { T8_FREE (*data); - return true; + return 1; } T8_ASSERT (modus == T8_VTK_KERNEL_EXECUTE); @@ -188,14 +188,14 @@ t8_forest_vtk_cells_connectivity_kernel (t8_forest_t forest, const t8_locidx_t l for (ivertex = 0; ivertex < num_vertices; ++ivertex, (*count_vertices)++) { freturn = fprintf (vtufile, " %ld", (long) *count_vertices); if (freturn <= 0) { - return false; + return 0; } } *columns += t8_eclass_num_vertices[element_shape]; - return true; + return 1; } -static bool +static int 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, @@ -225,10 +225,10 @@ t8_forest_vtk_cells_offset_kernel (t8_forest_t forest, const t8_locidx_t ltree_i } *columns += 1; - return true; + return 1; } -static bool +static int 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, @@ -243,10 +243,10 @@ t8_forest_vtk_cells_type_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, } *columns += 1; } - return true; + return 1; } -static bool +static int t8_forest_vtk_cells_level_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, @@ -256,10 +256,10 @@ t8_forest_vtk_cells_level_kernel (t8_forest_t forest, const t8_locidx_t ltree_id fprintf (vtufile, "%i ", ts->t8_element_level (element)); *columns += 1; } - return true; + return 1; } -static bool +static int t8_forest_vtk_cells_rank_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, @@ -269,10 +269,10 @@ t8_forest_vtk_cells_rank_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, fprintf (vtufile, "%i ", forest->mpirank); *columns += 1; } - return true; + return 1; } -static bool +static int t8_forest_vtk_cells_treeid_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, @@ -291,10 +291,10 @@ t8_forest_vtk_cells_treeid_kernel (t8_forest_t forest, const t8_locidx_t ltree_i fprintf (vtufile, "%lli ", tree_id); *columns += 1; } - return true; + return 1; } -static bool +static int t8_forest_vtk_cells_elementid_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, @@ -310,10 +310,10 @@ t8_forest_vtk_cells_elementid_kernel (t8_forest_t forest, const t8_locidx_t ltre } *columns += 1; } - return true; + return 1; } -static bool +static int t8_forest_vtk_cells_scalar_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, @@ -334,10 +334,10 @@ t8_forest_vtk_cells_scalar_kernel (t8_forest_t forest, const t8_locidx_t ltree_i fprintf (vtufile, "%g ", element_value); *columns += 1; } - return true; + return 1; } -static bool +static int t8_forest_vtk_cells_vector_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, @@ -364,11 +364,11 @@ t8_forest_vtk_cells_vector_kernel (t8_forest_t forest, const t8_locidx_t ltree_i } *columns += dim; } - return true; + return 1; } /* The point data version of the scalar kernel */ -static bool +static int t8_forest_vtk_vertices_scalar_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, @@ -394,11 +394,11 @@ t8_forest_vtk_vertices_scalar_kernel (t8_forest_t forest, const t8_locidx_t ltre *columns += 1; } } - return true; + return 1; } /* The point data version of the vector kernel */ -static bool +static int t8_forest_vtk_vertices_vector_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, @@ -429,12 +429,12 @@ t8_forest_vtk_vertices_vector_kernel (t8_forest_t forest, const t8_locidx_t ltre *columns += dim; } } - return true; + return 1; } /* Iterate over all cells and write cell data to the file using * the cell_data_kernel as callback */ -static bool +static int t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *dataname, const char *datatype, const char *component_string, const int max_columns, t8_forest_vtk_cell_data_kernel kernel, const int write_ghosts, void *udata) @@ -456,7 +456,7 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da "Name=\"%s\" %s format=\"ascii\">\n ", datatype, dataname, component_string); if (freturn <= 0) { - return false; + return 0; } /* if udata != NULL, use it as the data pointer, in this case, the kernel @@ -487,7 +487,7 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da T8_VTK_KERNEL_EXECUTE)) { /* call the kernel in clean-up modus */ kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return false; + return 0; } /* After max_columns we break the line */ if (!(countcols % max_columns)) { @@ -495,14 +495,14 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da if (freturn <= 0) { /* call the kernel in clean-up modus */ kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return false; + return 0; } } } /* element loop ends here */ if (freturn <= 0) { /* call the kernel in clean-up modus */ kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return false; + return 0; } } /* tree loop ends here */ @@ -524,7 +524,7 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da T8_VTK_KERNEL_EXECUTE)) { /* call the kernel in clean-up modus */ kernel (NULL, 0, NULL, 0, NULL, NULL, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return false; + return 0; } /* After max_columns we break the line */ if (!(countcols % max_columns)) { @@ -532,14 +532,14 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da if (freturn <= 0) { /* call the kernel in clean-up modus */ kernel (NULL, 0, NULL, 0, NULL, NULL, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return false; + return 0; } } } /* element loop ends here */ if (freturn <= 0) { /* call the kernel in clean-up modus */ kernel (NULL, 0, NULL, 0, NULL, NULL, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); - return false; + return 0; } } /* ghost loop ends here */ } /* write_ghosts ends here */ @@ -547,17 +547,17 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); freturn = fprintf (vtufile, "\n \n"); if (freturn <= 0) { - return false; + return 0; } - return true; + return 1; } /* Write the cell data to an open file stream. * Returns true on success and zero otherwise. * After completion the file will remain open, whether writing * cells was successful or not. */ -static bool +static int t8_forest_vtk_write_cells (t8_forest_t forest, FILE *vtufile, 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) @@ -687,18 +687,18 @@ t8_forest_vtk_write_cells (t8_forest_t forest, FILE *vtufile, const int write_tr } /* Function completed successfully */ - return true; + return 1; t8_forest_vtk_cell_failure: /* Something went wrong */ t8_errorf ("Error when writing cell data to forest vtk file.\n"); - return false; + return 0; } /* Write the cell data to an open file stream. * Returns true on success and zero otherwise. * After completion the file will remain open, whether writing * cells was successful or not. */ -static bool +static int t8_forest_vtk_write_points (t8_forest_t forest, FILE *vtufile, const int write_ghosts, const int num_data, t8_vtk_data_field_t *data) { @@ -767,14 +767,14 @@ t8_forest_vtk_write_points (t8_forest_t forest, FILE *vtufile, const int write_g freturn = fprintf (vtufile, " \n"); } /* Function completed successfully */ - return true; + return 1; t8_forest_vtk_cell_failure: /* Something went wrong */ t8_errorf ("Error when writing cell data to forest vtk file.\n"); - return false; + return 0; } -bool +int t8_forest_vtk_write_ASCII (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, int write_ghosts, const int num_data, t8_vtk_data_field_t *data) @@ -880,13 +880,13 @@ t8_forest_vtk_write_ASCII (t8_forest_t forest, const char *fileprefix, const int goto t8_forest_vtk_failure; } /* Writing was successful */ - return true; + return 1; t8_forest_vtk_failure: if (vtufile != NULL) { fclose (vtufile); } t8_errorf ("Error when writing vtk file.\n"); - return false; + return 0; } /* Return the local number of vertices in a cmesh. @@ -919,7 +919,7 @@ t8_cmesh_get_num_vertices (const t8_cmesh_t cmesh, const int count_ghosts) return num_vertices; } -static bool +static int t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, const int write_ghosts) { T8_ASSERT (cmesh != NULL); @@ -961,7 +961,7 @@ t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, con vtufile = fopen (vtufilename, "wb"); if (vtufile == NULL) { t8_global_errorf ("Could not open file %s for output.\n", vtufilename); - return false; + return -1; } fprintf (vtufile, "\n"); fprintf (vtufile, "\n"); fclose (vtufile); } - return true; + return 0; } -bool +int t8_cmesh_vtk_write_ASCII (const t8_cmesh_t cmesh, const char *fileprefix) { return t8_cmesh_vtk_write_file_ext (cmesh, fileprefix, 1); diff --git a/src/t8_vtk/t8_vtk_write_ASCII.hxx b/src/t8_vtk/t8_vtk_write_ASCII.hxx index 5ed0de95cc..114e32b868 100644 --- a/src/t8_vtk/t8_vtk_write_ASCII.hxx +++ b/src/t8_vtk/t8_vtk_write_ASCII.hxx @@ -46,12 +46,12 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * must come first in the array. * \return True if successful, false if not (process local). */ -bool +int t8_forest_vtk_write_ASCII (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, int write_ghosts, const int num_data, t8_vtk_data_field_t *data); -bool +int t8_cmesh_vtk_write_ASCII (t8_cmesh_t cmesh, const char *fileprefix); #endif /* T8_VTK_WRITE_ASCII_HXX */ diff --git a/src/t8_vtk/t8_vtk_writer.cxx b/src/t8_vtk/t8_vtk_writer.cxx index 5ad3a79f45..69165eee20 100644 --- a/src/t8_vtk/t8_vtk_writer.cxx +++ b/src/t8_vtk/t8_vtk_writer.cxx @@ -67,6 +67,8 @@ vtk_writer::t8_grid_tree_to_vtk_cells ( return; } +#endif /* T8_WITH_VTK */ + /** * \brief template specialization for cmeshes. * @@ -87,7 +89,6 @@ vtk_writer::t8_grid_tree_to_vtk_cells ( (*elem_id)++; return; } -#endif /* T8_WITH_VTK */ template <> bool diff --git a/test/t8_IO/t8_gtest_vtk_writer.cxx b/test/t8_IO/t8_gtest_vtk_writer.cxx index 68195037ac..61ec42f6da 100644 --- a/test/t8_IO/t8_gtest_vtk_writer.cxx +++ b/test/t8_IO/t8_gtest_vtk_writer.cxx @@ -95,7 +95,7 @@ use_c_interface (const t8_forest_t grid, const char *fileprefix, co curved_flag, write_ghosts, num_data, data); #else return t8_forest_vtk_write_file (grid, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, - write_ghosts, num_data, data); + curved_flag, write_ghosts, num_data, data); #endif } From 3e75209287040ff9d74a8781c60b7cf85d4a77db Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 7 Aug 2024 14:33:25 +0200 Subject: [PATCH 50/87] update return values --- src/t8_vtk/t8_vtk_write_ASCII.cxx | 4 ++-- src/t8_vtk/t8_vtk_writer.cxx | 3 +-- test/t8_IO/t8_gtest_vtk_writer.cxx | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/t8_vtk/t8_vtk_write_ASCII.cxx b/src/t8_vtk/t8_vtk_write_ASCII.cxx index bc8351a5d5..e9afd23698 100644 --- a/src/t8_vtk/t8_vtk_write_ASCII.cxx +++ b/src/t8_vtk/t8_vtk_write_ASCII.cxx @@ -961,7 +961,7 @@ t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, con vtufile = fopen (vtufilename, "wb"); if (vtufile == NULL) { t8_global_errorf ("Could not open file %s for output.\n", vtufilename); - return -1; + return 0; } fprintf (vtufile, "\n"); fprintf (vtufile, "\n"); fclose (vtufile); } - return 0; + return 1; } int diff --git a/src/t8_vtk/t8_vtk_writer.cxx b/src/t8_vtk/t8_vtk_writer.cxx index 69165eee20..5ad3a79f45 100644 --- a/src/t8_vtk/t8_vtk_writer.cxx +++ b/src/t8_vtk/t8_vtk_writer.cxx @@ -67,8 +67,6 @@ vtk_writer::t8_grid_tree_to_vtk_cells ( return; } -#endif /* T8_WITH_VTK */ - /** * \brief template specialization for cmeshes. * @@ -89,6 +87,7 @@ vtk_writer::t8_grid_tree_to_vtk_cells ( (*elem_id)++; return; } +#endif /* T8_WITH_VTK */ template <> bool diff --git a/test/t8_IO/t8_gtest_vtk_writer.cxx b/test/t8_IO/t8_gtest_vtk_writer.cxx index 61ec42f6da..68195037ac 100644 --- a/test/t8_IO/t8_gtest_vtk_writer.cxx +++ b/test/t8_IO/t8_gtest_vtk_writer.cxx @@ -95,7 +95,7 @@ use_c_interface (const t8_forest_t grid, const char *fileprefix, co curved_flag, write_ghosts, num_data, data); #else return t8_forest_vtk_write_file (grid, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, - curved_flag, write_ghosts, num_data, data); + write_ghosts, num_data, data); #endif } From 7e8e2029dc19bab9234276c18ef66d35a2252cca Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 9 Aug 2024 14:39:00 +0200 Subject: [PATCH 51/87] Update cmake --- src/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 42dbd11093..74ddabe5c3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,7 +50,7 @@ endif() if( T8CODE_ENABLE_VTK ) target_compile_definitions( T8 PUBLIC T8_VTK_VERSION_USED="${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}" ) target_compile_definitions( T8 PUBLIC T8_WITH_VTK=1 ) - target_include_directories( T8 PUBLIC ${VTK_INCLUDE_DIRS} ) + target_include_directories( T8 PUBLIC ${VTK_INCLUDE_DIR} ) target_link_libraries( T8 PUBLIC ${VTK_LIBRARIES} ) endif() @@ -105,7 +105,6 @@ target_sources( T8 PRIVATE t8_forest/t8_forest_partition.cxx t8_forest/t8_forest.cxx t8_forest/t8_forest_private.c - t8_forest/t8_forest_vtk.cxx t8_forest/t8_forest_ghost.cxx t8_forest/t8_forest_iterate.cxx t8_forest/t8_forest_balance.cxx @@ -147,6 +146,9 @@ target_sources( T8 PRIVATE t8_vtk/t8_vtk_unstructured.cxx t8_vtk/t8_vtk_parallel.cxx t8_vtk/t8_vtk_reader.cxx + t8_vtk/t8_vtk_writer.cxx + t8_vtk/t8_vtk_write_ASCII.cxx + t8_vtk/t8_vtk_writer_helper.cxx ) target_compile_definitions( T8 PUBLIC T8_CMAKE_BUILD ) From 1db0c34d65af934b5de6e7afa4707ace8d10a0c0 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 12 Aug 2024 11:15:10 +0200 Subject: [PATCH 52/87] fixed vtk test bug Function called itself, was a nice recursion. fixed it by not calling itself. --- src/t8_vtk/t8_vtk_writer.hxx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/t8_vtk/t8_vtk_writer.hxx b/src/t8_vtk/t8_vtk_writer.hxx index abeeb5c42b..47a9669c4d 100644 --- a/src/t8_vtk/t8_vtk_writer.hxx +++ b/src/t8_vtk/t8_vtk_writer.hxx @@ -137,10 +137,7 @@ class vtk_writer { * \return false */ bool - write_ASCII (const grid_t grid) - { - return write_ASCII (grid); - } + write_ASCII (const grid_t grid); private: #if T8_WITH_VTK From ffc7abf8b6f999d4266a4769f224cbc814307e22 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 12 Aug 2024 16:12:50 +0200 Subject: [PATCH 53/87] split search_query callback function into two they do different things and therefore should be split into two. --- src/t8_forest/t8_forest_ghost.cxx | 4 +--- src/t8_forest/t8_forest_iterate.cxx | 14 ++++++-------- src/t8_forest/t8_forest_iterate.h | 24 ++++++++++++++++++------ test/t8_forest/t8_gtest_search.cxx | 12 +++++------- tutorials/general/t8_tutorial_search.cxx | 6 ++---- 5 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index f53b4806c7..1f85ef452a 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -506,9 +506,7 @@ typedef struct static int t8_forest_ghost_search_boundary (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, - const int is_leaf, const t8_element_array_t *leaves, const t8_locidx_t tree_leaf_index, - void *query, sc_array_t *query_indices, int *query_matches, - const size_t num_active_queries) + const int is_leaf, const t8_element_array_t *leaves, const t8_locidx_t tree_leaf_index) { t8_forest_ghost_boundary_data_t *data = (t8_forest_ghost_boundary_data_t *) t8_forest_get_user_data (forest); int num_faces, iface, faces_totally_owned, level; diff --git a/src/t8_forest/t8_forest_iterate.cxx b/src/t8_forest/t8_forest_iterate.cxx index 2134b4a817..e6abca40ea 100644 --- a/src/t8_forest/t8_forest_iterate.cxx +++ b/src/t8_forest/t8_forest_iterate.cxx @@ -172,8 +172,8 @@ t8_forest_iterate_faces (t8_forest_t forest, t8_locidx_t ltreeid, const t8_eleme static void t8_forest_search_recursion (t8_forest_t forest, const t8_locidx_t ltreeid, t8_element_t *element, const t8_eclass_scheme_c *ts, t8_element_array_t *leaf_elements, - const t8_locidx_t tree_lindex_of_first_leaf, t8_forest_search_query_fn search_fn, - t8_forest_search_query_fn query_fn, sc_array_t *queries, sc_array_t *active_queries) + const t8_locidx_t tree_lindex_of_first_leaf, t8_forest_search_fn search_fn, + t8_forest_query_fn query_fn, sc_array_t *queries, sc_array_t *active_queries) { /* Assertions to check for necessary requirements */ /* The forest must be committed */ @@ -209,8 +209,7 @@ t8_forest_search_recursion (t8_forest_t forest, const t8_locidx_t ltreeid, t8_el } } /* Call the callback function for the element */ - const int ret - = search_fn (forest, ltreeid, element, is_leaf, leaf_elements, tree_lindex_of_first_leaf, NULL, NULL, NULL, 0); + const int ret = search_fn (forest, ltreeid, element, is_leaf, leaf_elements, tree_lindex_of_first_leaf); if (!ret) { /* The function returned false. We abort the recursion */ @@ -288,8 +287,8 @@ t8_forest_search_recursion (t8_forest_t forest, const t8_locidx_t ltreeid, t8_el /* Perform a top-down search in one tree of the forest */ static void -t8_forest_search_tree (t8_forest_t forest, t8_locidx_t ltreeid, t8_forest_search_query_fn search_fn, - t8_forest_search_query_fn query_fn, sc_array_t *queries, sc_array_t *active_queries) +t8_forest_search_tree (t8_forest_t forest, t8_locidx_t ltreeid, t8_forest_search_fn search_fn, + t8_forest_query_fn query_fn, sc_array_t *queries, sc_array_t *active_queries) { /* Get the element class, scheme and leaf elements of this tree */ @@ -315,8 +314,7 @@ t8_forest_search_tree (t8_forest_t forest, t8_locidx_t ltreeid, t8_forest_search } void -t8_forest_search (t8_forest_t forest, t8_forest_search_query_fn search_fn, t8_forest_search_query_fn query_fn, - sc_array_t *queries) +t8_forest_search (t8_forest_t forest, t8_forest_search_fn search_fn, t8_forest_query_fn query_fn, sc_array_t *queries) { /* If we have queries build a list of all active queries, * thus all queries in the array */ diff --git a/src/t8_forest/t8_forest_iterate.h b/src/t8_forest/t8_forest_iterate.h index 9211ec41e7..e651c8d828 100644 --- a/src/t8_forest/t8_forest_iterate.h +++ b/src/t8_forest/t8_forest_iterate.h @@ -36,6 +36,19 @@ typedef int (*t8_forest_iterate_face_fn) (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, void *user_data, t8_locidx_t tree_leaf_index); +/* + * \param[in] forest the forest + * \param[in] ltreeid the local tree id of the current tree + * \param[in] element the element for which the query is executed + * \param[in] is_leaf true if and only if \a element is a leaf element + * \param[in] leaf_elements the leaf elements in \a forest that are descendants of \a element (or the element + * itself if \a is_leaf is true) + * \param[in] tree_leaf_index the local index of the first leaf in \a leaf_elements + */ +typedef int (*t8_forest_search_fn) (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, + const int is_leaf, const t8_element_array_t *leaf_elements, + const t8_locidx_t tree_leaf_index); + /* * \param[in] forest the forest * \param[in] ltreeid the local tree id of the current tree @@ -54,10 +67,10 @@ typedef int (*t8_forest_iterate_face_fn) (t8_forest_t forest, t8_locidx_t ltreei * \param[in] num_active_queries The number of currently active queries. Does not have to be equal to query->elem_count, * since some queries might have been deactivated from previous calls */ -typedef int (*t8_forest_search_query_fn) (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, - const int is_leaf, const t8_element_array_t *leaf_elements, - const t8_locidx_t tree_leaf_index, void *query, sc_array_t *query_indices, - int *query_matches, const size_t num_active_queries); +typedef int (*t8_forest_query_fn) (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, + const int is_leaf, const t8_element_array_t *leaf_elements, + const t8_locidx_t tree_leaf_index, sc_array_t *query, sc_array_t *query_indices, + int *query_matches, const size_t num_active_queries); T8_EXTERN_C_BEGIN (); @@ -85,8 +98,7 @@ t8_forest_iterate_faces (t8_forest_t forest, t8_locidx_t ltreeid, const t8_eleme * To pass user data to the search_fn function use \ref t8_forest_set_user_data */ void -t8_forest_search (t8_forest_t forest, t8_forest_search_query_fn search_fn, t8_forest_search_query_fn query_fn, - sc_array_t *queries); +t8_forest_search (t8_forest_t forest, t8_forest_search_fn search_fn, t8_forest_query_fn query_fn, sc_array_t *queries); /** Given two forest where the elements in one forest are either direct children or * parents of the elements in the other forest diff --git a/test/t8_forest/t8_gtest_search.cxx b/test/t8_forest/t8_gtest_search.cxx index 175917e3a8..2f88277d13 100644 --- a/test/t8_forest/t8_gtest_search.cxx +++ b/test/t8_forest/t8_gtest_search.cxx @@ -62,11 +62,8 @@ class forest_search: public testing::TestWithParam> { */ static int t8_test_search_all_fn (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, const int is_leaf, - const t8_element_array_t *leaf_elements, const t8_locidx_t tree_leaf_index, void *queries, - sc_array_t *query_indices, int *query_matches, const size_t num_active_queries) + const t8_element_array_t *leaf_elements, const t8_locidx_t tree_leaf_index) { - EXPECT_TRUE (queries == NULL) << "Search callback must not be called with query argument."; - sc_array_t *matched_leaves = (sc_array_t *) t8_forest_get_user_data (forest); if (is_leaf) { t8_locidx_t tree_offset; @@ -90,13 +87,14 @@ t8_test_search_all_fn (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_e static int t8_test_search_query_all_fn (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const int is_leaf, - const t8_element_array_t *leaf_elements, const t8_locidx_t tree_leaf_index, void *queries, - sc_array_t *query_indices, int *query_matches, const size_t num_active_queries) + const t8_element_array_t *leaf_elements, const t8_locidx_t tree_leaf_index, + sc_array_t *queries, sc_array_t *query_indices, int *query_matches, + const size_t num_active_queries) { EXPECT_TRUE (queries != NULL) << "query callback must be called with queries argument. "; EXPECT_EQ (num_active_queries, (long unsigned int) 1) << "Wrong number of active queries passed to query callback."; for (size_t iquery = 0; iquery < num_active_queries; iquery++) { - void *query = sc_array_index_int ((sc_array_t *) queries, iquery); + void *query = sc_array_index_int (queries, iquery); /* The query callback is always called with a query */ EXPECT_TRUE (query != NULL) << "query " << iquery << " is NULL."; /* The query is an int with value 42 (see below) */ diff --git a/tutorials/general/t8_tutorial_search.cxx b/tutorials/general/t8_tutorial_search.cxx index aea51588b0..b9a202e7b6 100644 --- a/tutorials/general/t8_tutorial_search.cxx +++ b/tutorials/general/t8_tutorial_search.cxx @@ -148,10 +148,8 @@ typedef struct static int t8_tutorial_search_callback (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, const int is_leaf, const t8_element_array_t *leaf_elements, - const t8_locidx_t tree_leaf_index, void *query, sc_array_t *query_indices, - int *query_matches, const size_t num_active_queries) + const t8_locidx_t tree_leaf_index) { - T8_ASSERT (query == NULL); /* Get a pointer to our user data and increase the counter of searched elements. */ t8_tutorial_search_user_data_t *user_data = (t8_tutorial_search_user_data_t *) t8_forest_get_user_data (forest); @@ -174,7 +172,7 @@ t8_tutorial_search_callback (t8_forest_t forest, const t8_locidx_t ltreeid, cons static int t8_tutorial_search_query_callback (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, const int is_leaf, const t8_element_array_t *leaf_elements, - const t8_locidx_t tree_leaf_index, void *query, sc_array_t *query_indices, + const t8_locidx_t tree_leaf_index, sc_array_t *query, sc_array_t *query_indices, int *query_matches, const size_t num_active_queries) { /* Build an array of all particle-coords, necessary for t8_forest_element_point_batch_inside */ From 63591f6ce77f1229eeb80465ec34c1da5fd7159e Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 12 Aug 2024 16:29:10 +0200 Subject: [PATCH 54/87] Changed return type of query function to void We don't need the return value anymore, replaced by query_matches --- src/t8_forest/t8_forest_iterate.h | 8 ++++---- test/t8_forest/t8_gtest_search.cxx | 3 +-- tutorials/general/t8_tutorial_search.cxx | 3 +-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/t8_forest/t8_forest_iterate.h b/src/t8_forest/t8_forest_iterate.h index e651c8d828..f7702ed9df 100644 --- a/src/t8_forest/t8_forest_iterate.h +++ b/src/t8_forest/t8_forest_iterate.h @@ -67,10 +67,10 @@ typedef int (*t8_forest_search_fn) (t8_forest_t forest, const t8_locidx_t ltreei * \param[in] num_active_queries The number of currently active queries. Does not have to be equal to query->elem_count, * since some queries might have been deactivated from previous calls */ -typedef int (*t8_forest_query_fn) (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, - const int is_leaf, const t8_element_array_t *leaf_elements, - const t8_locidx_t tree_leaf_index, sc_array_t *query, sc_array_t *query_indices, - int *query_matches, const size_t num_active_queries); +typedef void (*t8_forest_query_fn) (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, + const int is_leaf, const t8_element_array_t *leaf_elements, + const t8_locidx_t tree_leaf_index, sc_array_t *query, sc_array_t *query_indices, + int *query_matches, const size_t num_active_queries); T8_EXTERN_C_BEGIN (); diff --git a/test/t8_forest/t8_gtest_search.cxx b/test/t8_forest/t8_gtest_search.cxx index 2f88277d13..a4a9bb2712 100644 --- a/test/t8_forest/t8_gtest_search.cxx +++ b/test/t8_forest/t8_gtest_search.cxx @@ -85,7 +85,7 @@ t8_test_search_all_fn (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_e return 1; } -static int +static void t8_test_search_query_all_fn (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const int is_leaf, const t8_element_array_t *leaf_elements, const t8_locidx_t tree_leaf_index, sc_array_t *queries, sc_array_t *query_indices, int *query_matches, @@ -113,7 +113,6 @@ t8_test_search_query_all_fn (t8_forest_t forest, t8_locidx_t ltreeid, const t8_e } query_matches[iquery] = 1; } - return 1; } TEST_P (forest_search, test_search_one_query_matches_all) diff --git a/tutorials/general/t8_tutorial_search.cxx b/tutorials/general/t8_tutorial_search.cxx index b9a202e7b6..444996ff77 100644 --- a/tutorials/general/t8_tutorial_search.cxx +++ b/tutorials/general/t8_tutorial_search.cxx @@ -169,7 +169,7 @@ t8_tutorial_search_callback (t8_forest_t forest, const t8_locidx_t ltreeid, cons * a counter for this element by one. * These counters are provided in an sc_array as user data of the input forest. */ -static int +static void t8_tutorial_search_query_callback (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, const int is_leaf, const t8_element_array_t *leaf_elements, const t8_locidx_t tree_leaf_index, sc_array_t *query, sc_array_t *query_indices, @@ -222,7 +222,6 @@ t8_tutorial_search_query_callback (t8_forest_t forest, const t8_locidx_t ltreeid } } } - return 0; } /* Write the forest to vtu files and also write the particles_per_element From 991fe2cbe2464ac0e64b4c3ed3b5df9628560a53 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 12 Aug 2024 16:37:26 +0200 Subject: [PATCH 55/87] Update documentation --- src/t8_forest/t8_forest_iterate.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/t8_forest/t8_forest_iterate.h b/src/t8_forest/t8_forest_iterate.h index f7702ed9df..b22a58acfb 100644 --- a/src/t8_forest/t8_forest_iterate.h +++ b/src/t8_forest/t8_forest_iterate.h @@ -57,13 +57,10 @@ typedef int (*t8_forest_search_fn) (t8_forest_t forest, const t8_locidx_t ltreei * \param[in] leaf_elements the leaf elements in \a forest that are descendants of \a element (or the element * itself if \a is_leaf is true) * \param[in] tree_leaf_index the local index of the first leaf in \a leaf_elements - * \param[in] queries if not NULL, a query that is passed through from the search function - * \param[in] query_indices if \a query is not NULL the indices of \a query in the \a queries array from \ref - * t8_forest_search - * \param[in, out] query_matches if \a query is not NULL: true at the i-th index if and only if the element 'matches' - * the query of the i-th query index. - * if \a query is NULL: true if and only if the search should continue with the - * children of \a element and the queries should be performed for this element. + * \param[in] queries An array of queries that are checked by the function + * \param[in] query_indices An array of size_t entries, where each entry is an index of a query in \q queries. + * \param[in, out] query_matches An array of length \a num_active_queries. True at the i-th index if and only if the element 'matches' + * the query of the i-th query index. When the element is a leaf we can return without handling all queries for optimization. * \param[in] num_active_queries The number of currently active queries. Does not have to be equal to query->elem_count, * since some queries might have been deactivated from previous calls */ From 57afd955d77086832951e5461fcae70fa1be4d5c Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 13 Aug 2024 08:58:55 +0200 Subject: [PATCH 56/87] Get the username of the user interacting with an issue following some googling it should be `github.actor` . --- .github/workflows/mattermost_issue.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/mattermost_issue.yml b/.github/workflows/mattermost_issue.yml index b118ebb084..a3d582ed7a 100644 --- a/.github/workflows/mattermost_issue.yml +++ b/.github/workflows/mattermost_issue.yml @@ -48,16 +48,17 @@ jobs: if: github.event.action == 'closed' run: | echo message_build=1 >> $GITHUB_ENV && - echo message_content='Issue ${{ github.event.issue.number }} has been closed. See ${{ github.event.issue.html_url }} for more details.' >> $GITHUB_ENV -# Would like to have this message read "User X closed issue ...". -# How can we get the user name? Tried ${{ github.event.issue.user.name }} and others, did not work. + echo message_content='User ${{github.actor}} closed issue ${{ github.event.issue.number }}. See ${{ github.event.issue.html_url }} for more details.' >> $GITHUB_ENV - name: opened_message - if: github.event.action == 'opened' || github.event.action == 'reopened' + if: github.event.action == 'opened' run: | echo message_build=1 >> $GITHUB_ENV && - echo message_content='Issue ${{ github.event.issue.number }} was (re-)opened. See ${{ github.event.issue.html_url }} for more details.' >> $GITHUB_ENV -# Would like to have this message read "User X (re-)opened issue ...". -# How can we get the user name? Tried ${{ github.event.issue.user.name }} and others, did not work. + echo message_content='User ${{github.actor}} opened issue ${{ github.event.issue.number }}. See ${{ github.event.issue.html_url }} for more details.' >> $GITHUB_ENV + - name: reopened_message + if: github.event.action == 'reopened' + run: | + echo message_build=1 >> $GITHUB_ENV && + echo message_content='User ${{github.actor}} reopened issue ${{ github.event.issue.number }}. See ${{ github.event.issue.html_url }} for more details.' >> $GITHUB_ENV - name: debug_after_build run: echo ${{ env.message_build }} # if a message has been written send the message to the mattermost-channel described in the secrets From 4fb6658a5065ee1e07af94f6f230a9e936f74c1a Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 13 Aug 2024 10:20:42 +0200 Subject: [PATCH 57/87] only search for components of the vtk library --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9727328e4..ec64d7f618 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,10 @@ if( T8CODE_ENABLE_MPI ) endif() if( T8CODE_ENABLE_VTK ) - find_package( VTK REQUIRED ) + find_package( VTK REQUIRED COMPONENTS + IOXML CommonExecutionModel CommonDataModel + IOGeometry IOXMLParser IOParallelXML IOPLY + ParallelMPI FiltersCore vtksys CommonCore zlib IOLegacy) if(VTK_FOUND) message("Found VTK") endif (VTK_FOUND) From 7fc83ba6404e2148428ddec98f8e92f319023057 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Tue, 13 Aug 2024 10:53:18 +0200 Subject: [PATCH 58/87] Add white space around variable --- .github/workflows/mattermost_issue.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mattermost_issue.yml b/.github/workflows/mattermost_issue.yml index a3d582ed7a..d907ca3507 100644 --- a/.github/workflows/mattermost_issue.yml +++ b/.github/workflows/mattermost_issue.yml @@ -48,17 +48,17 @@ jobs: if: github.event.action == 'closed' run: | echo message_build=1 >> $GITHUB_ENV && - echo message_content='User ${{github.actor}} closed issue ${{ github.event.issue.number }}. See ${{ github.event.issue.html_url }} for more details.' >> $GITHUB_ENV + echo message_content='User ${{ github.actor }} closed issue ${{ github.event.issue.number }}. See ${{ github.event.issue.html_url }} for more details.' >> $GITHUB_ENV - name: opened_message if: github.event.action == 'opened' run: | echo message_build=1 >> $GITHUB_ENV && - echo message_content='User ${{github.actor}} opened issue ${{ github.event.issue.number }}. See ${{ github.event.issue.html_url }} for more details.' >> $GITHUB_ENV + echo message_content='User ${{ github.actor }} opened issue ${{ github.event.issue.number }}. See ${{ github.event.issue.html_url }} for more details.' >> $GITHUB_ENV - name: reopened_message if: github.event.action == 'reopened' run: | echo message_build=1 >> $GITHUB_ENV && - echo message_content='User ${{github.actor}} reopened issue ${{ github.event.issue.number }}. See ${{ github.event.issue.html_url }} for more details.' >> $GITHUB_ENV + echo message_content='User ${{ github.actor }} reopened issue ${{ github.event.issue.number }}. See ${{ github.event.issue.html_url }} for more details.' >> $GITHUB_ENV - name: debug_after_build run: echo ${{ env.message_build }} # if a message has been written send the message to the mattermost-channel described in the secrets From b5f35c8c2be56c756a96af4c41d9f8761daa3b22 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 13 Aug 2024 11:02:39 +0200 Subject: [PATCH 59/87] Add reaction if wf is triggered manually --- .github/workflows/mattermost_issue.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/mattermost_issue.yml b/.github/workflows/mattermost_issue.yml index d907ca3507..cd6aeb154f 100644 --- a/.github/workflows/mattermost_issue.yml +++ b/.github/workflows/mattermost_issue.yml @@ -44,6 +44,11 @@ jobs: - name: debug_before_build run: echo ${{ env.message_build}} # build the message depending on different types of events and event actions. Message is written into mattermost.json + - name: dispatch_run + if: github.event.action == 'workflow_dispatch' + run: | + echo message_build=1 >> $GITHUB_ENV && + echo message_content='User ${{github.actor}} triggered the ${{ github.jobs[github.job].name }} workflow_dispatch' >> $GITHUB_ENV - name: closed_message if: github.event.action == 'closed' run: | From c84062ea77f86fba558de5a75d6e47849a132694 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 13 Aug 2024 11:09:31 +0200 Subject: [PATCH 60/87] Update mattermost_issue.yml --- .github/workflows/mattermost_issue.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mattermost_issue.yml b/.github/workflows/mattermost_issue.yml index cd6aeb154f..5846102c04 100644 --- a/.github/workflows/mattermost_issue.yml +++ b/.github/workflows/mattermost_issue.yml @@ -45,7 +45,7 @@ jobs: run: echo ${{ env.message_build}} # build the message depending on different types of events and event actions. Message is written into mattermost.json - name: dispatch_run - if: github.event.action == 'workflow_dispatch' + if: github.event_name == 'workflow_dispatch' run: | echo message_build=1 >> $GITHUB_ENV && echo message_content='User ${{github.actor}} triggered the ${{ github.jobs[github.job].name }} workflow_dispatch' >> $GITHUB_ENV From d599c7140e2c482a74fc7a30c7ccb2d93c4f08ea Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 13 Aug 2024 11:15:16 +0200 Subject: [PATCH 61/87] Update mattermost_issue.yml --- .github/workflows/mattermost_issue.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mattermost_issue.yml b/.github/workflows/mattermost_issue.yml index 5846102c04..9776326944 100644 --- a/.github/workflows/mattermost_issue.yml +++ b/.github/workflows/mattermost_issue.yml @@ -48,7 +48,7 @@ jobs: if: github.event_name == 'workflow_dispatch' run: | echo message_build=1 >> $GITHUB_ENV && - echo message_content='User ${{github.actor}} triggered the ${{ github.jobs[github.job].name }} workflow_dispatch' >> $GITHUB_ENV + echo message_content='User ${{github.actor}} triggered the ${{ github.action }} workflow_dispatch' >> $GITHUB_ENV - name: closed_message if: github.event.action == 'closed' run: | From e00e39177f8f26dd8ec49fdb6b6cd798709d01b6 Mon Sep 17 00:00:00 2001 From: Johannes Markert <10619309+jmark@users.noreply.github.com> Date: Tue, 13 Aug 2024 11:16:53 +0200 Subject: [PATCH 62/87] Update example/cmesh/t8_cmesh_geometry_examples.cxx Co-authored-by: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> --- example/cmesh/t8_cmesh_geometry_examples.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/cmesh/t8_cmesh_geometry_examples.cxx b/example/cmesh/t8_cmesh_geometry_examples.cxx index 1265e7bb70..6034fb0e18 100644 --- a/example/cmesh/t8_cmesh_geometry_examples.cxx +++ b/example/cmesh/t8_cmesh_geometry_examples.cxx @@ -181,7 +181,7 @@ main (int argc, char **argv) t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); - t8_global_productionf ("Wrote %s.\n", prefix_cmesh); + t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); t8_write_forest_to_vtu (forest, prefix_forest); t8_global_productionf ("Wrote %s.\n\n", prefix_forest); From ac14c2ea8142e3420ee84135ee78cd84292de484 Mon Sep 17 00:00:00 2001 From: Johannes Markert <10619309+jmark@users.noreply.github.com> Date: Tue, 13 Aug 2024 11:16:58 +0200 Subject: [PATCH 63/87] Update example/cmesh/t8_cmesh_geometry_examples.cxx Co-authored-by: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> --- example/cmesh/t8_cmesh_geometry_examples.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/cmesh/t8_cmesh_geometry_examples.cxx b/example/cmesh/t8_cmesh_geometry_examples.cxx index 6034fb0e18..225fabcd9c 100644 --- a/example/cmesh/t8_cmesh_geometry_examples.cxx +++ b/example/cmesh/t8_cmesh_geometry_examples.cxx @@ -184,7 +184,7 @@ main (int argc, char **argv) t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); t8_write_forest_to_vtu (forest, prefix_forest); - t8_global_productionf ("Wrote %s.\n\n", prefix_forest); + t8_global_productionf ("Wrote %s.pvtu\n\n", prefix_forest); t8_forest_unref (&forest); } From 93e9a19dab43be19be68336655097090a998f350 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 13 Aug 2024 11:18:33 +0200 Subject: [PATCH 64/87] Update mattermost_issue.yml --- .github/workflows/mattermost_issue.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mattermost_issue.yml b/.github/workflows/mattermost_issue.yml index 9776326944..a0126646b5 100644 --- a/.github/workflows/mattermost_issue.yml +++ b/.github/workflows/mattermost_issue.yml @@ -48,7 +48,7 @@ jobs: if: github.event_name == 'workflow_dispatch' run: | echo message_build=1 >> $GITHUB_ENV && - echo message_content='User ${{github.actor}} triggered the ${{ github.action }} workflow_dispatch' >> $GITHUB_ENV + echo message_content='User ${{github.actor}} triggered the workflow_dispatch' >> $GITHUB_ENV - name: closed_message if: github.event.action == 'closed' run: | From e55824f9dab6bfc60c1a7d1372da62a187c8c0b7 Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Tue, 13 Aug 2024 12:00:32 +0200 Subject: [PATCH 65/87] Refined cmesh geometry example. --- example/cmesh/t8_cmesh_geometry_examples.cxx | 38 ++++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/example/cmesh/t8_cmesh_geometry_examples.cxx b/example/cmesh/t8_cmesh_geometry_examples.cxx index 225fabcd9c..2badae246d 100644 --- a/example/cmesh/t8_cmesh_geometry_examples.cxx +++ b/example/cmesh/t8_cmesh_geometry_examples.cxx @@ -113,7 +113,7 @@ main (int argc, char **argv) const char *prefix_cmesh = "t8_quadrangulated_disk_cmesh"; const char *prefix_forest = "t8_quadrangulated_disk_forest"; - const int uniform_level = 5; + const int uniform_level = 6; const double radius = 1.0; t8_cmesh_t cmesh = t8_cmesh_new_quadrangulated_disk (radius, comm); @@ -121,10 +121,10 @@ main (int argc, char **argv) t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); - t8_global_productionf ("Wrote %s.\n", prefix_cmesh); + t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); t8_write_forest_to_vtu (forest, prefix_forest); - t8_global_productionf ("Wrote %s.\n\n", prefix_forest); + t8_global_productionf ("Wrote %s.pvtu\n\n", prefix_forest); t8_forest_unref (&forest); } @@ -141,10 +141,10 @@ main (int argc, char **argv) t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); - t8_global_productionf ("Wrote %s.\n", prefix_cmesh); + t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); t8_write_forest_to_vtu (forest, prefix_forest); - t8_global_productionf ("Wrote %s.\n\n", prefix_forest); + t8_global_productionf ("Wrote %s.pvtu\n\n", prefix_forest); t8_forest_unref (&forest); } @@ -161,10 +161,10 @@ main (int argc, char **argv) t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); - t8_global_productionf ("Wrote %s.\n", prefix_cmesh); + t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); t8_write_forest_to_vtu (forest, prefix_forest); - t8_global_productionf ("Wrote %s.\n\n", prefix_forest); + t8_global_productionf ("Wrote %s.pvtu\n\n", prefix_forest); t8_forest_unref (&forest); } @@ -201,10 +201,10 @@ main (int argc, char **argv) t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); - t8_global_productionf ("Wrote %s.\n", prefix_cmesh); + t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); t8_write_forest_to_vtu (forest, prefix_forest); - t8_global_productionf ("Wrote %s.\n\n", prefix_forest); + t8_global_productionf ("Wrote %s.pvtu\n\n", prefix_forest); t8_forest_unref (&forest); } @@ -226,10 +226,10 @@ main (int argc, char **argv) t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); - t8_global_productionf ("Wrote %s.\n", prefix_cmesh); + t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); t8_write_forest_to_vtu (forest, prefix_forest); - t8_global_productionf ("Wrote %s.\n\n", prefix_forest); + t8_global_productionf ("Wrote %s.pvtu\n\n", prefix_forest); t8_forest_unref (&forest); } @@ -238,7 +238,7 @@ main (int argc, char **argv) const char *prefix_cmesh = "t8_prismed_spherical_shell_octahedron_cmesh"; const char *prefix_forest = "t8_prismed_spherical_shell_octahedron_forest"; - const int uniform_level = 3; + const int uniform_level = 2; const double inner_radius = 42.0; const double shell_thickness = 5.0; const int num_levels = 2; @@ -250,10 +250,10 @@ main (int argc, char **argv) t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); - t8_global_productionf ("Wrote %s.\n", prefix_cmesh); + t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); t8_write_forest_to_vtu (forest, prefix_forest); - t8_global_productionf ("Wrote %s.\n\n", prefix_forest); + t8_global_productionf ("Wrote %s.pvtu\n\n", prefix_forest); t8_forest_unref (&forest); } @@ -262,7 +262,7 @@ main (int argc, char **argv) const char *prefix_cmesh = "t8_prismed_spherical_shell_icosahedron_cmesh"; const char *prefix_forest = "t8_prismed_spherical_shell_icosahedron_forest"; - const int uniform_level = 3; + const int uniform_level = 2; const double inner_radius = 42.0; const double shell_thickness = 5.0; const int num_levels = 2; @@ -274,10 +274,10 @@ main (int argc, char **argv) t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); - t8_global_productionf ("Wrote %s.\n", prefix_cmesh); + t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); t8_write_forest_to_vtu (forest, prefix_forest); - t8_global_productionf ("Wrote %s.\n\n", prefix_forest); + t8_global_productionf ("Wrote %s.pvtu\n\n", prefix_forest); t8_forest_unref (&forest); } @@ -294,10 +294,10 @@ main (int argc, char **argv) t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); - t8_global_productionf ("Wrote %s.\n", prefix_cmesh); + t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); t8_write_forest_to_vtu (forest, prefix_forest); - t8_global_productionf ("Wrote %s.\n\n", prefix_forest); + t8_global_productionf ("Wrote %s.pvtu\n\n", prefix_forest); t8_forest_unref (&forest); } From df5192692b95100ecccf8b0e9c77fc0dbcc29270 Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Tue, 13 Aug 2024 12:01:57 +0200 Subject: [PATCH 66/87] Renamed geometry. --- src/t8_cmesh/t8_cmesh_examples.cxx | 4 +-- .../t8_geometry_examples.cxx | 34 ++----------------- .../t8_geometry_examples.h | 4 +-- .../t8_geometry_examples.hxx | 8 ++--- .../t8_gtest_geometry_handling.cxx | 2 +- 5 files changed, 12 insertions(+), 40 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.cxx b/src/t8_cmesh/t8_cmesh_examples.cxx index 0ec97e60c6..f67f8fa081 100644 --- a/src/t8_cmesh/t8_cmesh_examples.cxx +++ b/src/t8_cmesh/t8_cmesh_examples.cxx @@ -3121,7 +3121,7 @@ t8_cmesh_new_triangulated_spherical_surface_cube (const double radius, sc_MPI_Co t8_cmesh_t cmesh; t8_cmesh_init (&cmesh); - t8_cmesh_register_geometry (cmesh); + t8_cmesh_register_geometry (cmesh); const int nface_rot = 4; // Four triangles create a cube's face. const int ncube_rot = 6; // Six rotations of the four triangles to the six cube's faces. @@ -3205,7 +3205,7 @@ t8_cmesh_new_quadrangulated_spherical_surface (const double radius, sc_MPI_Comm t8_cmesh_t cmesh; t8_cmesh_init (&cmesh); - t8_cmesh_register_geometry (cmesh); /* Use spherical geometry */ + t8_cmesh_register_geometry (cmesh); /* Use spherical geometry */ const int ntrees = 6; /* Number of cmesh elements resp. trees. */ const int nverts = 4; /* Number of cmesh element vertices. */ diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx index 52bdb42c78..1bcfaff882 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx @@ -118,13 +118,6 @@ t8_geom_evaluate_sphere_tri_prism (const double *active_tree_vertices, const t8_ } } -/** - * Map the faces of an octahedron to a spherical surface. - * \param [in] cmesh The cmesh in which the point lies. - * \param [in] gtreeid The global tree (of the cmesh) in which the reference point is. - * \param [in] ref_coords Array of \a dimension many entries, specifying a point in [0,1]^dimension. - * \param [out] out_coords The mapped coordinates in physical space of \a ref_coords. - */ void t8_geometry_triangulated_spherical_surface::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, @@ -133,13 +126,6 @@ t8_geometry_triangulated_spherical_surface::t8_geom_evaluate (t8_cmesh_t cmesh, t8_geom_evaluate_sphere_tri_prism (active_tree_vertices, T8_ECLASS_TRIANGLE, ref_coords, num_coords, out_coords); } -/** - * Map the prismed faces of an octahedron to a spherical shell. - * \param [in] cmesh The cmesh in which the point lies. - * \param [in] gtreeid The global tree (of the cmesh) in which the reference point is. - * \param [in] ref_coords Array of \a dimension many entries, specifying a point in [0,1]^dimension. - * \param [out] out_coords The mapped coordinates in physical space of \a ref_coords. - */ void t8_geometry_prismed_spherical_shell::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *out_coords) const @@ -148,15 +134,8 @@ t8_geometry_prismed_spherical_shell::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloi t8_geom_evaluate_sphere_tri_prism (active_tree_vertices, T8_ECLASS_PRISM, ref_coords, num_coords, out_coords); } -/** - * Map the faces of a unit cube to a spherical surface. - * \param [in] cmesh The cmesh in which the point lies. - * \param [in] gtreeid The global tree (of the cmesh) in which the reference point is. - * \param [in] ref_coords Array of \a dimension many entries, specifying a point in [0,1]^dimension. - * \param [out] out_coords The mapped coordinates in physical space of \a ref_coords. - */ void -t8_geometry_quadrangulated_spherical_surface::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, +t8_geometry_tesselated_spherical_surface::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *out_coords) const { @@ -212,13 +191,6 @@ t8_geometry_quadrangulated_spherical_surface::t8_geom_evaluate (t8_cmesh_t cmesh } } -/** - * Maps six hexaeders arranged into cube to a spherical shell. - * \param [in] cmesh The cmesh in which the point lies. - * \param [in] gtreeid The global tree (of the cmesh) in which the reference point is. - * \param [in] ref_coords Array of \a dimension many entries, specifying a point in [0,1]^dimension. - * \param [out] out_coords The mapped coordinates in physical space of \a ref_coords. - */ void t8_geometry_cubed_spherical_shell::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *out_coords) const @@ -392,9 +364,9 @@ t8_geometry_prismed_spherical_shell_new () } t8_geometry_c * -t8_geometry_quadrangulated_spherical_surface_new () +t8_geometry_tesselated_spherical_surface_new () { - t8_geometry_quadrangulated_spherical_surface *geom = new t8_geometry_quadrangulated_spherical_surface (); + t8_geometry_tesselated_spherical_surface *geom = new t8_geometry_tesselated_spherical_surface (); return (t8_geometry_c *) geom; } diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.h b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.h index 8af8d89a90..5f6f960d3b 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.h +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.h @@ -50,11 +50,11 @@ t8_geometry_quadrangulated_disk_new (); t8_geometry_c * t8_geometry_triangulated_spherical_surface_new (); -/** Create a new quadrangulated_spherical_surface geometry. +/** Create a new tesselated_spherical_surface geometry. * \return A pointer to an allocated geometry struct. */ t8_geometry_c * -t8_geometry_quadrangulated_spherical_surface_new (); +t8_geometry_tesselated_spherical_surface_new (); /** Create a new cubed_spherical_shell geometry. * \return A pointer to an allocated geometry struct. diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.hxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.hxx index 203dec3872..006a1e2203 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.hxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.hxx @@ -129,18 +129,18 @@ struct t8_geometry_triangulated_spherical_surface: public t8_geometry_with_verti /* Load tree data is inherited from t8_geometry_with_vertices. */ }; -/** This geometry maps the faces of a cube to a spherical surface. +/** This geometry maps the faces of a cube made of quads and/or triangles to a spherical surface. */ -struct t8_geometry_quadrangulated_spherical_surface: public t8_geometry_with_vertices +struct t8_geometry_tesselated_spherical_surface: public t8_geometry_with_vertices { public: /* Basic constructor that sets the dimension and the name. */ - t8_geometry_quadrangulated_spherical_surface (): t8_geometry_with_vertices (2, "t8_quadrangulated_spherical_surface_") + t8_geometry_tesselated_spherical_surface (): t8_geometry_with_vertices (2, "t8_tesselated_spherical_surface_") { } /* The destructor. */ - virtual ~t8_geometry_quadrangulated_spherical_surface () + virtual ~t8_geometry_tesselated_spherical_surface () { } diff --git a/test/t8_geometry/t8_gtest_geometry_handling.cxx b/test/t8_geometry/t8_gtest_geometry_handling.cxx index ae9998990f..7a74a216e6 100644 --- a/test/t8_geometry/t8_gtest_geometry_handling.cxx +++ b/test/t8_geometry/t8_gtest_geometry_handling.cxx @@ -69,7 +69,7 @@ TEST (test_geometry, test_geometry_handler_register) /* Register the geometries without dimension. */ geometries.push_back (geom_handler.register_geometry ()); geometries.push_back (geom_handler.register_geometry ()); - geometries.push_back (geom_handler.register_geometry ()); + geometries.push_back (geom_handler.register_geometry ()); geometries.push_back (geom_handler.register_geometry ()); /* Check that we can find the geometries by name. */ From 409d241996b20a0a12dde0733407da173b362dad Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Tue, 13 Aug 2024 12:04:32 +0200 Subject: [PATCH 67/87] Fixed typo. --- src/t8_cmesh/t8_cmesh_examples.cxx | 4 ++-- .../t8_geometry_implementations/t8_geometry_examples.cxx | 6 +++--- .../t8_geometry_implementations/t8_geometry_examples.h | 4 ++-- .../t8_geometry_implementations/t8_geometry_examples.hxx | 6 +++--- test/t8_geometry/t8_gtest_geometry_handling.cxx | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.cxx b/src/t8_cmesh/t8_cmesh_examples.cxx index f67f8fa081..8425beb751 100644 --- a/src/t8_cmesh/t8_cmesh_examples.cxx +++ b/src/t8_cmesh/t8_cmesh_examples.cxx @@ -3121,7 +3121,7 @@ t8_cmesh_new_triangulated_spherical_surface_cube (const double radius, sc_MPI_Co t8_cmesh_t cmesh; t8_cmesh_init (&cmesh); - t8_cmesh_register_geometry (cmesh); + t8_cmesh_register_geometry (cmesh); const int nface_rot = 4; // Four triangles create a cube's face. const int ncube_rot = 6; // Six rotations of the four triangles to the six cube's faces. @@ -3205,7 +3205,7 @@ t8_cmesh_new_quadrangulated_spherical_surface (const double radius, sc_MPI_Comm t8_cmesh_t cmesh; t8_cmesh_init (&cmesh); - t8_cmesh_register_geometry (cmesh); /* Use spherical geometry */ + t8_cmesh_register_geometry (cmesh); /* Use spherical geometry */ const int ntrees = 6; /* Number of cmesh elements resp. trees. */ const int nverts = 4; /* Number of cmesh element vertices. */ diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx index 1bcfaff882..10319650d7 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx @@ -135,7 +135,7 @@ t8_geometry_prismed_spherical_shell::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloi } void -t8_geometry_tesselated_spherical_surface::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, +t8_geometry_tessellated_spherical_surface::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *out_coords) const { @@ -364,9 +364,9 @@ t8_geometry_prismed_spherical_shell_new () } t8_geometry_c * -t8_geometry_tesselated_spherical_surface_new () +t8_geometry_tessellated_spherical_surface_new () { - t8_geometry_tesselated_spherical_surface *geom = new t8_geometry_tesselated_spherical_surface (); + t8_geometry_tessellated_spherical_surface *geom = new t8_geometry_tessellated_spherical_surface (); return (t8_geometry_c *) geom; } diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.h b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.h index 5f6f960d3b..8bcaa6c59a 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.h +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.h @@ -50,11 +50,11 @@ t8_geometry_quadrangulated_disk_new (); t8_geometry_c * t8_geometry_triangulated_spherical_surface_new (); -/** Create a new tesselated_spherical_surface geometry. +/** Create a new tessellated_spherical_surface geometry. * \return A pointer to an allocated geometry struct. */ t8_geometry_c * -t8_geometry_tesselated_spherical_surface_new (); +t8_geometry_tessellated_spherical_surface_new (); /** Create a new cubed_spherical_shell geometry. * \return A pointer to an allocated geometry struct. diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.hxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.hxx index 006a1e2203..f1f11158ab 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.hxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.hxx @@ -131,16 +131,16 @@ struct t8_geometry_triangulated_spherical_surface: public t8_geometry_with_verti /** This geometry maps the faces of a cube made of quads and/or triangles to a spherical surface. */ -struct t8_geometry_tesselated_spherical_surface: public t8_geometry_with_vertices +struct t8_geometry_tessellated_spherical_surface: public t8_geometry_with_vertices { public: /* Basic constructor that sets the dimension and the name. */ - t8_geometry_tesselated_spherical_surface (): t8_geometry_with_vertices (2, "t8_tesselated_spherical_surface_") + t8_geometry_tessellated_spherical_surface (): t8_geometry_with_vertices (2, "t8_tessellated_spherical_surface_") { } /* The destructor. */ - virtual ~t8_geometry_tesselated_spherical_surface () + virtual ~t8_geometry_tessellated_spherical_surface () { } diff --git a/test/t8_geometry/t8_gtest_geometry_handling.cxx b/test/t8_geometry/t8_gtest_geometry_handling.cxx index 7a74a216e6..b9cfa15dd3 100644 --- a/test/t8_geometry/t8_gtest_geometry_handling.cxx +++ b/test/t8_geometry/t8_gtest_geometry_handling.cxx @@ -69,7 +69,7 @@ TEST (test_geometry, test_geometry_handler_register) /* Register the geometries without dimension. */ geometries.push_back (geom_handler.register_geometry ()); geometries.push_back (geom_handler.register_geometry ()); - geometries.push_back (geom_handler.register_geometry ()); + geometries.push_back (geom_handler.register_geometry ()); geometries.push_back (geom_handler.register_geometry ()); /* Check that we can find the geometries by name. */ From c210a2813c607803bc14e035d061fdee2aed7a34 Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Tue, 13 Aug 2024 12:17:09 +0200 Subject: [PATCH 68/87] Applied formatter. --- .../t8_geometry_implementations/t8_geometry_examples.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx index 10319650d7..31672c465d 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx @@ -136,8 +136,8 @@ t8_geometry_prismed_spherical_shell::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloi void t8_geometry_tessellated_spherical_surface::t8_geom_evaluate (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, - const double *ref_coords, const size_t num_coords, - double *out_coords) const + const double *ref_coords, const size_t num_coords, + double *out_coords) const { // Note, all elements are aligned such that the face normal follows the // outward radial direction of the sphere. From 2e328b8f7df312b727350319c2fac605030908a8 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 13 Aug 2024 13:17:11 +0200 Subject: [PATCH 69/87] Update src/t8_vtk/t8_vtk_writer.cxx Co-authored-by: Johannes Markert <10619309+jmark@users.noreply.github.com> --- src/t8_vtk/t8_vtk_writer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_vtk/t8_vtk_writer.cxx b/src/t8_vtk/t8_vtk_writer.cxx index 5ad3a79f45..7c50a2c131 100644 --- a/src/t8_vtk/t8_vtk_writer.cxx +++ b/src/t8_vtk/t8_vtk_writer.cxx @@ -81,7 +81,7 @@ vtk_writer::t8_grid_tree_to_vtk_cells ( const t8_locidx_t num_local_trees, t8_gloidx_t *elem_id, long int *point_id, const t8_gloidx_t offset, const bool ghosts, const t8_locidx_t itree) { - /* A cmesh does not have any further elements, we can call the translatore directly. */ + /* A cmesh does not have any further elements, we can call the translator directly. */ this->t8_grid_element_to_vtk_cell (cmesh, NULL, itree, offset, ghosts, *elem_id, point_id, cellTypes, points, cellArray, vtk_treeid, vtk_mpirank, vtk_level, vtk_element_id); (*elem_id)++; From 1839359cc421003d72535eec71badab67c99b8d2 Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Tue, 13 Aug 2024 13:35:47 +0200 Subject: [PATCH 70/87] Added missing geometries to test. --- test/t8_geometry/t8_gtest_geometry_handling.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/t8_geometry/t8_gtest_geometry_handling.cxx b/test/t8_geometry/t8_gtest_geometry_handling.cxx index b9cfa15dd3..3591972a8e 100644 --- a/test/t8_geometry/t8_gtest_geometry_handling.cxx +++ b/test/t8_geometry/t8_gtest_geometry_handling.cxx @@ -71,6 +71,8 @@ TEST (test_geometry, test_geometry_handler_register) geometries.push_back (geom_handler.register_geometry ()); geometries.push_back (geom_handler.register_geometry ()); geometries.push_back (geom_handler.register_geometry ()); + geometries.push_back (geom_handler.register_geometry ()); + geometries.push_back (geom_handler.register_geometry ()); /* Check that we can find the geometries by name. */ for (auto geom : geometries) { From ff2f2923ef7372fc73eba113b4c33faa4461f7bf Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 13 Aug 2024 15:05:05 +0200 Subject: [PATCH 71/87] Update comments content and doxygen-style comment --- src/t8_forest/t8_forest_iterate.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/t8_forest/t8_forest_iterate.h b/src/t8_forest/t8_forest_iterate.h index b22a58acfb..ba8d72f542 100644 --- a/src/t8_forest/t8_forest_iterate.h +++ b/src/t8_forest/t8_forest_iterate.h @@ -36,7 +36,12 @@ typedef int (*t8_forest_iterate_face_fn) (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, void *user_data, t8_locidx_t tree_leaf_index); -/* +/** + * A call-back function used by \ref t8_forest_search describing a search-criterion. Is called on an element and the search criterion should be + * checked on that element. + * Return true if the search criterion is met, false otherwise. + * + * * \param[in] forest the forest * \param[in] ltreeid the local tree id of the current tree * \param[in] element the element for which the query is executed @@ -44,15 +49,20 @@ typedef int (*t8_forest_iterate_face_fn) (t8_forest_t forest, t8_locidx_t ltreei * \param[in] leaf_elements the leaf elements in \a forest that are descendants of \a element (or the element * itself if \a is_leaf is true) * \param[in] tree_leaf_index the local index of the first leaf in \a leaf_elements + * \returns non-zero if the search criterion is met, zero otherwise. */ typedef int (*t8_forest_search_fn) (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, const int is_leaf, const t8_element_array_t *leaf_elements, const t8_locidx_t tree_leaf_index); -/* +/** + * A call-back function used by \ref t8_forest_search for queries. Is called on an element and all queries are checked on that element. + * All positive queries are passed further down to the children of the element up to leaf elements of the tree. The results of the check + * are stored in \a query_matches. + * * \param[in] forest the forest * \param[in] ltreeid the local tree id of the current tree - * \param[in] element the element for which the query is executed + * \param[in] element the element for which the queries are executed * \param[in] is_leaf true if and only if \a element is a leaf element * \param[in] leaf_elements the leaf elements in \a forest that are descendants of \a element (or the element * itself if \a is_leaf is true) From 869ccb6af218d84065fe2e8de65740c7a47290e7 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 13 Aug 2024 15:09:36 +0200 Subject: [PATCH 72/87] Update comment content --- src/t8_forest/t8_forest_iterate.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/t8_forest/t8_forest_iterate.h b/src/t8_forest/t8_forest_iterate.h index ba8d72f542..1b5274f069 100644 --- a/src/t8_forest/t8_forest_iterate.h +++ b/src/t8_forest/t8_forest_iterate.h @@ -37,9 +37,8 @@ typedef int (*t8_forest_iterate_face_fn) (t8_forest_t forest, t8_locidx_t ltreei int face, void *user_data, t8_locidx_t tree_leaf_index); /** - * A call-back function used by \ref t8_forest_search describing a search-criterion. Is called on an element and the search criterion should be - * checked on that element. - * Return true if the search criterion is met, false otherwise. + * A call-back function used by \ref t8_forest_search describing a search-criterion. Is called on an element and the + * search criterion should be checked on that element. Return true if the search criterion is met, false otherwise. * * * \param[in] forest the forest @@ -56,9 +55,9 @@ typedef int (*t8_forest_search_fn) (t8_forest_t forest, const t8_locidx_t ltreei const t8_locidx_t tree_leaf_index); /** - * A call-back function used by \ref t8_forest_search for queries. Is called on an element and all queries are checked on that element. - * All positive queries are passed further down to the children of the element up to leaf elements of the tree. The results of the check - * are stored in \a query_matches. + * A call-back function used by \ref t8_forest_search for queries. Is called on an element and all queries are checked + * on that element. All positive queries are passed further down to the children of the element up to leaf elements of + * the tree. The results of the check are stored in \a query_matches. * * \param[in] forest the forest * \param[in] ltreeid the local tree id of the current tree @@ -69,10 +68,12 @@ typedef int (*t8_forest_search_fn) (t8_forest_t forest, const t8_locidx_t ltreei * \param[in] tree_leaf_index the local index of the first leaf in \a leaf_elements * \param[in] queries An array of queries that are checked by the function * \param[in] query_indices An array of size_t entries, where each entry is an index of a query in \q queries. - * \param[in, out] query_matches An array of length \a num_active_queries. True at the i-th index if and only if the element 'matches' - * the query of the i-th query index. When the element is a leaf we can return without handling all queries for optimization. - * \param[in] num_active_queries The number of currently active queries. Does not have to be equal to query->elem_count, - * since some queries might have been deactivated from previous calls + * \param[in, out] query_matches An array of length \a num_active_queries. + * If the element is not a leave must be set to true or false at the i-th index for + * each query, specifying whether the element 'matches' the query of the i-th query + * index or not. When the element is a leaf we can return before all entries are set. + * \param[in] num_active_queries The number of currently active queries (equals the number of entries of + * \a query_matches and entries of \a query_indices). */ typedef void (*t8_forest_query_fn) (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, const int is_leaf, const t8_element_array_t *leaf_elements, From 68862524949a68b184a6d2d5cf6aba891e7c460c Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 13 Aug 2024 15:11:59 +0200 Subject: [PATCH 73/87] query -> queries --- src/t8_forest/t8_forest_iterate.h | 2 +- tutorials/general/t8_tutorial_search.cxx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/t8_forest/t8_forest_iterate.h b/src/t8_forest/t8_forest_iterate.h index 1b5274f069..1ef95a7bf5 100644 --- a/src/t8_forest/t8_forest_iterate.h +++ b/src/t8_forest/t8_forest_iterate.h @@ -77,7 +77,7 @@ typedef int (*t8_forest_search_fn) (t8_forest_t forest, const t8_locidx_t ltreei */ typedef void (*t8_forest_query_fn) (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, const int is_leaf, const t8_element_array_t *leaf_elements, - const t8_locidx_t tree_leaf_index, sc_array_t *query, sc_array_t *query_indices, + const t8_locidx_t tree_leaf_index, sc_array_t *queries, sc_array_t *query_indices, int *query_matches, const size_t num_active_queries); T8_EXTERN_C_BEGIN (); diff --git a/tutorials/general/t8_tutorial_search.cxx b/tutorials/general/t8_tutorial_search.cxx index 444996ff77..8a056468e9 100644 --- a/tutorials/general/t8_tutorial_search.cxx +++ b/tutorials/general/t8_tutorial_search.cxx @@ -172,7 +172,7 @@ t8_tutorial_search_callback (t8_forest_t forest, const t8_locidx_t ltreeid, cons static void t8_tutorial_search_query_callback (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element, const int is_leaf, const t8_element_array_t *leaf_elements, - const t8_locidx_t tree_leaf_index, sc_array_t *query, sc_array_t *query_indices, + const t8_locidx_t tree_leaf_index, sc_array_t *queries, sc_array_t *query_indices, int *query_matches, const size_t num_active_queries) { /* Build an array of all particle-coords, necessary for t8_forest_element_point_batch_inside */ @@ -182,7 +182,7 @@ t8_tutorial_search_query_callback (t8_forest_t forest, const t8_locidx_t ltreeid const size_t particle_id = *(size_t *) sc_array_index_int (query_indices, particle_iter); /* Cast the query into a particle*/ t8_tutorial_search_particle_t *particle - = (t8_tutorial_search_particle_t *) sc_array_index ((sc_array_t *) query, particle_id); + = (t8_tutorial_search_particle_t *) sc_array_index ((sc_array_t *) queries, particle_id); /* extract the coordinates of the particle struct */ coords[3 * particle_iter] = particle->coordinates[0]; coords[3 * particle_iter + 1] = particle->coordinates[1]; @@ -198,7 +198,7 @@ t8_tutorial_search_query_callback (t8_forest_t forest, const t8_locidx_t ltreeid sc_array *particles_per_element = user_data->particles_per_element; /* Ensure that the data is actually set. */ T8_ASSERT (particles_per_element != NULL); - T8_ASSERT (query != NULL); + T8_ASSERT (queries != NULL); /* Test whether the particles are inside this element. */ t8_forest_element_points_inside (forest, ltreeid, element, coords, num_active_queries, query_matches, tolerance); @@ -216,7 +216,7 @@ t8_tutorial_search_query_callback (t8_forest_t forest, const t8_locidx_t ltreeid /* Get the correct particle_id */ size_t particle_id = *(size_t *) sc_array_index_int (query_indices, matches_id); t8_tutorial_search_particle_t *particle - = (t8_tutorial_search_particle_t *) sc_array_index ((sc_array_t *) query, particle_id); + = (t8_tutorial_search_particle_t *) sc_array_index ((sc_array_t *) queries, particle_id); particle->is_inside_partition = 1; *(double *) t8_sc_array_index_locidx (particles_per_element, element_index) += 1; } From f6bc3bcd798f03a8902dcfff5932427c5d9571be Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 13 Aug 2024 16:47:50 +0200 Subject: [PATCH 74/87] Add api folder to indent all files script --- scripts/indent_all_files.scp | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/indent_all_files.scp b/scripts/indent_all_files.scp index 2b176f09b1..8879513291 100755 --- a/scripts/indent_all_files.scp +++ b/scripts/indent_all_files.scp @@ -55,6 +55,7 @@ echo $PWD/../example/ echo $PWD/../test/ echo $PWD/../tutorials/ echo $PWD/../benchmarks/ +echo $PWD/../api/ echo read -p "Are you sure? ('Y' or 'y' to continue)" -n 1 -r echo From 23cb4574604f4b6a5ef1219e6d550a1a5f7056e5 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 13 Aug 2024 12:25:38 +0200 Subject: [PATCH 75/87] add tree compatibility test for example cmesh geoms --- .../t8_geometry_examples.hxx | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.hxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.hxx index 203dec3872..c2142bd473 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.hxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.hxx @@ -84,6 +84,23 @@ struct t8_geometry_quadrangulated_disk: public t8_geometry_with_vertices return T8_GEOMETRY_TYPE_UNDEFINED; }; + /** + * Check for compatibility of the currently loaded tree with the geometry. + * Only quad elements are supported by this geometry. + * \return True if the geometry is compatible with the tree. + */ + bool + t8_geom_check_tree_compatibility () const + { + if (active_tree_class != T8_ECLASS_QUAD) { + t8_productionf ("t8_geometry_quadrangulated_disk is not compatible with tree type %s\n" + "It is only compatible with quad elements.\n", + t8_eclass_to_string[active_tree_class]); + return true; + } + return false; + } + /* Load tree data is inherited from t8_geometry_with_vertices. */ }; @@ -126,6 +143,23 @@ struct t8_geometry_triangulated_spherical_surface: public t8_geometry_with_verti SC_ABORT_NOT_REACHED (); } + /** + * Check for compatibility of the currently loaded tree with the geometry. + * Only triangle elements are supported by this geometry. + * \return True if the geometry is compatible with the tree. + */ + bool + t8_geom_check_tree_compatibility () const + { + if (active_tree_class != T8_ECLASS_TRIANGLE) { + t8_productionf ("t8_geometry_triangulated_spherical_surface is not compatible with tree type %s\n" + "It is only compatible with triangle elements.\n", + t8_eclass_to_string[active_tree_class]); + return true; + } + return false; + } + /* Load tree data is inherited from t8_geometry_with_vertices. */ }; @@ -167,6 +201,23 @@ struct t8_geometry_quadrangulated_spherical_surface: public t8_geometry_with_ver SC_ABORT_NOT_REACHED (); } + /** + * Check for compatibility of the currently loaded tree with the geometry. + * Only quad elements are supported by this geometry. + * \return True if the geometry is compatible with the tree. + */ + bool + t8_geom_check_tree_compatibility () const + { + if (active_tree_class != T8_ECLASS_QUAD) { + t8_productionf ("t8_geometry_quadrangulated_spherical_surface is not compatible with tree type %s\n" + "It is only compatible with quad elements.\n", + t8_eclass_to_string[active_tree_class]); + return true; + } + return false; + } + /* Load tree data is inherited from t8_geometry_with_vertices. */ }; @@ -208,6 +259,23 @@ struct t8_geometry_cubed_spherical_shell: public t8_geometry_with_vertices SC_ABORT_NOT_REACHED (); } + /** + * Check for compatibility of the currently loaded tree with the geometry. + * Only hex elements are supported by this geometry. + * \return True if the geometry is compatible with the tree. + */ + bool + t8_geom_check_tree_compatibility () const + { + if (active_tree_class != T8_ECLASS_HEX) { + t8_productionf ("t8_geometry_cubed_spherical_shell is not compatible with tree type %s\n" + "It is only compatible with hex elements.\n", + t8_eclass_to_string[active_tree_class]); + return true; + } + return false; + } + /* Load tree data is inherited from t8_geometry_with_vertices. */ }; @@ -249,6 +317,23 @@ struct t8_geometry_prismed_spherical_shell: public t8_geometry_with_vertices SC_ABORT_NOT_REACHED (); } + /** + * Check for compatibility of the currently loaded tree with the geometry. + * Only prism elements are supported by this geometry. + * \return True if the geometry is compatible with the tree. + */ + bool + t8_geom_check_tree_compatibility () const + { + if (active_tree_class != T8_ECLASS_PRISM) { + t8_productionf ("t8_geometry_prismed_spherical_shell is not compatible with tree type %s\n" + "It is only compatible with prism elements.\n", + t8_eclass_to_string[active_tree_class]); + return true; + } + return false; + } + /* Load tree data is inherited from t8_geometry_with_vertices. */ }; @@ -290,6 +375,23 @@ struct t8_geometry_cubed_sphere: public t8_geometry_with_vertices SC_ABORT_NOT_REACHED (); } + /** + * Check for compatibility of the currently loaded tree with the geometry. + * Only hex elements are supported by this geometry. + * \return True if the geometry is compatible with the tree. + */ + bool + t8_geom_check_tree_compatibility () const + { + if (active_tree_class != T8_ECLASS_HEX) { + t8_productionf ("t8_geometry_cubed_sphere is not compatible with tree type %s\n" + "It is only compatible with hex elements.\n", + t8_eclass_to_string[active_tree_class]); + return true; + } + return false; + } + /* Load tree data is inherited from t8_geometry_with_vertices. */ }; From 9525dc497be3cd0a4bcc6565336ab781cfb338b3 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 14 Aug 2024 15:35:21 +0200 Subject: [PATCH 76/87] fix faulty copyright statements --- test/t8_cmesh/t8_gtest_bcast.cxx | 5 ++--- test/t8_geometry/t8_gtest_point_inside.cxx | 5 ++--- test/t8_gtest_basics.cxx | 5 ++--- test/t8_gtest_eclass.cxx | 5 ++--- test/t8_gtest_refcount.cxx | 5 ++--- test/t8_gtest_vec.cxx | 5 ++--- test/t8_gtest_version.cxx | 5 ++--- test/t8_schemes/t8_gtest_descendant.cxx | 5 ++--- test/t8_schemes/t8_gtest_face_descendant.cxx | 5 ++--- test/t8_schemes/t8_gtest_scheme_consistency.cxx | 5 ++--- test/t8_schemes/t8_gtest_successor.cxx | 5 ++--- 11 files changed, 22 insertions(+), 33 deletions(-) diff --git a/test/t8_cmesh/t8_gtest_bcast.cxx b/test/t8_cmesh/t8_gtest_bcast.cxx index 4d9e05bc1b..4fbe66083e 100644 --- a/test/t8_cmesh/t8_gtest_bcast.cxx +++ b/test/t8_cmesh/t8_gtest_bcast.cxx @@ -1,10 +1,9 @@ /* 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. + connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2010 The University of Texas System - Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac + Copyright (C) 2024 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 diff --git a/test/t8_geometry/t8_gtest_point_inside.cxx b/test/t8_geometry/t8_gtest_point_inside.cxx index 4cfbf7288d..da28c40a05 100644 --- a/test/t8_geometry/t8_gtest_point_inside.cxx +++ b/test/t8_geometry/t8_gtest_point_inside.cxx @@ -1,10 +1,9 @@ /* 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. + connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2010 The University of Texas System - Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac + Copyright (C) 2024 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 diff --git a/test/t8_gtest_basics.cxx b/test/t8_gtest_basics.cxx index d8633dc3a9..5732d11461 100644 --- a/test/t8_gtest_basics.cxx +++ b/test/t8_gtest_basics.cxx @@ -1,10 +1,9 @@ /* 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. + connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2010 The University of Texas System - Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac + Copyright (C) 2024 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 diff --git a/test/t8_gtest_eclass.cxx b/test/t8_gtest_eclass.cxx index deda7e12c8..4abe116e66 100644 --- a/test/t8_gtest_eclass.cxx +++ b/test/t8_gtest_eclass.cxx @@ -1,10 +1,9 @@ /* 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. + connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2010 The University of Texas System - Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac + Copyright (C) 2024 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 diff --git a/test/t8_gtest_refcount.cxx b/test/t8_gtest_refcount.cxx index c58721272b..09ef36559d 100644 --- a/test/t8_gtest_refcount.cxx +++ b/test/t8_gtest_refcount.cxx @@ -1,10 +1,9 @@ /* 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. + connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2010 The University of Texas System - Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac + Copyright (C) 2024 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 diff --git a/test/t8_gtest_vec.cxx b/test/t8_gtest_vec.cxx index 395f82f838..efe41a258f 100644 --- a/test/t8_gtest_vec.cxx +++ b/test/t8_gtest_vec.cxx @@ -1,10 +1,9 @@ /* 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. + connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2010 The University of Texas System - Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac + Copyright (C) 2024 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 diff --git a/test/t8_gtest_version.cxx b/test/t8_gtest_version.cxx index 56a1a56dfb..12dd6446f4 100644 --- a/test/t8_gtest_version.cxx +++ b/test/t8_gtest_version.cxx @@ -1,10 +1,9 @@ /* 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. + connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2010 The University of Texas System - Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac + Copyright (C) 2024 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 diff --git a/test/t8_schemes/t8_gtest_descendant.cxx b/test/t8_schemes/t8_gtest_descendant.cxx index 625454d58d..2461ec138a 100644 --- a/test/t8_schemes/t8_gtest_descendant.cxx +++ b/test/t8_schemes/t8_gtest_descendant.cxx @@ -1,10 +1,9 @@ /* 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. + connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2010 The University of Texas System - Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac + Copyright (C) 2024 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 diff --git a/test/t8_schemes/t8_gtest_face_descendant.cxx b/test/t8_schemes/t8_gtest_face_descendant.cxx index 376f9d32aa..6d12e21b5b 100644 --- a/test/t8_schemes/t8_gtest_face_descendant.cxx +++ b/test/t8_schemes/t8_gtest_face_descendant.cxx @@ -1,10 +1,9 @@ /* 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. + connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2010 The University of Texas System - Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac + Copyright (C) 2024 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 diff --git a/test/t8_schemes/t8_gtest_scheme_consistency.cxx b/test/t8_schemes/t8_gtest_scheme_consistency.cxx index f42f2373f3..4882e6429d 100644 --- a/test/t8_schemes/t8_gtest_scheme_consistency.cxx +++ b/test/t8_schemes/t8_gtest_scheme_consistency.cxx @@ -1,10 +1,9 @@ /* 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. + connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2010 The University of Texas System - Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac + Copyright (C) 2024 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 diff --git a/test/t8_schemes/t8_gtest_successor.cxx b/test/t8_schemes/t8_gtest_successor.cxx index 31e4e07d8d..2b7a465a48 100644 --- a/test/t8_schemes/t8_gtest_successor.cxx +++ b/test/t8_schemes/t8_gtest_successor.cxx @@ -1,10 +1,9 @@ /* 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. + connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2010 The University of Texas System - Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac + Copyright (C) 2024 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 From 6331c989d87aa458e64871d24fd070396a25a8af Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 14 Aug 2024 15:36:39 +0200 Subject: [PATCH 77/87] unify indentation of copyright notices --- src/t8_cmesh/t8_cmesh_vtk_reader.cxx | 30 +++++++++---------- src/t8_cmesh_vtk_reader.hxx | 30 +++++++++---------- src/t8_vtk/t8_vtk_parallel.cxx | 30 +++++++++---------- src/t8_vtk/t8_vtk_parallel.hxx | 30 +++++++++---------- src/t8_vtk/t8_vtk_polydata.cxx | 30 +++++++++---------- src/t8_vtk/t8_vtk_polydata.hxx | 30 +++++++++---------- src/t8_vtk/t8_vtk_reader.cxx | 30 +++++++++---------- src/t8_vtk/t8_vtk_reader.hxx | 30 +++++++++---------- src/t8_vtk/t8_vtk_types.h | 30 +++++++++---------- src/t8_vtk/t8_vtk_unstructured.cxx | 30 +++++++++---------- src/t8_vtk/t8_vtk_unstructured.hxx | 30 +++++++++---------- src/t8_vtk/t8_vtk_write_ASCII.cxx | 30 +++++++++---------- src/t8_vtk/t8_vtk_write_ASCII.hxx | 30 +++++++++---------- src/t8_vtk/t8_vtk_writer.cxx | 30 +++++++++---------- src/t8_vtk/t8_vtk_writer.h | 30 +++++++++---------- src/t8_vtk/t8_vtk_writer.hxx | 30 +++++++++---------- src/t8_vtk/t8_vtk_writer_helper.cxx | 30 +++++++++---------- src/t8_vtk/t8_vtk_writer_helper.hxx | 30 +++++++++---------- test/t8_IO/t8_gtest_vtk_reader.cxx | 30 +++++++++---------- test/t8_IO/t8_gtest_vtk_writer.cxx | 30 +++++++++---------- ...st_cmesh_tree_vertices_negative_volume.cxx | 30 +++++++++---------- .../t8_cmesh_example_sets.hxx | 30 +++++++++---------- .../t8_cmesh_new_bigmesh_param.hxx | 30 +++++++++---------- .../t8_cmesh_new_comm.hxx | 30 +++++++++---------- .../t8_cmesh_new_disjoint_bricks_param.hxx | 30 +++++++++---------- .../t8_cmesh_new_empty.hxx | 30 +++++++++---------- .../t8_cmesh_new_from_class_param.hxx | 30 +++++++++---------- .../t8_cmesh_new_hypercube_pad.hxx | 30 +++++++++---------- .../t8_cmesh_new_hypercube_param.hxx | 30 +++++++++---------- .../t8_cmesh_new_periodic.hxx | 30 +++++++++---------- .../t8_cmesh_new_prism_cake_param.hxx | 30 +++++++++---------- .../t8_cmesh_params.hxx | 30 +++++++++---------- .../t8_gtest_cmesh_cartestian_product.hxx | 30 +++++++++---------- .../t8_gtest_cmesh_generator_test.cxx | 30 +++++++++---------- .../t8_gtest_cmesh_sum_of_sets.hxx | 30 +++++++++---------- test/t8_forest/t8_gtest_balance.cxx | 30 +++++++++---------- test/t8_forest/t8_gtest_element_volume.cxx | 30 +++++++++---------- .../t8_forest/t8_gtest_forest_face_normal.cxx | 30 +++++++++---------- .../t8_gtest_geometry_lagrange.cxx | 30 +++++++++---------- test/t8_gtest_custom_assertion.hxx | 30 +++++++++---------- test/t8_gtest_macros.hxx | 30 +++++++++---------- test/t8_schemes/t8_gtest_ancestor.cxx | 30 +++++++++---------- .../t8_gtest_element_ref_coords.cxx | 30 +++++++++---------- test/t8_schemes/t8_gtest_init_linear_id.cxx | 30 +++++++++---------- test/t8_schemes/t8_gtest_nca.cxx | 30 +++++++++---------- .../t8_schemes/t8_gtest_pyra_connectivity.cxx | 30 +++++++++---------- test/t8_schemes/t8_gtest_root.cxx | 30 +++++++++---------- 47 files changed, 705 insertions(+), 705 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx index 48e9616aa6..e27d1a1c8c 100644 --- a/src/t8_cmesh/t8_cmesh_vtk_reader.cxx +++ b/src/t8_cmesh/t8_cmesh_vtk_reader.cxx @@ -1,23 +1,23 @@ /* -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. + 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 + 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 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. + 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. + 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_cmesh_vtk_reader.cxx diff --git a/src/t8_cmesh_vtk_reader.hxx b/src/t8_cmesh_vtk_reader.hxx index 7c0ef85331..9ae9dac0fe 100644 --- a/src/t8_cmesh_vtk_reader.hxx +++ b/src/t8_cmesh_vtk_reader.hxx @@ -1,23 +1,23 @@ /* -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. + 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 + 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 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. + 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. + 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_cmesh_vtk_reader.hxx diff --git a/src/t8_vtk/t8_vtk_parallel.cxx b/src/t8_vtk/t8_vtk_parallel.cxx index ffd7e6b62b..8652db46cc 100644 --- a/src/t8_vtk/t8_vtk_parallel.cxx +++ b/src/t8_vtk/t8_vtk_parallel.cxx @@ -1,23 +1,23 @@ /* -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. + 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 the developers + 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 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. + 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. + 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 "t8_vtk_parallel.hxx" diff --git a/src/t8_vtk/t8_vtk_parallel.hxx b/src/t8_vtk/t8_vtk_parallel.hxx index 31890200a6..383e3e55f0 100644 --- a/src/t8_vtk/t8_vtk_parallel.hxx +++ b/src/t8_vtk/t8_vtk_parallel.hxx @@ -1,23 +1,23 @@ /* -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. + 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 the developers + 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 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. + 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. + 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_PARALLEL_HXX diff --git a/src/t8_vtk/t8_vtk_polydata.cxx b/src/t8_vtk/t8_vtk_polydata.cxx index d95e1af570..dd38d55e87 100644 --- a/src/t8_vtk/t8_vtk_polydata.cxx +++ b/src/t8_vtk/t8_vtk_polydata.cxx @@ -1,23 +1,23 @@ /* -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. + 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 + 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 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. + 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. + 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 "t8_vtk_polydata.hxx" diff --git a/src/t8_vtk/t8_vtk_polydata.hxx b/src/t8_vtk/t8_vtk_polydata.hxx index d23e96da70..dd20e803c9 100644 --- a/src/t8_vtk/t8_vtk_polydata.hxx +++ b/src/t8_vtk/t8_vtk_polydata.hxx @@ -1,23 +1,23 @@ /* -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. + 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 + 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 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. + 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. + 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. */ /** diff --git a/src/t8_vtk/t8_vtk_reader.cxx b/src/t8_vtk/t8_vtk_reader.cxx index b5d9a00040..83d827a0d5 100644 --- a/src/t8_vtk/t8_vtk_reader.cxx +++ b/src/t8_vtk/t8_vtk_reader.cxx @@ -1,23 +1,23 @@ /* -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. + 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 the developers + 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 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. + 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. + 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 diff --git a/src/t8_vtk/t8_vtk_reader.hxx b/src/t8_vtk/t8_vtk_reader.hxx index 34b7235c59..8c320106be 100644 --- a/src/t8_vtk/t8_vtk_reader.hxx +++ b/src/t8_vtk/t8_vtk_reader.hxx @@ -1,23 +1,23 @@ /* -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. + 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 the developers + 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 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. + 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. + 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 diff --git a/src/t8_vtk/t8_vtk_types.h b/src/t8_vtk/t8_vtk_types.h index e8355e5836..b610dc333f 100644 --- a/src/t8_vtk/t8_vtk_types.h +++ b/src/t8_vtk/t8_vtk_types.h @@ -1,23 +1,23 @@ /* -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. + 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 + 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 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. + 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. + 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 diff --git a/src/t8_vtk/t8_vtk_unstructured.cxx b/src/t8_vtk/t8_vtk_unstructured.cxx index 3d026d70b3..e45ca9780f 100644 --- a/src/t8_vtk/t8_vtk_unstructured.cxx +++ b/src/t8_vtk/t8_vtk_unstructured.cxx @@ -1,23 +1,23 @@ /* -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. + 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 + 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 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. + 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. + 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 "t8_vtk/t8_vtk_unstructured.hxx" diff --git a/src/t8_vtk/t8_vtk_unstructured.hxx b/src/t8_vtk/t8_vtk_unstructured.hxx index 2ae3925cc0..994c1a0968 100644 --- a/src/t8_vtk/t8_vtk_unstructured.hxx +++ b/src/t8_vtk/t8_vtk_unstructured.hxx @@ -1,23 +1,23 @@ /* -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. + 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 + 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 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. + 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. + 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_CMESH_VTK_UNSTRUCTURED_READER diff --git a/src/t8_vtk/t8_vtk_write_ASCII.cxx b/src/t8_vtk/t8_vtk_write_ASCII.cxx index e9afd23698..f2b7f45a24 100644 --- a/src/t8_vtk/t8_vtk_write_ASCII.cxx +++ b/src/t8_vtk/t8_vtk_write_ASCII.cxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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 "t8_vtk/t8_vtk_write_ASCII.hxx" diff --git a/src/t8_vtk/t8_vtk_write_ASCII.hxx b/src/t8_vtk/t8_vtk_write_ASCII.hxx index 114e32b868..aa04e0cd1a 100644 --- a/src/t8_vtk/t8_vtk_write_ASCII.hxx +++ b/src/t8_vtk/t8_vtk_write_ASCII.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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_WRITE_ASCII_HXX diff --git a/src/t8_vtk/t8_vtk_writer.cxx b/src/t8_vtk/t8_vtk_writer.cxx index 7c50a2c131..67f0172982 100644 --- a/src/t8_vtk/t8_vtk_writer.cxx +++ b/src/t8_vtk/t8_vtk_writer.cxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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 diff --git a/src/t8_vtk/t8_vtk_writer.h b/src/t8_vtk/t8_vtk_writer.h index a3a00b7111..1e65dc2f3f 100644 --- a/src/t8_vtk/t8_vtk_writer.h +++ b/src/t8_vtk/t8_vtk_writer.h @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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_WRITER_C_INTERFACE_H diff --git a/src/t8_vtk/t8_vtk_writer.hxx b/src/t8_vtk/t8_vtk_writer.hxx index 47a9669c4d..6bb94bfe4e 100644 --- a/src/t8_vtk/t8_vtk_writer.hxx +++ b/src/t8_vtk/t8_vtk_writer.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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_WRITER_HXX diff --git a/src/t8_vtk/t8_vtk_writer_helper.cxx b/src/t8_vtk/t8_vtk_writer_helper.cxx index c5ecae3c53..976c403c88 100644 --- a/src/t8_vtk/t8_vtk_writer_helper.cxx +++ b/src/t8_vtk/t8_vtk_writer_helper.cxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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 diff --git a/src/t8_vtk/t8_vtk_writer_helper.hxx b/src/t8_vtk/t8_vtk_writer_helper.hxx index c980dbad52..efe1832ef9 100644 --- a/src/t8_vtk/t8_vtk_writer_helper.hxx +++ b/src/t8_vtk/t8_vtk_writer_helper.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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_WRITER_HELPER diff --git a/test/t8_IO/t8_gtest_vtk_reader.cxx b/test/t8_IO/t8_gtest_vtk_reader.cxx index 51c992e9e1..3df4b8dfdc 100644 --- a/test/t8_IO/t8_gtest_vtk_reader.cxx +++ b/test/t8_IO/t8_gtest_vtk_reader.cxx @@ -1,23 +1,23 @@ /* -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. + 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 + 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 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. + 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. + 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 diff --git a/test/t8_IO/t8_gtest_vtk_writer.cxx b/test/t8_IO/t8_gtest_vtk_writer.cxx index 68195037ac..81fb56630f 100644 --- a/test/t8_IO/t8_gtest_vtk_writer.cxx +++ b/test/t8_IO/t8_gtest_vtk_writer.cxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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 diff --git a/test/t8_cmesh/t8_gtest_cmesh_tree_vertices_negative_volume.cxx b/test/t8_cmesh/t8_gtest_cmesh_tree_vertices_negative_volume.cxx index af0e714bfd..810f1847a0 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_tree_vertices_negative_volume.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_tree_vertices_negative_volume.cxx @@ -1,23 +1,23 @@ /* -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. + 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 the developers + 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 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. + 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. + 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_gtest_cmesh_tree_vertices_negative_volume.cxx diff --git a/test/t8_cmesh_generator/t8_cmesh_example_sets.hxx b/test/t8_cmesh_generator/t8_cmesh_example_sets.hxx index 769151c55e..0bdf5addaa 100644 --- a/test/t8_cmesh_generator/t8_cmesh_example_sets.hxx +++ b/test/t8_cmesh_generator/t8_cmesh_example_sets.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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_GTEST_CMESH_COMM_CREATOR_HXX diff --git a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_bigmesh_param.hxx b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_bigmesh_param.hxx index 848b12090b..9af128eee5 100644 --- a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_bigmesh_param.hxx +++ b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_bigmesh_param.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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_CMESH_NEW_BIGMESH_PARAM_HXX diff --git a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_comm.hxx b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_comm.hxx index d0da2f6160..3ad941b589 100644 --- a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_comm.hxx +++ b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_comm.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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_CMESH_NEW_COMM diff --git a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_disjoint_bricks_param.hxx b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_disjoint_bricks_param.hxx index 3e3c85b254..0d4658dfeb 100644 --- a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_disjoint_bricks_param.hxx +++ b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_disjoint_bricks_param.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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 "test/t8_cmesh_generator/t8_gtest_cmesh_cartestian_product.hxx" diff --git a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_empty.hxx b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_empty.hxx index 4f0974a429..1d0eb1e796 100644 --- a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_empty.hxx +++ b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_empty.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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_CMESH_NEW_EMPTY_HXX diff --git a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_from_class_param.hxx b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_from_class_param.hxx index 640200feae..cf24526e83 100644 --- a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_from_class_param.hxx +++ b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_from_class_param.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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 "test/t8_cmesh_generator/t8_gtest_cmesh_cartestian_product.hxx" diff --git a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_hypercube_pad.hxx b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_hypercube_pad.hxx index 7806f1d526..19b57fcfe6 100644 --- a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_hypercube_pad.hxx +++ b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_hypercube_pad.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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_CMESH_NEW_HYPERCUBE_PAD diff --git a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_hypercube_param.hxx b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_hypercube_param.hxx index b2e0ff85fd..e0639fe49d 100644 --- a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_hypercube_param.hxx +++ b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_hypercube_param.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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_CMESH_NEW_HYPERCUBE_PARAM_HXX diff --git a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_periodic.hxx b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_periodic.hxx index 0e1b0f4bc6..854db24ad8 100644 --- a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_periodic.hxx +++ b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_periodic.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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_CMESH_NEW_PERIODIC_HXX diff --git a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_prism_cake_param.hxx b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_prism_cake_param.hxx index c9521aeeb1..a63909f7ac 100644 --- a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_prism_cake_param.hxx +++ b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_prism_cake_param.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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 "test/t8_cmesh_generator/t8_gtest_cmesh_cartestian_product.hxx" diff --git a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_params.hxx b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_params.hxx index 0c86bba505..53c42de2a5 100644 --- a/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_params.hxx +++ b/test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_params.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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. */ /** diff --git a/test/t8_cmesh_generator/t8_gtest_cmesh_cartestian_product.hxx b/test/t8_cmesh_generator/t8_gtest_cmesh_cartestian_product.hxx index cec3c617da..1a4538e97d 100644 --- a/test/t8_cmesh_generator/t8_gtest_cmesh_cartestian_product.hxx +++ b/test/t8_cmesh_generator/t8_gtest_cmesh_cartestian_product.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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_GTEST_CMESH_CREATOR_BASE_HXX diff --git a/test/t8_cmesh_generator/t8_gtest_cmesh_generator_test.cxx b/test/t8_cmesh_generator/t8_gtest_cmesh_generator_test.cxx index 0130f7ad11..5056787115 100644 --- a/test/t8_cmesh_generator/t8_gtest_cmesh_generator_test.cxx +++ b/test/t8_cmesh_generator/t8_gtest_cmesh_generator_test.cxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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 diff --git a/test/t8_cmesh_generator/t8_gtest_cmesh_sum_of_sets.hxx b/test/t8_cmesh_generator/t8_gtest_cmesh_sum_of_sets.hxx index 49cafa2635..ad0bd9e2db 100644 --- a/test/t8_cmesh_generator/t8_gtest_cmesh_sum_of_sets.hxx +++ b/test/t8_cmesh_generator/t8_gtest_cmesh_sum_of_sets.hxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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_GTEST_cmesh_sum_of_sets_HXX diff --git a/test/t8_forest/t8_gtest_balance.cxx b/test/t8_forest/t8_gtest_balance.cxx index 2fc7857f97..3d4e3062ba 100644 --- a/test/t8_forest/t8_gtest_balance.cxx +++ b/test/t8_forest/t8_gtest_balance.cxx @@ -1,23 +1,23 @@ /* -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. + 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 + 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 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. + 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. + 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_gtest_balance.cxx diff --git a/test/t8_forest/t8_gtest_element_volume.cxx b/test/t8_forest/t8_gtest_element_volume.cxx index f0c20099d3..5edc73ea33 100644 --- a/test/t8_forest/t8_gtest_element_volume.cxx +++ b/test/t8_forest/t8_gtest_element_volume.cxx @@ -1,23 +1,23 @@ /* -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. + 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 + 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 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. + 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. + 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 diff --git a/test/t8_forest/t8_gtest_forest_face_normal.cxx b/test/t8_forest/t8_gtest_forest_face_normal.cxx index 83ed348087..659aa53ea9 100644 --- a/test/t8_forest/t8_gtest_forest_face_normal.cxx +++ b/test/t8_forest/t8_gtest_forest_face_normal.cxx @@ -1,23 +1,23 @@ /* -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. + 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 the developers + 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 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. + 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. + 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 diff --git a/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_lagrange.cxx b/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_lagrange.cxx index 7b8cf7e5aa..8fd697abff 100644 --- a/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_lagrange.cxx +++ b/test/t8_geometry/t8_geometry_implementations/t8_gtest_geometry_lagrange.cxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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_gtest_geometry_lagrange.cxx diff --git a/test/t8_gtest_custom_assertion.hxx b/test/t8_gtest_custom_assertion.hxx index 2341393781..e5cb271576 100644 --- a/test/t8_gtest_custom_assertion.hxx +++ b/test/t8_gtest_custom_assertion.hxx @@ -1,23 +1,23 @@ /* -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. + 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 the developers + 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 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. + 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. + 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_gtest_custom_assertion.cxx diff --git a/test/t8_gtest_macros.hxx b/test/t8_gtest_macros.hxx index 983f7a8e70..b3cdb559e2 100644 --- a/test/t8_gtest_macros.hxx +++ b/test/t8_gtest_macros.hxx @@ -1,23 +1,23 @@ /* -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. + 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 the developers + 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 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. + 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. + 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_gtest_macros.hxx diff --git a/test/t8_schemes/t8_gtest_ancestor.cxx b/test/t8_schemes/t8_gtest_ancestor.cxx index b067e85be8..05ca3df634 100644 --- a/test/t8_schemes/t8_gtest_ancestor.cxx +++ b/test/t8_schemes/t8_gtest_ancestor.cxx @@ -1,23 +1,23 @@ /* -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. + 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 + 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 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. + 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. + 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_gtest_nca.cxx diff --git a/test/t8_schemes/t8_gtest_element_ref_coords.cxx b/test/t8_schemes/t8_gtest_element_ref_coords.cxx index 325a946ab7..fa7e6ed0b9 100644 --- a/test/t8_schemes/t8_gtest_element_ref_coords.cxx +++ b/test/t8_schemes/t8_gtest_element_ref_coords.cxx @@ -1,23 +1,23 @@ /* -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. + 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 + 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 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. + 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. + 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_gtest_element_ref_coords.cxx diff --git a/test/t8_schemes/t8_gtest_init_linear_id.cxx b/test/t8_schemes/t8_gtest_init_linear_id.cxx index 253c850c56..7e2e6c419b 100644 --- a/test/t8_schemes/t8_gtest_init_linear_id.cxx +++ b/test/t8_schemes/t8_gtest_init_linear_id.cxx @@ -1,23 +1,23 @@ /* -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. + 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 + 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 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. + 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. + 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 diff --git a/test/t8_schemes/t8_gtest_nca.cxx b/test/t8_schemes/t8_gtest_nca.cxx index 5498e63f38..e78a07ece0 100644 --- a/test/t8_schemes/t8_gtest_nca.cxx +++ b/test/t8_schemes/t8_gtest_nca.cxx @@ -1,23 +1,23 @@ /* -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. + 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 + 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 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. + 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. + 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_gtest_nca.cxx diff --git a/test/t8_schemes/t8_gtest_pyra_connectivity.cxx b/test/t8_schemes/t8_gtest_pyra_connectivity.cxx index 399f15d9ec..4bc0ed6c06 100644 --- a/test/t8_schemes/t8_gtest_pyra_connectivity.cxx +++ b/test/t8_schemes/t8_gtest_pyra_connectivity.cxx @@ -1,23 +1,23 @@ /* -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. + 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 + 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 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. + 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. + 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. */ /** t8_test_pyra_connectivity.cxx diff --git a/test/t8_schemes/t8_gtest_root.cxx b/test/t8_schemes/t8_gtest_root.cxx index 5c92f313f5..63d546c6b4 100644 --- a/test/t8_schemes/t8_gtest_root.cxx +++ b/test/t8_schemes/t8_gtest_root.cxx @@ -1,23 +1,23 @@ /* -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. + 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) 2024 the developers + Copyright (C) 2024 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 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. + 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. + 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_gtest_root.cxx From f50d818fc01f001f1d39dd5e2ed1a60486571594 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 14 Aug 2024 15:38:41 +0200 Subject: [PATCH 78/87] fix copyright notice --- test/t8_schemes/t8_gtest_default.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/t8_schemes/t8_gtest_default.cxx b/test/t8_schemes/t8_gtest_default.cxx index ea361ac571..aab7410d43 100644 --- a/test/t8_schemes/t8_gtest_default.cxx +++ b/test/t8_schemes/t8_gtest_default.cxx @@ -1,10 +1,9 @@ /* 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. + connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2023 The University of Texas System - Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac + Copyright (C) 2024 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 From 0ed07241f2778da1151415440934b493510a3c42 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Wed, 14 Aug 2024 15:59:21 +0200 Subject: [PATCH 79/87] Update copyright notice. Co-authored-by: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> --- .../t8_gtest_geometry_triangular_interpolation.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx b/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx index d0b59be6b0..e1522b7694 100644 --- a/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx +++ b/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx @@ -1,10 +1,9 @@ /* 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. + connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2010 The University of Texas System - Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac + Copyright (C) 2024 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 From c44a5d7628f1b757818ca24a486fff1de5cf8df5 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Wed, 14 Aug 2024 16:03:14 +0200 Subject: [PATCH 80/87] Change eps to T8_PRECISION_EPS Co-authored-by: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> --- ...test_geometry_triangular_interpolation.cxx | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx b/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx index e1522b7694..b8664aafd4 100644 --- a/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx +++ b/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx @@ -44,8 +44,6 @@ * mapped to the corners of a triangle. */ TEST (triangular_interpolation, corners_map_to_corners_2d) { - const double eps = 1e-14; - const double coeff_A[2] = { 0, 0 }; const double coeff_B[2] = { 0, 1 }; const double coeff_C[2] = { 1, 1 }; @@ -67,8 +65,8 @@ TEST (triangular_interpolation, corners_map_to_corners_2d) // Check corner A // 2D t8_geom_triangular_interpolation (coeff_A, corner_values_2d, 2, dimension, result); - EXPECT_NEAR (cornerA[0], result[0], eps); - EXPECT_NEAR (cornerA[1], result[1], eps); + EXPECT_NEAR (cornerA[0], result[0], T8_PRECISION_EPS); + EXPECT_NEAR (cornerA[1], result[1], T8_PRECISION_EPS); // Check corner B // 2D @@ -79,16 +77,14 @@ TEST (triangular_interpolation, corners_map_to_corners_2d) // Check corner C // 2D t8_geom_triangular_interpolation (coeff_C, corner_values_2d, 2, dimension, result); - EXPECT_NEAR (cornerC[0], result[0], eps); - EXPECT_NEAR (cornerC[1], result[1], eps); + EXPECT_NEAR (cornerC[0], result[0], T8_PRECISION_EPS); + EXPECT_NEAR (cornerC[1], result[1], T8_PRECISION_EPS); } /* Check that the corner interpolation coordinates are * mapped to the corners of a tetrahedron. */ TEST (triangular_interpolation, corners_map_to_corners_3d) { - const double eps = 1e-14; - const double coeff_A[3] = { 0, 0, 0 }; const double coeff_B[3] = { 0, 1, 0 }; const double coeff_C[3] = { 1, 1, 0 }; @@ -113,28 +109,28 @@ TEST (triangular_interpolation, corners_map_to_corners_3d) // Check corner A // 3D t8_geom_triangular_interpolation (coeff_A, corner_values_3d, 3, dimension, result); - EXPECT_NEAR (cornerA[0], result[0], eps); - EXPECT_NEAR (cornerA[1], result[1], eps); - EXPECT_NEAR (cornerA[2], result[2], eps); + EXPECT_NEAR (cornerA[0], result[0], T8_PRECISION_EPS); + EXPECT_NEAR (cornerA[1], result[1], T8_PRECISION_EPS); + EXPECT_NEAR (cornerA[2], result[2], T8_PRECISION_EPS); // Check corner B // 3D t8_geom_triangular_interpolation (coeff_B, corner_values_3d, 3, dimension, result); - EXPECT_NEAR (cornerB[0], result[0], eps); - EXPECT_NEAR (cornerB[1], result[1], eps); - EXPECT_NEAR (cornerB[2], result[2], eps); + EXPECT_NEAR (cornerB[0], result[0], T8_PRECISION_EPS); + EXPECT_NEAR (cornerB[1], result[1], T8_PRECISION_EPS); + EXPECT_NEAR (cornerB[2], result[2], T8_PRECISION_EPS); // Check corner C // 3D t8_geom_triangular_interpolation (coeff_C, corner_values_3d, 3, dimension, result); - EXPECT_NEAR (cornerC[0], result[0], eps); - EXPECT_NEAR (cornerC[1], result[1], eps); - EXPECT_NEAR (cornerC[2], result[2], eps); + EXPECT_NEAR (cornerC[0], result[0], T8_PRECISION_EPS); + EXPECT_NEAR (cornerC[1], result[1], T8_PRECISION_EPS); + EXPECT_NEAR (cornerC[2], result[2], T8_PRECISION_EPS); // Check corner D // 3D t8_geom_triangular_interpolation (coeff_D, corner_values_3d, 3, dimension, result); - EXPECT_NEAR (cornerD[0], result[0], eps); - EXPECT_NEAR (cornerD[1], result[1], eps); - EXPECT_NEAR (cornerD[2], result[2], eps); + EXPECT_NEAR (cornerD[0], result[0], T8_PRECISION_EPS); + EXPECT_NEAR (cornerD[1], result[1], T8_PRECISION_EPS); + EXPECT_NEAR (cornerD[2], result[2], T8_PRECISION_EPS); } From a4a50eaa43f8855649e422033fa64eb22bad67f9 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Wed, 14 Aug 2024 16:05:50 +0200 Subject: [PATCH 81/87] change eps to T8_PRECISION_EPS --- .../t8_gtest_geometry_triangular_interpolation.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx b/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx index b8664aafd4..d549c8ff0a 100644 --- a/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx +++ b/test/t8_geometry/t8_gtest_geometry_triangular_interpolation.cxx @@ -71,8 +71,8 @@ TEST (triangular_interpolation, corners_map_to_corners_2d) // Check corner B // 2D t8_geom_triangular_interpolation (coeff_B, corner_values_2d, 2, dimension, result); - EXPECT_NEAR (cornerB[0], result[0], eps); - EXPECT_NEAR (cornerB[1], result[1], eps); + EXPECT_NEAR (cornerB[0], result[0], T8_PRECISION_EPS); + EXPECT_NEAR (cornerB[1], result[1], T8_PRECISION_EPS); // Check corner C // 2D From 93631ae260313b749c86e341eff4898ae48225be Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Wed, 14 Aug 2024 17:04:50 +0200 Subject: [PATCH 82/87] Increased example radius for disk and sphere. --- example/cmesh/t8_cmesh_geometry_examples.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/example/cmesh/t8_cmesh_geometry_examples.cxx b/example/cmesh/t8_cmesh_geometry_examples.cxx index b6aacb9196..99575d20d1 100644 --- a/example/cmesh/t8_cmesh_geometry_examples.cxx +++ b/example/cmesh/t8_cmesh_geometry_examples.cxx @@ -114,8 +114,8 @@ main (int argc, char **argv) const char *prefix_cmesh = "t8_quadrangulated_disk_cmesh"; const char *prefix_forest = "t8_quadrangulated_disk_forest"; - const int uniform_level = 6; - const double radius = 1.0; + const int uniform_level = 5; + const double radius = 5.0; t8_cmesh_t cmesh = t8_cmesh_new_quadrangulated_disk (radius, comm); @@ -288,7 +288,7 @@ main (int argc, char **argv) const char *prefix_forest = "t8_cubed_sphere_forest"; const int uniform_level = 2; - const double radius = 1.0; + const double radius = 5.0; t8_cmesh_t cmesh = t8_cmesh_new_cubed_sphere (radius, comm); From 48223afe1589712e36ae8aaecd38a9abc492ef83 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Thu, 15 Aug 2024 08:53:44 +0200 Subject: [PATCH 83/87] Updated comment --- 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 1ef95a7bf5..cbca823f13 100644 --- a/src/t8_forest/t8_forest_iterate.h +++ b/src/t8_forest/t8_forest_iterate.h @@ -43,7 +43,7 @@ typedef int (*t8_forest_iterate_face_fn) (t8_forest_t forest, t8_locidx_t ltreei * * \param[in] forest the forest * \param[in] ltreeid the local tree id of the current tree - * \param[in] element the element for which the query is executed + * \param[in] element the element for which the search criterion is checked. * \param[in] is_leaf true if and only if \a element is a leaf element * \param[in] leaf_elements the leaf elements in \a forest that are descendants of \a element (or the element * itself if \a is_leaf is true) From b3b88df49840da08e8c2610d7333883fbb97db0a Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Fri, 16 Aug 2024 12:32:23 +0200 Subject: [PATCH 84/87] remove [[maybe_unused]] attributes --- src/t8_forest/t8_forest_vtk.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index 7f726a72c0..c97044ef88 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -114,10 +114,10 @@ typedef int (*t8_forest_vtk_cell_data_kernel) (t8_forest_t forest, const t8_loci #define T8_FOREST_VTK_QUADRATIC_ELEMENT_MAX_CORNERS 20 /** Lookup table for number of nodes for curved eclasses. */ -[[maybe_unused]] const int t8_curved_eclass_num_nodes[T8_ECLASS_COUNT] = { 1, 3, 8, 6, 20, 10, 15, 13 }; +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 */ -[[maybe_unused]] const int t8_curved_eclass_vtk_type[T8_ECLASS_COUNT] = { 1, 21, 23, 22, 25, 24, 26, 27 }; +const int t8_curved_eclass_vtk_type[T8_ECLASS_COUNT] = { 1, 21, 23, 22, 25, 24, 26, 27 }; /** Map vtk element corners to element reference coordinates. The reference * coordinates are defined in such a way, that the linear vtk corners are listed From a62ab7a8a7e2c137572e5f40bc2835cbc4e9a749 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Fri, 16 Aug 2024 13:34:37 +0200 Subject: [PATCH 85/87] add macro around variable which is only used with vtk --- src/t8_vtk/t8_vtk_writer_helper.hxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/t8_vtk/t8_vtk_writer_helper.hxx b/src/t8_vtk/t8_vtk_writer_helper.hxx index c980dbad52..2b06fb1252 100644 --- a/src/t8_vtk/t8_vtk_writer_helper.hxx +++ b/src/t8_vtk/t8_vtk_writer_helper.hxx @@ -31,8 +31,10 @@ along with t8code; if not, write to the Free Software Foundation, Inc., /** 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 }; +#if T8_WITH_VTK /** 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 }; +#endif /** Map vtk element corners to element reference coordinates. The reference * coordinates are defined in such a way, that the linear vtk corners are listed From b65182dfd91f5fcc409543aefa37302fde7a06f6 Mon Sep 17 00:00:00 2001 From: Alex Dutka <97711898+dutkalex@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:16:08 +0200 Subject: [PATCH 86/87] Delete src/t8_cmesh/t8_cmesh_vtk_writer.c --- src/t8_cmesh/t8_cmesh_vtk_writer.c | 311 ----------------------------- 1 file changed, 311 deletions(-) delete mode 100644 src/t8_cmesh/t8_cmesh_vtk_writer.c diff --git a/src/t8_cmesh/t8_cmesh_vtk_writer.c b/src/t8_cmesh/t8_cmesh_vtk_writer.c deleted file mode 100644 index 1d38c47e16..0000000000 --- a/src/t8_cmesh/t8_cmesh_vtk_writer.c +++ /dev/null @@ -1,311 +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. -*/ - -#include -#include -#include "t8_cmesh_trees.h" -#include "t8_cmesh_types.h" - -/* Return the local number of vertices in a cmesh. - * \param [in] cmesh The cmesh to be considered. - * \param [in] count_ghosts If true, we also count the vertices of the ghost trees. - * \return The number of vertices associated to \a cmesh. - * \a cmesh must be committed before calling this function. - */ -static t8_gloidx_t -t8_cmesh_get_num_vertices (const t8_cmesh_t cmesh, const int count_ghosts) -{ - int iclass; - t8_eclass_t ghost_class; - t8_gloidx_t num_vertices = 0; - t8_locidx_t ighost; - T8_ASSERT (cmesh != NULL); - T8_ASSERT (cmesh->committed); - - for (iclass = T8_ECLASS_ZERO; iclass < T8_ECLASS_COUNT; iclass++) { - num_vertices += t8_eclass_num_vertices[iclass] * cmesh->num_local_trees_per_eclass[iclass]; - } - if (count_ghosts) { - /* Also count the vertices of the ghost trees */ - for (ighost = 0; ighost < t8_cmesh_get_num_ghosts (cmesh); ighost++) { - ghost_class = t8_cmesh_get_ghost_class (cmesh, ighost); - num_vertices += t8_eclass_num_vertices[ghost_class]; - } - } - - return num_vertices; -} - -static int -t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, const int write_ghosts) -{ - T8_ASSERT (cmesh != NULL); - T8_ASSERT (t8_cmesh_is_committed (cmesh)); - T8_ASSERT (fileprefix != NULL); - - if (cmesh->mpirank == 0) { - /* Write the pvtu header file. */ - int num_ranks_that_write = cmesh->set_partition ? cmesh->mpisize : 1; - if (t8_write_pvtu (fileprefix, num_ranks_that_write, 1, 1, 0, 0, 0, NULL)) { - SC_ABORTF ("Error when writing file %s.pvtu\n", fileprefix); - } - } - /* If the cmesh is replicated only rank 0 prints it, - * otherwise each process prints its part of the cmesh.*/ - if (cmesh->mpirank == 0 || cmesh->set_partition) { - char vtufilename[BUFSIZ]; - FILE *vtufile; - t8_locidx_t num_vertices, ivertex; - t8_locidx_t num_trees; - t8_ctree_t tree; - double x, y, z; - double *vertices, *vertex; - int k, sk; - long long offset, count_vertices; - t8_locidx_t ighost, num_ghosts = 0, num_loc_trees; -#ifdef T8_ENABLE_DEBUG - t8_cghost_t ghost; -#endif - t8_eclass_t eclass; - - num_vertices = t8_cmesh_get_num_vertices (cmesh, write_ghosts); - num_trees = t8_cmesh_get_num_local_trees (cmesh); - if (write_ghosts) { - num_trees += t8_cmesh_get_num_ghosts (cmesh); - } - - snprintf (vtufilename, BUFSIZ, "%s_%04d.vtu", fileprefix, cmesh->mpirank); - vtufile = fopen (vtufilename, "wb"); - if (vtufile == NULL) { - t8_global_errorf ("Could not open file %s for output.\n", vtufilename); - return -1; - } - fprintf (vtufile, "\n"); - fprintf (vtufile, "\n"); -#else - fprintf (vtufile, " byte_order=\"LittleEndian\">\n"); -#endif - fprintf (vtufile, " \n"); - fprintf (vtufile, " \n", (long long) num_vertices, - (long long) num_trees); - fprintf (vtufile, " \n"); - - /* write point position data */ - fprintf (vtufile, - " \n", - T8_VTK_FLOAT_NAME, T8_VTK_FORMAT_STRING); - - for (tree = t8_cmesh_get_first_tree (cmesh); tree != NULL; tree = t8_cmesh_get_next_tree (cmesh, tree)) { - /* TODO: Use new geometry here. Need cmesh_get_reference coords function. */ - vertices = t8_cmesh_get_tree_vertices (cmesh, tree->treeid); - for (ivertex = 0; ivertex < t8_eclass_num_vertices[tree->eclass]; ivertex++) { - vertex = vertices + 3 * t8_eclass_t8_to_vtk_corner_number[tree->eclass][ivertex]; - x = vertex[0]; - y = vertex[1]; - z = vertex[2]; -#ifdef T8_VTK_DOUBLES - fprintf (vtufile, " %24.16e %24.16e %24.16e\n", x, y, z); -#else - fprintf (vtufile, " %16.8e %16.8e %16.8e\n", x, y, z); -#endif - } - } /* end tree loop */ - if (write_ghosts) { - - /* Write the vertices of the ghost trees */ - num_ghosts = t8_cmesh_get_num_ghosts (cmesh); - num_loc_trees = t8_cmesh_get_num_local_trees (cmesh); - for (ighost = 0; ighost < num_ghosts; ighost++) { - /* Get the eclass of this ghost */ - eclass = t8_cmesh_get_ghost_class (cmesh, ighost); - /* Get a pointer to this ghosts vertices */ - vertices = (double *) t8_cmesh_get_attribute (cmesh, t8_get_package_id (), 0, ighost + num_loc_trees); - T8_ASSERT (vertices != NULL); - /* TODO: This code is duplicated above */ - for (ivertex = 0; ivertex < t8_eclass_num_vertices[eclass]; ivertex++) { - vertex = vertices + 3 * t8_eclass_vtk_to_t8_corner_number[eclass][ivertex]; - x = vertex[0]; - y = vertex[1]; - z = vertex[2]; -#ifdef T8_VTK_DOUBLES - fprintf (vtufile, " %24.16e %24.16e %24.16e\n", x, y, z); -#else - fprintf (vtufile, " %16.8e %16.8e %16.8e\n", x, y, z); -#endif - } - } /* end ghost loop */ - } - fprintf (vtufile, " \n"); - fprintf (vtufile, " \n"); - fprintf (vtufile, " \n"); - - /* write connectivity data */ - fprintf (vtufile, - " \n", - T8_VTK_LOCIDX, T8_VTK_FORMAT_STRING); - for (tree = t8_cmesh_get_first_tree (cmesh), count_vertices = 0; tree != NULL; - tree = t8_cmesh_get_next_tree (cmesh, tree)) { - fprintf (vtufile, " "); - for (k = 0; k < t8_eclass_num_vertices[tree->eclass]; ++k, count_vertices++) { - fprintf (vtufile, " %lld", count_vertices); - } - fprintf (vtufile, "\n"); - } - if (write_ghosts) { - /* Write the ghost connectivity */ - for (ighost = 0; ighost < num_ghosts; ighost++) { - eclass = t8_cmesh_get_ghost_class (cmesh, ighost); - fprintf (vtufile, " "); - for (k = 0; k < t8_eclass_num_vertices[eclass]; ++k, count_vertices++) { - fprintf (vtufile, " %lld", count_vertices); - } - fprintf (vtufile, "\n"); - } - } - fprintf (vtufile, " \n"); - - /* write offset data */ - fprintf (vtufile, - " \n", - T8_VTK_LOCIDX, T8_VTK_FORMAT_STRING); - fprintf (vtufile, " "); - for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1, offset = 0; tree != NULL; - tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { - offset += t8_eclass_num_vertices[tree->eclass]; - fprintf (vtufile, " %lld", offset); - if (!(sk % 8)) - fprintf (vtufile, "\n "); - } - if (write_ghosts) { - /* ghost offset data */ - for (ighost = 0; ighost < num_ghosts; ighost++, ++sk) { - eclass = t8_cmesh_get_ghost_class (cmesh, ighost); - offset += t8_eclass_num_vertices[eclass]; - fprintf (vtufile, " %lld", offset); - if (!(sk % 8)) - fprintf (vtufile, "\n "); - } - } - fprintf (vtufile, "\n"); - fprintf (vtufile, " \n"); - /* write type data */ - fprintf (vtufile, - " \n", - T8_VTK_FORMAT_STRING); - fprintf (vtufile, " "); - for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1; tree != NULL; - tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { - fprintf (vtufile, " %d", t8_eclass_vtk_type[tree->eclass]); - if (!(sk % 20) && tree->treeid != (cmesh->num_local_trees - 1)) - fprintf (vtufile, "\n "); - } - if (write_ghosts) { - /* ghost offset types */ - for (ighost = 0; ighost < num_ghosts; ighost++, ++sk) { - eclass = t8_cmesh_get_ghost_class (cmesh, ighost); - fprintf (vtufile, " %d", t8_eclass_vtk_type[eclass]); - if (!(sk % 20) && ighost != (num_ghosts - 1)) - fprintf (vtufile, "\n "); - } - } - fprintf (vtufile, "\n"); - fprintf (vtufile, " \n"); - fprintf (vtufile, " \n"); - /* write treeif data */ - fprintf (vtufile, " \n"); - fprintf (vtufile, - " \n", - T8_VTK_GLOIDX, T8_VTK_FORMAT_STRING); - fprintf (vtufile, " "); - for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1, offset = 0; tree != NULL; - tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { - /* Since tree_id is actually 64 Bit but we store it as 32, we have to check - * that we do not get into conversion errors */ - /* TODO: We switched to 32 Bit because Paraview could not handle 64 well enough. - */ - T8_ASSERT (tree->treeid + cmesh->first_tree == (t8_gloidx_t) ((long) tree->treeid + cmesh->first_tree)); - T8_ASSERT (tree->treeid + cmesh->first_tree == tree->treeid + (t8_locidx_t) cmesh->first_tree); - fprintf (vtufile, " %ld", (long)(tree->treeid + (t8_locidx_t) cmesh->first_tree)); - if (!(sk % 8)) - fprintf (vtufile, "\n "); - } - if (write_ghosts) { - /* ghost offset types */ - for (ighost = 0; ighost < num_ghosts; ighost++, ++sk) { -#ifdef T8_ENABLE_DEBUG - ghost = t8_cmesh_trees_get_ghost (cmesh->trees, ighost); - /* Check for conversion errors */ - T8_ASSERT (ghost->treeid == (t8_gloidx_t) ((long) ghost->treeid)); -#endif - /* Write -1 as tree_id so that we can distinguish ghosts from normal trees - * in the vtk file */ - fprintf (vtufile, " %ld", (long) -1); - if (!(sk % 8)) - fprintf (vtufile, "\n "); - } - } - fprintf (vtufile, "\n"); - fprintf (vtufile, " \n"); - /* write mpirank data */ - fprintf (vtufile, - " \n", - "Int32", T8_VTK_FORMAT_STRING); - fprintf (vtufile, " "); - for (tree = t8_cmesh_get_first_tree (cmesh), sk = 1, offset = 0; tree != NULL; - tree = t8_cmesh_get_next_tree (cmesh, tree), ++sk) { - fprintf (vtufile, " %i", cmesh->mpirank); - if (!(sk % 8)) - fprintf (vtufile, "\n "); - } - if (write_ghosts) { - /* write our rank for each ghost */ - for (ighost = 0; ighost < num_ghosts; ighost++, ++sk) { - fprintf (vtufile, " %i", cmesh->mpirank); - if (!(sk % 8)) - fprintf (vtufile, "\n "); - } - } - fprintf (vtufile, "\n"); - fprintf (vtufile, " \n"); - fprintf (vtufile, " \n"); - /* write type data */ - fprintf (vtufile, " \n"); - fprintf (vtufile, " \n"); - fprintf (vtufile, "\n"); - fclose (vtufile); - } - return 0; -} - -int -t8_cmesh_vtk_write_file (const t8_cmesh_t cmesh, const char *fileprefix) -{ - return t8_cmesh_vtk_write_file_ext (cmesh, fileprefix, 1); -} From 6399e1605ba7c0b35cae725d83a11bbbcd6a1c2a Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Fri, 16 Aug 2024 16:25:44 +0200 Subject: [PATCH 87/87] indent --- src/t8_cmesh/t8_cmesh_geometry.cxx | 2 +- src/t8_cmesh/t8_cmesh_partition.cxx | 5 +++-- src/t8_cmesh/t8_cmesh_readmshfile.cxx | 4 ++-- src/t8_cmesh/t8_cmesh_triangle.cxx | 2 +- src/t8_geometry/t8_geometry_base.hxx | 2 +- src/t8_geometry/t8_geometry_handler.cxx | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_geometry.cxx b/src/t8_cmesh/t8_cmesh_geometry.cxx index 68a15da36f..eca196b4bf 100644 --- a/src/t8_cmesh/t8_cmesh_geometry.cxx +++ b/src/t8_cmesh/t8_cmesh_geometry.cxx @@ -97,7 +97,7 @@ t8_cmesh_get_tree_geom_hash (const t8_cmesh_t cmesh, const t8_gloidx_t gtreeid) const size_t *hash = (const size_t *) t8_cmesh_get_attribute (cmesh, t8_get_package_id (), T8_CMESH_GEOMETRY_ATTRIBUTE_KEY, ltreeid); if (hash == nullptr) { - SC_ABORTF ("Could not find geometry for tree %ld.", static_cast(gtreeid)); + SC_ABORTF ("Could not find geometry for tree %ld.", static_cast (gtreeid)); } return *hash; } diff --git a/src/t8_cmesh/t8_cmesh_partition.cxx b/src/t8_cmesh/t8_cmesh_partition.cxx index d0fd523884..b9de8fbc54 100644 --- a/src/t8_cmesh/t8_cmesh_partition.cxx +++ b/src/t8_cmesh/t8_cmesh_partition.cxx @@ -391,7 +391,8 @@ t8_cmesh_partition_sendrange (const t8_cmesh_t cmesh, const t8_cmesh_t cmesh_fro ret--; } - t8_debugf ("%s_first = %i, %s_last = %i, last_tree = %li\n", "send", *send_first, "send", *send_last, static_cast(ret)); + t8_debugf ("%s_first = %i, %s_last = %i, last_tree = %li\n", "send", *send_first, "send", *send_last, + static_cast (ret)); T8_ASSERT (*send_first >= 0); //TODO:reactivate T8_ASSERT (*send_last >= 0); @@ -1412,7 +1413,7 @@ t8_cmesh_partition_debug_listprocs (const t8_cmesh_t cmesh, const t8_cmesh_t cme } } t8_debugf ("I send to: %s\n", out); - std::strcpy(out, " "); + std::strcpy (out, " "); if (cmesh_from->set_partition) { for (p = 0; p < mpisize; p++) { if (t8_offset_sendsto (p, mpirank, from, to)) { diff --git a/src/t8_cmesh/t8_cmesh_readmshfile.cxx b/src/t8_cmesh/t8_cmesh_readmshfile.cxx index 094e25622d..18479c58d5 100644 --- a/src/t8_cmesh/t8_cmesh_readmshfile.cxx +++ b/src/t8_cmesh/t8_cmesh_readmshfile.cxx @@ -634,7 +634,7 @@ t8_cmesh_msh_file_2_read_eles (t8_cmesh_t cmesh, FILE *fp, sc_hash_t *vertices, int switch_indices[4] = { 0 }; int iswitch; T8_ASSERT (t8_eclass_to_dimension[eclass] > 1); - t8_debugf ("Correcting negative volume of tree %li\n", static_cast(tree_count)); + t8_debugf ("Correcting negative volume of tree %li\n", static_cast (tree_count)); switch (eclass) { case T8_ECLASS_TRIANGLE: case T8_ECLASS_QUAD: @@ -973,7 +973,7 @@ t8_cmesh_msh_file_4_read_eles (t8_cmesh_t cmesh, FILE *fp, sc_hash_t *vertices, int switch_indices[4] = { 0 }; int iswitch; T8_ASSERT (t8_eclass_to_dimension[eclass] > 1); - t8_debugf ("Correcting negative volume of tree %li\n", static_cast(tree_count)); + t8_debugf ("Correcting negative volume of tree %li\n", static_cast (tree_count)); switch (eclass) { case T8_ECLASS_TRIANGLE: case T8_ECLASS_QUAD: diff --git a/src/t8_cmesh/t8_cmesh_triangle.cxx b/src/t8_cmesh/t8_cmesh_triangle.cxx index 4651dd5c59..6d66dae5c4 100644 --- a/src/t8_cmesh/t8_cmesh_triangle.cxx +++ b/src/t8_cmesh/t8_cmesh_triangle.cxx @@ -262,7 +262,7 @@ t8_cmesh_triangle_read_eles (t8_cmesh_t cmesh, int corner_offset, char *filename double temp; T8_ASSERT (dim == 3); - t8_debugf ("Correcting negative volume of tree %li\n", static_cast(triangle - triangle_offset)); + t8_debugf ("Correcting negative volume of tree %li\n", static_cast (triangle - triangle_offset)); /* We switch vertex 0 and vertex 1 */ for (i = 0; i < 3; i++) { temp = tree_vertices[i]; diff --git a/src/t8_geometry/t8_geometry_base.hxx b/src/t8_geometry/t8_geometry_base.hxx index 43a7e01c43..cc96324199 100644 --- a/src/t8_geometry/t8_geometry_base.hxx +++ b/src/t8_geometry/t8_geometry_base.hxx @@ -156,7 +156,7 @@ struct t8_geometry * Get the name of this geometry. * \return The name. */ - inline const std::string& + inline const std::string & t8_geom_get_name () const { return name; diff --git a/src/t8_geometry/t8_geometry_handler.cxx b/src/t8_geometry/t8_geometry_handler.cxx index a64fc47412..57900be091 100644 --- a/src/t8_geometry/t8_geometry_handler.cxx +++ b/src/t8_geometry/t8_geometry_handler.cxx @@ -62,7 +62,7 @@ t8_geometry_handler::update_tree (t8_cmesh_t cmesh, t8_gloidx_t gtreeid) active_geometry = get_geometry (geom_hash); SC_CHECK_ABORTF (active_geometry != nullptr, "Could not find geometry with hash %zu or tree %ld has no registered geometry.", geom_hash, - static_cast(gtreeid)); + static_cast (gtreeid)); } /* Get the user data for this geometry and this tree. */ active_geometry->t8_geom_load_tree_data (cmesh, gtreeid);