diff --git a/doc/author_schmitt.txt b/doc/author_schmitt.txt new file mode 100644 index 0000000000..42045f2bc9 --- /dev/null +++ b/doc/author_schmitt.txt @@ -0,0 +1 @@ +I place my contributions to t8code under the FreeBSD license. Vincent Schmitt (vinz@vincent-schmitt.de) \ No newline at end of file diff --git a/mesh_handle/element.hxx b/mesh_handle/element.hxx index 3b1854b452..4f02329912 100644 --- a/mesh_handle/element.hxx +++ b/mesh_handle/element.hxx @@ -401,6 +401,31 @@ class element: public TCompetences>... { } } + /** Function to convert points in reference space of an element to points of the + * reference space of the tree. + * \param [in] ref_coords Pointer to the reference coordinates of the element. + * \param [in] num_coords Number of reference coordinates to convert. + * \param [out] tree_ref_coords Pointer to the reference coordinates of the tree. + */ + void + get_reference_coordinates (const t8_3D_vec ref_coords, std::size_t num_coords, t8_3D_vec tree_ref_coords) const + { + t8_forest_get_scheme (m_mesh->m_forest) + ->element_get_reference_coords (get_tree_class (), m_element, ref_coords.data (), num_coords, + tree_ref_coords.data ()); + } + + /** Compute the orientation of a face of an element with respect to its neighbor. + * \param [in] face The index of the face for which the orientation should be computed. + * \return The orientation of the face with respect to its neighbor. Returns 0 if the face has no neighbor. + */ + int + get_face_orientation (int face) const + { + return t8_forest_leaf_face_orientation (m_mesh->m_forest, m_tree_id, t8_forest_get_scheme (m_mesh->m_forest), + m_element, face); + } + // --- Getter for face properties. --- /** The area of a face of the element. * This is only an approximation. @@ -583,6 +608,18 @@ class element: public TCompetences>... { return m_is_ghost_element; } + /** Check if two elements are equal. + * \param [in] elem1 The first element. + * \param [in] elem2 The second element. + * \return true if the elements are equal, false if they are not equal. + */ + bool + is_equal (const SelfType& other) const + { + return t8_forest_get_scheme (m_mesh->m_forest) + ->element_is_equal (get_tree_class (), get_forest_element (), other.get_forest_element ()); + } + private: // --- Private member variables. --- TMeshClass* m_mesh; /**< Pointer to the mesh the element is defined for. */ diff --git a/test/mesh_handle/t8_gtest_compare_handle_to_forest.cxx b/test/mesh_handle/t8_gtest_compare_handle_to_forest.cxx index d39351ac21..4d26ee003e 100644 --- a/test/mesh_handle/t8_gtest_compare_handle_to_forest.cxx +++ b/test/mesh_handle/t8_gtest_compare_handle_to_forest.cxx @@ -26,6 +26,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., */ #include +#include #include #include @@ -61,6 +62,16 @@ TEST (t8_gtest_compare_handle_to_forest, compare_handle_to_forest) // --- Compare elements. --- EXPECT_EQ (mesh_iterator->get_local_tree_id (), itree); EXPECT_EQ (mesh_iterator->get_local_element_id (), ielem); + EXPECT_TRUE (mesh_iterator->is_equal (*mesh_iterator)); + auto mesh_iterator_copy = mesh_iterator; + mesh_iterator_copy++; + EXPECT_FALSE (mesh_iterator->is_equal (*mesh_iterator_copy)); + + t8_3D_vec ref = { 0.2, 0.3, 1 }; + t8_3D_vec a, b; + mesh_iterator->get_reference_coordinates (ref, 1, a); + scheme->element_get_reference_coords (tree_class, elem, ref.data (), 1, b.data ()); + EXPECT_EQ (a, b); // --- Compare functionality. --- EXPECT_EQ (mesh_iterator->get_level (), scheme->element_get_level (tree_class, elem)); EXPECT_EQ (mesh_iterator->get_num_faces (), scheme->element_get_num_faces (tree_class, elem)); @@ -94,6 +105,8 @@ TEST (t8_gtest_compare_handle_to_forest, compare_handle_to_forest) EXPECT_EQ (mesh_iterator->face_vertex_to_element_vertex (iface, ivertex), scheme->element_get_face_corner (tree_class, elem, iface, ivertex)); } + EXPECT_EQ (mesh_iterator->get_face_orientation (iface), + t8_forest_leaf_face_orientation (forest, itree, scheme, elem, iface)); } // --- Evolve mesh iterator. --- mesh_iterator++; diff --git a/test/mesh_handle/t8_gtest_ghost.cxx b/test/mesh_handle/t8_gtest_ghost.cxx index 27f15207d9..ec8779e2c9 100644 --- a/test/mesh_handle/t8_gtest_ghost.cxx +++ b/test/mesh_handle/t8_gtest_ghost.cxx @@ -81,11 +81,17 @@ TEST_P (t8_mesh_ghost_test, check_ghosts) for (t8_locidx_t ighost = num_local_elements; ighost < num_local_elements + num_ghost_elements; ++ighost) { EXPECT_EQ (ighost, (*mesh)[ighost].get_element_handle_id ()); EXPECT_TRUE ((*mesh)[ighost].is_ghost_element ()); + EXPECT_TRUE ((*mesh)[ighost].is_equal ((*mesh)[ighost])); EXPECT_EQ (level, (*mesh)[ighost].get_level ()); EXPECT_LE (0, (*mesh)[ighost].get_num_faces ()); EXPECT_LE (0, (*mesh)[ighost].get_num_vertices ()); EXPECT_LE (0, (*mesh)[ighost].get_volume ()); EXPECT_LE (0, (*mesh)[ighost].get_diameter ()); + t8_3D_vec ref = { 0.2, 0.3, 1 }, a; + (*mesh)[ighost].get_reference_coordinates (ref, 1, a); + for (const auto& coordinate : a) { + EXPECT_LE (0, coordinate); + } for (const auto& coordinate : (*mesh)[ighost].get_centroid ()) { EXPECT_TRUE (coordinate >= 0.0 && coordinate <= 1.0); } @@ -104,6 +110,7 @@ TEST_P (t8_mesh_ghost_test, check_ghosts) } EXPECT_LT (0, (*mesh)[ighost].get_num_vertices_of_face (0)); EXPECT_LE (0, (*mesh)[ighost].face_vertex_to_element_vertex (0, 0)); + EXPECT_GE ((*mesh)[ighost].get_face_orientation (0), 0); // Check exemplary that caches work for ghost elements. EXPECT_TRUE ((*mesh)[ighost].volume_cache_filled ()); EXPECT_LE (0, (*mesh)[ighost].get_volume ());