From 4aceda49b3791821afc04468cf4f3aee5da3859b Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Mon, 31 Jul 2023 15:55:14 +0200 Subject: [PATCH] GT::vertex_to_cell_map(): check if tria has hn --- source/grid/grid_tools.cc | 53 +++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 6d84bbd0ed..75d416c694 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -3423,33 +3423,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::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::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::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); + } } } -- 2.39.5