Skip to content

Commit

Permalink
Merge pull request #15810 from peterrum/vertex_to_cell_map_check_hn
Browse files Browse the repository at this point in the history
GT::vertex_to_cell_map(): check if triangulation is locally refined.
  • Loading branch information
luca-heltai committed Aug 1, 2023
2 parents 7c0fd73 + 4aceda4 commit 69f31dc
Showing 1 changed file with 31 additions and 22 deletions.
53 changes: 31 additions & 22 deletions source/grid/grid_tools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3414,33 +3414,42 @@ namespace GridTools
for (const unsigned int i : cell->vertex_indices())
vertex_to_cell_map[cell->vertex_index(i)].insert(cell);

// Take care of hanging nodes
cell = triangulation.begin_active();
for (; cell != endc; ++cell)
// Check if mesh has hanging nodes. Do this only locally to
// prevent communication and possible deadlock.
if (triangulation.Triangulation<dim, spacedim>::has_hanging_nodes())
{
for (const unsigned int i : cell->face_indices())
Assert(triangulation.all_reference_cells_are_hyper_cube(),
ExcNotImplemented());

// Take care of hanging nodes
cell = triangulation.begin_active();
for (; cell != endc; ++cell)
{
if ((cell->at_boundary(i) == false) &&
(cell->neighbor(i)->is_active()))
for (const unsigned int i : cell->face_indices())
{
typename Triangulation<dim, spacedim>::active_cell_iterator
adjacent_cell = cell->neighbor(i);
for (unsigned int j = 0; j < cell->face(i)->n_vertices(); ++j)
vertex_to_cell_map[cell->face(i)->vertex_index(j)].insert(
adjacent_cell);
if ((cell->at_boundary(i) == false) &&
(cell->neighbor(i)->is_active()))
{
typename Triangulation<dim, spacedim>::active_cell_iterator
adjacent_cell = cell->neighbor(i);
for (unsigned int j = 0; j < cell->face(i)->n_vertices();
++j)
vertex_to_cell_map[cell->face(i)->vertex_index(j)].insert(
adjacent_cell);
}
}
}

// in 3d also loop over the edges
if (dim == 3)
{
for (unsigned int i = 0; i < cell->n_lines(); ++i)
if (cell->line(i)->has_children())
// the only place where this vertex could have been
// hiding is on the mid-edge point of the edge we
// are looking at
vertex_to_cell_map[cell->line(i)->child(0)->vertex_index(1)]
.insert(cell);
// in 3d also loop over the edges
if (dim == 3)
{
for (unsigned int i = 0; i < cell->n_lines(); ++i)
if (cell->line(i)->has_children())
// the only place where this vertex could have been
// hiding is on the mid-edge point of the edge we
// are looking at
vertex_to_cell_map[cell->line(i)->child(0)->vertex_index(1)]
.insert(cell);
}
}
}

Expand Down

0 comments on commit 69f31dc

Please sign in to comment.