#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>
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);
#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>
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;
#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>
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,
#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>
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>>(
#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>
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>>(
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();
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();
#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>
{
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);
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);
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);
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);
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);
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);
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);
#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>
(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);
#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>
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);
#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>
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();
}
#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>
// ------ 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);
#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>
// ------ 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);
#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>
// 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);
#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>
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);
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);
#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>
#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>
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);
#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>
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);
#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>
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);
#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>
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);
#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>
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);
#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>
#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>
// 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: "
#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>
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);
#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>
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);
#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>
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);
#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>
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);
#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>
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);
#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>
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);
#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>
#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;
#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>
#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;
#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>
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;
}
#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>
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;
+ }
}
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);
#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>
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(
#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>
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(
#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>
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),
#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>
}
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,
// 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);
#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>
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
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);
#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>
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
#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>
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;
#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>
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;
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");
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");
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");
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");
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");
#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>
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;
#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>
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;
#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>
// 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 =
#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>
#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;
#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>
#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;
#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>
#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>
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;
}
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
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);
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);
#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);