From d0a95a8d14d8cf6565b92e340fe77077101fd337 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 24 Jun 2024 15:16:59 +0200 Subject: [PATCH 01/26] first ghost-interface draft --- .../t8_forest_ghost_interface.cxx | 41 +++++ .../t8_forest_ghost_interface.h | 59 ++++++++ .../t8_forest_ghost_interface.hxx | 141 ++++++++++++++++++ .../t8_forest_ghost_interface_faces.cxx | 104 +++++++++++++ .../t8_forest_ghost_interface_faces.h | 0 .../t8_forest_ghost_interface_faces.hxx | 74 +++++++++ 6 files changed, 419 insertions(+) create mode 100644 src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.cxx create mode 100644 src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.h create mode 100644 src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.hxx create mode 100644 src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx create mode 100644 src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.h create mode 100644 src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.cxx b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.cxx new file mode 100644 index 0000000000..d5ca9080f9 --- /dev/null +++ b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.cxx @@ -0,0 +1,41 @@ +/* + 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 + +T8_EXTERN_C_BEGIN (); + + +void t8_forest_ghost_interface_ref(t8_forest_ghost_interface_c * ghost_interface){ + ghost_interface->ref(); +} + +void t8_forest_ghost_interface_unref(t8_forest_ghost_interface_c * ghost_interface){ + ghost_interface->unref(); +} + + + +T8_EXTERN_C_END (); + diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.h b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.h new file mode 100644 index 0000000000..3086bcbc96 --- /dev/null +++ b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.h @@ -0,0 +1,59 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef T8_FOREST_GHOST_INTERFACE_H +#define T8_FOREST_GHOST_INTERFACE_H + +#include + + +T8_EXTERN_C_BEGIN (); + + +/** This typedef holds virtual functions for a particular ghost interface. + * We need it so that we can use t8_ghost_interface_c pointers in .c files + * without them seeing the actual C++ code (and then not compiling) + */ +typedef struct t8_forest_ghost_interface t8_forest_ghost_interface_c; + +/** + * Satisfy the C interface of forest + * Create a new ghost_interface with given version +*/ +t8_forest_ghost_interface_c * t8_forest_ghost_interface_face_new(int version); + + +/** + * Satisfy the C interface of forest + * Do a ref on the ghost_interface +*/ +void t8_forest_ghost_interface_ref(t8_forest_ghost_interface_c * ghost_interface); + +/** + * Satisfy the C interface of forest + * Do a unref on the ghost_interface +*/ +void t8_forest_ghost_interface_unref(t8_forest_ghost_interface_c * ghost_interface); + +T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_GHOST_INTERFACE_H */ \ No newline at end of file diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.hxx b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.hxx new file mode 100644 index 0000000000..4dac44d8b3 --- /dev/null +++ b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.hxx @@ -0,0 +1,141 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef T8_FOREST_GHOST_INTERFACE_HXX +#define T8_FOREST_GHOST_INTERFACE_HXX + +#include +#include +#include +#include + +T8_EXTERN_C_BEGIN (); + +struct t8_forest_ghost_interface +{ + public: + /** + * Constructor + */ + t8_forest_ghost_interface() : ghost_type(T8_GHOST_NONE) + { + t8_refcount_init (&rc); + t8_debugf ("Constructed the a None ghost_interface.\n"); + } + + /** + * Destructor. + */ + virtual ~t8_forest_ghost_interface () + { + if (sc_refcount_is_active (&rc)) { + T8_ASSERT (t8_refcount_is_last (&rc)); + t8_refcount_unref (&rc); + } + t8_debugf ("Deleted the ghost_interface.\n"); + } + + /** + * Get the type of the ghost_interface + * \return the type + */ + inline t8_ghost_type_t + t8_ghost_get_type() const + { + return ghost_type; + } + + /** + * Increase the reference count of the ghost interface. + */ + virtual inline void + ref () + { + t8_refcount_ref (&rc); + } + + /** + * Decrease the reference count of the ghost_interface. + * If the reference count reaches zero, the ghost_interface is deleted. + */ + virtual inline void + unref () + { + if (t8_refcount_unref (&rc)) { + t8_debugf ("Deleting the ghost_interface.\n"); + delete this; + } + } + + + /** + * The algorithm to create the ghost layer is structured in three steps + * First is every prozess tells every other one, witch elements belong to him + * Second every prozess identifies all his neighbor elements an to witch prozess they blong + * Third every prozesse send the date of his owne elements to the neighbots, + * which he knows have this element as a neighbor + */ + /** + * Virtual function for the first step. + * \param [in] forest the forest an witch the ghost should work + */ + virtual void + t8_ghost_step_1_allocate(t8_forest_t forest) + = 0; + + /** + * Clean up memory, which was allocatet in the first step, but first can releas after step two + * \param [in] forest the forest an witch the ghost should work + */ + virtual void + t8_ghost_step_1_clean_up(t8_forest_t forest) + = 0; + + /** + * Virtual function for the second step. + * \param [in] forest the forest an witch the ghost should work + */ + virtual void + t8_ghost_step_2(t8_forest_t forest) + = 0; + + + protected: + /** + * Constructor for the derivided classes to set the korrekt type for them. + * \param [in] g_type The type (faces, edges, userdefind, ...) of the ghost_interface + */ + t8_forest_ghost_interface(t8_ghost_type_t g_type) : ghost_type(g_type) { + t8_refcount_init (&rc); + t8_debugf ("Constructed a ghost_interface.\n"); + }; + /** type of the ghost_interface */ + t8_ghost_type_t ghost_type; + /** The reference count of the ghost_interface. TODO: Replace by shared_ptr when forest becomes a class. */ + t8_refcount_t rc; +}; + + + +T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_GHOST_INTERFACE_HXX */ diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx new file mode 100644 index 0000000000..e9b2c217c9 --- /dev/null +++ b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx @@ -0,0 +1,104 @@ +/* + 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 + + +t8_forest_ghost_interface_faces::t8_forest_ghost_interface_faces() + : t8_forest_ghost_interface(T8_GHOST_FACES), ghost_version(3), flag_step_1(0) +{ + // forest->ghost_type = ghost_type; + // forest->ghost_algorithm = ghost_version; +} + +t8_forest_ghost_interface_faces::t8_forest_ghost_interface_faces(int version) + : t8_forest_ghost_interface(T8_GHOST_FACES), ghost_version(version), flag_step_1(0) +{ + // SC_CHECK_ABORT (1 <= ghost_version && ghost_version <= 3, "Invalid choice for ghost version. Choose 1, 2, or 3.\n"); + // forest->ghost_type = ghost_type; + // forest->ghost_algorithm = ghost_version; +} + + +void +t8_forest_ghost_interface_faces::t8_ghost_step_1_allocate(t8_forest_t forest) +{ + t8_global_productionf (" t8_forest_ghost_interface_faces::t8_ghost_step_1_allocate \n"); + // if (forest->element_offsets == NULL) { + // /* create element offset array if not done already */ + // flag_step_1 = flag_step_1 | CREATE_ELEMENT_ARRAY; + // t8_forest_partition_create_offsets (forest); + // } + // if (forest->tree_offsets == NULL) { + // /* Create tree offset array if not done already */ + // flag_step_1 = flag_step_1 | CREATE_TREE_ARRAY; + // t8_forest_partition_create_tree_offsets (forest); + // } + // if (forest->global_first_desc == NULL) { + // /* Create global first desc array if not done already */ + // flag_step_1 = flag_step_1 | CREATE_GFIRST_DESC_ARRAY; + // t8_forest_partition_create_first_desc (forest); + // } +} + + +void +t8_forest_ghost_interface_faces::t8_ghost_step_1_clean_up(t8_forest_t forest) +{ + t8_global_productionf (" t8_forest_ghost_interface_faces::t8_ghost_step_1_clean_up \n"); + // if (flag_step_1 & CREATE_GFIRST_DESC_ARRAY){ + // /* Free the offset memory, if created */ + // t8_shmem_array_destroy (&forest->element_offsets); + // } + // if (flag_step_1 & CREATE_TREE_ARRAY) { + // /* Free the offset memory, if created */ + // t8_shmem_array_destroy (&forest->tree_offsets); + // } + // if (flag_step_1 & CREATE_GFIRST_DESC_ARRAY) { + // /* Free the offset memory, if created */ + // t8_shmem_array_destroy (&forest->global_first_desc); + // } +} + +void +t8_forest_ghost_interface_faces::t8_ghost_step_2(t8_forest_t forest) +{ + t8_global_productionf (" t8_forest_ghost_interface_faces::t8_ghost_step_2 \n"); + // T8_ASSERT( forest->ghosts != NULL); + // t8_forest_ghost_t ghost = forest->ghosts; + // if (ghost_version == -1) { + // t8_forest_ghost_fill_remote_v3 (forest); + // } + // else { + // /* Construct the remote elements and processes. */ + // t8_forest_ghost_fill_remote (forest, ghost, ghost_version != 0); + // } +} + + + + +t8_forest_ghost_interface_c * t8_forest_ghost_interface_face_new(int version){ + t8_forest_ghost_interface_faces * ghost_interface = new t8_forest_ghost_interface_faces(version); + return (t8_forest_ghost_interface_c *) ghost_interface; +} \ No newline at end of file diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.h b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx new file mode 100644 index 0000000000..e037241256 --- /dev/null +++ b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx @@ -0,0 +1,74 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + + + +#ifndef T8_GHOST_INTERFACE__FACE_H +#define T8_GHOST_INTERFACE__FACE_H + +#include + + +enum t8_ghost_interface_face_flag { + CREATE_ELEMENT_ARRAY = 1, + CREATE_TREE_ARRAY = 2, + CREATE_GFIRST_DESC_ARRAY= 4 +}; + +struct t8_forest_ghost_interface_faces : public t8_forest_ghost_interface +{ + public: + + t8_forest_ghost_interface_faces(); + + t8_forest_ghost_interface_faces(int version); + + ~t8_forest_ghost_interface_faces () + { + } + + inline int + t8_ghost_get_version() const + { + return ghost_version; + } + + + void + t8_ghost_step_1_allocate(t8_forest_t forest) override; + + void + t8_ghost_step_1_clean_up(t8_forest_t forest) override; + + + void + t8_ghost_step_2(t8_forest_t forest) override; + + protected: + + int ghost_version; + int32_t flag_step_1; + +}; + + +#endif /* !T8_GHOST_INTERFACE__FACE_H */ From 4d72771d492f20e021fdbe968c05e533785db9e7 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 24 Jun 2024 15:21:58 +0200 Subject: [PATCH 02/26] work status --- src/t8_forest/t8_forest.c | 20 +++++++++++++- src/t8_forest/t8_forest_balance.cxx | 3 +++ src/t8_forest/t8_forest_cxx.cxx | 3 +++ src/t8_forest/t8_forest_general.h | 7 ++++- src/t8_forest/t8_forest_ghost.cxx | 26 +++++++++++++++++++ .../t8_forest_ghost_interface_faces.cxx | 15 +++++++++-- .../t8_forest_ghost_interface_faces.hxx | 9 +++++-- src/t8_forest/t8_forest_types.h | 3 +++ 8 files changed, 80 insertions(+), 6 deletions(-) diff --git a/src/t8_forest/t8_forest.c b/src/t8_forest/t8_forest.c index 7a0a6c397c..79bbcc377b 100644 --- a/src/t8_forest/t8_forest.c +++ b/src/t8_forest/t8_forest.c @@ -218,6 +218,14 @@ t8_forest_set_balance (t8_forest_t forest, const t8_forest_t set_from, int no_re } } +void +t8_forest_set_ghost_ext_new (t8_forest_t forest, int do_ghost, t8_forest_ghost_interface_c * ghost_interface){ + T8_ASSERT (t8_forest_is_initialized (forest)); + SC_CHECK_ABORT (do_ghost == 0, "do_ghost == 0 in set_ghost_ext_new.\n"); + SC_CHECK_ABORT (ghost_interface == NULL, "invalides ghost interface in set_ghost_ext_new\n"); + forest->ghost_interface = ghost_interface; +} + void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type, int ghost_version) { @@ -243,7 +251,7 @@ t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type) { - /* Use ghost version 3, top-down search and for unbalanced forests. */ + /* Use ghost version 3, top-down search and for unbalanced forests. */ t8_forest_set_ghost_ext (forest, do_ghost, ghost_type, 3); } @@ -500,6 +508,12 @@ t8_forest_commit (t8_forest_t forest) forest->scheme_cxx = forest->set_from->scheme_cxx; forest->global_num_trees = forest->set_from->global_num_trees; + if (forest->ghost_interface == NULL && forest->set_from->ghost_interface != NULL) { + forest->ghost_interface = forest->set_from->ghost_interface; + t8_forest_ghost_interface_ref(forest->ghost_interface); + t8_debugf("t8_forest_commit: uebernehme ghost von set_from"); + } + /* Compute the maximum allowed refinement level */ t8_forest_compute_maxlevel (forest); if (forest->from_method == T8_FOREST_FROM_COPY) { @@ -1514,6 +1528,10 @@ t8_forest_reset (t8_forest_t *pforest) if (forest->ghosts != NULL) { t8_forest_ghost_unref (&forest->ghosts); } + /* Destroy the ghost_interface class if it exist */ + if (forest->ghost_interface != NULL){ + t8_forest_ghost_interface_unref(forest->ghost_interface); + } /* we have taken ownership on calling t8_forest_set_* */ if (forest->scheme_cxx != NULL) { t8_scheme_cxx_unref (&forest->scheme_cxx); diff --git a/src/t8_forest/t8_forest_balance.cxx b/src/t8_forest/t8_forest_balance.cxx index 3537311b6b..21f15564aa 100644 --- a/src/t8_forest/t8_forest_balance.cxx +++ b/src/t8_forest/t8_forest_balance.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -171,6 +172,8 @@ t8_forest_balance (t8_forest_t forest, int repartition) if (forest->set_from->ghosts == NULL) { forest->set_from->ghost_type = T8_GHOST_FACES; + // forest->set_from->ghost_algorithm = 3; + // forest->set_from->ghost_interface = t8_forest_ghost_interface_face_new(3); t8_forest_ghost_create_topdown (forest->set_from); } diff --git a/src/t8_forest/t8_forest_cxx.cxx b/src/t8_forest/t8_forest_cxx.cxx index 464457228d..e895532f86 100644 --- a/src/t8_forest/t8_forest_cxx.cxx +++ b/src/t8_forest/t8_forest_cxx.cxx @@ -36,6 +36,9 @@ #include #include #include +// #include +#include +#include #if T8_ENABLE_DEBUG #include #include diff --git a/src/t8_forest/t8_forest_general.h b/src/t8_forest/t8_forest_general.h index 7e39fa9c45..8a956bb709 100644 --- a/src/t8_forest/t8_forest_general.h +++ b/src/t8_forest/t8_forest_general.h @@ -32,6 +32,7 @@ #include #include #include +#include /** Opaque pointer to a forest implementation. */ typedef struct t8_forest *t8_forest_t; @@ -43,7 +44,8 @@ typedef enum { T8_GHOST_NONE = 0, /**< Do not create ghost layer. */ T8_GHOST_FACES, /**< Consider all face (codimension 1) neighbors. */ T8_GHOST_EDGES, /**< Consider all edge (codimension 2) and face neighbors. */ - T8_GHOST_VERTICES /**< Consider all vertex (codimension 3) and edge and face neighbors. */ + T8_GHOST_VERTICES, /**< Consider all vertex (codimension 3) and edge and face neighbors. */ + T8_GHOST_USERDEFINED/** If the user define by his self a step_1 or step_2 function*/ } t8_ghost_type_t; /** This typedef is needed as a helper construct to @@ -367,6 +369,9 @@ t8_forest_set_ghost (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_typ void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type, int ghost_version); +void +t8_forest_set_ghost_ext_new (t8_forest_t forest, int do_ghost, t8_forest_ghost_interface_c * ghost_interface); + /* TODO: use assertions and document that the forest_set (..., from) and * set_load are mutually exclusive. */ void diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index 64ba73fb77..5bef60f052 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -31,6 +31,10 @@ #include #include +#include +#include +#include + /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); @@ -1395,8 +1399,18 @@ t8_forest_ghost_create_ext (t8_forest_t forest, int unbalanced_version) sc_MPI_Request *requests; int create_tree_array = 0, create_gfirst_desc_array = 0; int create_element_array = 0; + t8_forest_ghost_interface_c * test_interface; T8_ASSERT (t8_forest_is_committed (forest)); + // T8_ASSERT (forest->ghost_interface != NULL); + + // if(forest->ghost_interface != NULL){ + // test_interface = forest->ghost_interface; + // } else{ + // test_interface = t8_forest_ghost_interface_face_new( unbalanced_version<0 ? 3 : unbalanced_version+1); // nur vorlaufig um etwas zu testen, wird später wieder entfernt + forest->ghost_interface = t8_forest_ghost_interface_face_new(3); + T8_ASSERT(test_interface != NULL); + // } t8_global_productionf ("Into t8_forest_ghost with %i local elements.\n", t8_forest_get_local_num_elements (forest)); @@ -1418,6 +1432,10 @@ t8_forest_ghost_create_ext (t8_forest_t forest, int unbalanced_version) t8_global_productionf ("Start ghost at %f %f\n", sc_MPI_Wtime (), forest->profile->ghost_runtime); } + // t8_global_productionf ("Befor step1\n"); + // (forest->ghost_interface)->t8_ghost_step_1_allocate(forest); + // test_interface->t8_ghost_step_1_allocate(forest); + if (forest->element_offsets == NULL) { /* create element offset array if not done already */ create_element_array = 1; @@ -1447,6 +1465,10 @@ t8_forest_ghost_create_ext (t8_forest_t forest, int unbalanced_version) t8_forest_ghost_init (&forest->ghosts, forest->ghost_type); ghost = forest->ghosts; + // t8_global_productionf ("Befor step2\n"); + // (forest->ghost_interface)->t8_ghost_step_2(forest); + // test_interface->t8_ghost_step_2(forest); + if (unbalanced_version == -1) { t8_forest_ghost_fill_remote_v3 (forest); } @@ -1465,6 +1487,10 @@ t8_forest_ghost_create_ext (t8_forest_t forest, int unbalanced_version) t8_forest_ghost_send_end (forest, ghost, send_info, requests); } + // t8_global_productionf ("Befor step1 clean up\n"); + // (forest->ghost_interface)->t8_ghost_step_1_clean_up(forest); + // test_interface->t8_ghost_step_1_clean_up(forest); + if (create_element_array) { /* Free the offset memory, if created */ t8_shmem_array_destroy (&forest->element_offsets); diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx index e9b2c217c9..2c66de96b1 100644 --- a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx +++ b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx @@ -34,7 +34,8 @@ t8_forest_ghost_interface_faces::t8_forest_ghost_interface_faces() t8_forest_ghost_interface_faces::t8_forest_ghost_interface_faces(int version) : t8_forest_ghost_interface(T8_GHOST_FACES), ghost_version(version), flag_step_1(0) { - // SC_CHECK_ABORT (1 <= ghost_version && ghost_version <= 3, "Invalid choice for ghost version. Choose 1, 2, or 3.\n"); + T8_ASSERT( 1 <= version && version <= 3 ); + SC_CHECK_ABORT (1 <= ghost_version && ghost_version <= 3, "Invalid choice for ghost version. Choose 1, 2, or 3.\n"); // forest->ghost_type = ghost_type; // forest->ghost_algorithm = ghost_version; } @@ -80,6 +81,13 @@ t8_forest_ghost_interface_faces::t8_ghost_step_1_clean_up(t8_forest_t forest) // } } + +/** + * algorithmus 1 : t8_forest_ghost_create_balanced_only --> t8_forest_ghost_create_ext (forest, 0); + * algorithmus 2 : t8_forest_ghost_create --> t8_forest_ghost_create_ext (forest, 1); + * algorithmus 3 : t8_forest_ghost_create_topdown --> t8_forest_ghost_create_ext (forest, -1); + * --> alg = unbalanced_version < 0 ? 3 : unbalanced_version + 1 +*/ void t8_forest_ghost_interface_faces::t8_ghost_step_2(t8_forest_t forest) { @@ -98,7 +106,10 @@ t8_forest_ghost_interface_faces::t8_ghost_step_2(t8_forest_t forest) -t8_forest_ghost_interface_c * t8_forest_ghost_interface_face_new(int version){ +t8_forest_ghost_interface_c * +t8_forest_ghost_interface_face_new(int version){ + t8_debugf ("Call t8_forest_ghost_interface_face_new.\n"); + T8_ASSERT( 1 <= version && version <= 3 ); t8_forest_ghost_interface_faces * ghost_interface = new t8_forest_ghost_interface_faces(version); return (t8_forest_ghost_interface_c *) ghost_interface; } \ No newline at end of file diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx index e037241256..d846a14054 100644 --- a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx +++ b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx @@ -27,7 +27,10 @@ #include - +/** + * Flags for first step function + * store in the flags which memory was allocated +*/ enum t8_ghost_interface_face_flag { CREATE_ELEMENT_ARRAY = 1, CREATE_TREE_ARRAY = 2, @@ -37,7 +40,9 @@ enum t8_ghost_interface_face_flag { struct t8_forest_ghost_interface_faces : public t8_forest_ghost_interface { public: - + /** + * Constru + */ t8_forest_ghost_interface_faces(); t8_forest_ghost_interface_faces(int version); diff --git a/src/t8_forest/t8_forest_types.h b/src/t8_forest/t8_forest_types.h index 10f4c84b72..a7fb487f9f 100644 --- a/src/t8_forest/t8_forest_types.h +++ b/src/t8_forest/t8_forest_types.h @@ -35,6 +35,8 @@ #include #include #include +#include +// #include typedef struct t8_profile t8_profile_t; /* Defined below */ typedef struct t8_forest_ghost *t8_forest_ghost_t; /* Defined below */ @@ -101,6 +103,7 @@ typedef struct t8_forest t8_ghost_type_t ghost_type; /**< If a ghost layer will be created, the type of neighbors that count as ghost. */ int ghost_algorithm; /**< Controls the algorithm used for ghost. 1 = balanced only. 2 = also unbalanced 3 = top-down search and unbalanced. */ + t8_forest_ghost_interface_c * ghost_interface; void *user_data; /**< Pointer for arbitrary user data. \see t8_forest_set_user_data. */ void (*user_function) (); /**< Pointer for arbitrary user function. \see t8_forest_set_user_function. */ void *t8code_data; /**< Pointer for arbitrary data that is used internally. */ From b8c6e378080c8973445263b441abbfea0889bca5 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 1 Jul 2024 13:54:34 +0200 Subject: [PATCH 03/26] update ghost_interface_unref, update set_ghost (not final), add debuging prints --- src/Makefile.am | 2 + src/t8_forest/t8_forest.c | 31 +++++++-- src/t8_forest/t8_forest_cxx.cxx | 1 - src/t8_forest/t8_forest_ghost.cxx | 41 +++++++----- .../t8_forest_ghost_interface.cxx | 14 +++- .../t8_forest_ghost_interface.h | 18 ----- .../t8_forest_ghost_interface.hxx | 4 ++ .../t8_forest_ghost_interface_faces.cxx | 9 +++ .../t8_forest_ghost_interface_faces.hxx | 6 +- .../t8_forest_ghost_interface_wrapper.h | 66 +++++++++++++++++++ 10 files changed, 148 insertions(+), 44 deletions(-) create mode 100644 src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_wrapper.h diff --git a/src/Makefile.am b/src/Makefile.am index 0983d65a09..7f2b8b784c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -139,6 +139,8 @@ libt8_compiled_sources = \ src/t8_forest/t8_forest_partition.cxx src/t8_forest/t8_forest_cxx.cxx \ src/t8_forest/t8_forest_private.c src/t8_forest/t8_forest_vtk.cxx \ src/t8_forest/t8_forest_ghost.cxx src/t8_forest/t8_forest_iterate.cxx \ + src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.cxx \ + src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx \ src/t8_version.c \ src/t8_vtk.c src/t8_forest/t8_forest_balance.cxx \ src/t8_forest/t8_forest_netcdf.cxx \ diff --git a/src/t8_forest/t8_forest.c b/src/t8_forest/t8_forest.c index 79bbcc377b..eeae30021a 100644 --- a/src/t8_forest/t8_forest.c +++ b/src/t8_forest/t8_forest.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -221,8 +222,16 @@ t8_forest_set_balance (t8_forest_t forest, const t8_forest_t set_from, int no_re void t8_forest_set_ghost_ext_new (t8_forest_t forest, int do_ghost, t8_forest_ghost_interface_c * ghost_interface){ T8_ASSERT (t8_forest_is_initialized (forest)); - SC_CHECK_ABORT (do_ghost == 0, "do_ghost == 0 in set_ghost_ext_new.\n"); - SC_CHECK_ABORT (ghost_interface == NULL, "invalides ghost interface in set_ghost_ext_new\n"); + SC_CHECK_ABORT (do_ghost != 0, "do_ghost == 0 in set_ghost_ext_new.\n"); + SC_CHECK_ABORT (ghost_interface != NULL, "invalides ghost interface in set_ghost_ext_new\n"); + if(forest->ghost_interface != NULL){ + t8_forest_ghost_interface_unref(&(forest->ghost_interface)); + } + forest->do_ghost = do_ghost; + forest->ghost_type = t8_forest_ghost_interface_get_type(ghost_interface); + if(forest->ghost_type == T8_GHOST_FACES){ + forest->ghost_algorithm = t8_forest_ghost_interface_face_verison(ghost_interface); + } forest->ghost_interface = ghost_interface; } @@ -245,13 +254,18 @@ t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost if (forest->do_ghost) { forest->ghost_type = ghost_type; forest->ghost_algorithm = ghost_version; + t8_forest_ghost_interface_c * ghost_interface = t8_forest_ghost_interface_face_new(ghost_version); + t8_forest_set_ghost_ext_new(forest, do_ghost, ghost_interface); + } + if(forest->ghost_interface != NULL){ + t8_productionf("t8_set_ghost_ext aufgerufen, obwohl schon ghost_interface existiert."); } } void t8_forest_set_ghost (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type) { - /* Use ghost version 3, top-down search and for unbalanced forests. */ + /* Use ghost version 3, top-down search and for unbalanced forests. */ t8_forest_set_ghost_ext (forest, do_ghost, ghost_type, 3); } @@ -511,7 +525,8 @@ t8_forest_commit (t8_forest_t forest) if (forest->ghost_interface == NULL && forest->set_from->ghost_interface != NULL) { forest->ghost_interface = forest->set_from->ghost_interface; t8_forest_ghost_interface_ref(forest->ghost_interface); - t8_debugf("t8_forest_commit: uebernehme ghost von set_from"); + t8_debugf("t8_forest_commit: uebernehme ghost von set_from\n"); + t8_productionf("t8_forest_commit: uebernehme ghost von set_from\n"); } /* Compute the maximum allowed refinement level */ @@ -667,6 +682,7 @@ t8_forest_commit (t8_forest_t forest) /* Construct a ghost layer, if desired */ if (forest->do_ghost) { /* TODO: ghost type */ + t8_productionf("t8_forest_commit: do_ghost\n"); switch (forest->ghost_algorithm) { case 1: t8_forest_ghost_create_balanced_only (forest); @@ -1402,10 +1418,12 @@ t8_forest_write_vtk_ext (t8_forest_t forest, const char *fileprefix, const int w do_not_use_API = 1; #endif if (!do_not_use_API) { + t8_productionf (" t8_forest_write_vtk_ext: t8_forest_vtk_write_file_via_API.\n"); return t8_forest_vtk_write_file_via_API (forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, write_curved, num_data, data); } else { + t8_productionf (" t8_forest_write_vtk_ext: t8_forest_vtk_write_file.\n"); 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); @@ -1497,6 +1515,7 @@ t8_forest_free_trees (t8_forest_t forest) static void t8_forest_reset (t8_forest_t *pforest) { + t8_productionf("t8_forest_reset:\n"); int mpiret; t8_forest_t forest; @@ -1508,10 +1527,12 @@ t8_forest_reset (t8_forest_t *pforest) if (!forest->committed) { if (forest->set_from != NULL) { /* in this case we have taken ownership and not released it yet */ + t8_productionf("set_from wird unref in t8_forest_reset\n"); t8_forest_unref (&forest->set_from); } } else { + t8_productionf("forest hat kein set_from in t8_forest_reset\n"); T8_ASSERT (forest->set_from == NULL); } @@ -1530,7 +1551,7 @@ t8_forest_reset (t8_forest_t *pforest) } /* Destroy the ghost_interface class if it exist */ if (forest->ghost_interface != NULL){ - t8_forest_ghost_interface_unref(forest->ghost_interface); + t8_forest_ghost_interface_unref(&(forest->ghost_interface)); } /* we have taken ownership on calling t8_forest_set_* */ if (forest->scheme_cxx != NULL) { diff --git a/src/t8_forest/t8_forest_cxx.cxx b/src/t8_forest/t8_forest_cxx.cxx index e895532f86..9afb3c7934 100644 --- a/src/t8_forest/t8_forest_cxx.cxx +++ b/src/t8_forest/t8_forest_cxx.cxx @@ -36,7 +36,6 @@ #include #include #include -// #include #include #include #if T8_ENABLE_DEBUG diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index 5bef60f052..ee87707625 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -1394,23 +1394,25 @@ t8_forest_ghost_receive (t8_forest_t forest, t8_forest_ghost_t ghost) void t8_forest_ghost_create_ext (t8_forest_t forest, int unbalanced_version) { + t8_productionf("t8_forest_ghost_create_ext(forest, %i):\n", unbalanced_version); t8_forest_ghost_t ghost = NULL; t8_ghost_mpi_send_info_t *send_info; sc_MPI_Request *requests; int create_tree_array = 0, create_gfirst_desc_array = 0; int create_element_array = 0; - t8_forest_ghost_interface_c * test_interface; + t8_forest_ghost_interface_c * test_interface = NULL; T8_ASSERT (t8_forest_is_committed (forest)); // T8_ASSERT (forest->ghost_interface != NULL); - // if(forest->ghost_interface != NULL){ - // test_interface = forest->ghost_interface; - // } else{ + if(forest->ghost_interface != NULL){ + test_interface = forest->ghost_interface; + } else{ + t8_productionf("no ghost_interface ther\n"); // test_interface = t8_forest_ghost_interface_face_new( unbalanced_version<0 ? 3 : unbalanced_version+1); // nur vorlaufig um etwas zu testen, wird später wieder entfernt - forest->ghost_interface = t8_forest_ghost_interface_face_new(3); - T8_ASSERT(test_interface != NULL); - // } + // forest->ghost_interface = test_interface; + // T8_ASSERT(test_interface != NULL); + } t8_global_productionf ("Into t8_forest_ghost with %i local elements.\n", t8_forest_get_local_num_elements (forest)); @@ -1432,9 +1434,10 @@ t8_forest_ghost_create_ext (t8_forest_t forest, int unbalanced_version) t8_global_productionf ("Start ghost at %f %f\n", sc_MPI_Wtime (), forest->profile->ghost_runtime); } - // t8_global_productionf ("Befor step1\n"); - // (forest->ghost_interface)->t8_ghost_step_1_allocate(forest); - // test_interface->t8_ghost_step_1_allocate(forest); + if(test_interface != NULL){ + t8_global_productionf ("Befor step1\n"); + test_interface->t8_ghost_step_1_allocate(forest); + } if (forest->element_offsets == NULL) { /* create element offset array if not done already */ @@ -1465,15 +1468,19 @@ t8_forest_ghost_create_ext (t8_forest_t forest, int unbalanced_version) t8_forest_ghost_init (&forest->ghosts, forest->ghost_type); ghost = forest->ghosts; - // t8_global_productionf ("Befor step2\n"); - // (forest->ghost_interface)->t8_ghost_step_2(forest); - // test_interface->t8_ghost_step_2(forest); + if(test_interface != NULL){ + t8_global_productionf ("Befor step2\n"); + // (forest->ghost_interface)->t8_ghost_step_2(forest); + test_interface->t8_ghost_step_2(forest); + } if (unbalanced_version == -1) { + t8_global_productionf ("t8_forest_ghost_create_ext: t8_forest_ghost_fill_remote_v3(forest)\n"); t8_forest_ghost_fill_remote_v3 (forest); } else { /* Construct the remote elements and processes. */ + t8_global_productionf ("t8_forest_ghost_create_ext: t8_forest_ghost_fill_remote (forest, ghost, unbalanced_version != 0)\n"); t8_forest_ghost_fill_remote (forest, ghost, unbalanced_version != 0); } @@ -1487,9 +1494,11 @@ t8_forest_ghost_create_ext (t8_forest_t forest, int unbalanced_version) t8_forest_ghost_send_end (forest, ghost, send_info, requests); } - // t8_global_productionf ("Befor step1 clean up\n"); - // (forest->ghost_interface)->t8_ghost_step_1_clean_up(forest); - // test_interface->t8_ghost_step_1_clean_up(forest); + if(test_interface != NULL){ + t8_global_productionf ("Befor step1 clean up\n"); + // (forest->ghost_interface)->t8_ghost_step_1_clean_up(forest); + test_interface->t8_ghost_step_1_clean_up(forest); + } if (create_element_array) { /* Free the offset memory, if created */ diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.cxx b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.cxx index d5ca9080f9..bf85142099 100644 --- a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.cxx +++ b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.cxx @@ -26,12 +26,24 @@ T8_EXTERN_C_BEGIN (); +t8_ghost_type_t +t8_forest_ghost_interface_get_type(t8_forest_ghost_interface_c * ghost_interface){ + T8_ASSERT (ghost_interface != NULL); + ghost_interface->t8_ghost_get_type(); +} void t8_forest_ghost_interface_ref(t8_forest_ghost_interface_c * ghost_interface){ + T8_ASSERT (ghost_interface != NULL); ghost_interface->ref(); } -void t8_forest_ghost_interface_unref(t8_forest_ghost_interface_c * ghost_interface){ +void t8_forest_ghost_interface_unref(t8_forest_ghost_interface_c ** pghost_interface){ + t8_forest_ghost_interface_c * ghost_interface; + + T8_ASSERT (pghost_interface != NULL); + ghost_interface = *pghost_interface; + T8_ASSERT (ghost_interface != NULL); + ghost_interface->unref(); } diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.h b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.h index 3086bcbc96..181bcf2923 100644 --- a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.h +++ b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.h @@ -35,24 +35,6 @@ T8_EXTERN_C_BEGIN (); */ typedef struct t8_forest_ghost_interface t8_forest_ghost_interface_c; -/** - * Satisfy the C interface of forest - * Create a new ghost_interface with given version -*/ -t8_forest_ghost_interface_c * t8_forest_ghost_interface_face_new(int version); - - -/** - * Satisfy the C interface of forest - * Do a ref on the ghost_interface -*/ -void t8_forest_ghost_interface_ref(t8_forest_ghost_interface_c * ghost_interface); - -/** - * Satisfy the C interface of forest - * Do a unref on the ghost_interface -*/ -void t8_forest_ghost_interface_unref(t8_forest_ghost_interface_c * ghost_interface); T8_EXTERN_C_END (); diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.hxx b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.hxx index 4dac44d8b3..1051676e39 100644 --- a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.hxx +++ b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.hxx @@ -27,6 +27,7 @@ #include #include #include +#include T8_EXTERN_C_BEGIN (); @@ -52,6 +53,7 @@ struct t8_forest_ghost_interface t8_refcount_unref (&rc); } t8_debugf ("Deleted the ghost_interface.\n"); + t8_productionf ("Deleted the ghost_interface.\n"); } /** @@ -82,6 +84,7 @@ struct t8_forest_ghost_interface { if (t8_refcount_unref (&rc)) { t8_debugf ("Deleting the ghost_interface.\n"); + t8_productionf ("Deleting the ghost_interface.\n"); delete this; } } @@ -127,6 +130,7 @@ struct t8_forest_ghost_interface t8_forest_ghost_interface(t8_ghost_type_t g_type) : ghost_type(g_type) { t8_refcount_init (&rc); t8_debugf ("Constructed a ghost_interface.\n"); + t8_productionf("Constructed a ghost_interface.\n"); }; /** type of the ghost_interface */ t8_ghost_type_t ghost_type; diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx index 2c66de96b1..d4a8e9a149 100644 --- a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx +++ b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx @@ -22,6 +22,7 @@ #include #include +#include t8_forest_ghost_interface_faces::t8_forest_ghost_interface_faces() @@ -112,4 +113,12 @@ t8_forest_ghost_interface_face_new(int version){ T8_ASSERT( 1 <= version && version <= 3 ); t8_forest_ghost_interface_faces * ghost_interface = new t8_forest_ghost_interface_faces(version); return (t8_forest_ghost_interface_c *) ghost_interface; +} + +int +t8_forest_ghost_interface_face_verison(t8_forest_ghost_interface_c * ghost_interface){ + T8_ASSERT(ghost_interface != NULL); + T8_ASSERT(ghost_interface->t8_ghost_get_type() == T8_GHOST_FACES); + t8_forest_ghost_interface_faces * carsted_ghost_interface = (t8_forest_ghost_interface_faces *) ghost_interface; + return carsted_ghost_interface->t8_ghost_get_version(); } \ No newline at end of file diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx index d846a14054..e279f5b077 100644 --- a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx +++ b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx @@ -22,8 +22,8 @@ -#ifndef T8_GHOST_INTERFACE__FACE_H -#define T8_GHOST_INTERFACE__FACE_H +#ifndef T8_GHOST_INTERFACE_FACE_H +#define T8_GHOST_INTERFACE_FACE_H #include @@ -76,4 +76,4 @@ struct t8_forest_ghost_interface_faces : public t8_forest_ghost_interface }; -#endif /* !T8_GHOST_INTERFACE__FACE_H */ +#endif /* !T8_GHOST_INTERFACE_FACE_H */ diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_wrapper.h b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_wrapper.h new file mode 100644 index 0000000000..419bc826e5 --- /dev/null +++ b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_wrapper.h @@ -0,0 +1,66 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef T8_FOREST_GHOST_INTERFACE_WRAPPER_H +#define T8_FOREST_GHOST_INTERFACE_WRAPPER_H + +#include +#include +#include + + +T8_EXTERN_C_BEGIN (); + + +/** + * Satisfy the C interface of forest + * Create a new ghost_interface with given version +*/ +t8_forest_ghost_interface_c * t8_forest_ghost_interface_face_new(int version); + +/** + * Satisfy the C interface of forest + * Return for a ghost_interface of Type FACE the ghost_algorithm / ghost_version +*/ +int t8_forest_ghost_interface_face_verison(t8_forest_ghost_interface_c * ghost_interface); + +/** + * Satisfy the C interface of forest + * Return the type of a ghost_interface +*/ +t8_ghost_type_t t8_forest_ghost_interface_get_type(t8_forest_ghost_interface_c * ghost_interface); + +/** + * Satisfy the C interface of forest + * Do a ref on the ghost_interface +*/ +void t8_forest_ghost_interface_ref(t8_forest_ghost_interface_c * ghost_interface); + +/** + * Satisfy the C interface of forest + * Do a unref on the ghost_interface +*/ +void t8_forest_ghost_interface_unref(t8_forest_ghost_interface_c ** pghost_interface); + +T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_GHOST_INTERFACE_WRAPPER_H */ \ No newline at end of file From 11db7f3cc2b989263874a51ade5d3f820a43f89b Mon Sep 17 00:00:00 2001 From: antjeHP Date: Thu, 4 Jul 2024 12:43:00 +0200 Subject: [PATCH 04/26] updated ghost_interface_face --- src/t8_forest/t8_forest.c | 20 +--- src/t8_forest/t8_forest_general.h | 9 ++ src/t8_forest/t8_forest_ghost.cxx | 112 +++++++++--------- src/t8_forest/t8_forest_ghost.h | 36 +++++- .../t8_forest_ghost_interface_faces.cxx | 77 ++++++------ src/t8_forest/t8_forest_vtk.cxx | 4 + 6 files changed, 147 insertions(+), 111 deletions(-) diff --git a/src/t8_forest/t8_forest.c b/src/t8_forest/t8_forest.c index eeae30021a..a704ec2ab9 100644 --- a/src/t8_forest/t8_forest.c +++ b/src/t8_forest/t8_forest.c @@ -228,10 +228,6 @@ t8_forest_set_ghost_ext_new (t8_forest_t forest, int do_ghost, t8_forest_ghost_i t8_forest_ghost_interface_unref(&(forest->ghost_interface)); } forest->do_ghost = do_ghost; - forest->ghost_type = t8_forest_ghost_interface_get_type(ghost_interface); - if(forest->ghost_type == T8_GHOST_FACES){ - forest->ghost_algorithm = t8_forest_ghost_interface_face_verison(ghost_interface); - } forest->ghost_interface = ghost_interface; } @@ -252,8 +248,6 @@ t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost forest->do_ghost = (do_ghost != 0); /* True if and only if do_ghost != 0 */ } if (forest->do_ghost) { - forest->ghost_type = ghost_type; - forest->ghost_algorithm = ghost_version; t8_forest_ghost_interface_c * ghost_interface = t8_forest_ghost_interface_face_new(ghost_version); t8_forest_set_ghost_ext_new(forest, do_ghost, ghost_interface); } @@ -683,19 +677,7 @@ t8_forest_commit (t8_forest_t forest) if (forest->do_ghost) { /* TODO: ghost type */ t8_productionf("t8_forest_commit: do_ghost\n"); - switch (forest->ghost_algorithm) { - case 1: - t8_forest_ghost_create_balanced_only (forest); - break; - case 2: - t8_forest_ghost_create (forest); - break; - case 3: - t8_forest_ghost_create_topdown (forest); - break; - default: - SC_ABORT ("Invalid choice of ghost algorithm"); - } + t8_forest_ghost_create_ext(forest); } forest->do_ghost = 0; } diff --git a/src/t8_forest/t8_forest_general.h b/src/t8_forest/t8_forest_general.h index 8a956bb709..332e79233f 100644 --- a/src/t8_forest/t8_forest_general.h +++ b/src/t8_forest/t8_forest_general.h @@ -365,10 +365,19 @@ t8_forest_set_ghost (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_typ * If 2, the iterative algorithm for unbalanced forests. * If 3, the top-down search algorithm for unbalanced forests. * \see t8_forest_set_ghost + * \note this function creats an ghost_interface obcejct and call \ref t8_forest_set_ghost_ext_new */ void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type, int ghost_version); +/** Set a ghost_interface + * In application schoud only used if the user creats its own ghost_interface class (type = userderdefined) + * \param [in] forest the fores + * \param [in] do_ghost --- + * \param [in] ghost_interface pointer to an object of the class ghost_interface or a derived class + * The forest takes ownership of the ghost_interface + * \note if the forest has alrady a ghost_interface, the old one will be unref and the new one will be set. +*/ void t8_forest_set_ghost_ext_new (t8_forest_t forest, int do_ghost, t8_forest_ghost_interface_c * ghost_interface); diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index ee87707625..9b8538fd29 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -177,7 +177,7 @@ t8_forest_ghost_init (t8_forest_ghost_t *pghost, t8_ghost_type_t ghost_type) t8_forest_ghost_t ghost; /* We currently only support face-neighbor ghosts */ - T8_ASSERT (ghost_type == T8_GHOST_FACES); + T8_ASSERT (ghost_type == T8_GHOST_FACES); // TODO muss angepasst werden /* Allocate memory for ghost */ ghost = *pghost = T8_ALLOC_ZERO (t8_forest_ghost_struct_t, 1); @@ -644,7 +644,7 @@ t8_forest_ghost_search_boundary (t8_forest_t forest, t8_locidx_t ltreeid, const * remote_ghosts array of ghost. * We also fill the remote_processes here. */ -static void +void t8_forest_ghost_fill_remote_v3 (t8_forest_t forest) { t8_forest_ghost_boundary_data_t data; @@ -688,7 +688,7 @@ t8_forest_ghost_fill_remote_v3 (t8_forest_t forest) * construct the remote processes by looking at the half neighbors of an element. * Otherwise, we use the owners_at_face method. */ -static void +void t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int ghost_method) { t8_element_t *elem, **half_neighbors = NULL; @@ -1392,23 +1392,23 @@ t8_forest_ghost_receive (t8_forest_t forest, t8_forest_ghost_t ghost) * for unbalanced_version = -1 */ void -t8_forest_ghost_create_ext (t8_forest_t forest, int unbalanced_version) +t8_forest_ghost_create_ext (t8_forest_t forest) { - t8_productionf("t8_forest_ghost_create_ext(forest, %i):\n", unbalanced_version); + t8_productionf("t8_forest_ghost_create_ext(forest):\n"); t8_forest_ghost_t ghost = NULL; t8_ghost_mpi_send_info_t *send_info; sc_MPI_Request *requests; - int create_tree_array = 0, create_gfirst_desc_array = 0; - int create_element_array = 0; + // int create_tree_array = 0, create_gfirst_desc_array = 0; + // int create_element_array = 0; // nicht mehr nötig da in ghost-interface ausgelagert t8_forest_ghost_interface_c * test_interface = NULL; T8_ASSERT (t8_forest_is_committed (forest)); - // T8_ASSERT (forest->ghost_interface != NULL); + T8_ASSERT (forest->ghost_interface != NULL); if(forest->ghost_interface != NULL){ test_interface = forest->ghost_interface; } else{ - t8_productionf("no ghost_interface ther\n"); + t8_productionf("no ghost_interface in t8_forest_ghost_create_ext\n"); // test_interface = t8_forest_ghost_interface_face_new( unbalanced_version<0 ? 3 : unbalanced_version+1); // nur vorlaufig um etwas zu testen, wird später wieder entfernt // forest->ghost_interface = test_interface; // T8_ASSERT(test_interface != NULL); @@ -1434,56 +1434,57 @@ t8_forest_ghost_create_ext (t8_forest_t forest, int unbalanced_version) t8_global_productionf ("Start ghost at %f %f\n", sc_MPI_Wtime (), forest->profile->ghost_runtime); } + /* step one */ if(test_interface != NULL){ t8_global_productionf ("Befor step1\n"); test_interface->t8_ghost_step_1_allocate(forest); } - if (forest->element_offsets == NULL) { - /* create element offset array if not done already */ - create_element_array = 1; - t8_forest_partition_create_offsets (forest); - } - if (forest->tree_offsets == NULL) { - /* Create tree offset array if not done already */ - create_tree_array = 1; - t8_forest_partition_create_tree_offsets (forest); - } - if (forest->global_first_desc == NULL) { - /* Create global first desc array if not done already */ - create_gfirst_desc_array = 1; - t8_forest_partition_create_first_desc (forest); - } + // if (forest->element_offsets == NULL) { + // /* create element offset array if not done already */ + // create_element_array = 1; + // t8_forest_partition_create_offsets (forest); + // } + // if (forest->tree_offsets == NULL) { + // /* Create tree offset array if not done already */ + // create_tree_array = 1; + // t8_forest_partition_create_tree_offsets (forest); + // } + // if (forest->global_first_desc == NULL) { + // /* Create global first desc array if not done already */ + // create_gfirst_desc_array = 1; + // t8_forest_partition_create_first_desc (forest); + // } if (t8_forest_get_local_num_elements (forest) > 0) { - if (forest->ghost_type == T8_GHOST_NONE) { + if (t8_forest_ghost_interface_get_type(test_interface) == T8_GHOST_NONE) { t8_debugf ("WARNING: Trying to construct ghosts with ghost_type NONE. " "Ghost layer is not constructed.\n"); return; } - /* Currently we only support face ghosts */ - T8_ASSERT (forest->ghost_type == T8_GHOST_FACES); /* Initialize the ghost structure */ - t8_forest_ghost_init (&forest->ghosts, forest->ghost_type); + t8_forest_ghost_init (&forest->ghosts, t8_forest_ghost_interface_get_type(test_interface)); ghost = forest->ghosts; + /* step two */ if(test_interface != NULL){ t8_global_productionf ("Befor step2\n"); // (forest->ghost_interface)->t8_ghost_step_2(forest); test_interface->t8_ghost_step_2(forest); } - if (unbalanced_version == -1) { - t8_global_productionf ("t8_forest_ghost_create_ext: t8_forest_ghost_fill_remote_v3(forest)\n"); - t8_forest_ghost_fill_remote_v3 (forest); - } - else { - /* Construct the remote elements and processes. */ - t8_global_productionf ("t8_forest_ghost_create_ext: t8_forest_ghost_fill_remote (forest, ghost, unbalanced_version != 0)\n"); - t8_forest_ghost_fill_remote (forest, ghost, unbalanced_version != 0); - } - + // if (unbalanced_version == -1) { + // t8_global_productionf ("t8_forest_ghost_create_ext: t8_forest_ghost_fill_remote_v3(forest)\n"); + // t8_forest_ghost_fill_remote_v3 (forest); + // } + // else { + // /* Construct the remote elements and processes. */ + // t8_global_productionf ("t8_forest_ghost_create_ext: t8_forest_ghost_fill_remote (forest, ghost, unbalanced_version != 0)\n"); + // t8_forest_ghost_fill_remote (forest, ghost, unbalanced_version != 0); + // } + + /* Step three */ /* Start sending the remote elements */ send_info = t8_forest_ghost_send_start (forest, ghost, &requests); @@ -1494,24 +1495,25 @@ t8_forest_ghost_create_ext (t8_forest_t forest, int unbalanced_version) t8_forest_ghost_send_end (forest, ghost, send_info, requests); } + /* step one clean up */ if(test_interface != NULL){ t8_global_productionf ("Befor step1 clean up\n"); // (forest->ghost_interface)->t8_ghost_step_1_clean_up(forest); test_interface->t8_ghost_step_1_clean_up(forest); } - if (create_element_array) { - /* Free the offset memory, if created */ - t8_shmem_array_destroy (&forest->element_offsets); - } - if (create_tree_array) { - /* Free the offset memory, if created */ - t8_shmem_array_destroy (&forest->tree_offsets); - } - if (create_gfirst_desc_array) { - /* Free the offset memory, if created */ - t8_shmem_array_destroy (&forest->global_first_desc); - } + // if (create_element_array) { + // /* Free the offset memory, if created */ + // t8_shmem_array_destroy (&forest->element_offsets); + // } + // if (create_tree_array) { + // /* Free the offset memory, if created */ + // t8_shmem_array_destroy (&forest->tree_offsets); + // } + // if (create_gfirst_desc_array) { + // /* Free the offset memory, if created */ + // t8_shmem_array_destroy (&forest->global_first_desc); + // } if (forest->profile != NULL) { /* If profiling is enabled, we measure the runtime of ghost_create */ @@ -1543,7 +1545,8 @@ t8_forest_ghost_create (t8_forest_t forest) T8_ASSERT (t8_forest_is_committed (forest)); if (forest->mpisize > 1) { /* call unbalanced version of ghost algorithm */ - t8_forest_ghost_create_ext (forest, 1); + T8_ASSERT(t8_forest_ghost_interface_face_verison(forest->ghost_interface) == 2); + t8_forest_ghost_create_ext (forest); } } @@ -1554,7 +1557,8 @@ t8_forest_ghost_create_balanced_only (t8_forest_t forest) if (forest->mpisize > 1) { /* TODO: assert that forest is balanced */ /* Call balanced version of ghost algorithm */ - t8_forest_ghost_create_ext (forest, 0); + T8_ASSERT(t8_forest_ghost_interface_face_verison(forest->ghost_interface) == 1); + t8_forest_ghost_create_ext (forest); } } @@ -1562,8 +1566,8 @@ void t8_forest_ghost_create_topdown (t8_forest_t forest) { T8_ASSERT (t8_forest_is_committed (forest)); - - t8_forest_ghost_create_ext (forest, -1); + T8_ASSERT(t8_forest_ghost_interface_face_verison(forest->ghost_interface) == 3); + t8_forest_ghost_create_ext (forest); } /** Return the array of remote ranks. diff --git a/src/t8_forest/t8_forest_ghost.h b/src/t8_forest/t8_forest_ghost.h index 427a73109e..9236f54312 100644 --- a/src/t8_forest/t8_forest_ghost.h +++ b/src/t8_forest/t8_forest_ghost.h @@ -162,12 +162,40 @@ t8_forest_ghost_unref (t8_forest_ghost_t *pghost); void t8_forest_ghost_destroy (t8_forest_ghost_t *pghost); +/** Part of step 2 of the ghost_creat_ext + * for ghost_type face + * Is declared, so that ghost_interface_face can use ist + * \see t8_forest_ghost_interface_faces::t8_ghost_step_2 + * \param [in,out] forest The forest. + */ +void +t8_forest_ghost_fill_remote_v3 (t8_forest_t forest); + +/** Part of step 2 of the ghost_creat_ext + * for ghost_type face + * Is declared, so that ghost_interface_face can use ist + * \see t8_forest_ghost_interface_faces::t8_ghost_step_2 + * \param [in,out] forest The forest. + */ +void +t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int ghost_method); + + /** Create one layer of ghost elements for a forest. * \see t8_forest_set_ghost * \param [in,out] forest The forest. * \a forest must be committed before calling this function. */ void +t8_forest_ghost_create_ext (t8_forest_t forest); + +/** Create one layer of ghost elements for a forest. + * \see t8_forest_set_ghost + * \param [in,out] forest The forest. + * \a forest must be committed before calling this function. + * \a forest->ghost_interface must have the \a type FACE and the \a version 2 + */ +void t8_forest_ghost_create (t8_forest_t forest); /** Create one layer of ghost elements for a forest. @@ -176,12 +204,18 @@ t8_forest_ghost_create (t8_forest_t forest); * Mesh Refinement On Forests of Octrees * \param [in,out] forest The balanced forest/ * \a forest must be committed before calling this function. + * \a forest->ghost_interface must have the \a type FACE and the \a version 1 * \note The user should prefer \ref t8_forest_ghost_create even for balanced forests. */ void t8_forest_ghost_create_balanced_only (t8_forest_t forest); -/* experimental version using the ghost_v3 algorithm */ +/** Creating one layer of ghost elements for a forest. + * experimental version using the ghost_v3 algorithm + * \param [in,out] forest The forest. + * \a forest must be committed before calling this function. + * \a forest->ghost_interface must have the \a type FACE and the \a version 1 + */ void t8_forest_ghost_create_topdown (t8_forest_t forest); diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx index d4a8e9a149..ed322c92a5 100644 --- a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx +++ b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx @@ -23,7 +23,8 @@ #include #include #include - +#include +#include t8_forest_ghost_interface_faces::t8_forest_ghost_interface_faces() : t8_forest_ghost_interface(T8_GHOST_FACES), ghost_version(3), flag_step_1(0) @@ -46,21 +47,21 @@ void t8_forest_ghost_interface_faces::t8_ghost_step_1_allocate(t8_forest_t forest) { t8_global_productionf (" t8_forest_ghost_interface_faces::t8_ghost_step_1_allocate \n"); - // if (forest->element_offsets == NULL) { - // /* create element offset array if not done already */ - // flag_step_1 = flag_step_1 | CREATE_ELEMENT_ARRAY; - // t8_forest_partition_create_offsets (forest); - // } - // if (forest->tree_offsets == NULL) { - // /* Create tree offset array if not done already */ - // flag_step_1 = flag_step_1 | CREATE_TREE_ARRAY; - // t8_forest_partition_create_tree_offsets (forest); - // } - // if (forest->global_first_desc == NULL) { - // /* Create global first desc array if not done already */ - // flag_step_1 = flag_step_1 | CREATE_GFIRST_DESC_ARRAY; - // t8_forest_partition_create_first_desc (forest); - // } + if (forest->element_offsets == NULL) { + /* create element offset array if not done already */ + flag_step_1 = flag_step_1 | CREATE_ELEMENT_ARRAY; + t8_forest_partition_create_offsets (forest); + } + if (forest->tree_offsets == NULL) { + /* Create tree offset array if not done already */ + flag_step_1 = flag_step_1 | CREATE_TREE_ARRAY; + t8_forest_partition_create_tree_offsets (forest); + } + if (forest->global_first_desc == NULL) { + /* Create global first desc array if not done already */ + flag_step_1 = flag_step_1 | CREATE_GFIRST_DESC_ARRAY; + t8_forest_partition_create_first_desc (forest); + } } @@ -68,18 +69,18 @@ void t8_forest_ghost_interface_faces::t8_ghost_step_1_clean_up(t8_forest_t forest) { t8_global_productionf (" t8_forest_ghost_interface_faces::t8_ghost_step_1_clean_up \n"); - // if (flag_step_1 & CREATE_GFIRST_DESC_ARRAY){ - // /* Free the offset memory, if created */ - // t8_shmem_array_destroy (&forest->element_offsets); - // } - // if (flag_step_1 & CREATE_TREE_ARRAY) { - // /* Free the offset memory, if created */ - // t8_shmem_array_destroy (&forest->tree_offsets); - // } - // if (flag_step_1 & CREATE_GFIRST_DESC_ARRAY) { - // /* Free the offset memory, if created */ - // t8_shmem_array_destroy (&forest->global_first_desc); - // } + if (flag_step_1 & CREATE_GFIRST_DESC_ARRAY){ + /* Free the offset memory, if created */ + t8_shmem_array_destroy (&forest->element_offsets); + } + if (flag_step_1 & CREATE_TREE_ARRAY) { + /* Free the offset memory, if created */ + t8_shmem_array_destroy (&forest->tree_offsets); + } + if (flag_step_1 & CREATE_GFIRST_DESC_ARRAY) { + /* Free the offset memory, if created */ + t8_shmem_array_destroy (&forest->global_first_desc); + } } @@ -93,15 +94,17 @@ void t8_forest_ghost_interface_faces::t8_ghost_step_2(t8_forest_t forest) { t8_global_productionf (" t8_forest_ghost_interface_faces::t8_ghost_step_2 \n"); - // T8_ASSERT( forest->ghosts != NULL); - // t8_forest_ghost_t ghost = forest->ghosts; - // if (ghost_version == -1) { - // t8_forest_ghost_fill_remote_v3 (forest); - // } - // else { - // /* Construct the remote elements and processes. */ - // t8_forest_ghost_fill_remote (forest, ghost, ghost_version != 0); - // } + T8_ASSERT( forest->ghosts != NULL); + t8_forest_ghost_t ghost = forest->ghosts; + if (ghost_version == 3) { + t8_global_productionf ("t8_forest_ghost_create_ext: t8_forest_ghost_fill_remote_v3(forest)\n"); + t8_forest_ghost_fill_remote_v3 (forest); + } + else { + /* Construct the remote elements and processes. */ + t8_global_productionf ("t8_forest_ghost_create_ext: t8_forest_ghost_fill_remote (forest, ghost, ghost_version != 1)\n"); + t8_forest_ghost_fill_remote (forest, ghost, ghost_version != 1); + } } diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index 0d9659c0c1..45b5099bff 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -1273,6 +1273,10 @@ t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, const int T8_ASSERT (t8_forest_is_committed (forest)); T8_ASSERT (fileprefix != NULL); if (forest->ghosts == NULL || forest->ghosts->num_ghosts_elements == 0) { + t8_productionf ("t8_forest_vtk_write_file: write_ghosts = %i\n", write_ghosts); + if(forest->ghosts != NULL){ + t8_productionf ("t8_forest_vtk_write_file: num_ghosts_elements = %i\n", forest->ghosts->num_ghosts_elements); + } /* Never write ghost elements if there aren't any */ write_ghosts = 0; } From 3786648e62c426dd1fb5ff1e8b03a7f5ff40b467 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Thu, 4 Jul 2024 12:51:24 +0200 Subject: [PATCH 05/26] edit balance for ghost_interface --- src/t8_forest/t8_forest_balance.cxx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/t8_forest/t8_forest_balance.cxx b/src/t8_forest/t8_forest_balance.cxx index 21f15564aa..3d156c6835 100644 --- a/src/t8_forest/t8_forest_balance.cxx +++ b/src/t8_forest/t8_forest_balance.cxx @@ -138,6 +138,7 @@ t8_forest_balance (t8_forest_t forest, int repartition) int count_partition_stats = 0; double ada_time, ghost_time, part_time; sc_statinfo_t *adap_stats, *ghost_stats, *partition_stats; + int create_ghost_interface = 0; t8_global_productionf ("Into t8_forest_balance with %lli global elements.\n", (long long) t8_forest_get_global_num_elements (forest->set_from)); @@ -171,10 +172,16 @@ t8_forest_balance (t8_forest_t forest, int repartition) t8_forest_ref (forest_from); if (forest->set_from->ghosts == NULL) { - forest->set_from->ghost_type = T8_GHOST_FACES; - // forest->set_from->ghost_algorithm = 3; - // forest->set_from->ghost_interface = t8_forest_ghost_interface_face_new(3); + // forest->set_from->ghost_type = T8_GHOST_FACES; + if(forest->set_from->ghost_interface != NULL){ + t8_productionf("set_from has alrady a ghost_interface\n"); + }else{ + t8_productionf("set_from did not have a ghost_interface jed, create one and delete it afterward\n"); + forest->set_from->ghost_interface = t8_forest_ghost_interface_face_new(3); + create_ghost_interface = 1; + } t8_forest_ghost_create_topdown (forest->set_from); + if(create_ghost_interface){ t8_forest_ghost_interface_unref( &(forest->set_from->ghost_interface)); } } while (!done_global) { From cfa63f10723cf4ed2c0f27b6378465d4605e1daf Mon Sep 17 00:00:00 2001 From: antjeHP Date: Thu, 4 Jul 2024 13:27:58 +0200 Subject: [PATCH 06/26] updated ghost_creat_ext to ghost_interface --- src/t8_forest/t8_forest_ghost.cxx | 38 ++++++++----------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index 9b8538fd29..79c6f21925 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -1400,19 +1400,12 @@ t8_forest_ghost_create_ext (t8_forest_t forest) sc_MPI_Request *requests; // int create_tree_array = 0, create_gfirst_desc_array = 0; // int create_element_array = 0; // nicht mehr nötig da in ghost-interface ausgelagert - t8_forest_ghost_interface_c * test_interface = NULL; + t8_forest_ghost_interface_c * ghost_interface; T8_ASSERT (t8_forest_is_committed (forest)); T8_ASSERT (forest->ghost_interface != NULL); - if(forest->ghost_interface != NULL){ - test_interface = forest->ghost_interface; - } else{ - t8_productionf("no ghost_interface in t8_forest_ghost_create_ext\n"); - // test_interface = t8_forest_ghost_interface_face_new( unbalanced_version<0 ? 3 : unbalanced_version+1); // nur vorlaufig um etwas zu testen, wird später wieder entfernt - // forest->ghost_interface = test_interface; - // T8_ASSERT(test_interface != NULL); - } + ghost_interface = forest->ghost_interface; t8_global_productionf ("Into t8_forest_ghost with %i local elements.\n", t8_forest_get_local_num_elements (forest)); @@ -1435,12 +1428,9 @@ t8_forest_ghost_create_ext (t8_forest_t forest) } /* step one */ - if(test_interface != NULL){ - t8_global_productionf ("Befor step1\n"); - test_interface->t8_ghost_step_1_allocate(forest); - } + t8_global_productionf ("Befor step1\n"); + ghost_interface->t8_ghost_step_1_allocate(forest); - // if (forest->element_offsets == NULL) { // /* create element offset array if not done already */ // create_element_array = 1; // t8_forest_partition_create_offsets (forest); @@ -1457,24 +1447,20 @@ t8_forest_ghost_create_ext (t8_forest_t forest) // } if (t8_forest_get_local_num_elements (forest) > 0) { - if (t8_forest_ghost_interface_get_type(test_interface) == T8_GHOST_NONE) { + if (t8_forest_ghost_interface_get_type(ghost_interface) == T8_GHOST_NONE) { t8_debugf ("WARNING: Trying to construct ghosts with ghost_type NONE. " "Ghost layer is not constructed.\n"); return; } /* Initialize the ghost structure */ - t8_forest_ghost_init (&forest->ghosts, t8_forest_ghost_interface_get_type(test_interface)); + t8_forest_ghost_init (&forest->ghosts, t8_forest_ghost_interface_get_type(ghost_interface)); ghost = forest->ghosts; /* step two */ - if(test_interface != NULL){ - t8_global_productionf ("Befor step2\n"); - // (forest->ghost_interface)->t8_ghost_step_2(forest); - test_interface->t8_ghost_step_2(forest); - } + t8_global_productionf ("Befor step2\n"); + ghost_interface->t8_ghost_step_2(forest); - // if (unbalanced_version == -1) { // t8_global_productionf ("t8_forest_ghost_create_ext: t8_forest_ghost_fill_remote_v3(forest)\n"); // t8_forest_ghost_fill_remote_v3 (forest); // } @@ -1496,13 +1482,9 @@ t8_forest_ghost_create_ext (t8_forest_t forest) } /* step one clean up */ - if(test_interface != NULL){ - t8_global_productionf ("Befor step1 clean up\n"); - // (forest->ghost_interface)->t8_ghost_step_1_clean_up(forest); - test_interface->t8_ghost_step_1_clean_up(forest); - } + t8_global_productionf ("Befor step1 clean up\n"); + ghost_interface->t8_ghost_step_1_clean_up(forest); - // if (create_element_array) { // /* Free the offset memory, if created */ // t8_shmem_array_destroy (&forest->element_offsets); // } From 65fc4e49ceb3014d1f3fb91d10a2edf9ca8d7381 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Thu, 4 Jul 2024 13:29:25 +0200 Subject: [PATCH 07/26] delete unnecesssary prints --- src/t8_forest/t8_forest.c | 2 -- src/t8_forest/t8_forest_vtk.cxx | 4 ---- 2 files changed, 6 deletions(-) diff --git a/src/t8_forest/t8_forest.c b/src/t8_forest/t8_forest.c index a704ec2ab9..515219e81c 100644 --- a/src/t8_forest/t8_forest.c +++ b/src/t8_forest/t8_forest.c @@ -1400,12 +1400,10 @@ t8_forest_write_vtk_ext (t8_forest_t forest, const char *fileprefix, const int w do_not_use_API = 1; #endif if (!do_not_use_API) { - t8_productionf (" t8_forest_write_vtk_ext: t8_forest_vtk_write_file_via_API.\n"); return t8_forest_vtk_write_file_via_API (forest, fileprefix, write_treeid, write_mpirank, write_level, write_element_id, write_ghosts, write_curved, num_data, data); } else { - t8_productionf (" t8_forest_write_vtk_ext: t8_forest_vtk_write_file.\n"); 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); diff --git a/src/t8_forest/t8_forest_vtk.cxx b/src/t8_forest/t8_forest_vtk.cxx index 45b5099bff..0d9659c0c1 100644 --- a/src/t8_forest/t8_forest_vtk.cxx +++ b/src/t8_forest/t8_forest_vtk.cxx @@ -1273,10 +1273,6 @@ t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, const int T8_ASSERT (t8_forest_is_committed (forest)); T8_ASSERT (fileprefix != NULL); if (forest->ghosts == NULL || forest->ghosts->num_ghosts_elements == 0) { - t8_productionf ("t8_forest_vtk_write_file: write_ghosts = %i\n", write_ghosts); - if(forest->ghosts != NULL){ - t8_productionf ("t8_forest_vtk_write_file: num_ghosts_elements = %i\n", forest->ghosts->num_ghosts_elements); - } /* Never write ghost elements if there aren't any */ write_ghosts = 0; } From c61a5a44e428fff96195c273d5d5316c416b76a1 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Thu, 4 Jul 2024 13:31:02 +0200 Subject: [PATCH 08/26] commed out the members ghost_type and ghost_algorithm in forest --- src/t8_forest/t8_forest_types.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/t8_forest/t8_forest_types.h b/src/t8_forest/t8_forest_types.h index a7fb487f9f..d601b0cc9b 100644 --- a/src/t8_forest/t8_forest_types.h +++ b/src/t8_forest/t8_forest_types.h @@ -100,9 +100,9 @@ typedef struct t8_forest If 0, no balance. If 1 balance with repartitioning, if 2 balance without repartitioning, \see t8_forest_balance */ int do_ghost; /**< If True, a ghost layer will be created when the forest is committed. */ - t8_ghost_type_t ghost_type; /**< If a ghost layer will be created, the type of neighbors that count as ghost. */ - int ghost_algorithm; /**< Controls the algorithm used for ghost. 1 = balanced only. 2 = also unbalanced - 3 = top-down search and unbalanced. */ + // t8_ghost_type_t ghost_type; /**< If a ghost layer will be created, the type of neighbors that count as ghost. */ + // int ghost_algorithm; /**< Controls the algorithm used for ghost. 1 = balanced only. 2 = also unbalanced + // 3 = top-down search and unbalanced. */ t8_forest_ghost_interface_c * ghost_interface; void *user_data; /**< Pointer for arbitrary user data. \see t8_forest_set_user_data. */ void (*user_function) (); /**< Pointer for arbitrary user function. \see t8_forest_set_user_function. */ From 4bca580f48fb7b863c3703a8763db4c3973fa3b0 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 5 Aug 2024 15:04:03 +0200 Subject: [PATCH 09/26] fix ghost interface bug in blanace --- src/t8_forest/t8_forest_balance.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/t8_forest/t8_forest_balance.cxx b/src/t8_forest/t8_forest_balance.cxx index 3d156c6835..956cc44802 100644 --- a/src/t8_forest/t8_forest_balance.cxx +++ b/src/t8_forest/t8_forest_balance.cxx @@ -173,15 +173,15 @@ t8_forest_balance (t8_forest_t forest, int repartition) if (forest->set_from->ghosts == NULL) { // forest->set_from->ghost_type = T8_GHOST_FACES; - if(forest->set_from->ghost_interface != NULL){ - t8_productionf("set_from has alrady a ghost_interface\n"); - }else{ - t8_productionf("set_from did not have a ghost_interface jed, create one and delete it afterward\n"); + if(forest->set_from->ghost_interface == NULL){ forest->set_from->ghost_interface = t8_forest_ghost_interface_face_new(3); create_ghost_interface = 1; } t8_forest_ghost_create_topdown (forest->set_from); - if(create_ghost_interface){ t8_forest_ghost_interface_unref( &(forest->set_from->ghost_interface)); } + if(create_ghost_interface){ + t8_forest_ghost_interface_unref( &(forest->set_from->ghost_interface)); + forest->set_from->ghost_interface = NULL; + } } while (!done_global) { From bf5add27515486eae00ffeff47130624da20a7d1 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 5 Aug 2024 15:10:30 +0200 Subject: [PATCH 10/26] header for ghost interface --- .../t8_forest_ghost_interface.h | 0 .../t8_forest_ghost_interface.hxx | 59 ++++---- .../t8_forest_ghost_interface.cxx | 53 -------- .../t8_forest_ghost_interface_faces.cxx | 127 ------------------ .../t8_forest_ghost_interface_faces.h | 0 .../t8_forest_ghost_interface_faces.hxx | 79 ----------- .../t8_forest_ghost_interface_faces.hxx | 73 ++++++++++ .../t8_forest_ghost_interface_wrapper.h | 6 +- src/t8_forest/t8_forest_ghost_search.hxx | 89 ++++++++++++ 9 files changed, 195 insertions(+), 291 deletions(-) rename src/t8_forest/{t8_forest_ghost_interface => }/t8_forest_ghost_interface.h (100%) rename src/t8_forest/{t8_forest_ghost_interface => }/t8_forest_ghost_interface.hxx (65%) delete mode 100644 src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.cxx delete mode 100644 src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx delete mode 100644 src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.h delete mode 100644 src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx create mode 100644 src/t8_forest/t8_forest_ghost_interface_faces.hxx rename src/t8_forest/{t8_forest_ghost_interface => }/t8_forest_ghost_interface_wrapper.h (90%) create mode 100644 src/t8_forest/t8_forest_ghost_search.hxx diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.h b/src/t8_forest/t8_forest_ghost_interface.h similarity index 100% rename from src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.h rename to src/t8_forest/t8_forest_ghost_interface.h diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.hxx b/src/t8_forest/t8_forest_ghost_interface.hxx similarity index 65% rename from src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.hxx rename to src/t8_forest/t8_forest_ghost_interface.hxx index 1051676e39..8490476aa0 100644 --- a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.hxx +++ b/src/t8_forest/t8_forest_ghost_interface.hxx @@ -26,18 +26,28 @@ #include #include #include -#include -#include +#include +#include T8_EXTERN_C_BEGIN (); +/** + * Flags for first step function + * store in the flags which memory was allocated +*/ +enum t8_ghost_interface_face_flag { + CREATE_ELEMENT_ARRAY = 1, + CREATE_TREE_ARRAY = 2, + CREATE_GFIRST_DESC_ARRAY= 4 +}; + struct t8_forest_ghost_interface { public: /** * Constructor */ - t8_forest_ghost_interface() : ghost_type(T8_GHOST_NONE) + t8_forest_ghost_interface() { t8_refcount_init (&rc); t8_debugf ("Constructed the a None ghost_interface.\n"); @@ -53,7 +63,6 @@ struct t8_forest_ghost_interface t8_refcount_unref (&rc); } t8_debugf ("Deleted the ghost_interface.\n"); - t8_productionf ("Deleted the ghost_interface.\n"); } /** @@ -84,58 +93,46 @@ struct t8_forest_ghost_interface { if (t8_refcount_unref (&rc)) { t8_debugf ("Deleting the ghost_interface.\n"); - t8_productionf ("Deleting the ghost_interface.\n"); delete this; } } - - /** - * The algorithm to create the ghost layer is structured in three steps - * First is every prozess tells every other one, witch elements belong to him - * Second every prozess identifies all his neighbor elements an to witch prozess they blong - * Third every prozesse send the date of his owne elements to the neighbots, - * which he knows have this element as a neighbor - */ - /** - * Virtual function for the first step. - * \param [in] forest the forest an witch the ghost should work - */ + /** Create one layer of ghost elements for a forest. + * \see t8_forest_set_ghost + * \param [in,out] forest The forest. + * \a forest must be committed before calling this function. + */ virtual void - t8_ghost_step_1_allocate(t8_forest_t forest) + do_ghost(t8_forest_t forest) = 0; /** - * Clean up memory, which was allocatet in the first step, but first can releas after step two - * \param [in] forest the forest an witch the ghost should work + * Compute and collect ownerships to create the nessesary offset + * for elements, trees and first descandance */ virtual void - t8_ghost_step_1_clean_up(t8_forest_t forest) - = 0; + communicate_ownerships(t8_forest_t forest); - /** - * Virtual function for the second step. - * \param [in] forest the forest an witch the ghost should work - */ virtual void - t8_ghost_step_2(t8_forest_t forest) - = 0; + communicate_ghost_elements(t8_forest_t forest); + virtual void + clean_up(t8_forest_t forest); protected: /** * Constructor for the derivided classes to set the korrekt type for them. * \param [in] g_type The type (faces, edges, userdefind, ...) of the ghost_interface */ - t8_forest_ghost_interface(t8_ghost_type_t g_type) : ghost_type(g_type) { + explicit t8_forest_ghost_interface(t8_ghost_type_t g_type) : ghost_type(g_type) { t8_refcount_init (&rc); t8_debugf ("Constructed a ghost_interface.\n"); - t8_productionf("Constructed a ghost_interface.\n"); }; /** type of the ghost_interface */ - t8_ghost_type_t ghost_type; + t8_ghost_type_t ghost_type{T8_GHOST_NONE}; /** The reference count of the ghost_interface. TODO: Replace by shared_ptr when forest becomes a class. */ t8_refcount_t rc; + int32_t memory_flag{}; }; diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.cxx b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.cxx deleted file mode 100644 index bf85142099..0000000000 --- a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.cxx +++ /dev/null @@ -1,53 +0,0 @@ -/* - This file is part of t8code. - t8code is a C library to manage a collection (a forest) of multiple - connected adaptive space-trees of general element classes in parallel. - - Copyright (C) 2015 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include - -T8_EXTERN_C_BEGIN (); - -t8_ghost_type_t -t8_forest_ghost_interface_get_type(t8_forest_ghost_interface_c * ghost_interface){ - T8_ASSERT (ghost_interface != NULL); - ghost_interface->t8_ghost_get_type(); -} - -void t8_forest_ghost_interface_ref(t8_forest_ghost_interface_c * ghost_interface){ - T8_ASSERT (ghost_interface != NULL); - ghost_interface->ref(); -} - -void t8_forest_ghost_interface_unref(t8_forest_ghost_interface_c ** pghost_interface){ - t8_forest_ghost_interface_c * ghost_interface; - - T8_ASSERT (pghost_interface != NULL); - ghost_interface = *pghost_interface; - T8_ASSERT (ghost_interface != NULL); - - ghost_interface->unref(); -} - - - -T8_EXTERN_C_END (); - diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx deleted file mode 100644 index ed322c92a5..0000000000 --- a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx +++ /dev/null @@ -1,127 +0,0 @@ -/* - This file is part of t8code. - t8code is a C library to manage a collection (a forest) of multiple - connected adaptive space-trees of general element classes in parallel. - - Copyright (C) 2015 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include - -t8_forest_ghost_interface_faces::t8_forest_ghost_interface_faces() - : t8_forest_ghost_interface(T8_GHOST_FACES), ghost_version(3), flag_step_1(0) -{ - // forest->ghost_type = ghost_type; - // forest->ghost_algorithm = ghost_version; -} - -t8_forest_ghost_interface_faces::t8_forest_ghost_interface_faces(int version) - : t8_forest_ghost_interface(T8_GHOST_FACES), ghost_version(version), flag_step_1(0) -{ - T8_ASSERT( 1 <= version && version <= 3 ); - SC_CHECK_ABORT (1 <= ghost_version && ghost_version <= 3, "Invalid choice for ghost version. Choose 1, 2, or 3.\n"); - // forest->ghost_type = ghost_type; - // forest->ghost_algorithm = ghost_version; -} - - -void -t8_forest_ghost_interface_faces::t8_ghost_step_1_allocate(t8_forest_t forest) -{ - t8_global_productionf (" t8_forest_ghost_interface_faces::t8_ghost_step_1_allocate \n"); - if (forest->element_offsets == NULL) { - /* create element offset array if not done already */ - flag_step_1 = flag_step_1 | CREATE_ELEMENT_ARRAY; - t8_forest_partition_create_offsets (forest); - } - if (forest->tree_offsets == NULL) { - /* Create tree offset array if not done already */ - flag_step_1 = flag_step_1 | CREATE_TREE_ARRAY; - t8_forest_partition_create_tree_offsets (forest); - } - if (forest->global_first_desc == NULL) { - /* Create global first desc array if not done already */ - flag_step_1 = flag_step_1 | CREATE_GFIRST_DESC_ARRAY; - t8_forest_partition_create_first_desc (forest); - } -} - - -void -t8_forest_ghost_interface_faces::t8_ghost_step_1_clean_up(t8_forest_t forest) -{ - t8_global_productionf (" t8_forest_ghost_interface_faces::t8_ghost_step_1_clean_up \n"); - if (flag_step_1 & CREATE_GFIRST_DESC_ARRAY){ - /* Free the offset memory, if created */ - t8_shmem_array_destroy (&forest->element_offsets); - } - if (flag_step_1 & CREATE_TREE_ARRAY) { - /* Free the offset memory, if created */ - t8_shmem_array_destroy (&forest->tree_offsets); - } - if (flag_step_1 & CREATE_GFIRST_DESC_ARRAY) { - /* Free the offset memory, if created */ - t8_shmem_array_destroy (&forest->global_first_desc); - } -} - - -/** - * algorithmus 1 : t8_forest_ghost_create_balanced_only --> t8_forest_ghost_create_ext (forest, 0); - * algorithmus 2 : t8_forest_ghost_create --> t8_forest_ghost_create_ext (forest, 1); - * algorithmus 3 : t8_forest_ghost_create_topdown --> t8_forest_ghost_create_ext (forest, -1); - * --> alg = unbalanced_version < 0 ? 3 : unbalanced_version + 1 -*/ -void -t8_forest_ghost_interface_faces::t8_ghost_step_2(t8_forest_t forest) -{ - t8_global_productionf (" t8_forest_ghost_interface_faces::t8_ghost_step_2 \n"); - T8_ASSERT( forest->ghosts != NULL); - t8_forest_ghost_t ghost = forest->ghosts; - if (ghost_version == 3) { - t8_global_productionf ("t8_forest_ghost_create_ext: t8_forest_ghost_fill_remote_v3(forest)\n"); - t8_forest_ghost_fill_remote_v3 (forest); - } - else { - /* Construct the remote elements and processes. */ - t8_global_productionf ("t8_forest_ghost_create_ext: t8_forest_ghost_fill_remote (forest, ghost, ghost_version != 1)\n"); - t8_forest_ghost_fill_remote (forest, ghost, ghost_version != 1); - } -} - - - - -t8_forest_ghost_interface_c * -t8_forest_ghost_interface_face_new(int version){ - t8_debugf ("Call t8_forest_ghost_interface_face_new.\n"); - T8_ASSERT( 1 <= version && version <= 3 ); - t8_forest_ghost_interface_faces * ghost_interface = new t8_forest_ghost_interface_faces(version); - return (t8_forest_ghost_interface_c *) ghost_interface; -} - -int -t8_forest_ghost_interface_face_verison(t8_forest_ghost_interface_c * ghost_interface){ - T8_ASSERT(ghost_interface != NULL); - T8_ASSERT(ghost_interface->t8_ghost_get_type() == T8_GHOST_FACES); - t8_forest_ghost_interface_faces * carsted_ghost_interface = (t8_forest_ghost_interface_faces *) ghost_interface; - return carsted_ghost_interface->t8_ghost_get_version(); -} \ No newline at end of file diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.h b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx b/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx deleted file mode 100644 index e279f5b077..0000000000 --- a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.hxx +++ /dev/null @@ -1,79 +0,0 @@ -/* - This file is part of t8code. - t8code is a C library to manage a collection (a forest) of multiple - connected adaptive space-trees of general element classes in parallel. - - Copyright (C) 2015 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - - -#ifndef T8_GHOST_INTERFACE_FACE_H -#define T8_GHOST_INTERFACE_FACE_H - -#include - -/** - * Flags for first step function - * store in the flags which memory was allocated -*/ -enum t8_ghost_interface_face_flag { - CREATE_ELEMENT_ARRAY = 1, - CREATE_TREE_ARRAY = 2, - CREATE_GFIRST_DESC_ARRAY= 4 -}; - -struct t8_forest_ghost_interface_faces : public t8_forest_ghost_interface -{ - public: - /** - * Constru - */ - t8_forest_ghost_interface_faces(); - - t8_forest_ghost_interface_faces(int version); - - ~t8_forest_ghost_interface_faces () - { - } - - inline int - t8_ghost_get_version() const - { - return ghost_version; - } - - - void - t8_ghost_step_1_allocate(t8_forest_t forest) override; - - void - t8_ghost_step_1_clean_up(t8_forest_t forest) override; - - - void - t8_ghost_step_2(t8_forest_t forest) override; - - protected: - - int ghost_version; - int32_t flag_step_1; - -}; - - -#endif /* !T8_GHOST_INTERFACE_FACE_H */ diff --git a/src/t8_forest/t8_forest_ghost_interface_faces.hxx b/src/t8_forest/t8_forest_ghost_interface_faces.hxx new file mode 100644 index 0000000000..b8b6d80390 --- /dev/null +++ b/src/t8_forest/t8_forest_ghost_interface_faces.hxx @@ -0,0 +1,73 @@ +// /* +// This file is part of t8code. +// t8code is a C library to manage a collection (a forest) of multiple +// connected adaptive space-trees of general element classes in parallel. + +// Copyright (C) 2015 the developers + +// t8code is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. + +// t8code is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with t8code; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// */ + + + +// #ifndef T8_GHOST_INTERFACE_FACE_H +// #define T8_GHOST_INTERFACE_FACE_H + +// #include +// #include + +// /** +// * Flags for first step function +// * store in the flags which memory was allocated +// */ +// enum t8_ghost_interface_face_flag { +// CREATE_ELEMENT_ARRAY = 1, +// CREATE_TREE_ARRAY = 2, +// CREATE_GFIRST_DESC_ARRAY= 4 +// }; + +// struct t8_forest_ghost_interface_faces : public t8_forest_ghost_interface +// { +// public: +// /** +// * Construtor +// */ +// t8_forest_ghost_interface_faces(); + +// t8_forest_ghost_interface_faces(int version); + +// ~t8_forest_ghost_interface_faces () +// { +// } + +// inline int +// t8_ghost_get_version() const +// { +// return ghost_version; +// } + +// virtual void +// do_ghost(t8_forest forest) override; + + +// protected: + +// int ghost_version; +// int32_t flag_step_1; + +// }; + + +// #endif /* !T8_GHOST_INTERFACE_FACE_H */ diff --git a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_wrapper.h b/src/t8_forest/t8_forest_ghost_interface_wrapper.h similarity index 90% rename from src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_wrapper.h rename to src/t8_forest/t8_forest_ghost_interface_wrapper.h index 419bc826e5..e3b0f14749 100644 --- a/src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_wrapper.h +++ b/src/t8_forest/t8_forest_ghost_interface_wrapper.h @@ -25,7 +25,7 @@ #include #include -#include +#include T8_EXTERN_C_BEGIN (); @@ -37,6 +37,8 @@ T8_EXTERN_C_BEGIN (); */ t8_forest_ghost_interface_c * t8_forest_ghost_interface_face_new(int version); +t8_forest_ghost_interface_c * t8_forest_ghost_interface_stencil_new(); + /** * Satisfy the C interface of forest * Return for a ghost_interface of Type FACE the ghost_algorithm / ghost_version @@ -52,12 +54,14 @@ t8_ghost_type_t t8_forest_ghost_interface_get_type(t8_forest_ghost_interface_c * /** * Satisfy the C interface of forest * Do a ref on the ghost_interface + * Needed in t8_forest_commit */ void t8_forest_ghost_interface_ref(t8_forest_ghost_interface_c * ghost_interface); /** * Satisfy the C interface of forest * Do a unref on the ghost_interface + * Needed in t8_forest_commit and t8_forest_set_ghost_ext_new */ void t8_forest_ghost_interface_unref(t8_forest_ghost_interface_c ** pghost_interface); diff --git a/src/t8_forest/t8_forest_ghost_search.hxx b/src/t8_forest/t8_forest_ghost_search.hxx new file mode 100644 index 0000000000..bbaeb97a6d --- /dev/null +++ b/src/t8_forest/t8_forest_ghost_search.hxx @@ -0,0 +1,89 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + + + +#ifndef T8_GHOST_INTERFACE_FACE_H +#define T8_GHOST_INTERFACE_FACE_H + +#include +#include +#include // Definition of t8_forest_search_query_fn + + +struct t8_forest_ghost_w_search : public t8_forest_ghost_interface +{ + public: + /** + * Construtor + */ + t8_forest_ghost_w_search(); + + explicit t8_forest_ghost_w_search(t8_forest_search_query_fn serach_function) + : t8_forest_ghost_interface(T8_GHOST_USERDEFINED), search_fn(serach_function) + { + T8_ASSERT(serach_function != nullptr); + } + + explicit t8_forest_ghost_w_search(t8_ghost_type_t ghost_type); + + virtual ~t8_forest_ghost_w_search () + { + } + + virtual void + do_ghost(t8_forest_t forest) override; + + /** + * Übernommen aus t8_forest_ghost_fill_remote_v3 + * daher keine unterstüzung mehr von version 1 und 2 + * Nur der search_fn parameter, ist nicht fest sonder etwpricht der member variabel + */ + virtual void + step_2(t8_forest_t forest); + + + protected: + t8_forest_ghost_w_search(t8_ghost_type_t ghost_type, t8_forest_search_query_fn search_function) + : t8_forest_ghost_interface(ghost_type), search_fn(search_function) + { + } + + t8_forest_search_query_fn search_fn{}; + +}; + +struct t8_forest_ghost_face : public t8_forest_ghost_w_search +{ + public: + explicit t8_forest_ghost_face(int version); + + void step_2(t8_forest_t forest) override; + + inline int get_version() const {return version;} + + private: + int version{}; +}; + + +#endif /* !T8_GHOST_INTERFACE_FACE_H */ From d548aec6895d0d25a67eb2444d3034797b20a798 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 5 Aug 2024 15:14:50 +0200 Subject: [PATCH 11/26] change includes for ghost interface --- src/t8_forest/t8_forest.c | 2 +- src/t8_forest/t8_forest_balance.cxx | 3 ++- src/t8_forest/t8_forest_cxx.cxx | 4 ++-- src/t8_forest/t8_forest_general.h | 2 +- src/t8_forest/t8_forest_ghost.cxx | 6 +++--- src/t8_forest/t8_forest_types.h | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/t8_forest/t8_forest.c b/src/t8_forest/t8_forest.c index 515219e81c..11e917372d 100644 --- a/src/t8_forest/t8_forest.c +++ b/src/t8_forest/t8_forest.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/t8_forest/t8_forest_balance.cxx b/src/t8_forest/t8_forest_balance.cxx index 956cc44802..3ace01e18b 100644 --- a/src/t8_forest/t8_forest_balance.cxx +++ b/src/t8_forest/t8_forest_balance.cxx @@ -25,7 +25,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/t8_forest/t8_forest_cxx.cxx b/src/t8_forest/t8_forest_cxx.cxx index 9afb3c7934..778120c390 100644 --- a/src/t8_forest/t8_forest_cxx.cxx +++ b/src/t8_forest/t8_forest_cxx.cxx @@ -36,8 +36,8 @@ #include #include #include -#include -#include +#include +#include #if T8_ENABLE_DEBUG #include #include diff --git a/src/t8_forest/t8_forest_general.h b/src/t8_forest/t8_forest_general.h index 332e79233f..9e12aa0626 100644 --- a/src/t8_forest/t8_forest_general.h +++ b/src/t8_forest/t8_forest_general.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include /** Opaque pointer to a forest implementation. */ typedef struct t8_forest *t8_forest_t; diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index 79c6f21925..28871b65ab 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -31,9 +31,9 @@ #include #include -#include -#include -#include +#include +#include +#include /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); diff --git a/src/t8_forest/t8_forest_types.h b/src/t8_forest/t8_forest_types.h index d601b0cc9b..a9db73a826 100644 --- a/src/t8_forest/t8_forest_types.h +++ b/src/t8_forest/t8_forest_types.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include // #include typedef struct t8_profile t8_profile_t; /* Defined below */ From b5ba195c88a0b3ed41b12168b0be2e8b2ba361b8 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 5 Aug 2024 15:17:13 +0200 Subject: [PATCH 12/26] update t8_forest_ghost_create_ext for ghost interface --- src/t8_forest/t8_forest_ghost.cxx | 75 +------------------------------ 1 file changed, 2 insertions(+), 73 deletions(-) diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index 28871b65ab..1033545621 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -1394,12 +1394,7 @@ t8_forest_ghost_receive (t8_forest_t forest, t8_forest_ghost_t ghost) void t8_forest_ghost_create_ext (t8_forest_t forest) { - t8_productionf("t8_forest_ghost_create_ext(forest):\n"); - t8_forest_ghost_t ghost = NULL; - t8_ghost_mpi_send_info_t *send_info; - sc_MPI_Request *requests; - // int create_tree_array = 0, create_gfirst_desc_array = 0; - // int create_element_array = 0; // nicht mehr nötig da in ghost-interface ausgelagert + t8_forest_ghost_t ghost; t8_forest_ghost_interface_c * ghost_interface; T8_ASSERT (t8_forest_is_committed (forest)); @@ -1427,76 +1422,10 @@ t8_forest_ghost_create_ext (t8_forest_t forest) t8_global_productionf ("Start ghost at %f %f\n", sc_MPI_Wtime (), forest->profile->ghost_runtime); } - /* step one */ - t8_global_productionf ("Befor step1\n"); - ghost_interface->t8_ghost_step_1_allocate(forest); - - // /* create element offset array if not done already */ - // create_element_array = 1; - // t8_forest_partition_create_offsets (forest); - // } - // if (forest->tree_offsets == NULL) { - // /* Create tree offset array if not done already */ - // create_tree_array = 1; - // t8_forest_partition_create_tree_offsets (forest); - // } - // if (forest->global_first_desc == NULL) { - // /* Create global first desc array if not done already */ - // create_gfirst_desc_array = 1; - // t8_forest_partition_create_first_desc (forest); - // } - - if (t8_forest_get_local_num_elements (forest) > 0) { - if (t8_forest_ghost_interface_get_type(ghost_interface) == T8_GHOST_NONE) { - t8_debugf ("WARNING: Trying to construct ghosts with ghost_type NONE. " - "Ghost layer is not constructed.\n"); - return; - } + ghost_interface->do_ghost(forest); - /* Initialize the ghost structure */ - t8_forest_ghost_init (&forest->ghosts, t8_forest_ghost_interface_get_type(ghost_interface)); ghost = forest->ghosts; - /* step two */ - t8_global_productionf ("Befor step2\n"); - ghost_interface->t8_ghost_step_2(forest); - - // t8_global_productionf ("t8_forest_ghost_create_ext: t8_forest_ghost_fill_remote_v3(forest)\n"); - // t8_forest_ghost_fill_remote_v3 (forest); - // } - // else { - // /* Construct the remote elements and processes. */ - // t8_global_productionf ("t8_forest_ghost_create_ext: t8_forest_ghost_fill_remote (forest, ghost, unbalanced_version != 0)\n"); - // t8_forest_ghost_fill_remote (forest, ghost, unbalanced_version != 0); - // } - - /* Step three */ - /* Start sending the remote elements */ - send_info = t8_forest_ghost_send_start (forest, ghost, &requests); - - /* Receive the ghost elements from the remote processes */ - t8_forest_ghost_receive (forest, ghost); - - /* End sending the remote elements */ - t8_forest_ghost_send_end (forest, ghost, send_info, requests); - } - - /* step one clean up */ - t8_global_productionf ("Befor step1 clean up\n"); - ghost_interface->t8_ghost_step_1_clean_up(forest); - - // /* Free the offset memory, if created */ - // t8_shmem_array_destroy (&forest->element_offsets); - // } - // if (create_tree_array) { - // /* Free the offset memory, if created */ - // t8_shmem_array_destroy (&forest->tree_offsets); - // } - // if (create_gfirst_desc_array) { - // /* Free the offset memory, if created */ - // t8_shmem_array_destroy (&forest->global_first_desc); - // } - if (forest->profile != NULL) { /* If profiling is enabled, we measure the runtime of ghost_create */ forest->profile->ghost_runtime += sc_MPI_Wtime (); From 9b693d426f29982cef077dff660d6b7b677febb6 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 5 Aug 2024 15:20:18 +0200 Subject: [PATCH 13/26] remove debuging print statmens --- src/t8_forest/t8_forest.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/t8_forest/t8_forest.c b/src/t8_forest/t8_forest.c index 11e917372d..7089ed1064 100644 --- a/src/t8_forest/t8_forest.c +++ b/src/t8_forest/t8_forest.c @@ -251,9 +251,6 @@ t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost t8_forest_ghost_interface_c * ghost_interface = t8_forest_ghost_interface_face_new(ghost_version); t8_forest_set_ghost_ext_new(forest, do_ghost, ghost_interface); } - if(forest->ghost_interface != NULL){ - t8_productionf("t8_set_ghost_ext aufgerufen, obwohl schon ghost_interface existiert."); - } } void @@ -520,7 +517,6 @@ t8_forest_commit (t8_forest_t forest) forest->ghost_interface = forest->set_from->ghost_interface; t8_forest_ghost_interface_ref(forest->ghost_interface); t8_debugf("t8_forest_commit: uebernehme ghost von set_from\n"); - t8_productionf("t8_forest_commit: uebernehme ghost von set_from\n"); } /* Compute the maximum allowed refinement level */ @@ -676,7 +672,6 @@ t8_forest_commit (t8_forest_t forest) /* Construct a ghost layer, if desired */ if (forest->do_ghost) { /* TODO: ghost type */ - t8_productionf("t8_forest_commit: do_ghost\n"); t8_forest_ghost_create_ext(forest); } forest->do_ghost = 0; @@ -1495,7 +1490,6 @@ t8_forest_free_trees (t8_forest_t forest) static void t8_forest_reset (t8_forest_t *pforest) { - t8_productionf("t8_forest_reset:\n"); int mpiret; t8_forest_t forest; @@ -1507,12 +1501,10 @@ t8_forest_reset (t8_forest_t *pforest) if (!forest->committed) { if (forest->set_from != NULL) { /* in this case we have taken ownership and not released it yet */ - t8_productionf("set_from wird unref in t8_forest_reset\n"); t8_forest_unref (&forest->set_from); } } else { - t8_productionf("forest hat kein set_from in t8_forest_reset\n"); T8_ASSERT (forest->set_from == NULL); } From dbfb924ae806b0568f6af11182f2dcf3dfea4949 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 5 Aug 2024 15:23:56 +0200 Subject: [PATCH 14/26] add hypercube hybrid to benchmarks --- benchmarks/time_forest_partition.cxx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/benchmarks/time_forest_partition.cxx b/benchmarks/time_forest_partition.cxx index 3b62cf19d9..48d4cd9946 100644 --- a/benchmarks/time_forest_partition.cxx +++ b/benchmarks/time_forest_partition.cxx @@ -339,7 +339,7 @@ main (int argc, char *argv[]) int level, level_diff; int help = 0, no_vtk, do_ghost, do_balance, use_cad; int dim, num_files; - int test_tet, test_linear_cylinder, test_cad_cylinder; + int test_tet, test_linear_cylinder, test_cad_cylinder, test_hypercube; int stride; int cmesh_level; double T, delta_t, cfl; @@ -389,6 +389,9 @@ main (int argc, char *argv[]) sc_options_add_switch (opt, 'O', "test-cad-cylinder", &test_cad_cylinder, "Use a cad cmesh to compare linear and cad geometry performance." " If this option is used -o is enabled automatically. Not allowed with -f and -c."); + sc_options_add_switch (opt, 'H', "test-hypercube", &test_hypercube, + "Use a hypercube with Hybercube with Tets, Prism and Hex elements as cmesh." + " If this option is used -o is enabled automatically. Not allowed with -f and -c."); sc_options_add_int (opt, 'l', "level", &level, 0, "The initial uniform refinement level of the forest."); sc_options_add_int (opt, 'r', "rlevel", &level_diff, 1, "The number of levels that the forest is refined from the initial level."); @@ -414,11 +417,11 @@ main (int argc, char *argv[]) /* check for wrong usage of arguments */ if (first_argc < 0 || first_argc != argc || dim < 2 || dim > 3 || (cmeshfileprefix == NULL && mshfileprefix == NULL && test_tet == 0 && test_cad_cylinder == 0 - && test_linear_cylinder == 0) + && test_linear_cylinder == 0 && test_hypercube == 0) || stride <= 0 || (num_files - 1) * stride >= mpisize || cfl < 0 || T <= 0 - || test_tet + test_linear_cylinder + test_cad_cylinder > 1 - || (cmesh_level >= 0 && (!test_linear_cylinder && !test_cad_cylinder)) - || ((mshfileprefix != NULL || cmeshfileprefix != NULL) && (test_linear_cylinder || test_cad_cylinder || test_tet)) + || test_tet + test_linear_cylinder + test_cad_cylinder + test_hypercube > 1 + || (cmesh_level >= 0 && (!test_linear_cylinder && !test_cad_cylinder && !test_hypercube)) + || ((mshfileprefix != NULL || cmeshfileprefix != NULL) && (test_linear_cylinder || test_cad_cylinder || test_tet || test_hypercube)) || (mshfileprefix == NULL && use_cad)) { sc_options_print_usage (t8_get_package_id (), SC_LP_ERROR, opt, NULL); return 1; @@ -453,6 +456,10 @@ main (int argc, char *argv[]) sc_intpow (2, cmesh_level), sc_intpow (2, cmesh_level), test_cad_cylinder); test_linear_cylinder ? vtu_prefix = "test_linear_cylinder" : vtu_prefix = "test_cad_cylinder"; } + else if (test_hypercube){ + cmesh = t8_cmesh_new_hypercube_hybrid (comm, 0, 0); + vtu_prefix = "test_hypercube_hybrid"; + } else { T8_ASSERT (cmeshfileprefix != NULL); cmesh From ce0a928fd68a2e792c0b4a2a3fbde15e088e1b39 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Sun, 11 Aug 2024 20:22:17 +0200 Subject: [PATCH 15/26] update Makefile for ghost_interface --- src/Makefile.am | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 7f2b8b784c..0983d65a09 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -139,8 +139,6 @@ libt8_compiled_sources = \ src/t8_forest/t8_forest_partition.cxx src/t8_forest/t8_forest_cxx.cxx \ src/t8_forest/t8_forest_private.c src/t8_forest/t8_forest_vtk.cxx \ src/t8_forest/t8_forest_ghost.cxx src/t8_forest/t8_forest_iterate.cxx \ - src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface.cxx \ - src/t8_forest/t8_forest_ghost_interface/t8_forest_ghost_interface_faces.cxx \ src/t8_version.c \ src/t8_vtk.c src/t8_forest/t8_forest_balance.cxx \ src/t8_forest/t8_forest_netcdf.cxx \ From c47c5361f5805078776e66ef23d1b7368df72cfd Mon Sep 17 00:00:00 2001 From: antjeHP Date: Sun, 11 Aug 2024 20:30:24 +0200 Subject: [PATCH 16/26] fix benachmark bug --- benchmarks/time_forest_partition.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/time_forest_partition.cxx b/benchmarks/time_forest_partition.cxx index 48d4cd9946..5604f4bcfe 100644 --- a/benchmarks/time_forest_partition.cxx +++ b/benchmarks/time_forest_partition.cxx @@ -457,7 +457,7 @@ main (int argc, char *argv[]) test_linear_cylinder ? vtu_prefix = "test_linear_cylinder" : vtu_prefix = "test_cad_cylinder"; } else if (test_hypercube){ - cmesh = t8_cmesh_new_hypercube_hybrid (comm, 0, 0); + cmesh = t8_cmesh_new_hypercube_hybrid (sc_MPI_COMM_WORLD, 0, 0); vtu_prefix = "test_hypercube_hybrid"; } else { From 06fd2e26d8d38ce3fd413e8246e524024864c163 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 12 Aug 2024 09:43:16 +0200 Subject: [PATCH 17/26] add ghost_interface implemenation --- src/t8_forest/t8_forest_ghost.cxx | 210 +++++++++++++++++++++++++++++- 1 file changed, 209 insertions(+), 1 deletion(-) diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index b9a79042e6..0675c0cf12 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -1424,7 +1424,7 @@ t8_forest_ghost_create_ext (t8_forest_t forest) ghost_interface->do_ghost(forest); - ghost = forest->ghosts; + ghost = forest->ghosts; if (forest->profile != NULL) { /* If profiling is enabled, we measure the runtime of ghost_create */ @@ -1477,6 +1477,7 @@ void t8_forest_ghost_create_topdown (t8_forest_t forest) { T8_ASSERT (t8_forest_is_committed (forest)); + T8_ASSERT(forest->ghost_interface != NULL); T8_ASSERT(t8_forest_ghost_interface_face_verison(forest->ghost_interface) == 3); t8_forest_ghost_create_ext (forest); } @@ -1885,4 +1886,211 @@ t8_forest_ghost_destroy (t8_forest_ghost_t *pghost) T8_ASSERT (*pghost == NULL); } + +/** + * Implementation of the ghost-interface + * Wrapper for the abstracte base classe + * Implementation of the comunication steps + * and implementation of the dreived classe search +*/ + +t8_ghost_type_t +t8_forest_ghost_interface_get_type(t8_forest_ghost_interface_c * ghost_interface){ + T8_ASSERT (ghost_interface != NULL); + return ghost_interface->t8_ghost_get_type(); +} + +void t8_forest_ghost_interface_ref(t8_forest_ghost_interface_c * ghost_interface){ + T8_ASSERT (ghost_interface != NULL); + ghost_interface->ref(); +} + +void t8_forest_ghost_interface_unref(t8_forest_ghost_interface_c ** pghost_interface){ + t8_forest_ghost_interface_c * ghost_interface; + + T8_ASSERT (pghost_interface != NULL); + ghost_interface = *pghost_interface; + T8_ASSERT (ghost_interface != NULL); + + ghost_interface->unref(); +} + + +/** + * Abstract Base Class +*/ + +void +t8_forest_ghost_interface::communicate_ownerships(t8_forest_t forest){ + t8_global_productionf (" t8_forest_ghost_interface_faces::t8_ghost_step_1_allocate \n"); + if (forest->element_offsets == NULL) { + /* create element offset array if not done already */ + memory_flag = memory_flag | CREATE_ELEMENT_ARRAY; + t8_forest_partition_create_offsets (forest); + } + if (forest->tree_offsets == NULL) { + /* Create tree offset array if not done already */ + memory_flag = memory_flag | CREATE_TREE_ARRAY; + t8_forest_partition_create_tree_offsets (forest); + } + if (forest->global_first_desc == NULL) { + /* Create global first desc array if not done already */ + memory_flag = memory_flag | CREATE_GFIRST_DESC_ARRAY; + t8_forest_partition_create_first_desc (forest); + } +} + +void +t8_forest_ghost_interface::communicate_ghost_elements(t8_forest_t forest){ + t8_forest_ghost_t ghost = forest->ghosts; // TODO: make sure, that ghost is init + t8_ghost_mpi_send_info_t *send_info; + sc_MPI_Request *requests; + + /* Start sending the remote elements */ + send_info = t8_forest_ghost_send_start (forest, ghost, &requests); + + /* Receive the ghost elements from the remote processes */ + t8_forest_ghost_receive (forest, ghost); + + /* End sending the remote elements */ + t8_forest_ghost_send_end (forest, ghost, send_info, requests); +} + + +void +t8_forest_ghost_interface::clean_up(t8_forest_t forest){ + t8_global_productionf (" t8_forest_ghost_interface_faces::t8_ghost_step_1_clean_up \n"); + if (memory_flag & CREATE_GFIRST_DESC_ARRAY){ + /* Free the offset memory, if created */ + t8_shmem_array_destroy (&forest->element_offsets); + } + if (memory_flag & CREATE_TREE_ARRAY) { + /* Free the offset memory, if created */ + t8_shmem_array_destroy (&forest->tree_offsets); + } + if (memory_flag & CREATE_GFIRST_DESC_ARRAY) { + /* Free the offset memory, if created */ + t8_shmem_array_destroy (&forest->global_first_desc); + } +} + +/** + * Derived class ghost_w_search +*/ + +t8_forest_ghost_w_search::t8_forest_ghost_w_search(t8_ghost_type_t ghost_type) + : t8_forest_ghost_interface(ghost_type) +{ + T8_ASSERT(ghost_type != T8_GHOST_NONE && ghost_type != T8_GHOST_USERDEFINED); + T8_ASSERT(ghost_type == T8_GHOST_FACES); + if(ghost_type == T8_GHOST_FACES){ + search_fn = t8_forest_ghost_search_boundary; + } + SC_CHECK_ABORT(ghost_type == T8_GHOST_VERTICES || ghost_type == T8_GHOST_EDGES || ghost_type == T8_GHOST_FACES, + "invalide type for t8_forest_ghost_w_search"); +} + +void +t8_forest_ghost_w_search::do_ghost(t8_forest_t forest){ + t8_forest_ghost_t ghost; + + communicate_ownerships(forest); + + if (t8_forest_get_local_num_elements (forest) > 0) { + if ( t8_ghost_get_type() == T8_GHOST_NONE) { + t8_debugf ("WARNING: Trying to construct ghosts with ghost_type NONE. " + "Ghost layer is not constructed.\n"); + return; + } + + /* Initialize the ghost structure */ + t8_forest_ghost_init (&forest->ghosts, ghost_type); + ghost = forest->ghosts; + + step_2(forest); + + communicate_ghost_elements(forest); + } + clean_up(forest); +} + +void +t8_forest_ghost_w_search::step_2(t8_forest_t forest){ + t8_forest_ghost_boundary_data_t data; + void *store_user_data = NULL; + + /* Start with invalid entries in the user data. + * These are set in t8_forest_ghost_search_boundary each time a new tree is entered */ + data.eclass = T8_ECLASS_COUNT; + data.gtreeid = -1; + data.ts = NULL; +#ifdef T8_ENABLE_DEBUG + data.left_out = 0; +#endif + sc_array_init (&data.face_owners, sizeof (int)); + /* This is a dummy init, since we call sc_array_reset in ghost_search_boundary + * and we should not call sc_array_reset on a non-initialized array */ + sc_array_init (&data.bounds_per_level, 1); + /* Store any user data that may reside on the forest */ + store_user_data = t8_forest_get_user_data (forest); + /* Set the user data for the search routine */ + t8_forest_set_user_data (forest, &data); + /* Loop over the trees of the forest */ + t8_forest_search (forest, search_fn, NULL, NULL); + + /* Reset the user data from before search */ + t8_forest_set_user_data (forest, store_user_data); + + /* Reset the data arrays */ + sc_array_reset (&data.face_owners); + sc_array_reset (&data.bounds_per_level); +#ifdef T8_ENABLE_DEBUG +#endif +} + + +t8_forest_ghost_face::t8_forest_ghost_face(int version) + : t8_forest_ghost_w_search(T8_GHOST_FACES, t8_forest_ghost_search_boundary) , version(version) + { + T8_ASSERT( 1<= version && version <= 3); + } + + + +void +t8_forest_ghost_face::step_2(t8_forest_t forest){ + t8_global_productionf (" t8_forest_ghost_face::step_2 \n"); + T8_ASSERT( forest->ghosts != NULL); + t8_forest_ghost_t ghost = forest->ghosts; + if (version == 3) { + t8_global_productionf ("t8_forest_ghost_face::step_2: t8_forest_ghost_fill_remote_v3(forest)\n"); + t8_forest_ghost_fill_remote_v3 (forest); + } + else { + /* Construct the remote elements and processes. */ + t8_global_productionf ("t8_forest_ghost_face::step_2: t8_forest_ghost_fill_remote (forest, ghost, ghost_version != 1)\n"); + t8_forest_ghost_fill_remote (forest, ghost, version != 1); + } +} + + + +/* warpper for derived face class */ +t8_forest_ghost_interface_c * +t8_forest_ghost_interface_face_new(int version){ + t8_debugf ("Call t8_forest_ghost_interface_face_new.\n"); + T8_ASSERT( 1 <= version && version <= 3 ); + t8_forest_ghost_face * ghost_interface = new t8_forest_ghost_face(version); + return (t8_forest_ghost_interface_c *) ghost_interface; +} + +int +t8_forest_ghost_interface_face_verison(t8_forest_ghost_interface_c * ghost_interface){ + T8_ASSERT(ghost_interface != NULL); + T8_ASSERT(ghost_interface->t8_ghost_get_type() == T8_GHOST_FACES); + t8_forest_ghost_face * ghost_interface_passed = (t8_forest_ghost_face *) ghost_interface; + + return ghost_interface_passed->get_version(); +} + T8_EXTERN_C_END (); From ba64acbfe048ac045e53f5d56fd2dfa6366af20f Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 12 Aug 2024 09:43:43 +0200 Subject: [PATCH 18/26] add ghost interface to makefile --- src/Makefile.am | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 191cccad5b..e572ef74b1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -55,7 +55,11 @@ libt8_installed_headers_forest = \ src/t8_forest/t8_forest_adapt.h \ src/t8_forest/t8_forest_vtk.h \ src/t8_forest/t8_forest_to_vtkUnstructured.hxx \ - src/t8_forest/t8_forest_iterate.h src/t8_forest/t8_forest_partition.h + src/t8_forest/t8_forest_iterate.h src/t8_forest/t8_forest_partition.h \ + src/t8_forest/t8_forest_ghost_interface_wrapper.h \ + src/t8_forest/t8_forest_ghost_interface.h \ + src/t8_forest/t8_forest_ghost_interface.hxx \ + src/t8_forest/t8_forest_ghost_search.hxx libt8_installed_headers_geometry = \ src/t8_geometry/t8_geometry.h \ src/t8_geometry/t8_geometry_handler.hxx \ From 137c1893bfc30ead7c31d76853435904631f0fb6 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 26 Aug 2024 19:06:46 +0200 Subject: [PATCH 19/26] add more cubetests --- benchmarks/time_forest_partition.cxx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/benchmarks/time_forest_partition.cxx b/benchmarks/time_forest_partition.cxx index 54d5c09c36..4c0c7b1356 100644 --- a/benchmarks/time_forest_partition.cxx +++ b/benchmarks/time_forest_partition.cxx @@ -339,7 +339,7 @@ main (int argc, char *argv[]) int level, level_diff; int help = 0, no_vtk, do_ghost, do_balance, use_cad; int dim, num_files; - int test_tet, test_linear_cylinder, test_cad_cylinder, test_hypercube; + int test_tet, test_linear_cylinder, test_cad_cylinder, test_hybrid_cube, test_hex_cube; int stride; int cmesh_level; double T, delta_t, cfl; @@ -389,9 +389,12 @@ main (int argc, char *argv[]) sc_options_add_switch (opt, 'O', "test-cad-cylinder", &test_cad_cylinder, "Use a cad cmesh to compare linear and cad geometry performance." " If this option is used -o is enabled automatically. Not allowed with -f and -c."); - sc_options_add_switch (opt, 'H', "test-hypercube", &test_hypercube, + sc_options_add_switch (opt, 'C', "test-hybridcube", &test_hybrid_cube, "Use a hypercube with Hybercube with Tets, Prism and Hex elements as cmesh." " If this option is used -o is enabled automatically. Not allowed with -f and -c."); + sc_options_add_switch (opt, 'H', "test-hexcube", &test_hex_cube, + "Use a hypercube with Hex elements as cmesh." + " If this option is used -o is enabled automatically. Not allowed with -f and -c."); sc_options_add_int (opt, 'l', "level", &level, 0, "The initial uniform refinement level of the forest."); sc_options_add_int (opt, 'r', "rlevel", &level_diff, 1, "The number of levels that the forest is refined from the initial level."); @@ -417,11 +420,11 @@ main (int argc, char *argv[]) /* check for wrong usage of arguments */ if (first_argc < 0 || first_argc != argc || dim < 2 || dim > 3 || (cmeshfileprefix == NULL && mshfileprefix == NULL && test_tet == 0 && test_cad_cylinder == 0 - && test_linear_cylinder == 0 && test_hypercube == 0) + && test_linear_cylinder == 0 && test_hybrid_cube == 0 && test_hex_cube == 0 ) || stride <= 0 || (num_files - 1) * stride >= mpisize || cfl < 0 || T <= 0 - || test_tet + test_linear_cylinder + test_cad_cylinder + test_hypercube > 1 - || (cmesh_level >= 0 && (!test_linear_cylinder && !test_cad_cylinder && !test_hypercube)) - || ((mshfileprefix != NULL || cmeshfileprefix != NULL) && (test_linear_cylinder || test_cad_cylinder || test_tet || test_hypercube)) + || test_tet + test_linear_cylinder + test_cad_cylinder + test_hybrid_cube + test_hex_cube > 1 + || (cmesh_level >= 0 && (!test_linear_cylinder && !test_cad_cylinder && !test_hybrid_cube && !test_hex_cube)) + || ((mshfileprefix != NULL || cmeshfileprefix != NULL) && (test_linear_cylinder || test_cad_cylinder || test_tet || test_hybrid_cube || test_hex_cube)) || (mshfileprefix == NULL && use_cad)) { sc_options_print_usage (t8_get_package_id (), SC_LP_ERROR, opt, NULL); return 1; @@ -456,10 +459,14 @@ main (int argc, char *argv[]) sc_intpow (2, cmesh_level), sc_intpow (2, cmesh_level), test_cad_cylinder); test_linear_cylinder ? vtu_prefix = "test_linear_cylinder" : vtu_prefix = "test_cad_cylinder"; } - else if (test_hypercube){ + else if (test_hybrid_cube){ cmesh = t8_cmesh_new_hypercube_hybrid (sc_MPI_COMM_WORLD, 0, 0); vtu_prefix = "test_hypercube_hybrid"; } + else if (test_hex_cube){ + cmesh = t8_cmesh_new_hypercube(T8_ECLASS_HEX, sc_MPI_COMM_WORLD, 0, 0, 0); + vtu_prefix = "test_hypercube_hex"; + } else { T8_ASSERT (cmeshfileprefix != NULL); cmesh From cd88e76173dd90b09eac07b2185dee674aac53f9 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 9 Sep 2024 15:24:25 +0200 Subject: [PATCH 20/26] add ghost stencil --- src/t8_forest/t8_forest_ghost.cxx | 108 ++++++++++++++++++++++ src/t8_forest/t8_forest_ghost_stencil.hxx | 47 ++++++++++ 2 files changed, 155 insertions(+) create mode 100644 src/t8_forest/t8_forest_ghost_stencil.hxx diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index 0675c0cf12..c74245a670 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -34,6 +34,7 @@ #include #include #include +#include /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); @@ -2084,6 +2085,14 @@ t8_forest_ghost_interface_face_new(int version){ return (t8_forest_ghost_interface_c *) ghost_interface; } + +t8_forest_ghost_interface_c * +t8_forest_ghost_interface_stencil_new(){ + t8_debugf ("Call t8_forest_ghost_interface_stencil_new.\n"); + t8_forest_ghost_stencil * ghost_interface = new t8_forest_ghost_stencil(); + return (t8_forest_ghost_interface_c *) ghost_interface; +} + int t8_forest_ghost_interface_face_verison(t8_forest_ghost_interface_c * ghost_interface){ T8_ASSERT(ghost_interface != NULL); @@ -2093,4 +2102,103 @@ t8_forest_ghost_interface_face_verison(t8_forest_ghost_interface_c * ghost_inter return ghost_interface_passed->get_version(); } + +/** + * Derived class for a stencil on an uniform mesh. + */ + + + +void +t8_forest_ghost_stencil::do_ghost(t8_forest_t forest){ + /** + * Compute bounds for elements + */ + + t8_forest_ghost_init (&forest->ghosts, ghost_type); + + t8_locidx_t current_index; // counter over all local elements + t8_locidx_t ielement, num_elements_in_tree; // count over the local elements in a tree + t8_eclass_scheme_c *eclass_scheme; + t8_eclass_t tree_class; + const t8_element_t *element; + + + SC_CHECK_ABORT( forest->global_num_trees > 1, "more than one tree in ghost for stencil" ); + + tree_class = t8_forest_get_tree_class (forest, 0); + eclass_scheme = t8_forest_get_eclass_scheme (forest, tree_class); + SC_CHECK_ABORT( tree_class == T8_ECLASS_HEX, "only forest with eclass hex are possible for ghost for stencil" ) + num_elements_in_tree = t8_forest_get_tree_num_elements (forest, 0); + + for (ielement = 0; ielement < num_elements_in_tree; ++ielement, ++current_index){ + element = t8_forest_get_element_in_tree (forest, 0, ielement); + /** compute the stencil elements */ + add_stencil_to_ghost(forest, element, eclass_scheme, eclass_scheme->t8_element_level(element), tree_class, 0, ielement); + } + + communicate_ghost_elements(forest); +} + +/** + * Add this stencil (elements N and F) for elmenet E to ghost + * + * N + * | + * N - F - N + * | | | + * N - F - E - F - N + * | | | + * N - F - N + * | + * N + */ +void +t8_forest_ghost_stencil::add_stencil_to_ghost(t8_forest_t forest, const t8_element_t * element, t8_eclass_scheme_c *eclass_scheme, int level, + t8_eclass_t tree_class, t8_locidx_t ltreeid, t8_locidx_t ielement){ + + t8_locidx_t iface_neig, ineig; + t8_element_t * face_neig; + t8_element_t * neig; + t8_eclass_t eclass = t8_forest_get_eclass (forest, 0); + + /** + * First loop over the F elements, this are the face-neighbors of E + */ + for ( iface_neig = 0; iface_neig < eclass_scheme->t8_element_num_faces(element); ++iface_neig){ + eclass_scheme->t8_element_new (1,&face_neig); + eclass_scheme->t8_element_new (1,&neig); + /* Compute one F */ + int neight_face; + int face_neig_exists = eclass_scheme->t8_element_face_neighbor_inside(element, face_neig, iface_neig, &neight_face); + /* if the F exists */ + if(face_neig_exists){ + /* compute the mpirank for F, and if its not ownes by this prozess, add it to gost */ + int remote_rank = t8_forest_element_find_owner_ext(forest, 0, face_neig, eclass, 0, forest->mpisize - 1, (forest->mpisize - 1)/2, 0); + T8_ASSERT( 0 <= remote_rank && remote_rank < forest->mpisize ); + if(forest->mpirank != remote_rank){ + t8_ghost_add_remote (forest, forest->ghosts, remote_rank, ltreeid, element, ielement); + } + /* Loop over the face neighbors of F (exept of E), this are the N */ + for( ineig = 0; ineig < eclass_scheme->t8_element_num_faces(face_neig); ++ineig ){ + if(ineig != neight_face){ + /* Compute N */ + int neight_neig_face; + int neig_exists = eclass_scheme->t8_element_face_neighbor_inside(face_neig, neig, ineig, &neight_neig_face); + if(neig_exists){ + /* compute the mpirank for N, and if its not ownes by this prozess, add it to gost */ + remote_rank = t8_forest_element_find_owner_ext(forest, 0, neig, eclass, 0, forest->mpisize -1, (forest->mpisize - 1) / 2 ,0); + T8_ASSERT( 0 <= remote_rank && remote_rank < forest->mpisize ); + if(forest->mpirank != remote_rank){ + t8_ghost_add_remote (forest, forest->ghosts, remote_rank, ltreeid, element, ielement); + } + } + } + } + } + eclass_scheme->t8_element_destroy(1, &face_neig); + eclass_scheme->t8_element_destroy(1, &neig); + } +} + T8_EXTERN_C_END (); diff --git a/src/t8_forest/t8_forest_ghost_stencil.hxx b/src/t8_forest/t8_forest_ghost_stencil.hxx new file mode 100644 index 0000000000..e8f0209982 --- /dev/null +++ b/src/t8_forest/t8_forest_ghost_stencil.hxx @@ -0,0 +1,47 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2015 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef T8_FOREST_GHOST_STENCIL_HXX +#define T8_FOREST_GHOST_STENCIL_HXX + + +#include +#include + +T8_EXTERN_C_BEGIN (); + +struct t8_forest_ghost_stencil : t8_forest_ghost_interface +{ + public: + t8_forest_ghost_stencil() : t8_forest_ghost_interface(T8_GHOST_USERDEFINED){}; + + void + do_ghost(t8_forest_t forest) override; + + protected: + void add_stencil_to_ghost(t8_forest_t forest, const t8_element_t * element, t8_eclass_scheme_c *eclass_scheme, int level, + t8_eclass_t tree_class, t8_locidx_t ltreeid, t8_locidx_t ielement); +}; + +T8_EXTERN_C_END (); + +#endif /* !T8_FOREST_GHOST_STENCIL_HXX */ From 0d74a112a6b63c1695b6f3b218d539d813ff8ce6 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 9 Sep 2024 16:55:28 +0200 Subject: [PATCH 21/26] update function name of step 2 of ghost interface --- src/t8_forest/t8_forest_ghost.cxx | 20 ++++++++------------ src/t8_forest/t8_forest_ghost_interface.hxx | 2 +- src/t8_forest/t8_forest_ghost_search.hxx | 17 ++++++++++------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index c74245a670..77ba2a8e79 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -177,8 +177,7 @@ t8_forest_ghost_init (t8_forest_ghost_t *pghost, t8_ghost_type_t ghost_type) { t8_forest_ghost_t ghost; - /* We currently only support face-neighbor ghosts */ - T8_ASSERT (ghost_type == T8_GHOST_FACES); // TODO muss angepasst werden + T8_ASSERT (ghost_type != T8_GHOST_NONE); /* Allocate memory for ghost */ ghost = *pghost = T8_ALLOC_ZERO (t8_forest_ghost_struct_t, 1); @@ -1982,18 +1981,16 @@ t8_forest_ghost_interface::clean_up(t8_forest_t forest){ t8_forest_ghost_w_search::t8_forest_ghost_w_search(t8_ghost_type_t ghost_type) : t8_forest_ghost_interface(ghost_type) { - T8_ASSERT(ghost_type != T8_GHOST_NONE && ghost_type != T8_GHOST_USERDEFINED); - T8_ASSERT(ghost_type == T8_GHOST_FACES); + T8_ASSERT(ghost_type != T8_GHOST_NONE); + T8_ASSERT(ghost_type == T8_GHOST_FACES); // currently no other typs are suportet if(ghost_type == T8_GHOST_FACES){ search_fn = t8_forest_ghost_search_boundary; } - SC_CHECK_ABORT(ghost_type == T8_GHOST_VERTICES || ghost_type == T8_GHOST_EDGES || ghost_type == T8_GHOST_FACES, - "invalide type for t8_forest_ghost_w_search"); + SC_CHECK_ABORT(ghost_type != T8_GHOST_USERDEFINED, "use t8_forest_ghost_w_search(t8_forest_search_query_fn serach_function) for userdefined ghost") ; } void t8_forest_ghost_w_search::do_ghost(t8_forest_t forest){ - t8_forest_ghost_t ghost; communicate_ownerships(forest); @@ -2006,9 +2003,8 @@ t8_forest_ghost_w_search::do_ghost(t8_forest_t forest){ /* Initialize the ghost structure */ t8_forest_ghost_init (&forest->ghosts, ghost_type); - ghost = forest->ghosts; - step_2(forest); + search_for_ghost_elements(forest); communicate_ghost_elements(forest); } @@ -2016,7 +2012,7 @@ t8_forest_ghost_w_search::do_ghost(t8_forest_t forest){ } void -t8_forest_ghost_w_search::step_2(t8_forest_t forest){ +t8_forest_ghost_w_search::search_for_ghost_elements(t8_forest_t forest){ t8_forest_ghost_boundary_data_t data; void *store_user_data = NULL; @@ -2059,7 +2055,7 @@ t8_forest_ghost_face::t8_forest_ghost_face(int version) void -t8_forest_ghost_face::step_2(t8_forest_t forest){ +t8_forest_ghost_face::search_for_ghost_elements(t8_forest_t forest){ t8_global_productionf (" t8_forest_ghost_face::step_2 \n"); T8_ASSERT( forest->ghosts != NULL); t8_forest_ghost_t ghost = forest->ghosts; @@ -2128,7 +2124,7 @@ t8_forest_ghost_stencil::do_ghost(t8_forest_t forest){ tree_class = t8_forest_get_tree_class (forest, 0); eclass_scheme = t8_forest_get_eclass_scheme (forest, tree_class); - SC_CHECK_ABORT( tree_class == T8_ECLASS_HEX, "only forest with eclass hex are possible for ghost for stencil" ) + SC_CHECK_ABORT( tree_class == T8_ECLASS_HEX, "only forest with eclass hex are possible for ghost for stencil" ); num_elements_in_tree = t8_forest_get_tree_num_elements (forest, 0); for (ielement = 0; ielement < num_elements_in_tree; ++ielement, ++current_index){ diff --git a/src/t8_forest/t8_forest_ghost_interface.hxx b/src/t8_forest/t8_forest_ghost_interface.hxx index 8490476aa0..669d37e53c 100644 --- a/src/t8_forest/t8_forest_ghost_interface.hxx +++ b/src/t8_forest/t8_forest_ghost_interface.hxx @@ -106,6 +106,7 @@ struct t8_forest_ghost_interface do_ghost(t8_forest_t forest) = 0; + protected: /** * Compute and collect ownerships to create the nessesary offset * for elements, trees and first descandance @@ -119,7 +120,6 @@ struct t8_forest_ghost_interface virtual void clean_up(t8_forest_t forest); - protected: /** * Constructor for the derivided classes to set the korrekt type for them. * \param [in] g_type The type (faces, edges, userdefind, ...) of the ghost_interface diff --git a/src/t8_forest/t8_forest_ghost_search.hxx b/src/t8_forest/t8_forest_ghost_search.hxx index bbaeb97a6d..cee7b8d624 100644 --- a/src/t8_forest/t8_forest_ghost_search.hxx +++ b/src/t8_forest/t8_forest_ghost_search.hxx @@ -53,19 +53,21 @@ struct t8_forest_ghost_w_search : public t8_forest_ghost_interface virtual void do_ghost(t8_forest_t forest) override; + protected: /** - * Übernommen aus t8_forest_ghost_fill_remote_v3 - * daher keine unterstüzung mehr von version 1 und 2 - * Nur der search_fn parameter, ist nicht fest sonder etwpricht der member variabel + * Equal to t8_forest_ghost_fill_remote_v3 + * so no support for version 1 and 2 of face heigbors + * Only the search_fn parameter for serch ist not the same as in t8_forest_ghost_fill_remote_v3 + * use the member variable of the class */ virtual void - step_2(t8_forest_t forest); + search_for_ghost_elements(t8_forest_t forest); - protected: t8_forest_ghost_w_search(t8_ghost_type_t ghost_type, t8_forest_search_query_fn search_function) : t8_forest_ghost_interface(ghost_type), search_fn(search_function) { + T8_ASSERT(ghost_type != T8_GHOST_NONE); } t8_forest_search_query_fn search_fn{}; @@ -77,10 +79,11 @@ struct t8_forest_ghost_face : public t8_forest_ghost_w_search public: explicit t8_forest_ghost_face(int version); - void step_2(t8_forest_t forest) override; - inline int get_version() const {return version;} + protected: + void search_for_ghost_elements(t8_forest_t forest) override; + private: int version{}; }; From 53de48db3622ebb75a3fab3591381998d4cbc919 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Wed, 11 Sep 2024 17:53:48 +0200 Subject: [PATCH 22/26] update ghost stencil --- src/t8_forest/t8_forest_ghost.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index 77ba2a8e79..b537cb0ed3 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -2120,11 +2120,11 @@ t8_forest_ghost_stencil::do_ghost(t8_forest_t forest){ const t8_element_t *element; - SC_CHECK_ABORT( forest->global_num_trees > 1, "more than one tree in ghost for stencil" ); + SC_CHECK_ABORT( t8_forest_get_num_global_trees(forest) == 1, "more than one tree in ghost for stencil" ); tree_class = t8_forest_get_tree_class (forest, 0); eclass_scheme = t8_forest_get_eclass_scheme (forest, tree_class); - SC_CHECK_ABORT( tree_class == T8_ECLASS_HEX, "only forest with eclass hex are possible for ghost for stencil" ); + SC_CHECK_ABORT( tree_class == T8_ECLASS_QUAD, "only forest with eclass quad are possible for ghost for stencil" ); num_elements_in_tree = t8_forest_get_tree_num_elements (forest, 0); for (ielement = 0; ielement < num_elements_in_tree; ++ielement, ++current_index){ From febd5b1c578170e6dd300ce6e1389cb51ce9ab24 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 16 Sep 2024 10:46:44 +0200 Subject: [PATCH 23/26] add stencil find owner function --- src/t8_forest/t8_forest_ghost.cxx | 41 +++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index b537cb0ed3..5b86bbb1cf 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -2136,6 +2136,41 @@ t8_forest_ghost_stencil::do_ghost(t8_forest_t forest){ communicate_ghost_elements(forest); } + + +/** + * Function to compute the owner of an element + * \param [in] forest a commit uniform forest which is partitioned + * \param [in] eclass_scheme shoud fit to the element + * \param [in] element compute owner of this + * \param [out] owner + * \note: the function use, that the linear id of the element is the same as the golbal index + * for example this is true for uniform meshes. + * the function also use, that the forest is partitioned. + * The owner is found in O(1) + */ +int +t8_forest_ghost_interface_stencil_get_remot_rank(t8_forest_t forest, t8_eclass_scheme_c * eclass_scheme, t8_element_t *element){ + t8_gloidx_t golbal_num_elements = t8_forest_get_global_num_elements(forest); + t8_linearidx_t lin_id = eclass_scheme->t8_element_get_linear_id( element, eclass_scheme->t8_element_level(element)); + + t8_linearidx_t b_0 = golbal_num_elements / forest->mpisize ; + t8_linearidx_t r = golbal_num_elements % forest->mpisize ; + + int p_guess = lin_id / b_0 ; + if( p_guess < 2 || r == 0){ + return p_guess; + } + int x = ( p_guess * r ) / forest->mpisize ; + + int owner = ( lin_id - x ) / b_0 ; + + return owner; + +} + + + /** * Add this stencil (elements N and F) for elmenet E to ghost * @@ -2170,7 +2205,8 @@ t8_forest_ghost_stencil::add_stencil_to_ghost(t8_forest_t forest, const t8_eleme /* if the F exists */ if(face_neig_exists){ /* compute the mpirank for F, and if its not ownes by this prozess, add it to gost */ - int remote_rank = t8_forest_element_find_owner_ext(forest, 0, face_neig, eclass, 0, forest->mpisize - 1, (forest->mpisize - 1)/2, 0); + int remote_rank = t8_forest_ghost_interface_stencil_get_remot_rank(forest, eclass_scheme, face_neig); + T8_ASSERT( remote_rank == t8_forest_element_find_owner_ext(forest, 0, face_neig, eclass, 0, forest->mpisize - 1, remote_rank, 0) ); T8_ASSERT( 0 <= remote_rank && remote_rank < forest->mpisize ); if(forest->mpirank != remote_rank){ t8_ghost_add_remote (forest, forest->ghosts, remote_rank, ltreeid, element, ielement); @@ -2183,7 +2219,8 @@ t8_forest_ghost_stencil::add_stencil_to_ghost(t8_forest_t forest, const t8_eleme int neig_exists = eclass_scheme->t8_element_face_neighbor_inside(face_neig, neig, ineig, &neight_neig_face); if(neig_exists){ /* compute the mpirank for N, and if its not ownes by this prozess, add it to gost */ - remote_rank = t8_forest_element_find_owner_ext(forest, 0, neig, eclass, 0, forest->mpisize -1, (forest->mpisize - 1) / 2 ,0); + remote_rank = t8_forest_ghost_interface_stencil_get_remot_rank(forest, eclass_scheme, neig); + T8_ASSERT(remote_rank == t8_forest_element_find_owner_ext(forest, 0, neig, eclass, 0, forest->mpisize -1, remote_rank ,0)); T8_ASSERT( 0 <= remote_rank && remote_rank < forest->mpisize ); if(forest->mpirank != remote_rank){ t8_ghost_add_remote (forest, forest->ghosts, remote_rank, ltreeid, element, ielement); From c9bb0f45676085d965b5a2e21aac141d365d445d Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 30 Sep 2024 12:52:40 +0200 Subject: [PATCH 24/26] typos --- src/t8_forest/t8_forest.cxx | 21 +- src/t8_forest/t8_forest_balance.cxx | 12 +- src/t8_forest/t8_forest_general.h | 18 +- src/t8_forest/t8_forest_ghost.cxx | 313 +++++++++--------- src/t8_forest/t8_forest_ghost.h | 5 +- src/t8_forest/t8_forest_ghost_interface.h | 5 +- src/t8_forest/t8_forest_ghost_interface.hxx | 123 ++++--- .../t8_forest_ghost_interface_faces.hxx | 8 +- .../t8_forest_ghost_interface_wrapper.h | 22 +- src/t8_forest/t8_forest_ghost_search.hxx | 87 +++-- src/t8_forest/t8_forest_ghost_stencil.hxx | 22 +- src/t8_forest/t8_forest_types.h | 16 +- 12 files changed, 326 insertions(+), 326 deletions(-) diff --git a/src/t8_forest/t8_forest.cxx b/src/t8_forest/t8_forest.cxx index 23a718fee4..dc44505a77 100644 --- a/src/t8_forest/t8_forest.cxx +++ b/src/t8_forest/t8_forest.cxx @@ -2962,12 +2962,13 @@ t8_forest_set_balance (t8_forest_t forest, const t8_forest_t set_from, int no_re } void -t8_forest_set_ghost_ext_new (t8_forest_t forest, int do_ghost, t8_forest_ghost_interface_c * ghost_interface){ +t8_forest_set_ghost_ext_new (t8_forest_t forest, int do_ghost, t8_forest_ghost_interface_c *ghost_interface) +{ T8_ASSERT (t8_forest_is_initialized (forest)); SC_CHECK_ABORT (do_ghost != 0, "do_ghost == 0 in set_ghost_ext_new.\n"); SC_CHECK_ABORT (ghost_interface != NULL, "invalides ghost interface in set_ghost_ext_new\n"); - if(forest->ghost_interface != NULL){ - t8_forest_ghost_interface_unref(&(forest->ghost_interface)); + if (forest->ghost_interface != NULL) { + t8_forest_ghost_interface_unref (&(forest->ghost_interface)); } forest->do_ghost = do_ghost; forest->ghost_interface = ghost_interface; @@ -2990,8 +2991,8 @@ t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost forest->do_ghost = (do_ghost != 0); /* True if and only if do_ghost != 0 */ } if (forest->do_ghost) { - t8_forest_ghost_interface_c * ghost_interface = t8_forest_ghost_interface_face_new(ghost_version); - t8_forest_set_ghost_ext_new(forest, do_ghost, ghost_interface); + t8_forest_ghost_interface_c *ghost_interface = t8_forest_ghost_interface_face_new (ghost_version); + t8_forest_set_ghost_ext_new (forest, do_ghost, ghost_interface); } } @@ -3257,8 +3258,8 @@ t8_forest_commit (t8_forest_t forest) if (forest->ghost_interface == NULL && forest->set_from->ghost_interface != NULL) { forest->ghost_interface = forest->set_from->ghost_interface; - t8_forest_ghost_interface_ref(forest->ghost_interface); - t8_debugf("t8_forest_commit: uebernehme ghost von set_from\n"); + t8_forest_ghost_interface_ref (forest->ghost_interface); + t8_debugf ("t8_forest_commit: uebernehme ghost von set_from\n"); } /* Compute the maximum allowed refinement level */ @@ -3414,7 +3415,7 @@ t8_forest_commit (t8_forest_t forest) /* Construct a ghost layer, if desired */ if (forest->do_ghost) { /* TODO: ghost type */ - t8_forest_ghost_create_ext(forest); + t8_forest_ghost_create_ext (forest); } forest->do_ghost = 0; } @@ -4266,8 +4267,8 @@ t8_forest_reset (t8_forest_t *pforest) t8_forest_ghost_unref (&forest->ghosts); } /* Destroy the ghost_interface class if it exist */ - if (forest->ghost_interface != NULL){ - t8_forest_ghost_interface_unref(&(forest->ghost_interface)); + if (forest->ghost_interface != NULL) { + t8_forest_ghost_interface_unref (&(forest->ghost_interface)); } /* we have taken ownership on calling t8_forest_set_* */ if (forest->scheme_cxx != NULL) { diff --git a/src/t8_forest/t8_forest_balance.cxx b/src/t8_forest/t8_forest_balance.cxx index ef5e6eae7d..89f0e14020 100644 --- a/src/t8_forest/t8_forest_balance.cxx +++ b/src/t8_forest/t8_forest_balance.cxx @@ -173,16 +173,16 @@ t8_forest_balance (t8_forest_t forest, int repartition) t8_forest_ref (forest_from); if (forest->set_from->ghosts == NULL) { - // forest->set_from->ghost_type = T8_GHOST_FACES; - if(forest->set_from->ghost_interface == NULL){ - forest->set_from->ghost_interface = t8_forest_ghost_interface_face_new(3); + // forest->set_from->ghost_type = T8_GHOST_FACES; + if (forest->set_from->ghost_interface == NULL) { + forest->set_from->ghost_interface = t8_forest_ghost_interface_face_new (3); create_ghost_interface = 1; } t8_forest_ghost_create_topdown (forest->set_from); - if(create_ghost_interface){ - t8_forest_ghost_interface_unref( &(forest->set_from->ghost_interface)); + if (create_ghost_interface) { + t8_forest_ghost_interface_unref (&(forest->set_from->ghost_interface)); forest->set_from->ghost_interface = NULL; - } + } } while (!done_global) { diff --git a/src/t8_forest/t8_forest_general.h b/src/t8_forest/t8_forest_general.h index 73339b5a5d..5c2b2c4f22 100644 --- a/src/t8_forest/t8_forest_general.h +++ b/src/t8_forest/t8_forest_general.h @@ -41,11 +41,11 @@ typedef struct t8_tree *t8_tree_t; /** This type controls, which neighbors count as ghost elements. * Currently, we support face-neighbors. Vertex and edge neighbors will eventually be added. */ typedef enum { - T8_GHOST_NONE = 0, /**< Do not create ghost layer. */ - T8_GHOST_FACES, /**< Consider all face (codimension 1) neighbors. */ - T8_GHOST_EDGES, /**< Consider all edge (codimension 2) and face neighbors. */ - T8_GHOST_VERTICES, /**< Consider all vertex (codimension 3) and edge and face neighbors. */ - T8_GHOST_USERDEFINED/** If the user define by his self a step_1 or step_2 function*/ + T8_GHOST_NONE = 0, /**< Do not create ghost layer. */ + T8_GHOST_FACES, /**< Consider all face (codimension 1) neighbors. */ + T8_GHOST_EDGES, /**< Consider all edge (codimension 2) and face neighbors. */ + T8_GHOST_VERTICES, /**< Consider all vertex (codimension 3) and edge and face neighbors. */ + T8_GHOST_USERDEFINED /** If the user define by his self a step_1 or step_2 function*/ } t8_ghost_type_t; /** This typedef is needed as a helper construct to @@ -365,21 +365,21 @@ t8_forest_set_ghost (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_typ * If 2, the iterative algorithm for unbalanced forests. * If 3, the top-down search algorithm for unbalanced forests. * \see t8_forest_set_ghost - * \note this function creats an ghost_interface obcejct and call \ref t8_forest_set_ghost_ext_new + * \note this function creates an ghost_interface obcejct and call \ref t8_forest_set_ghost_ext_new */ void t8_forest_set_ghost_ext (t8_forest_t forest, int do_ghost, t8_ghost_type_t ghost_type, int ghost_version); /** Set a ghost_interface - * In application schoud only used if the user creats its own ghost_interface class (type = userderdefined) + * In application schoud only used if the user creates its own ghost_interface class (type = userderdefined) * \param [in] forest the fores * \param [in] do_ghost --- * \param [in] ghost_interface pointer to an object of the class ghost_interface or a derived class * The forest takes ownership of the ghost_interface - * \note if the forest has alrady a ghost_interface, the old one will be unref and the new one will be set. + * \note if the forest has already a ghost_interface, the old one will be unref and the new one will be set. */ void -t8_forest_set_ghost_ext_new (t8_forest_t forest, int do_ghost, t8_forest_ghost_interface_c * ghost_interface); +t8_forest_set_ghost_ext_new (t8_forest_t forest, int do_ghost, t8_forest_ghost_interface_c *ghost_interface); /* TODO: use assertions and document that the forest_set (..., from) and * set_load are mutually exclusive. */ diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index 5b86bbb1cf..2615ca4e31 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -1395,7 +1395,7 @@ void t8_forest_ghost_create_ext (t8_forest_t forest) { t8_forest_ghost_t ghost; - t8_forest_ghost_interface_c * ghost_interface; + t8_forest_ghost_interface_c *ghost_interface; T8_ASSERT (t8_forest_is_committed (forest)); T8_ASSERT (forest->ghost_interface != NULL); @@ -1422,7 +1422,7 @@ t8_forest_ghost_create_ext (t8_forest_t forest) t8_global_productionf ("Start ghost at %f %f\n", sc_MPI_Wtime (), forest->profile->ghost_runtime); } - ghost_interface->do_ghost(forest); + ghost_interface->do_ghost (forest); ghost = forest->ghosts; @@ -1456,7 +1456,7 @@ t8_forest_ghost_create (t8_forest_t forest) T8_ASSERT (t8_forest_is_committed (forest)); if (forest->mpisize > 1) { /* call unbalanced version of ghost algorithm */ - T8_ASSERT(t8_forest_ghost_interface_face_verison(forest->ghost_interface) == 2); + T8_ASSERT (t8_forest_ghost_interface_face_version (forest->ghost_interface) == 2); t8_forest_ghost_create_ext (forest); } } @@ -1468,7 +1468,7 @@ t8_forest_ghost_create_balanced_only (t8_forest_t forest) if (forest->mpisize > 1) { /* TODO: assert that forest is balanced */ /* Call balanced version of ghost algorithm */ - T8_ASSERT(t8_forest_ghost_interface_face_verison(forest->ghost_interface) == 1); + T8_ASSERT (t8_forest_ghost_interface_face_version (forest->ghost_interface) == 1); t8_forest_ghost_create_ext (forest); } } @@ -1477,8 +1477,8 @@ void t8_forest_ghost_create_topdown (t8_forest_t forest) { T8_ASSERT (t8_forest_is_committed (forest)); - T8_ASSERT(forest->ghost_interface != NULL); - T8_ASSERT(t8_forest_ghost_interface_face_verison(forest->ghost_interface) == 3); + T8_ASSERT (forest->ghost_interface != NULL); + T8_ASSERT (t8_forest_ghost_interface_face_version (forest->ghost_interface) == 3); t8_forest_ghost_create_ext (forest); } @@ -1886,42 +1886,46 @@ t8_forest_ghost_destroy (t8_forest_ghost_t *pghost) T8_ASSERT (*pghost == NULL); } - /** * Implementation of the ghost-interface - * Wrapper for the abstracte base classe - * Implementation of the comunication steps - * and implementation of the dreived classe search + * Wrapper for the abstracte base classes + * Implementation of the communication steps + * and implementation of the dreived class search */ -t8_ghost_type_t -t8_forest_ghost_interface_get_type(t8_forest_ghost_interface_c * ghost_interface){ +t8_ghost_type_t +t8_forest_ghost_interface_get_type (t8_forest_ghost_interface_c *ghost_interface) +{ T8_ASSERT (ghost_interface != NULL); - return ghost_interface->t8_ghost_get_type(); + return ghost_interface->t8_ghost_get_type (); } -void t8_forest_ghost_interface_ref(t8_forest_ghost_interface_c * ghost_interface){ +void +t8_forest_ghost_interface_ref (t8_forest_ghost_interface_c *ghost_interface) +{ T8_ASSERT (ghost_interface != NULL); - ghost_interface->ref(); + ghost_interface->ref (); } -void t8_forest_ghost_interface_unref(t8_forest_ghost_interface_c ** pghost_interface){ - t8_forest_ghost_interface_c * ghost_interface; +void +t8_forest_ghost_interface_unref (t8_forest_ghost_interface_c **pghost_interface) +{ + t8_forest_ghost_interface_c *ghost_interface; T8_ASSERT (pghost_interface != NULL); ghost_interface = *pghost_interface; T8_ASSERT (ghost_interface != NULL); - ghost_interface->unref(); + ghost_interface->unref (); } - /** * Abstract Base Class */ void -t8_forest_ghost_interface::communicate_ownerships(t8_forest_t forest){ +t8_forest_ghost_interface::communicate_ownerships (t8_forest_t forest) +{ t8_global_productionf (" t8_forest_ghost_interface_faces::t8_ghost_step_1_allocate \n"); if (forest->element_offsets == NULL) { /* create element offset array if not done already */ @@ -1929,20 +1933,21 @@ t8_forest_ghost_interface::communicate_ownerships(t8_forest_t forest){ t8_forest_partition_create_offsets (forest); } if (forest->tree_offsets == NULL) { - /* Create tree offset array if not done already */ - memory_flag = memory_flag | CREATE_TREE_ARRAY; - t8_forest_partition_create_tree_offsets (forest); + /* Create tree offset array if not done already */ + memory_flag = memory_flag | CREATE_TREE_ARRAY; + t8_forest_partition_create_tree_offsets (forest); } if (forest->global_first_desc == NULL) { - /* Create global first desc array if not done already */ - memory_flag = memory_flag | CREATE_GFIRST_DESC_ARRAY; - t8_forest_partition_create_first_desc (forest); + /* Create global first desc array if not done already */ + memory_flag = memory_flag | CREATE_GFIRST_DESC_ARRAY; + t8_forest_partition_create_first_desc (forest); } } void -t8_forest_ghost_interface::communicate_ghost_elements(t8_forest_t forest){ - t8_forest_ghost_t ghost = forest->ghosts; // TODO: make sure, that ghost is init +t8_forest_ghost_interface::communicate_ghost_elements (t8_forest_t forest) +{ + t8_forest_ghost_t ghost = forest->ghosts; // TODO: make sure, that ghost is init t8_ghost_mpi_send_info_t *send_info; sc_MPI_Request *requests; @@ -1956,63 +1961,65 @@ t8_forest_ghost_interface::communicate_ghost_elements(t8_forest_t forest){ t8_forest_ghost_send_end (forest, ghost, send_info, requests); } - void -t8_forest_ghost_interface::clean_up(t8_forest_t forest){ +t8_forest_ghost_interface::clean_up (t8_forest_t forest) +{ t8_global_productionf (" t8_forest_ghost_interface_faces::t8_ghost_step_1_clean_up \n"); - if (memory_flag & CREATE_GFIRST_DESC_ARRAY){ - /* Free the offset memory, if created */ - t8_shmem_array_destroy (&forest->element_offsets); - } - if (memory_flag & CREATE_TREE_ARRAY) { - /* Free the offset memory, if created */ - t8_shmem_array_destroy (&forest->tree_offsets); - } - if (memory_flag & CREATE_GFIRST_DESC_ARRAY) { - /* Free the offset memory, if created */ - t8_shmem_array_destroy (&forest->global_first_desc); - } + if (memory_flag & CREATE_GFIRST_DESC_ARRAY) { + /* Free the offset memory, if created */ + t8_shmem_array_destroy (&forest->element_offsets); + } + if (memory_flag & CREATE_TREE_ARRAY) { + /* Free the offset memory, if created */ + t8_shmem_array_destroy (&forest->tree_offsets); + } + if (memory_flag & CREATE_GFIRST_DESC_ARRAY) { + /* Free the offset memory, if created */ + t8_shmem_array_destroy (&forest->global_first_desc); + } } /** * Derived class ghost_w_search */ -t8_forest_ghost_w_search::t8_forest_ghost_w_search(t8_ghost_type_t ghost_type) - : t8_forest_ghost_interface(ghost_type) +t8_forest_ghost_w_search::t8_forest_ghost_w_search (t8_ghost_type_t ghost_type): t8_forest_ghost_interface (ghost_type) { - T8_ASSERT(ghost_type != T8_GHOST_NONE); - T8_ASSERT(ghost_type == T8_GHOST_FACES); // currently no other typs are suportet - if(ghost_type == T8_GHOST_FACES){ + T8_ASSERT (ghost_type != T8_GHOST_NONE); + T8_ASSERT (ghost_type == T8_GHOST_FACES); // currently no other typs are suportet + if (ghost_type == T8_GHOST_FACES) { search_fn = t8_forest_ghost_search_boundary; } - SC_CHECK_ABORT(ghost_type != T8_GHOST_USERDEFINED, "use t8_forest_ghost_w_search(t8_forest_search_query_fn serach_function) for userdefined ghost") ; + SC_CHECK_ABORT (ghost_type != T8_GHOST_USERDEFINED, + "use t8_forest_ghost_w_search(t8_forest_search_query_fn search_function) for userdefined ghost"); } void -t8_forest_ghost_w_search::do_ghost(t8_forest_t forest){ +t8_forest_ghost_w_search::do_ghost (t8_forest_t forest) +{ - communicate_ownerships(forest); + communicate_ownerships (forest); if (t8_forest_get_local_num_elements (forest) > 0) { - if ( t8_ghost_get_type() == T8_GHOST_NONE) { - t8_debugf ("WARNING: Trying to construct ghosts with ghost_type NONE. " - "Ghost layer is not constructed.\n"); - return; + if (t8_ghost_get_type () == T8_GHOST_NONE) { + t8_debugf ("WARNING: Trying to construct ghosts with ghost_type NONE. " + "Ghost layer is not constructed.\n"); + return; } /* Initialize the ghost structure */ t8_forest_ghost_init (&forest->ghosts, ghost_type); - search_for_ghost_elements(forest); + search_for_ghost_elements (forest); - communicate_ghost_elements(forest); + communicate_ghost_elements (forest); } - clean_up(forest); + clean_up (forest); } void -t8_forest_ghost_w_search::search_for_ghost_elements(t8_forest_t forest){ +t8_forest_ghost_w_search::search_for_ghost_elements (t8_forest_t forest) +{ t8_forest_ghost_boundary_data_t data; void *store_user_data = NULL; @@ -2045,134 +2052,128 @@ t8_forest_ghost_w_search::search_for_ghost_elements(t8_forest_t forest){ #endif } - -t8_forest_ghost_face::t8_forest_ghost_face(int version) - : t8_forest_ghost_w_search(T8_GHOST_FACES, t8_forest_ghost_search_boundary) , version(version) - { - T8_ASSERT( 1<= version && version <= 3); - } - - +t8_forest_ghost_face::t8_forest_ghost_face (int version) + : t8_forest_ghost_w_search (T8_GHOST_FACES, t8_forest_ghost_search_boundary), version (version) +{ + T8_ASSERT (1 <= version && version <= 3); +} void -t8_forest_ghost_face::search_for_ghost_elements(t8_forest_t forest){ +t8_forest_ghost_face::search_for_ghost_elements (t8_forest_t forest) +{ t8_global_productionf (" t8_forest_ghost_face::step_2 \n"); - T8_ASSERT( forest->ghosts != NULL); + T8_ASSERT (forest->ghosts != NULL); t8_forest_ghost_t ghost = forest->ghosts; if (version == 3) { - t8_global_productionf ("t8_forest_ghost_face::step_2: t8_forest_ghost_fill_remote_v3(forest)\n"); - t8_forest_ghost_fill_remote_v3 (forest); + t8_global_productionf ("t8_forest_ghost_face::step_2: t8_forest_ghost_fill_remote_v3(forest)\n"); + t8_forest_ghost_fill_remote_v3 (forest); } else { - /* Construct the remote elements and processes. */ - t8_global_productionf ("t8_forest_ghost_face::step_2: t8_forest_ghost_fill_remote (forest, ghost, ghost_version != 1)\n"); - t8_forest_ghost_fill_remote (forest, ghost, version != 1); + /* Construct the remote elements and processes. */ + t8_global_productionf ( + "t8_forest_ghost_face::step_2: t8_forest_ghost_fill_remote (forest, ghost, ghost_version != 1)\n"); + t8_forest_ghost_fill_remote (forest, ghost, version != 1); } } - - -/* warpper for derived face class */ -t8_forest_ghost_interface_c * -t8_forest_ghost_interface_face_new(int version){ +/* Wrapper for derived face class */ +t8_forest_ghost_interface_c * +t8_forest_ghost_interface_face_new (int version) +{ t8_debugf ("Call t8_forest_ghost_interface_face_new.\n"); - T8_ASSERT( 1 <= version && version <= 3 ); - t8_forest_ghost_face * ghost_interface = new t8_forest_ghost_face(version); + T8_ASSERT (1 <= version && version <= 3); + t8_forest_ghost_face *ghost_interface = new t8_forest_ghost_face (version); return (t8_forest_ghost_interface_c *) ghost_interface; } - -t8_forest_ghost_interface_c * -t8_forest_ghost_interface_stencil_new(){ +t8_forest_ghost_interface_c * +t8_forest_ghost_interface_stencil_new () +{ t8_debugf ("Call t8_forest_ghost_interface_stencil_new.\n"); - t8_forest_ghost_stencil * ghost_interface = new t8_forest_ghost_stencil(); + t8_forest_ghost_stencil *ghost_interface = new t8_forest_ghost_stencil (); return (t8_forest_ghost_interface_c *) ghost_interface; } -int -t8_forest_ghost_interface_face_verison(t8_forest_ghost_interface_c * ghost_interface){ - T8_ASSERT(ghost_interface != NULL); - T8_ASSERT(ghost_interface->t8_ghost_get_type() == T8_GHOST_FACES); - t8_forest_ghost_face * ghost_interface_passed = (t8_forest_ghost_face *) ghost_interface; +int +t8_forest_ghost_interface_face_version (t8_forest_ghost_interface_c *ghost_interface) +{ + T8_ASSERT (ghost_interface != NULL); + T8_ASSERT (ghost_interface->t8_ghost_get_type () == T8_GHOST_FACES); + t8_forest_ghost_face *ghost_interface_passed = (t8_forest_ghost_face *) ghost_interface; - return ghost_interface_passed->get_version(); + return ghost_interface_passed->get_version (); } - /** * Derived class for a stencil on an uniform mesh. */ - - void -t8_forest_ghost_stencil::do_ghost(t8_forest_t forest){ +t8_forest_ghost_stencil::do_ghost (t8_forest_t forest) +{ /** * Compute bounds for elements */ t8_forest_ghost_init (&forest->ghosts, ghost_type); - t8_locidx_t current_index; // counter over all local elements - t8_locidx_t ielement, num_elements_in_tree; // count over the local elements in a tree + t8_locidx_t current_index; // counter over all local elements + t8_locidx_t ielement, num_elements_in_tree; // count over the local elements in a tree t8_eclass_scheme_c *eclass_scheme; t8_eclass_t tree_class; const t8_element_t *element; - - SC_CHECK_ABORT( t8_forest_get_num_global_trees(forest) == 1, "more than one tree in ghost for stencil" ); + SC_CHECK_ABORT (t8_forest_get_num_global_trees (forest) == 1, "more than one tree in ghost for stencil"); tree_class = t8_forest_get_tree_class (forest, 0); eclass_scheme = t8_forest_get_eclass_scheme (forest, tree_class); - SC_CHECK_ABORT( tree_class == T8_ECLASS_QUAD, "only forest with eclass quad are possible for ghost for stencil" ); + SC_CHECK_ABORT (tree_class == T8_ECLASS_QUAD, "only forest with eclass quad are possible for ghost for stencil"); num_elements_in_tree = t8_forest_get_tree_num_elements (forest, 0); - - for (ielement = 0; ielement < num_elements_in_tree; ++ielement, ++current_index){ + + for (ielement = 0; ielement < num_elements_in_tree; ++ielement, ++current_index) { element = t8_forest_get_element_in_tree (forest, 0, ielement); /** compute the stencil elements */ - add_stencil_to_ghost(forest, element, eclass_scheme, eclass_scheme->t8_element_level(element), tree_class, 0, ielement); + add_stencil_to_ghost (forest, element, eclass_scheme, eclass_scheme->t8_element_level (element), tree_class, 0, + ielement); } - communicate_ghost_elements(forest); + communicate_ghost_elements (forest); } - - /** * Function to compute the owner of an element * \param [in] forest a commit uniform forest which is partitioned - * \param [in] eclass_scheme shoud fit to the element + * \param [in] eclass_scheme should fit to the element * \param [in] element compute owner of this * \param [out] owner - * \note: the function use, that the linear id of the element is the same as the golbal index + * \note: the function use, that the linear id of the element is the same as the global index * for example this is true for uniform meshes. * the function also use, that the forest is partitioned. * The owner is found in O(1) */ int -t8_forest_ghost_interface_stencil_get_remot_rank(t8_forest_t forest, t8_eclass_scheme_c * eclass_scheme, t8_element_t *element){ - t8_gloidx_t golbal_num_elements = t8_forest_get_global_num_elements(forest); - t8_linearidx_t lin_id = eclass_scheme->t8_element_get_linear_id( element, eclass_scheme->t8_element_level(element)); - - t8_linearidx_t b_0 = golbal_num_elements / forest->mpisize ; - t8_linearidx_t r = golbal_num_elements % forest->mpisize ; - - int p_guess = lin_id / b_0 ; - if( p_guess < 2 || r == 0){ +t8_forest_ghost_interface_stencil_get_remote_rank (t8_forest_t forest, t8_eclass_scheme_c *eclass_scheme, + t8_element_t *element) +{ + t8_gloidx_t global_num_elements = t8_forest_get_global_num_elements (forest); + t8_linearidx_t lin_id = eclass_scheme->t8_element_get_linear_id (element, eclass_scheme->t8_element_level (element)); + + t8_linearidx_t b_0 = global_num_elements / forest->mpisize; + t8_linearidx_t r = global_num_elements % forest->mpisize; + + int p_guess = lin_id / b_0; + if (p_guess < 2 || r == 0) { return p_guess; } - int x = ( p_guess * r ) / forest->mpisize ; + int x = (p_guess * r) / forest->mpisize; - int owner = ( lin_id - x ) / b_0 ; + int owner = (lin_id - x) / b_0; return owner; - } - - /** - * Add this stencil (elements N and F) for elmenet E to ghost + * Add this stencil (elements N and F) for element E to ghost * * N * | @@ -2185,52 +2186,60 @@ t8_forest_ghost_interface_stencil_get_remot_rank(t8_forest_t forest, t8_eclass_s * N */ void -t8_forest_ghost_stencil::add_stencil_to_ghost(t8_forest_t forest, const t8_element_t * element, t8_eclass_scheme_c *eclass_scheme, int level, - t8_eclass_t tree_class, t8_locidx_t ltreeid, t8_locidx_t ielement){ - - t8_locidx_t iface_neig, ineig; - t8_element_t * face_neig; - t8_element_t * neig; +t8_forest_ghost_stencil::add_stencil_to_ghost (t8_forest_t forest, const t8_element_t *element, + t8_eclass_scheme_c *eclass_scheme, int level, t8_eclass_t tree_class, + t8_locidx_t ltreeid, t8_locidx_t ielement) +{ + + t8_locidx_t iface_neighbor, ineighbor; + t8_element_t *face_neighbor; + t8_element_t *neighbor; t8_eclass_t eclass = t8_forest_get_eclass (forest, 0); /** * First loop over the F elements, this are the face-neighbors of E */ - for ( iface_neig = 0; iface_neig < eclass_scheme->t8_element_num_faces(element); ++iface_neig){ - eclass_scheme->t8_element_new (1,&face_neig); - eclass_scheme->t8_element_new (1,&neig); + for (iface_neighbor = 0; iface_neighbor < eclass_scheme->t8_element_num_faces (element); ++iface_neighbor) { + eclass_scheme->t8_element_new (1, &face_neighbor); + eclass_scheme->t8_element_new (1, &neighbor); /* Compute one F */ - int neight_face; - int face_neig_exists = eclass_scheme->t8_element_face_neighbor_inside(element, face_neig, iface_neig, &neight_face); + int neighbor_face; + int face_neighbor_exists + = eclass_scheme->t8_element_face_neighbor_inside (element, face_neighbor, iface_neighbor, &neighbor_face); /* if the F exists */ - if(face_neig_exists){ - /* compute the mpirank for F, and if its not ownes by this prozess, add it to gost */ - int remote_rank = t8_forest_ghost_interface_stencil_get_remot_rank(forest, eclass_scheme, face_neig); - T8_ASSERT( remote_rank == t8_forest_element_find_owner_ext(forest, 0, face_neig, eclass, 0, forest->mpisize - 1, remote_rank, 0) ); - T8_ASSERT( 0 <= remote_rank && remote_rank < forest->mpisize ); - if(forest->mpirank != remote_rank){ + if (face_neighbor_exists) { + /* compute the mpirank for F, and if its not owns by this process, add it to ghost */ + int remote_rank = t8_forest_ghost_interface_stencil_get_remote_rank (forest, eclass_scheme, face_neighbor); + T8_ASSERT ( + remote_rank + == t8_forest_element_find_owner_ext (forest, 0, face_neighbor, eclass, 0, forest->mpisize - 1, remote_rank, 0)); + T8_ASSERT (0 <= remote_rank && remote_rank < forest->mpisize); + if (forest->mpirank != remote_rank) { t8_ghost_add_remote (forest, forest->ghosts, remote_rank, ltreeid, element, ielement); } - /* Loop over the face neighbors of F (exept of E), this are the N */ - for( ineig = 0; ineig < eclass_scheme->t8_element_num_faces(face_neig); ++ineig ){ - if(ineig != neight_face){ + /* Loop over the face neighbors of F (except of E), this are the N */ + for (ineighbor = 0; ineighbor < eclass_scheme->t8_element_num_faces (face_neighbor); ++ineighbor) { + if (ineighbor != neighbor_face) { /* Compute N */ - int neight_neig_face; - int neig_exists = eclass_scheme->t8_element_face_neighbor_inside(face_neig, neig, ineig, &neight_neig_face); - if(neig_exists){ - /* compute the mpirank for N, and if its not ownes by this prozess, add it to gost */ - remote_rank = t8_forest_ghost_interface_stencil_get_remot_rank(forest, eclass_scheme, neig); - T8_ASSERT(remote_rank == t8_forest_element_find_owner_ext(forest, 0, neig, eclass, 0, forest->mpisize -1, remote_rank ,0)); - T8_ASSERT( 0 <= remote_rank && remote_rank < forest->mpisize ); - if(forest->mpirank != remote_rank){ + int neighbor_neighbor_face; + int neighbor_exists = eclass_scheme->t8_element_face_neighbor_inside (face_neighbor, neighbor, ineighbor, + &neighbor_neighbor_face); + if (neighbor_exists) { + /* compute the mpirank for N, and if its not owns by this process, add it to ghost */ + remote_rank = t8_forest_ghost_interface_stencil_get_remote_rank (forest, eclass_scheme, neighbor); + T8_ASSERT (remote_rank + == t8_forest_element_find_owner_ext (forest, 0, neighbor, eclass, 0, forest->mpisize - 1, + remote_rank, 0)); + T8_ASSERT (0 <= remote_rank && remote_rank < forest->mpisize); + if (forest->mpirank != remote_rank) { t8_ghost_add_remote (forest, forest->ghosts, remote_rank, ltreeid, element, ielement); } } } } } - eclass_scheme->t8_element_destroy(1, &face_neig); - eclass_scheme->t8_element_destroy(1, &neig); + eclass_scheme->t8_element_destroy (1, &face_neighbor); + eclass_scheme->t8_element_destroy (1, &neighbor); } } diff --git a/src/t8_forest/t8_forest_ghost.h b/src/t8_forest/t8_forest_ghost.h index 9236f54312..8431874ece 100644 --- a/src/t8_forest/t8_forest_ghost.h +++ b/src/t8_forest/t8_forest_ghost.h @@ -164,7 +164,7 @@ t8_forest_ghost_destroy (t8_forest_ghost_t *pghost); /** Part of step 2 of the ghost_creat_ext * for ghost_type face - * Is declared, so that ghost_interface_face can use ist + * Is declared, so that ghost_interface_face can use it * \see t8_forest_ghost_interface_faces::t8_ghost_step_2 * \param [in,out] forest The forest. */ @@ -173,14 +173,13 @@ t8_forest_ghost_fill_remote_v3 (t8_forest_t forest); /** Part of step 2 of the ghost_creat_ext * for ghost_type face - * Is declared, so that ghost_interface_face can use ist + * Is declared, so that ghost_interface_face can use it * \see t8_forest_ghost_interface_faces::t8_ghost_step_2 * \param [in,out] forest The forest. */ void t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int ghost_method); - /** Create one layer of ghost elements for a forest. * \see t8_forest_set_ghost * \param [in,out] forest The forest. diff --git a/src/t8_forest/t8_forest_ghost_interface.h b/src/t8_forest/t8_forest_ghost_interface.h index 181bcf2923..7442f5f98e 100644 --- a/src/t8_forest/t8_forest_ghost_interface.h +++ b/src/t8_forest/t8_forest_ghost_interface.h @@ -25,17 +25,14 @@ #include - T8_EXTERN_C_BEGIN (); - /** This typedef holds virtual functions for a particular ghost interface. * We need it so that we can use t8_ghost_interface_c pointers in .c files * without them seeing the actual C++ code (and then not compiling) */ typedef struct t8_forest_ghost_interface t8_forest_ghost_interface_c; - T8_EXTERN_C_END (); -#endif /* !T8_FOREST_GHOST_INTERFACE_H */ \ No newline at end of file +#endif /* !T8_FOREST_GHOST_INTERFACE_H */ diff --git a/src/t8_forest/t8_forest_ghost_interface.hxx b/src/t8_forest/t8_forest_ghost_interface.hxx index 669d37e53c..1d23b8348e 100644 --- a/src/t8_forest/t8_forest_ghost_interface.hxx +++ b/src/t8_forest/t8_forest_ghost_interface.hxx @@ -35,108 +35,103 @@ T8_EXTERN_C_BEGIN (); * Flags for first step function * store in the flags which memory was allocated */ -enum t8_ghost_interface_face_flag { - CREATE_ELEMENT_ARRAY = 1, - CREATE_TREE_ARRAY = 2, - CREATE_GFIRST_DESC_ARRAY= 4 -}; +enum t8_ghost_interface_face_flag { CREATE_ELEMENT_ARRAY = 1, CREATE_TREE_ARRAY = 2, CREATE_GFIRST_DESC_ARRAY = 4 }; struct t8_forest_ghost_interface { - public: - /** + public: + /** * Constructor */ - t8_forest_ghost_interface() - { - t8_refcount_init (&rc); - t8_debugf ("Constructed the a None ghost_interface.\n"); - } + t8_forest_ghost_interface () + { + t8_refcount_init (&rc); + t8_debugf ("Constructed the a None ghost_interface.\n"); + } - /** + /** * Destructor. */ - virtual ~t8_forest_ghost_interface () - { - if (sc_refcount_is_active (&rc)) { - T8_ASSERT (t8_refcount_is_last (&rc)); - t8_refcount_unref (&rc); - } - t8_debugf ("Deleted the ghost_interface.\n"); + virtual ~t8_forest_ghost_interface () + { + if (sc_refcount_is_active (&rc)) { + T8_ASSERT (t8_refcount_is_last (&rc)); + t8_refcount_unref (&rc); } + t8_debugf ("Deleted the ghost_interface.\n"); + } - /** + /** * Get the type of the ghost_interface * \return the type */ - inline t8_ghost_type_t - t8_ghost_get_type() const - { - return ghost_type; - } + inline t8_ghost_type_t + t8_ghost_get_type () const + { + return ghost_type; + } - /** + /** * Increase the reference count of the ghost interface. */ - virtual inline void - ref () - { - t8_refcount_ref (&rc); - } + virtual inline void + ref () + { + t8_refcount_ref (&rc); + } - /** + /** * Decrease the reference count of the ghost_interface. * If the reference count reaches zero, the ghost_interface is deleted. */ - virtual inline void - unref () - { - if (t8_refcount_unref (&rc)) { - t8_debugf ("Deleting the ghost_interface.\n"); - delete this; - } + virtual inline void + unref () + { + if (t8_refcount_unref (&rc)) { + t8_debugf ("Deleting the ghost_interface.\n"); + delete this; } + } - /** Create one layer of ghost elements for a forest. + /** Create one layer of ghost elements for a forest. * \see t8_forest_set_ghost * \param [in,out] forest The forest. * \a forest must be committed before calling this function. */ - virtual void - do_ghost(t8_forest_t forest) + virtual void + do_ghost (t8_forest_t forest) = 0; - protected: - /** - * Compute and collect ownerships to create the nessesary offset + protected: + /** + * Compute and collect ownerships to create the necessary offset * for elements, trees and first descandance */ - virtual void - communicate_ownerships(t8_forest_t forest); + virtual void + communicate_ownerships (t8_forest_t forest); - virtual void - communicate_ghost_elements(t8_forest_t forest); + virtual void + communicate_ghost_elements (t8_forest_t forest); - virtual void - clean_up(t8_forest_t forest); + virtual void + clean_up (t8_forest_t forest); - /** + /** * Constructor for the derivided classes to set the korrekt type for them. * \param [in] g_type The type (faces, edges, userdefind, ...) of the ghost_interface */ - explicit t8_forest_ghost_interface(t8_ghost_type_t g_type) : ghost_type(g_type) { - t8_refcount_init (&rc); - t8_debugf ("Constructed a ghost_interface.\n"); - }; - /** type of the ghost_interface */ - t8_ghost_type_t ghost_type{T8_GHOST_NONE}; - /** The reference count of the ghost_interface. TODO: Replace by shared_ptr when forest becomes a class. */ - t8_refcount_t rc; - int32_t memory_flag{}; + explicit t8_forest_ghost_interface (t8_ghost_type_t g_type): ghost_type (g_type) + { + t8_refcount_init (&rc); + t8_debugf ("Constructed a ghost_interface.\n"); + }; + /** type of the ghost_interface */ + t8_ghost_type_t ghost_type { T8_GHOST_NONE }; + /** The reference count of the ghost_interface. TODO: Replace by shared_ptr when forest becomes a class. */ + t8_refcount_t rc; + int32_t memory_flag {}; }; - - T8_EXTERN_C_END (); #endif /* !T8_FOREST_GHOST_INTERFACE_HXX */ diff --git a/src/t8_forest/t8_forest_ghost_interface_faces.hxx b/src/t8_forest/t8_forest_ghost_interface_faces.hxx index b8b6d80390..6fc10374dd 100644 --- a/src/t8_forest/t8_forest_ghost_interface_faces.hxx +++ b/src/t8_forest/t8_forest_ghost_interface_faces.hxx @@ -20,8 +20,6 @@ // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // */ - - // #ifndef T8_GHOST_INTERFACE_FACE_H // #define T8_GHOST_INTERFACE_FACE_H @@ -42,7 +40,7 @@ // { // public: // /** -// * Construtor +// * Constructor // */ // t8_forest_ghost_interface_faces(); @@ -60,14 +58,12 @@ // virtual void // do_ghost(t8_forest forest) override; - // protected: - + // int ghost_version; // int32_t flag_step_1; // }; - // #endif /* !T8_GHOST_INTERFACE_FACE_H */ diff --git a/src/t8_forest/t8_forest_ghost_interface_wrapper.h b/src/t8_forest/t8_forest_ghost_interface_wrapper.h index e3b0f14749..77f767dd12 100644 --- a/src/t8_forest/t8_forest_ghost_interface_wrapper.h +++ b/src/t8_forest/t8_forest_ghost_interface_wrapper.h @@ -27,44 +27,48 @@ #include #include - T8_EXTERN_C_BEGIN (); - /** * Satisfy the C interface of forest * Create a new ghost_interface with given version */ -t8_forest_ghost_interface_c * t8_forest_ghost_interface_face_new(int version); +t8_forest_ghost_interface_c * +t8_forest_ghost_interface_face_new (int version); -t8_forest_ghost_interface_c * t8_forest_ghost_interface_stencil_new(); +t8_forest_ghost_interface_c * +t8_forest_ghost_interface_stencil_new (); /** * Satisfy the C interface of forest * Return for a ghost_interface of Type FACE the ghost_algorithm / ghost_version */ -int t8_forest_ghost_interface_face_verison(t8_forest_ghost_interface_c * ghost_interface); +int +t8_forest_ghost_interface_face_version (t8_forest_ghost_interface_c *ghost_interface); /** * Satisfy the C interface of forest * Return the type of a ghost_interface */ -t8_ghost_type_t t8_forest_ghost_interface_get_type(t8_forest_ghost_interface_c * ghost_interface); +t8_ghost_type_t +t8_forest_ghost_interface_get_type (t8_forest_ghost_interface_c *ghost_interface); /** * Satisfy the C interface of forest * Do a ref on the ghost_interface * Needed in t8_forest_commit */ -void t8_forest_ghost_interface_ref(t8_forest_ghost_interface_c * ghost_interface); +void +t8_forest_ghost_interface_ref (t8_forest_ghost_interface_c *ghost_interface); /** * Satisfy the C interface of forest * Do a unref on the ghost_interface * Needed in t8_forest_commit and t8_forest_set_ghost_ext_new */ -void t8_forest_ghost_interface_unref(t8_forest_ghost_interface_c ** pghost_interface); +void +t8_forest_ghost_interface_unref (t8_forest_ghost_interface_c **pghost_interface); T8_EXTERN_C_END (); -#endif /* !T8_FOREST_GHOST_INTERFACE_WRAPPER_H */ \ No newline at end of file +#endif /* !T8_FOREST_GHOST_INTERFACE_WRAPPER_H */ diff --git a/src/t8_forest/t8_forest_ghost_search.hxx b/src/t8_forest/t8_forest_ghost_search.hxx index cee7b8d624..89243b930a 100644 --- a/src/t8_forest/t8_forest_ghost_search.hxx +++ b/src/t8_forest/t8_forest_ghost_search.hxx @@ -20,73 +20,72 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - - #ifndef T8_GHOST_INTERFACE_FACE_H #define T8_GHOST_INTERFACE_FACE_H #include #include -#include // Definition of t8_forest_search_query_fn +#include // Definition of t8_forest_search_query_fn - -struct t8_forest_ghost_w_search : public t8_forest_ghost_interface +struct t8_forest_ghost_w_search: public t8_forest_ghost_interface { - public: - /** - * Construtor + public: + /** + * Constructor */ - t8_forest_ghost_w_search(); - - explicit t8_forest_ghost_w_search(t8_forest_search_query_fn serach_function) - : t8_forest_ghost_interface(T8_GHOST_USERDEFINED), search_fn(serach_function) - { - T8_ASSERT(serach_function != nullptr); - } + t8_forest_ghost_w_search (); + + explicit t8_forest_ghost_w_search (t8_forest_search_query_fn search_function) + : t8_forest_ghost_interface (T8_GHOST_USERDEFINED), search_fn (search_function) + { + T8_ASSERT (search_function != nullptr); + } - explicit t8_forest_ghost_w_search(t8_ghost_type_t ghost_type); + explicit t8_forest_ghost_w_search (t8_ghost_type_t ghost_type); - virtual ~t8_forest_ghost_w_search () - { - } + virtual ~t8_forest_ghost_w_search () + { + } - virtual void - do_ghost(t8_forest_t forest) override; + virtual void + do_ghost (t8_forest_t forest) override; - protected: - /** + protected: + /** * Equal to t8_forest_ghost_fill_remote_v3 * so no support for version 1 and 2 of face heigbors - * Only the search_fn parameter for serch ist not the same as in t8_forest_ghost_fill_remote_v3 + * Only the search_fn parameter for search it not the same as in t8_forest_ghost_fill_remote_v3 * use the member variable of the class */ - virtual void - search_for_ghost_elements(t8_forest_t forest); - + virtual void + search_for_ghost_elements (t8_forest_t forest); - t8_forest_ghost_w_search(t8_ghost_type_t ghost_type, t8_forest_search_query_fn search_function) - : t8_forest_ghost_interface(ghost_type), search_fn(search_function) - { - T8_ASSERT(ghost_type != T8_GHOST_NONE); - } - - t8_forest_search_query_fn search_fn{}; + t8_forest_ghost_w_search (t8_ghost_type_t ghost_type, t8_forest_search_query_fn search_function) + : t8_forest_ghost_interface (ghost_type), search_fn (search_function) + { + T8_ASSERT (ghost_type != T8_GHOST_NONE); + } + t8_forest_search_query_fn search_fn {}; }; -struct t8_forest_ghost_face : public t8_forest_ghost_w_search +struct t8_forest_ghost_face: public t8_forest_ghost_w_search { - public: - explicit t8_forest_ghost_face(int version); - - inline int get_version() const {return version;} + public: + explicit t8_forest_ghost_face (int version); - protected: - void search_for_ghost_elements(t8_forest_t forest) override; + inline int + get_version () const + { + return version; + } - private: - int version{}; -}; + protected: + void + search_for_ghost_elements (t8_forest_t forest) override; + private: + int version {}; +}; #endif /* !T8_GHOST_INTERFACE_FACE_H */ diff --git a/src/t8_forest/t8_forest_ghost_stencil.hxx b/src/t8_forest/t8_forest_ghost_stencil.hxx index e8f0209982..ecbb629c76 100644 --- a/src/t8_forest/t8_forest_ghost_stencil.hxx +++ b/src/t8_forest/t8_forest_ghost_stencil.hxx @@ -23,23 +23,23 @@ #ifndef T8_FOREST_GHOST_STENCIL_HXX #define T8_FOREST_GHOST_STENCIL_HXX - #include #include T8_EXTERN_C_BEGIN (); -struct t8_forest_ghost_stencil : t8_forest_ghost_interface +struct t8_forest_ghost_stencil: t8_forest_ghost_interface { - public: - t8_forest_ghost_stencil() : t8_forest_ghost_interface(T8_GHOST_USERDEFINED){}; - - void - do_ghost(t8_forest_t forest) override; - - protected: - void add_stencil_to_ghost(t8_forest_t forest, const t8_element_t * element, t8_eclass_scheme_c *eclass_scheme, int level, - t8_eclass_t tree_class, t8_locidx_t ltreeid, t8_locidx_t ielement); + public: + t8_forest_ghost_stencil (): t8_forest_ghost_interface (T8_GHOST_USERDEFINED) {}; + + void + do_ghost (t8_forest_t forest) override; + + protected: + void + add_stencil_to_ghost (t8_forest_t forest, const t8_element_t *element, t8_eclass_scheme_c *eclass_scheme, int level, + t8_eclass_t tree_class, t8_locidx_t ltreeid, t8_locidx_t ielement); }; T8_EXTERN_C_END (); diff --git a/src/t8_forest/t8_forest_types.h b/src/t8_forest/t8_forest_types.h index a9db73a826..95c68237c1 100644 --- a/src/t8_forest/t8_forest_types.h +++ b/src/t8_forest/t8_forest_types.h @@ -102,14 +102,14 @@ typedef struct t8_forest int do_ghost; /**< If True, a ghost layer will be created when the forest is committed. */ // t8_ghost_type_t ghost_type; /**< If a ghost layer will be created, the type of neighbors that count as ghost. */ // int ghost_algorithm; /**< Controls the algorithm used for ghost. 1 = balanced only. 2 = also unbalanced - // 3 = top-down search and unbalanced. */ - t8_forest_ghost_interface_c * ghost_interface; - void *user_data; /**< Pointer for arbitrary user data. \see t8_forest_set_user_data. */ - void (*user_function) (); /**< Pointer for arbitrary user function. \see t8_forest_set_user_function. */ - void *t8code_data; /**< Pointer for arbitrary data that is used internally. */ - int committed; /**< \ref t8_forest_commit called? */ - int mpisize; /**< Number of MPI processes. */ - int mpirank; /**< Number of this MPI process. */ + // 3 = top-down search and unbalanced. */ + t8_forest_ghost_interface_c *ghost_interface; + void *user_data; /**< Pointer for arbitrary user data. \see t8_forest_set_user_data. */ + void (*user_function) (); /**< Pointer for arbitrary user function. \see t8_forest_set_user_function. */ + void *t8code_data; /**< Pointer for arbitrary data that is used internally. */ + int committed; /**< \ref t8_forest_commit called? */ + int mpisize; /**< Number of MPI processes. */ + int mpirank; /**< Number of this MPI process. */ t8_gloidx_t first_local_tree; /**< The global index of the first local tree on this process. If first_local_tree is larger than last_local_tree then From 5010b0966192acbc6caed9032175d6fc7ba94e30 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Mon, 7 Oct 2024 15:12:23 +0200 Subject: [PATCH 25/26] Detailed description of ghost interface functions --- src/t8_forest/t8_forest_ghost.cxx | 13 ---- src/t8_forest/t8_forest_ghost_interface.hxx | 59 +++++++++++-------- .../t8_forest_ghost_interface_wrapper.h | 20 ++++--- src/t8_forest/t8_forest_ghost_search.hxx | 42 +++++++++++-- src/t8_forest/t8_forest_ghost_stencil.hxx | 32 ++++++++++ 5 files changed, 118 insertions(+), 48 deletions(-) diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index 2615ca4e31..45c821e577 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -2172,19 +2172,6 @@ t8_forest_ghost_interface_stencil_get_remote_rank (t8_forest_t forest, t8_eclass return owner; } -/** - * Add this stencil (elements N and F) for element E to ghost - * - * N - * | - * N - F - N - * | | | - * N - F - E - F - N - * | | | - * N - F - N - * | - * N - */ void t8_forest_ghost_stencil::add_stencil_to_ghost (t8_forest_t forest, const t8_element_t *element, t8_eclass_scheme_c *eclass_scheme, int level, t8_eclass_t tree_class, diff --git a/src/t8_forest/t8_forest_ghost_interface.hxx b/src/t8_forest/t8_forest_ghost_interface.hxx index 1d23b8348e..96257d18f1 100644 --- a/src/t8_forest/t8_forest_ghost_interface.hxx +++ b/src/t8_forest/t8_forest_ghost_interface.hxx @@ -34,15 +34,17 @@ T8_EXTERN_C_BEGIN (); /** * Flags for first step function * store in the flags which memory was allocated -*/ + */ enum t8_ghost_interface_face_flag { CREATE_ELEMENT_ARRAY = 1, CREATE_TREE_ARRAY = 2, CREATE_GFIRST_DESC_ARRAY = 4 }; struct t8_forest_ghost_interface { public: /** - * Constructor - */ + * Constructor: + * Creates t8_forest_ghost_interface of type non + * init the refcout + */ t8_forest_ghost_interface () { t8_refcount_init (&rc); @@ -50,8 +52,9 @@ struct t8_forest_ghost_interface } /** - * Destructor. - */ + * Destructor. + * unref the refcout + */ virtual ~t8_forest_ghost_interface () { if (sc_refcount_is_active (&rc)) { @@ -62,9 +65,9 @@ struct t8_forest_ghost_interface } /** - * Get the type of the ghost_interface - * \return the type - */ + * Get the type of the ghost_interface + * \return the type + */ inline t8_ghost_type_t t8_ghost_get_type () const { @@ -72,8 +75,8 @@ struct t8_forest_ghost_interface } /** - * Increase the reference count of the ghost interface. - */ + * Increase the reference count of the ghost interface. + */ virtual inline void ref () { @@ -81,9 +84,9 @@ struct t8_forest_ghost_interface } /** - * Decrease the reference count of the ghost_interface. - * If the reference count reaches zero, the ghost_interface is deleted. - */ + * Decrease the reference count of the ghost_interface. + * If the reference count reaches zero, the ghost_interface is deleted. + */ virtual inline void unref () { @@ -94,32 +97,41 @@ struct t8_forest_ghost_interface } /** Create one layer of ghost elements for a forest. - * \see t8_forest_set_ghost - * \param [in,out] forest The forest. - * \a forest must be committed before calling this function. - */ + * \param [in,out] forest The forest. + * \a forest must be committed before calling this function. + */ virtual void do_ghost (t8_forest_t forest) = 0; protected: /** - * Compute and collect ownerships to create the necessary offset - * for elements, trees and first descandance - */ + * Compute and collect ownerships to create the necessary offset + * for elements, trees and first descandance + * Use memory_flag to record the allocation of memory + * \note this function could be used in do_ghost + */ virtual void communicate_ownerships (t8_forest_t forest); + /** + * Exchange the list of remote ghost elements between prozesses + * \note this function could be used in do_ghost + */ virtual void communicate_ghost_elements (t8_forest_t forest); + /** + * If memory was allocated for the offset array in communicate_ownerships it is released here. + * Use memory_flag for this. + */ virtual void clean_up (t8_forest_t forest); /** - * Constructor for the derivided classes to set the korrekt type for them. - * \param [in] g_type The type (faces, edges, userdefind, ...) of the ghost_interface - */ + * Constructor for the derivided classes to set the correkt type for them. + * \param [in] g_type The type (faces, edges, userdefind, ...) of the ghost_interface + */ explicit t8_forest_ghost_interface (t8_ghost_type_t g_type): ghost_type (g_type) { t8_refcount_init (&rc); @@ -129,6 +141,7 @@ struct t8_forest_ghost_interface t8_ghost_type_t ghost_type { T8_GHOST_NONE }; /** The reference count of the ghost_interface. TODO: Replace by shared_ptr when forest becomes a class. */ t8_refcount_t rc; + /** Record allocated memory in communicate_ownerships for release in clean_up */ int32_t memory_flag {}; }; diff --git a/src/t8_forest/t8_forest_ghost_interface_wrapper.h b/src/t8_forest/t8_forest_ghost_interface_wrapper.h index 77f767dd12..4d177c0947 100644 --- a/src/t8_forest/t8_forest_ghost_interface_wrapper.h +++ b/src/t8_forest/t8_forest_ghost_interface_wrapper.h @@ -31,25 +31,31 @@ T8_EXTERN_C_BEGIN (); /** * Satisfy the C interface of forest - * Create a new ghost_interface with given version -*/ + * Create a new ghost_interface of type face with given version + */ t8_forest_ghost_interface_c * t8_forest_ghost_interface_face_new (int version); +/** + * Satisfy the C interface of forest + * Create a new ghost_interface of type stencil + */ t8_forest_ghost_interface_c * t8_forest_ghost_interface_stencil_new (); /** * Satisfy the C interface of forest - * Return for a ghost_interface of Type FACE the ghost_algorithm / ghost_version -*/ + * Return for a ghost_interface of Type FACE the ghost_algorithm / ghost_version (1, 2 or 3) + * \param [in] ghost_interface Pointer to object of class t8_forest_ghost_face + */ int t8_forest_ghost_interface_face_version (t8_forest_ghost_interface_c *ghost_interface); /** * Satisfy the C interface of forest * Return the type of a ghost_interface -*/ + * \param [in] ghost_interface Pointer to object of class t8_forest_ghost_interface or a derivet class + */ t8_ghost_type_t t8_forest_ghost_interface_get_type (t8_forest_ghost_interface_c *ghost_interface); @@ -57,7 +63,7 @@ t8_forest_ghost_interface_get_type (t8_forest_ghost_interface_c *ghost_interface * Satisfy the C interface of forest * Do a ref on the ghost_interface * Needed in t8_forest_commit -*/ + */ void t8_forest_ghost_interface_ref (t8_forest_ghost_interface_c *ghost_interface); @@ -65,7 +71,7 @@ t8_forest_ghost_interface_ref (t8_forest_ghost_interface_c *ghost_interface); * Satisfy the C interface of forest * Do a unref on the ghost_interface * Needed in t8_forest_commit and t8_forest_set_ghost_ext_new -*/ + */ void t8_forest_ghost_interface_unref (t8_forest_ghost_interface_c **pghost_interface); diff --git a/src/t8_forest/t8_forest_ghost_search.hxx b/src/t8_forest/t8_forest_ghost_search.hxx index 89243b930a..a411bcb8a4 100644 --- a/src/t8_forest/t8_forest_ghost_search.hxx +++ b/src/t8_forest/t8_forest_ghost_search.hxx @@ -31,47 +31,75 @@ struct t8_forest_ghost_w_search: public t8_forest_ghost_interface { public: /** - * Constructor + * Constructor */ t8_forest_ghost_w_search (); + /** + * Constructr of t8_forest_ghost_w_search by search_function + * If do_ghost is called on this object, + * the ghost layer will be created by an treesearch (t8_forest_search) + * with search_function as callbackfunction. + * \note the t8_ghost_type_t of the object will we userdefined + */ explicit t8_forest_ghost_w_search (t8_forest_search_query_fn search_function) : t8_forest_ghost_interface (T8_GHOST_USERDEFINED), search_fn (search_function) { T8_ASSERT (search_function != nullptr); } + /** + * Constructr of t8_forest_ghost_w_search by type + * The search_function is chosen by the type + * \note currently only the type face is supported + */ explicit t8_forest_ghost_w_search (t8_ghost_type_t ghost_type); virtual ~t8_forest_ghost_w_search () { } + /** Create one layer of ghost elements for a forest. + * \param [in,out] forest The forest. + * \a forest must be committed before calling this function. + */ virtual void do_ghost (t8_forest_t forest) override; protected: /** * Equal to t8_forest_ghost_fill_remote_v3 - * so no support for version 1 and 2 of face heigbors - * Only the search_fn parameter for search it not the same as in t8_forest_ghost_fill_remote_v3 - * use the member variable of the class + * so no support for version 1 and 2 of face neighbors. + * Only the search_fn parameter for t8_forest_search + * is not the same as in t8_forest_ghost_fill_remote_v3. + * Use the member variable of the class. */ virtual void search_for_ghost_elements (t8_forest_t forest); + /** + * Constructor for the derivided classes to set the type and the search_function. + * \param [in] ghost_type The type (faces, edges, userdefind, ...) of the ghost_interface + * \param [in] search_function Function of type t8_forest_search_query_fn, used as callbackfunktion in search_for_ghost_elements + */ t8_forest_ghost_w_search (t8_ghost_type_t ghost_type, t8_forest_search_query_fn search_function) : t8_forest_ghost_interface (ghost_type), search_fn (search_function) { T8_ASSERT (ghost_type != T8_GHOST_NONE); } - + /** Callbackfunction for t8_forest_search in search_for_ghost_elements */ t8_forest_search_query_fn search_fn {}; }; struct t8_forest_ghost_face: public t8_forest_ghost_w_search { public: + /** + * Constructor for the ghost class face. + * do_ghost will construct a ghost layer with face neighbors + * \param [in] version one of tree versions (1,2,3) can be used + * \note version 3 is the same treesearch as in t8_forest_ghost_w_search + */ explicit t8_forest_ghost_face (int version); inline int @@ -81,6 +109,10 @@ struct t8_forest_ghost_face: public t8_forest_ghost_w_search } protected: + /** + * Equal to t8_forest_ghost_fill_remote_v3 for version = 3 + * and t8_forest_ghost_fill_remote for version 1 and 2 + */ void search_for_ghost_elements (t8_forest_t forest) override; diff --git a/src/t8_forest/t8_forest_ghost_stencil.hxx b/src/t8_forest/t8_forest_ghost_stencil.hxx index ecbb629c76..1cefd0d6a5 100644 --- a/src/t8_forest/t8_forest_ghost_stencil.hxx +++ b/src/t8_forest/t8_forest_ghost_stencil.hxx @@ -31,12 +31,44 @@ T8_EXTERN_C_BEGIN (); struct t8_forest_ghost_stencil: t8_forest_ghost_interface { public: + /** + * Only constructor of t8_forest_ghost_stencil. + * Derived class of t8_forest_ghost_interface. + * Hase userdefined as type. + */ t8_forest_ghost_stencil (): t8_forest_ghost_interface (T8_GHOST_USERDEFINED) {}; + /** Create one layer of ghost elements for a forest. + * The neighborhood for this is defined by an stencil. + * \see add_stencil_to_ghost + * \param [in,out] forest The forest. + * \a forest must be committed before calling this function. + */ void do_ghost (t8_forest_t forest) override; protected: + /** + * Add this stencil (elements N and F) for element E to ghost. + * + * N + * | + * N - F - N + * | | | + * N - F - E - F - N + * | | | + * N - F - N + * | + * N + * \param[in] forest a commit uniform forest + * \param[in] element element E + * \param[in] eclass_scheme + * \param[in] level level of the uniform forest + * \param[in] tree_class expect T8_ECLASS_QUAD + * \param[in] ltreeid local tree id, expect 0 + * \param[in] ielement local index of element E + * \note some parameters currently expect specific values + */ void add_stencil_to_ghost (t8_forest_t forest, const t8_element_t *element, t8_eclass_scheme_c *eclass_scheme, int level, t8_eclass_t tree_class, t8_locidx_t ltreeid, t8_locidx_t ielement); From 39ca69029f12beec63e0e76546f7b918a2dd6eb8 Mon Sep 17 00:00:00 2001 From: antjeHP Date: Wed, 23 Oct 2024 16:38:38 +0200 Subject: [PATCH 26/26] deleted unused file t8_forest_ghost_interface_faces.hxx --- .../t8_forest_ghost_interface_faces.hxx | 69 ------------------- 1 file changed, 69 deletions(-) delete mode 100644 src/t8_forest/t8_forest_ghost_interface_faces.hxx diff --git a/src/t8_forest/t8_forest_ghost_interface_faces.hxx b/src/t8_forest/t8_forest_ghost_interface_faces.hxx deleted file mode 100644 index 6fc10374dd..0000000000 --- a/src/t8_forest/t8_forest_ghost_interface_faces.hxx +++ /dev/null @@ -1,69 +0,0 @@ -// /* -// This file is part of t8code. -// t8code is a C library to manage a collection (a forest) of multiple -// connected adaptive space-trees of general element classes in parallel. - -// Copyright (C) 2015 the developers - -// t8code is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. - -// t8code is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with t8code; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// */ - -// #ifndef T8_GHOST_INTERFACE_FACE_H -// #define T8_GHOST_INTERFACE_FACE_H - -// #include -// #include - -// /** -// * Flags for first step function -// * store in the flags which memory was allocated -// */ -// enum t8_ghost_interface_face_flag { -// CREATE_ELEMENT_ARRAY = 1, -// CREATE_TREE_ARRAY = 2, -// CREATE_GFIRST_DESC_ARRAY= 4 -// }; - -// struct t8_forest_ghost_interface_faces : public t8_forest_ghost_interface -// { -// public: -// /** -// * Constructor -// */ -// t8_forest_ghost_interface_faces(); - -// t8_forest_ghost_interface_faces(int version); - -// ~t8_forest_ghost_interface_faces () -// { -// } - -// inline int -// t8_ghost_get_version() const -// { -// return ghost_version; -// } - -// virtual void -// do_ghost(t8_forest forest) override; - -// protected: - -// int ghost_version; -// int32_t flag_step_1; - -// }; - -// #endif /* !T8_GHOST_INTERFACE_FACE_H */