face_iterator
end_face() const;
+ /**
+ * Return an iterator range that contains all active faces that make up this
+ * triangulation. This function is the face version of
+ * Triangulation::active_cell_iterators(), and allows one to write code
+ * like, e.g.,
+ *
+ * @code
+ * Triangulation<dim> triangulation;
+ * ...
+ * for (auto &face : triangulation.active_face_iterators())
+ * face->set_manifold_id(42);
+ * @endcode
+ *
+ * @return The half open range <code>[this->begin_active_face(),
+ * this->end_face())</code>
+ *
+ * @ingroup CPP11
+ */
+ IteratorRange<active_face_iterator>
+ active_face_iterators() const;
+
/*
* @}
*/
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2018 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+
+// Check face range-based for loops for triangulations
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+
+#include <string>
+
+#include "../tests.h"
+
+
+template <int dim, int spacedim>
+void
+check()
+{
+ Triangulation<dim, spacedim> tr;
+ GridGenerator::hyper_cube(tr);
+ tr.refine_global(2);
+
+ for (auto &face : tr.active_face_iterators())
+ face->set_manifold_id(42);
+
+ for (const auto &cell : tr.active_cell_iterators())
+ for (unsigned int face_n = 0; face_n < GeometryInfo<dim>::faces_per_cell;
+ ++face_n)
+ Assert(cell->face(face_n)->manifold_id() == 42, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+int
+main()
+{
+ initlog();
+
+ check<2, 2>();
+ check<2, 3>();
+ check<3, 3>();
+}
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2018 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+// check that we can create filtered face iterators from a face iterator
+// range. Similar to filtered_iterator_05.
+
+#include <deal.II/grid/filtered_iterator.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+
+#include <set>
+
+#include "../tests.h"
+
+template <int dim, int spacedim>
+void
+test()
+{
+ Triangulation<dim, spacedim> tria;
+ GridGenerator::hyper_cube(tria);
+ // refine the boundary cells a few times
+ for (unsigned int i = 0; i < 5; ++i)
+ {
+ for (auto &cell : tria.active_cell_iterators())
+ cell->set_refine_flag();
+ tria.execute_coarsening_and_refinement();
+ }
+
+ // we now have a number of cells, flag them with some manifold ids
+ std::size_t i = 0;
+ for (auto &cell : tria.active_cell_iterators())
+ {
+ cell->set_all_manifold_ids(i % 3);
+ ++i;
+ }
+
+ // Count the faces that are on the boundary and have a manifold_id of 0
+ const types::manifold_id manifold_id = 0;
+ std::set<typename Triangulation<dim, spacedim>::active_face_iterator>
+ face_set;
+ for (const auto &cell : tria.active_cell_iterators())
+ for (unsigned int face_n = 0; face_n < GeometryInfo<dim>::faces_per_cell;
+ ++face_n)
+ if (cell->face(face_n)->at_boundary() &&
+ cell->face(face_n)->manifold_id() == manifold_id)
+ face_set.insert(cell->face(face_n));
+
+ std::size_t n_filtered_cells = 0;
+ for (const auto filtered_cell : filter_iterators(
+ tria.active_face_iterators(),
+ IteratorFilters::AtBoundary(),
+ [=](const typename Triangulation<dim, spacedim>::active_face_iterator
+ &face) { return face->manifold_id() == manifold_id; }))
+ {
+ AssertThrow(face_set.count(filtered_cell) == 1,
+ ExcMessage("Wrong cell filtered."));
+ ++n_filtered_cells;
+ }
+ AssertThrow(n_filtered_cells == face_set.size(),
+ ExcMessage("Filtered cells missing."));
+}
+
+int
+main()
+{
+ initlog();
+ deallog << std::setprecision(4);
+
+ test<2, 2>();
+ test<2, 3>();
+ test<3, 3>();
+
+ deallog << "OK" << std::endl;
+}