Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions mesh_handle/element.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,31 @@ class element: public TCompetences<element<TMeshClass, 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.
Expand Down Expand Up @@ -583,6 +608,17 @@ class element: public TCompetences<element<TMeshClass, TCompetences...>>... {
return m_is_ghost_element;
}

/** Check if two elements are equal.
Comment thread
Vyp3er marked this conversation as resolved.
* \param [in] other The other element, this element is compared with.
* \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. */
Expand Down
14 changes: 14 additions & 0 deletions test/mesh_handle/t8_gtest_compare_handle_to_forest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc.,
*/

#include <gtest/gtest.h>
#include <test/t8_gtest_macros.hxx>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this?

#include <t8.h>

#include <mesh_handle/mesh.hxx>
Expand Down Expand Up @@ -63,6 +64,17 @@ 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++;
if (mesh_iterator_copy != mesh.cend ()) {
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));
Expand Down Expand Up @@ -96,6 +108,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++;
Expand Down
7 changes: 7 additions & 0 deletions test/mesh_handle/t8_gtest_ghost.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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 ());
Expand Down
Loading