]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix some errors revealed by STL debug compile 12919/head
authorMartin Kronbichler <martin.kronbichler@it.uu.se>
Fri, 5 Nov 2021 11:22:25 +0000 (12:22 +0100)
committerMartin Kronbichler <martin.kronbichler@it.uu.se>
Fri, 5 Nov 2021 14:35:29 +0000 (15:35 +0100)
source/distributed/tria_base.cc
source/grid/grid_generator.cc

index 4cc72503b4ef31b8419378b479de7a989e926472..971288f4b16dd282d3ceef23002f1a0b0303dc08 100644 (file)
@@ -1291,7 +1291,8 @@ namespace parallel
         // Adjust buffer iterator to the offset of the callback
         // function so that we only have to advance its position
         // to the next cell after each iteration.
-        dest_data_it = dest_data_fixed.cbegin() + offset;
+        if (cell_relations.begin() != cell_relations.end())
+          dest_data_it = dest_data_fixed.cbegin() + offset;
       }
 
     // Iterate over all cells and unpack the transferred data.
@@ -1334,8 +1335,10 @@ namespace parallel
                 data_increment -= offset;
               }
 
-            // Advance data size iterators to the next cell.
-            dest_sizes_cell_it += sizes_fixed_cumulative.back();
+            // Advance data size iterators to the next cell, avoid iterating
+            // past the end of dest_sizes_cell_it
+            if (cell_rel_it != cell_relations.end() - 1)
+              dest_sizes_cell_it += sizes_fixed_cumulative.back();
             ++dest_sizes_it;
           }
 
@@ -1369,7 +1372,8 @@ namespace parallel
               break;
           }
 
-        dest_data_it += data_increment;
+        if (cell_rel_it != cell_relations.end() - 1)
+          dest_data_it += data_increment;
       }
   }
 
index f7d6f104a26436a5cb7edd6a69d4e658722ea430..36f03a9226be323ec938fe1152a96af746aaa227 100644 (file)
@@ -4266,20 +4266,16 @@ namespace GridGenerator
     // compute cells to remove
     std::set<typename Triangulation<dim, spacedim>::active_cell_iterator>
       cells_to_remove;
-    std::copy_if(
-      rectangle.active_cell_iterators().begin(),
-      rectangle.active_cell_iterators().end(),
-      std::inserter(cells_to_remove, cells_to_remove.end()),
-      [&](
-        const typename Triangulation<dim, spacedim>::active_cell_iterator &cell)
-        -> bool {
-        for (unsigned int d = 0; d < dim; ++d)
+    for (const auto &cell : rectangle.active_cell_iterators())
+      {
+        bool remove_cell = true;
+        for (unsigned int d = 0; d < dim && remove_cell; ++d)
           if ((n_cells_to_remove[d] > 0 && cell->center()[d] >= cut_step[d]) ||
               (n_cells_to_remove[d] < 0 && cell->center()[d] <= cut_step[d]))
-            return false;
-
-        return true;
-      });
+            remove_cell = false;
+        if (remove_cell)
+          cells_to_remove.insert(cell);
+      }
 
     GridGenerator::create_triangulation_with_removed_cells(rectangle,
                                                            cells_to_remove,

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.