From f09ca12e1e18ba82223c9df21cfec89e925a58c1 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Wed, 13 Sep 2023 16:35:41 +0200 Subject: [PATCH 01/58] Add an option to use axis-aligned geometry for hex/quad/lines in hypercube_pad --- example/cmesh/t8_cmesh_hypercube_pad.cxx | 2 +- example/remove/t8_example_empty_trees.cxx | 3 ++- src/t8_cmesh/t8_cmesh_examples.c | 16 ++++++++++++---- src/t8_cmesh/t8_cmesh_examples.h | 2 +- .../t8_gtest_cmesh_set_join_by_vertices.cxx | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/example/cmesh/t8_cmesh_hypercube_pad.cxx b/example/cmesh/t8_cmesh_hypercube_pad.cxx index 6af89db1b5..3e8239a653 100644 --- a/example/cmesh/t8_cmesh_hypercube_pad.cxx +++ b/example/cmesh/t8_cmesh_hypercube_pad.cxx @@ -46,7 +46,7 @@ main (int argc, char **argv) t8_init (SC_LP_PRODUCTION); /* Add hypercube with given element class. */ - t8_cmesh_t cmesh = t8_cmesh_new_hypercube_pad (T8_ECLASS_HEX, sc_MPI_COMM_WORLD, boundary_coords, 3, 3, 3); + t8_cmesh_t cmesh = t8_cmesh_new_hypercube_pad (T8_ECLASS_HEX, sc_MPI_COMM_WORLD, boundary_coords, 3, 3, 3, 0); /* Compute local and global number of trees. */ local_num_trees = t8_cmesh_get_num_local_trees (cmesh); diff --git a/example/remove/t8_example_empty_trees.cxx b/example/remove/t8_example_empty_trees.cxx index 5194548129..b7b7465e6d 100644 --- a/example/remove/t8_example_empty_trees.cxx +++ b/example/remove/t8_example_empty_trees.cxx @@ -50,7 +50,8 @@ t8_strip_of_quads (t8_gloidx_t num_trees, t8_gloidx_t empty_tree, const char **v const double boundary_coords[12] = { 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0 }; - t8_cmesh_t cmesh = t8_cmesh_new_hypercube_pad (T8_ECLASS_QUAD, sc_MPI_COMM_WORLD, boundary_coords, num_trees, 1, 0); + t8_cmesh_t cmesh + = t8_cmesh_new_hypercube_pad (T8_ECLASS_QUAD, sc_MPI_COMM_WORLD, boundary_coords, num_trees, 1, 0, 1); t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), 0, 0, sc_MPI_COMM_WORLD); diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index a399b334b6..a8a0d122f9 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -1194,7 +1195,7 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub t8_cmesh_t t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, - t8_locidx_t polygons_y, t8_locidx_t polygons_z) + t8_locidx_t polygons_y, t8_locidx_t polygons_z, int use_axis_aligned) { SC_CHECK_ABORT (eclass != T8_ECLASS_PYRAMID, "Pyramids are not yet supported."); const int dim = t8_eclass_to_dimension[eclass]; @@ -1215,9 +1216,16 @@ t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const do t8_cmesh_t cmesh; t8_cmesh_init (&cmesh); - /* We use standard linear geometry */ - const t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); - t8_cmesh_register_geometry (cmesh, linear_geom); + if (use_axis_aligned && (eclass == T8_ECLASS_HEX || eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_LINE)) { + /* We use axis aligned geometries */ + const t8_geometry_c *axis_aligned_geom = t8_geometry_linear_axis_aligned_new (dim); + t8_cmesh_register_geometry (cmesh, axis_aligned_geom); + } + else { + /* We use standard linear geometry */ + const t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); + t8_cmesh_register_geometry (cmesh, linear_geom); + } /* Number of trees inside each polygon of given eclass. */ const t8_locidx_t num_trees_for_single_hypercube[T8_ECLASS_COUNT] = { 1, 1, 1, 2, 1, 6, 2, -1 }; diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 986966e01b..a6f9bd0e6a 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -132,7 +132,7 @@ t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int */ t8_cmesh_t t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, - t8_locidx_t polygons_y, t8_locidx_t polygons_z); + t8_locidx_t polygons_y, t8_locidx_t polygons_z, int use_axis_aligned); /** Hybercube with 6 Tets, 6 Prism, 4 Hex. * \param [in] comm The mpi communicator to be used. diff --git a/test/t8_cmesh/t8_gtest_cmesh_set_join_by_vertices.cxx b/test/t8_cmesh/t8_gtest_cmesh_set_join_by_vertices.cxx index c7676ddec1..12d4398f85 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_set_join_by_vertices.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_set_join_by_vertices.cxx @@ -241,7 +241,7 @@ TEST (t8_cmesh_set_join_by_vertices, test_cmesh_set_join_by_vertices) const double boundary_coords[24] = { 1, 0, 0, 4, 0, 0, 0, 6, 0, 5, 5, 0, -1, -2, 8, 9, 0, 10, 0, 8, 9, 10, 10, 10 }; t8_eclass_t eclass = T8_ECLASS_HEX; - t8_cmesh_t cmesh = t8_cmesh_new_hypercube_pad (eclass, comm, boundary_coords, 2, 2, 2); + t8_cmesh_t cmesh = t8_cmesh_new_hypercube_pad (eclass, comm, boundary_coords, 2, 2, 2, 0); test_with_cmesh (cmesh); t8_cmesh_destroy (&cmesh); } From 636abd26a479834f9e38c375eae86b6fde47a211 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Thu, 14 Sep 2023 10:00:19 +0200 Subject: [PATCH 02/58] Adapt construction of tree-vertices --- src/t8_cmesh/t8_cmesh_examples.c | 77 +++++++++++++++++++------------- 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index a8a0d122f9..a48c911522 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -885,12 +885,13 @@ t8_resize_box (const int dim, double *box_corners, const double *box_dir, const * \param [in] boundary The boundary vertices of \a cmesh. * \param [in] quads_x The number of quads along the x-axis. * \param [in] quads_y The number of quads along the y-axis. + * \param [in] use_axis_aligned_geom Flag if cmesh uses the axis_aligned_geometry. Only available for T8_ECLASS_QUAD * \note each quad of \a quads_x * \a quads_y quads in \a boundary contains one * tree of \a eclass T8_ECLASS_QUAD or two of T8_ECLASS_TRIANGLE. */ static void t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const double *boundary, const t8_locidx_t quads_x, - const t8_locidx_t quads_y) + const t8_locidx_t quads_y, const int use_axis_aligned_geom) { T8_ASSERT (!t8_cmesh_is_committed (cmesh)); T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_TRIANGLE); @@ -941,21 +942,28 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub for (t8_locidx_t quad_y_id = 0; quad_y_id < quads_y; quad_y_id++) { for (t8_locidx_t quad_x_id = 0; quad_x_id < quads_x; quad_x_id++) { - t8_vec_axy (box, vertices, 1.0); /* Vertex 0 */ - t8_vec_axpyz (box, box_dir, vertices + 6, 1.0); /* Vertex 2 */ + if (use_axis_aligned_geom && eclass == T8_ECLASS_QUAD) { + t8_vec_axy (box, vertices, 1.0); /* Vertex 0*/ + t8_vec_axpyz (box, box_dir, vertices + 9, 1.0); /* Vertex 3 */ + } + else { + t8_vec_axy (box, vertices, 1.0); /* Vertex 0 */ + t8_vec_axpyz (box, box_dir, vertices + 6, 1.0); /* Vertex 2 */ - /* Reduce box along x axis */ - t8_resize_box (2, box, box_dir, 0, 1, box_quads); - t8_update_box_face_edges (2, box, box_dir, 0, box_quads); + /* Reduce box along x axis */ + t8_resize_box (2, box, box_dir, 0, 1, box_quads); + t8_update_box_face_edges (2, box, box_dir, 0, box_quads); - t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ - t8_vec_axpyz (box, box_dir, vertices + 9, 1.0); /* Vertex 3 */ + t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ + t8_vec_axpyz (box, box_dir, vertices + 9, 1.0); /* Vertex 3 */ + } /* Map vertices of current quad on to respective trees inside. */ if (eclass == T8_ECLASS_QUAD) { /* No mapping is required. */ const t8_locidx_t tree_id = quad_y_id * quads_x + quad_x_id; - t8_cmesh_set_tree_vertices (cmesh, tree_id, vertices, 4); + t8_cmesh_set_tree_vertices (cmesh, tree_id, vertices, + (use_axis_aligned_geom && eclass == T8_ECLASS_QUAD) ? 2 : 4); } else { T8_ASSERT (eclass == T8_ECLASS_TRIANGLE); @@ -998,12 +1006,13 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub * \param [in] hexs_x The number of hexs along the x-axis. * \param [in] hexs_y The number of hexs along the y-axis. * \param [in] hexs_z The number of hexs along the z-axis. + * \param [in] use_axis_aligned_geom Flag if cmesh uses the axis aligned_geometry. Only available for T8_ECLASS_QUAD * \note each hex of \a hexs_x * \a hexs_y * \a hexs_z hexs in \a boundary * contains several trees of class \a eclass. */ static void t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const double *boundary, const t8_locidx_t hexs_x, - const t8_locidx_t hexs_y, const t8_locidx_t hexs_z) + const t8_locidx_t hexs_y, const t8_locidx_t hexs_z, const int use_axis_aligned_geom) { T8_ASSERT (!t8_cmesh_is_committed (cmesh)); /* x axes */ @@ -1079,36 +1088,42 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub for (t8_locidx_t hex_z_id = 0; hex_z_id < hexs_z; hex_z_id++) { for (t8_locidx_t hex_y_id = 0; hex_y_id < hexs_y; hex_y_id++) { for (t8_locidx_t hex_x_id = 0; hex_x_id < hexs_x; hex_x_id++) { + if (use_axis_aligned_geom && eclass == T8_ECLASS_HEX) { + t8_vec_axy (box, vertices, 1.0); /* Vertex 0 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 21, 1.0); /* Vertex 7 */ + } + else { + t8_vec_axy (box, vertices, 1.0); /* Vertex 0 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 6, 1.0); /* Vertex 2 */ - t8_vec_axy (box, vertices, 1.0); /* Vertex 0 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 6, 1.0); /* Vertex 2 */ - - /* Reduce box along z axis and face 4. */ - t8_resize_box (3, box, box_dir, 4, 1, box_hexs); - t8_update_box_face_edges (3, box, box_dir, 4, box_hexs); + /* Reduce box along z axis and face 4. */ + t8_resize_box (3, box, box_dir, 4, 1, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 4, box_hexs); - t8_vec_axy (box, vertices + 12, 1.0); /* Vertex 4 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 18, 1.0); /* Vertex 6 */ + t8_vec_axy (box, vertices + 12, 1.0); /* Vertex 4 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 18, 1.0); /* Vertex 6 */ - /* Reduce box along x axis and face 0. */ - t8_resize_box (3, box, box_dir, 0, 1, box_hexs); - t8_update_box_face_edges (3, box, box_dir, 0, box_hexs); + /* Reduce box along x axis and face 0. */ + t8_resize_box (3, box, box_dir, 0, 1, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 0, box_hexs); - t8_vec_axy (box, vertices + 15, 1.0); /* Vertex 5 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 21, 1.0); /* Vertex 7 */ + t8_vec_axy (box, vertices + 15, 1.0); /* Vertex 5 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 21, 1.0); /* Vertex 7 */ - /* Increase box along z axis and and face 4 */ - t8_resize_box (3, box, box_dir, 4, -1, box_hexs); - t8_update_box_face_edges (3, box, box_dir, 4, box_hexs); + /* Increase box along z axis and and face 4 */ + t8_resize_box (3, box, box_dir, 4, -1, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 4, box_hexs); - t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 9, 1.0); /* Vertex 3 */ + t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 9, 1.0); /* Vertex 3 */ + } /* Map vertices of current hex on to respective trees inside. */ const t8_locidx_t hex_id = hex_z_id * hexs_y * hexs_x + hex_y_id * hexs_x + hex_x_id; if (eclass == T8_ECLASS_HEX) { /* No mapping is required. */ - t8_cmesh_set_tree_vertices (cmesh, hex_id, vertices, 8); + t8_cmesh_set_tree_vertices (cmesh, hex_id, vertices, + (use_axis_aligned_geom && eclass == T8_ECLASS_HEX) ? 2 : 8); } else if (eclass == T8_ECLASS_TET) { const t8_locidx_t tree_id_0 = hex_id * 6; @@ -1239,11 +1254,11 @@ t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const do /* Set the vertices of all trees. */ if (dim == 3) { T8_ASSERT (eclass == T8_ECLASS_HEX || eclass == T8_ECLASS_TET || eclass == T8_ECLASS_PRISM); - t8_cmesh_set_vertices_3D (cmesh, eclass, boundary, polygons_x, polygons_y, polygons_z); + t8_cmesh_set_vertices_3D (cmesh, eclass, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned); } else if (dim == 2) { T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_TRIANGLE); - t8_cmesh_set_vertices_2D (cmesh, eclass, boundary, polygons_x, polygons_y); + t8_cmesh_set_vertices_2D (cmesh, eclass, boundary, polygons_x, polygons_y, use_axis_aligned); } else if (dim == 1) { T8_ASSERT (eclass == T8_ECLASS_LINE); From 4d15fe05b90626ab2114bc721fa97a9d9d86ef0c Mon Sep 17 00:00:00 2001 From: David Knapp Date: Thu, 14 Sep 2023 10:01:31 +0200 Subject: [PATCH 03/58] Make use_axis_aligned const --- src/t8_cmesh/t8_cmesh_examples.c | 2 +- src/t8_cmesh/t8_cmesh_examples.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index a48c911522..cce0710d20 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1210,7 +1210,7 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub t8_cmesh_t t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, - t8_locidx_t polygons_y, t8_locidx_t polygons_z, int use_axis_aligned) + t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int use_axis_aligned) { SC_CHECK_ABORT (eclass != T8_ECLASS_PYRAMID, "Pyramids are not yet supported."); const int dim = t8_eclass_to_dimension[eclass]; diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index a6f9bd0e6a..652daa3d26 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -132,7 +132,7 @@ t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int */ t8_cmesh_t t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, - t8_locidx_t polygons_y, t8_locidx_t polygons_z, int use_axis_aligned); + t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int use_axis_aligned); /** Hybercube with 6 Tets, 6 Prism, 4 Hex. * \param [in] comm The mpi communicator to be used. From b5af4a8354417a52e861e5e534ae16cb6c78cca7 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Thu, 14 Sep 2023 10:02:57 +0200 Subject: [PATCH 04/58] Update variable name --- src/t8_cmesh/t8_cmesh_examples.c | 8 ++++---- src/t8_cmesh/t8_cmesh_examples.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index cce0710d20..6c91a04ec7 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1210,7 +1210,7 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub t8_cmesh_t t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, - t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int use_axis_aligned) + t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int use_axis_aligned_geom) { SC_CHECK_ABORT (eclass != T8_ECLASS_PYRAMID, "Pyramids are not yet supported."); const int dim = t8_eclass_to_dimension[eclass]; @@ -1231,7 +1231,7 @@ t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const do t8_cmesh_t cmesh; t8_cmesh_init (&cmesh); - if (use_axis_aligned && (eclass == T8_ECLASS_HEX || eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_LINE)) { + if (use_axis_aligned_geom && (eclass == T8_ECLASS_HEX || eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_LINE)) { /* We use axis aligned geometries */ const t8_geometry_c *axis_aligned_geom = t8_geometry_linear_axis_aligned_new (dim); t8_cmesh_register_geometry (cmesh, axis_aligned_geom); @@ -1254,11 +1254,11 @@ t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const do /* Set the vertices of all trees. */ if (dim == 3) { T8_ASSERT (eclass == T8_ECLASS_HEX || eclass == T8_ECLASS_TET || eclass == T8_ECLASS_PRISM); - t8_cmesh_set_vertices_3D (cmesh, eclass, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned); + t8_cmesh_set_vertices_3D (cmesh, eclass, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned_geom); } else if (dim == 2) { T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_TRIANGLE); - t8_cmesh_set_vertices_2D (cmesh, eclass, boundary, polygons_x, polygons_y, use_axis_aligned); + t8_cmesh_set_vertices_2D (cmesh, eclass, boundary, polygons_x, polygons_y, use_axis_aligned_geom); } else if (dim == 1) { T8_ASSERT (eclass == T8_ECLASS_LINE); diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 652daa3d26..1a8301b5c1 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -132,7 +132,7 @@ t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int */ t8_cmesh_t t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, - t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int use_axis_aligned); + t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int use_axis_aligned_geom); /** Hybercube with 6 Tets, 6 Prism, 4 Hex. * \param [in] comm The mpi communicator to be used. From 07b6474077c78633695d3d75d3a9915c31c1dd79 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Thu, 14 Sep 2023 10:04:00 +0200 Subject: [PATCH 05/58] Add documentation --- src/t8_cmesh/t8_cmesh_examples.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 1a8301b5c1..0b0b423285 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -106,6 +106,8 @@ t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int * Only required if \a eclass is 2D or 3D. * \param [in] polygons_z The number of polygons along the z-axis. * Only required if \a eclass is 3D. + * \param [in] use_axis_aligned_geom Flag if cmesh uses the axis aligned_geometry. Only available for + * T8_ECLASS_LINE/QUAD/HEX * \return A committed t8_cmesh structure with * \a polygons_x * \a polygons_z * \a polygons_y many * sub-hypercubes of class \a eclass. From 72ef89a42a9bbba07f20659dc99cedca429e3152 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 15 Sep 2023 15:17:12 +0200 Subject: [PATCH 06/58] restructre hypercube_pad for axis_aligned geometries --- src/t8_cmesh/t8_cmesh_examples.c | 73 +++++++++++++++++--------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 6c91a04ec7..16828cbf05 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -942,21 +942,23 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub for (t8_locidx_t quad_y_id = 0; quad_y_id < quads_y; quad_y_id++) { for (t8_locidx_t quad_x_id = 0; quad_x_id < quads_x; quad_x_id++) { - if (use_axis_aligned_geom && eclass == T8_ECLASS_QUAD) { - t8_vec_axy (box, vertices, 1.0); /* Vertex 0*/ - t8_vec_axpyz (box, box_dir, vertices + 9, 1.0); /* Vertex 3 */ - } - else { - t8_vec_axy (box, vertices, 1.0); /* Vertex 0 */ - t8_vec_axpyz (box, box_dir, vertices + 6, 1.0); /* Vertex 2 */ + memcpy (vertices, box, 3 * sizeof (double)); /* Vertex 0 */ + t8_vec_axpyz (box, box_dir, vertices + 6, 1.0); /* Vertex 2 */ - /* Reduce box along x axis */ - t8_resize_box (2, box, box_dir, 0, 1, box_quads); - t8_update_box_face_edges (2, box, box_dir, 0, box_quads); + /* Reduce box along x axis */ + t8_resize_box (2, box, box_dir, 0, 1, box_quads); + t8_update_box_face_edges (2, box, box_dir, 0, box_quads); - t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ - t8_vec_axpyz (box, box_dir, vertices + 9, 1.0); /* Vertex 3 */ + t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ + t8_vec_axpyz (box, box_dir, vertices + 9, 1.0); /* Vertex 3 */ + if (use_axis_aligned_geom && eclass == T8_ECLASS_QUAD) { + memcpy (vertices, vertices + 9, 3 * sizeof (double)); + } +#if T8_ENABLE_DEBUG + else if (use_axis_aligned_geom && eclass != T8_ECLASS_QUAD) { + SC_ABORTF ("Axis aligned geometry is not available for eclass %s!\n", t8_eclass_to_string[eclass]); } +#endif /* Map vertices of current quad on to respective trees inside. */ if (eclass == T8_ECLASS_QUAD) { @@ -1088,35 +1090,38 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub for (t8_locidx_t hex_z_id = 0; hex_z_id < hexs_z; hex_z_id++) { for (t8_locidx_t hex_y_id = 0; hex_y_id < hexs_y; hex_y_id++) { for (t8_locidx_t hex_x_id = 0; hex_x_id < hexs_x; hex_x_id++) { - if (use_axis_aligned_geom && eclass == T8_ECLASS_HEX) { - t8_vec_axy (box, vertices, 1.0); /* Vertex 0 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 21, 1.0); /* Vertex 7 */ - } - else { - t8_vec_axy (box, vertices, 1.0); /* Vertex 0 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 6, 1.0); /* Vertex 2 */ + memcpy (vertices, box, 3 * sizeof (double)); /* Vertex 0 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 6, 1.0); /* Vertex 2 */ + + /* Reduce box along z axis and face 4. */ + t8_resize_box (3, box, box_dir, 4, 1, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 4, box_hexs); - /* Reduce box along z axis and face 4. */ - t8_resize_box (3, box, box_dir, 4, 1, box_hexs); - t8_update_box_face_edges (3, box, box_dir, 4, box_hexs); + t8_vec_axy (box, vertices + 12, 1.0); /* Vertex 4 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 18, 1.0); /* Vertex 6 */ - t8_vec_axy (box, vertices + 12, 1.0); /* Vertex 4 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 18, 1.0); /* Vertex 6 */ + /* Reduce box along x axis and face 0. */ + t8_resize_box (3, box, box_dir, 0, 1, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 0, box_hexs); - /* Reduce box along x axis and face 0. */ - t8_resize_box (3, box, box_dir, 0, 1, box_hexs); - t8_update_box_face_edges (3, box, box_dir, 0, box_hexs); + t8_vec_axy (box, vertices + 15, 1.0); /* Vertex 5 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 21, 1.0); /* Vertex 7 */ - t8_vec_axy (box, vertices + 15, 1.0); /* Vertex 5 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 21, 1.0); /* Vertex 7 */ + /* Increase box along z axis and and face 4 */ + t8_resize_box (3, box, box_dir, 4, -1, box_hexs); + t8_update_box_face_edges (3, box, box_dir, 4, box_hexs); - /* Increase box along z axis and and face 4 */ - t8_resize_box (3, box, box_dir, 4, -1, box_hexs); - t8_update_box_face_edges (3, box, box_dir, 4, box_hexs); + t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ + t8_vec_axpyz (box, box_dir + 12, vertices + 9, 1.0); /* Vertex 3 */ - t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ - t8_vec_axpyz (box, box_dir + 12, vertices + 9, 1.0); /* Vertex 3 */ + if (use_axis_aligned_geom && eclass == T8_ECLASS_HEX) { + memcpy (vertices + 3, vertices + 21, 3 * sizeof (double)); + } +#if T8_ENABLE_DEBUG + else if (use_axis_aligned_geom && eclass != T8_ECLASS_HEX) { + SC_ABORTF ("Axis aligned geometry is not available for eclass %s!\n", t8_eclass_to_string[eclass]); } +#endif /* Map vertices of current hex on to respective trees inside. */ const t8_locidx_t hex_id = hex_z_id * hexs_y * hexs_x + hex_y_id * hexs_x + hex_x_id; From 335880c8670c8e5443a427f5ad1003778e463094 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 15 Sep 2023 15:18:47 +0200 Subject: [PATCH 07/58] add documentation --- src/t8_cmesh/t8_cmesh_examples.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 16828cbf05..a4c4821f2e 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -952,6 +952,8 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub t8_vec_axy (box, vertices + 3, 1.0); /* Vertex 1 */ t8_vec_axpyz (box, box_dir, vertices + 9, 1.0); /* Vertex 3 */ if (use_axis_aligned_geom && eclass == T8_ECLASS_QUAD) { + /* Copy vertex 3 into the place of vertex 1. The box-procedure has to be done to compute + * vertex 3 correctly. */ memcpy (vertices, vertices + 9, 3 * sizeof (double)); } #if T8_ENABLE_DEBUG @@ -1115,6 +1117,8 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub t8_vec_axpyz (box, box_dir + 12, vertices + 9, 1.0); /* Vertex 3 */ if (use_axis_aligned_geom && eclass == T8_ECLASS_HEX) { + /* Copy vertex 7 into the place of vertex 1. The box-procedure has to be done to compute + * vertex 7 correctly. */ memcpy (vertices + 3, vertices + 21, 3 * sizeof (double)); } #if T8_ENABLE_DEBUG From 1411fcc8ff9f889bca625086be902d9319a06682 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 15 Sep 2023 15:21:56 +0200 Subject: [PATCH 08/58] Add another check --- src/t8_cmesh/t8_cmesh_examples.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index a4c4821f2e..cff7f508ee 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1245,6 +1245,12 @@ t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const do const t8_geometry_c *axis_aligned_geom = t8_geometry_linear_axis_aligned_new (dim); t8_cmesh_register_geometry (cmesh, axis_aligned_geom); } +#if T8_ENABLE_DEBUG + else if (use_axis_aligned_geom + && !(eclass == T8_ECLASS_HEX || eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_LINE)) { + SC_ABORTF ("Axis aligned geometry is not available for eclass %s!\n", t8_eclass_to_string[eclass]); + } +#endif else { /* We use standard linear geometry */ const t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); From af2497b8455e960a0dceb4c6cb89fc11a5945eb9 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 15 Sep 2023 15:42:12 +0200 Subject: [PATCH 09/58] Correct index --- src/t8_cmesh/t8_cmesh_examples.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index cff7f508ee..857b57d1bc 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -954,7 +954,7 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub if (use_axis_aligned_geom && eclass == T8_ECLASS_QUAD) { /* Copy vertex 3 into the place of vertex 1. The box-procedure has to be done to compute * vertex 3 correctly. */ - memcpy (vertices, vertices + 9, 3 * sizeof (double)); + memcpy (vertices + 3, vertices + 9, 3 * sizeof (double)); } #if T8_ENABLE_DEBUG else if (use_axis_aligned_geom && eclass != T8_ECLASS_QUAD) { From 1b94268cb66c4ed9c0e6df7fde68ebf91078c9a8 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 6 Oct 2023 14:35:37 +0200 Subject: [PATCH 10/58] Use the geometry as an argument to pass to hypercube_pad --- example/remove/t8_example_empty_trees.cxx | 4 ++- src/t8_cmesh/t8_cmesh_examples.c | 25 +++++-------------- src/t8_cmesh/t8_cmesh_examples.h | 6 ++--- .../t8_gtest_cmesh_set_join_by_vertices.cxx | 4 ++- test/t8_geometry/t8_gtest_point_inside.cxx | 5 ++++ 5 files changed, 20 insertions(+), 24 deletions(-) diff --git a/example/remove/t8_example_empty_trees.cxx b/example/remove/t8_example_empty_trees.cxx index b7b7465e6d..ca03fe0b5f 100644 --- a/example/remove/t8_example_empty_trees.cxx +++ b/example/remove/t8_example_empty_trees.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -49,9 +50,10 @@ t8_strip_of_quads (t8_gloidx_t num_trees, t8_gloidx_t empty_tree, const char **v { const double boundary_coords[12] = { 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0 }; + const t8_geometry_c *geometry = t8_geometry_linear_axis_aligned_new (2); t8_cmesh_t cmesh - = t8_cmesh_new_hypercube_pad (T8_ECLASS_QUAD, sc_MPI_COMM_WORLD, boundary_coords, num_trees, 1, 0, 1); + = t8_cmesh_new_hypercube_pad (T8_ECLASS_QUAD, sc_MPI_COMM_WORLD, boundary_coords, num_trees, 1, 0, geometry); t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), 0, 0, sc_MPI_COMM_WORLD); diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 857b57d1bc..be3589585a 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1219,7 +1219,7 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub t8_cmesh_t t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, - t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int use_axis_aligned_geom) + t8_locidx_t polygons_y, t8_locidx_t polygons_z, const t8_geometry_c *geometry) { SC_CHECK_ABORT (eclass != T8_ECLASS_PYRAMID, "Pyramids are not yet supported."); const int dim = t8_eclass_to_dimension[eclass]; @@ -1240,22 +1240,9 @@ t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const do t8_cmesh_t cmesh; t8_cmesh_init (&cmesh); - if (use_axis_aligned_geom && (eclass == T8_ECLASS_HEX || eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_LINE)) { - /* We use axis aligned geometries */ - const t8_geometry_c *axis_aligned_geom = t8_geometry_linear_axis_aligned_new (dim); - t8_cmesh_register_geometry (cmesh, axis_aligned_geom); - } -#if T8_ENABLE_DEBUG - else if (use_axis_aligned_geom - && !(eclass == T8_ECLASS_HEX || eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_LINE)) { - SC_ABORTF ("Axis aligned geometry is not available for eclass %s!\n", t8_eclass_to_string[eclass]); - } -#endif - else { - /* We use standard linear geometry */ - const t8_geometry_c *linear_geom = t8_geometry_linear_new (dim); - t8_cmesh_register_geometry (cmesh, linear_geom); - } + const int is_axis_aligned = t8_geom_is_linear_axis_aligned (geometry); + + t8_cmesh_register_geometry (cmesh, geometry); /* Number of trees inside each polygon of given eclass. */ const t8_locidx_t num_trees_for_single_hypercube[T8_ECLASS_COUNT] = { 1, 1, 1, 2, 1, 6, 2, -1 }; @@ -1269,11 +1256,11 @@ t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const do /* Set the vertices of all trees. */ if (dim == 3) { T8_ASSERT (eclass == T8_ECLASS_HEX || eclass == T8_ECLASS_TET || eclass == T8_ECLASS_PRISM); - t8_cmesh_set_vertices_3D (cmesh, eclass, boundary, polygons_x, polygons_y, polygons_z, use_axis_aligned_geom); + t8_cmesh_set_vertices_3D (cmesh, eclass, boundary, polygons_x, polygons_y, polygons_z, is_axis_aligned); } else if (dim == 2) { T8_ASSERT (eclass == T8_ECLASS_QUAD || eclass == T8_ECLASS_TRIANGLE); - t8_cmesh_set_vertices_2D (cmesh, eclass, boundary, polygons_x, polygons_y, use_axis_aligned_geom); + t8_cmesh_set_vertices_2D (cmesh, eclass, boundary, polygons_x, polygons_y, is_axis_aligned); } else if (dim == 1) { T8_ASSERT (eclass == T8_ECLASS_LINE); diff --git a/src/t8_cmesh/t8_cmesh_examples.h b/src/t8_cmesh/t8_cmesh_examples.h index 0b0b423285..147ad29d9d 100644 --- a/src/t8_cmesh/t8_cmesh_examples.h +++ b/src/t8_cmesh/t8_cmesh_examples.h @@ -30,6 +30,7 @@ #include #include #include +#include T8_EXTERN_C_BEGIN (); @@ -106,8 +107,7 @@ t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int * Only required if \a eclass is 2D or 3D. * \param [in] polygons_z The number of polygons along the z-axis. * Only required if \a eclass is 3D. - * \param [in] use_axis_aligned_geom Flag if cmesh uses the axis aligned_geometry. Only available for - * T8_ECLASS_LINE/QUAD/HEX + * \param [in] geometry The geometry to use. If the geometry is axis_aligned only two points per tree are stored * \return A committed t8_cmesh structure with * \a polygons_x * \a polygons_z * \a polygons_y many * sub-hypercubes of class \a eclass. @@ -134,7 +134,7 @@ t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int */ t8_cmesh_t t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x, - t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int use_axis_aligned_geom); + t8_locidx_t polygons_y, t8_locidx_t polygons_z, const t8_geometry_c *geometry); /** Hybercube with 6 Tets, 6 Prism, 4 Hex. * \param [in] comm The mpi communicator to be used. diff --git a/test/t8_cmesh/t8_gtest_cmesh_set_join_by_vertices.cxx b/test/t8_cmesh/t8_gtest_cmesh_set_join_by_vertices.cxx index 12d4398f85..b78c5eb046 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_set_join_by_vertices.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_set_join_by_vertices.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -241,7 +242,8 @@ TEST (t8_cmesh_set_join_by_vertices, test_cmesh_set_join_by_vertices) const double boundary_coords[24] = { 1, 0, 0, 4, 0, 0, 0, 6, 0, 5, 5, 0, -1, -2, 8, 9, 0, 10, 0, 8, 9, 10, 10, 10 }; t8_eclass_t eclass = T8_ECLASS_HEX; - t8_cmesh_t cmesh = t8_cmesh_new_hypercube_pad (eclass, comm, boundary_coords, 2, 2, 2, 0); + t8_geometry_c *geometry = new t8_geometry_linear (3); + t8_cmesh_t cmesh = t8_cmesh_new_hypercube_pad (eclass, comm, boundary_coords, 2, 2, 2, geometry); test_with_cmesh (cmesh); t8_cmesh_destroy (&cmesh); } diff --git a/test/t8_geometry/t8_gtest_point_inside.cxx b/test/t8_geometry/t8_gtest_point_inside.cxx index 9c3b9abac3..10d662b558 100644 --- a/test/t8_geometry/t8_gtest_point_inside.cxx +++ b/test/t8_geometry/t8_gtest_point_inside.cxx @@ -33,6 +33,11 @@ #include #include #include +<<<<<<< HEAD +======= +#include +#include +>>>>>>> c4633209... Use the geometry as an argument to pass to hypercube_pad /* In this test we define a triangle in the x-y plane * and a point that lies in a triangle that is parallel From 41651c96395f223f6cd69f6d9f7f0ff8d4380f59 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 6 Oct 2023 14:43:26 +0200 Subject: [PATCH 11/58] Indentation --- test/t8_geometry/t8_gtest_point_inside.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/t8_geometry/t8_gtest_point_inside.cxx b/test/t8_geometry/t8_gtest_point_inside.cxx index 10d662b558..48ba58123e 100644 --- a/test/t8_geometry/t8_gtest_point_inside.cxx +++ b/test/t8_geometry/t8_gtest_point_inside.cxx @@ -37,15 +37,15 @@ ======= #include #include ->>>>>>> c4633209... Use the geometry as an argument to pass to hypercube_pad + >>>>>>> c4633209... Use the geometry as an argument to pass to hypercube_pad -/* In this test we define a triangle in the x-y plane + /* In this test we define a triangle in the x-y plane * and a point that lies in a triangle that is parallel * to this triangle on the z-axis. * The point must be correctly identified as lying outside * of the triangle. */ -TEST (t8_point_inside, test_point_inside_specific_triangle) + TEST (t8_point_inside, test_point_inside_specific_triangle) { t8_cmesh_t cmesh; From 954d101122b3f31c555a5a9daaa708fef0fe0332 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 6 Oct 2023 14:51:24 +0200 Subject: [PATCH 12/58] Remove debug-flags from is_axis_aligned_check --- .../t8_geometry_linear_axis_aligned.cxx | 2 -- .../t8_geometry_linear_axis_aligned.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.cxx index f11615e350..581d85e892 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.cxx @@ -77,7 +77,6 @@ t8_geometry_linear_axis_aligned_destroy (t8_geometry_c **geom) *geom = NULL; } -#if T8_ENABLE_DEBUG int t8_geom_is_linear_axis_aligned (const t8_geometry_c *geometry) { @@ -90,6 +89,5 @@ t8_geom_is_linear_axis_aligned (const t8_geometry_c *geometry) return is_linear_axis_aligned_geom; } -#endif T8_EXTERN_C_END (); diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.h b/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.h index 73781c62e6..bd7d68e8f8 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.h +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.h @@ -54,7 +54,6 @@ t8_geometry_linear_axis_aligned_new (int dim); void t8_geometry_linear_axis_aligned_destroy (t8_geometry_c **geom); -#if T8_ENABLE_DEBUG /** Query whether a given geometry is \ref t8_geometry_linear_axis_aligned. * \param [in] geometry A geometry. * \return True (non-zero) if and only if the geometry is of @@ -63,7 +62,6 @@ t8_geometry_linear_axis_aligned_destroy (t8_geometry_c **geom); */ int t8_geom_is_linear_axis_aligned (const t8_geometry_c *geometry); -#endif T8_EXTERN_C_END (); From 48bb7d936fa5bc524fb15a9cfc0b5b1fce85688f Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 6 Oct 2023 14:56:35 +0200 Subject: [PATCH 13/58] Clean-up --- test/t8_geometry/t8_gtest_point_inside.cxx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/test/t8_geometry/t8_gtest_point_inside.cxx b/test/t8_geometry/t8_gtest_point_inside.cxx index 48ba58123e..9c3b9abac3 100644 --- a/test/t8_geometry/t8_gtest_point_inside.cxx +++ b/test/t8_geometry/t8_gtest_point_inside.cxx @@ -33,19 +33,14 @@ #include #include #include -<<<<<<< HEAD -======= -#include -#include - >>>>>>> c4633209... Use the geometry as an argument to pass to hypercube_pad - /* In this test we define a triangle in the x-y plane +/* In this test we define a triangle in the x-y plane * and a point that lies in a triangle that is parallel * to this triangle on the z-axis. * The point must be correctly identified as lying outside * of the triangle. */ - TEST (t8_point_inside, test_point_inside_specific_triangle) +TEST (t8_point_inside, test_point_inside_specific_triangle) { t8_cmesh_t cmesh; From 9942484a3a8ca9beb904983d77134d628e114728 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Tue, 14 Nov 2023 15:53:05 +0100 Subject: [PATCH 14/58] Add a test for t8_cmesh_set_partition_offsets for underived cmeshes. According to a comment in the code, t8_cmesh_set_partition_offsets does not work with underived cmeshes. We started with test cases to check this comment. --- test/Makefile.am | 10 ++++ .../t8_gtest_cmesh_set_partition_offsets.cxx | 55 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx diff --git a/test/Makefile.am b/test/Makefile.am index d7c1ec92f5..3b90523a5d 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -26,6 +26,7 @@ t8code_googletest_programs = \ test/t8_schemes/t8_gtest_find_parent \ test/t8_cmesh/t8_gtest_cmesh_face_is_boundary \ test/t8_cmesh/t8_gtest_cmesh_partition \ + test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets \ test/t8_cmesh/t8_gtest_cmesh_set_join_by_vertices \ test/t8_forest/t8_gtest_element_volume \ test/t8_cmesh/t8_gtest_multiple_attributes \ @@ -149,6 +150,10 @@ test_t8_cmesh_t8_gtest_cmesh_face_is_boundary_SOURCES = \ test_t8_cmesh_t8_gtest_cmesh_partition_SOURCES = \ test/t8_gtest_main.cxx \ test/t8_cmesh/t8_gtest_cmesh_partition.cxx + +test_t8_cmesh_t8_gtest_cmesh_set_partition_offsets_SOURCES = \ + test/t8_gtest_main.cxx \ + test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx test_t8_forest_t8_gtest_element_volume_SOURCES = \ test/t8_gtest_main.cxx \ @@ -339,6 +344,10 @@ test_t8_cmesh_t8_gtest_cmesh_partition_LDADD = $(t8_gtest_target_ld_add) test_t8_cmesh_t8_gtest_cmesh_partition_LDFLAGS = $(t8_gtest_target_ld_flags) test_t8_cmesh_t8_gtest_cmesh_partition_CPPFLAGS = $(t8_gtest_target_cpp_flags) +test_t8_cmesh_t8_gtest_cmesh_set_partition_offsets_LDADD = $(t8_gtest_target_ld_add) +test_t8_cmesh_t8_gtest_cmesh_set_partition_offsets_LDFLAGS = $(t8_gtest_target_ld_flags) +test_t8_cmesh_t8_gtest_cmesh_set_partition_offsets_CPPFLAGS = $(t8_gtest_target_cpp_flags) + test_t8_forest_t8_gtest_element_volume_LDADD = $(t8_gtest_target_ld_add) test_t8_forest_t8_gtest_element_volume_LDFLAGS = $(t8_gtest_target_ld_flags) test_t8_forest_t8_gtest_element_volume_CPPFLAGS = $(t8_gtest_target_cpp_flags) @@ -454,6 +463,7 @@ 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) test_t8_cmesh_t8_gtest_cmesh_face_is_boundary_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_cmesh_t8_gtest_cmesh_partition_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) +test_t8_cmesh_t8_gtest_cmesh_set_partition_offsets_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_forest_t8_gtest_element_volume_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_cmesh_t8_gtest_multiple_attributes_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_schemes_t8_gtest_successor_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) diff --git a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx new file mode 100644 index 0000000000..5881824498 --- /dev/null +++ b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx @@ -0,0 +1,55 @@ +/* + 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 "t8_cmesh/t8_cmesh_trees.h" +#include "t8_cmesh/t8_cmesh_partition.h" +#include + +/* We create a cmesh, partition it and repartition it several times. + * At the end we result in the same partition as at the beginning and we + * compare this cmesh with the initial one. If they are equal the test is + * passed. + */ + +TEST (t8_cmesh_set_partition_offsets, test_set_offsets) +{ + t8_cmesh_t cmesh; + const t8_gloidx_t num_trees = 1; + const int main_process = 0; + /* Build a valid offset array. For this test it is onlt necessary that + * the array corresponds to any valid partition. + * We use the offset_concentrate function to build an offset array for a partition + * that concentrates all trees at one process. */ + t8_shmem_init (sc_MPI_COMM_WORLD); + t8_shmem_array_t shmem_array = t8_cmesh_offset_concentrate (main_process, sc_MPI_COMM_WORLD, num_trees); + + /* Initialize the cmesh */ + t8_cmesh_init (&cmesh); + + /* Set the partition offsets */ + t8_cmesh_set_partition_offsets (cmesh, shmem_array); + /* Destroy the cmesh */ + t8_cmesh_unref (&cmesh); +} From ed67426437f1afb7fe3168b228e5e5b41702f08f Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 14 Nov 2023 16:06:14 +0100 Subject: [PATCH 15/58] Remove file --- example/cmesh/t8_cmesh_refine.cxx | 111 ------------------------------ 1 file changed, 111 deletions(-) delete mode 100644 example/cmesh/t8_cmesh_refine.cxx diff --git a/example/cmesh/t8_cmesh_refine.cxx b/example/cmesh/t8_cmesh_refine.cxx deleted file mode 100644 index ce6dc9fabb..0000000000 --- a/example/cmesh/t8_cmesh_refine.cxx +++ /dev/null @@ -1,111 +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 types in parallel. - - Copyright (C) 2015 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include - -/* TODO: rename this file to t8_something */ - -/* Create a small hybrid mesh in dimension 2 and refine it - * to a given level. */ -static void -t8_refine_hybrid (int level) -{ - t8_cmesh_t cmesh, cmesh_refine; - - t8_global_productionf ("Enter refine_hybrid\n"); - t8_cmesh_init (&cmesh); - t8_cmesh_init (&cmesh_refine); - t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_QUAD); - t8_cmesh_set_tree_class (cmesh, 1, T8_ECLASS_TRIANGLE); - - t8_cmesh_set_join (cmesh, 0, 1, 2, 1, 0); - t8_cmesh_commit (cmesh, sc_MPI_COMM_WORLD); - t8_cmesh_set_derive (cmesh_refine, cmesh); - t8_cmesh_set_refine (cmesh_refine, level, t8_scheme_new_default_cxx ()); - t8_cmesh_commit (cmesh_refine, sc_MPI_COMM_WORLD); - t8_cmesh_destroy (&cmesh_refine); - t8_global_productionf ("Done refine_hybrid\n"); -} - -/* Create a unit cube out of a given eclass and - * refine it to a given level. */ -static void -t8_refine_cube (t8_eclass_t eclass, int level) -{ - t8_cmesh_t cmesh, cmesh_refine; - - t8_global_productionf ("Enter refine_cube\n"); - cmesh = t8_cmesh_new_hypercube (eclass, sc_MPI_COMM_WORLD, 0, 0, 0); - t8_cmesh_init (&cmesh_refine); - t8_cmesh_set_derive (cmesh_refine, cmesh); - t8_cmesh_set_refine (cmesh_refine, level, t8_scheme_new_default_cxx ()); - t8_cmesh_commit (cmesh_refine, sc_MPI_COMM_WORLD); - t8_cmesh_destroy (&cmesh_refine); - t8_global_productionf ("Done refine_cube\n"); -} - -/* Create a cmesh from a p4est brick connectivity - * and refine it to a given level. */ -static void -t8_refine_p4est (int level) -{ - t8_cmesh_t cmesh, cmesh_refine; - p4est_connectivity_t *conn; - - t8_global_productionf ("Enter refine_p4est\n"); - conn = p4est_connectivity_new_brick (3, 2, 0, 0); - cmesh = t8_cmesh_new_from_p4est (conn, sc_MPI_COMM_WORLD, 0); - p4est_connectivity_destroy (conn); - t8_cmesh_init (&cmesh_refine); - t8_cmesh_set_derive (cmesh_refine, cmesh); - t8_cmesh_set_refine (cmesh_refine, level, t8_scheme_new_default_cxx ()); - t8_cmesh_commit (cmesh_refine, sc_MPI_COMM_WORLD); - t8_cmesh_destroy (&cmesh_refine); - t8_global_productionf ("Done refine_p4est\n"); -} - -int -main (int argc, char **argv) -{ - int mpiret, level; - - mpiret = sc_MPI_Init (&argc, &argv); - SC_CHECK_MPI (mpiret); - - sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_ESSENTIAL); - t8_init (SC_LP_DEFAULT); - - level = 2; - t8_refine_p4est (level); - t8_refine_cube (T8_ECLASS_TRIANGLE, level); - /* TODO: does not work with level > 0 yet */ - t8_refine_hybrid (0); - - sc_finalize (); - - mpiret = sc_MPI_Finalize (); - SC_CHECK_MPI (mpiret); - return 0; -} From 150da2a2c8f0e21cac70de42f9bf950a63b45686 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 14 Nov 2023 16:13:16 +0100 Subject: [PATCH 16/58] Update Makefile --- example/cmesh/Makefile.am | 2 -- 1 file changed, 2 deletions(-) diff --git a/example/cmesh/Makefile.am b/example/cmesh/Makefile.am index d5ad9154bd..c1ad61dfd3 100644 --- a/example/cmesh/Makefile.am +++ b/example/cmesh/Makefile.am @@ -5,13 +5,11 @@ bin_PROGRAMS += \ example/cmesh/t8_cmesh_partition \ example/cmesh/t8_cmesh_create_partitioned \ - example/cmesh/t8_cmesh_refine \ example/cmesh/t8_cmesh_set_join_by_vertices \ example/cmesh/t8_cmesh_geometry_examples \ example/cmesh/t8_cmesh_hypercube_pad example_cmesh_t8_cmesh_partition_SOURCES = example/cmesh/t8_cmesh_partition.cxx -example_cmesh_t8_cmesh_refine_SOURCES = example/cmesh/t8_cmesh_refine.cxx example_cmesh_t8_cmesh_set_join_by_vertices_SOURCES = example/cmesh/t8_cmesh_set_join_by_vertices.cxx example_cmesh_t8_cmesh_geometry_examples_SOURCES = example/cmesh/t8_cmesh_geometry_examples.cxx example_cmesh_t8_cmesh_create_partitioned_SOURCES = example/cmesh/t8_cmesh_create_partitioned.cxx From d635497e8fa6f8729d65584802239e8fc3eabf7a Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Wed, 15 Nov 2023 15:58:07 +0100 Subject: [PATCH 17/58] in cmesh_reset only check comm valid if cmesh is committed --- src/t8_cmesh/t8_cmesh.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh.c b/src/t8_cmesh/t8_cmesh.c index fd60612ed9..4133e4ba08 100644 --- a/src/t8_cmesh/t8_cmesh.c +++ b/src/t8_cmesh/t8_cmesh.c @@ -1165,8 +1165,10 @@ t8_cmesh_reset (t8_cmesh_t *pcmesh) sc_MPI_Comm comm; /* Check whether a correct communicator was stored at tree_offsets. * This is useful for debugging. */ - comm = t8_shmem_array_get_comm (cmesh->tree_offsets); - T8_ASSERT (t8_cmesh_comm_is_valid (cmesh, comm)); + if (t8_cmesh_is_committed (cmesh)) { + comm = t8_shmem_array_get_comm (cmesh->tree_offsets); + T8_ASSERT (t8_cmesh_comm_is_valid (cmesh, comm)); + } #endif /* Destroy the shared memory array */ t8_shmem_array_destroy (&cmesh->tree_offsets); From 1cc3130e614edfd7fe2921c63690efd5402c1459 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Wed, 15 Nov 2023 16:02:00 +0100 Subject: [PATCH 18/58] Add a second test for t8_cmesh_offset_concentrate where the cmesh is committed. --- .../t8_gtest_cmesh_set_partition_offsets.cxx | 45 ++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx index 5881824498..27ba71cbfb 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx @@ -27,13 +27,14 @@ #include "t8_cmesh/t8_cmesh_partition.h" #include -/* We create a cmesh, partition it and repartition it several times. - * At the end we result in the same partition as at the beginning and we - * compare this cmesh with the initial one. If they are equal the test is - * passed. +/* At the time of this writing (November 15 2023) t8_cmesh_offset_concentrate + * has a comment stating it does not work with non-derived cmeshes. + * We write the tests in this file to check this. */ -TEST (t8_cmesh_set_partition_offsets, test_set_offsets) +/* call t8_cmesh_offset_concentrate for non-derived cmesh + * and destroy it before commit. */ +TEST (t8_cmesh_set_partition_offsets, test_set_offsets_nocommit) { t8_cmesh_t cmesh; const t8_gloidx_t num_trees = 1; @@ -53,3 +54,37 @@ TEST (t8_cmesh_set_partition_offsets, test_set_offsets) /* Destroy the cmesh */ t8_cmesh_unref (&cmesh); } + +/* call t8_cmesh_offset_concentrate for non-derived cmesh + * and commit it. */ +TEST (t8_cmesh_set_partition_offsets, test_set_offsets_commit) +{ + t8_cmesh_t cmesh; + const t8_gloidx_t num_trees = 1; + const int main_process = 0; + sc_MPI_Comm comm = sc_MPI_COMM_WORLD; + /* Build a valid offset array. For this test it is onlt necessary that + * the array corresponds to any valid partition. + * We use the offset_concentrate function to build an offset array for a partition + * that concentrates all trees at one process. */ + t8_shmem_init (comm); + t8_shmem_array_t shmem_array = t8_cmesh_offset_concentrate (main_process, comm, num_trees); + + /* Initialize the cmesh */ + t8_cmesh_init (&cmesh); + + /* Set the partition offsets */ + t8_cmesh_set_partition_offsets (cmesh, shmem_array); + + /* Specify a dimension */ + t8_cmesh_set_dimension (cmesh, 0); + + /* Set class for the trees */ + t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_VERTEX); + + /* Commit the cmesh */ + t8_cmesh_commit (cmesh, comm); + + /* Destroy the cmesh */ + t8_cmesh_unref (&cmesh); +} From 7ac9908bcf0d348370b93b7aaff6709730943d07 Mon Sep 17 00:00:00 2001 From: "Dreyer, Lukas" Date: Fri, 3 Nov 2023 18:30:43 +0100 Subject: [PATCH 19/58] Enforce c++ 17 --- Makefile.am | 1 + config/ax_cxx_compile_stdcxx.m4 | 1018 +++++++++++++++++++++++++++++++ config/t8_include.m4 | 3 +- config/t8_stdpp.m4 | 4 +- configure.ac | 6 + test/Makefile.am | 5 +- 6 files changed, 1031 insertions(+), 6 deletions(-) create mode 100644 config/ax_cxx_compile_stdcxx.m4 diff --git a/Makefile.am b/Makefile.am index adb20acd68..c5edcd6ca7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -42,6 +42,7 @@ Makefile.t8.mk : Makefile.t8.pre # install t8code m4 macros in the correct directory t8aclocaldir = $(datadir)/aclocal dist_t8aclocal_DATA = config/t8_include.m4 \ + config/ax_cxx_compile_stdcxx.m4 \ config/t8_stdpp.m4 \ config/t8_netcdf.m4 \ config/t8_vtk.m4 \ diff --git a/config/ax_cxx_compile_stdcxx.m4 b/config/ax_cxx_compile_stdcxx.m4 new file mode 100644 index 0000000000..9ba3713962 --- /dev/null +++ b/config/ax_cxx_compile_stdcxx.m4 @@ -0,0 +1,1018 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) +# +# DESCRIPTION +# +# Check for baseline language coverage in the compiler for the specified +# version of the C++ standard. If necessary, add switches to CXX and +# CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for +# the respective C++ standard version. +# +# The second argument, if specified, indicates whether you insist on an +# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. +# -std=c++11). If neither is specified, you get whatever works, with +# preference for no added switch, and then for an extended mode. +# +# The third argument, if specified 'mandatory' or if left unspecified, +# indicates that baseline support for the specified C++ standard is +# required and that the macro should error out if no mode with that +# support is found. If specified 'optional', then configuration proceeds +# regardless, after defining HAVE_CXX${VERSION} if and only if a +# supporting mode is found. +# +# LICENSE +# +# Copyright (c) 2008 Benjamin Kosnik +# Copyright (c) 2012 Zack Weinberg +# Copyright (c) 2013 Roy Stogner +# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov +# Copyright (c) 2015 Paul Norman +# Copyright (c) 2015 Moritz Klammler +# Copyright (c) 2016, 2018 Krzesimir Nowak +# Copyright (c) 2019 Enji Cooper +# Copyright (c) 2020 Jason Merrill +# Copyright (c) 2021 Jörn Heusipp +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 18 + +dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro +dnl (serial version number 13). + +AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl + m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], + [$1], [14], [ax_cxx_compile_alternatives="14 1y"], + [$1], [17], [ax_cxx_compile_alternatives="17 1z"], + [$1], [20], [ax_cxx_compile_alternatives="20"], + [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl + m4_if([$2], [], [], + [$2], [ext], [], + [$2], [noext], [], + [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl + m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], + [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], + [$3], [optional], [ax_cxx_compile_cxx$1_required=false], + [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) + AC_LANG_PUSH([C++])dnl + ac_success=no + + m4_if([$2], [], [dnl + AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, + ax_cv_cxx_compile_cxx$1, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [ax_cv_cxx_compile_cxx$1=yes], + [ax_cv_cxx_compile_cxx$1=no])]) + if test x$ax_cv_cxx_compile_cxx$1 = xyes; then + ac_success=yes + fi]) + + m4_if([$2], [noext], [], [dnl + if test x$ac_success = xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + switch="-std=gnu++${alternative}" + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, + $cachevar, + [ac_save_CXX="$CXX" + CXX="$CXX $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXX="$ac_save_CXX"]) + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + fi]) + + m4_if([$2], [ext], [], [dnl + if test x$ac_success = xno; then + dnl HP's aCC needs +std=c++11 according to: + dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf + dnl Cray's crayCC needs "-h std=c++11" + dnl MSVC needs -std:c++NN for C++17 and later (default is C++14) + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do + if test x"$switch" = xMSVC; then + dnl AS_TR_SH maps both `:` and `=` to `_` so -std:c++17 would collide + dnl with -std=c++17. We suffix the cache variable name with _MSVC to + dnl avoid this. + switch=-std:c++${alternative} + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_${switch}_MSVC]) + else + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + fi + AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, + $cachevar, + [ac_save_CXX="$CXX" + CXX="$CXX $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXX="$ac_save_CXX"]) + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + if test x$ac_success = xyes; then + break + fi + done + fi]) + AC_LANG_POP([C++]) + if test x$ax_cxx_compile_cxx$1_required = xtrue; then + if test x$ac_success = xno; then + AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.]) + fi + fi + if test x$ac_success = xno; then + HAVE_CXX$1=0 + AC_MSG_NOTICE([No compiler with C++$1 support was found]) + else + HAVE_CXX$1=1 + AC_DEFINE(HAVE_CXX$1,1, + [define if the compiler supports basic C++$1 syntax]) + fi + AC_SUBST(HAVE_CXX$1) +]) + + +dnl Test body for checking C++11 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 +) + +dnl Test body for checking C++14 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 +) + +dnl Test body for checking C++17 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 +) + +dnl Test body for checking C++20 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_20 +) + + +dnl Tests for new features in C++11 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual ~Base() {} + virtual void f() {} + }; + + struct Derived : public Base + { + virtual ~Derived() override {} + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check single_type; + typedef check> double_type; + typedef check>> triple_type; + typedef check>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a = 1; + decltype(a) b = 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value = false; + }; + + template < typename T > + struct is_same + { + static const bool value = true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same::value == true, ""); + static_assert(is_same::value == false, ""); + static_assert(is_same::value == false, ""); + auto ac = c; + auto av = v; + auto sumi = ac + av + 'x'; + auto sumf = ac + av + 1.0; + static_assert(is_same::value == true, ""); + static_assert(is_same::value == true, ""); + static_assert(is_same::value == true, ""); + static_assert(is_same::value == false, ""); + static_assert(is_same::value == true, ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) == false, ""); + static_assert(noexcept(g()) == true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("1") == 1UL, ""); + static_assert(strlen_c("example") == 7UL, ""); + static_assert(strlen_c("another\0example") == 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value = N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i = 0; + const int c = 0; + static_assert(decltype(f(i))::value == 1, ""); + static_assert(decltype(f(c))::value == 2, ""); + static_assert(decltype(f(0))::value == 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero == 0, ""); + static_assert(test::one == 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 = [](){}; + auto lambda2 = lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a = [](int i, int j){ return i + j; }(1, 2); + auto b = []() -> int { return '0'; }(); + auto c = [=](){ return a + b; }(); + auto d = [&](){ return c; }(); + auto e = [a, &b](int x) mutable { + const auto identity = [](int y){ return y; }; + for (auto i = 0; i < a; ++i) + a += b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary = [](){ return 0; }; + const auto unary = [](int x){ return x; }; + using nullary_t = decltype(nullary); + using unary_t = decltype(unary); + const auto higher1st = [](nullary_t f){ return f(); }; + const auto higher2nd = [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template + struct sum; + + template + struct sum + { + static constexpr auto value = N0 + sum::value; + }; + + template <> + struct sum<> + { + static constexpr auto value = 0; + }; + + static_assert(sum<>::value == 0, ""); + static_assert(sum<1>::value == 1, ""); + static_assert(sum<23>::value == 23, ""); + static_assert(sum<1, 2>::value == 3, ""); + static_assert(sum<5, 5, 11>::value == 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template + using member = typename T::member_type; + + template + void func(...) {} + + template + void func(member*) {} + + void test(); + + void test() { func(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >= 201103L + +]]) + + +dnl Tests for new features in C++14 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L && !defined _MSC_VER + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + +]]) + + +dnl Tests for new features in C++17 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ + +// If the compiler admits that it is not ready for C++17, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201703L && !defined _MSC_VER + +#error "This is not a C++17 compiler" + +#else + +#include +#include +#include + +namespace cxx17 +{ + + namespace test_constexpr_lambdas + { + + constexpr int foo = [](){return 42;}(); + + } + + namespace test::nested_namespace::definitions + { + + } + + namespace test_fold_expression + { + + template + int multiply(Args... args) + { + return (args * ... * 1); + } + + template + bool all(Args... args) + { + return (args && ...); + } + + } + + namespace test_extended_static_assert + { + + static_assert (true); + + } + + namespace test_auto_brace_init_list + { + + auto foo = {5}; + auto bar {5}; + + static_assert(std::is_same, decltype(foo)>::value); + static_assert(std::is_same::value); + } + + namespace test_typename_in_template_template_parameter + { + + template typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() + { + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); + } + + } + + namespace test_extended_aggregate_initialization + { + + struct base1 + { + int b1, b2 = 42; + }; + + struct base2 + { + base2() { + b3 = 42; + } + int b3; + }; + + struct derived : base1, base2 + { + int d; + }; + + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + + } + + namespace test_general_range_based_for_loop + { + + struct iter + { + int i; + + int& operator* () + { + return i; + } + + const int& operator* () const + { + return i; + } + + iter& operator++() + { + ++i; + return *this; + } + }; + + struct sentinel + { + int i; + }; + + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; + } + + bool operator!= (const iter& i, const sentinel& s) + { + return !(i == s); + } + + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } + } + + } + + namespace test_lambda_capture_asterisk_this_by_value + { + + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; + + } + + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; + + } + + namespace test_constexpr_if + { + + template + int f () + { + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } + } + + } + + namespace test_selection_statement_with_initializer + { + + int f() + { + return 13; + } + + int f2() + { + if (auto i = f(); i > 0) + { + return 3; + } + + switch (auto i = f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } + } + + } + + namespace test_template_argument_deduction_for_class_templates + { + + template + struct pair + { + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} + + T1 m1; + T2 m2; + }; + + void f() + { + [[maybe_unused]] auto p = pair{13, 42u}; + } + + } + + namespace test_non_type_auto_template_parameters + { + + template + struct B + {}; + + B<5> b1; + B<'a'> b2; + + } + + namespace test_structured_bindings + { + + int arr[2] = { 1, 2 }; + std::pair pr = { 1, 2 }; + + auto f1() -> int(&)[2] + { + return arr; + } + + auto f2() -> std::pair& + { + return pr; + } + + struct S + { + int x1 : 2; + volatile double y1; + }; + + S f3() + { + return {}; + } + + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); + + } + + namespace test_exception_spec_type_system + { + + struct Good {}; + struct Bad {}; + + void g1() noexcept; + void g2(); + + template + Bad + f(T*, T*); + + template + Good + f(T1*, T2*); + + static_assert (std::is_same_v); + + } + + namespace test_inline_variables + { + + template void f(T) + {} + + template inline T g(T) + { + return T{}; + } + + template<> inline void f<>(int) + {} + + template<> int g<>(int) + { + return 5; + } + + } + +} // namespace cxx17 + +#endif // __cplusplus < 201703L && !defined _MSC_VER + +]]) + + +dnl Tests for new features in C++20 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[ + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 202002L && !defined _MSC_VER + +#error "This is not a C++20 compiler" + +#else + +#include + +namespace cxx20 +{ + +// As C++20 supports feature test macros in the standard, there is no +// immediate need to actually test for feature availability on the +// Autoconf side. + +} // namespace cxx20 + +#endif // __cplusplus < 202002L && !defined _MSC_VER + +]]) diff --git a/config/t8_include.m4 b/config/t8_include.m4 index e2620d3011..2e97ffa873 100644 --- a/config/t8_include.m4 +++ b/config/t8_include.m4 @@ -50,8 +50,9 @@ AC_DEFUN([T8_CHECK_LIBRARIES], T8_CHECK_NETCDF([$1]) T8_CHECK_VTK([$1]) T8_CHECK_OCC([$1]) -T8_CHECK_CPPSTD([$1]) +T8_CHECK_CPPSTDLIB([$1]) ]) +AC_DEFUN([T8_CHECK_CPPSTD],[AX_CXX_COMPILE_STDCXX([17],[ext],[mandatory])]) dnl T8_AS_SUBPACKAGE(PREFIX) dnl Call from a package that is using T8 as a subpackage. diff --git a/config/t8_stdpp.m4 b/config/t8_stdpp.m4 index eb858db683..99c56e4d18 100644 --- a/config/t8_stdpp.m4 +++ b/config/t8_stdpp.m4 @@ -1,5 +1,5 @@ -dnl T8_CHECK_CPPSTD +dnl T8_CHECK_CPPSTDLIB dnl Check for libstdc++ support and link a test program dnl dnl This macro tries to link to the standard c++ library. @@ -8,7 +8,7 @@ dnl or use --enable-cppstd= dnl dnl Using --enable-cppstd without any argument defaults to -lstdc++. dnl -AC_DEFUN([T8_CHECK_CPPSTD], [ +AC_DEFUN([T8_CHECK_CPPSTDLIB], [ dnl This link test changes the LIBS variable in place for posterity dnl SAVE_LIBS="$LIBS" diff --git a/configure.ac b/configure.ac index acb2274b35..9c3f5a1968 100644 --- a/configure.ac +++ b/configure.ac @@ -48,6 +48,12 @@ SC_CHECK_LIBRARIES([T8]) P4EST_CHECK_LIBRARIES([T8]) T8_CHECK_LIBRARIES([T8]) +echo "o---------------------------------------" +echo "| Checking C++ standard" +echo "o---------------------------------------" + +T8_CHECK_CPPSTD() + echo "o---------------------------------------" echo "| Checking headers" echo "o---------------------------------------" diff --git a/test/Makefile.am b/test/Makefile.am index d7c1ec92f5..3812d0f832 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -238,8 +238,7 @@ test_t8_forest_incomplete_t8_gtest_empty_global_tree_SOURCES = \ t8_gtest_target_ld_add = $(LDADD) test/libgtest.la t8_gtest_target_ld_flags = $(AM_LDFLAGS) -pthread t8_gtest_target_cpp_flags = $(AM_CPPFLAGS) -I$(top_srcdir)/thirdparty/googletest-mpi/ \ - -pthread \ - -std=c++11 + -pthread #flags to add when we compile with mpi t8_gtest_target_mpi_cpp_flags = -DGTEST_HAS_MPI=0 @@ -481,7 +480,7 @@ endif # Build Googletest library check_LTLIBRARIES = test/libgtest.la test_libgtest_la_SOURCES = thirdparty/googletest-mpi/gtest/gtest-all.cc -test_libgtest_la_CPPFLAGS = -I$(top_srcdir)/thirdparty/googletest-mpi -std=c++11 +test_libgtest_la_CPPFLAGS = -I$(top_srcdir)/thirdparty/googletest-mpi # If we did not configure t8code with MPI we need to build Googletest # without MPI support. if !T8_ENABLE_MPI From 0f937db47fd66b05b4c16050707997c7a1b98d34 Mon Sep 17 00:00:00 2001 From: "Dreyer, Lukas" Date: Fri, 3 Nov 2023 18:49:25 +0100 Subject: [PATCH 20/58] fix spelling --- config/ax_cxx_compile_stdcxx.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/ax_cxx_compile_stdcxx.m4 b/config/ax_cxx_compile_stdcxx.m4 index 9ba3713962..ef024495e9 100644 --- a/config/ax_cxx_compile_stdcxx.m4 +++ b/config/ax_cxx_compile_stdcxx.m4 @@ -417,10 +417,10 @@ namespace cxx11 using nullary_t = decltype(nullary); using unary_t = decltype(unary); const auto higher1st = [](nullary_t f){ return f(); }; - const auto higher2nd = [unary](nullary_t f1){ + const auto highersecond = [unary](nullary_t f1){ return [unary, f1](unary_t f2){ return f2(unary(f1())); }; }; - return higher1st(nullary) + higher2nd(nullary)(unary); + return higher1st(nullary) + highersecond(nullary)(unary); } } From dff791dd013a56be7e7bec9d012c3d4c03407631 Mon Sep 17 00:00:00 2001 From: "Dreyer, Lukas" Date: Thu, 9 Nov 2023 14:36:31 +0100 Subject: [PATCH 21/58] Limit number of procs to 8 in CI --- .github/workflows/tests_t8code_linkage_parallel_debug.yml | 6 +++--- .github/workflows/tests_t8code_linkage_parallel_release.yml | 6 +++--- .github/workflows/tests_t8code_parallel.yml | 6 +++--- .github/workflows/tests_t8code_serial.yml | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests_t8code_linkage_parallel_debug.yml b/.github/workflows/tests_t8code_linkage_parallel_debug.yml index 9c324ef5c7..d904e6205b 100644 --- a/.github/workflows/tests_t8code_linkage_parallel_debug.yml +++ b/.github/workflows/tests_t8code_linkage_parallel_debug.yml @@ -192,7 +192,7 @@ jobs: - name: make install run: cd build_netcdf && make install -j - name: make check - run: cd build_netcdf && make check -j V=0 CFLAGS="$CFLAGS_var -Werror" CXXFLAGS="$CXXFLAGS_var -Werror" + run: cd build_netcdf && make check -j8 V=0 CFLAGS="$CFLAGS_var -Werror" CXXFLAGS="$CXXFLAGS_var -Werror" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 @@ -215,7 +215,7 @@ jobs: - name: make install run: cd build_occ && make install -j - name: make check - run: cd build_occ && make check -j V=0 CFLAGS="$CFLAGS_var -Werror -I/usr/include/opencascade" CXXFLAGS="$CXXFLAGS_var -Werror -I/usr/include/opencascade" + run: cd build_occ && make check -j8 V=0 CFLAGS="$CFLAGS_var -Werror -I/usr/include/opencascade" CXXFLAGS="$CXXFLAGS_var -Werror -I/usr/include/opencascade" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 @@ -238,7 +238,7 @@ jobs: - name: make install run: cd build_vtk && make install -j - name: make check - run: cd build_vtk && make check -j V=0 CFLAGS="$CFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" CXXFLAGS="$CXXFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" + run: cd build_vtk && make check -j8 V=0 CFLAGS="$CFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" CXXFLAGS="$CXXFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 diff --git a/.github/workflows/tests_t8code_linkage_parallel_release.yml b/.github/workflows/tests_t8code_linkage_parallel_release.yml index 251714d6bc..eb78a3673e 100644 --- a/.github/workflows/tests_t8code_linkage_parallel_release.yml +++ b/.github/workflows/tests_t8code_linkage_parallel_release.yml @@ -192,7 +192,7 @@ jobs: - name: make install run: cd build_netcdf && make install -j - name: make check - run: cd build_netcdf && make check -j V=0 CFLAGS="$CFLAGS_var -Werror" CXXFLAGS="$CXXFLAGS_var -Werror" + run: cd build_netcdf && make check -j8 V=0 CFLAGS="$CFLAGS_var -Werror" CXXFLAGS="$CXXFLAGS_var -Werror" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 @@ -215,7 +215,7 @@ jobs: - name: make install run: cd build_occ && make install -j - name: make check - run: cd build_occ && make check -j V=0 CFLAGS="$CFLAGS_var -Werror -I/usr/include/opencascade" CXXFLAGS="$CXXFLAGS_var -Werror -I/usr/include/opencascade" + run: cd build_occ && make check -j8 V=0 CFLAGS="$CFLAGS_var -Werror -I/usr/include/opencascade" CXXFLAGS="$CXXFLAGS_var -Werror -I/usr/include/opencascade" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 @@ -238,7 +238,7 @@ jobs: - name: make install run: cd build_vtk && make install -j - name: make check - run: cd build_vtk && make check -j V=0 CFLAGS="$CFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" CXXFLAGS="$CXXFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" + run: cd build_vtk && make check -j8 V=0 CFLAGS="$CFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" CXXFLAGS="$CXXFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 diff --git a/.github/workflows/tests_t8code_parallel.yml b/.github/workflows/tests_t8code_parallel.yml index 58f750a69f..ce5d6f8a90 100644 --- a/.github/workflows/tests_t8code_parallel.yml +++ b/.github/workflows/tests_t8code_parallel.yml @@ -221,7 +221,7 @@ jobs: - name: make install run: cd build_release && make install -j - name: make check - run: cd build_release && make check -j V=0 CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" + run: cd build_release && make check -j8 V=0 CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 @@ -244,7 +244,7 @@ jobs: - name: make install run: cd build_debug && make install -j - name: make check - run: cd build_debug && make check -j V=0 CFLAGS="$CFLAGS_var_debug -Werror" CXXFLAGS="$CXXFLAGS_var_debug -Werror" + run: cd build_debug && make check -j8 V=0 CFLAGS="$CFLAGS_var_debug -Werror" CXXFLAGS="$CXXFLAGS_var_debug -Werror" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 @@ -267,7 +267,7 @@ jobs: - name: make install run: cd build_release_cpp && make install -j - name: make check - run: cd build_release_cpp && make check -j V=0 CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" + run: cd build_release_cpp && make check -j8 V=0 CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 diff --git a/.github/workflows/tests_t8code_serial.yml b/.github/workflows/tests_t8code_serial.yml index 5583079fff..c6e070946e 100644 --- a/.github/workflows/tests_t8code_serial.yml +++ b/.github/workflows/tests_t8code_serial.yml @@ -215,7 +215,7 @@ jobs: - name: make install run: cd build_serial_release && make install -j - name: make check - run: cd build_serial_release && make check -j V=0 CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" + run: cd build_serial_release && make check -j8 V=0 CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 @@ -238,7 +238,7 @@ jobs: - name: make install run: cd build_serial_debug && make install -j - name: make check - run: cd build_serial_debug && make check -j V=0 CFLAGS="$CFLAGS_var_debug -Werror" CXXFLAGS="$CXXFLAGS_var_debug -Werror" + run: cd build_serial_debug && make check -j8 V=0 CFLAGS="$CFLAGS_var_debug -Werror" CXXFLAGS="$CXXFLAGS_var_debug -Werror" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 From 011f76ab67fd9f17f3a70416d6f8c13523b2fb05 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 24 Nov 2023 09:18:00 +0100 Subject: [PATCH 22/58] Update .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 050577653b..e536e16531 100644 --- a/.gitignore +++ b/.gitignore @@ -55,7 +55,6 @@ example/IO/forest/netcdf/t8_netcdf_compilation_status example/advect/t8_advection example/cmesh/t8_cmesh_create_partitioned example/cmesh/t8_cmesh_partition -example/cmesh/t8_cmesh_refine example/forest/t8_face_neighbor example/forest/t8_test_face_iterate example/forest/t8_test_ghost From e5694d2df37c51816657cd644307676232ab263b Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 28 Nov 2023 09:35:04 +0100 Subject: [PATCH 23/58] Remove DEBUG-Makros --- src/t8_cmesh/t8_cmesh_examples.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 623bd7d848..3fe143c4e9 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -998,11 +998,9 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub * vertex 3 correctly. */ memcpy (vertices + 3, vertices + 9, 3 * sizeof (double)); } -#if T8_ENABLE_DEBUG else if (use_axis_aligned_geom && eclass != T8_ECLASS_QUAD) { SC_ABORTF ("Axis aligned geometry is not available for eclass %s!\n", t8_eclass_to_string[eclass]); } -#endif /* Map vertices of current quad on to respective trees inside. */ if (eclass == T8_ECLASS_QUAD) { From ccf1f3dbe814e9e71a13e2bc1b89ba9dbb25b4cd Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 28 Nov 2023 09:37:22 +0100 Subject: [PATCH 24/58] Simplify check --- src/t8_cmesh/t8_cmesh_examples.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 3fe143c4e9..7174d1fed9 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1007,7 +1007,7 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub /* No mapping is required. */ const t8_gloidx_t tree_id = quad_y_id * quads_x + quad_x_id; t8_cmesh_set_tree_vertices (cmesh, tree_id, vertices, - (use_axis_aligned_geom && eclass == T8_ECLASS_QUAD) ? 2 : 4); + (use_axis_aligned_geom ? 2 : 4); } else { T8_ASSERT (eclass == T8_ECLASS_TRIANGLE); From 2311415f681720ccd4cc43b676a53f5f842f0ee1 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 28 Nov 2023 09:37:55 +0100 Subject: [PATCH 25/58] Remove Debug-Makros --- src/t8_cmesh/t8_cmesh_examples.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 7174d1fed9..3f23f6bba4 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1161,11 +1161,9 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub * vertex 7 correctly. */ memcpy (vertices + 3, vertices + 21, 3 * sizeof (double)); } -#if T8_ENABLE_DEBUG else if (use_axis_aligned_geom && eclass != T8_ECLASS_HEX) { SC_ABORTF ("Axis aligned geometry is not available for eclass %s!\n", t8_eclass_to_string[eclass]); } -#endif /* Map vertices of current hex on to respective trees inside. */ const t8_gloidx_t hex_id = hex_z_id * hexs_y * hexs_x + hex_y_id * hexs_x + hex_x_id; From 30a2b506478249bff320331f0c647867fde0bb7c Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 28 Nov 2023 09:39:04 +0100 Subject: [PATCH 26/58] Simplify check --- src/t8_cmesh/t8_cmesh_examples.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 3f23f6bba4..3e37dacce6 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1006,8 +1006,7 @@ t8_cmesh_set_vertices_2D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub if (eclass == T8_ECLASS_QUAD) { /* No mapping is required. */ const t8_gloidx_t tree_id = quad_y_id * quads_x + quad_x_id; - t8_cmesh_set_tree_vertices (cmesh, tree_id, vertices, - (use_axis_aligned_geom ? 2 : 4); + t8_cmesh_set_tree_vertices (cmesh, tree_id, vertices, use_axis_aligned_geom ? 2 : 4); } else { T8_ASSERT (eclass == T8_ECLASS_TRIANGLE); @@ -1169,8 +1168,7 @@ t8_cmesh_set_vertices_3D (t8_cmesh_t cmesh, const t8_eclass_t eclass, const doub const t8_gloidx_t hex_id = hex_z_id * hexs_y * hexs_x + hex_y_id * hexs_x + hex_x_id; if (eclass == T8_ECLASS_HEX) { /* No mapping is required. */ - t8_cmesh_set_tree_vertices (cmesh, hex_id, vertices, - (use_axis_aligned_geom && eclass == T8_ECLASS_HEX) ? 2 : 8); + t8_cmesh_set_tree_vertices (cmesh, hex_id, vertices, use_axis_aligned_geom ? 2 : 8); } else if (eclass == T8_ECLASS_TET) { const t8_gloidx_t tree_id_0 = hex_id * 6; From 7d25f63fd20d1a387f0f3f1653597707387eb3fd Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 28 Nov 2023 09:46:51 +0100 Subject: [PATCH 27/58] Update src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.cxx Co-authored-by: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> --- .../t8_geometry_linear_axis_aligned.cxx | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.cxx index 9dcad4a2ae..880d83362b 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.cxx @@ -77,16 +77,4 @@ t8_geometry_linear_axis_aligned_destroy (t8_geometry_c **geom) *geom = NULL; } -int -t8_geom_is_linear_axis_aligned (const t8_geometry_c *geometry) -{ - /* Try to dynamic cast the geometry into linear, axis-aligned geometry. - * This is only successful if geometry pointed to a - * t8_geometry_linear_axis_aligned. - * If successful, then is_linear_geom will be true. - */ - const int is_linear_axis_aligned_geom = (dynamic_cast (geometry) != NULL); - - return is_linear_axis_aligned_geom; -} T8_EXTERN_C_END (); From 5d403fbc8d67d98bdc0a25bc6b30622c3e1b8416 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 28 Nov 2023 09:47:01 +0100 Subject: [PATCH 28/58] Update src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.h Co-authored-by: Sandro Elsweijer <49643115+sandro-elsweijer@users.noreply.github.com> --- .../t8_geometry_linear_axis_aligned.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.h b/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.h index bd7d68e8f8..b741d11ce2 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.h +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear_axis_aligned.h @@ -54,15 +54,6 @@ t8_geometry_linear_axis_aligned_new (int dim); void t8_geometry_linear_axis_aligned_destroy (t8_geometry_c **geom); -/** Query whether a given geometry is \ref t8_geometry_linear_axis_aligned. - * \param [in] geometry A geometry. - * \return True (non-zero) if and only if the geometry is of - * type \ref t8_geometry_linear_axis_aligned. - * \note This function is currently only available in debug mode. - */ -int -t8_geom_is_linear_axis_aligned (const t8_geometry_c *geometry); - T8_EXTERN_C_END (); #endif /* !T8_GEOMETRY_LINEAR_AXIS_ALIGNED_H! */ From 76433f9a34d5c14e9e7ac81f2910d6decc36f36e Mon Sep 17 00:00:00 2001 From: David Knapp Date: Tue, 28 Nov 2023 09:47:59 +0100 Subject: [PATCH 29/58] Update geometry_check --- src/t8_cmesh/t8_cmesh_examples.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index 3e37dacce6..908cb25183 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -1276,7 +1276,7 @@ t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const do t8_cmesh_t cmesh; t8_cmesh_init (&cmesh); - const int is_axis_aligned = t8_geom_is_linear_axis_aligned (geometry); + const int is_axis_aligned = geometry->t8_geom_get_type () == T8_GEOMETRY_TYPE_LINEAR_AXIS_ALIGNED; t8_cmesh_register_geometry (cmesh, geometry); From 1b89f05e159a293e057b96c3053dc0234684fc10 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Wed, 29 Nov 2023 14:20:18 +0100 Subject: [PATCH 30/58] Improve set partition offset test case - value ranges over classes and tree count - check that the cmesh is committed - check that the cmesh is partitioned according to the offset --- .../t8_gtest_cmesh_set_partition_offsets.cxx | 64 ++++++++++++++++--- 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx index 27ba71cbfb..1c8ba59874 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx @@ -21,6 +21,7 @@ */ #include +#include #include #include #include "t8_cmesh/t8_cmesh_trees.h" @@ -30,21 +31,40 @@ /* At the time of this writing (November 15 2023) t8_cmesh_offset_concentrate * has a comment stating it does not work with non-derived cmeshes. * We write the tests in this file to check this. + * + * Theses tests will create an offset array, build a new cmesh + * with trees of the same eclass, set the offset array and commit the cmesh. + * We will iterate through all eclasses and all tree counts up to a given maximum. */ +/* The maximum number of trees for a cmesh to test with. + * We will test all numbers of trees from 0 to the maximum. */ +#define T8_TEST_PARTITION_OFFSET_MAX_TREE_NUM 100 + +class cmesh_set_partition_offsets: public testing::TestWithParam> { + protected: + void + SetUp () override + { + ieclass = std::get<0> (GetParam ()); + inum_trees = std::get<1> (GetParam ()); + } + t8_eclass_t ieclass; + t8_gloidx_t inum_trees; +}; + /* call t8_cmesh_offset_concentrate for non-derived cmesh * and destroy it before commit. */ -TEST (t8_cmesh_set_partition_offsets, test_set_offsets_nocommit) +TEST_P (cmesh_set_partition_offsets, test_set_offsets_nocommit) { t8_cmesh_t cmesh; - const t8_gloidx_t num_trees = 1; const int main_process = 0; /* Build a valid offset array. For this test it is onlt necessary that * the array corresponds to any valid partition. * We use the offset_concentrate function to build an offset array for a partition * that concentrates all trees at one process. */ t8_shmem_init (sc_MPI_COMM_WORLD); - t8_shmem_array_t shmem_array = t8_cmesh_offset_concentrate (main_process, sc_MPI_COMM_WORLD, num_trees); + t8_shmem_array_t shmem_array = t8_cmesh_offset_concentrate (main_process, sc_MPI_COMM_WORLD, inum_trees); /* Initialize the cmesh */ t8_cmesh_init (&cmesh); @@ -57,18 +77,17 @@ TEST (t8_cmesh_set_partition_offsets, test_set_offsets_nocommit) /* call t8_cmesh_offset_concentrate for non-derived cmesh * and commit it. */ -TEST (t8_cmesh_set_partition_offsets, test_set_offsets_commit) +TEST_P (cmesh_set_partition_offsets, test_set_offsets_commit) { t8_cmesh_t cmesh; - const t8_gloidx_t num_trees = 1; const int main_process = 0; sc_MPI_Comm comm = sc_MPI_COMM_WORLD; - /* Build a valid offset array. For this test it is onlt necessary that + /* Build a valid offset array. For this test it is only necessary that * the array corresponds to any valid partition. * We use the offset_concentrate function to build an offset array for a partition * that concentrates all trees at one process. */ t8_shmem_init (comm); - t8_shmem_array_t shmem_array = t8_cmesh_offset_concentrate (main_process, comm, num_trees); + t8_shmem_array_t shmem_array = t8_cmesh_offset_concentrate (main_process, comm, inum_trees); /* Initialize the cmesh */ t8_cmesh_init (&cmesh); @@ -77,14 +96,41 @@ TEST (t8_cmesh_set_partition_offsets, test_set_offsets_commit) t8_cmesh_set_partition_offsets (cmesh, shmem_array); /* Specify a dimension */ - t8_cmesh_set_dimension (cmesh, 0); + const int dim = t8_eclass_to_dimension[ieclass]; + t8_cmesh_set_dimension (cmesh, dim); /* Set class for the trees */ - t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_VERTEX); + for (int itree = 0; itree < inum_trees; ++itree) { + t8_cmesh_set_tree_class (cmesh, itree, ieclass); + } /* Commit the cmesh */ t8_cmesh_commit (cmesh, comm); + /* Check that the cmesh was partitioned according to the offset */ + + ASSERT_TRUE (t8_cmesh_is_committed (cmesh)); + + /* Get the mpirank */ + int mpirank; + int mpiret; + + mpiret = sc_MPI_Comm_rank (comm, &mpirank); + SC_CHECK_MPI (mpiret); + + /* Get the local number of trees */ + const t8_locidx_t num_local_trees = t8_cmesh_get_num_local_trees (cmesh); + /* Compute the reference value, num_trees for mpirank main_process, + * 0 on each other rank. */ + const t8_locidx_t expected_num_local_trees = mpirank == main_process ? inum_trees : 0; + + EXPECT_EQ (num_local_trees, expected_num_local_trees); + EXPECT_EQ (t8_cmesh_get_num_trees (cmesh), inum_trees); + /* Destroy the cmesh */ t8_cmesh_unref (&cmesh); } + +/* Make atest suite that iterates over all classes and a tree count from 0 to the maximum. */ +INSTANTIATE_TEST_SUITE_P (t8_cmesh_set_partition_offsets, cmesh_set_partition_offsets, + testing::Combine (AllEclasses, testing::Values (0, T8_TEST_PARTITION_OFFSET_MAX_TREE_NUM))); From f923adf8590b25304f017aab0c10d889ae58e460 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Wed, 29 Nov 2023 14:45:32 +0100 Subject: [PATCH 31/58] Split test cases in two, add comments and debug output --- .../t8_gtest_cmesh_set_partition_offsets.cxx | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx index 1c8ba59874..d031d5e2f7 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx @@ -41,7 +41,21 @@ * We will test all numbers of trees from 0 to the maximum. */ #define T8_TEST_PARTITION_OFFSET_MAX_TREE_NUM 100 -class cmesh_set_partition_offsets: public testing::TestWithParam> { +/* The tests that do not commit the cmesh iterate over the number of trees, + * hence we have a TestWithParam with one int. */ +class cmesh_set_partition_offsets_nocommit: public testing::TestWithParam { + protected: + void + SetUp () override + { + inum_trees = GetParam (); + } + t8_gloidx_t inum_trees; +}; + +/* The tests that do commit the cmesh iterate over eclasses and the number of + * tress, hence they have a TestWithParam with eclass and int. */ +class cmesh_set_partition_offsets_commit: public testing::TestWithParam> { protected: void SetUp () override @@ -55,10 +69,13 @@ class cmesh_set_partition_offsets: public testing::TestWithParam Date: Wed, 29 Nov 2023 14:50:24 +0100 Subject: [PATCH 32/58] add todo --- test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx index d031d5e2f7..cf8283b1d4 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx @@ -36,6 +36,8 @@ * with trees of the same eclass, set the offset array and commit the cmesh. * We will iterate through all eclasses and all tree counts up to a given maximum. */ +/* TODO: Currently only the offset t8_cmesh_offset_concentrate is tested. + * We can extend this test case to check for different offset arrays. */ /* The maximum number of trees for a cmesh to test with. * We will test all numbers of trees from 0 to the maximum. */ From dec8d537273ecfc95868405dea8d45a8506bee03 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 8 Dec 2023 11:19:25 +0100 Subject: [PATCH 33/58] fix ghost writing for geometry with vertices --- src/t8_cmesh/t8_cmesh.c | 1 - src/t8_geometry/t8_geometry_with_vertices.cxx | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh.c b/src/t8_cmesh/t8_cmesh.c index aad323e96f..6b31fa7740 100644 --- a/src/t8_cmesh/t8_cmesh.c +++ b/src/t8_cmesh/t8_cmesh.c @@ -376,7 +376,6 @@ double * t8_cmesh_get_tree_vertices (t8_cmesh_t cmesh, t8_locidx_t ltreeid) { T8_ASSERT (t8_cmesh_is_committed (cmesh)); - T8_ASSERT (t8_cmesh_treeid_is_local_tree (cmesh, ltreeid)); return (double *) t8_cmesh_get_attribute (cmesh, t8_get_package_id (), T8_CMESH_VERTICES_ATTRIBUTE_KEY, ltreeid); } diff --git a/src/t8_geometry/t8_geometry_with_vertices.cxx b/src/t8_geometry/t8_geometry_with_vertices.cxx index 3e7391741d..c2a7844f40 100644 --- a/src/t8_geometry/t8_geometry_with_vertices.cxx +++ b/src/t8_geometry/t8_geometry_with_vertices.cxx @@ -34,7 +34,13 @@ t8_geometry_with_vertices::t8_geom_load_tree_data (t8_cmesh_t cmesh, t8_gloidx_t /* Set active id and eclass */ t8_locidx_t ltreeid = t8_cmesh_get_local_id (cmesh, gtreeid); active_tree = gtreeid; - active_tree_class = t8_cmesh_get_tree_class (cmesh, ltreeid); + const t8_locidx_t num_local_trees = t8_cmesh_get_num_local_trees (cmesh); + if (0 <= ltree_id && ltree_id <) { + active_tree_class = t8_cmesh_get_tree_class (cmesh, ltreeid); + } + else { + active_tree_class = t8_cmesh_get_ghost_class (cmesh, ltree_id - num_local_trees); + } /* Load this trees vertices. */ active_tree_vertices = t8_cmesh_get_tree_vertices (cmesh, ltreeid); From fd1a1ecea11c736b56593bd61758a9b1bcbb8151 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 8 Dec 2023 11:30:00 +0100 Subject: [PATCH 34/58] Improve assertion instead of deleting it --- src/t8_cmesh/t8_cmesh.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/t8_cmesh/t8_cmesh.c b/src/t8_cmesh/t8_cmesh.c index 6b31fa7740..6062f09c2d 100644 --- a/src/t8_cmesh/t8_cmesh.c +++ b/src/t8_cmesh/t8_cmesh.c @@ -376,6 +376,7 @@ double * t8_cmesh_get_tree_vertices (t8_cmesh_t cmesh, t8_locidx_t ltreeid) { T8_ASSERT (t8_cmesh_is_committed (cmesh)); + T8_ASSERT (t8_cmesh_treeid_is_local_tree (cmesh, ltreeid) || t8_cmesh_treeid_is_ghost (cmesh, ltreeid)); return (double *) t8_cmesh_get_attribute (cmesh, t8_get_package_id (), T8_CMESH_VERTICES_ATTRIBUTE_KEY, ltreeid); } From d222047a24d389d4502baa26fae14f94ee15e768 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 8 Dec 2023 12:53:13 +0100 Subject: [PATCH 35/58] Fix compile errors --- src/t8_geometry/t8_geometry_with_vertices.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_geometry/t8_geometry_with_vertices.cxx b/src/t8_geometry/t8_geometry_with_vertices.cxx index c2a7844f40..16c3824d5b 100644 --- a/src/t8_geometry/t8_geometry_with_vertices.cxx +++ b/src/t8_geometry/t8_geometry_with_vertices.cxx @@ -35,11 +35,11 @@ t8_geometry_with_vertices::t8_geom_load_tree_data (t8_cmesh_t cmesh, t8_gloidx_t t8_locidx_t ltreeid = t8_cmesh_get_local_id (cmesh, gtreeid); active_tree = gtreeid; const t8_locidx_t num_local_trees = t8_cmesh_get_num_local_trees (cmesh); - if (0 <= ltree_id && ltree_id <) { + if (0 <= ltreeid && ltreeid < num_local_trees) { active_tree_class = t8_cmesh_get_tree_class (cmesh, ltreeid); } else { - active_tree_class = t8_cmesh_get_ghost_class (cmesh, ltree_id - num_local_trees); + active_tree_class = t8_cmesh_get_ghost_class (cmesh, ltreeid - num_local_trees); } /* Load this trees vertices. */ active_tree_vertices = t8_cmesh_get_tree_vertices (cmesh, ltreeid); From 5883e2f45ed80b8bee827084bcbac6667747a277 Mon Sep 17 00:00:00 2001 From: "Dreyer, Lukas" Date: Wed, 3 Jan 2024 15:50:06 +0100 Subject: [PATCH 36/58] Introduce MAKEFLAGS for CI Jobs --- .github/workflows/tests_sc_p4est.yml | 34 ++++++++++--------- .../tests_t8code_linkage_parallel_debug.yml | 24 +++++++------ .../tests_t8code_linkage_parallel_release.yml | 24 +++++++------ .github/workflows/tests_t8code_parallel.yml | 28 ++++++++------- .github/workflows/tests_t8code_serial.yml | 22 ++++++------ 5 files changed, 71 insertions(+), 61 deletions(-) diff --git a/.github/workflows/tests_sc_p4est.yml b/.github/workflows/tests_sc_p4est.yml index b7012f6315..1e706abf5e 100644 --- a/.github/workflows/tests_sc_p4est.yml +++ b/.github/workflows/tests_sc_p4est.yml @@ -30,6 +30,8 @@ name: sc and p4est tests # in the "key:" entries of the sc and p4est steps or set the variables # SC_IGNORE_CACHE and P4EST_IGNORE_CACHE to 1 in the respective steps. +env: + MAKEFLAGS: "-j2 V=0" on: push: @@ -114,10 +116,10 @@ jobs: run: cd $SC_DEBUG && ../configure --enable-mpi --enable-debug --prefix=$PWD/install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: sc build debug - run: cd $SC_DEBUG && make -j V=0 && make -j V=0 install + run: cd $SC_DEBUG && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: sc debug check - run: cd $SC_DEBUG && make -j V=0 check + run: cd $SC_DEBUG && make $MAKEFLAGS check if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: OnFailPrintLog if: (${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }}) && failure() @@ -127,10 +129,10 @@ jobs: run: cd $SC_RELEASE && ../configure --enable-mpi --enable-debug --prefix=$PWD/install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: sc build release - run: cd $SC_RELEASE && make -j V=0 && make -j V=0 install + run: cd $SC_RELEASE && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: sc release check - run: cd $SC_RELEASE && make -j V=0 check + run: cd $SC_RELEASE && make $MAKEFLAGS check if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: OnFailPrintLog if: (${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }}) && failure() @@ -140,10 +142,10 @@ jobs: run: cd $SC_SERIAL_DEBUG && ../configure --enable-debug --prefix=$PWD/install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: sc build serial debug - run: cd $SC_SERIAL_DEBUG && make -j V=0 && make -j V=0 install + run: cd $SC_SERIAL_DEBUG && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: sc serial debug check - run: cd $SC_SERIAL_DEBUG && make -j V=0 check + run: cd $SC_SERIAL_DEBUG && make $MAKEFLAGS check if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: OnFailPrintLog if: (${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }}) && failure() @@ -153,10 +155,10 @@ jobs: run: cd $SC_SERIAL_RELEASE && ../configure --prefix=$PWD/install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: sc build release serial - run: cd $SC_SERIAL_RELEASE && make -j V=0 && make -j V=0 install + run: cd $SC_SERIAL_RELEASE && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: sc release debug check - run: cd $SC_SERIAL_RELEASE && make -j V=0 check + run: cd $SC_SERIAL_RELEASE && make $MAKEFLAGS check if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: OnFailPrintLog if: (${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }}) && failure() @@ -206,10 +208,10 @@ jobs: run: cd $P4EST_DEBUG && ../configure --enable-mpi --enable-debug --prefix=$PWD/install --with-sc=$SC_DEBUG/install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: p4est build debug - run: cd $P4EST_DEBUG && make -j V=0 && make -j V=0 install + run: cd $P4EST_DEBUG && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: p4est debug check - run: cd $P4EST_DEBUG && make -j V=0 check + run: cd $P4EST_DEBUG && make $MAKEFLAGS check if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: OnFailPrintLog if: (${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }}) && failure() @@ -219,10 +221,10 @@ jobs: run: cd $P4EST_RELEASE && ../configure --enable-mpi --prefix=$PWD/install --with-sc=$SC_RELEASE/install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: p4est build release - run: cd $P4EST_RELEASE && make -j V=0 && make -j V=0 install + run: cd $P4EST_RELEASE && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: p4est release check - run: cd $P4EST_RELEASE && make -j V=0 check + run: cd $P4EST_RELEASE && make $MAKEFLAGS check if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: OnFailPrintLog if: (${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }}) && failure() @@ -232,10 +234,10 @@ jobs: run: cd $P4EST_SERIAL_RELEASE && ../configure --prefix=$PWD/install --with-sc=$SC_SERIAL_RELEASE/install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: p4est build serial release - run: cd $P4EST_SERIAL_RELEASE && make -j V=0 && make -j V=0 install + run: cd $P4EST_SERIAL_RELEASE && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: p4est serial release check - run: cd $P4EST_SERIAL_RELEASE && make -j V=0 check + run: cd $P4EST_SERIAL_RELEASE && make $MAKEFLAGS check if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: OnFailPrintLog if: (${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }}) && failure() @@ -245,10 +247,10 @@ jobs: run: cd $P4EST_SERIAL_DEBUG && ../configure --enable-debug --prefix=$PWD/install --with-sc=$SC_SERIAL_DEBUG/install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: p4est build serial debug - run: cd $P4EST_SERIAL_DEBUG && make -j V=0 && make -j V=0 install + run: cd $P4EST_SERIAL_DEBUG && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: p4est serial debug check - run: cd $P4EST_SERIAL_DEBUG && make -j V=0 check + run: cd $P4EST_SERIAL_DEBUG && make $MAKEFLAGS check if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: OnFailPrintLog if: (${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }}) && failure () diff --git a/.github/workflows/tests_t8code_linkage_parallel_debug.yml b/.github/workflows/tests_t8code_linkage_parallel_debug.yml index d904e6205b..b180a82e62 100644 --- a/.github/workflows/tests_t8code_linkage_parallel_debug.yml +++ b/.github/workflows/tests_t8code_linkage_parallel_debug.yml @@ -30,6 +30,8 @@ name: t8code tests linkage parallel debug # in the "key:" entries of the sc and p4est steps or set the variables # SC_IGNORE_CACHE and P4EST_IGNORE_CACHE to 1 in the respective steps. +env: + MAKEFLAGS: "-j2 V=0" on: push: @@ -110,7 +112,7 @@ jobs: run: cd $SC_DEBUG && ../configure --enable-mpi --enable-debug --prefix=$PWD/install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: sc build debug - run: cd $SC_DEBUG && make -j V=0 && make -j V=0 install + run: cd $SC_DEBUG && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} # # P4EST @@ -150,7 +152,7 @@ jobs: run: cd $P4EST_DEBUG && ../configure --enable-mpi --enable-debug --prefix=$PWD/install --with-sc=$SC_DEBUG/install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: p4est build debug - run: cd $P4EST_DEBUG && make -j V=0 && make -j V=0 install + run: cd $P4EST_DEBUG && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} # P4EST AND SC END # @@ -188,11 +190,11 @@ jobs: name: config_netcdf_debug_MPI.log path: build_netcdf/config.log - name: make - run: cd build_netcdf && make -j V=0 CFLAGS="$CFLAGS_var -Werror" CXXFLAGS="$CXXFLAGS_var -Werror" + run: cd build_netcdf && make $MAKEFLAGS CFLAGS="$CFLAGS_var -Werror" CXXFLAGS="$CXXFLAGS_var -Werror" - name: make install - run: cd build_netcdf && make install -j + run: cd build_netcdf && make install $MAKEFLAGS - name: make check - run: cd build_netcdf && make check -j8 V=0 CFLAGS="$CFLAGS_var -Werror" CXXFLAGS="$CXXFLAGS_var -Werror" + run: cd build_netcdf && make check $MAKEFLAGS CFLAGS="$CFLAGS_var -Werror" CXXFLAGS="$CXXFLAGS_var -Werror" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 @@ -211,11 +213,11 @@ jobs: name: config_occ_debug_MPI.log path: build_occ/config.log - name: make - run: cd build_occ && make -j V=0 CFLAGS="$CFLAGS_var -Werror -I/usr/include/opencascade" CXXFLAGS="$CXXFLAGS_var -Werror -I/usr/include/opencascade" + run: cd build_occ && make $MAKEFLAGS CFLAGS="$CFLAGS_var -Werror -I/usr/include/opencascade" CXXFLAGS="$CXXFLAGS_var -Werror -I/usr/include/opencascade" - name: make install - run: cd build_occ && make install -j + run: cd build_occ && make install $MAKEFLAGS - name: make check - run: cd build_occ && make check -j8 V=0 CFLAGS="$CFLAGS_var -Werror -I/usr/include/opencascade" CXXFLAGS="$CXXFLAGS_var -Werror -I/usr/include/opencascade" + run: cd build_occ && make check $MAKEFLAGS CFLAGS="$CFLAGS_var -Werror -I/usr/include/opencascade" CXXFLAGS="$CXXFLAGS_var -Werror -I/usr/include/opencascade" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 @@ -234,11 +236,11 @@ jobs: name: config_vtk_debug_MPI.log path: build_vtk/config.log - name: make - run: cd build_vtk && make -j V=0 CFLAGS="$CFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" CXXFLAGS="$CXXFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" + run: cd build_vtk && make $MAKEFLAGS CFLAGS="$CFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" CXXFLAGS="$CXXFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" - name: make install - run: cd build_vtk && make install -j + run: cd build_vtk && make install $MAKEFLAGS - name: make check - run: cd build_vtk && make check -j8 V=0 CFLAGS="$CFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" CXXFLAGS="$CXXFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" + run: cd build_vtk && make check $MAKEFLAGS CFLAGS="$CFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" CXXFLAGS="$CXXFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 diff --git a/.github/workflows/tests_t8code_linkage_parallel_release.yml b/.github/workflows/tests_t8code_linkage_parallel_release.yml index eb78a3673e..414cb27581 100644 --- a/.github/workflows/tests_t8code_linkage_parallel_release.yml +++ b/.github/workflows/tests_t8code_linkage_parallel_release.yml @@ -30,6 +30,8 @@ name: t8code tests linkage parallel release # in the "key:" entries of the sc and p4est steps or set the variables # SC_IGNORE_CACHE and P4EST_IGNORE_CACHE to 1 in the respective steps. +env: + MAKEFLAGS: "-j2 V=0" on: push: @@ -110,7 +112,7 @@ jobs: run: cd $SC_RELEASE && ../configure --enable-mpi --prefix=$PWD/install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: sc build release - run: cd $SC_RELEASE && make -j V=0 && make -j V=0 install + run: cd $SC_RELEASE && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} # # P4EST @@ -150,7 +152,7 @@ jobs: run: cd $P4EST_RELEASE && ../configure --enable-mpi --prefix=$PWD/install --with-sc=$SC_RELEASE/install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: p4est build release - run: cd $P4EST_RELEASE && make -j V=0 && make -j V=0 install + run: cd $P4EST_RELEASE && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} # P4EST AND SC END # @@ -188,11 +190,11 @@ jobs: name: config_netcdf_release_MPI.log path: build_netcdf/config.log - name: make - run: cd build_netcdf && make -j V=0 CFLAGS="$CFLAGS_var -Werror" CXXFLAGS="$CXXFLAGS_var -Werror" + run: cd build_netcdf && make $MAKEFLAGS CFLAGS="$CFLAGS_var -Werror" CXXFLAGS="$CXXFLAGS_var -Werror" - name: make install - run: cd build_netcdf && make install -j + run: cd build_netcdf && make install $MAKEFLAGS - name: make check - run: cd build_netcdf && make check -j8 V=0 CFLAGS="$CFLAGS_var -Werror" CXXFLAGS="$CXXFLAGS_var -Werror" + run: cd build_netcdf && make check $MAKEFLAGS CFLAGS="$CFLAGS_var -Werror" CXXFLAGS="$CXXFLAGS_var -Werror" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 @@ -211,11 +213,11 @@ jobs: name: config_occ_release_MPI.log path: build_occ/config.log - name: make - run: cd build_occ && make -j V=0 CFLAGS="$CFLAGS_var -Werror -I/usr/include/opencascade" CXXFLAGS="$CXXFLAGS_var -Werror -I/usr/include/opencascade" + run: cd build_occ && make $MAKEFLAGS CFLAGS="$CFLAGS_var -Werror -I/usr/include/opencascade" CXXFLAGS="$CXXFLAGS_var -Werror -I/usr/include/opencascade" - name: make install - run: cd build_occ && make install -j + run: cd build_occ && make install $MAKEFLAGS - name: make check - run: cd build_occ && make check -j8 V=0 CFLAGS="$CFLAGS_var -Werror -I/usr/include/opencascade" CXXFLAGS="$CXXFLAGS_var -Werror -I/usr/include/opencascade" + run: cd build_occ && make check $MAKEFLAGS CFLAGS="$CFLAGS_var -Werror -I/usr/include/opencascade" CXXFLAGS="$CXXFLAGS_var -Werror -I/usr/include/opencascade" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 @@ -234,11 +236,11 @@ jobs: name: config_vtk_release_MPI.log path: build_vtk/config.log - name: make - run: cd build_vtk && make -j V=0 CFLAGS="$CFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" CXXFLAGS="$CXXFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" + run: cd build_vtk && make $MAKEFLAGS CFLAGS="$CFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" CXXFLAGS="$CXXFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" - name: make install - run: cd build_vtk && make install -j + run: cd build_vtk && make install $MAKEFLAGS - name: make check - run: cd build_vtk && make check -j8 V=0 CFLAGS="$CFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" CXXFLAGS="$CXXFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" + run: cd build_vtk && make check $MAKEFLAGS CFLAGS="$CFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" CXXFLAGS="$CXXFLAGS_var -Werror -isystem/usr/local/include/vtk-9.1" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 diff --git a/.github/workflows/tests_t8code_parallel.yml b/.github/workflows/tests_t8code_parallel.yml index ce5d6f8a90..afc1204322 100644 --- a/.github/workflows/tests_t8code_parallel.yml +++ b/.github/workflows/tests_t8code_parallel.yml @@ -30,6 +30,8 @@ name: t8code tests parallel # in the "key:" entries of the sc and p4est steps or set the variables # SC_IGNORE_CACHE and P4EST_IGNORE_CACHE to 1 in the respective steps. +env: + MAKEFLAGS: "-j2 V=0" on: push: @@ -112,14 +114,14 @@ jobs: run: cd $SC_DEBUG && ../configure --enable-mpi --enable-debug --prefix=$PWD/install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: sc build debug - run: cd $SC_DEBUG && make -j V=0 && make -j V=0 install + run: cd $SC_DEBUG && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} ## sc release - name: sc configure and build release run: cd $SC_RELEASE && ../configure --enable-mpi --enable-debug --prefix=$PWD/install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: sc build release - run: cd $SC_RELEASE && make -j V=0 && make -j V=0 install + run: cd $SC_RELEASE && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} # # P4EST @@ -161,14 +163,14 @@ jobs: run: cd $P4EST_DEBUG && ../configure --enable-mpi --enable-debug --prefix=$PWD/install --with-sc=$SC_DEBUG/install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: p4est build debug - run: cd $P4EST_DEBUG && make -j V=0 && make -j V=0 install + run: cd $P4EST_DEBUG && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} ## p4est release - name: p4est configure and build release run: cd $P4EST_RELEASE && ../configure --enable-mpi --prefix=$PWD/install --with-sc=$SC_RELEASE/install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: p4est build release - run: cd $P4EST_RELEASE && make -j V=0 && make -j V=0 install + run: cd $P4EST_RELEASE && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} # P4EST AND SC END # @@ -217,11 +219,11 @@ jobs: name: config_release_MPI.log path: build_release/config.log - name: make - run: cd build_release && make -j V=0 CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" + run: cd build_release && make $MAKEFLAGS CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" - name: make install - run: cd build_release && make install -j + run: cd build_release && make install $MAKEFLAGS - name: make check - run: cd build_release && make check -j8 V=0 CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" + run: cd build_release && make check $MAKEFLAGS CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 @@ -240,11 +242,11 @@ jobs: name: config_debug_MPI.log path: build_debug/config.log - name: make - run: cd build_debug && make -j V=0 CFLAGS="$CFLAGS_var_debug -Werror" CXXFLAGS="$CXXFLAGS_var_debug -Werror" + run: cd build_debug && make $MAKEFLAGS CFLAGS="$CFLAGS_var_debug -Werror" CXXFLAGS="$CXXFLAGS_var_debug -Werror" - name: make install - run: cd build_debug && make install -j + run: cd build_debug && make install $MAKEFLAGS - name: make check - run: cd build_debug && make check -j8 V=0 CFLAGS="$CFLAGS_var_debug -Werror" CXXFLAGS="$CXXFLAGS_var_debug -Werror" + run: cd build_debug && make check $MAKEFLAGS CFLAGS="$CFLAGS_var_debug -Werror" CXXFLAGS="$CXXFLAGS_var_debug -Werror" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 @@ -263,11 +265,11 @@ jobs: name: config_release_MPI_CXX.log path: build_release_cpp/config.log - name: make - run: cd build_release_cpp && make -j V=0 CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" + run: cd build_release_cpp && make $MAKEFLAGS CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" - name: make install - run: cd build_release_cpp && make install -j + run: cd build_release_cpp && make install $MAKEFLAGS - name: make check - run: cd build_release_cpp && make check -j8 V=0 CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" + run: cd build_release_cpp && make check $MAKEFLAGS CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 diff --git a/.github/workflows/tests_t8code_serial.yml b/.github/workflows/tests_t8code_serial.yml index c6e070946e..f6aaed0266 100644 --- a/.github/workflows/tests_t8code_serial.yml +++ b/.github/workflows/tests_t8code_serial.yml @@ -30,6 +30,8 @@ name: t8code tests serial # in the "key:" entries of the sc and p4est steps or set the variables # SC_IGNORE_CACHE and P4EST_IGNORE_CACHE to 1 in the respective steps. +env: + MAKEFLAGS: "-j2 V=0" on: push: @@ -112,14 +114,14 @@ jobs: run: cd $SC_SERIAL_DEBUG && ../configure --enable-debug --prefix=$PWD/install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: sc build serial debug - run: cd $SC_SERIAL_DEBUG && make -j V=0 && make -j V=0 install + run: cd $SC_SERIAL_DEBUG && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} ## sc serial release - name: sc configure and build serial release run: cd $SC_SERIAL_RELEASE && ../configure --prefix=$PWD/install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} - name: sc build release serial - run: cd $SC_SERIAL_RELEASE && make -j V=0 && make -j V=0 install + run: cd $SC_SERIAL_RELEASE && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.sc_cache.outputs.cache-hit != 'true' || env.SC_IGNORE_CACHE == 1 }} # # P4EST @@ -161,14 +163,14 @@ jobs: run: cd $P4EST_SERIAL_RELEASE && ../configure --prefix=$PWD/install --with-sc=$SC_SERIAL_RELEASE/install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: p4est build serial release - run: cd $P4EST_SERIAL_RELEASE && make -j V=0 && make -j V=0 install + run: cd $P4EST_SERIAL_RELEASE && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: p4est configure and build serial debug ## p4est serial debug run: cd $P4EST_SERIAL_DEBUG && ../configure --enable-debug --prefix=$PWD/install --with-sc=$SC_SERIAL_DEBUG/install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} - name: p4est build serial debug - run: cd $P4EST_SERIAL_DEBUG && make -j V=0 && make -j V=0 install + run: cd $P4EST_SERIAL_DEBUG && make $MAKEFLAGS && make $MAKEFLAGS install if: ${{ steps.p4est_cache.outputs.cache-hit != 'true' || env.P4EST_IGNORE_CACHE == 1 }} # P4EST AND SC END # @@ -211,11 +213,11 @@ jobs: name: config_release_serial.log path: build_serial_release/config.log - name: make - run: cd build_serial_release && make -j V=0 CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" + run: cd build_serial_release && make $MAKEFLAGS CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" - name: make install - run: cd build_serial_release && make install -j + run: cd build_serial_release && make install $MAKEFLAGS - name: make check - run: cd build_serial_release && make check -j8 V=0 CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" + run: cd build_serial_release && make check $MAKEFLAGS CFLAGS="$CFLAGS_var_release -Werror" CXXFLAGS="$CXXFLAGS_var_release -Werror" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 @@ -234,11 +236,11 @@ jobs: name: config_debug_serial.log path: build_serial_debug/config.log - name: make - run: cd build_serial_debug && make -j V=0 CFLAGS="$CFLAGS_var_debug -Werror" CXXFLAGS="$CXXFLAGS_var_debug -Werror" + run: cd build_serial_debug && make $MAKEFLAGS CFLAGS="$CFLAGS_var_debug -Werror" CXXFLAGS="$CXXFLAGS_var_debug -Werror" - name: make install - run: cd build_serial_debug && make install -j + run: cd build_serial_debug && make install $MAKEFLAGS - name: make check - run: cd build_serial_debug && make check -j8 V=0 CFLAGS="$CFLAGS_var_debug -Werror" CXXFLAGS="$CXXFLAGS_var_debug -Werror" + run: cd build_serial_debug && make check $MAKEFLAGS CFLAGS="$CFLAGS_var_debug -Werror" CXXFLAGS="$CXXFLAGS_var_debug -Werror" - name: OnFailUploadLog if: failure() uses: actions/upload-artifact@v3 From a1ad1779a4ffda3adb2e145205642105a9e3c699 Mon Sep 17 00:00:00 2001 From: "Dreyer, Lukas" Date: Wed, 3 Jan 2024 15:50:56 +0100 Subject: [PATCH 37/58] Do not use extended mode of CXX compiler enforcement --- config/t8_include.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/t8_include.m4 b/config/t8_include.m4 index 2e97ffa873..59691f59d7 100644 --- a/config/t8_include.m4 +++ b/config/t8_include.m4 @@ -52,7 +52,7 @@ T8_CHECK_VTK([$1]) T8_CHECK_OCC([$1]) T8_CHECK_CPPSTDLIB([$1]) ]) -AC_DEFUN([T8_CHECK_CPPSTD],[AX_CXX_COMPILE_STDCXX([17],[ext],[mandatory])]) +AC_DEFUN([T8_CHECK_CPPSTD],[AX_CXX_COMPILE_STDCXX([17],[noext],[mandatory])]) dnl T8_AS_SUBPACKAGE(PREFIX) dnl Call from a package that is using T8 as a subpackage. From 182d13a06151571fcf0dd4f9150f8ddec288c904 Mon Sep 17 00:00:00 2001 From: Johannes Markert Date: Thu, 11 Jan 2024 12:47:58 +0100 Subject: [PATCH 38/58] Added include statement. --- src/t8_geometry/t8_geometry_with_vertices.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/t8_geometry/t8_geometry_with_vertices.h b/src/t8_geometry/t8_geometry_with_vertices.h index 2ce8ae59ed..48bf0e1702 100644 --- a/src/t8_geometry/t8_geometry_with_vertices.h +++ b/src/t8_geometry/t8_geometry_with_vertices.h @@ -28,6 +28,8 @@ #ifndef T8_GEOMETRY_WITH_VERTICES_H #define T8_GEOMETRY_WITH_VERTICES_H +#include + T8_EXTERN_C_BEGIN (); /** Set the vertex coordinates of a tree in the cmesh. From b8e4e15a6be01bf790f0b2c332c6c1ad99e8ae40 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Thu, 11 Jan 2024 13:17:28 +0100 Subject: [PATCH 39/58] change copyright year --- test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx index cf8283b1d4..eb460126c8 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx @@ -3,7 +3,7 @@ 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) 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 From 3f6a9103b1e0c434e107b12a3b5a600c1118e62b Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Thu, 11 Jan 2024 13:17:46 +0100 Subject: [PATCH 40/58] typos --- test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx index eb460126c8..69c48c865a 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx @@ -154,11 +154,11 @@ TEST_P (cmesh_set_partition_offsets_commit, test_set_offsets) t8_cmesh_unref (&cmesh); } -/* Make atest suite that iterates over all tree counts from 0 to the maximum. */ +/* Make a test suite that iterates over all tree counts from 0 to the maximum. */ INSTANTIATE_TEST_SUITE_P (t8_cmesh_set_partition_offsets_nocommit, cmesh_set_partition_offsets_nocommit, testing::Range (0, T8_TEST_PARTITION_OFFSET_MAX_TREE_NUM + 1)); -/* Make atest suite that iterates over all classes and a tree count from 0 to the maximum. */ +/* Make a test suite that iterates over all classes and a tree count from 0 to the maximum. */ INSTANTIATE_TEST_SUITE_P (t8_cmesh_set_partition_offsets_commit, cmesh_set_partition_offsets_commit, testing::Combine (AllEclasses, testing::Range (0, T8_TEST_PARTITION_OFFSET_MAX_TREE_NUM + 1))); \ No newline at end of file From 63ae99941d9da1cf01295026a215a3a2459d4ceb Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Thu, 11 Jan 2024 13:18:23 +0100 Subject: [PATCH 41/58] Switch test parameter to gloidx --- test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx index 69c48c865a..e5fd020691 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx @@ -45,7 +45,7 @@ /* The tests that do not commit the cmesh iterate over the number of trees, * hence we have a TestWithParam with one int. */ -class cmesh_set_partition_offsets_nocommit: public testing::TestWithParam { +class cmesh_set_partition_offsets_nocommit: public testing::TestWithParam { protected: void SetUp () override @@ -57,7 +57,7 @@ class cmesh_set_partition_offsets_nocommit: public testing::TestWithParam { /* The tests that do commit the cmesh iterate over eclasses and the number of * tress, hence they have a TestWithParam with eclass and int. */ -class cmesh_set_partition_offsets_commit: public testing::TestWithParam> { +class cmesh_set_partition_offsets_commit: public testing::TestWithParam> { protected: void SetUp () override @@ -156,9 +156,9 @@ TEST_P (cmesh_set_partition_offsets_commit, test_set_offsets) /* Make a test suite that iterates over all tree counts from 0 to the maximum. */ INSTANTIATE_TEST_SUITE_P (t8_cmesh_set_partition_offsets_nocommit, cmesh_set_partition_offsets_nocommit, - testing::Range (0, T8_TEST_PARTITION_OFFSET_MAX_TREE_NUM + 1)); + testing::Range (0, T8_TEST_PARTITION_OFFSET_MAX_TREE_NUM + 1)); /* Make a test suite that iterates over all classes and a tree count from 0 to the maximum. */ INSTANTIATE_TEST_SUITE_P (t8_cmesh_set_partition_offsets_commit, cmesh_set_partition_offsets_commit, testing::Combine (AllEclasses, - testing::Range (0, T8_TEST_PARTITION_OFFSET_MAX_TREE_NUM + 1))); \ No newline at end of file + testing::Range (0, T8_TEST_PARTITION_OFFSET_MAX_TREE_NUM + 1))); \ No newline at end of file From 3d7e2adaaa099a84e626fa6c830657de5f245ffc Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Thu, 11 Jan 2024 13:18:44 +0100 Subject: [PATCH 42/58] Use SetUp and TearDown function in test --- .../t8_gtest_cmesh_set_partition_offsets.cxx | 67 ++++++++++++------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx index e5fd020691..2bc1d5614c 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx @@ -51,8 +51,21 @@ class cmesh_set_partition_offsets_nocommit: public testing::TestWithParam (GetParam ()); inum_trees = std::get<1> (GetParam ()); + + + /* Initialize the cmesh */ + t8_cmesh_init (&cmesh); + + /* Specify a dimension */ + const int dim = t8_eclass_to_dimension[ieclass]; + t8_cmesh_set_dimension (cmesh, dim); + + + /* Set class for the trees */ + for (t8_gloidx_t itree = 0; itree < inum_trees; ++itree) { + t8_cmesh_set_tree_class (cmesh, itree, ieclass); + } + } + + void + TearDown () override + { + /* Destroy the cmesh */ + t8_cmesh_unref (&cmesh); } + t8_eclass_t ieclass; t8_gloidx_t inum_trees; + t8_cmesh_t cmesh; + sc_MPI_Comm comm = sc_MPI_COMM_WORLD; + const int main_process = 0; }; /* call t8_cmesh_offset_concentrate for non-derived cmesh * and destroy it before commit. */ TEST_P (cmesh_set_partition_offsets_nocommit, test_set_offsets) { - t8_cmesh_t cmesh; - const int main_process = 0; t8_debugf ("Testing t8_cmesh_set_partition_offset (no commit) with %li trees.\n", inum_trees); @@ -85,22 +121,15 @@ TEST_P (cmesh_set_partition_offsets_nocommit, test_set_offsets) t8_shmem_init (sc_MPI_COMM_WORLD); t8_shmem_array_t shmem_array = t8_cmesh_offset_concentrate (main_process, sc_MPI_COMM_WORLD, inum_trees); - /* Initialize the cmesh */ - t8_cmesh_init (&cmesh); /* Set the partition offsets */ t8_cmesh_set_partition_offsets (cmesh, shmem_array); - /* Destroy the cmesh */ - t8_cmesh_unref (&cmesh); } /* call t8_cmesh_offset_concentrate for non-derived cmesh * and commit it. */ TEST_P (cmesh_set_partition_offsets_commit, test_set_offsets) { - t8_cmesh_t cmesh; - const int main_process = 0; - sc_MPI_Comm comm = sc_MPI_COMM_WORLD; t8_debugf ("Testing t8_cmesh_set_partition_offset (with commit) with %li trees of class %s.\n", inum_trees, t8_eclass_to_string[ieclass]); @@ -112,21 +141,9 @@ TEST_P (cmesh_set_partition_offsets_commit, test_set_offsets) t8_shmem_init (comm); t8_shmem_array_t shmem_array = t8_cmesh_offset_concentrate (main_process, comm, inum_trees); - /* Initialize the cmesh */ - t8_cmesh_init (&cmesh); - /* Set the partition offsets */ t8_cmesh_set_partition_offsets (cmesh, shmem_array); - /* Specify a dimension */ - const int dim = t8_eclass_to_dimension[ieclass]; - t8_cmesh_set_dimension (cmesh, dim); - - /* Set class for the trees */ - for (int itree = 0; itree < inum_trees; ++itree) { - t8_cmesh_set_tree_class (cmesh, itree, ieclass); - } - /* Commit the cmesh */ t8_cmesh_commit (cmesh, comm); @@ -146,12 +163,14 @@ TEST_P (cmesh_set_partition_offsets_commit, test_set_offsets) /* Compute the reference value, num_trees for mpirank main_process, * 0 on each other rank. */ const t8_locidx_t expected_num_local_trees = mpirank == main_process ? inum_trees : 0; + + if (mpirank == main_process) { + /* Double check that no overflow from converting gloidx to locidx occured. */ + ASSERT_EQ (expected_num_local_trees, inum_trees); + } EXPECT_EQ (num_local_trees, expected_num_local_trees); EXPECT_EQ (t8_cmesh_get_num_trees (cmesh), inum_trees); - - /* Destroy the cmesh */ - t8_cmesh_unref (&cmesh); } /* Make a test suite that iterates over all tree counts from 0 to the maximum. */ From cc73c24362e8a184acb88617c2162d737c569972 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Thu, 11 Jan 2024 13:51:41 +0100 Subject: [PATCH 43/58] Spell-check and indentation --- .../t8_gtest_cmesh_set_partition_offsets.cxx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx index 2bc1d5614c..a21c311256 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx @@ -78,7 +78,6 @@ class cmesh_set_partition_offsets_commit: public testing::TestWithParam (GetParam ()); inum_trees = std::get<1> (GetParam ()); - /* Initialize the cmesh */ t8_cmesh_init (&cmesh); @@ -86,7 +85,6 @@ class cmesh_set_partition_offsets_commit: public testing::TestWithParam (0, T8_TEST_PARTITION_OFFSET_MAX_TREE_NUM + 1)); /* Make a test suite that iterates over all classes and a tree count from 0 to the maximum. */ -INSTANTIATE_TEST_SUITE_P (t8_cmesh_set_partition_offsets_commit, cmesh_set_partition_offsets_commit, - testing::Combine (AllEclasses, - testing::Range (0, T8_TEST_PARTITION_OFFSET_MAX_TREE_NUM + 1))); \ No newline at end of file +INSTANTIATE_TEST_SUITE_P ( + t8_cmesh_set_partition_offsets_commit, cmesh_set_partition_offsets_commit, + testing::Combine (AllEclasses, testing::Range (0, T8_TEST_PARTITION_OFFSET_MAX_TREE_NUM + 1))); \ No newline at end of file From 2f4843f3e233bab46f2e4fec1366d3c0ee1d0bb2 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Mon, 15 Jan 2024 10:22:27 +0100 Subject: [PATCH 44/58] remove deprecated indent markers --- src/t8_geometry/t8_geometry.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/t8_geometry/t8_geometry.cxx b/src/t8_geometry/t8_geometry.cxx index 5945f5fa46..c4c61b6973 100644 --- a/src/t8_geometry/t8_geometry.cxx +++ b/src/t8_geometry/t8_geometry.cxx @@ -368,7 +368,5 @@ t8_geometry_get_type (t8_cmesh_t cmesh, t8_gloidx_t gtreeid) t8_geom_handler_update_tree (geom_handler, cmesh, gtreeid); /* Return the type. */ - /* *INDENT-OFF* */ return geom_handler->active_geometry->t8_geom_get_type (); - /* *INDENT-ON* */ } From 01456090c10f0271e731d6d6c8603f3f2822b99d Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Mon, 15 Jan 2024 10:22:49 +0100 Subject: [PATCH 45/58] add include --- src/t8_cmesh/t8_cmesh_examples.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index a139388d57..a73de1b199 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include From 254e12a60a5ba77b20144009e599922abda984d1 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Mon, 15 Jan 2024 11:05:43 +0100 Subject: [PATCH 46/58] streamline geometries and make them all structs --- example/geometry/t8_example_geometries.cxx | 18 ++++++++++++------ src/t8_geometry/t8_geometry_base.hxx | 2 +- .../t8_geometry_examples.hxx | 6 ++++-- src/t8_geometry/t8_geometry_with_vertices.hxx | 5 +++-- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/example/geometry/t8_example_geometries.cxx b/example/geometry/t8_example_geometries.cxx index 066a8e0043..1922b350ea 100644 --- a/example/geometry/t8_example_geometries.cxx +++ b/example/geometry/t8_example_geometries.cxx @@ -76,7 +76,8 @@ typedef enum { * * This geometry does not provide a jacobian. */ -class t8_geometry_sincos: public t8_geometry { +struct t8_geometry_sincos: public t8_geometry +{ public: /* Basic constructor that sets the dimension and the name. */ t8_geometry_sincos (): t8_geometry (2, "t8_sincos_geometry") @@ -143,7 +144,8 @@ class t8_geometry_sincos: public t8_geometry { * It inherits from the w_vertices geometry since we use the tree's vertex coordinates. * This geometry does not provide a jacobian. */ -class t8_geometry_moebius: public t8_geometry_with_vertices { +struct t8_geometry_moebius: public t8_geometry_with_vertices +{ public: /* Basic constructor that sets the dimension and the name. */ t8_geometry_moebius (): t8_geometry_with_vertices (2, "t8_moebius_geometry") @@ -208,7 +210,8 @@ class t8_geometry_moebius: public t8_geometry_with_vertices { * * This geometry does not provide a jacobian. */ -class t8_geometry_cylinder: public t8_geometry { +struct t8_geometry_cylinder: public t8_geometry +{ public: /* Basic constructor that sets the dimension and the name. */ t8_geometry_cylinder (): t8_geometry (2, "t8_cylinder_geometry") @@ -269,7 +272,8 @@ class t8_geometry_cylinder: public t8_geometry { * * This geometry does not provide a jacobian. */ -class t8_geometry_circle: public t8_geometry_with_vertices { +struct t8_geometry_circle: public t8_geometry_with_vertices +{ public: /* Basic constructor that sets the dimension and the name. */ t8_geometry_circle (): t8_geometry_with_vertices (2, "t8_circle_geometry") @@ -339,7 +343,8 @@ class t8_geometry_circle: public t8_geometry_with_vertices { * The geometry can only be used with single tree cmeshes (unit square). */ -class t8_geometry_moving: public t8_geometry { +struct t8_geometry_moving: public t8_geometry +{ public: /* Basic constructor that sets the dimension the name and the time pointer. */ t8_geometry_moving (const double *time): t8_geometry (2, "t8_moving_geometry"), ptime (time) @@ -415,7 +420,8 @@ class t8_geometry_moving: public t8_geometry { * in z direction. * Can be used with 1 tree unit cube cmesh only. */ -class t8_geometry_cube_zdistorted: public t8_geometry { +struct t8_geometry_cube_zdistorted: public t8_geometry +{ public: /* Basic constructor that sets the dimension and the name. */ t8_geometry_cube_zdistorted (): t8_geometry (3, "t8_cube_zdistorted_geometry") diff --git a/src/t8_geometry/t8_geometry_base.hxx b/src/t8_geometry/t8_geometry_base.hxx index 3ffe15d582..2d24b40717 100644 --- a/src/t8_geometry/t8_geometry_base.hxx +++ b/src/t8_geometry/t8_geometry_base.hxx @@ -21,7 +21,7 @@ */ /** \file t8_geometry_base.hxx - * Implements the base pure virtual class t8_geometry which + * Implements the base pure virtual struct t8_geometry which * provides a general template for all geometries. */ 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 94fbb2ea40..ec91d549f9 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.hxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.hxx @@ -32,7 +32,8 @@ /** This geometry maps five quads to a disk. */ -class t8_geometry_squared_disk: public t8_geometry_with_vertices { +struct t8_geometry_squared_disk: public t8_geometry_with_vertices +{ public: /* Basic constructor that sets the dimension and the name. */ t8_geometry_squared_disk (): t8_geometry_with_vertices (2, "t8_squared_disk") @@ -89,7 +90,8 @@ class t8_geometry_squared_disk: public t8_geometry_with_vertices { /** This geometry maps the faces of an oktaeder to a spherical surface. */ -class t8_geometry_triangulated_spherical_surface: public t8_geometry_with_vertices { +struct t8_geometry_triangulated_spherical_surface: public t8_geometry_with_vertices +{ public: /* Basic constructor that sets the dimension and the name. */ t8_geometry_triangulated_spherical_surface (): t8_geometry_with_vertices (2, "t8_triangulated_spherical_surface") diff --git a/src/t8_geometry/t8_geometry_with_vertices.hxx b/src/t8_geometry/t8_geometry_with_vertices.hxx index efb2946c9c..2f39b76ddb 100644 --- a/src/t8_geometry/t8_geometry_with_vertices.hxx +++ b/src/t8_geometry/t8_geometry_with_vertices.hxx @@ -21,7 +21,7 @@ */ /** \file t8_geometry_with_vertices.hxx - * Implements the inherited class t8_geometry_with_vertices, which can be + * Implements the inherited struct t8_geometry_with_vertices, which can be * used for geometries that use vertex coordinate information of the cmesh. */ @@ -35,7 +35,8 @@ T8_EXTERN_C_BEGIN (); -class t8_geometry_with_vertices: public t8_geometry { +struct t8_geometry_with_vertices: public t8_geometry +{ public: /* Basic constructor that sets the dimension, the name, and the name for the attribute. */ t8_geometry_with_vertices (int dimension, const char *name, const char *attribute_name = NULL) From ed0896a2d54d78613d9de32a86b0e5c5b707fc41 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 16 Jan 2024 14:10:26 +0100 Subject: [PATCH 47/58] add missing c implementation of t8_geom_get_type --- src/t8_geometry/t8_geometry_base.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/t8_geometry/t8_geometry_base.cxx b/src/t8_geometry/t8_geometry_base.cxx index 9de004d98a..7737c719a6 100644 --- a/src/t8_geometry/t8_geometry_base.cxx +++ b/src/t8_geometry/t8_geometry_base.cxx @@ -50,3 +50,15 @@ t8_geom_get_name (const t8_geometry_c *geom) return geom->t8_geom_get_name (); } + +/** Get the type of the geometry. + * \param [in] geom A geometry. + * \return The type of \a geom. + */ +t8_geometry_type_t +t8_geom_get_type (const t8_geometry_c *geom) +{ + T8_ASSERT (geom != NULL); + + return geom->t8_geom_get_type (); +} From d134c7cec22166143ed57232171c97864527bc53 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 16 Jan 2024 14:11:03 +0100 Subject: [PATCH 48/58] add missing include --- src/t8_geometry/t8_geometry_base.hxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/t8_geometry/t8_geometry_base.hxx b/src/t8_geometry/t8_geometry_base.hxx index 2d24b40717..ee3d47ef2b 100644 --- a/src/t8_geometry/t8_geometry_base.hxx +++ b/src/t8_geometry/t8_geometry_base.hxx @@ -30,6 +30,7 @@ #include #include +#include T8_EXTERN_C_BEGIN (); From fd7278d6619a128c7f0e7152e2ec7ac1de88ac31 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Tue, 16 Jan 2024 14:11:29 +0100 Subject: [PATCH 49/58] use c implementation of t8_geom_get_type --- src/t8_cmesh/t8_cmesh_examples.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_examples.c b/src/t8_cmesh/t8_cmesh_examples.c index a73de1b199..643f5c543a 100644 --- a/src/t8_cmesh/t8_cmesh_examples.c +++ b/src/t8_cmesh/t8_cmesh_examples.c @@ -24,10 +24,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -1277,7 +1277,7 @@ t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const do t8_cmesh_t cmesh; t8_cmesh_init (&cmesh); - const int is_axis_aligned = geometry->t8_geom_get_type () == T8_GEOMETRY_TYPE_LINEAR_AXIS_ALIGNED; + const int is_axis_aligned = t8_geom_get_type (geometry) == T8_GEOMETRY_TYPE_LINEAR_AXIS_ALIGNED; t8_cmesh_register_geometry (cmesh, geometry); From adc831ec3f297f2c6b9f497d931ce002632aa258 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Thu, 18 Jan 2024 16:21:14 +0100 Subject: [PATCH 50/58] Apply suggestions from code review Co-authored-by: David Knapp --- test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx b/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx index b9bdbd7024..a00151f89b 100644 --- a/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx +++ b/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx @@ -90,13 +90,13 @@ TEST_P (cmesh_attribute_gloidx_array, check_values_data_not_persist) /* If we did not store any values, we except to get the NULL pointer back. */ if (entries == NULL) { - EXPECT_TRUE (get_entries == NULL); + EXPECT_EQ (get_entries, nullptr); /* Number of entries must be < 0 in that case and we cannot continue the test otherwise. */ ASSERT_EQ (num_entries, 0); } else { /* Otherwise it must not be NULL and we abort the test if it is. */ - ASSERT_TRUE (get_entries != NULL); + ASSERT_NE (get_entries, nullptr); } /* Check for equality of the values. */ @@ -114,13 +114,13 @@ TEST_P (cmesh_attribute_gloidx_array, check_values_data_persist) /* If we did not store any values, we except to get the NULL pointer back. */ if (entries == NULL) { - EXPECT_TRUE (get_entries == NULL); + EXPECT_EQ (get_entries, nullptr); /* Number of entries must be < 0 in that case and we cannot continue the test otherwise. */ ASSERT_EQ (num_entries, 0); } else { /* Otherwise it must not be NULL and we abort the test if it is. */ - ASSERT_TRUE (get_entries != NULL); + ASSERT_NE (get_entries, nullptr); } /* Check for equality of the values. */ From 6c5e222e1fdcbd91c9c557edd1d752eb6453fe63 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Thu, 18 Jan 2024 16:47:22 +0100 Subject: [PATCH 51/58] Combine data persist and nonpersist test --- .../t8_gtest_attribute_gloidx_array.cxx | 37 ++++--------------- 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx b/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx index a00151f89b..f9c9928baf 100644 --- a/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx +++ b/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx @@ -33,7 +33,8 @@ class cmesh_attribute_gloidx_array: public testing::TestWithParam { void SetUp () override { - num_entries = GetParam (); + num_entries = std::get<0> (GetParam ()); + check_tree_id = std::get<1> (GetParam ()); /* Build a cmesh with one QUAD tree and one TRIANGLE tree. */ t8_cmesh_init (&cmesh); @@ -77,40 +78,16 @@ class cmesh_attribute_gloidx_array: public testing::TestWithParam { t8_cmesh_t cmesh; t8_locidx_t num_entries; + t8_locidx_t check_tree_id; t8_gloidx_t *entries; t8_gloidx_t *get_entries; }; /** Check attribute values of cmeshes against reference values. */ -TEST_P (cmesh_attribute_gloidx_array, check_values_data_not_persist) +TEST_P (cmesh_attribute_gloidx_array, check_values_data) { - const t8_locidx_t tree_id = 0; - get_entries = t8_cmesh_get_attribute_gloidx_array (cmesh, t8_get_package_id (), T8_CMESH_NEXT_POSSIBLE_KEY, tree_id, - num_entries); - - /* If we did not store any values, we except to get the NULL pointer back. */ - if (entries == NULL) { - EXPECT_EQ (get_entries, nullptr); - /* Number of entries must be < 0 in that case and we cannot continue the test otherwise. */ - ASSERT_EQ (num_entries, 0); - } - else { - /* Otherwise it must not be NULL and we abort the test if it is. */ - ASSERT_NE (get_entries, nullptr); - } - - /* Check for equality of the values. */ - for (t8_locidx_t ientry = 0; ientry < num_entries; ++ientry) { - EXPECT_EQ (get_entries[ientry], ientry); - } -} - -/** Check attribute values of cmeshes against reference values. */ -TEST_P (cmesh_attribute_gloidx_array, check_values_data_persist) -{ - const t8_locidx_t tree_id = 1; - get_entries = t8_cmesh_get_attribute_gloidx_array (cmesh, t8_get_package_id (), T8_CMESH_NEXT_POSSIBLE_KEY, tree_id, - num_entries); + get_entries = t8_cmesh_get_attribute_gloidx_array (cmesh, t8_get_package_id (), T8_CMESH_NEXT_POSSIBLE_KEY, + check_tree_id, num_entries); /* If we did not store any values, we except to get the NULL pointer back. */ if (entries == NULL) { @@ -132,4 +109,4 @@ TEST_P (cmesh_attribute_gloidx_array, check_values_data_persist) /* Test for different number of entries. * 0, 100, 200, ... T8_ATTRIBUTE_TEST_MAX_NUM_ENTRIES */ INSTANTIATE_TEST_SUITE_P (t8_gtest_attribute_gloidx_array, cmesh_attribute_gloidx_array, - testing::Range (0, T8_ATTRIBUTE_TEST_MAX_NUM_ENTRIES + 1, 100)); + testing::Combine(testing::Range (0, T8_ATTRIBUTE_TEST_MAX_NUM_ENTRIES + 1, 100), testing::Range(0, 2)); From 4db17095d4c69816bb523441827ea3133fcd4194 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Thu, 18 Jan 2024 16:48:00 +0100 Subject: [PATCH 52/58] Update test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx Co-authored-by: David Knapp --- test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx b/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx index f9c9928baf..f1d6bf750e 100644 --- a/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx +++ b/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx @@ -3,7 +3,7 @@ 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) 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 7bce1d395f1a2695fec4e09c19303da1f72f478f Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Thu, 18 Jan 2024 19:21:51 +0100 Subject: [PATCH 53/58] Update src/t8_cmesh.h Co-authored-by: David Knapp --- src/t8_cmesh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh.h b/src/t8_cmesh.h index 7a4f7335be..73017be5ff 100644 --- a/src/t8_cmesh.h +++ b/src/t8_cmesh.h @@ -306,7 +306,7 @@ t8_cmesh_set_attribute_string (t8_cmesh_t cmesh, t8_gloidx_t gtree_id, int packa */ void t8_cmesh_set_attribute_gloidx_array (t8_cmesh_t cmesh, t8_gloidx_t gtree_id, int package_id, int key, - const t8_gloidx_t *data, size_t data_count, int data_persists); + const t8_gloidx_t *data, const size_t data_count, int data_persists); /** Insert a face-connection between two trees in a cmesh. * \param [in,out] cmesh The cmesh to be updated. From 8d7a67a14f1fc966a69a9a9a7e78c470f6d11776 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Thu, 18 Jan 2024 19:21:58 +0100 Subject: [PATCH 54/58] Update src/t8_cmesh/t8_cmesh.c Co-authored-by: David Knapp --- src/t8_cmesh/t8_cmesh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh.c b/src/t8_cmesh/t8_cmesh.c index e63d44b2cf..3c3d01facf 100644 --- a/src/t8_cmesh/t8_cmesh.c +++ b/src/t8_cmesh/t8_cmesh.c @@ -419,7 +419,7 @@ t8_cmesh_get_attribute (t8_cmesh_t cmesh, int package_id, int key, t8_locidx_t l * \see t8_cmesh_set_attribute_gloidx_array */ t8_gloidx_t * -t8_cmesh_get_attribute_gloidx_array (t8_cmesh_t cmesh, int package_id, int key, t8_locidx_t ltree_id, size_t data_count) +t8_cmesh_get_attribute_gloidx_array (t8_cmesh_t cmesh, int package_id, int key, t8_locidx_t ltree_id, const size_t data_count) { T8_ASSERT (0 <= data_count); return (t8_gloidx_t *) t8_cmesh_get_attribute (cmesh, package_id, key, ltree_id); From 21fb6869bb222ffc7e67bd75c3d5511af7629a70 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Thu, 18 Jan 2024 19:22:06 +0100 Subject: [PATCH 55/58] Update src/t8_cmesh.h Co-authored-by: David Knapp --- src/t8_cmesh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t8_cmesh.h b/src/t8_cmesh.h index 73017be5ff..e5616dc734 100644 --- a/src/t8_cmesh.h +++ b/src/t8_cmesh.h @@ -684,7 +684,7 @@ t8_cmesh_get_attribute (t8_cmesh_t cmesh, int package_id, int key, t8_locidx_t l */ t8_gloidx_t * t8_cmesh_get_attribute_gloidx_array (t8_cmesh_t cmesh, int package_id, int key, t8_locidx_t ltree_id, - size_t data_count); + const size_t data_count); /** Return the shared memory array storing the partition table of * a partitioned cmesh. From 618743a7d0c87af3092a734a77a3ecf7ae4a9188 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Thu, 18 Jan 2024 19:45:34 +0100 Subject: [PATCH 56/58] Bugfix parameter usage --- test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx b/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx index f9c9928baf..4b6932293c 100644 --- a/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx +++ b/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx @@ -28,7 +28,7 @@ #define T8_ATTRIBUTE_TEST_MAX_NUM_ENTRIES 1000 -class cmesh_attribute_gloidx_array: public testing::TestWithParam { +class cmesh_attribute_gloidx_array: public testing::TestWithParam> { protected: void SetUp () override @@ -109,4 +109,5 @@ TEST_P (cmesh_attribute_gloidx_array, check_values_data) /* Test for different number of entries. * 0, 100, 200, ... T8_ATTRIBUTE_TEST_MAX_NUM_ENTRIES */ INSTANTIATE_TEST_SUITE_P (t8_gtest_attribute_gloidx_array, cmesh_attribute_gloidx_array, - testing::Combine(testing::Range (0, T8_ATTRIBUTE_TEST_MAX_NUM_ENTRIES + 1, 100), testing::Range(0, 2)); + testing::Combine (testing::Range (0, T8_ATTRIBUTE_TEST_MAX_NUM_ENTRIES + 1, 100), + testing::Range (0, 2))); \ No newline at end of file From 1b10626e5b1d92b4f6886e0080158b6ac838e546 Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Fri, 19 Jan 2024 14:38:15 +0100 Subject: [PATCH 57/58] indent --- src/t8_cmesh/t8_cmesh.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/t8_cmesh/t8_cmesh.c b/src/t8_cmesh/t8_cmesh.c index 3c3d01facf..172c9ecc56 100644 --- a/src/t8_cmesh/t8_cmesh.c +++ b/src/t8_cmesh/t8_cmesh.c @@ -419,7 +419,8 @@ t8_cmesh_get_attribute (t8_cmesh_t cmesh, int package_id, int key, t8_locidx_t l * \see t8_cmesh_set_attribute_gloidx_array */ t8_gloidx_t * -t8_cmesh_get_attribute_gloidx_array (t8_cmesh_t cmesh, int package_id, int key, t8_locidx_t ltree_id, const size_t data_count) +t8_cmesh_get_attribute_gloidx_array (t8_cmesh_t cmesh, int package_id, int key, t8_locidx_t ltree_id, + const size_t data_count) { T8_ASSERT (0 <= data_count); return (t8_gloidx_t *) t8_cmesh_get_attribute (cmesh, package_id, key, ltree_id); From 538da0b01d8e5e0fc6df839b929885d9c403a58b Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Fri, 19 Jan 2024 14:43:57 +0100 Subject: [PATCH 58/58] comments --- test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx b/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx index 6daf30c7ff..e4c2bfbfa9 100644 --- a/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx +++ b/test/t8_cmesh/t8_gtest_attribute_gloidx_array.cxx @@ -24,12 +24,20 @@ #include #include -/* Test if multiple attributes are partitioned correctly. */ +/* Test the t8_cmesh_set_attribute_gloidx_array and t8_cmesh_get_attribute_gloidx_array functions. + * We create a cmesh with two trees and add an array with N entries to each tree. + * The first tree has data_persists = 0, the second data_persists = 1. + * Then we get the array and check whether it's entries are correct. + * We parametrize the test over the number of entries N and the treeid (0 or 1). + * Thus for each element count N, we do one test for the first tree and one for the second tree. + */ #define T8_ATTRIBUTE_TEST_MAX_NUM_ENTRIES 1000 class cmesh_attribute_gloidx_array: public testing::TestWithParam> { protected: + /* in Setup we build a two tree cmesh, fill an array with entries + * and set the array as attribute for both trees with different data_persists settings. */ void SetUp () override { @@ -83,7 +91,7 @@ class cmesh_attribute_gloidx_array: public testing::TestWithParam