]> https://gitweb.dealii.org/ - dealii.git/commitdiff
GT::vertex_to_cell_map(): check if tria has hn 15810/head
authorPeter Munch <peterrmuench@gmail.com>
Mon, 31 Jul 2023 13:55:14 +0000 (15:55 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Mon, 31 Jul 2023 19:48:14 +0000 (21:48 +0200)
source/grid/grid_tools.cc

index 6d84bbd0ede1b137f8a433c065ca6961bc8e4d8a..75d416c694f0572dadb68ca4f96352297febe7f6 100644 (file)
@@ -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<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);
+              }
           }
       }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.