From ef622dbece5cf631515d2276e32085a536397cbe Mon Sep 17 00:00:00 2001 From: Johannes Holke Date: Mon, 14 Oct 2024 14:19:20 +0200 Subject: [PATCH] indent and typo --- src/t8_cmesh/t8_cmesh_commit.cxx | 3 +- src/t8_cmesh/t8_cmesh_types.h | 3 +- .../t8_cmesh_vertex_conn_tree_to_vertex.cxx | 2 +- .../t8_cmesh_vertex_conn_tree_to_vertex.hxx | 121 +++++----- .../t8_cmesh_vertex_conn_vertex_to_tree.cxx | 7 +- .../t8_cmesh_vertex_conn_vertex_to_tree.hxx | 220 +++++++++--------- src/t8_cmesh/t8_cmesh_vertex_connectivity.cxx | 4 +- test/t8_cmesh/t8_gtest_cmesh_vertex_conn.cxx | 2 +- ...gtest_cmesh_vertex_conn_tree_to_vertex.cxx | 4 +- ...gtest_cmesh_vertex_conn_vertex_to_tree.cxx | 4 +- 10 files changed, 183 insertions(+), 187 deletions(-) diff --git a/src/t8_cmesh/t8_cmesh_commit.cxx b/src/t8_cmesh/t8_cmesh_commit.cxx index bb57ea852f..b76299ccff 100644 --- a/src/t8_cmesh/t8_cmesh_commit.cxx +++ b/src/t8_cmesh/t8_cmesh_commit.cxx @@ -584,7 +584,8 @@ t8_cmesh_commit (t8_cmesh_t cmesh, sc_MPI_Comm comm) * but only if the vertex_to_tree instance is not yet committed * and if the tree_to_vertex instance is not empty. */ - if (cmesh->vertex_connectivity->get_vertex_to_tree_state () == 0 && cmesh->vertex_connectivity->get_tree_to_vertex_state () == 1) { + if (cmesh->vertex_connectivity->get_vertex_to_tree_state () == 0 + && cmesh->vertex_connectivity->get_tree_to_vertex_state () == 1) { cmesh->vertex_connectivity->build_vertex_to_tree (cmesh); } diff --git a/src/t8_cmesh/t8_cmesh_types.h b/src/t8_cmesh/t8_cmesh_types.h index c81f207030..c1781b177e 100644 --- a/src/t8_cmesh/t8_cmesh_types.h +++ b/src/t8_cmesh/t8_cmesh_types.h @@ -139,7 +139,8 @@ typedef struct t8_cmesh t8_geometry_handler_c *geometry_handler; /**< Handles all geometries that are used by trees in this cmesh. */ - struct t8_cmesh_vertex_connectivity *vertex_connectivity; /**< Structure that manages tree_to_vertex and vertex_to_tree connectivity. */ + struct t8_cmesh_vertex_connectivity + *vertex_connectivity; /**< Structure that manages tree_to_vertex and vertex_to_tree connectivity. */ #ifdef T8_ENABLE_DEBUG t8_locidx_t inserted_trees; /**< Count the number of inserted trees to diff --git a/src/t8_cmesh/t8_cmesh_vertex_conn_tree_to_vertex.cxx b/src/t8_cmesh/t8_cmesh_vertex_conn_tree_to_vertex.cxx index 991d0f7a78..b469de7f56 100644 --- a/src/t8_cmesh/t8_cmesh_vertex_conn_tree_to_vertex.cxx +++ b/src/t8_cmesh/t8_cmesh_vertex_conn_tree_to_vertex.cxx @@ -163,4 +163,4 @@ t8_cmesh_vertex_conn_tree_to_vertex::get_global_vertex (const t8_cmesh_t cmesh, T8_ASSERT (local_tree_vertex < num_tree_vertices); return get_global_vertices (cmesh, local_tree, num_tree_vertices)[local_tree_vertex]; -} \ No newline at end of file +} diff --git a/src/t8_cmesh/t8_cmesh_vertex_conn_tree_to_vertex.hxx b/src/t8_cmesh/t8_cmesh_vertex_conn_tree_to_vertex.hxx index 67789b6443..36b0f62b12 100644 --- a/src/t8_cmesh/t8_cmesh_vertex_conn_tree_to_vertex.hxx +++ b/src/t8_cmesh/t8_cmesh_vertex_conn_tree_to_vertex.hxx @@ -18,15 +18,15 @@ You should have received a copy of the GNU General Public License along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - +*/ + /** \file t8_cmesh_vertex_conn_tree_to_vertex.hxx * Class to save data structure for tree_to_vertex_lists of the cmesh. * When the cmesh stores global vertex numbers, we require a lookup that * matches a tree and its local vertex to a global vertex id. * This lookup is encoded in the t8_cmesh_vertex_conn_tree_to_vertex struct. - */ - + */ + /* TODO: * It is probably best to set all global ids of a single tree as one attribute. * That way we can store it as a single arrays of id's. @@ -35,41 +35,40 @@ * when accessing. * * On the downside we will only have a "set all ids of a tree" function and no "set this single id for this tree and this vertex" function. - */ - -#pragma once - -#include -#include -#include - -/* forward declaration of ttv class needed since the two class headers include each other. */ -class t8_cmesh_vertex_conn_vertex_to_tree; - -class t8_cmesh_vertex_conn_tree_to_vertex -{ - public: - /** Standard constructor. Does nothing. */ - t8_cmesh_vertex_conn_tree_to_vertex (): state (EMPTY) - { - } - - /** Constructor from a cmesh where all the attributes are set. */ - t8_cmesh_vertex_conn_tree_to_vertex (const t8_cmesh_t cmesh) - { - SC_ABORT ("not implemented."); - } - + */ + +#pragma once + +#include +#include +#include + +/* forward declaration of ttv class needed since the two class headers include each other. */ +class t8_cmesh_vertex_conn_vertex_to_tree; + +class t8_cmesh_vertex_conn_tree_to_vertex { + public: + /** Standard constructor. Does nothing. */ + t8_cmesh_vertex_conn_tree_to_vertex (): state (EMPTY) + { + } + + /** Constructor from a cmesh where all the attributes are set. */ + t8_cmesh_vertex_conn_tree_to_vertex (const t8_cmesh_t cmesh) + { + SC_ABORT ("not implemented."); + } + /** Constructor from a cmesh and a given vertex to tree connectivity. * * \note \a cmesh must not be committed. * \note \a vtt must be committed. * \note This does not work until issue #923 https://github.com/DLR-AMR/t8code/issues/923 is resolved. - */ - t8_cmesh_vertex_conn_tree_to_vertex (const t8_cmesh_t cmesh_from, const t8_cmesh_t cmesh, - const struct t8_cmesh_vertex_conn_vertex_to_tree &vtt); - - /* Setter functions */ + */ + t8_cmesh_vertex_conn_tree_to_vertex (const t8_cmesh_t cmesh_from, const t8_cmesh_t cmesh, + const struct t8_cmesh_vertex_conn_vertex_to_tree &vtt); + + /* Setter functions */ /** Set all global vertex ids of a local tree. * \param[in] cmesh The considered cmesh * \param[in] local_tree A local tree id of \a cmesh @@ -77,31 +76,29 @@ class t8_cmesh_vertex_conn_tree_to_vertex * \param[in] num_vertices Must match the number of vertices of \a local_tree * * \note \a cmesh must not be committed. - */ - void - set_global_vertex_ids_of_tree_vertices (const t8_cmesh_t, const t8_gloidx_t global_tree, - const t8_gloidx_t *global_tree_vertices, const int num_vertices); - - t8_gloidx_t - get_global_vertex (const t8_cmesh_t cmesh, const t8_locidx_t local_tree, const int local_tree_vertex, - const int num_tree_vertices) const; - - const t8_gloidx_t * - get_global_vertices (const t8_cmesh_t cmesh, const t8_locidx_t local_tree, const int num_vertices) const; - - const int - get_state () - { - return state; - } - - friend struct t8_cmesh_vertex_connectivity; - - private: - - enum { - EMPTY, /*< Is initialized but empty. */ - FILLED /*< Is filled with at least one entry. */ - } state; -}; - + */ + void + set_global_vertex_ids_of_tree_vertices (const t8_cmesh_t, const t8_gloidx_t global_tree, + const t8_gloidx_t *global_tree_vertices, const int num_vertices); + + t8_gloidx_t + get_global_vertex (const t8_cmesh_t cmesh, const t8_locidx_t local_tree, const int local_tree_vertex, + const int num_tree_vertices) const; + + const t8_gloidx_t * + get_global_vertices (const t8_cmesh_t cmesh, const t8_locidx_t local_tree, const int num_vertices) const; + + const int + get_state () + { + return state; + } + + friend struct t8_cmesh_vertex_connectivity; + + private: + enum { + EMPTY, /*< Is initialized but empty. */ + FILLED /*< Is filled with at least one entry. */ + } state; +}; diff --git a/src/t8_cmesh/t8_cmesh_vertex_conn_vertex_to_tree.cxx b/src/t8_cmesh/t8_cmesh_vertex_conn_vertex_to_tree.cxx index c87be4695f..76faabd98a 100644 --- a/src/t8_cmesh/t8_cmesh_vertex_conn_vertex_to_tree.cxx +++ b/src/t8_cmesh/t8_cmesh_vertex_conn_vertex_to_tree.cxx @@ -33,8 +33,7 @@ /* Builds vertex_to_tree with existing tree_to_vertex list. */ void -t8_cmesh_vertex_conn_vertex_to_tree::build_from_ttv ( - const t8_cmesh_t cmesh, t8_cmesh_vertex_conn_tree_to_vertex& ttv) +t8_cmesh_vertex_conn_vertex_to_tree::build_from_ttv (const t8_cmesh_t cmesh, t8_cmesh_vertex_conn_tree_to_vertex& ttv) { /* Call standard constructor */ T8_ASSERT (state == INITIALIZED); @@ -112,7 +111,7 @@ t8_cmesh_vertex_conn_vertex_to_tree::commit (const t8_cmesh_t cmesh) void t8_cmesh_vertex_conn_vertex_to_tree::add_vertex_to_tree (const t8_cmesh_t cmesh, t8_gloidx_t global_vertex_id, - t8_locidx_t ltreeid, int tree_vertex) + t8_locidx_t ltreeid, int tree_vertex) { T8_ASSERT (!is_committed ()); T8_ASSERT (0 <= global_vertex_id); @@ -223,4 +222,4 @@ t8_cmesh_vertex_conn_vertex_to_tree::contains_all_vertices (const t8_cmesh_t cme } } return 1; -} \ No newline at end of file +} diff --git a/src/t8_cmesh/t8_cmesh_vertex_conn_vertex_to_tree.hxx b/src/t8_cmesh/t8_cmesh_vertex_conn_vertex_to_tree.hxx index 320e19ca60..4cfd8d3cf7 100644 --- a/src/t8_cmesh/t8_cmesh_vertex_conn_vertex_to_tree.hxx +++ b/src/t8_cmesh/t8_cmesh_vertex_conn_vertex_to_tree.hxx @@ -18,23 +18,23 @@ You should have received a copy of the GNU General Public License along with t8code; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - +*/ + /** \file t8_cmesh_vertex_conn_vertex_to_tree.hxx * Class to save data structure for vertex_to_tree_lists - */ - -#ifndef T8_CMESH_VERTEX_CONN_VERTEX_TO_TREE_HXX -#define T8_CMESH_VERTEX_CONN_VERTEX_TO_TREE_HXX - -#include -#include -#include -#include - -/* forward declaration of ttv class needed since the two class headers include each other. */ -class t8_cmesh_vertex_conn_tree_to_vertex; - + */ + +#ifndef T8_CMESH_VERTEX_CONN_VERTEX_TO_TREE_HXX +#define T8_CMESH_VERTEX_CONN_VERTEX_TO_TREE_HXX + +#include +#include +#include +#include + +/* forward declaration of ttv class needed since the two class headers include each other. */ +class t8_cmesh_vertex_conn_tree_to_vertex; + /* * notes during development * @@ -62,142 +62,140 @@ class t8_cmesh_vertex_conn_tree_to_vertex; * List of (tree_id, tree_vertex): std::vector = TV_LIST * Table global_id -> TV_LIST: std::unordered_map * -*/ - -class t8_cmesh_vertex_conn_vertex_to_tree -{ - public: +*/ + +class t8_cmesh_vertex_conn_vertex_to_tree { + public: /** Standard constructor. * Initializes the class and allows setting vertex entries * via \ref add_vertex_to_tree - */ - t8_cmesh_vertex_conn_vertex_to_tree (): state (INITIALIZED) - { - } - - /** Funktion to fill vtt from cmesh and ttv information. + */ + t8_cmesh_vertex_conn_vertex_to_tree (): state (INITIALIZED) + { + } + + /** Function to fill vtt from cmesh and ttv information. * Sets all global ids and associated tree vertices from * the given input class. * Afterwards, the class is set to committed and can be used. * * \param [in] cmesh A committed cmesh with set tree to vertex entries. * \param [in] ttv A filled tree to vertex list for \a cmesh. - */ - - void - build_from_ttv (const t8_cmesh_t cmesh, t8_cmesh_vertex_conn_tree_to_vertex& ttv); - - /* Variable type for (tree_id, tree_vertex_id) pair */ - using tree_vertex_pair = std::pair; - + */ + + void + build_from_ttv (const t8_cmesh_t cmesh, t8_cmesh_vertex_conn_tree_to_vertex& ttv); + + /* Variable type for (tree_id, tree_vertex_id) pair */ + using tree_vertex_pair = std::pair; + /* list of tree vertex pairs, each global vertex id maps to - * such a list. */ - using tree_vertex_list = std::vector; - - using vtt_storage_type = std::unordered_map; - - /* Setter functions */ + * such a list. */ + using tree_vertex_list = std::vector; + + using vtt_storage_type = std::unordered_map; + + /* Setter functions */ /* Given a cmesh, build up the vertex_to_tree. * \return: some error value to be specified. * The cmesh must not be committed, but all tree information and neighbor information must * have been set. - * Currently, \a cmesh has to be replicated. */ - void - set_vertex_to_tree_list (const t8_cmesh_t cmesh); - - const tree_vertex_list& - get_tree_list_of_vertex (t8_gloidx_t global_vertex_id) const; - - const int - get_state () - { - return state; - } - - /* Setter functions */ + * Currently, \a cmesh has to be replicated. */ + void + set_vertex_to_tree_list (const t8_cmesh_t cmesh); + + const tree_vertex_list& + get_tree_list_of_vertex (t8_gloidx_t global_vertex_id) const; + + const int + get_state () + { + return state; + } + + /* Setter functions */ /* A single value is added to the vertex_to_tree_list. - * \a cmesh must be committed. */ - void - add_vertex_to_tree (const t8_cmesh_t cmesh, t8_gloidx_t global_vertex_id, t8_locidx_t ltreeid, int tree_vertex); - + * \a cmesh must be committed. */ + void + add_vertex_to_tree (const t8_cmesh_t cmesh, t8_gloidx_t global_vertex_id, t8_locidx_t ltreeid, int tree_vertex); + /* Mark as ready for commit. Meaning that all * global vertex ids have been added. - * After commit, no vertex ids can be added anymore. */ - void - commit (const t8_cmesh_t cmesh); - + * After commit, no vertex ids can be added anymore. */ + void + commit (const t8_cmesh_t cmesh); + /** * @brief Check whether this instance is committed. * * @return int True if committed. Thus all entries have been set. - */ - int - is_committed () const; - + */ + int + is_committed () const; + /** * @brief Compare with another instance of this class. * * @param other * @return int True if and only if the stored vertex indices match. - */ - int - is_equal (const t8_cmesh_vertex_conn_vertex_to_tree& other) const; - + */ + int + is_equal (const t8_cmesh_vertex_conn_vertex_to_tree& other) const; + /** * @brief Equality operator. Implement * * @param other * @return true * @return false - */ - bool - operator== (const t8_cmesh_vertex_conn_vertex_to_tree& other) const; - - /** Typedef for the iterator type */ - typedef vtt_storage_type::const_iterator const_iterator; - - const_iterator - begin () const - { - return vertex_to_tree.begin (); - } - const_iterator - end () const - { - return vertex_to_tree.end (); - } - - friend struct t8_cmesh_vertex_connectivity; - - private: + */ + bool + operator== (const t8_cmesh_vertex_conn_vertex_to_tree& other) const; + + /** Typedef for the iterator type */ + typedef vtt_storage_type::const_iterator const_iterator; + + const_iterator + begin () const + { + return vertex_to_tree.begin (); + } + const_iterator + end () const + { + return vertex_to_tree.end (); + } + + friend struct t8_cmesh_vertex_connectivity; + + private: /* For each global vertex id sort the list of * (tree_id, tree_vertex) pairs according to * tree_id and tree_vertex index. * Example: (1, 3), (0, 0), (1, 0) * becomes: (0, 0), (1, 0), (1, 3) - */ - void - sort_list_by_tree_id (); - + */ + void + sort_list_by_tree_id (); + /** * @brief Check that all local trees and vertices of a given cmesh are mapped to a global id. * * @param cmesh A committed cmesh. * @return int True if and only if each local tree and vertex of \a cmesh is associated with a global id. - */ - int - contains_all_vertices (const t8_cmesh_t cmesh) const; - + */ + int + contains_all_vertices (const t8_cmesh_t cmesh) const; + /* The actual data storage mapping global vertex ids to a list - * local trees and tree vertices. */ - vtt_storage_type vertex_to_tree; - - /** Stores the state of this instance. */ - enum { - INITIALIZED, /*< Can currently be filled with entries. */ - COMMITTED /*< Is filled and cannot be changed. */ - } state; - -}; - -#endif /* !T8_CMESH_VERTEX_CONN_VERTEX_TO_TREE_HXX */ + * local trees and tree vertices. */ + vtt_storage_type vertex_to_tree; + + /** Stores the state of this instance. */ + enum { + INITIALIZED, /*< Can currently be filled with entries. */ + COMMITTED /*< Is filled and cannot be changed. */ + } state; +}; + +#endif /* !T8_CMESH_VERTEX_CONN_VERTEX_TO_TREE_HXX */ diff --git a/src/t8_cmesh/t8_cmesh_vertex_connectivity.cxx b/src/t8_cmesh/t8_cmesh_vertex_connectivity.cxx index 13c4304b82..2515c5cfe6 100644 --- a/src/t8_cmesh/t8_cmesh_vertex_connectivity.cxx +++ b/src/t8_cmesh/t8_cmesh_vertex_connectivity.cxx @@ -63,8 +63,8 @@ t8_cmesh_set_global_vertices_of_tree (const t8_cmesh_t cmesh, const t8_gloidx_t const t8_gloidx_t *global_tree_vertices, const int num_vertices) { T8_ASSERT (t8_cmesh_is_initialized (cmesh)); - cmesh->vertex_connectivity->set_global_vertex_ids_of_tree_vertices ( - cmesh, global_tree, global_tree_vertices, num_vertices); + cmesh->vertex_connectivity->set_global_vertex_ids_of_tree_vertices (cmesh, global_tree, global_tree_vertices, + num_vertices); } t8_gloidx_t diff --git a/test/t8_cmesh/t8_gtest_cmesh_vertex_conn.cxx b/test/t8_cmesh/t8_gtest_cmesh_vertex_conn.cxx index 6fb524c0df..51e49a7990 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_vertex_conn.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_vertex_conn.cxx @@ -172,4 +172,4 @@ TEST_F (t8_test_cmesh_vertex_conn, check_vertex_to_tree) const t8_locidx_t num_trees_at_vertex = t8_cmesh_get_num_trees_at_vertex (cmesh, ivertex); EXPECT_EQ (num_trees_at_vertex, check_num_trees_at_vertex[ivertex]); } -} \ No newline at end of file +} diff --git a/test/t8_cmesh/t8_gtest_cmesh_vertex_conn_tree_to_vertex.cxx b/test/t8_cmesh/t8_gtest_cmesh_vertex_conn_tree_to_vertex.cxx index 23605afbd2..22e199d47b 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_vertex_conn_tree_to_vertex.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_vertex_conn_tree_to_vertex.cxx @@ -189,7 +189,7 @@ TEST_P (cmesh_vertex_conn_ttv_with_core_classes_temp, convert_to_vtt) { /* create a vertex_to_tree list from ttv */ t8_cmesh_vertex_conn_vertex_to_tree vtt; - vtt.build_from_ttv(cmesh, ttv); + vtt.build_from_ttv (cmesh, ttv); /* Since global tree i is mapped to vertices: * i*T8_ECLASS_MAX_CORNERS, i*T8_ECLASS_MAX_CORNERS + 1, ... * and this mapping is unique, we know that the list for vertex j @@ -367,4 +367,4 @@ INSTANTIATE_TEST_SUITE_P (t8_gtest_cmesh_vertex_tree_to_vertex, cmesh_vertex_con AllCmeshsParam, pretty_print_base_example); INSTANTIATE_TEST_SUITE_P (t8_gtest_cmesh_vertex_tree_to_vertex, cmesh_vertex_conn_ttv_with_cmesh_functions_temp, - testing::Combine (testing::Values (1, VTT_TEST_MAX_NUM_TREES + 1), AllEclasses)); \ No newline at end of file + testing::Combine (testing::Values (1, VTT_TEST_MAX_NUM_TREES + 1), AllEclasses)); diff --git a/test/t8_cmesh/t8_gtest_cmesh_vertex_conn_vertex_to_tree.cxx b/test/t8_cmesh/t8_gtest_cmesh_vertex_conn_vertex_to_tree.cxx index 5f745d2eef..15a2d20123 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_vertex_conn_vertex_to_tree.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_vertex_conn_vertex_to_tree.cxx @@ -234,9 +234,9 @@ TEST_P (t8_test_cmesh_vertex_conn_vtt, DISABLED_convert_to_ttv_and_back) /* Now we can build vtt conns from the ttv conns. * They should match the original connectivities. */ t8_cmesh_vertex_conn_vertex_to_tree vtt_new; - vtt_new.build_from_ttv(derived_cmesh_A, ttv); + vtt_new.build_from_ttv (derived_cmesh_A, ttv); t8_cmesh_vertex_conn_vertex_to_tree vtt_new_all_to_one; - vtt_all_to_one.build_from_ttv(derived_cmesh_B, ttv_all_to_one); + vtt_all_to_one.build_from_ttv (derived_cmesh_B, ttv_all_to_one); /* Check for equality. */ EXPECT_EQ (vtt, vtt_new);