]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use iterator filters in tests/. 12971/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 19 Nov 2021 18:29:21 +0000 (11:29 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 19 Nov 2021 18:30:56 +0000 (11:30 -0700)
66 files changed:
tests/boost/extract_representative_set_02.cc
tests/distributed_grids/grid_tools_exchange_cell_data_01.cc
tests/distributed_grids/grid_tools_exchange_cell_data_02.cc
tests/distributed_grids/grid_tools_exchange_cell_data_03.cc
tests/distributed_grids/grid_tools_exchange_cell_data_04.cc
tests/fullydistributed_grids/repartitioning_01.cc
tests/fullydistributed_grids/repartitioning_05.cc
tests/grid/grid_tools_subdomain_association_01.cc
tests/lac/step-40-linear_operator_01.cc
tests/lac/step-40-linear_operator_02.cc
tests/lac/step-40-linear_operator_03.cc
tests/lac/step-40-linear_operator_04.cc
tests/lac/step-40-linear_operator_05.cc
tests/lac/step-40-linear_operator_06.cc
tests/matrix_free/cell_categorization.cc
tests/matrix_free/cell_categorization_02.cc
tests/matrix_free/laplace_operator_03.cc
tests/mpi/error_prediction_01.cc
tests/mpi/error_prediction_02.cc
tests/mpi/hp_constraints_consistent_03.cc
tests/mpi/hp_hanging_node_constraints_02.cc
tests/mpi/hp_step-40_variable_01.cc
tests/mpi/hp_unify_dof_indices_01.cc
tests/mpi/hp_unify_dof_indices_02.cc
tests/mpi/hp_unify_dof_indices_03.cc
tests/mpi/hp_unify_dof_indices_04.cc
tests/mpi/hp_unify_dof_indices_05.cc
tests/mpi/hp_unify_dof_indices_06.cc
tests/mpi/hp_unify_dof_indices_07.cc
tests/mpi/hp_unify_dof_indices_08.cc
tests/mpi/hp_unify_dof_indices_09.cc
tests/mpi/hp_unify_dof_indices_10.cc
tests/mpi/hp_unify_dof_indices_11.cc
tests/mpi/hp_unify_dof_indices_12.cc
tests/mpi/hp_unify_dof_indices_13.cc
tests/mpi/hp_unify_dof_indices_14.cc
tests/mpi/limit_p_level_difference_01.cc
tests/mpi/limit_p_level_difference_02.cc
tests/mpi/limit_p_level_difference_04.cc
tests/mpi/p_refinement_and_coarsening.cc
tests/mpi/petsc_step-27.cc
tests/mpi/refine_and_coarsen_fixed_fraction_08.cc
tests/mpi/refine_and_coarsen_fixed_fraction_09.cc
tests/mpi/refine_and_coarsen_fixed_number_08.cc
tests/mpi/renumber_cuthill_mckee_03.cc
tests/mpi/solution_transfer_05.cc
tests/mpi/trilinos_step-27.cc
tests/multigrid-global-coarsening/mg_transfer_a_03.cc
tests/remote_point_evaluation/mapping_01.cc
tests/remote_point_evaluation/mapping_02.cc
tests/remote_point_evaluation/vector_tools_evaluate_at_points_01.cc
tests/remote_point_evaluation/vector_tools_evaluate_at_points_02.cc
tests/remote_point_evaluation/vector_tools_evaluate_at_points_03.cc
tests/remote_point_evaluation/vector_tools_evaluate_at_points_04.cc
tests/remote_point_evaluation/vector_tools_evaluate_at_points_05.cc
tests/sharedtria/cell_data_transfer_01.cc
tests/sharedtria/cell_data_transfer_02.cc
tests/sharedtria/hp_choose_p_over_h.cc
tests/sharedtria/limit_p_level_difference_01.cc
tests/sharedtria/limit_p_level_difference_02.cc
tests/sharedtria/limit_p_level_difference_03.cc
tests/sharedtria/limit_p_level_difference_04.cc
tests/simplex/step-18.cc
tests/simplex/step-40.cc
tests/simplex/step-55.cc
tests/simplex/step-67.cc

index c083ab08ebd4ac4ecf5f4978f85a381248dd6d75..f2c9867043e0fd31b5127f7731d3c5ab1f9b7191 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <deal.II/distributed/tria.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/grid_tools_cache.h>
 
@@ -59,9 +60,9 @@ test(const unsigned int n_refinements)
 
   std::vector<BoundingBox<2>> all_boxes(tria.n_locally_owned_active_cells());
   unsigned int                i = 0;
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      all_boxes[i++] = cell->bounding_box();
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    all_boxes[i++] = cell->bounding_box();
 
   const auto tree  = pack_rtree(all_boxes);
   const auto boxes = extract_rtree_level(tree, 0);
index 04f46fde2c85d9ef5a33499f25b04d38d31c0156..77366e8dc58414705aeecae4d8746e0afa0b6f7e 100644 (file)
@@ -21,6 +21,7 @@
 #include <deal.II/distributed/tria.h>
 
 #include <deal.II/grid/cell_id.h>
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/grid_out.h>
 #include <deal.II/grid/grid_tools.h>
@@ -51,24 +52,24 @@ test()
     vertices_with_ghost_neighbors =
       GridTools::compute_vertices_with_ghost_neighbors(tria);
 
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        for (const unsigned int v : GeometryInfo<dim>::vertex_indices())
-          {
-            const std::map<unsigned int,
-                           std::set<dealii::types::subdomain_id>>::
-              const_iterator neighbor_subdomains_of_vertex =
-                vertices_with_ghost_neighbors.find(cell->vertex_index(v));
-
-            if (neighbor_subdomains_of_vertex !=
-                vertices_with_ghost_neighbors.end())
-              {
-                map[cell->id()] = ++counter;
-                break;
-              }
-          }
-      }
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      for (const unsigned int v : GeometryInfo<dim>::vertex_indices())
+        {
+          const std::map<unsigned int,
+                         std::set<dealii::types::subdomain_id>>::const_iterator
+            neighbor_subdomains_of_vertex =
+              vertices_with_ghost_neighbors.find(cell->vertex_index(v));
+
+          if (neighbor_subdomains_of_vertex !=
+              vertices_with_ghost_neighbors.end())
+            {
+              map[cell->id()] = ++counter;
+              break;
+            }
+        }
+    }
 
   using cell_iterator =
     typename parallel::distributed::Triangulation<dim>::active_cell_iterator;
index 1cdb25566cdbe438cf229101d57b73c5fc612667..edadccd4e9bafb7ae032d2c0ec66d683fac51193 100644 (file)
@@ -25,6 +25,7 @@
 #include <deal.II/fe/fe_q.h>
 
 #include <deal.II/grid/cell_id.h>
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/grid_out.h>
 #include <deal.II/grid/grid_tools.h>
