Skip to content

Commit dc1fd8b

Browse files
committed
Merge branch 'handle-neighbor-and-ghost' into handle_element-data
2 parents e8b023a + 13b23b6 commit dc1fd8b

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

mesh_handle/element.hxx

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -349,41 +349,47 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
349349
}
350350
}
351351

352-
//--- Getter for the member variables. ---
352+
// --- Function to access mesh specific id. ---
353353
/**
354-
* Getter for the tree id of the element.
355-
* \return The element's local tree id.
354+
* Getter for the index of the element in the mesh to which the element belongs.
355+
* \return The local element id of the element in the mesh.
356356
*/
357357
t8_locidx_t
358-
get_local_tree_id () const
358+
get_element_handle_id () const
359359
{
360-
return m_tree_id;
360+
if (m_is_ghost_element) {
361+
return m_mesh->get_num_local_elements ()
362+
+ t8_forest_ghost_get_tree_element_offset (m_mesh->m_forest,
363+
m_tree_id - t8_forest_get_num_local_trees (m_mesh->m_forest))
364+
+ m_element_id;
365+
}
366+
return t8_forest_get_tree_element_offset (m_mesh->m_forest, m_tree_id) + m_element_id;
361367
}
362368

369+
//--- Getter for the member variables. ---
363370
/**
364-
* Getter for the local element id in the tree of the element.
365-
* \return The local element id in the tree of the element.
371+
* Getter for the tree id of the element in the forest related to the mesh.
372+
* \warning This is related to t8code's tree structure and should not be confused with \ref mesh specific ids.
373+
* This function is mainly relevant for writing custom competences that need to access t8code functionality.
374+
* \return The element's local tree id in the forest.
366375
*/
367376
t8_locidx_t
368-
get_local_element_id () const
377+
get_local_tree_id () const
369378
{
370-
return m_element_id;
379+
return m_tree_id;
371380
}
372381

373382
/**
374-
* Getter for the flat local element id. This is the local index of the element in the mesh to which the element belongs.
375-
* \return The flat local element id of the element.
383+
* Getter for the local element id in the tree of the element in the forest related to the mesh.
384+
* \warning This is related to t8code's tree structure and should not be confused with \ref mesh specific ids.
385+
* For mesh specific id use \ref get_element_handle_id.
386+
* This function is mainly relevant for writing custom competences that need to access t8code functionality.
387+
* \return The local element id in the tree of the element in the forest.
376388
*/
377389
t8_locidx_t
378-
get_flat_element_id () const
390+
get_local_element_id () const
379391
{
380-
if (m_is_ghost_element) {
381-
return m_mesh->get_num_local_elements ()
382-
+ t8_forest_ghost_get_tree_element_offset (m_mesh->m_forest,
383-
m_tree_id - t8_forest_get_num_local_trees (m_mesh->m_forest))
384-
+ m_element_id;
385-
}
386-
return t8_forest_get_tree_element_offset (m_mesh->m_forest, m_tree_id) + m_element_id;
392+
return m_element_id;
387393
}
388394

389395
/**
@@ -416,7 +422,7 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
416422
const E&
417423
get_element_data () const
418424
{
419-
return m_mesh->m_element_data[get_flat_element_id ()];
425+
return m_mesh->m_element_data[get_element_handle_id ()];
420426
}
421427

422428
/**
@@ -431,7 +437,7 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
431437
SC_CHECK_ABORT (!m_is_ghost_element, "Element data cannot be set for ghost elements.\n");
432438
// Resize for the case that no data vector has been set previously.
433439
m_mesh->m_element_data.resize (m_mesh->get_num_local_elements () + m_mesh->get_num_ghosts ());
434-
m_mesh->m_element_data[get_flat_element_id ()] = element_data;
440+
m_mesh->m_element_data[get_element_handle_id ()] = element_data;
435441
}
436442

437443
private:

test/mesh_handle/t8_gtest_ghost.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ TEST_P (t8_mesh_ghost_test, compare_neighbors_to_forest)
135135
EXPECT_EQ (num_neighbors, (int) neighbors_handle.size ());
136136
EXPECT_EQ (dual_faces_handle, std::vector<int> (dual_faces, dual_faces + num_neighbors));
137137
for (int ineighs = 0; ineighs < num_neighbors; ineighs++) {
138-
EXPECT_EQ (neighbors_handle[ineighs]->get_flat_element_id (), neigh_ids[ineighs]);
138+
EXPECT_EQ (neighbors_handle[ineighs]->get_element_handle_id (), neigh_ids[ineighs]);
139139
}
140140
for (int ineigh = 0; ineigh < num_neighbors; ineigh++) {
141141
EXPECT_EQ (scheme->element_get_shape (neigh_eclass, neighbors[ineigh]),

0 commit comments

Comments
 (0)