diff --git a/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx b/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx index a1d3f5371c..a328edad3a 100644 --- a/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx +++ b/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx @@ -102,7 +102,7 @@ t8_forest_construct_from_vtk (const char *prefix, sc_MPI_Comm comm, const int va /* Write the forest */ snprintf (out_file, BUFSIZ - 7, "%s_forest", out_prefix); - t8_forest_write_vtk_ext (forest, out_file, 1, 1, 1, 1, 1, 0, 1, 0, values_per_cell, vtk_data); + t8_forest_write_vtk_ext (forest, out_file, 1, 1, 1, 1, 1, 0, 1, values_per_cell, vtk_data); /* Free the cell-data */ if (values_per_cell > 0) { diff --git a/example/advect/t8_advection.cxx b/example/advect/t8_advection.cxx index 55e215e247..c6bcb88a65 100644 --- a/example/advect/t8_advection.cxx +++ b/example/advect/t8_advection.cxx @@ -581,10 +581,8 @@ t8_advect_replace (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t w #if T8_ENABLE_DEBUG /* Ensure that the number of incoming elements matches the * number of children of the outgoing element. */ - const t8_element_t *element_outgoing = - t8_forest_get_element_in_tree (forest_old, which_tree, first_outgoing); - const int num_children = - ts->t8_element_num_children (element_outgoing); + const t8_element_t *element_outgoing = t8_forest_get_element_in_tree (forest_old, which_tree, first_outgoing); + const int num_children = ts->t8_element_num_children (element_outgoing); T8_ASSERT (num_incoming == num_children); #endif /* The old element is refined, we copy the phi values and compute the new midpoints */ @@ -595,7 +593,7 @@ t8_advect_replace (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t w t8_advect_compute_element_data (problem, elem_data_in + i, element, which_tree, ts); t8_advect_element_set_phi_adapt (problem, first_incoming_data + i, phi_old); /* Set the neighbor entries to uninitialized */ - const int num_new_faces = ts->t8_element_num_faces (element); + const int num_new_faces = ts->t8_element_num_faces (element); elem_data_in[i].num_faces = num_new_faces; for (iface = 0; iface < num_new_faces; iface++) { elem_data_in[i].num_neighbors[iface] = 0; @@ -615,10 +613,8 @@ t8_advect_replace (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t w #if T8_ENABLE_DEBUG /* Ensure that the number of outgoing elements matches the * number of siblings of the first outgoing element. */ - const t8_element_t *element_outgoing = - t8_forest_get_element_in_tree (forest_old, which_tree, first_outgoing); - const int num_siblings = - ts->t8_element_num_siblings (element_outgoing); + const t8_element_t *element_outgoing = t8_forest_get_element_in_tree (forest_old, which_tree, first_outgoing); + const int num_siblings = ts->t8_element_num_siblings (element_outgoing); T8_ASSERT (num_outgoing == num_siblings); #endif /* The old elements form a family which is coarsened. We compute the average @@ -1117,7 +1113,7 @@ t8_advect_write_vtk (t8_advect_problem_t *problem) /* Write filename */ snprintf (fileprefix, BUFSIZ, "advection_%03i", problem->vtk_count); /* Write vtk files */ - if (t8_forest_write_vtk_ext (problem->forest, fileprefix, 1, 1, 1, 1, 0, 0, 0, 0, 4, vtk_data)) { + if (t8_forest_write_vtk_ext (problem->forest, fileprefix, 1, 1, 1, 1, 0, 0, 0, 4, vtk_data)) { t8_debugf ("[Advect] Wrote pvtu to files %s\n", fileprefix); } else { diff --git a/example/cmesh/t8_cmesh_geometry_examples.cxx b/example/cmesh/t8_cmesh_geometry_examples.cxx index 73985d8504..8f9f09f6d1 100644 --- a/example/cmesh/t8_cmesh_geometry_examples.cxx +++ b/example/cmesh/t8_cmesh_geometry_examples.cxx @@ -68,7 +68,7 @@ main (int argc, char **argv) t8_cmesh_vtk_write_file (cmesh, prefix_cmesh, 1.0); t8_global_productionf ("Wrote %s.\n", prefix_cmesh); - t8_forest_write_vtk_ext (forest, prefix_forest, 1, 1, 1, 1, 0, 1, 0, 0, 0, NULL); + t8_forest_write_vtk_ext (forest, prefix_forest, 1, 1, 1, 1, 0, 1, 0, 0, NULL); t8_global_productionf ("Wrote %s.\n\n", prefix_forest); t8_forest_unref (&forest); diff --git a/example/geometry/Makefile.am b/example/geometry/Makefile.am index b83642f31e..832ff2acda 100644 --- a/example/geometry/Makefile.am +++ b/example/geometry/Makefile.am @@ -3,11 +3,7 @@ # Included from toplevel directory bin_PROGRAMS += \ - example/geometry/t8_example_geometries \ - example/geometry/t8_puma_patches + example/geometry/t8_example_geometries example_geometry_t8_example_geometries_SOURCES = \ example/geometry/t8_example_geometries.cxx - -example_geometry_t8_puma_patches_SOURCES = \ - example/geometry/t8_puma_patches.cxx diff --git a/example/geometry/t8_example_geometries.cxx b/example/geometry/t8_example_geometries.cxx index 148c0adaa1..066a8e0043 100644 --- a/example/geometry/t8_example_geometries.cxx +++ b/example/geometry/t8_example_geometries.cxx @@ -970,7 +970,7 @@ t8_analytic_geom (int level, t8_example_geom_type geom_type) /* Write to vtk. We use the extended vtk function to export a curved vtk mesh. * This is only viable if you link to vtk. */ - t8_forest_write_vtk_ext (forest, vtuname, 1, 1, 1, 1, 0, 1, 0, 0, 0, NULL); + t8_forest_write_vtk_ext (forest, vtuname, 1, 1, 1, 1, 0, 1, 0, 0, NULL); /* Output */ t8_global_productionf ("Wrote forest to vtu files %s.*\n", vtuname); if (geom_type == T8_GEOM_CIRCLE) { diff --git a/example/geometry/t8_puma_patches.cxx b/example/geometry/t8_puma_patches.cxx deleted file mode 100644 index 408ab5fb4f..0000000000 --- a/example/geometry/t8_puma_patches.cxx +++ /dev/null @@ -1,255 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct t8_puma_patches_adapt_data -{ - double radius; - /** Radius of the refinement area around the refinement path. */ - int uniform_refinement_level; - /** Uniform refinement level of the mesh. */ - int refinement_level; - /** Refinement level along the refinement path. */ - double timestep; - /** Current timestep */ -}; - -/** - * The adaptation callback function. This function will be called once for each element - * and the return value decides whether this element should be refined or not. - * return > 0 -> This element should get refined. - * return = 0 -> This element should not get refined. - * If the current element is the first element of a family (= all level l elements that arise from refining - * the same level l-1 element) then this function is called with the whole family of elements - * as input and the return value additionally decides whether the whole family should get coarsened. - * return > 0 -> The first element should get refined. - * return = 0 -> The first element should not get refined. - * return < 0 -> The whole family should get coarsened. - * - * In this case, the function retrieves the geometry information of the tree the element belongs to. - * Based on that the function looks whether the tree is linked to a specific geometry - * and if this element touches this geometry. If true, it returns 1. Otherwise it returns 0. - * - * \param [in] forest The current forest that is in construction. - * \param [in] forest_from The forest from which we adapt the current forest (in our case, the uniform forest) - * \param [in] which_tree The process local id of the current tree. - * \param [in] lelement_id The tree local index of the current element (or the first of the family). - * \param [in] ts The refinement scheme for this tree's element class. - * \param [in] is_family if 1, the first \a num_elements entries in \a elements form a family. If 0, they do not. - * \param [in] num_elements The number of entries in \a elements elements that are defined. - * \param [in] elements The element or family of elements to consider for refinement/coarsening. - */ -int -t8_puma_patches_adapt_callback (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, - t8_locidx_t lelement_id, t8_eclass_scheme_c *ts, const int is_family, - const int num_elements, t8_element_t *elements[]) -{ - /* We retrieve the adapt data */ - const struct t8_puma_patches_adapt_data *adapt_data - = (const struct t8_puma_patches_adapt_data *) t8_forest_get_user_data (forest); - /* And check if it was retrieved successfully. */ - T8_ASSERT (adapt_data != NULL); - /* Refine element to the uniform refinement level */ - if (ts->t8_element_level (elements[0]) < adapt_data->uniform_refinement_level) { - return 1; - } - double current_path_point[3]; - if (adapt_data->timestep <= 0.5) { - current_path_point[0] = 0.3 + cos (4 * M_PI * adapt_data->timestep) * 0.2; - current_path_point[1] = 0.5 + sin (4 * M_PI * adapt_data->timestep) * 0.4; - } - else { - current_path_point[0] = 0.7 - cos (4 * M_PI * adapt_data->timestep) * 0.2; - current_path_point[1] = 0.5 + sin (4 * M_PI * adapt_data->timestep) * 0.4; - } - current_path_point[2] = 0; - double centroid[3]; - int inside_refinement_area = 0; - for (int ielement = 0; ielement < num_elements; ++ielement) { - t8_forest_element_centroid (forest_from, which_tree, elements[0], centroid); - if (t8_vec_dist (centroid, current_path_point) <= adapt_data->radius) { - inside_refinement_area = 1; - break; - } - } - if (inside_refinement_area && ts->t8_element_level (elements[0]) < adapt_data->refinement_level) { - return 1; - } - if (!inside_refinement_area && is_family - && ts->t8_element_level (elements[0]) > adapt_data->uniform_refinement_level + 1) { - return -1; - } - - /* Do not change this element. */ - return 0; -} - -int -t8_puma_patches (const int level, const int rlevel, const double radius, const int dim, double *stretch_factors) -{ - t8_cmesh_t cmesh; - t8_forest_t forest; - t8_forest_t forest_new; - t8_geometry_c *geom = new t8_geometry_linear_axis_aligned (dim); - std::string forest_vtu; - char fileprefix[BUFSIZ]; - double vertices[6] = { 0, 0, 0, 1, 1, 1 }; - if (dim == 2) { - vertices[5] = 0; - } - - t8_cmesh_init (&cmesh); - switch (dim) { - case 2: - t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_QUAD); - break; - case 3: - t8_cmesh_set_tree_class (cmesh, 0, T8_ECLASS_HEX); - break; - default: - SC_ABORT_NOT_REACHED (); - } - t8_cmesh_set_tree_vertices (cmesh, 0, vertices, 2); - t8_cmesh_register_geometry (cmesh, geom); - t8_cmesh_set_attribute (cmesh, 0, t8_get_package_id (), T8_CMESH_PATCH_STRETCH_FACTORS_KEY, stretch_factors, - 3 * sizeof (double), 0); - t8_cmesh_commit (cmesh, sc_MPI_COMM_WORLD); - - forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), level, 0, sc_MPI_COMM_WORLD); - - forest_vtu = "t8_puma_patches_uniform_level_" + std::to_string (level); - t8_forest_write_vtk_ext (forest, forest_vtu.c_str (), 0, 1, 1, 1, 0, 0, 1, 0, 0, NULL); - - t8_puma_patches_adapt_data adapt_data; - adapt_data.radius = radius; - adapt_data.uniform_refinement_level = level; - adapt_data.refinement_level = level + rlevel; - - for (adapt_data.timestep = 0; adapt_data.timestep <= 1; adapt_data.timestep += 0.02) { - t8_forest_init (&forest_new); - t8_forest_set_adapt (forest_new, forest, t8_puma_patches_adapt_callback, 1); - t8_forest_set_user_data (forest_new, &adapt_data); - t8_forest_set_partition (forest_new, forest, 0); - t8_forest_set_balance (forest_new, forest, 0); - t8_forest_commit (forest_new); - snprintf (fileprefix, BUFSIZ, "aaaaaaaa_%03i", (int) (adapt_data.timestep * 100)); - t8_forest_write_vtk_ext (forest_new, fileprefix, 0, 1, 1, 1, 0, 0, 1, 0, 0, NULL); - forest = forest_new; - } - t8_forest_unref (&forest); - return 0; -} - -int -main (int argc, char **argv) -{ - int mpiret; - sc_options_t *opt; - char usage[BUFSIZ]; - char help[BUFSIZ]; - int level; - int rlevel; - double stretch_factors[3]; - int dim; - double radius; - int parsed; - int helpme; - int sreturn; - - /* brief help message */ - snprintf (usage, BUFSIZ, - "\t%s \n\t%s -h\t" - "for a brief overview of all options.", - basename (argv[0]), basename (argv[0])); - - /* long help message */ - sreturn = snprintf (help, BUFSIZ, - "Demonstrates the usage of patches (partition of unity method(PUM)).\n" - "Patches are realized as axis-aligned, overlapping elements.\n" - "Usage: %s\n", - usage); - - if (sreturn >= BUFSIZ) { - /* The help message was truncated */ - /* Note: gcc >= 7.1 prints a warning if we - * do not check the return value of snprintf. */ - t8_debugf ("Warning: Truncated help message to '%s'\n", help); - } - - mpiret = sc_MPI_Init (&argc, &argv); - SC_CHECK_MPI (mpiret); - - sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_ESSENTIAL); - t8_init (SC_LP_DEFAULT); - - /* initialize command line argument parser */ - opt = sc_options_new (argv[0]); - sc_options_add_switch (opt, 'h', "help", &helpme, "Display a short help message."); - sc_options_add_int (opt, 'l', "level", &level, 4, "The uniform refinement level of the cover. Default: 4"); - sc_options_add_int (opt, 'r', "rlevel", &rlevel, 2, "The refinement level of the cover. Default: 2"); - sc_options_add_int (opt, 'd', "dim", &dim, 2, "The dimension of the cover. Default: 2"); - sc_options_add_double (opt, 'R', "radius", &radius, 0.07, "Radius of the refinement sphere. Default: 0.07"); - sc_options_add_double (opt, 'x', "xstretch", stretch_factors, 1.2, - "Definition of the stretch factor in the x-direction. Default: 1.2" - "There is a gradient in the stretch factors from left to right."); - sc_options_add_double (opt, 'y', "ystretch", stretch_factors + 1, 1.2, - "Definition of the stretch factor in the y-direction. Default: 1.2"); - sc_options_add_double (opt, 'z', "zstretch", stretch_factors + 2, 1.2, - "Definition of the stretch factor in the z-direction. Default: 1.2"); - - parsed = sc_options_parse (t8_get_package_id (), SC_LP_ERROR, opt, argc, argv); - if (helpme) { - /* display help message and usage */ - t8_global_productionf ("%s\n", help); - sc_options_print_usage (t8_get_package_id (), SC_LP_ERROR, opt, NULL); - } - else if (parsed >= 0 && 0 <= level && 0 <= rlevel && 2 <= dim && dim <= 3) { - t8_puma_patches (level, rlevel, radius, dim, stretch_factors); - } - else { - /* wrong usage */ - t8_global_productionf ("\n\t ERROR: Wrong usage.\n\n"); - sc_options_print_usage (t8_get_package_id (), SC_LP_ERROR, opt, NULL); - } - - sc_options_destroy (opt); - sc_finalize (); - - mpiret = sc_MPI_Finalize (); - SC_CHECK_MPI (mpiret); - - return 0; -} diff --git a/example/remove/t8_example_gauss_blob.cxx b/example/remove/t8_example_gauss_blob.cxx index dacec92022..f8bf76480a 100644 --- a/example/remove/t8_example_gauss_blob.cxx +++ b/example/remove/t8_example_gauss_blob.cxx @@ -91,7 +91,7 @@ t8_output_data_to_vtu (t8_forest_t forest, double *data, const char *prefix) int write_element_id = 1; int write_ghosts = 0; t8_forest_write_vtk_ext (forest, prefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, 0, - 0, 0, num_data, &vtk_data); + 0, num_data, &vtk_data); } /* Refine, if element is within a given radius. */ diff --git a/src/t8_cmesh/t8_cmesh_types.h b/src/t8_cmesh/t8_cmesh_types.h index b9c461557d..3494cdb10e 100644 --- a/src/t8_cmesh/t8_cmesh_types.h +++ b/src/t8_cmesh/t8_cmesh_types.h @@ -59,11 +59,9 @@ typedef struct t8_cprofile t8_cprofile_t; /* Defined below */ +T8_ECLASS_MAX_EDGES /* Used to store which face is linked to which surface */ #define T8_CMESH_OCC_FACE_PARAMETERS_ATTRIBUTE_KEY \ T8_CMESH_OCC_FACE_ATTRIBUTE_KEY + 1 /* Used to store face parameters */ -#define T8_CMESH_PATCH_STRETCH_FACTORS_KEY \ - T8_CMESH_OCC_FACE_PARAMETERS_ATTRIBUTE_KEY \ - +T8_ECLASS_MAX_FACES /* Used to store the patch stretch factors of a tree */ #define T8_CMESH_NEXT_POSSIBLE_KEY \ - T8_CMESH_PATCH_STRETCH_FACTORS_KEY + 1 /* The next free value for a t8code attribute key */ + T8_CMESH_OCC_FACE_PARAMETERS_ATTRIBUTE_KEY \ + +T8_ECLASS_MAX_FACES /* The next free value for a t8code attribute key */ /** This structure holds the connectivity data of the coarse mesh. * It can either be replicated, then each process stores a copy of the whole diff --git a/src/t8_forest/t8_forest.c b/src/t8_forest/t8_forest.c index 21f2a08dc0..901678f1f8 100644 --- a/src/t8_forest/t8_forest.c +++ b/src/t8_forest/t8_forest.c @@ -1361,16 +1361,15 @@ t8_forest_compute_elements_offset (t8_forest_t forest) int t8_forest_write_vtk_ext (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int write_ghosts, - const int write_curved, const int stretched_flag, int do_not_use_API, const int num_data, - t8_vtk_data_field_t *data) + const int write_curved, int do_not_use_API, const int num_data, t8_vtk_data_field_t *data) { T8_ASSERT (forest != NULL); T8_ASSERT (forest->rc.refcount > 0); T8_ASSERT (forest->committed); #if T8_WITH_VTK - if (!do_not_use_API && stretched_flag) { - t8_errorf ("WARNING: Export of stretched elements not yet available with the inbuild function. " + if (do_not_use_API && write_curved) { + t8_errorf ("WARNING: Export of curved elements not yet available with the inbuild function. " "Using the VTK API instead.\n"); do_not_use_API = 0; } @@ -1383,20 +1382,14 @@ t8_forest_write_vtk_ext (t8_forest_t forest, const char *fileprefix, const int w "Please link to VTK.\n" "Using the inbuild function to write out uncurved elements instead.\n"); } - if (stretched_flag) { - t8_errorf ("WARNING: Export of stretched elements not yet available with the inbuild function. " - "Please link to VTK.\n" - "Using the inbuild function to write out unstretched elements instead.\n"); - } do_not_use_API = 1; #endif if (!do_not_use_API) { return t8_forest_vtk_write_file_via_API (forest, fileprefix, write_treeid, write_mpirank, write_level, - write_element_id, write_ghosts, write_curved, stretched_flag, num_data, - data); + write_element_id, write_ghosts, write_curved, num_data, data); } else { - T8_ASSERT (!write_curved && !stretched_flag); + T8_ASSERT (!write_curved); return t8_forest_vtk_write_file (forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, num_data, data); } @@ -1405,7 +1398,7 @@ t8_forest_write_vtk_ext (t8_forest_t forest, const char *fileprefix, const int w int t8_forest_write_vtk (t8_forest_t forest, const char *fileprefix) { - return t8_forest_write_vtk_ext (forest, fileprefix, 1, 1, 1, 1, 0, 0, 0, 0, 0, NULL); + return t8_forest_write_vtk_ext (forest, fileprefix, 1, 1, 1, 1, 0, 0, 0, 0, NULL); } t8_forest_t diff --git a/src/t8_forest/t8_forest_cxx.cxx b/src/t8_forest/t8_forest_cxx.cxx index 6cdae11ecb..263a0f7e71 100644 --- a/src/t8_forest/t8_forest_cxx.cxx +++ b/src/t8_forest/t8_forest_cxx.cxx @@ -392,9 +392,9 @@ t8_forest_element_coordinate (t8_forest_t forest, t8_locidx_t ltree_id, const t8 } void -t8_forest_element_from_ref_coords (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, - const double *ref_coords, const size_t num_coords, double *coords_out, - const int stretch_elements) +t8_forest_element_from_ref_coords_ext (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, + const double *ref_coords, const size_t num_coords, double *coords_out, + const double *stretch_factors) { double tree_ref_coords[3] = { 0 }; const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); @@ -402,15 +402,12 @@ t8_forest_element_from_ref_coords (t8_forest_t forest, t8_locidx_t ltreeid, cons const t8_cmesh_t cmesh = t8_forest_get_cmesh (forest); const t8_gloidx_t gtreeid = t8_forest_global_tree_id (forest, ltreeid); - if (stretch_elements) { + if (stretch_factors != NULL) { #if T8_ENABLE_DEBUG const t8_geometry_type_t geom_type = t8_geometry_get_type (cmesh, gtreeid); T8_ASSERT (geom_type == T8_GEOMETRY_TYPE_LINEAR || geom_type == T8_GEOMETRY_TYPE_LINEAR_AXIS_ALIGNED); #endif /* T8_ENABLE_DEBUG */ const int tree_dim = t8_eclass_to_dimension[tree_class]; - double *stretch_factors - = (double *) t8_cmesh_get_attribute (cmesh, t8_get_package_id (), T8_CMESH_PATCH_STRETCH_FACTORS_KEY, ltreeid); - T8_ASSERT (stretch_factors != NULL); double stretched_ref_coords[T8_ECLASS_MAX_CORNERS * T8_ECLASS_MAX_DIM]; for (size_t i_coord = 0; i_coord < num_coords; ++i_coord) { for (int dim = 0; dim < tree_dim; ++dim) { @@ -481,7 +478,7 @@ t8_forest_element_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_el * reference coordinates */ const t8_element_shape_t element_shape = t8_element_shape (ts, element); t8_forest_element_from_ref_coords (forest, ltreeid, element, t8_element_centroid_ref_coords[element_shape], 1, - coordinates, 0); + coordinates); } /* Compute the length of the line from one corner to a second corner in an element */ diff --git a/src/t8_forest/t8_forest_geometrical.h b/src/t8_forest/t8_forest_geometrical.h index 21cfd84dcd..c5b8db51ed 100644 --- a/src/t8_forest/t8_forest_geometrical.h +++ b/src/t8_forest/t8_forest_geometrical.h @@ -52,21 +52,40 @@ t8_forest_element_coordinate (t8_forest_t forest, t8_locidx_t ltree_id, const t8 * is converted to global coordinates inside the domain. If needed, the element * is stretched by the given stretch factors (the resulting mesh is then * no longer non-overlapping). - * * \param [in] forest The forest. * \param [in] ltreeid The forest local id of the tree in which the element is. * \param [in] element The element. - * \param [in] ref_coord The reference coordinates of the point inside the element. + * \param [in] ref_coords The reference coordinates of the point inside the element. * \param [in] num_coords The number of coordinate sets in ref_coord (dimension x double). * \param [out] coords_out On input an allocated array to store 3 doubles, on output * the x, y and z coordinates of the point inside the domain. - * \param [in] stretch_elements If true, elements are stretched according to the stretch factors + * \param [in] stretch_factors If provided, elements are stretched according to the stretch factors * of the tree. */ + void +t8_forest_element_from_ref_coords_ext (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, + const double *ref_coords, const size_t num_coords, double *coords_out, + const double *stretch_factors); + +/** Compute the coordinates of a point inside an element inside a tree. + * The point is given in reference coordinates inside the element and gets + * converted to reference coordinates inside the tree. After that, the point + * is converted to global coordinates inside the domain. + * \param [in] forest The forest. + * \param [in] ltreeid The forest local id of the tree in which the element is. + * \param [in] element The element. + * \param [in] ref_coords The reference coordinates of the point inside the element. + * \param [in] num_coords The number of coordinate sets in ref_coord (dimension x double). + * \param [out] coords_out On input an allocated array to store 3 doubles, on output + * the x, y and z coordinates of the point inside the domain. + */ +inline void t8_forest_element_from_ref_coords (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, - const double *ref_coord, const size_t num_coords, double *coords_out, - const int stretch_elements); + const double *ref_coords, const size_t num_coords, double *coords_out) +{ + t8_forest_element_from_ref_coords_ext (forest, ltreeid, element, ref_coords, num_coords, coords_out, NULL); +} /** Compute the coordinates of the centroid of an element if a geometry * for this tree is registered in the forest's cmesh. diff --git a/src/t8_forest/t8_forest_io.h b/src/t8_forest/t8_forest_io.h index 73088fa67a..7f587c84e8 100644 --- a/src/t8_forest/t8_forest_io.h +++ b/src/t8_forest/t8_forest_io.h @@ -75,8 +75,7 @@ t8_forest_save (t8_forest_t forest); int t8_forest_write_vtk_ext (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int write_ghosts, - const int write_curved, const int stretched_flag, int do_not_use_API, const int num_data, - t8_vtk_data_field_t *data); + const int write_curved, int do_not_use_API, const int num_data, t8_vtk_data_field_t *data); /** Write the forest in a parallel vtu format. Writes one master * .pvtu file and each process writes in its own .vtu file. diff --git a/src/t8_forest/t8_forest_to_vtkUnstructured.hxx b/src/t8_forest/t8_forest_to_vtkUnstructured.hxx index cf2974e472..450f0fcf5d 100644 --- a/src/t8_forest/t8_forest_to_vtkUnstructured.hxx +++ b/src/t8_forest/t8_forest_to_vtkUnstructured.hxx @@ -58,8 +58,8 @@ T8_EXTERN_C_BEGIN (); void t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, vtkSmartPointer unstructuredGrid, const int write_treeid, const int write_mpirank, const int write_level, - const int write_element_id, const int curved_flag, const int stretch_flag, - const int write_ghosts, const int num_data, t8_vtk_data_field_t *data); + const int write_element_id, const int curved_flag, const int write_ghosts, + const int num_data, t8_vtk_data_field_t *data); #endif diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index eabca6ae7f..1ddb9d6878 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -178,13 +178,13 @@ t8_get_number_of_vtk_nodes (const t8_element_shape_t eclass, const int curved_fl #if T8_WITH_VTK static void t8_forest_vtk_get_element_nodes (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, const int vertex, - double *out_coords, const int stretch_flag) + double *out_coords) { const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); const t8_eclass_scheme_c *scheme = t8_forest_get_eclass_scheme (forest, tree_class); const t8_element_shape_t element_shape = scheme->t8_element_shape (element); const double *ref_coords = t8_forest_vtk_point_to_element_ref_coords[element_shape][vertex]; - t8_forest_element_from_ref_coords (forest, ltreeid, element, ref_coords, 1, out_coords, stretch_flag); + t8_forest_element_from_ref_coords (forest, ltreeid, element, ref_coords, 1, out_coords); } /** @@ -195,8 +195,8 @@ static void t8_forest_element_to_vtk_cell ( t8_forest_t forest, const t8_element_t *element, t8_eclass_scheme_c *scheme, const t8_locidx_t itree, const t8_gloidx_t offset, const int write_treeid, const int write_mpirank, const int write_level, - const int write_element_id, const int curved_flag, const int stretch_flag, const int is_ghost, const int elem_id, - long int *point_id, int *cellTypes, vtkSmartPointer points, vtkSmartPointer cellArray, + const int write_element_id, const int curved_flag, const int is_ghost, const int elem_id, long int *point_id, + int *cellTypes, vtkSmartPointer points, vtkSmartPointer cellArray, vtkSmartPointer vtk_treeid, vtkSmartPointer vtk_mpirank, vtkSmartPointer vtk_level, vtkSmartPointer vtk_element_id) { @@ -269,7 +269,7 @@ t8_forest_element_to_vtk_cell ( double coordinates[3]; for (int ivertex = 0; ivertex < num_node; ivertex++, (*point_id)++) { /* Compute the vertex coordinates inside the domain. */ - t8_forest_vtk_get_element_nodes (forest, itree, element, ivertex, coordinates, stretch_flag); + t8_forest_vtk_get_element_nodes (forest, itree, element, ivertex, coordinates); /* Insert point in the points array */ points->InsertNextPoint (coordinates[0], coordinates[1], coordinates[2]); @@ -315,8 +315,8 @@ t8_forest_element_to_vtk_cell ( int t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, - const int curved_flag, const int stretch_flag, const int write_ghosts, - const int num_data, t8_vtk_data_field_t *data) + const int curved_flag, const int write_ghosts, const int num_data, + t8_vtk_data_field_t *data) { #if T8_WITH_VTK int freturn = 0; @@ -330,7 +330,7 @@ t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, co vtkSmartPointer unstructuredGrid = vtkSmartPointer::New (); t8_forest_to_vtkUnstructuredGrid (forest, unstructuredGrid, write_treeid, write_mpirank, write_level, - write_element_id, curved_flag, stretch_flag, write_ghosts, num_data, data); + write_element_id, curved_flag, write_ghosts, num_data, data); /* * We define the filename used to write the pvtu and the vtu files. * The pwriterObj is of class XMLPUnstructuredGridWriter, the P in @@ -413,7 +413,7 @@ void t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, vtkSmartPointer unstructuredGrid, const int write_treeid, const int write_mpirank, const int write_level, const int write_element_id, const int write_ghosts, const int curved_flag, - const int stretch_flag, const int num_data, t8_vtk_data_field_t *data) + const int num_data, t8_vtk_data_field_t *data) { /*Check assertions: forest and fileprefix are not NULL and forest is committed */ T8_ASSERT (forest != NULL); @@ -491,8 +491,8 @@ t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, vtkSmartPointer /* General t8code header, always include this. */ -#include /* cmesh definition and basic interface. */ -#include /* cmesh-writer interface. */ -#include /* A collection of exemplary cmeshes */ - -/* Builds cmesh of 6 tetrahedra that build up a unit cube. - * \param [in] comm MPI Communicator to use. - * \return The coarse mesh. - */ -static t8_cmesh_t -t8_step1_build_tetcube_coarse_mesh (sc_MPI_Comm comm) -{ - t8_cmesh_t cmesh; - - /* Build a coarse mesh of 6 tetrahedral trees that form a cube. - * You can modify the first parameter to build a cube with different - * tree shapes, i.e. T8_ECLASS_QUAD for a unit square with 1 quadrilateral tree. - * See t8_eclass.h, t8_cmesh.h for all possible shapes. - * - * The second argument is the MPI communicator to use for this cmesh. - * The remaining arguments are 3 flags that control - * do_bcast - If non-zero only the root process will build the cmesh and will broadcast it to the other processes. The result is the same. - * do_partition - If non-zero the cmesh will be partitioned among the processes. If 0 each process has a copy of the whole cmesh. - * periodic - If non-zero the cube will have periodic boundaries. That is, i.e. the left face is connected to the right face. - */ - cmesh = t8_cmesh_new_hypercube (T8_ECLASS_TET, comm, 0, 0, 0); - - return cmesh; -} - -/* Write vtk (or more accurately vtu) files of the cmesh. - * \param [in] cmesh A coarse mesh. - * \param [in] prefix A string that is used as a prefix of the output files. - * - * This will create the file prefix.pvtu and the file prefix_0000.vtu. - * If the coarse mesh would be repartitioned, then it would write the .pvtu file - * and additionally one file prefix_MPIRANK.vtu per MPI rank. - */ -static void -t8_step1_write_cmesh_vtk (t8_cmesh_t cmesh, const char *prefix) -{ - t8_cmesh_vtk_write_file (cmesh, prefix, 1.0); -} - -/* Destroy a cmesh. This will free all allocated memory. - * \param [in] cmesh A cmesh. - */ -static void -t8_step1_destroy_cmesh (t8_cmesh_t cmesh) -{ - t8_cmesh_destroy (&cmesh); -} +#include +#include +#include +#include +#include int main (int argc, char **argv) { int mpiret; t8_cmesh_t cmesh; - /* The prefix for our output files. */ - const char prefix[BUFSIZ] = "t8_step1_tetcube"; - t8_locidx_t local_num_trees; - t8_gloidx_t global_num_trees; - - /* Initialize MPI. This has to happen before we initialize sc or t8code. */ mpiret = sc_MPI_Init (&argc, &argv); - /* Error check the MPI return value. */ SC_CHECK_MPI (mpiret); - - /* Initialize the sc library, has to happen before we initialize t8code. */ sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_ESSENTIAL); - /* Initialize t8code with log level SC_LP_PRODUCTION. See sc.h for more info on the log levels. */ t8_init (SC_LP_PRODUCTION); - /* Print a message on the root process. */ - t8_global_productionf (" [step1] \n"); - t8_global_productionf (" [step1] Hello, this is the step1 example of t8code.\n"); - t8_global_productionf (" [step1] In this example we build our first coarse mesh and output it to vtu files.\n"); - t8_global_productionf (" [step1] \n"); - - /* Build the coarse mesh */ - cmesh = t8_step1_build_tetcube_coarse_mesh (sc_MPI_COMM_WORLD); - /* Compute local and global number of trees. */ - local_num_trees = t8_cmesh_get_num_local_trees (cmesh); - global_num_trees = t8_cmesh_get_num_trees (cmesh); - t8_global_productionf (" [step1] Created coarse mesh.\n"); - t8_global_productionf (" [step1] Local number of trees:\t%i\n", local_num_trees); - t8_global_productionf (" [step1] Global number of trees:\t%li\n", global_num_trees); - t8_step1_write_cmesh_vtk (cmesh, prefix); - t8_global_productionf (" [step1] Wrote coarse mesh to vtu files: %s*\n", prefix); - t8_step1_destroy_cmesh (cmesh); - t8_global_productionf (" [step1] Destroyed coarse mesh.\n"); + cmesh = t8_cmesh_new_from_class (T8_ECLASS_LINE, sc_MPI_COMM_WORLD); + t8_productionf ("Local number of trees:\t%i\n", t8_cmesh_get_num_local_trees (cmesh)); + t8_productionf ("Global number of trees:\t%li\n", t8_cmesh_get_num_trees (cmesh)); + int orientation, dual_face; + t8_productionf ("Vertex memory address: %p\n", t8_cmesh_get_tree_vertices (cmesh, 0)); + const t8_ctree_t tree = t8_cmesh_get_tree (cmesh, 0); + t8_locidx_t *face_neighbors = (t8_locidx_t *) T8_TREE_FACE (tree); + t8_productionf ("Face neighbor memory address: %p\n", face_neighbors); + t8_cmesh_destroy (&cmesh); sc_finalize (); - mpiret = sc_MPI_Finalize (); SC_CHECK_MPI (mpiret); - return 0; } diff --git a/tutorials/general/t8_step4_partition_balance_ghost.cxx b/tutorials/general/t8_step4_partition_balance_ghost.cxx index 5f978e9b3e..ab388f253a 100644 --- a/tutorials/general/t8_step4_partition_balance_ghost.cxx +++ b/tutorials/general/t8_step4_partition_balance_ghost.cxx @@ -268,7 +268,7 @@ t8_step4_main (int argc, char **argv) t8_global_productionf (" [step4] Repartitioned forest and built ghost layer.\n"); t8_step3_print_forest_information (forest); /* Write forest to vtu files. */ - t8_forest_write_vtk_ext (forest, prefix_partition_ghost, 1, 1, 1, 1, 1, 0, 0, 1, 0, NULL); + t8_forest_write_vtk_ext (forest, prefix_partition_ghost, 1, 1, 1, 1, 1, 0, 1, 0, NULL); /* * Balance diff --git a/tutorials/general/t8_step5_element_data.cxx b/tutorials/general/t8_step5_element_data.cxx index 4b6839a80e..54867dd06b 100644 --- a/tutorials/general/t8_step5_element_data.cxx +++ b/tutorials/general/t8_step5_element_data.cxx @@ -224,7 +224,7 @@ t8_step5_output_data_to_vtu (t8_forest_t forest, struct t8_step5_data_per_elemen int write_element_id = 1; int write_ghosts = 0; t8_forest_write_vtk_ext (forest, prefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, - 0, 0, 0, num_data, &vtk_data); + 0, 0, num_data, &vtk_data); } T8_FREE (element_volumes); } diff --git a/tutorials/general/t8_step5_element_data_c_interface.c b/tutorials/general/t8_step5_element_data_c_interface.c index cb4cf5249a..a32596f4ce 100644 --- a/tutorials/general/t8_step5_element_data_c_interface.c +++ b/tutorials/general/t8_step5_element_data_c_interface.c @@ -228,7 +228,7 @@ t8_step5_output_data_to_vtu (t8_forest_t forest, struct t8_step5_data_per_elemen int write_element_id = 1; int write_ghosts = 0; t8_forest_write_vtk_ext (forest, prefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, - 0, 0, 0, num_data, &vtk_data); + 0, 0, num_data, &vtk_data); } T8_FREE (element_volumes); } diff --git a/tutorials/general/t8_step6_stencil.cxx b/tutorials/general/t8_step6_stencil.cxx index 45238e8a7e..50abd17533 100644 --- a/tutorials/general/t8_step6_stencil.cxx +++ b/tutorials/general/t8_step6_stencil.cxx @@ -349,7 +349,7 @@ t8_step6_output_data_to_vtu (t8_forest_t forest, struct data_per_element *data, const int write_element_id = 1; const int write_ghosts = 0; t8_forest_write_vtk_ext (forest, prefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, - 0, 0, 0, num_data, vtk_data); + 0, 0, num_data, vtk_data); } T8_FREE (heights); diff --git a/tutorials/general/t8_step7_interpolation.cxx b/tutorials/general/t8_step7_interpolation.cxx index bc1c002ba4..7769e1a7b2 100644 --- a/tutorials/general/t8_step7_interpolation.cxx +++ b/tutorials/general/t8_step7_interpolation.cxx @@ -239,7 +239,7 @@ t8_write_vtu (t8_forest_t forest, struct t8_step7_adapt_data *data, const char * int write_element_id = 1; int write_ghosts = 0; t8_forest_write_vtk_ext (forest, prefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, 0, - 0, 0, num_data, &vtk_data); + 0, num_data, &vtk_data); T8_FREE (element_data); } diff --git a/tutorials/general/t8_tutorial_search.cxx b/tutorials/general/t8_tutorial_search.cxx index 2d9887686c..068cb0038e 100644 --- a/tutorials/general/t8_tutorial_search.cxx +++ b/tutorials/general/t8_tutorial_search.cxx @@ -226,7 +226,7 @@ t8_tutorial_search_vtk (t8_forest_t forest, sc_array *particles_per_element, con strcpy (vtk_data.description, "Number of particles"); vtk_data.type = T8_VTK_SCALAR; /* Write vtu files with our user define number of particles data. */ - t8_forest_write_vtk_ext (forest, prefix, 1, 1, 1, 1, 0, 0, 0, 0, 1, &vtk_data); + t8_forest_write_vtk_ext (forest, prefix, 1, 1, 1, 1, 0, 0, 0, 1, &vtk_data); t8_global_productionf (" [search] Wrote forest and number of particles per element to %s*\n", prefix); }