diff --git a/src/t8_vtk/t8_vtk_writer.hxx b/src/t8_vtk/t8_vtk_writer.hxx index a396fef9d6..bf108cad59 100644 --- a/src/t8_vtk/t8_vtk_writer.hxx +++ b/src/t8_vtk/t8_vtk_writer.hxx @@ -257,12 +257,12 @@ class vtk_writer { /* Compute the coordinates of the element/tree. */ double *coordinates = T8_ALLOC (double, 3 * num_node); - grid_element_to_coords (grid, itree, element, curved_flag, coordinates, num_node, element_shape); + T8_ASSERT (coordinates != NULL); + grid_element_to_coords (grid, itree, element, curved_flag, coordinates, element_shape); vtkIdType ptId = -1; for (int ivertex = 0; ivertex < num_node; ivertex++, (*point_id)++) { const size_t offset_3d = 3 * ivertex; - /* Insert the point in the points array. */ double vtkCoords[3] = { coordinates[offset_3d], coordinates[offset_3d + 1], coordinates[offset_3d + 2] }; if (merge_points) { diff --git a/src/t8_vtk/t8_vtk_writer_helper.cxx b/src/t8_vtk/t8_vtk_writer_helper.cxx index ee5973b566..bd04042367 100644 --- a/src/t8_vtk/t8_vtk_writer_helper.cxx +++ b/src/t8_vtk/t8_vtk_writer_helper.cxx @@ -38,15 +38,15 @@ t8_get_number_of_vtk_nodes (const t8_element_shape_t eclass, const int curved_fl } void -t8_forest_vtk_get_element_nodes (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const int vertex, +t8_forest_vtk_get_element_nodes (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const int curved_flag, double *out_coords) { const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); const t8_scheme *scheme = t8_forest_get_scheme (forest); const t8_element_shape_t element_shape = scheme->element_get_shape (tree_class, element); - const double *ref_coords = t8_forest_vtk_point_to_element_ref_coords[element_shape][vertex]; - const int num_node = t8_get_number_of_vtk_nodes (element_shape, curved_flag); - t8_forest_element_from_ref_coords (forest, ltreeid, element, ref_coords, num_node, out_coords); + const double *ref_coords = t8_forest_vtk_point_to_element_ref_coords[element_shape][0]; + const int num_nodes = t8_get_number_of_vtk_nodes (element_shape, curved_flag); + t8_forest_element_from_ref_coords (forest, ltreeid, element, ref_coords, num_nodes, out_coords); } template <> @@ -202,21 +202,24 @@ grid_element_shape (const t8_cmesh_t grid, const t8_locidx_t itree, template <> void grid_element_to_coords (const t8_forest_t grid, const t8_locidx_t itree, const t8_element_t *element, - const int curved_flag, double *coordinates, [[maybe_unused]] const int num_node, + const int curved_flag, double *coordinates, [[maybe_unused]] const t8_element_shape_t shape) { - t8_forest_vtk_get_element_nodes (grid, itree, element, 0, curved_flag, coordinates); + t8_forest_vtk_get_element_nodes (grid, itree, element, curved_flag, coordinates); } template <> void grid_element_to_coords (const t8_cmesh_t grid, const t8_locidx_t itree, [[maybe_unused]] const t8_element_t *element, const int curved_flag, - double *coordinates, const int num_node, const t8_element_shape_t shape) + double *coordinates, const t8_element_shape_t shape) { const double *ref_coords = t8_forest_vtk_point_to_element_ref_coords[shape][curved_flag]; const t8_gloidx_t gtree_id = t8_cmesh_get_global_id (grid, itree); - t8_geometry_evaluate (grid, gtree_id, ref_coords, num_node, coordinates); + const t8_eclass_t eclass = t8_cmesh_get_tree_class (grid, itree); + const int num_nodes = t8_get_number_of_vtk_nodes (eclass, curved_flag); + + t8_geometry_evaluate (grid, gtree_id, ref_coords, num_nodes, coordinates); } template <> diff --git a/src/t8_vtk/t8_vtk_writer_helper.hxx b/src/t8_vtk/t8_vtk_writer_helper.hxx index d87581316a..698635ba00 100644 --- a/src/t8_vtk/t8_vtk_writer_helper.hxx +++ b/src/t8_vtk/t8_vtk_writer_helper.hxx @@ -103,12 +103,11 @@ t8_get_number_of_vtk_nodes (const t8_element_shape_t eclass, const int curved_fl * \param[in] forest The forest of \a element. * \param[in] ltreeid The local id to the tree of \a element. * \param[in] element The element to process. - * \param[in] vertex The id of the vertex to evaluate. - * \param[in] curved_flag Flag to tell if we use curved or linear cells. + * \param[in] curved_flag Flag to tell if we use curved or linear cells. * \param[in, out] out_coords An array to fill with the coordinates of the vertex. */ void -t8_forest_vtk_get_element_nodes (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const int vertex, +t8_forest_vtk_get_element_nodes (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const int curved_flag, double *out_coords); /** @@ -227,13 +226,12 @@ grid_element_shape (const grid_t grid, const t8_locidx_t itree, const t8_element * \param[in] element An element in the tree with local id \a itree. If \a grid is cmesh the input is ignored. * \param[in] curved_flag If true, we use quadratic elements to write. * \param[in, out] coordinates An array with enough space to hold 3*num_node doubles. On output filled with the coordinate of the corners of the element/tree - * \param[in] num_node The number of nodes to use to describe the element/tree. * \param[in] shape The shape of the element/tree. */ template void grid_element_to_coords (const grid_t grid, const t8_locidx_t itree, const t8_element_t *element, const int curved_flag, - double *coordinates, const int num_node, const t8_element_shape_t shape); + double *coordinates, const t8_element_shape_t shape); /** * Get the level of an element/tree. If \a grid is a cmesh we always return 0.