// 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.
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;
}
break;
}
- dest_data_it += data_increment;
+ if (cell_rel_it != cell_relations.end() - 1)
+ dest_data_it += data_increment;
}
}
// 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,