From 0333ac7fd8422b93d0a8e9b54eaadb0ac0a583c4 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 19 Nov 2021 11:29:21 -0700 Subject: [PATCH] Use iterator filters in tests/. --- tests/boost/extract_representative_set_02.cc | 7 +- .../grid_tools_exchange_cell_data_01.cc | 37 +++---- .../grid_tools_exchange_cell_data_02.cc | 37 +++---- .../grid_tools_exchange_cell_data_03.cc | 37 +++---- .../grid_tools_exchange_cell_data_04.cc | 37 +++---- .../repartitioning_01.cc | 8 +- .../repartitioning_05.cc | 10 +- .../grid_tools_subdomain_association_01.cc | 7 +- tests/lac/step-40-linear_operator_01.cc | 73 ++++++------- tests/lac/step-40-linear_operator_02.cc | 73 ++++++------- tests/lac/step-40-linear_operator_03.cc | 73 ++++++------- tests/lac/step-40-linear_operator_04.cc | 73 ++++++------- tests/lac/step-40-linear_operator_05.cc | 73 ++++++------- tests/lac/step-40-linear_operator_06.cc | 73 ++++++------- tests/matrix_free/cell_categorization.cc | 9 +- tests/matrix_free/cell_categorization_02.cc | 15 +-- tests/matrix_free/laplace_operator_03.cc | 9 +- tests/mpi/error_prediction_01.cc | 12 ++- tests/mpi/error_prediction_02.cc | 12 ++- tests/mpi/hp_constraints_consistent_03.cc | 57 +++++----- tests/mpi/hp_hanging_node_constraints_02.cc | 17 +-- tests/mpi/hp_step-40_variable_01.cc | 6 +- tests/mpi/hp_unify_dof_indices_01.cc | 1 + tests/mpi/hp_unify_dof_indices_02.cc | 25 ++--- tests/mpi/hp_unify_dof_indices_03.cc | 25 ++--- tests/mpi/hp_unify_dof_indices_04.cc | 25 ++--- tests/mpi/hp_unify_dof_indices_05.cc | 25 ++--- tests/mpi/hp_unify_dof_indices_06.cc | 25 ++--- tests/mpi/hp_unify_dof_indices_07.cc | 1 + tests/mpi/hp_unify_dof_indices_08.cc | 13 +-- tests/mpi/hp_unify_dof_indices_09.cc | 7 +- tests/mpi/hp_unify_dof_indices_10.cc | 25 ++--- tests/mpi/hp_unify_dof_indices_11.cc | 17 +-- tests/mpi/hp_unify_dof_indices_12.cc | 25 ++--- tests/mpi/hp_unify_dof_indices_13.cc | 25 ++--- tests/mpi/hp_unify_dof_indices_14.cc | 25 ++--- tests/mpi/limit_p_level_difference_01.cc | 23 ++-- tests/mpi/limit_p_level_difference_02.cc | 23 ++-- tests/mpi/limit_p_level_difference_04.cc | 10 +- tests/mpi/p_refinement_and_coarsening.cc | 17 +-- tests/mpi/petsc_step-27.cc | 84 +++++++-------- .../refine_and_coarsen_fixed_fraction_08.cc | 13 +-- .../refine_and_coarsen_fixed_fraction_09.cc | 13 +-- .../mpi/refine_and_coarsen_fixed_number_08.cc | 29 ++--- tests/mpi/renumber_cuthill_mckee_03.cc | 55 +++++----- tests/mpi/solution_transfer_05.cc | 7 +- tests/mpi/trilinos_step-27.cc | 84 +++++++-------- .../mg_transfer_a_03.cc | 7 +- tests/remote_point_evaluation/mapping_01.cc | 7 +- tests/remote_point_evaluation/mapping_02.cc | 7 +- .../vector_tools_evaluate_at_points_01.cc | 6 +- .../vector_tools_evaluate_at_points_02.cc | 6 +- .../vector_tools_evaluate_at_points_03.cc | 6 +- .../vector_tools_evaluate_at_points_04.cc | 6 +- .../vector_tools_evaluate_at_points_05.cc | 6 +- tests/sharedtria/cell_data_transfer_01.cc | 9 +- tests/sharedtria/cell_data_transfer_02.cc | 9 +- tests/sharedtria/hp_choose_p_over_h.cc | 18 ++-- .../sharedtria/limit_p_level_difference_01.cc | 23 ++-- .../sharedtria/limit_p_level_difference_02.cc | 23 ++-- .../sharedtria/limit_p_level_difference_03.cc | 2 + .../sharedtria/limit_p_level_difference_04.cc | 10 +- tests/simplex/step-18.cc | 61 ++++++----- tests/simplex/step-40.cc | 73 ++++++------- tests/simplex/step-55.cc | 101 +++++++++--------- tests/simplex/step-67.cc | 8 +- 66 files changed, 890 insertions(+), 875 deletions(-) diff --git a/tests/boost/extract_representative_set_02.cc b/tests/boost/extract_representative_set_02.cc index c083ab08eb..f2c9867043 100644 --- a/tests/boost/extract_representative_set_02.cc +++ b/tests/boost/extract_representative_set_02.cc @@ -22,6 +22,7 @@ #include +#include #include #include @@ -59,9 +60,9 @@ test(const unsigned int n_refinements) std::vector> 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); diff --git a/tests/distributed_grids/grid_tools_exchange_cell_data_01.cc b/tests/distributed_grids/grid_tools_exchange_cell_data_01.cc index 04f46fde2c..77366e8dc5 100644 --- a/tests/distributed_grids/grid_tools_exchange_cell_data_01.cc +++ b/tests/distributed_grids/grid_tools_exchange_cell_data_01.cc @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -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::vertex_indices()) - { - const std::map>:: - 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::vertex_indices()) + { + const std::map>::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::active_cell_iterator; diff --git a/tests/distributed_grids/grid_tools_exchange_cell_data_02.cc b/tests/distributed_grids/grid_tools_exchange_cell_data_02.cc index 1cdb25566c..edadccd4e9 100644 --- a/tests/distributed_grids/grid_tools_exchange_cell_data_02.cc +++ b/tests/distributed_grids/grid_tools_exchange_cell_data_02.cc @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -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::vertex_indices()) - { - const std::map>:: - 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::vertex_indices()) + { + const std::map>::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>( dofhandler, diff --git a/tests/distributed_grids/grid_tools_exchange_cell_data_03.cc b/tests/distributed_grids/grid_tools_exchange_cell_data_03.cc index c2c35b5c0c..837baab774 100644 --- a/tests/distributed_grids/grid_tools_exchange_cell_data_03.cc +++ b/tests/distributed_grids/grid_tools_exchange_cell_data_03.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -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::vertex_indices()) - { - const std::map>:: - 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::vertex_indices()) + { + const std::map>::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>( diff --git a/tests/distributed_grids/grid_tools_exchange_cell_data_04.cc b/tests/distributed_grids/grid_tools_exchange_cell_data_04.cc index ff835dbf4e..14474c2ed8 100644 --- a/tests/distributed_grids/grid_tools_exchange_cell_data_04.cc +++ b/tests/distributed_grids/grid_tools_exchange_cell_data_04.cc @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -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::vertex_indices()) - { - const std::map>:: - 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::vertex_indices()) + { + const std::map>::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>( diff --git a/tests/fullydistributed_grids/repartitioning_01.cc b/tests/fullydistributed_grids/repartitioning_01.cc index 0be4c56f4b..630bc2bb36 100644 --- a/tests/fullydistributed_grids/repartitioning_01.cc +++ b/tests/fullydistributed_grids/repartitioning_01.cc @@ -52,10 +52,10 @@ partition_distributed_triangulation(const Triangulation &tria_in, LinearAlgebra::distributed::Vector 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(); diff --git a/tests/fullydistributed_grids/repartitioning_05.cc b/tests/fullydistributed_grids/repartitioning_05.cc index d1a701a918..89f4451e74 100644 --- a/tests/fullydistributed_grids/repartitioning_05.cc +++ b/tests/fullydistributed_grids/repartitioning_05.cc @@ -89,11 +89,11 @@ partition_distributed_triangulation(const Triangulation &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(); diff --git a/tests/grid/grid_tools_subdomain_association_01.cc b/tests/grid/grid_tools_subdomain_association_01.cc index adeadcaee5..066f49558d 100644 --- a/tests/grid/grid_tools_subdomain_association_01.cc +++ b/tests/grid/grid_tools_subdomain_association_01.cc @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -78,9 +79,9 @@ test(parallel::TriangulationBase &tria) { std::vector 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> cell_ids_per_processor = Utilities::MPI::all_gather(MPI_COMM_WORLD, local_cell_ids); diff --git a/tests/lac/step-40-linear_operator_01.cc b/tests/lac/step-40-linear_operator_01.cc index 789713191c..ba0d590cd7 100644 --- a/tests/lac/step-40-linear_operator_01.cc +++ b/tests/lac/step-40-linear_operator_01.cc @@ -174,44 +174,41 @@ namespace Step40 std::vector 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); diff --git a/tests/lac/step-40-linear_operator_02.cc b/tests/lac/step-40-linear_operator_02.cc index b8bec22f7c..1b924159da 100644 --- a/tests/lac/step-40-linear_operator_02.cc +++ b/tests/lac/step-40-linear_operator_02.cc @@ -174,44 +174,41 @@ namespace Step40 std::vector 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); diff --git a/tests/lac/step-40-linear_operator_03.cc b/tests/lac/step-40-linear_operator_03.cc index d8438bb62c..9144770d1a 100644 --- a/tests/lac/step-40-linear_operator_03.cc +++ b/tests/lac/step-40-linear_operator_03.cc @@ -175,44 +175,41 @@ namespace Step40 std::vector 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); diff --git a/tests/lac/step-40-linear_operator_04.cc b/tests/lac/step-40-linear_operator_04.cc index d7fe515bf4..70156c9758 100644 --- a/tests/lac/step-40-linear_operator_04.cc +++ b/tests/lac/step-40-linear_operator_04.cc @@ -175,44 +175,41 @@ namespace Step40 std::vector 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); diff --git a/tests/lac/step-40-linear_operator_05.cc b/tests/lac/step-40-linear_operator_05.cc index d752d26dd3..e5858dd24c 100644 --- a/tests/lac/step-40-linear_operator_05.cc +++ b/tests/lac/step-40-linear_operator_05.cc @@ -175,44 +175,41 @@ namespace Step40 std::vector 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); diff --git a/tests/lac/step-40-linear_operator_06.cc b/tests/lac/step-40-linear_operator_06.cc index 91f3f253d8..0b47d597f9 100644 --- a/tests/lac/step-40-linear_operator_06.cc +++ b/tests/lac/step-40-linear_operator_06.cc @@ -175,44 +175,41 @@ namespace Step40 std::vector 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); diff --git a/tests/matrix_free/cell_categorization.cc b/tests/matrix_free/cell_categorization.cc index 7e03e56522..d3aa1fe511 100644 --- a/tests/matrix_free/cell_categorization.cc +++ b/tests/matrix_free/cell_categorization.cc @@ -24,6 +24,7 @@ #include +#include #include #include @@ -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(cell->center()[1] * 10.); + for (const auto &cell : + tria.active_cell_iterators() | IteratorFilters::LocallyOwnedCell()) + data.cell_vectorization_category[cell->active_cell_index()] = + static_cast(cell->center()[1] * 10.); data.cell_vectorization_categories_strict = false; mf_data.reinit(dof, constraints, QGauss<1>(2), data); diff --git a/tests/matrix_free/cell_categorization_02.cc b/tests/matrix_free/cell_categorization_02.cc index f99a38a3ac..8539f2fe43 100644 --- a/tests/matrix_free/cell_categorization_02.cc +++ b/tests/matrix_free/cell_categorization_02.cc @@ -26,6 +26,7 @@ #include +#include #include #include @@ -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); diff --git a/tests/matrix_free/laplace_operator_03.cc b/tests/matrix_free/laplace_operator_03.cc index f336e1fe92..f3e7cbf4a0 100644 --- a/tests/matrix_free/laplace_operator_03.cc +++ b/tests/matrix_free/laplace_operator_03.cc @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -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(); } diff --git a/tests/mpi/error_prediction_01.cc b/tests/mpi/error_prediction_01.cc index 0d9f19766e..1f9a311ba5 100644 --- a/tests/mpi/error_prediction_01.cc +++ b/tests/mpi/error_prediction_01.cc @@ -26,6 +26,8 @@ #include +#include + #include #include @@ -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); diff --git a/tests/mpi/error_prediction_02.cc b/tests/mpi/error_prediction_02.cc index 58c6cadb5e..c03f34f729 100644 --- a/tests/mpi/error_prediction_02.cc +++ b/tests/mpi/error_prediction_02.cc @@ -26,6 +26,8 @@ #include +#include + #include #include @@ -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); diff --git a/tests/mpi/hp_constraints_consistent_03.cc b/tests/mpi/hp_constraints_consistent_03.cc index 4a133fff7c..22f5319392 100644 --- a/tests/mpi/hp_constraints_consistent_03.cc +++ b/tests/mpi/hp_constraints_consistent_03.cc @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -81,37 +82,37 @@ test(const unsigned int degree_center, // prepare DoFHandler DoFHandler 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::face_indices()) - if (static_cast(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::face_indices()) + if (static_cast(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::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::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); diff --git a/tests/mpi/hp_hanging_node_constraints_02.cc b/tests/mpi/hp_hanging_node_constraints_02.cc index fd1d0dd39c..c1798c2bdd 100644 --- a/tests/mpi/hp_hanging_node_constraints_02.cc +++ b/tests/mpi/hp_hanging_node_constraints_02.cc @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -81,14 +82,14 @@ test() DoFHandler 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); diff --git a/tests/mpi/hp_step-40_variable_01.cc b/tests/mpi/hp_step-40_variable_01.cc index 7877160e6b..d312559088 100644 --- a/tests/mpi/hp_step-40_variable_01.cc +++ b/tests/mpi/hp_step-40_variable_01.cc @@ -138,9 +138,9 @@ namespace Step40 LaplaceProblem::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); diff --git a/tests/mpi/hp_unify_dof_indices_01.cc b/tests/mpi/hp_unify_dof_indices_01.cc index 8f47d8e298..2242327a1e 100644 --- a/tests/mpi/hp_unify_dof_indices_01.cc +++ b/tests/mpi/hp_unify_dof_indices_01.cc @@ -30,6 +30,7 @@ #include +#include #include #include #include diff --git a/tests/mpi/hp_unify_dof_indices_02.cc b/tests/mpi/hp_unify_dof_indices_02.cc index 599aedeea9..36c6398b88 100644 --- a/tests/mpi/hp_unify_dof_indices_02.cc +++ b/tests/mpi/hp_unify_dof_indices_02.cc @@ -34,6 +34,7 @@ #include +#include #include #include #include @@ -74,18 +75,18 @@ test() fe.push_back(FE_Q(2)); DoFHandler 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); diff --git a/tests/mpi/hp_unify_dof_indices_03.cc b/tests/mpi/hp_unify_dof_indices_03.cc index 4abac11f12..f991b5316d 100644 --- a/tests/mpi/hp_unify_dof_indices_03.cc +++ b/tests/mpi/hp_unify_dof_indices_03.cc @@ -32,6 +32,7 @@ #include +#include #include #include #include @@ -71,18 +72,18 @@ test() fe.push_back(FE_Q(2)); DoFHandler 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); diff --git a/tests/mpi/hp_unify_dof_indices_04.cc b/tests/mpi/hp_unify_dof_indices_04.cc index c9ee41e3a7..98fb1fbe8c 100644 --- a/tests/mpi/hp_unify_dof_indices_04.cc +++ b/tests/mpi/hp_unify_dof_indices_04.cc @@ -33,6 +33,7 @@ #include +#include #include #include #include @@ -72,18 +73,18 @@ test() fe.push_back(FE_Q(2)); DoFHandler 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); diff --git a/tests/mpi/hp_unify_dof_indices_05.cc b/tests/mpi/hp_unify_dof_indices_05.cc index 0496ee418c..8adc7a7b62 100644 --- a/tests/mpi/hp_unify_dof_indices_05.cc +++ b/tests/mpi/hp_unify_dof_indices_05.cc @@ -33,6 +33,7 @@ #include +#include #include #include #include @@ -72,18 +73,18 @@ test() fe.push_back(FE_Q(2)); DoFHandler 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); diff --git a/tests/mpi/hp_unify_dof_indices_06.cc b/tests/mpi/hp_unify_dof_indices_06.cc index 6ffc4614e3..3afa8342b1 100644 --- a/tests/mpi/hp_unify_dof_indices_06.cc +++ b/tests/mpi/hp_unify_dof_indices_06.cc @@ -33,6 +33,7 @@ #include +#include #include #include #include @@ -73,18 +74,18 @@ test() DoFHandler 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); diff --git a/tests/mpi/hp_unify_dof_indices_07.cc b/tests/mpi/hp_unify_dof_indices_07.cc index b0190ef4e7..b405d72ef8 100644 --- a/tests/mpi/hp_unify_dof_indices_07.cc +++ b/tests/mpi/hp_unify_dof_indices_07.cc @@ -39,6 +39,7 @@ #include +#include #include #include #include diff --git a/tests/mpi/hp_unify_dof_indices_08.cc b/tests/mpi/hp_unify_dof_indices_08.cc index 1adb3913e0..b282159fb7 100644 --- a/tests/mpi/hp_unify_dof_indices_08.cc +++ b/tests/mpi/hp_unify_dof_indices_08.cc @@ -39,6 +39,7 @@ #include +#include #include #include #include @@ -89,12 +90,12 @@ test() // that to build a hash value from it that is then used to assign an // active_fe_index DoFHandler 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: " diff --git a/tests/mpi/hp_unify_dof_indices_09.cc b/tests/mpi/hp_unify_dof_indices_09.cc index 0d7905e233..b3f2c7fad9 100644 --- a/tests/mpi/hp_unify_dof_indices_09.cc +++ b/tests/mpi/hp_unify_dof_indices_09.cc @@ -32,6 +32,7 @@ #include +#include #include #include #include @@ -59,9 +60,9 @@ test(MPI_Comm mpi_communicator) DoFHandler 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); diff --git a/tests/mpi/hp_unify_dof_indices_10.cc b/tests/mpi/hp_unify_dof_indices_10.cc index 090d13b0aa..b91468b55f 100644 --- a/tests/mpi/hp_unify_dof_indices_10.cc +++ b/tests/mpi/hp_unify_dof_indices_10.cc @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -75,18 +76,18 @@ test() fe.push_back(FESystem(FE_Q(2), dim)); DoFHandler 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); diff --git a/tests/mpi/hp_unify_dof_indices_11.cc b/tests/mpi/hp_unify_dof_indices_11.cc index 56067b7451..d9bd5ddfa0 100644 --- a/tests/mpi/hp_unify_dof_indices_11.cc +++ b/tests/mpi/hp_unify_dof_indices_11.cc @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -54,14 +55,14 @@ test() fe.push_back(FESystem(FE_Q(2), 1, FE_Q(1), 1)); DoFHandler 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); diff --git a/tests/mpi/hp_unify_dof_indices_12.cc b/tests/mpi/hp_unify_dof_indices_12.cc index f8edd3386c..de0380b177 100644 --- a/tests/mpi/hp_unify_dof_indices_12.cc +++ b/tests/mpi/hp_unify_dof_indices_12.cc @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -64,18 +65,18 @@ test() fe.push_back(FE_Q(2)); DoFHandler 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); diff --git a/tests/mpi/hp_unify_dof_indices_13.cc b/tests/mpi/hp_unify_dof_indices_13.cc index 62c6d4713f..3e3ced8780 100644 --- a/tests/mpi/hp_unify_dof_indices_13.cc +++ b/tests/mpi/hp_unify_dof_indices_13.cc @@ -26,6 +26,7 @@ #include +#include #include #include @@ -60,18 +61,18 @@ test() fe.push_back(FE_Q(d)); DoFHandler 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); diff --git a/tests/mpi/hp_unify_dof_indices_14.cc b/tests/mpi/hp_unify_dof_indices_14.cc index 1f8859375e..a0fdcacce6 100644 --- a/tests/mpi/hp_unify_dof_indices_14.cc +++ b/tests/mpi/hp_unify_dof_indices_14.cc @@ -26,6 +26,7 @@ #include +#include #include #include @@ -60,18 +61,18 @@ test() fe.push_back(FE_Q(d)); DoFHandler 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); diff --git a/tests/mpi/limit_p_level_difference_01.cc b/tests/mpi/limit_p_level_difference_01.cc index 1b6504203b..38d935c1b9 100644 --- a/tests/mpi/limit_p_level_difference_01.cc +++ b/tests/mpi/limit_p_level_difference_01.cc @@ -30,6 +30,7 @@ #include +#include #include #include @@ -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()); - const unsigned int expected_level = - (sequence.size() - 1) - - max_difference * static_cast(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()); + const unsigned int expected_level = + (sequence.size() - 1) - + max_difference * static_cast(std::round(distance)); + + Assert(cell->active_fe_index() == sequence[expected_level], + ExcInternalError()); + } #endif deallog << "OK" << std::endl; diff --git a/tests/mpi/limit_p_level_difference_02.cc b/tests/mpi/limit_p_level_difference_02.cc index 929b7d7632..6858278a6f 100644 --- a/tests/mpi/limit_p_level_difference_02.cc +++ b/tests/mpi/limit_p_level_difference_02.cc @@ -30,6 +30,7 @@ #include +#include #include #include @@ -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()); - const unsigned int expected_level = - (sequence.size() - 1) - - max_difference * static_cast(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()); + const unsigned int expected_level = + (sequence.size() - 1) - + max_difference * static_cast(std::round(distance)); + + Assert(cell->active_fe_index() == sequence[expected_level], + ExcInternalError()); + } #endif deallog << "OK" << std::endl; diff --git a/tests/mpi/limit_p_level_difference_04.cc b/tests/mpi/limit_p_level_difference_04.cc index 4904a9f638..b2143244a3 100644 --- a/tests/mpi/limit_p_level_difference_04.cc +++ b/tests/mpi/limit_p_level_difference_04.cc @@ -25,6 +25,8 @@ #include +#include + #include #include @@ -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; } diff --git a/tests/mpi/p_refinement_and_coarsening.cc b/tests/mpi/p_refinement_and_coarsening.cc index f804788f92..21be8ccb7b 100644 --- a/tests/mpi/p_refinement_and_coarsening.cc +++ b/tests/mpi/p_refinement_and_coarsening.cc @@ -25,6 +25,7 @@ #include +#include #include #include @@ -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; + } } diff --git a/tests/mpi/petsc_step-27.cc b/tests/mpi/petsc_step-27.cc index ef5e181ce4..45696f1047 100644 --- a/tests/mpi/petsc_step-27.cc +++ b/tests/mpi/petsc_step-27.cc @@ -276,51 +276,45 @@ namespace Step27 std::vector 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 &fe_values = hp_fe_values.get_present_fe_values(); - - std::vector 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 &fe_values = hp_fe_values.get_present_fe_values(); + + std::vector 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); diff --git a/tests/mpi/refine_and_coarsen_fixed_fraction_08.cc b/tests/mpi/refine_and_coarsen_fixed_fraction_08.cc index 7de5a22d3f..37974b3167 100644 --- a/tests/mpi/refine_and_coarsen_fixed_fraction_08.cc +++ b/tests/mpi/refine_and_coarsen_fixed_fraction_08.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -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( diff --git a/tests/mpi/refine_and_coarsen_fixed_fraction_09.cc b/tests/mpi/refine_and_coarsen_fixed_fraction_09.cc index 1fedd2e915..cd10057e4c 100644 --- a/tests/mpi/refine_and_coarsen_fixed_fraction_09.cc +++ b/tests/mpi/refine_and_coarsen_fixed_fraction_09.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -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( diff --git a/tests/mpi/refine_and_coarsen_fixed_number_08.cc b/tests/mpi/refine_and_coarsen_fixed_number_08.cc index a949957ce4..2515f4dcb3 100644 --- a/tests/mpi/refine_and_coarsen_fixed_number_08.cc +++ b/tests/mpi/refine_and_coarsen_fixed_number_08.cc @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -39,20 +40,20 @@ verify(parallel::distributed::Triangulation &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), diff --git a/tests/mpi/renumber_cuthill_mckee_03.cc b/tests/mpi/renumber_cuthill_mckee_03.cc index a20596981b..33ae828745 100644 --- a/tests/mpi/renumber_cuthill_mckee_03.cc +++ b/tests/mpi/renumber_cuthill_mckee_03.cc @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -77,19 +78,19 @@ test() } std::set starting_indices; - for (const auto &cell : dofh.active_cell_iterators()) - if (cell->is_locally_owned()) - for (const unsigned int f : GeometryInfo::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 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::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 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 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 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> support_points; DoFTools::map_dofs_to_support_points(MappingQ1(), dofh, support_points); diff --git a/tests/mpi/solution_transfer_05.cc b/tests/mpi/solution_transfer_05.cc index 4507900fd7..faa27bb1ca 100644 --- a/tests/mpi/solution_transfer_05.cc +++ b/tests/mpi/solution_transfer_05.cc @@ -33,6 +33,7 @@ #include +#include #include #include @@ -61,9 +62,9 @@ test() DoFHandler 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 diff --git a/tests/mpi/trilinos_step-27.cc b/tests/mpi/trilinos_step-27.cc index 0c742e3505..bb91e8ebd7 100644 --- a/tests/mpi/trilinos_step-27.cc +++ b/tests/mpi/trilinos_step-27.cc @@ -276,51 +276,45 @@ namespace Step27 std::vector 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 &fe_values = hp_fe_values.get_present_fe_values(); - - std::vector 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 &fe_values = hp_fe_values.get_present_fe_values(); + + std::vector 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); diff --git a/tests/multigrid-global-coarsening/mg_transfer_a_03.cc b/tests/multigrid-global-coarsening/mg_transfer_a_03.cc index 9eff216d09..b971aa2a3c 100644 --- a/tests/multigrid-global-coarsening/mg_transfer_a_03.cc +++ b/tests/multigrid-global-coarsening/mg_transfer_a_03.cc @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -85,9 +86,9 @@ do_test(const FiniteElement &fe_fine, const FiniteElement &fe_coarse) dof_handler_fine.distribute_dofs(fe); DoFHandler 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 diff --git a/tests/remote_point_evaluation/mapping_01.cc b/tests/remote_point_evaluation/mapping_01.cc index 601d35648a..3246f9a61d 100644 --- a/tests/remote_point_evaluation/mapping_01.cc +++ b/tests/remote_point_evaluation/mapping_01.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -47,9 +48,9 @@ test(const bool enforce_unique_map) Vector 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 mapping; diff --git a/tests/remote_point_evaluation/mapping_02.cc b/tests/remote_point_evaluation/mapping_02.cc index 29f4e9dbc2..38ea4889a6 100644 --- a/tests/remote_point_evaluation/mapping_02.cc +++ b/tests/remote_point_evaluation/mapping_02.cc @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -48,9 +49,9 @@ test() Vector 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 mapping; diff --git a/tests/remote_point_evaluation/vector_tools_evaluate_at_points_01.cc b/tests/remote_point_evaluation/vector_tools_evaluate_at_points_01.cc index 714bfc3997..c19e18666e 100644 --- a/tests/remote_point_evaluation/vector_tools_evaluate_at_points_01.cc +++ b/tests/remote_point_evaluation/vector_tools_evaluate_at_points_01.cc @@ -122,9 +122,9 @@ print(const Mapping & mapping, const auto &tria = dof_handler.get_triangulation(); Vector 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"); diff --git a/tests/remote_point_evaluation/vector_tools_evaluate_at_points_02.cc b/tests/remote_point_evaluation/vector_tools_evaluate_at_points_02.cc index 6a610129ef..73fce13042 100644 --- a/tests/remote_point_evaluation/vector_tools_evaluate_at_points_02.cc +++ b/tests/remote_point_evaluation/vector_tools_evaluate_at_points_02.cc @@ -95,9 +95,9 @@ print(const Mapping & mapping, const auto &tria = dof_handler.get_triangulation(); Vector 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"); diff --git a/tests/remote_point_evaluation/vector_tools_evaluate_at_points_03.cc b/tests/remote_point_evaluation/vector_tools_evaluate_at_points_03.cc index 2bf4c47d72..2e0b884ca6 100644 --- a/tests/remote_point_evaluation/vector_tools_evaluate_at_points_03.cc +++ b/tests/remote_point_evaluation/vector_tools_evaluate_at_points_03.cc @@ -91,9 +91,9 @@ print(const Mapping & mapping, const auto &tria = dof_handler.get_triangulation(); Vector 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"); diff --git a/tests/remote_point_evaluation/vector_tools_evaluate_at_points_04.cc b/tests/remote_point_evaluation/vector_tools_evaluate_at_points_04.cc index 50cd624619..1cb64eb435 100644 --- a/tests/remote_point_evaluation/vector_tools_evaluate_at_points_04.cc +++ b/tests/remote_point_evaluation/vector_tools_evaluate_at_points_04.cc @@ -90,9 +90,9 @@ print(const Mapping & mapping, const auto &tria = dof_handler.get_triangulation(); Vector 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"); diff --git a/tests/remote_point_evaluation/vector_tools_evaluate_at_points_05.cc b/tests/remote_point_evaluation/vector_tools_evaluate_at_points_05.cc index 62fcaf2a28..1423b2027d 100644 --- a/tests/remote_point_evaluation/vector_tools_evaluate_at_points_05.cc +++ b/tests/remote_point_evaluation/vector_tools_evaluate_at_points_05.cc @@ -91,9 +91,9 @@ print(const Mapping & mapping, const auto &tria = dof_handler.get_triangulation(); Vector 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"); diff --git a/tests/sharedtria/cell_data_transfer_01.cc b/tests/sharedtria/cell_data_transfer_01.cc index bd973d32d3..24a1679ada 100644 --- a/tests/sharedtria/cell_data_transfer_01.cc +++ b/tests/sharedtria/cell_data_transfer_01.cc @@ -21,6 +21,7 @@ #include +#include #include #include @@ -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; diff --git a/tests/sharedtria/cell_data_transfer_02.cc b/tests/sharedtria/cell_data_transfer_02.cc index e777475a4f..67089821a0 100644 --- a/tests/sharedtria/cell_data_transfer_02.cc +++ b/tests/sharedtria/cell_data_transfer_02.cc @@ -21,6 +21,7 @@ #include +#include #include #include @@ -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; diff --git a/tests/sharedtria/hp_choose_p_over_h.cc b/tests/sharedtria/hp_choose_p_over_h.cc index 2c073728c5..2aca273b47 100644 --- a/tests/sharedtria/hp_choose_p_over_h.cc +++ b/tests/sharedtria/hp_choose_p_over_h.cc @@ -25,6 +25,8 @@ #include +#include + #include #include @@ -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 = diff --git a/tests/sharedtria/limit_p_level_difference_01.cc b/tests/sharedtria/limit_p_level_difference_01.cc index bb162e9331..cf363d4a4e 100644 --- a/tests/sharedtria/limit_p_level_difference_01.cc +++ b/tests/sharedtria/limit_p_level_difference_01.cc @@ -30,6 +30,7 @@ #include +#include #include #include @@ -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()); - const unsigned int expected_level = - (sequence.size() - 1) - - max_difference * static_cast(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()); + const unsigned int expected_level = + (sequence.size() - 1) - + max_difference * static_cast(std::round(distance)); + + Assert(cell->active_fe_index() == sequence[expected_level], + ExcInternalError()); + } #endif deallog << "OK" << std::endl; diff --git a/tests/sharedtria/limit_p_level_difference_02.cc b/tests/sharedtria/limit_p_level_difference_02.cc index 33de084d82..1221ccf5bf 100644 --- a/tests/sharedtria/limit_p_level_difference_02.cc +++ b/tests/sharedtria/limit_p_level_difference_02.cc @@ -30,6 +30,7 @@ #include +#include #include #include @@ -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()); - const unsigned int expected_level = - (sequence.size() - 1) - - max_difference * static_cast(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()); + const unsigned int expected_level = + (sequence.size() - 1) - + max_difference * static_cast(std::round(distance)); + + Assert(cell->active_fe_index() == sequence[expected_level], + ExcInternalError()); + } #endif deallog << "OK" << std::endl; diff --git a/tests/sharedtria/limit_p_level_difference_03.cc b/tests/sharedtria/limit_p_level_difference_03.cc index 8e429450e1..d9bd72f6a1 100644 --- a/tests/sharedtria/limit_p_level_difference_03.cc +++ b/tests/sharedtria/limit_p_level_difference_03.cc @@ -27,6 +27,8 @@ #include +#include + #include #include diff --git a/tests/sharedtria/limit_p_level_difference_04.cc b/tests/sharedtria/limit_p_level_difference_04.cc index e94dddeca7..5a935b020b 100644 --- a/tests/sharedtria/limit_p_level_difference_04.cc +++ b/tests/sharedtria/limit_p_level_difference_04.cc @@ -25,6 +25,8 @@ #include +#include + #include #include @@ -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; } diff --git a/tests/simplex/step-18.cc b/tests/simplex/step-18.cc index c715661a7f..99d377637d 100644 --- a/tests/simplex/step-18.cc +++ b/tests/simplex/step-18.cc @@ -975,40 +975,39 @@ namespace Step18 std::vector>> displacement_increment_grads( quadrature_formula.size(), std::vector>(dim)); - for (auto &cell : dof_handler.active_cell_iterators()) - if (cell->is_locally_owned()) - { - PointHistory *local_quadrature_points_history = - reinterpret_cast *>(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 *local_quadrature_points_history = + reinterpret_cast *>(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>(new_stress) * rotation); + const SymmetricTensor<2, dim> rotated_new_stress = + symmetrize(transpose(rotation) * + static_cast>(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 diff --git a/tests/simplex/step-40.cc b/tests/simplex/step-40.cc index b040723a55..c0e297c8d7 100644 --- a/tests/simplex/step-40.cc +++ b/tests/simplex/step-40.cc @@ -216,44 +216,41 @@ namespace Step40 std::vector 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); diff --git a/tests/simplex/step-55.cc b/tests/simplex/step-55.cc index 1ddb7e6085..3b77662bf7 100644 --- a/tests/simplex/step-55.cc +++ b/tests/simplex/step-55.cc @@ -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); diff --git a/tests/simplex/step-67.cc b/tests/simplex/step-67.cc index 87cecd642b..fd8f2cb576 100644 --- a/tests/simplex/step-67.cc +++ b/tests/simplex/step-67.cc @@ -2424,10 +2424,10 @@ namespace Euler_DG #endif double min_vertex_distance = std::numeric_limits::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); -- 2.39.5