@@ -60,24 +61,24 @@ test()
     vertices_with_ghost_neighbors =
       GridTools::compute_vertices_with_ghost_neighbors(tria);
 
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        for (const unsigned int v : GeometryInfo<dim>::vertex_indices())
-          {
-            const std::map<unsigned int,
-                           std::set<dealii::types::subdomain_id>>::
-              const_iterator neighbor_subdomains_of_vertex =
-                vertices_with_ghost_neighbors.find(cell->vertex_index(v));
-
-            if (neighbor_subdomains_of_vertex !=
-                vertices_with_ghost_neighbors.end())
-              {
-                map[cell->id()] = ++counter;
-                break;
-              }
-          }
-      }
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      for (const unsigned int v : GeometryInfo<dim>::vertex_indices())
+        {
+          const std::map<unsigned int,
+                         std::set<dealii::types::subdomain_id>>::const_iterator
+            neighbor_subdomains_of_vertex =
+              vertices_with_ghost_neighbors.find(cell->vertex_index(v));
+
+          if (neighbor_subdomains_of_vertex !=
+              vertices_with_ghost_neighbors.end())
+            {
+              map[cell->id()] = ++counter;
+              break;
+            }
+        }
+    }
 
   GridTools::exchange_cell_data_to_ghosts<DT, DoFHandler<dim>>(
     dofhandler,
index c2c35b5c0c5054f77cc4993233b8754bce56a3ab..837baab7740ceefbcb80686723c88521bb220945 100644 (file)
@@ -22,6 +22,7 @@
 #include <deal.II/distributed/tria.h>
 
 #include <deal.II/grid/cell_id.h>
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/grid_out.h>
 #include <deal.II/grid/grid_tools.h>
@@ -58,24 +59,24 @@ test()
     vertices_with_ghost_neighbors =
       GridTools::compute_vertices_with_ghost_neighbors(tria);
 
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        for (const unsigned int v : GeometryInfo<dim>::vertex_indices())
-          {
-            const std::map<unsigned int,
-                           std::set<dealii::types::subdomain_id>>::
-              const_iterator neighbor_subdomains_of_vertex =
-                vertices_with_ghost_neighbors.find(cell->vertex_index(v));
-
-            if (neighbor_subdomains_of_vertex !=
-                vertices_with_ghost_neighbors.end())
-              {
-                map[cell->id()] = ++counter;
-                break;
-              }
-          }
-      }
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      for (const unsigned int v : GeometryInfo<dim>::vertex_indices())
+        {
+          const std::map<unsigned int,
+                         std::set<dealii::types::subdomain_id>>::const_iterator
+            neighbor_subdomains_of_vertex =
+              vertices_with_ghost_neighbors.find(cell->vertex_index(v));
+
+          if (neighbor_subdomains_of_vertex !=
+              vertices_with_ghost_neighbors.end())
+            {
+              map[cell->id()] = ++counter;
+              break;
+            }
+        }
+    }
 
   GridTools::exchange_cell_data_to_ghosts<DT,
                                           parallel::shared::Triangulation<dim>>(
index ff835dbf4ee0007de116557dad1ce2016810bb2f..14474c2ed8e44fb3e748313be0cb6f73bcc999b0 100644 (file)
@@ -25,6 +25,7 @@
 #include <deal.II/distributed/tria.h>
 
 #include <deal.II/grid/cell_id.h>
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/grid_out.h>
 #include <deal.II/grid/grid_tools.h>
@@ -57,24 +58,24 @@ test()
     vertices_with_ghost_neighbors =
       GridTools::compute_vertices_with_ghost_neighbors(tria);
 
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        for (const unsigned int v : GeometryInfo<dim>::vertex_indices())
-          {
-            const std::map<unsigned int,
-                           std::set<dealii::types::subdomain_id>>::
-              const_iterator neighbor_subdomains_of_vertex =
-                vertices_with_ghost_neighbors.find(cell->vertex_index(v));
-
-            if (neighbor_subdomains_of_vertex !=
-                vertices_with_ghost_neighbors.end())
-              {
-                map[cell->id()] = ++counter;
-                break;
-              }
-          }
-      }
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      for (const unsigned int v : GeometryInfo<dim>::vertex_indices())
+        {
+          const std::map<unsigned int,
+                         std::set<dealii::types::subdomain_id>>::const_iterator
+            neighbor_subdomains_of_vertex =
+              vertices_with_ghost_neighbors.find(cell->vertex_index(v));
+
+          if (neighbor_subdomains_of_vertex !=
+              vertices_with_ghost_neighbors.end())
+            {
+              map[cell->id()] = ++counter;
+              break;
+            }
+        }
+    }
 
   GridTools::
     exchange_cell_data_to_ghosts<DT, parallel::distributed::Triangulation<dim>>(
index 0be4c56f4b900c209d0f5772170ef3d00ba4b6a7..630bc2bb363a5db4a669707af7749c77f98bba3d 100644 (file)
@@ -52,10 +52,10 @@ partition_distributed_triangulation(const Triangulation<dim, spacedim> &tria_in,
   LinearAlgebra::distributed::Vector<double> partition(
     tria->global_active_cell_index_partitioner().lock());
 
-  for (const auto &cell : tria_in.active_cell_iterators())
-    if (cell->is_locally_owned())
-      partition[cell->global_active_cell_index()] =
-        std::floor(cell->center()[0] * n_partitions);
+  for (const auto &cell :
+       tria_in.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    partition[cell->global_active_cell_index()] =
+      std::floor(cell->center()[0] * n_partitions);
 
   partition.update_ghost_values();
 
index d1a701a918ed2367e1bc5bb67c293c925d8bf36c..89f4451e74746fe42d45b52853e5525663d8b380 100644 (file)
@@ -89,11 +89,11 @@ partition_distributed_triangulation(const Triangulation<dim, spacedim> &tria_in,
 
   const unsigned int n_partitions = Utilities::MPI::n_mpi_processes(comm);
 
-  for (const auto &cell : tria_in.active_cell_iterators())
-    if (cell->is_locally_owned())
-      partition[cell->global_active_cell_index()] =
-        cell->global_active_cell_index() * n_partitions /
-        tria_in.n_global_active_cells();
+  for (const auto &cell :
+       tria_in.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    partition[cell->global_active_cell_index()] =
+      cell->global_active_cell_index() * n_partitions /
+      tria_in.n_global_active_cells();
 
   partition.update_ghost_values();
 
index adeadcaee5c44692257b102d196ffec6c1b5bc30..066f49558dd70adbdf61266b4370b43eaa0dce48 100644 (file)
@@ -24,6 +24,7 @@
 #include <deal.II/distributed/tria_base.h>
 
 #include <deal.II/grid/cell_id.h>
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_tools.h>
 #include <deal.II/grid/tria.h>
 
@@ -78,9 +79,9 @@ test(parallel::TriangulationBase<dim> &tria)
   {
     std::vector<CellId> local_cell_ids;
     local_cell_ids.reserve(tria.n_active_cells());
-    for (const auto &cell : tria.active_cell_iterators())
-      if (cell->is_locally_owned())
-        local_cell_ids.push_back(cell->id());
+    for (const auto &cell :
+         tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+      local_cell_ids.push_back(cell->id());
 
     std::vector<std::vector<CellId>> cell_ids_per_processor =
       Utilities::MPI::all_gather(MPI_COMM_WORLD, local_cell_ids);
index 789713191cc1329c522b2e9c6a15b576cee22e70..ba0d590cd724211acf54daa5e3fdd71c308b95f8 100644 (file)
@@ -174,44 +174,41 @@ namespace Step40
 
     std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
 
-    for (const auto &cell : dof_handler.active_cell_iterators())
-      if (cell->is_locally_owned())
-        {
-          cell_matrix = 0.;
-          cell_rhs    = 0.;
-
-          fe_values.reinit(cell);
-
-          for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
-            {
-              const double rhs_value =
-                (fe_values.quadrature_point(q_point)[1] >
-                     0.5 +
-                       0.25 * std::sin(4.0 * numbers::PI *
-                                       fe_values.quadrature_point(q_point)[0]) ?
-                   1. :
-                   -1.);
-
-              for (unsigned int i = 0; i < dofs_per_cell; ++i)
-                {
-                  for (unsigned int j = 0; j < dofs_per_cell; ++j)
-                    cell_matrix(i, j) += fe_values.shape_grad(i, q_point) *
-                                         fe_values.shape_grad(j, q_point) *
-                                         fe_values.JxW(q_point);
-
-                  cell_rhs(i) += rhs_value *                         //
-                                 fe_values.shape_value(i, q_point) * //
-                                 fe_values.JxW(q_point);
-                }
-            }
-
-          cell->get_dof_indices(local_dof_indices);
-          constraints.distribute_local_to_global(cell_matrix,
-                                                 cell_rhs,
-                                                 local_dof_indices,
-                                                 system_matrix,
-                                                 system_rhs);
-        }
+    for (const auto &cell : dof_handler.active_cell_iterators() |
+                              IteratorFilters::LocallyOwnedCell())
+      {
+        cell_matrix = 0.;
+        cell_rhs    = 0.;
+
+        fe_values.reinit(cell);
+
+        for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
+          {
+            const double rhs_value =
+              (fe_values.quadrature_point(q_point)[1] >
+                   0.5 +
+                     0.25 * std::sin(4.0 * numbers::PI *
+                                     fe_values.quadrature_point(q_point)[0]) ?
+                 1. :
+                 -1.);
+
+            for (unsigned int i = 0; i < dofs_per_cell; ++i)
+              {
+                for (unsigned int j = 0; j < dofs_per_cell; ++j)
+                  cell_matrix(i, j) += fe_values.shape_grad(i, q_point) *
+                                       fe_values.shape_grad(j, q_point) *
+                                       fe_values.JxW(q_point);
+
+                cell_rhs(i) += rhs_value *                         //
+                               fe_values.shape_value(i, q_point) * //
+                               fe_values.JxW(q_point);
+              }
+          }
+
+        cell->get_dof_indices(local_dof_indices);
+        constraints.distribute_local_to_global(
+          cell_matrix, cell_rhs, local_dof_indices, system_matrix, system_rhs);
+      }
 
     system_matrix.compress(VectorOperation::add);
     system_rhs.compress(VectorOperation::add);
index b8bec22f7cd09b2c73cdabb90b493e0d0fe59fb8..1b924159da580068e0fcc94244faec95fe5e5580 100644 (file)
@@ -174,44 +174,41 @@ namespace Step40
 
     std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
 
-    for (const auto &cell : dof_handler.active_cell_iterators())
-      if (cell->is_locally_owned())
-        {
-          cell_matrix = 0.;
-          cell_rhs    = 0.;
-
-          fe_values.reinit(cell);
-
-          for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
-            {
-              const double rhs_value =
-                (fe_values.quadrature_point(q_point)[1] >
-                     0.5 +
-                       0.25 * std::sin(4.0 * numbers::PI *
-                                       fe_values.quadrature_point(q_point)[0]) ?
-                   1. :
-                   -1.);
-
-              for (unsigned int i = 0; i < dofs_per_cell; ++i)
-                {
-                  for (unsigned int j = 0; j < dofs_per_cell; ++j)
-                    cell_matrix(i, j) += fe_values.shape_grad(i, q_point) *
-                                         fe_values.shape_grad(j, q_point) *
-                                         fe_values.JxW(q_point);
-
-                  cell_rhs(i) += rhs_value *                         //
-                                 fe_values.shape_value(i, q_point) * //
-                                 fe_values.JxW(q_point);
-                }
-            }
-
-          cell->get_dof_indices(local_dof_indices);
-          constraints.distribute_local_to_global(cell_matrix,
-                                                 cell_rhs,
-                                                 local_dof_indices,
-                                                 system_matrix,
-                                                 system_rhs);
-        }
+    for (const auto &cell : dof_handler.active_cell_iterators() |
+                              IteratorFilters::LocallyOwnedCell())
+      {
+        cell_matrix = 0.;
+        cell_rhs    = 0.;
+
+        fe_values.reinit(cell);
+
+        for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
+          {
+            const double rhs_value =
+              (fe_values.quadrature_point(q_point)[1] >
+                   0.5 +
+                     0.25 * std::sin(4.0 * numbers::PI *
+                                     fe_values.quadrature_point(q_point)[0]) ?
+                 1. :
+                 -1.);
+
+            for (unsigned int i = 0; i < dofs_per_cell; ++i)
+              {
+                for (unsigned int j = 0; j < dofs_per_cell; ++j)
+                  cell_matrix(i, j) += fe_values.shape_grad(i, q_point) *
+                                       fe_values.shape_grad(j, q_point) *
+                                       fe_values.JxW(q_point);
+
+                cell_rhs(i) += rhs_value *                         //
+                               fe_values.shape_value(i, q_point) * //
+                               fe_values.JxW(q_point);
+              }
+          }
+
+        cell->get_dof_indices(local_dof_indices);
+        constraints.distribute_local_to_global(
+          cell_matrix, cell_rhs, local_dof_indices, system_matrix, system_rhs);
+      }
 
     system_matrix.compress(VectorOperation::add);
     system_rhs.compress(VectorOperation::add);
index d8438bb62ca96cef48f6f7a7b4cd7cc688e4804c..9144770d1a2064a2f9e3ad4d8985eb13ebff981e 100644 (file)
@@ -175,44 +175,41 @@ namespace Step40
 
     std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
 
-    for (const auto &cell : dof_handler.active_cell_iterators())
-      if (cell->is_locally_owned())
-        {
-          cell_matrix = 0.;
-          cell_rhs    = 0.;
-
-          fe_values.reinit(cell);
-
-          for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
-            {
-              const double rhs_value =
-                (fe_values.quadrature_point(q_point)[1] >
-                     0.5 +
-                       0.25 * std::sin(4.0 * numbers::PI *
-                                       fe_values.quadrature_point(q_point)[0]) ?
-                   1. :
-                   -1.);
-
-              for (unsigned int i = 0; i < dofs_per_cell; ++i)
-                {
-                  for (unsigned int j = 0; j < dofs_per_cell; ++j)
-                    cell_matrix(i, j) += fe_values.shape_grad(i, q_point) *
-                                         fe_values.shape_grad(j, q_point) *
-                                         fe_values.JxW(q_point);
-
-                  cell_rhs(i) += rhs_value *                         //
-                                 fe_values.shape_value(i, q_point) * //
-                                 fe_values.JxW(q_point);
-                }
-            }
-
-          cell->get_dof_indices(local_dof_indices);
-          constraints.distribute_local_to_global(cell_matrix,
-                                                 cell_rhs,
-                                                 local_dof_indices,
-                                                 system_matrix,
-                                                 system_rhs);
-        }
+    for (const auto &cell : dof_handler.active_cell_iterators() |
+                              IteratorFilters::LocallyOwnedCell())
+      {
+        cell_matrix = 0.;
+        cell_rhs    = 0.;
+
+        fe_values.reinit(cell);
+
+        for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
+          {
+            const double rhs_value =
+              (fe_values.quadrature_point(q_point)[1] >
+                   0.5 +
+                     0.25 * std::sin(4.0 * numbers::PI *
+                                     fe_values.quadrature_point(q_point)[0]) ?
+                 1. :
+                 -1.);
+
+            for (unsigned int i = 0; i < dofs_per_cell; ++i)
+              {
+                for (unsigned int j = 0; j < dofs_per_cell; ++j)
+                  cell_matrix(i, j) += fe_values.shape_grad(i, q_point) *
+                                       fe_values.shape_grad(j, q_point) *
+                                       fe_values.JxW(q_point);
+
+                cell_rhs(i) += rhs_value *                         //
+                               fe_values.shape_value(i, q_point) * //
+                               fe_values.JxW(q_point);
+              }
+          }
+
+        cell->get_dof_indices(local_dof_indices);
+        constraints.distribute_local_to_global(
+          cell_matrix, cell_rhs, local_dof_indices, system_matrix, system_rhs);
+      }
 
     system_matrix.compress(VectorOperation::add);
     system_rhs.compress(VectorOperation::add);
index d7fe515bf4e36e5d442c4959509db7e3e70c637b..70156c97580c5eaf5e3f030d69a8407c81e05154 100644 (file)
@@ -175,44 +175,41 @@ namespace Step40
 
     std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
 
-    for (const auto &cell : dof_handler.active_cell_iterators())
-      if (cell->is_locally_owned())
-        {
-          cell_matrix = 0.;
-          cell_rhs    = 0.;
-
-          fe_values.reinit(cell);
-
-          for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
-            {
-              const double rhs_value =
-                (fe_values.quadrature_point(q_point)[1] >
-                     0.5 +
-                       0.25 * std::sin(4.0 * numbers::PI *
-                                       fe_values.quadrature_point(q_point)[0]) ?
-                   1. :
-                   -1.);
-
-              for (unsigned int i = 0; i < dofs_per_cell; ++i)
-                {
-                  for (unsigned int j = 0; j < dofs_per_cell; ++j)
-                    cell_matrix(i, j) += fe_values.shape_grad(i, q_point) *
-                                         fe_values.shape_grad(j, q_point) *
-                                         fe_values.JxW(q_point);
-
-                  cell_rhs(i) += rhs_value *                         //
-                                 fe_values.shape_value(i, q_point) * //
-                                 fe_values.JxW(q_point);
-                }
-            }
-
-          cell->get_dof_indices(local_dof_indices);
-          constraints.distribute_local_to_global(cell_matrix,
-                                                 cell_rhs,
-                                                 local_dof_indices,
-                                                 system_matrix,
-                                                 system_rhs);
-        }
+    for (const auto &cell : dof_handler.active_cell_iterators() |
+                              IteratorFilters::LocallyOwnedCell())
+      {
+        cell_matrix = 0.;
+        cell_rhs    = 0.;
+
+        fe_values.reinit(cell);
+
+        for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
+          {
+            const double rhs_value =
+              (fe_values.quadrature_point(q_point)[1] >
+                   0.5 +
+                     0.25 * std::sin(4.0 * numbers::PI *
+                                     fe_values.quadrature_point(q_point)[0]) ?
+                 1. :
+                 -1.);
+
+            for (unsigned int i = 0; i < dofs_per_cell; ++i)
+              {
+                for (unsigned int j = 0; j < dofs_per_cell; ++j)
+                  cell_matrix(i, j) += fe_values.shape_grad(i, q_point) *
+                                       fe_values.shape_grad(j, q_point) *
+                                       fe_values.JxW(q_point);
+
+                cell_rhs(i) += rhs_value *                         //
+                               fe_values.shape_value(i, q_point) * //
+                               fe_values.JxW(q_point);
+              }
+          }
+
+        cell->get_dof_indices(local_dof_indices);
+        constraints.distribute_local_to_global(
+          cell_matrix, cell_rhs, local_dof_indices, system_matrix, system_rhs);
+      }
 
     system_matrix.compress(VectorOperation::add);
     system_rhs.compress(VectorOperation::add);
index d752d26dd3868935e4cb10f0ae2772ac684bb095..e5858dd24c8b937c49be74d3ea3d6d5dbed58403 100644 (file)
@@ -175,44 +175,41 @@ namespace Step40
 
     std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
 
-    for (const auto &cell : dof_handler.active_cell_iterators())
-      if (cell->is_locally_owned())
-        {
-          cell_matrix = 0.;
-          cell_rhs    = 0.;
-
-          fe_values.reinit(cell);
-
-          for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
-            {
-              const double rhs_value =
-                (fe_values.quadrature_point(q_point)[1] >
-                     0.5 +
-                       0.25 * std::sin(4.0 * numbers::PI *
-                                       fe_values.quadrature_point(q_point)[0]) ?
-                   1. :
-                   -1.);
-
-              for (unsigned int i = 0; i < dofs_per_cell; ++i)
-                {
-                  for (unsigned int j = 0; j < dofs_per_cell; ++j)
-                    cell_matrix(i, j) += fe_values.shape_grad(i, q_point) *
-                                         fe_values.shape_grad(j, q_point) *
-                                         fe_values.JxW(q_point);
-
-                  cell_rhs(i) += rhs_value *                         //
-                                 fe_values.shape_value(i, q_point) * //
-                                 fe_values.JxW(q_point);
-                }
-            }
-
-          cell->get_dof_indices(local_dof_indices);
-          constraints.distribute_local_to_global(cell_matrix,
-                                                 cell_rhs,
-                                                 local_dof_indices,
-                                                 system_matrix,
-                                                 system_rhs);
-        }
+    for (const auto &cell : dof_handler.active_cell_iterators() |
+                              IteratorFilters::LocallyOwnedCell())
+      {
+        cell_matrix = 0.;
+        cell_rhs    = 0.;
+
+        fe_values.reinit(cell);
+
+        for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
+          {
+            const double rhs_value =
+              (fe_values.quadrature_point(q_point)[1] >
+                   0.5 +
+                     0.25 * std::sin(4.0 * numbers::PI *
+                                     fe_values.quadrature_point(q_point)[0]) ?
+                 1. :
+                 -1.);
+
+            for (unsigned int i = 0; i < dofs_per_cell; ++i)
+              {
+                for (unsigned int j = 0; j < dofs_per_cell; ++j)
+                  cell_matrix(i, j) += fe_values.shape_grad(i, q_point) *
+                                       fe_values.shape_grad(j, q_point) *
+                                       fe_values.JxW(q_point);
+
+                cell_rhs(i) += rhs_value *                         //
+                               fe_values.shape_value(i, q_point) * //
+                               fe_values.JxW(q_point);
+              }
+          }
+
+        cell->get_dof_indices(local_dof_indices);
+        constraints.distribute_local_to_global(
+          cell_matrix, cell_rhs, local_dof_indices, system_matrix, system_rhs);
+      }
 
     system_matrix.compress(VectorOperation::add);
     system_rhs.compress(VectorOperation::add);
index 91f3f253d826672a5717dea2244ff4bd2f22a248..0b47d597f9f9271a382479e88db7edca85f731a4 100644 (file)
@@ -175,44 +175,41 @@ namespace Step40
 
     std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
 
-    for (const auto &cell : dof_handler.active_cell_iterators())
-      if (cell->is_locally_owned())
-        {
-          cell_matrix = 0.;
-          cell_rhs    = 0.;
-
-          fe_values.reinit(cell);
-
-          for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
-            {
-              const double rhs_value =
-                (fe_values.quadrature_point(q_point)[1] >
-                     0.5 +
-                       0.25 * std::sin(4.0 * numbers::PI *
-                                       fe_values.quadrature_point(q_point)[0]) ?
-                   1. :
-                   -1.);
-
-              for (unsigned int i = 0; i < dofs_per_cell; ++i)
-                {
-                  for (unsigned int j = 0; j < dofs_per_cell; ++j)
-                    cell_matrix(i, j) += fe_values.shape_grad(i, q_point) *
-                                         fe_values.shape_grad(j, q_point) *
-                                         fe_values.JxW(q_point);
-
-                  cell_rhs(i) += rhs_value *                         //
-                                 fe_values.shape_value(i, q_point) * //
-                                 fe_values.JxW(q_point);
-                }
-            }
-
-          cell->get_dof_indices(local_dof_indices);
-          constraints.distribute_local_to_global(cell_matrix,
-                                                 cell_rhs,
-                                                 local_dof_indices,
-                                                 system_matrix,
-                                                 system_rhs);
-        }
+    for (const auto &cell : dof_handler.active_cell_iterators() |
+                              IteratorFilters::LocallyOwnedCell())
+      {
+        cell_matrix = 0.;
+        cell_rhs    = 0.;
+
+        fe_values.reinit(cell);
+
+        for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
+          {
+            const double rhs_value =
+              (fe_values.quadrature_point(q_point)[1] >
+                   0.5 +
+                     0.25 * std::sin(4.0 * numbers::PI *
+                                     fe_values.quadrature_point(q_point)[0]) ?
+                 1. :
+                 -1.);
+
+            for (unsigned int i = 0; i < dofs_per_cell; ++i)
+              {
+                for (unsigned int j = 0; j < dofs_per_cell; ++j)
+                  cell_matrix(i, j) += fe_values.shape_grad(i, q_point) *
+                                       fe_values.shape_grad(j, q_point) *
+                                       fe_values.JxW(q_point);
+
+                cell_rhs(i) += rhs_value *                         //
+                               fe_values.shape_value(i, q_point) * //
+                               fe_values.JxW(q_point);
+              }
+          }
+
+        cell->get_dof_indices(local_dof_indices);
+        constraints.distribute_local_to_global(
+          cell_matrix, cell_rhs, local_dof_indices, system_matrix, system_rhs);
+      }
 
     system_matrix.compress(VectorOperation::add);
     system_rhs.compress(VectorOperation::add);
index 7e03e5652201304e9dda60bf4ebf71fe233ab790..d3aa1fe5118b9484d86b10225d9ee16b0bef4a92 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <deal.II/fe/fe_dgq.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_tools.h>
 
 #include <deal.II/matrix_free/matrix_free.h>
@@ -80,10 +81,10 @@ test()
     (update_gradients | update_JxW_values);
 
   data.cell_vectorization_category.resize(tria.n_active_cells());
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      data.cell_vectorization_category[cell->active_cell_index()] =
-        static_cast<unsigned int>(cell->center()[1] * 10.);
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    data.cell_vectorization_category[cell->active_cell_index()] =
+      static_cast<unsigned int>(cell->center()[1] * 10.);
 
   data.cell_vectorization_categories_strict = false;
   mf_data.reinit(dof, constraints, QGauss<1>(2), data);
index f99a38a3ac51a6c51987ac33eefab9e09a43e1e6..8539f2fe436a04f11b1e280476344e765425e0de 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/grid_tools.h>
 
@@ -103,13 +104,13 @@ test()
 
   data.cell_vectorization_categories_strict = true;
   data.cell_vectorization_category.resize(tria.n_active_cells());
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        AssertIndexRange(cell->active_cell_index(), tria.n_active_cells());
-        data.cell_vectorization_category[cell->active_cell_index()] =
-          cell->material_id();
-      }
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      AssertIndexRange(cell->active_cell_index(), tria.n_active_cells());
+      data.cell_vectorization_category[cell->active_cell_index()] =
+        cell->material_id();
+    }
 
   mf_data.reinit(dof, constraints, QGauss<1>(2), data);
 
index f336e1fe92d0e2a74b9c8dde038876bc037f3be0..f3e7cbf4a03b14f0758e2bfaedcf43ff89a1d273 100644 (file)
@@ -29,6 +29,7 @@
 #include <deal.II/fe/fe_q.h>
 #include <deal.II/fe/fe_values.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/manifold_lib.h>
 
@@ -71,10 +72,10 @@ test()
   for (unsigned int i = 0; i < 10 - 3 * dim; ++i)
     {
       unsigned int counter = 0;
-      for (const auto &cell : tria.active_cell_iterators())
-        if (cell->is_locally_owned())
-          if (counter++ % (7 - i) == 0)
-            cell->set_refine_flag();
+      for (const auto &cell :
+           tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+        if (counter++ % (7 - i) == 0)
+          cell->set_refine_flag();
       tria.execute_coarsening_and_refinement();
     }
 
index 0d9f19766edb6da976666c65782349c427650002..1f9a311ba549288089a578ade9ee053839ea47ab 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
+
 #include <deal.II/hp/refinement.h>
 
 #include <deal.II/lac/vector.h>
@@ -133,11 +135,11 @@ test()
 
   // ------ verify ------
   deallog << "post_adaptation" << std::endl;
-  for (const auto &cell : dh.active_cell_iterators())
-    if (cell->is_locally_owned())
-      deallog << " cell:" << cell->id().to_string()
-              << " predicted:" << predicted_errors(cell->active_cell_index())
-              << std::endl;
+  for (const auto &cell :
+       dh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    deallog << " cell:" << cell->id().to_string()
+            << " predicted:" << predicted_errors(cell->active_cell_index())
+            << std::endl;
 
   // make sure no processor is hanging
   MPI_Barrier(MPI_COMM_WORLD);
index 58c6cadb5ec912d6d27ee5209a33f8a677620d48..c03f34f729ac8dd4db21a0fbf56bb94efe42c420 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
+
 #include <deal.II/hp/refinement.h>
 
 #include <deal.II/lac/vector.h>
@@ -159,11 +161,11 @@ test()
 
   // ------ verify ------
   deallog << "post_adaptation" << std::endl;
-  for (const auto &cell : dh.active_cell_iterators())
-    if (cell->is_locally_owned())
-      deallog << " cell:" << cell->id().to_string()
-              << " predicted:" << predicted_errors(cell->active_cell_index())
-              << std::endl;
+  for (const auto &cell :
+       dh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    deallog << " cell:" << cell->id().to_string()
+            << " predicted:" << predicted_errors(cell->active_cell_index())
+            << std::endl;
 
   // make sure no processor is hanging
   MPI_Barrier(MPI_COMM_WORLD);
index 4a133fff7cd5dc53f3d1fe9a3895b88a7ef6d323..22f5319392f6ccf8094c7ab26ec5530ee7037fe5 100644 (file)
@@ -40,6 +40,7 @@
 #include <deal.II/fe/fe_q.h>
 #include <deal.II/fe/fe_system.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/hp/fe_collection.h>
@@ -81,37 +82,37 @@ test(const unsigned int degree_center,
   // prepare DoFHandler
   DoFHandler<dim> dh(tria);
 
-  for (const auto &cell : dh.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        if (cell->id().to_string() == "1_0:")
-          {
-            // set different FE on center cell
-            cell->set_active_fe_index(1);
+  for (const auto &cell :
+       dh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      if (cell->id().to_string() == "1_0:")
+        {
+          // set different FE on center cell
+          cell->set_active_fe_index(1);
 
 #ifdef DEBUG
-            // verify that our scenario is initialized correctly
-            // by checking the number of neighbors of the center cell
-            unsigned int n_neighbors = 0;
-            for (const unsigned int i : GeometryInfo<dim>::face_indices())
-              if (static_cast<unsigned int>(cell->neighbor_index(i)) !=
-                  numbers::invalid_unsigned_int)
-                ++n_neighbors;
-            Assert(n_neighbors == 3, ExcInternalError());
+          // verify that our scenario is initialized correctly
+          // by checking the number of neighbors of the center cell
+          unsigned int n_neighbors = 0;
+          for (const unsigned int i : GeometryInfo<dim>::face_indices())
+            if (static_cast<unsigned int>(cell->neighbor_index(i)) !=
+                numbers::invalid_unsigned_int)
+              ++n_neighbors;
+          Assert(n_neighbors == 3, ExcInternalError());
 #endif
-          }
-        else if (cell->id().to_string() == "0_0:")
-          {
-            // set different boundary id on leftmost cell
-            for (const unsigned int f : GeometryInfo<dim>::face_indices())
-              if (cell->face(f)->at_boundary())
-                cell->face(f)->set_boundary_id(1);
-
-            // verify that our scenario is initialized correctly
-            // by checking the cell's location
-            Assert(cell->center()[0] < 0, ExcInternalError());
-          }
-      }
+        }
+      else if (cell->id().to_string() == "0_0:")
+        {
+          // set different boundary id on leftmost cell
+          for (const unsigned int f : GeometryInfo<dim>::face_indices())
+            if (cell->face(f)->at_boundary())
+              cell->face(f)->set_boundary_id(1);
+
+          // verify that our scenario is initialized correctly
+          // by checking the cell's location
+          Assert(cell->center()[0] < 0, ExcInternalError());
+        }
+    }
 
   dh.distribute_dofs(fe_collection);
 
index fd1d0dd39cc08ca65389d037a2d371fd76cd435c..c1798c2bddb5bdefc39673e8cc846bee759c8467 100644 (file)
@@ -33,6 +33,7 @@
 #include <deal.II/fe/fe_q.h>
 #include <deal.II/fe/fe_system.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/hp/fe_collection.h>
@@ -81,14 +82,14 @@ test()
   DoFHandler<dim> dof_handler(triangulation);
 
   // Assign void_fe to all the cells with x < 0.5
-  for (const auto &cell : dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        if (cell->center()(0) < 0.5)
-          cell->set_active_fe_index(0);
-        else
-          cell->set_active_fe_index(1);
-      }
+  for (const auto &cell : dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    {
+      if (cell->center()(0) < 0.5)
+        cell->set_active_fe_index(0);
+      else
+        cell->set_active_fe_index(1);
+    }
 
   dof_handler.distribute_dofs(fe_collection);
 
index 7877160e6b18d62db242daab3df03b213ef1ff84..d3125590886f0baf7ae63bcb63ab6a723a503bce 100644 (file)
@@ -138,9 +138,9 @@ namespace Step40
   LaplaceProblem<dim>::setup_system()
   {
     // set active_fe_index mostly randomly
-    for (const auto &cell : dof_handler.active_cell_iterators())
-      if (cell->is_locally_owned())
-        cell->set_active_fe_index(cell->active_cell_index() % fe.size());
+    for (const auto &cell : dof_handler.active_cell_iterators() |
+                              IteratorFilters::LocallyOwnedCell())
+      cell->set_active_fe_index(cell->active_cell_index() % fe.size());
 
     dof_handler.distribute_dofs(fe);
 
index 8f47d8e2985a6ed2ede7e2f9a195cdae61e16514..2242327a1e7bc891221180c112d794a09fa74463 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/intergrid_map.h>
 #include <deal.II/grid/tria_accessor.h>
index 599aedeea9473c1c8ae68e7925bfbaba369e722f..36c6398b880aa77ab1a9f66fcb56c54219e2a8ed 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/intergrid_map.h>
 #include <deal.II/grid/tria_accessor.h>
@@ -74,18 +75,18 @@ test()
   fe.push_back(FE_Q<dim>(2));
 
   DoFHandler<dim> dof_handler(triangulation);
-  for (const auto &cell : dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        if (cell->id().to_string() == "0_0:")
-          cell->set_active_fe_index(0);
-        if (cell->id().to_string() == "1_0:")
-          cell->set_active_fe_index(1);
-        if (cell->id().to_string() == "2_0:")
-          cell->set_active_fe_index(2);
-        if (cell->id().to_string() == "3_0:")
-          cell->set_active_fe_index(0);
-      }
+  for (const auto &cell : dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    {
+      if (cell->id().to_string() == "0_0:")
+        cell->set_active_fe_index(0);
+      if (cell->id().to_string() == "1_0:")
+        cell->set_active_fe_index(1);
+      if (cell->id().to_string() == "2_0:")
+        cell->set_active_fe_index(2);
+      if (cell->id().to_string() == "3_0:")
+        cell->set_active_fe_index(0);
+    }
   dof_handler.distribute_dofs(fe);
 
   log_dof_diagnostics(dof_handler);
index 4abac11f12727a517544a37a111344968b85c57b..f991b5316dc08fcce5205150e215310aba350a9c 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/intergrid_map.h>
 #include <deal.II/grid/tria_accessor.h>
@@ -71,18 +72,18 @@ test()
   fe.push_back(FE_Q<dim>(2));
 
   DoFHandler<dim> dof_handler(triangulation);
-  for (const auto &cell : dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        if (cell->id().to_string() == "0_0:")
-          cell->set_active_fe_index(0);
-        if (cell->id().to_string() == "1_0:")
-          cell->set_active_fe_index(1);
-        if (cell->id().to_string() == "2_0:")
-          cell->set_active_fe_index(1);
-        if (cell->id().to_string() == "3_0:")
-          cell->set_active_fe_index(0);
-      }
+  for (const auto &cell : dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    {
+      if (cell->id().to_string() == "0_0:")
+        cell->set_active_fe_index(0);
+      if (cell->id().to_string() == "1_0:")
+        cell->set_active_fe_index(1);
+      if (cell->id().to_string() == "2_0:")
+        cell->set_active_fe_index(1);
+      if (cell->id().to_string() == "3_0:")
+        cell->set_active_fe_index(0);
+    }
   dof_handler.distribute_dofs(fe);
 
   log_dof_diagnostics(dof_handler);
index c9ee41e3a7f2b4930c2001ff9d17a669b1b9cfad..98fb1fbe8cdc511ba3148bf5bd584ac1a90306ae 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/intergrid_map.h>
 #include <deal.II/grid/tria_accessor.h>
@@ -72,18 +73,18 @@ test()
   fe.push_back(FE_Q<dim>(2));
 
   DoFHandler<dim> dof_handler(triangulation);
-  for (const auto &cell : dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        if (cell->id().to_string() == "0_0:")
-          cell->set_active_fe_index(0);
-        if (cell->id().to_string() == "1_0:")
-          cell->set_active_fe_index(0);
-        if (cell->id().to_string() == "2_0:")
-          cell->set_active_fe_index(1);
-        if (cell->id().to_string() == "3_0:")
-          cell->set_active_fe_index(1);
-      }
+  for (const auto &cell : dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    {
+      if (cell->id().to_string() == "0_0:")
+        cell->set_active_fe_index(0);
+      if (cell->id().to_string() == "1_0:")
+        cell->set_active_fe_index(0);
+      if (cell->id().to_string() == "2_0:")
+        cell->set_active_fe_index(1);
+      if (cell->id().to_string() == "3_0:")
+        cell->set_active_fe_index(1);
+    }
   dof_handler.distribute_dofs(fe);
 
   log_dof_diagnostics(dof_handler);
index 0496ee418ccddfe9642d49ff3a5ae8b04130c166..8adc7a7b62f60be18a4ef7327c40d8d62fd0f765 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/intergrid_map.h>
 #include <deal.II/grid/tria_accessor.h>
@@ -72,18 +73,18 @@ test()
   fe.push_back(FE_Q<dim>(2));
 
   DoFHandler<dim> dof_handler(triangulation);
-  for (const auto &cell : dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        if (cell->id().to_string() == "0_0:")
-          cell->set_active_fe_index(0);
-        if (cell->id().to_string() == "1_0:")
-          cell->set_active_fe_index(1);
-        if (cell->id().to_string() == "2_0:")
-          cell->set_active_fe_index(0);
-        if (cell->id().to_string() == "3_0:")
-          cell->set_active_fe_index(1);
-      }
+  for (const auto &cell : dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    {
+      if (cell->id().to_string() == "0_0:")
+        cell->set_active_fe_index(0);
+      if (cell->id().to_string() == "1_0:")
+        cell->set_active_fe_index(1);
+      if (cell->id().to_string() == "2_0:")
+        cell->set_active_fe_index(0);
+      if (cell->id().to_string() == "3_0:")
+        cell->set_active_fe_index(1);
+    }
   dof_handler.distribute_dofs(fe);
 
   log_dof_diagnostics(dof_handler);
index 6ffc4614e3c4313948c1afc8462cefe93b0b8e0a..3afa8342b1442f0f60c4b6a0fceba847c596f6f9 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/intergrid_map.h>
 #include <deal.II/grid/tria_accessor.h>
@@ -73,18 +74,18 @@ test()
 
 
   DoFHandler<dim> dof_handler(triangulation);
-  for (const auto &cell : dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        if (cell->id().to_string() == "0_0:")
-          cell->set_active_fe_index(0);
-        if (cell->id().to_string() == "1_0:")
-          cell->set_active_fe_index(0);
-        if (cell->id().to_string() == "2_0:")
-          cell->set_active_fe_index(1);
-        if (cell->id().to_string() == "3_0:")
-          cell->set_active_fe_index(0);
-      }
+  for (const auto &cell : dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    {
+      if (cell->id().to_string() == "0_0:")
+        cell->set_active_fe_index(0);
+      if (cell->id().to_string() == "1_0:")
+        cell->set_active_fe_index(0);
+      if (cell->id().to_string() == "2_0:")
+        cell->set_active_fe_index(1);
+      if (cell->id().to_string() == "3_0:")
+        cell->set_active_fe_index(0);
+    }
   dof_handler.distribute_dofs(fe);
 
   log_dof_diagnostics(dof_handler);
index b0190ef4e70c8fa4e7fee849b127d63f0f30913b..b405d72ef8ca7581c4772aed97dda031bbb35aa2 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/intergrid_map.h>
 #include <deal.II/grid/tria_accessor.h>
index 1adb3913e0250b2f4397efefff3e6fa255d345be..b282159fb7de6c88b8dc634b203308c801876fa7 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_in.h>
 #include <deal.II/grid/intergrid_map.h>
 #include <deal.II/grid/tria_accessor.h>
@@ -89,12 +90,12 @@ test()
   // that to build a hash value from it that is then used to assign an
   // active_fe_index
   DoFHandler<dim> dof_handler(triangulation);
-  for (const auto &cell : dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      cell->set_active_fe_index(
-        (cell->active_cell_index() +
-         13 * cell->active_cell_index() * cell->active_cell_index()) %
-        fe.size());
+  for (const auto &cell : dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    cell->set_active_fe_index(
+      (cell->active_cell_index() +
+       13 * cell->active_cell_index() * cell->active_cell_index()) %
+      fe.size());
   dof_handler.distribute_dofs(fe);
 
   deallog << "n_globally_active_cells: "
index 0d7905e23309d6767df55769c7f61d49f9641c95..b3f2c7fad961fab6b451f1da6fd4791f4acfc360 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/tria_accessor.h>
 #include <deal.II/grid/tria_iterator.h>
@@ -59,9 +60,9 @@ test(MPI_Comm mpi_communicator)
   DoFHandler<dim> dof_handler(triangulation);
 
   // set active_fe_index mostly randomly
-  for (const auto &cell : dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      cell->set_active_fe_index(cell->active_cell_index() % fe.size());
+  for (const auto &cell : dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    cell->set_active_fe_index(cell->active_cell_index() % fe.size());
 
   dof_handler.distribute_dofs(fe);
 
index 090d13b0aa3812db80f6f82ed1f4a7376bf6cb9c..b91468b55f3604b4521a4f5a2a6ad2d292cd0174 100644 (file)
@@ -35,6 +35,7 @@
 #include <deal.II/fe/fe_q.h>
 #include <deal.II/fe/fe_system.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/intergrid_map.h>
 #include <deal.II/grid/tria_accessor.h>
@@ -75,18 +76,18 @@ test()
   fe.push_back(FESystem<dim>(FE_Q<dim>(2), dim));
 
   DoFHandler<dim> dof_handler(triangulation);
-  for (const auto &cell : dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        if (cell->id().to_string() == "0_0:")
-          cell->set_active_fe_index(0);
-        if (cell->id().to_string() == "1_0:")
-          cell->set_active_fe_index(1);
-        if (cell->id().to_string() == "2_0:")
-          cell->set_active_fe_index(2);
-        if (cell->id().to_string() == "3_0:")
-          cell->set_active_fe_index(0);
-      }
+  for (const auto &cell : dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    {
+      if (cell->id().to_string() == "0_0:")
+        cell->set_active_fe_index(0);
+      if (cell->id().to_string() == "1_0:")
+        cell->set_active_fe_index(1);
+      if (cell->id().to_string() == "2_0:")
+        cell->set_active_fe_index(2);
+      if (cell->id().to_string() == "3_0:")
+        cell->set_active_fe_index(0);
+    }
   dof_handler.distribute_dofs(fe);
 
   log_dof_diagnostics(dof_handler);
index 56067b74515832ee580a0940db73cd459d691623..d9bd5ddfa098604926fe8439739ec990c521e56d 100644 (file)
@@ -30,6 +30,7 @@
 #include <deal.II/fe/fe_q.h>
 #include <deal.II/fe/fe_system.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/hp/fe_collection.h>
@@ -54,14 +55,14 @@ test()
   fe.push_back(FESystem<dim>(FE_Q<dim>(2), 1, FE_Q<dim>(1), 1));
 
   DoFHandler<dim> dof_handler(triangulation);
-  for (const auto &cell : dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        if (cell->id().to_string() == "0_0:")
-          cell->set_active_fe_index(0);
-        if (cell->id().to_string() == "1_0:")
-          cell->set_active_fe_index(1);
-      }
+  for (const auto &cell : dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    {
+      if (cell->id().to_string() == "0_0:")
+        cell->set_active_fe_index(0);
+      if (cell->id().to_string() == "1_0:")
+        cell->set_active_fe_index(1);
+    }
   dof_handler.distribute_dofs(fe);
 
   log_dof_diagnostics(dof_handler);
index f8edd3386ca10fb15785034bc7b25d9def1413c7..de0380b17718fe447dbb5a294189d4fc77a5d4ff 100644 (file)
@@ -30,6 +30,7 @@
 #include <deal.II/fe/fe_q.h>
 #include <deal.II/fe/fe_system.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/hp/fe_collection.h>
@@ -64,18 +65,18 @@ test()
   fe.push_back(FE_Q<dim>(2));
 
   DoFHandler<dim> dof_handler(triangulation);
-  for (const auto &cell : dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        if (cell->id().to_string() == "0_0:")
-          cell->set_active_fe_index(1);
-        if (cell->id().to_string() == "1_0:")
-          cell->set_active_fe_index(0);
-        if (cell->id().to_string() == "2_0:")
-          cell->set_active_fe_index(0);
-        if (cell->id().to_string() == "3_0:")
-          cell->set_active_fe_index(1);
-      }
+  for (const auto &cell : dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    {
+      if (cell->id().to_string() == "0_0:")
+        cell->set_active_fe_index(1);
+      if (cell->id().to_string() == "1_0:")
+        cell->set_active_fe_index(0);
+      if (cell->id().to_string() == "2_0:")
+        cell->set_active_fe_index(0);
+      if (cell->id().to_string() == "3_0:")
+        cell->set_active_fe_index(1);
+    }
   dof_handler.distribute_dofs(fe);
 
   log_dof_diagnostics(dof_handler);
index 62c6d4713f15c089a2dfc97894e8ffcd7d4dddde..3e3ced8780a624e6428c45d94342a17fc6708cf3 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/hp/fe_collection.h>
@@ -60,18 +61,18 @@ test()
     fe.push_back(FE_Q<dim>(d));
 
   DoFHandler<dim> dof_handler(triangulation);
-  for (const auto &cell : dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        if (cell->id().to_string() == "0_0:")
-          cell->set_active_fe_index(0);
-        if (cell->id().to_string() == "1_0:")
-          cell->set_active_fe_index(1);
-        if (cell->id().to_string() == "2_0:")
-          cell->set_active_fe_index(2);
-        if (cell->id().to_string() == "3_0:")
-          cell->set_active_fe_index(3);
-      }
+  for (const auto &cell : dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    {
+      if (cell->id().to_string() == "0_0:")
+        cell->set_active_fe_index(0);
+      if (cell->id().to_string() == "1_0:")
+        cell->set_active_fe_index(1);
+      if (cell->id().to_string() == "2_0:")
+        cell->set_active_fe_index(2);
+      if (cell->id().to_string() == "3_0:")
+        cell->set_active_fe_index(3);
+    }
   dof_handler.distribute_dofs(fe);
 
   log_dof_diagnostics(dof_handler);
index 1f8859375e2021b42ad55081c8e17b778581ed80..a0fdcacce606cf9c134ac5a6cbf91e3509fbc534 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/hp/fe_collection.h>
@@ -60,18 +61,18 @@ test()
     fe.push_back(FE_Q<dim>(d));
 
   DoFHandler<dim> dof_handler(triangulation);
-  for (const auto &cell : dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        if (cell->id().to_string() == "0_0:")
-          cell->set_active_fe_index(0);
-        if (cell->id().to_string() == "1_0:")
-          cell->set_active_fe_index(1);
-        if (cell->id().to_string() == "2_0:")
-          cell->set_active_fe_index(2);
-        if (cell->id().to_string() == "3_0:")
-          cell->set_active_fe_index(3);
-      }
+  for (const auto &cell : dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    {
+      if (cell->id().to_string() == "0_0:")
+        cell->set_active_fe_index(0);
+      if (cell->id().to_string() == "1_0:")
+        cell->set_active_fe_index(1);
+      if (cell->id().to_string() == "2_0:")
+        cell->set_active_fe_index(2);
+      if (cell->id().to_string() == "3_0:")
+        cell->set_active_fe_index(3);
+    }
   dof_handler.distribute_dofs(fe);
 
   log_dof_diagnostics(dof_handler);
index 1b6504203bdd78e5af3f8be0292cbdb7144bec87..38d935c1b9a73142ec1deb0de69e5888c4818a1c 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/hp/fe_collection.h>
@@ -101,17 +102,17 @@ test(const unsigned int fes_size, const unsigned int max_difference)
 
 #ifdef DEBUG
   // check each cell's active FE index by its distance from the center
-  for (const auto &cell : dofh.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        const double       distance = cell->center().distance(Point<dim>());
-        const unsigned int expected_level =
-          (sequence.size() - 1) -
-          max_difference * static_cast<unsigned int>(std::round(distance));
-
-        Assert(cell->active_fe_index() == sequence[expected_level],
-               ExcInternalError());
-      }
+  for (const auto &cell :
+       dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      const double       distance = cell->center().distance(Point<dim>());
+      const unsigned int expected_level =
+        (sequence.size() - 1) -
+        max_difference * static_cast<unsigned int>(std::round(distance));
+
+      Assert(cell->active_fe_index() == sequence[expected_level],
+             ExcInternalError());
+    }
 #endif
 
   deallog << "OK" << std::endl;
index 929b7d763259644dc87483672af39a3c53e024ba..6858278a6f1eb19859547c7d07b2e168e4e95c7e 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/hp/fe_collection.h>
@@ -108,17 +109,17 @@ test(const unsigned int fes_size, const unsigned int max_difference)
 
 #ifdef DEBUG
   // check each cell's active FE index by its distance from the center
-  for (const auto &cell : dofh.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        const double       distance = cell->center().distance(Point<dim>());
-        const unsigned int expected_level =
-          (sequence.size() - 1) -
-          max_difference * static_cast<unsigned int>(std::round(distance));
-
-        Assert(cell->active_fe_index() == sequence[expected_level],
-               ExcInternalError());
-      }
+  for (const auto &cell :
+       dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      const double       distance = cell->center().distance(Point<dim>());
+      const unsigned int expected_level =
+        (sequence.size() - 1) -
+        max_difference * static_cast<unsigned int>(std::round(distance));
+
+      Assert(cell->active_fe_index() == sequence[expected_level],
+             ExcInternalError());
+    }
 #endif
 
   deallog << "OK" << std::endl;
index 4904a9f638554e7f6d4921f8a91be7aee1e1123a..b2143244a3ff27c3a72d9d5ef45e974dfb31531d 100644 (file)
@@ -25,6 +25,8 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
+
 #include <deal.II/hp/fe_collection.h>
 #include <deal.II/hp/refinement.h>
 
@@ -99,10 +101,10 @@ test(const unsigned int max_difference)
   Assert(fe_indices_changed, ExcInternalError());
 
   deallog << "active FE indices after adaptation:" << std::endl;
-  for (const auto &cell : dofh.active_cell_iterators())
-    if (cell->is_locally_owned())
-      deallog << " " << cell->id().to_string() << " " << cell->active_fe_index()
-              << std::endl;
+  for (const auto &cell :
+       dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    deallog << " " << cell->id().to_string() << " " << cell->active_fe_index()
+            << std::endl;
 
   deallog << "OK" << std::endl;
 }
index f804788f92ddc5a737178294734129bf35d339fc..21be8ccb7b0807b25a479e2f5d541526c692b537 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/hp/fe_collection.h>
@@ -65,14 +66,14 @@ test()
   tria.execute_coarsening_and_refinement();
 
   // check if all flags were cleared and verify fe_indices
-  for (const auto &cell : dh.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        Assert(cell->future_fe_index_set() == false, ExcInternalError());
-
-        deallog << "cell:" << cell->id().to_string()
-                << ", fe_index:" << cell->active_fe_index() << std::endl;
-      }
+  for (const auto &cell :
+       dh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      Assert(cell->future_fe_index_set() == false, ExcInternalError());
+
+      deallog << "cell:" << cell->id().to_string()
+              << ", fe_index:" << cell->active_fe_index() << std::endl;
+    }
 }
 
 
index ef5e181ce464ae61f2d8f95317a0a45ab7094450..45696f1047b517ede975d795d17f428b75bca5bb 100644 (file)
@@ -276,51 +276,45 @@ namespace Step27
 
     std::vector<types::global_dof_index> local_dof_indices;
 
-    for (const auto &cell : dof_handler.active_cell_iterators())
-      if (cell->is_locally_owned())
-        {
-          const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
-
-          cell_matrix.reinit(dofs_per_cell, dofs_per_cell);
-          cell_matrix = 0;
-
-          cell_rhs.reinit(dofs_per_cell);
-          cell_rhs = 0;
-
-          hp_fe_values.reinit(cell);
-
-          const FEValues<dim> &fe_values = hp_fe_values.get_present_fe_values();
-
-          std::vector<double> rhs_values(fe_values.n_quadrature_points);
-          rhs_function.value_list(fe_values.get_quadrature_points(),
-                                  rhs_values);
-
-          for (unsigned int q_point = 0;
-               q_point < fe_values.n_quadrature_points;
-               ++q_point)
-            for (unsigned int i = 0; i < dofs_per_cell; ++i)
-              {
-                for (unsigned int j = 0; j < dofs_per_cell; ++j)
-                  cell_matrix(i, j) +=
-                    (fe_values.shape_grad(i, q_point) * // grad phi_i(x_q)
-                     fe_values.shape_grad(j, q_point) * // grad phi_j(x_q)
-                     fe_values.JxW(q_point));           // dx
-
-                cell_rhs(i) +=
-                  (fe_values.shape_value(i, q_point) * // phi_i(x_q)
-                   rhs_values[q_point] *               // f(x_q)
-                   fe_values.JxW(q_point));            // dx
-              }
-
-          local_dof_indices.resize(dofs_per_cell);
-          cell->get_dof_indices(local_dof_indices);
-
-          constraints.distribute_local_to_global(cell_matrix,
-                                                 cell_rhs,
-                                                 local_dof_indices,
-                                                 system_matrix,
-                                                 system_rhs);
-        }
+    for (const auto &cell : dof_handler.active_cell_iterators() |
+                              IteratorFilters::LocallyOwnedCell())
+      {
+        const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
+
+        cell_matrix.reinit(dofs_per_cell, dofs_per_cell);
+        cell_matrix = 0;
+
+        cell_rhs.reinit(dofs_per_cell);
+        cell_rhs = 0;
+
+        hp_fe_values.reinit(cell);
+
+        const FEValues<dim> &fe_values = hp_fe_values.get_present_fe_values();
+
+        std::vector<double> rhs_values(fe_values.n_quadrature_points);
+        rhs_function.value_list(fe_values.get_quadrature_points(), rhs_values);
+
+        for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points;
+             ++q_point)
+          for (unsigned int i = 0; i < dofs_per_cell; ++i)
+            {
+              for (unsigned int j = 0; j < dofs_per_cell; ++j)
+                cell_matrix(i, j) +=
+                  (fe_values.shape_grad(i, q_point) * // grad phi_i(x_q)
+                   fe_values.shape_grad(j, q_point) * // grad phi_j(x_q)
+                   fe_values.JxW(q_point));           // dx
+
+              cell_rhs(i) += (fe_values.shape_value(i, q_point) * // phi_i(x_q)
+                              rhs_values[q_point] *               // f(x_q)
+                              fe_values.JxW(q_point));            // dx
+            }
+
+        local_dof_indices.resize(dofs_per_cell);
+        cell->get_dof_indices(local_dof_indices);
+
+        constraints.distribute_local_to_global(
+          cell_matrix, cell_rhs, local_dof_indices, system_matrix, system_rhs);
+      }
 
     system_matrix.compress(VectorOperation::add);
     system_rhs.compress(VectorOperation::add);
index 7de5a22d3ffcc6ecb4e779bd80dc13fa75e4c536..37974b3167c14bfe6ef9c245405b7dbd9c533047 100644 (file)
@@ -22,6 +22,7 @@
 #include <deal.II/distributed/grid_refinement.h>
 #include <deal.II/distributed/tria.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/lac/vector.h>
@@ -81,12 +82,12 @@ test()
   deallog << std::endl;
 
   // reset refinement flags
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        cell->clear_refine_flag();
-        cell->clear_coarsen_flag();
-      }
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      cell->clear_refine_flag();
+      cell->clear_coarsen_flag();
+    }
 
   deallog << "l2-norm: ";
   parallel::distributed::GridRefinement::refine_and_coarsen_fixed_fraction(
index 1fedd2e915f6821238cc227a6de44269ad8c82cc..cd10057e4cd68f0e67e95333e1007fb7ecc292c1 100644 (file)
@@ -22,6 +22,7 @@
 #include <deal.II/distributed/grid_refinement.h>
 #include <deal.II/distributed/tria.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/lac/vector.h>
@@ -82,12 +83,12 @@ test()
   deallog << std::endl;
 
   // reset refinement flags
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        cell->clear_refine_flag();
-        cell->clear_coarsen_flag();
-      }
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      cell->clear_refine_flag();
+      cell->clear_coarsen_flag();
+    }
 
   deallog << "l2-norm: ";
   parallel::distributed::GridRefinement::refine_and_coarsen_fixed_fraction(
index a949957ce423bb9d5e4bcc23a66b733736ef0dd5..2515f4dcb3c13a48c392ff863f9d1a3c312b2028 100644 (file)
@@ -21,6 +21,7 @@
 #include <deal.II/distributed/grid_refinement.h>
 #include <deal.II/distributed/tria.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/lac/vector.h>
@@ -39,20 +40,20 @@ verify(parallel::distributed::Triangulation<dim> &tr,
     tr, criteria, refinement_fraction, coarsening_fraction);
 
   unsigned int n_refine_flags = 0, n_coarsen_flags = 0;
-  for (const auto &cell : tr.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        if (cell->refine_flag_set())
-          {
-            ++n_refine_flags;
-            cell->clear_refine_flag();
-          }
-        if (cell->coarsen_flag_set())
-          {
-            ++n_coarsen_flags;
-            cell->clear_coarsen_flag();
-          }
-      }
+  for (const auto &cell :
+       tr.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      if (cell->refine_flag_set())
+        {
+          ++n_refine_flags;
+          cell->clear_refine_flag();
+        }
+      if (cell->coarsen_flag_set())
+        {
+          ++n_coarsen_flags;
+          cell->clear_coarsen_flag();
+        }
+    }
 
   const unsigned int n_global_refine_flags =
                        Utilities::MPI::sum(n_refine_flags, MPI_COMM_WORLD),
index a20596981b3bbcfeafd7bbc0c832930840cb8acd..33ae8287454f3aca7ec528ef09ea2dce60b3c4f4 100644 (file)
@@ -37,6 +37,7 @@
 #include <deal.II/fe/fe_q.h>
 #include <deal.II/fe/mapping_q1.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/tria_iterator.h>
 
@@ -77,19 +78,19 @@ test()
       }
 
   std::set<types::global_dof_index> starting_indices;
-  for (const auto &cell : dofh.active_cell_iterators())
-    if (cell->is_locally_owned())
-      for (const unsigned int f : GeometryInfo<dim>::face_indices())
-        if (!cell->at_boundary(f) && cell->neighbor(f)->is_ghost())
-          {
-            // we've identified a subdomain interface. use these DoFs
-            // as starting indices
-            std::vector<types::global_dof_index> face_dofs(
-              cell->get_fe().dofs_per_face);
-            cell->face(f)->get_dof_indices(face_dofs);
-            for (auto i : face_dofs)
-              starting_indices.insert(i);
-          }
+  for (const auto &cell :
+       dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    for (const unsigned int f : GeometryInfo<dim>::face_indices())
+      if (!cell->at_boundary(f) && cell->neighbor(f)->is_ghost())
+        {
+          // we've identified a subdomain interface. use these DoFs
+          // as starting indices
+          std::vector<types::global_dof_index> face_dofs(
+            cell->get_fe().dofs_per_face);
+          cell->face(f)->get_dof_indices(face_dofs);
+          for (auto i : face_dofs)
+            starting_indices.insert(i);
+        }
 
   DoFRenumbering::Cuthill_McKee(
     dofh,
@@ -100,20 +101,20 @@ test()
 
   // output the renumbered DoF indices
   deallog << "After:" << std::endl;
-  for (const auto &cell : dofh.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        deallog << "locally owned cell: " << cell << std::endl;
-        deallog << "       dof indices: ";
-
-        std::vector<types::global_dof_index> cell_dofs(
-          cell->get_fe().dofs_per_cell);
-        cell->get_dof_indices(cell_dofs);
-
-        for (auto i : cell_dofs)
-          deallog << i << ' ';
-        deallog << std::endl;
-      }
+  for (const auto &cell :
+       dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      deallog << "locally owned cell: " << cell << std::endl;
+      deallog << "       dof indices: ";
+
+      std::vector<types::global_dof_index> cell_dofs(
+        cell->get_fe().dofs_per_cell);
+      cell->get_dof_indices(cell_dofs);
+
+      for (auto i : cell_dofs)
+        deallog << i << ' ';
+      deallog << std::endl;
+    }
 
   std::map<types::global_dof_index, Point<dim>> support_points;
   DoFTools::map_dofs_to_support_points(MappingQ1<dim>(), dofh, support_points);
index 4507900fd73f7126e321f0fa2e4478757e48a059..faa27bb1ca354ad2b62295a6964abff892f6da72 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <deal.II/fe/fe_dgq.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/hp/fe_collection.h>
@@ -61,9 +62,9 @@ test()
   DoFHandler<dim> dgq_dof_handler(tria);
 
   // randomly assign FEs
-  for (const auto &cell : dgq_dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      cell->set_active_fe_index(Testing::rand() % max_degree);
+  for (const auto &cell : dgq_dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    cell->set_active_fe_index(Testing::rand() % max_degree);
   dgq_dof_handler.distribute_dofs(fe_dgq);
 
   // prepare index sets
index 0c742e3505629fbaed8f06b3e1f9bff35276226a..bb91e8ebd77295c17cc1f0340cdee2e37da85b31 100644 (file)
@@ -276,51 +276,45 @@ namespace Step27
 
     std::vector<types::global_dof_index> local_dof_indices;
 
-    for (const auto &cell : dof_handler.active_cell_iterators())
-      if (cell->is_locally_owned())
-        {
-          const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
-
-          cell_matrix.reinit(dofs_per_cell, dofs_per_cell);
-          cell_matrix = 0;
-
-          cell_rhs.reinit(dofs_per_cell);
-          cell_rhs = 0;
-
-          hp_fe_values.reinit(cell);
-
-          const FEValues<dim> &fe_values = hp_fe_values.get_present_fe_values();
-
-          std::vector<double> rhs_values(fe_values.n_quadrature_points);
-          rhs_function.value_list(fe_values.get_quadrature_points(),
-                                  rhs_values);
-
-          for (unsigned int q_point = 0;
-               q_point < fe_values.n_quadrature_points;
-               ++q_point)
-            for (unsigned int i = 0; i < dofs_per_cell; ++i)
-              {
-                for (unsigned int j = 0; j < dofs_per_cell; ++j)
-                  cell_matrix(i, j) +=
-                    (fe_values.shape_grad(i, q_point) * // grad phi_i(x_q)
-                     fe_values.shape_grad(j, q_point) * // grad phi_j(x_q)
-                     fe_values.JxW(q_point));           // dx
-
-                cell_rhs(i) +=
-                  (fe_values.shape_value(i, q_point) * // phi_i(x_q)
-                   rhs_values[q_point] *               // f(x_q)
-                   fe_values.JxW(q_point));            // dx
-              }
-
-          local_dof_indices.resize(dofs_per_cell);
-          cell->get_dof_indices(local_dof_indices);
-
-          constraints.distribute_local_to_global(cell_matrix,
-                                                 cell_rhs,
-                                                 local_dof_indices,
-                                                 system_matrix,
-                                                 system_rhs);
-        }
+    for (const auto &cell : dof_handler.active_cell_iterators() |
+                              IteratorFilters::LocallyOwnedCell())
+      {
+        const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
+
+        cell_matrix.reinit(dofs_per_cell, dofs_per_cell);
+        cell_matrix = 0;
+
+        cell_rhs.reinit(dofs_per_cell);
+        cell_rhs = 0;
+
+        hp_fe_values.reinit(cell);
+
+        const FEValues<dim> &fe_values = hp_fe_values.get_present_fe_values();
+
+        std::vector<double> rhs_values(fe_values.n_quadrature_points);
+        rhs_function.value_list(fe_values.get_quadrature_points(), rhs_values);
+
+        for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points;
+             ++q_point)
+          for (unsigned int i = 0; i < dofs_per_cell; ++i)
+            {
+              for (unsigned int j = 0; j < dofs_per_cell; ++j)
+                cell_matrix(i, j) +=
+                  (fe_values.shape_grad(i, q_point) * // grad phi_i(x_q)
+                   fe_values.shape_grad(j, q_point) * // grad phi_j(x_q)
+                   fe_values.JxW(q_point));           // dx
+
+              cell_rhs(i) += (fe_values.shape_value(i, q_point) * // phi_i(x_q)
+                              rhs_values[q_point] *               // f(x_q)
+                              fe_values.JxW(q_point));            // dx
+            }
+
+        local_dof_indices.resize(dofs_per_cell);
+        cell->get_dof_indices(local_dof_indices);
+
+        constraints.distribute_local_to_global(
+          cell_matrix, cell_rhs, local_dof_indices, system_matrix, system_rhs);
+      }
 
     system_matrix.compress(VectorOperation::add);
     system_rhs.compress(VectorOperation::add);
index 9eff216d09a4ecb37937885f79be7649ef794316..b971aa2a3c6de857ac122feb06ea801a6fdab33d 100644 (file)
@@ -33,6 +33,7 @@
 #include <deal.II/fe/fe_tools.h>
 #include <deal.II/fe/mapping_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 #include <deal.II/grid/grid_out.h>
 
@@ -85,9 +86,9 @@ do_test(const FiniteElement<dim> &fe_fine, const FiniteElement<dim> &fe_coarse)
   dof_handler_fine.distribute_dofs(fe);
 
   DoFHandler<dim> dof_handler_coarse(tria_coarse);
-  for (const auto &cell : dof_handler_coarse.active_cell_iterators())
-    if (cell->is_locally_owned())
-      cell->set_active_fe_index(1);
+  for (const auto &cell : dof_handler_coarse.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    cell->set_active_fe_index(1);
   dof_handler_coarse.distribute_dofs(fe);
 
   // setup constraint matrix
index 601d35648a658f7663a30623b80bf19fb94ef1ba..3246f9a61da178467f57b0d1414809c162a13204 100644 (file)
@@ -22,6 +22,7 @@
 #include <deal.II/fe/fe_dgq.h>
 #include <deal.II/fe/mapping_q1.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/lac/la_vector.h>
@@ -47,9 +48,9 @@ test(const bool enforce_unique_map)
 
   Vector<double> vec(dof_handler.n_dofs());
 
-  for (const auto &cell : dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      vec[cell->global_active_cell_index()] = cell->global_active_cell_index();
+  for (const auto &cell : dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    vec[cell->global_active_cell_index()] = cell->global_active_cell_index();
 
   MappingQ1<dim> mapping;
 
index 29f4e9dbc261a570b76f14ce99cbdc121f9200ef..38ea4889a674085b9fc35e180d285da2c50a9e4e 100644 (file)
@@ -23,6 +23,7 @@
 #include <deal.II/fe/fe_dgq.h>
 #include <deal.II/fe/mapping_q1.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/lac/la_vector.h>
@@ -48,9 +49,9 @@ test()
 
   Vector<double> vec(dof_handler.n_dofs());
 
-  for (const auto &cell : dof_handler.active_cell_iterators())
-    if (cell->is_locally_owned())
-      vec[cell->global_active_cell_index()] = cell->global_active_cell_index();
+  for (const auto &cell : dof_handler.active_cell_iterators() |
+                            IteratorFilters::LocallyOwnedCell())
+    vec[cell->global_active_cell_index()] = cell->global_active_cell_index();
 
   MappingQ1<dim> mapping;
 
index 714bfc399789be7d65f1b541f5006efe9d03ee81..c19e18666e153b1ae1c559ea773b577952c14be8 100644 (file)
@@ -122,9 +122,9 @@ print(const Mapping<dim> &                              mapping,
   const auto &tria = dof_handler.get_triangulation();
 
   Vector<double> ranks(tria.n_active_cells());
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      ranks(cell->active_cell_index()) = cell->subdomain_id();
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    ranks(cell->active_cell_index()) = cell->subdomain_id();
   data_out.add_data_vector(ranks, "rank");
   data_out.add_data_vector(result, "result");
 
index 6a610129ef6a0f45659f548c3788e3ff86d08341..73fce13042f517fb7418521ba6db7863ea4a7951 100644 (file)
@@ -95,9 +95,9 @@ print(const Mapping<dim> &                              mapping,
   const auto &tria = dof_handler.get_triangulation();
 
   Vector<double> ranks(tria.n_active_cells());
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      ranks(cell->active_cell_index()) = cell->subdomain_id();
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    ranks(cell->active_cell_index()) = cell->subdomain_id();
   data_out.add_data_vector(ranks, "rank");
   data_out.add_data_vector(result, "result");
 
index 2bf4c47d723c7309036ffcd85f3043e7b544a810..2e0b884ca64ebb9ae25f2ae8dd1786533b7229b3 100644 (file)
@@ -91,9 +91,9 @@ print(const Mapping<dim> &                              mapping,
   const auto &tria = dof_handler.get_triangulation();
 
   Vector<double> ranks(tria.n_active_cells());
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      ranks(cell->active_cell_index()) = cell->subdomain_id();
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    ranks(cell->active_cell_index()) = cell->subdomain_id();
   data_out.add_data_vector(ranks, "rank");
   data_out.add_data_vector(result, "result");
 
index 50cd62461953b366a33f38f23573ae2c418dac09..1cb64eb43588d073701a65ebd8dedbf121804f6f 100644 (file)
@@ -90,9 +90,9 @@ print(const Mapping<dim> &                              mapping,
   const auto &tria = dof_handler.get_triangulation();
 
   Vector<double> ranks(tria.n_active_cells());
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      ranks(cell->active_cell_index()) = cell->subdomain_id();
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    ranks(cell->active_cell_index()) = cell->subdomain_id();
   data_out.add_data_vector(ranks, "rank");
   data_out.add_data_vector(result, "result");
 
index 62fcaf2a28a52617a7aba3fc47781285fe59572b..1423b2027d189811952c9ce7d58d80513d400883 100644 (file)
@@ -91,9 +91,9 @@ print(const Mapping<dim, spacedim> &                    mapping,
   const auto &tria = dof_handler.get_triangulation();
 
   Vector<double> ranks(tria.n_active_cells());
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      ranks(cell->active_cell_index()) = cell->subdomain_id();
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    ranks(cell->active_cell_index()) = cell->subdomain_id();
   data_out.add_data_vector(ranks, "rank");
   data_out.add_data_vector(result, "result");
 
index bd973d32d31e6880f991cb254050949c46c20c63..24a1679ada9a8467650e3881fdef87e8ef74e986 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <deal.II/distributed/shared_tria.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/lac/petsc_vector.h>
@@ -77,10 +78,10 @@ test()
     tria.n_active_cells(),
     tria.n_locally_owned_active_cells());
 
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      distributed_cell_ids_pre(cell->active_cell_index()) =
-        cell_ids_pre(cell->active_cell_index());
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    distributed_cell_ids_pre(cell->active_cell_index()) =
+      cell_ids_pre(cell->active_cell_index());
   distributed_cell_ids_pre.compress(VectorOperation::insert);
 
   cell_ids_pre = distributed_cell_ids_pre;
index e777475a4f7d1ef94086449b1894656f32426958..67089821a04412ca7c38832140422a470d40f547 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <deal.II/distributed/shared_tria.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/lac/petsc_vector.h>
@@ -77,10 +78,10 @@ test()
     tria.n_active_cells(),
     tria.n_locally_owned_active_cells());
 
-  for (const auto &cell : tria.active_cell_iterators())
-    if (cell->is_locally_owned())
-      distributed_cell_ids_pre(cell->active_cell_index()) =
-        cell_ids_pre(cell->active_cell_index());
+  for (const auto &cell :
+       tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    distributed_cell_ids_pre(cell->active_cell_index()) =
+      cell_ids_pre(cell->active_cell_index());
   distributed_cell_ids_pre.compress(VectorOperation::insert);
 
   cell_ids_pre = distributed_cell_ids_pre;
index 2c073728c5c0d869e18a806f317791e44707a3d3..2aca273b47297769fce897157407d1816656d55b 100644 (file)
@@ -25,6 +25,8 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
+
 #include <deal.II/hp/fe_collection.h>
 #include <deal.II/hp/refinement.h>
 
@@ -101,14 +103,14 @@ test()
 
   // verify
   unsigned int h_flagged_cells = 0, p_flagged_cells = 0;
-  for (const auto &cell : dh.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        if (cell->coarsen_flag_set())
-          ++h_flagged_cells;
-        if (cell->future_fe_index_set())
-          ++p_flagged_cells;
-      }
+  for (const auto &cell :
+       dh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      if (cell->coarsen_flag_set())
+        ++h_flagged_cells;
+      if (cell->future_fe_index_set())
+        ++p_flagged_cells;
+    }
   const unsigned int global_h_flagged_cells =
                        Utilities::MPI::sum(h_flagged_cells, MPI_COMM_WORLD),
                      global_p_flagged_cells =
index bb162e93319c88cc977921b17bdef2914b0275de..cf363d4a4e03a3dfa9f9eb0235ac1565787c2154 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/hp/fe_collection.h>
@@ -98,17 +99,17 @@ test(const unsigned int fes_size,
 
 #ifdef DEBUG
   // check each cell's active FE index by its distance from the center
-  for (const auto &cell : dofh.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        const double       distance = cell->center().distance(Point<dim>());
-        const unsigned int expected_level =
-          (sequence.size() - 1) -
-          max_difference * static_cast<unsigned int>(std::round(distance));
-
-        Assert(cell->active_fe_index() == sequence[expected_level],
-               ExcInternalError());
-      }
+  for (const auto &cell :
+       dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      const double       distance = cell->center().distance(Point<dim>());
+      const unsigned int expected_level =
+        (sequence.size() - 1) -
+        max_difference * static_cast<unsigned int>(std::round(distance));
+
+      Assert(cell->active_fe_index() == sequence[expected_level],
+             ExcInternalError());
+    }
 #endif
 
   deallog << "OK" << std::endl;
index 33de084d82cf355dcb45649baaaab069d3319ef0..1221ccf5bf485c0b9d0a9eb3df76ab786b33dc62 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
 #include <deal.II/grid/grid_generator.h>
 
 #include <deal.II/hp/fe_collection.h>
@@ -104,17 +105,17 @@ test(const unsigned int fes_size,
 
 #ifdef DEBUG
   // check each cell's active FE index by its distance from the center
-  for (const auto &cell : dofh.active_cell_iterators())
-    if (cell->is_locally_owned())
-      {
-        const double       distance = cell->center().distance(Point<dim>());
-        const unsigned int expected_level =
-          (sequence.size() - 1) -
-          max_difference * static_cast<unsigned int>(std::round(distance));
-
-        Assert(cell->active_fe_index() == sequence[expected_level],
-               ExcInternalError());
-      }
+  for (const auto &cell :
+       dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    {
+      const double       distance = cell->center().distance(Point<dim>());
+      const unsigned int expected_level =
+        (sequence.size() - 1) -
+        max_difference * static_cast<unsigned int>(std::round(distance));
+
+      Assert(cell->active_fe_index() == sequence[expected_level],
+             ExcInternalError());
+    }
 #endif
 
   deallog << "OK" << std::endl;
index 8e429450e1cfa62542368e1dc3ed760a786534c5..d9bd72f6a1457bd368ac473d8472b8eef73e5391 100644 (file)
@@ -27,6 +27,8 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
+
 #include <deal.II/hp/fe_collection.h>
 #include <deal.II/hp/refinement.h>
 
index e94dddeca731a364e2ffd6bda8d780e88f0fd24a..5a935b020b7160645275fe44c41bc28add7ad5ea 100644 (file)
@@ -25,6 +25,8 @@
 
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/grid/filtered_iterator.h>
+
 #include <deal.II/hp/fe_collection.h>
 #include <deal.II/hp/refinement.h>
 
@@ -102,10 +104,10 @@ test(const unsigned int max_difference, const bool allow_artificial_cells)
   tria.execute_coarsening_and_refinement();
 
   deallog << "active FE indices after adaptation:" << std::endl;
-  for (const auto &cell : dofh.active_cell_iterators())
-    if (cell->is_locally_owned())
-      deallog << " " << cell->id().to_string() << " " << cell->active_fe_index()
-              << std::endl;
+  for (const auto &cell :
+       dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+    deallog << " " << cell->id().to_string() << " " << cell->active_fe_index()
+            << std::endl;
 
   deallog << "OK" << std::endl;
 }
index c715661a7f81e67c08ebc246d17f67fc729ca16f..99d377637d00f784d9f0c88b92917229eca6811f 100644 (file)
@@ -975,40 +975,39 @@ namespace Step18
     std::vector<std::vector<Tensor<1, dim>>> displacement_increment_grads(
       quadrature_formula.size(), std::vector<Tensor<1, dim>>(dim));
 
-    for (auto &cell : dof_handler.active_cell_iterators())
-      if (cell->is_locally_owned())
-        {
-          PointHistory<dim> *local_quadrature_points_history =
-            reinterpret_cast<PointHistory<dim> *>(cell->user_pointer());
-          Assert(local_quadrature_points_history >=
-                   &quadrature_point_history.front(),
-                 ExcInternalError());
-          Assert(local_quadrature_points_history <=
-                   &quadrature_point_history.back(),
-                 ExcInternalError());
-
-          fe_values.reinit(cell);
-          fe_values.get_function_gradients(incremental_displacement,
-                                           displacement_increment_grads);
-
-          for (unsigned int q = 0; q < quadrature_formula.size(); ++q)
-            {
-              const SymmetricTensor<2, dim> new_stress =
-                (local_quadrature_points_history[q].old_stress +
-                 (stress_strain_tensor *
-                  get_strain(displacement_increment_grads[q])));
+    for (auto &cell : dof_handler.active_cell_iterators() |
+                        IteratorFilters::LocallyOwnedCell())
+      {
+        PointHistory<dim> *local_quadrature_points_history =
+          reinterpret_cast<PointHistory<dim> *>(cell->user_pointer());
+        Assert(local_quadrature_points_history >=
+                 &quadrature_point_history.front(),
+               ExcInternalError());
+        Assert(local_quadrature_points_history <=
+                 &quadrature_point_history.back(),
+               ExcInternalError());
+
+        fe_values.reinit(cell);
+        fe_values.get_function_gradients(incremental_displacement,
+                                         displacement_increment_grads);
+
+        for (unsigned int q = 0; q < quadrature_formula.size(); ++q)
+          {
+            const SymmetricTensor<2, dim> new_stress =
+              (local_quadrature_points_history[q].old_stress +
+               (stress_strain_tensor *
+                get_strain(displacement_increment_grads[q])));
 
-              const Tensor<2, dim> rotation =
-                get_rotation_matrix(displacement_increment_grads[q]);
+            const Tensor<2, dim> rotation =
+              get_rotation_matrix(displacement_increment_grads[q]);
 
-              const SymmetricTensor<2, dim> rotated_new_stress =
-                symmetrize(transpose(rotation) *
-                           static_cast<Tensor<2, dim>>(new_stress) * rotation);
+            const SymmetricTensor<2, dim> rotated_new_stress =
+              symmetrize(transpose(rotation) *
+                         static_cast<Tensor<2, dim>>(new_stress) * rotation);
 
-              local_quadrature_points_history[q].old_stress =
-                rotated_new_stress;
-            }
-        }
+            local_quadrature_points_history[q].old_stress = rotated_new_stress;
+          }
+      }
   }
 } // namespace Step18
 
index b040723a55acaaaecf1de6fadfd61b66739482eb..c0e297c8d779ddaf11de8ace4645d46758575398 100644 (file)
@@ -216,44 +216,41 @@ namespace Step40
 
     std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
 
-    for (const auto &cell : dof_handler.active_cell_iterators())
-      if (cell->is_locally_owned())
-        {
-          cell_matrix = 0.;
-          cell_rhs    = 0.;
-
-          fe_values.reinit(cell);
-
-          for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
-            {
-              const double rhs_value =
-                (fe_values.quadrature_point(q_point)[1] >
-                     0.5 +
-                       0.25 * std::sin(4.0 * numbers::PI *
-                                       fe_values.quadrature_point(q_point)[0]) ?
-                   1. :
-                   -1.);
-
-              for (unsigned int i = 0; i < dofs_per_cell; ++i)
-                {
-                  for (unsigned int j = 0; j < dofs_per_cell; ++j)
-                    cell_matrix(i, j) += fe_values.shape_grad(i, q_point) *
-                                         fe_values.shape_grad(j, q_point) *
-                                         fe_values.JxW(q_point);
-
-                  cell_rhs(i) += rhs_value *                         //
-                                 fe_values.shape_value(i, q_point) * //
-                                 fe_values.JxW(q_point);
-                }
-            }
-
-          cell->get_dof_indices(local_dof_indices);
-          constraints.distribute_local_to_global(cell_matrix,
-                                                 cell_rhs,
-                                                 local_dof_indices,
-                                                 system_matrix,
-                                                 system_rhs);
-        }
+    for (const auto &cell : dof_handler.active_cell_iterators() |
+                              IteratorFilters::LocallyOwnedCell())
+      {
+        cell_matrix = 0.;
+        cell_rhs    = 0.;
+
+        fe_values.reinit(cell);
+
+        for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
+          {
+            const double rhs_value =
+              (fe_values.quadrature_point(q_point)[1] >
+                   0.5 +
+                     0.25 * std::sin(4.0 * numbers::PI *
+                                     fe_values.quadrature_point(q_point)[0]) ?
+                 1. :
+                 -1.);
+
+            for (unsigned int i = 0; i < dofs_per_cell; ++i)
+              {
+                for (unsigned int j = 0; j < dofs_per_cell; ++j)
+                  cell_matrix(i, j) += fe_values.shape_grad(i, q_point) *
+                                       fe_values.shape_grad(j, q_point) *
+                                       fe_values.JxW(q_point);
+
+                cell_rhs(i) += rhs_value *                         //
+                               fe_values.shape_value(i, q_point) * //
+                               fe_values.JxW(q_point);
+              }
+          }
+
+        cell->get_dof_indices(local_dof_indices);
+        constraints.distribute_local_to_global(
+          cell_matrix, cell_rhs, local_dof_indices, system_matrix, system_rhs);
+      }
 
     system_matrix.compress(VectorOperation::add);
     system_rhs.compress(VectorOperation::add);
index 1ddb7e6085cabd216b333daa004fd2b663aafe4f..3b77662bf7f0107de5bcf14b1d6aa28309a62fe9 100644 (file)
@@ -598,58 +598,55 @@ namespace Step55
     const FEValuesExtractors::Vector     velocities(0);
     const FEValuesExtractors::Scalar     pressure(dim);
 
-    for (const auto &cell : dof_handler.active_cell_iterators())
-      if (cell->is_locally_owned())
-        {
-          cell_matrix  = 0;
-          cell_matrix2 = 0;
-          cell_rhs     = 0;
-
-          fe_values.reinit(cell);
-          right_hand_side.vector_value_list(fe_values.get_quadrature_points(),
-                                            rhs_values);
-          for (unsigned int q = 0; q < n_q_points; ++q)
-            {
-              for (unsigned int k = 0; k < dofs_per_cell; ++k)
-                {
-                  grad_phi_u[k] = fe_values[velocities].gradient(k, q);
-                  div_phi_u[k]  = fe_values[velocities].divergence(k, q);
-                  phi_p[k]      = fe_values[pressure].value(k, q);
-                }
-
-              for (unsigned int i = 0; i < dofs_per_cell; ++i)
-                {
-                  for (unsigned int j = 0; j < dofs_per_cell; ++j)
-                    {
-                      cell_matrix(i, j) +=
-                        (viscosity *
-                           scalar_product(grad_phi_u[i], grad_phi_u[j]) -
-                         div_phi_u[i] * phi_p[j] - phi_p[i] * div_phi_u[j]) *
-                        fe_values.JxW(q);
-
-                      cell_matrix2(i, j) += 1.0 / viscosity * phi_p[i] *
-                                            phi_p[j] * fe_values.JxW(q);
-                    }
-
-                  const unsigned int component_i =
-                    fe.system_to_component_index(i).first;
-                  cell_rhs(i) += fe_values.shape_value(i, q) *
-                                 rhs_values[q](component_i) * fe_values.JxW(q);
-                }
-            }
-
-
-          cell->get_dof_indices(local_dof_indices);
-          constraints.distribute_local_to_global(cell_matrix,
-                                                 cell_rhs,
-                                                 local_dof_indices,
-                                                 system_matrix,
-                                                 system_rhs);
-
-          constraints.distribute_local_to_global(cell_matrix2,
-                                                 local_dof_indices,
-                                                 preconditioner_matrix);
-        }
+    for (const auto &cell : dof_handler.active_cell_iterators() |
+                              IteratorFilters::LocallyOwnedCell())
+      {
+        cell_matrix  = 0;
+        cell_matrix2 = 0;
+        cell_rhs     = 0;
+
+        fe_values.reinit(cell);
+        right_hand_side.vector_value_list(fe_values.get_quadrature_points(),
+                                          rhs_values);
+        for (unsigned int q = 0; q < n_q_points; ++q)
+          {
+            for (unsigned int k = 0; k < dofs_per_cell; ++k)
+              {
+                grad_phi_u[k] = fe_values[velocities].gradient(k, q);
+                div_phi_u[k]  = fe_values[velocities].divergence(k, q);
+                phi_p[k]      = fe_values[pressure].value(k, q);
+              }
+
+            for (unsigned int i = 0; i < dofs_per_cell; ++i)
+              {
+                for (unsigned int j = 0; j < dofs_per_cell; ++j)
+                  {
+                    cell_matrix(i, j) +=
+                      (viscosity *
+                         scalar_product(grad_phi_u[i], grad_phi_u[j]) -
+                       div_phi_u[i] * phi_p[j] - phi_p[i] * div_phi_u[j]) *
+                      fe_values.JxW(q);
+
+                    cell_matrix2(i, j) +=
+                      1.0 / viscosity * phi_p[i] * phi_p[j] * fe_values.JxW(q);
+                  }
+
+                const unsigned int component_i =
+                  fe.system_to_component_index(i).first;
+                cell_rhs(i) += fe_values.shape_value(i, q) *
+                               rhs_values[q](component_i) * fe_values.JxW(q);
+              }
+          }
+
+
+        cell->get_dof_indices(local_dof_indices);
+        constraints.distribute_local_to_global(
+          cell_matrix, cell_rhs, local_dof_indices, system_matrix, system_rhs);
+
+        constraints.distribute_local_to_global(cell_matrix2,
+                                               local_dof_indices,
+                                               preconditioner_matrix);
+      }
 
     system_matrix.compress(VectorOperation::add);
     preconditioner_matrix.compress(VectorOperation::add);
index 87cecd642bbdf61fe280e68b9e42821fcaa9296e..fd8f2cb57613d65a746a67ea25b2e5fef6d52dfb 100644 (file)
@@ -2424,10 +2424,10 @@ namespace Euler_DG
 #endif
 
     double min_vertex_distance = std::numeric_limits<double>::max();
-    for (const auto &cell : triangulation.active_cell_iterators())
-      if (cell->is_locally_owned())
-        min_vertex_distance =
-          std::min(min_vertex_distance, cell->minimum_vertex_distance());
+    for (const auto &cell : triangulation.active_cell_iterators() |
+                              IteratorFilters::LocallyOwnedCell())
+      min_vertex_distance =
+        std::min(min_vertex_distance, cell->minimum_vertex_distance());
     min_vertex_distance =
       Utilities::MPI::min(min_vertex_distance, MPI_COMM_WORLD);
 

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.