diff --git a/dune/xt/grid/dd/glued.hh b/dune/xt/grid/dd/glued.hh index 18c4839e7533b7dfbeb3d27420f708b0962e8908..96b9333f6b80727717d294a7967d6207c2b84ba3 100644 --- a/dune/xt/grid/dd/glued.hh +++ b/dune/xt/grid/dd/glued.hh @@ -322,9 +322,7 @@ public: prepare_global_grid(); const size_t global_index_of_local_entity = local_to_global_indices_->operator[](subd)[local_entity_index]; const auto global_micro_grid_view = global_grid_view(); - const auto entity_it_end = global_micro_grid_view.template end<0>(); - for (auto entity_it = global_micro_grid_view.template begin<0>(); entity_it != entity_it_end; ++entity_it) { - const auto& entity = *entity_it; + for (auto&& entity : elements(global_macro_grid_view)) { if (global_micro_grid_view.indexSet().index(entity) == global_index_of_local_entity) return entity; } @@ -352,9 +350,7 @@ public: const auto subd = subdomain_and_local_entity_index.first; const auto local_index_of_global_entity = subdomain_and_local_entity_index.second; const auto local_grid_view = extract_local_view<layer>()(*local_grids_[subd], max_local_level(subd)); - const auto entity_it_end = local_grid_view.template end<0>(); - for (auto entity_it = local_grid_view.template begin<0>(); entity_it != entity_it_end; ++entity_it) { - const auto& entity = *entity_it; + for (auto&& entity : elements(local_grid_view)) { if (local_grid_view.indexSet().index(entity) == local_index_of_global_entity) return entity; } @@ -464,11 +460,7 @@ public: glues_for_this_entity_neighbor.clear(); } // find the corresponding macro intersection ... - const auto macro_intersection_it_end = macro_leaf_view_.iend(macro_entity); - for (auto macro_intersection_it = macro_leaf_view_.ibegin(macro_entity); - macro_intersection_it != macro_intersection_it_end; - ++macro_intersection_it) { - const auto& macro_intersection = *macro_intersection_it; + for (auto&& macro_intersection : intersections(macro_leaf_view_, macro_entity)) { if (macro_intersection.neighbor() && !macro_intersection.boundary()) { const auto real_neighbor_ptr = macro_intersection.outside(); # if DUNE_VERSION_GTE(DUNE_GRID, 2, 4) @@ -553,10 +545,7 @@ public: // create the container, therefore const auto local_leaf_view = local_grids_[macro_entity_index]->leaf_view(); // * walk the local grid (manually, to have access to the entity pointer) - const auto local_entity_it_end = local_leaf_view.template end<0>(); - for (auto local_entity_it = local_leaf_view.template begin<0>(); local_entity_it != local_entity_it_end; - ++local_entity_it) { - const auto& local_entity = *local_entity_it; + for (auto&& local_entity : elements(local_leaf_view)) { // logger.debug() << "local_entity: " << local_leaf_view.indexSet().index(local_entity) << " "; if (local_entity.hasBoundaryIntersections()) { // logger.debug() << "(boundary entity)" << std::endl; @@ -862,11 +851,7 @@ private: const auto macro_entity_index = macro_index_set.index(macro_entity); auto& entity_glues = glues_[macro_entity_index]; // walk the neighbors ... - const auto macro_intersection_it_end = macro_leaf_view_.iend(macro_entity); - for (auto macro_intersection_it = macro_leaf_view_.ibegin(macro_entity); - macro_intersection_it != macro_intersection_it_end; - ++macro_intersection_it) { - const auto& macro_intersection = *macro_intersection_it; + for (auto&& macro_intersection : intersections(macro_leaf_view_, macro_entity)) { if (macro_intersection.neighbor() && !macro_intersection.boundary()) { const auto macro_neighbor_ptr = macro_intersection.outside(); # if DUNE_VERSION_GTE(DUNE_GRID, 2, 4) diff --git a/dune/xt/grid/information.hh b/dune/xt/grid/information.hh index 6b65183e910bab34f5b755b2375d900759eac5fb..d301147e86ff47f2de28e99a9cc71a3e65a976ca 100644 --- a/dune/xt/grid/information.hh +++ b/dune/xt/grid/information.hh @@ -51,16 +51,13 @@ struct Statistics , maxGridWidth(0) { for (auto&& entity : elements(grid_layer)) { - const auto intersection_it_end = grid_layer.iend(entity); - for (auto intersection_it = grid_layer.ibegin(entity); intersection_it != intersection_it_end; - ++intersection_it) { - const auto& intIt = *intersection_it; + for (auto&& intersection : intersections(grid_layer, entity)) { ++numberOfIntersections; - maxGridWidth = std::max(intIt.geometry().volume(), maxGridWidth); + maxGridWidth = std::max(intersection.geometry().volume(), maxGridWidth); // if we are inside the grid - numberOfInnerIntersections += (intIt.neighbor() && !intIt.boundary()); + numberOfInnerIntersections += (intersection.neighbor() && !intersection.boundary()); // if we are on the boundary of the grid - numberOfBoundaryIntersections += (!intIt.neighbor() && intIt.boundary()); + numberOfBoundaryIntersections += (!intersection.neighbor() && intersection.boundary()); } } } @@ -88,8 +85,8 @@ size_t max_number_of_neighbors(const GridLayerType& grid_layer) size_t maxNeighbours = 0; for (auto&& entity : elements(grid_layer)) { size_t neighbours = 0; - const auto intersection_it_end = grid_layer.iend(entity); - for (auto intersection_it = grid_layer.ibegin(entity); intersection_it != intersection_it_end; ++intersection_it) { + for (auto&& intersection : intersections(grid_layer, entity)) { + (void)intersection; // silence unused variable warning ++neighbours; } maxNeighbours = std::max(maxNeighbours, neighbours); diff --git a/dune/xt/grid/output/entity_visualization.hh b/dune/xt/grid/output/entity_visualization.hh index cb5d52f85e94cd7bd9772838cb9c37a69737dfaa..8b5e9c19ac62ab7d68125c0397c42a78d19d7eed 100644 --- a/dune/xt/grid/output/entity_visualization.hh +++ b/dune/xt/grid/output/entity_visualization.hh @@ -139,9 +139,7 @@ struct ElementVisualization int numberOfBoundarySegments(0); bool isOnBoundary = false; - const auto intersection_it_end = gridview_.iend(entity); - for (auto intersection_it = gridview_.ibegin(entity); intersection_it != intersection_it_end; ++intersection_it) { - const auto& intersection = *intersection_it; + for (auto&& intersection : intersections(gridview_, entity)) { if (!intersection.neighbor() && intersection.boundary()) { isOnBoundary = true; numberOfBoundarySegments += 1; diff --git a/dune/xt/test/grid/periodic_gridview.cc b/dune/xt/test/grid/periodic_gridview.cc index 13324b949eaa09a946425760f55c055fa21d502c..daac41dacc8705aca265181c5a169cd22f013272 100644 --- a/dune/xt/test/grid/periodic_gridview.cc +++ b/dune/xt/test/grid/periodic_gridview.cc @@ -103,17 +103,13 @@ struct PeriodicViewTest : public testing::Test size_t boundary_count = 0; size_t periodic_count = 0; // iterate over codim 0 entities - const EntityIteratorType it_end = periodic_grid_view.template end<0>(); - for (EntityIteratorType it = periodic_grid_view.template begin<0>(); it != it_end; ++it) { - const EntityType& entity = *it; - EXPECT_TRUE(periodic_grid_view.contains(entity)); - EXPECT_TRUE(index_set.contains(entity)); - const auto sub_index = index_set.subIndex(entity, 0, 1); + for (auto&& element : elements(periodic_grid_view)) { + EXPECT_TRUE(periodic_grid_view.contains(element)); + EXPECT_TRUE(index_set.contains(element)); + const auto sub_index = index_set.subIndex(element, 0, 1); (void)sub_index; - // iterate over all intersections on current entity - const PeriodicIntersectionIteratorType i_it_end = periodic_grid_view.iend(entity); - for (PeriodicIntersectionIteratorType i_it = periodic_grid_view.ibegin(entity); i_it != i_it_end; ++i_it) { - const PeriodicIntersectionType& intersection = *i_it; + // iterate over all intersections on current element + for (auto&& intersection : intersections(periodic_grid_view, element)) { if (intersection.neighbor()) { ++neighbor_count; const EntityType outside = intersection.outside();