* @code
* class Active
* {
- * public:
- * template <class Iterator>
- * bool operator () (const Iterator &i) const {
- * return (i->active());
- * }
+ * public:
+ * template <class Iterator>
+ * bool operator () (const Iterator &i) const
+ * {
+ * return (i->active());
+ * }
* };
* @endcode
* and objects of this type can be used as predicates. Likewise, this more
* @code
* class SubdomainEqualTo
* {
- * public:
- * SubdomainEqualTo (const types::subdomain_id subdomain_id)
- * : subdomain_id (subdomain_id) {};
+ * public:
+ * SubdomainEqualTo (const types::subdomain_id subdomain_id)
+ * : subdomain_id (subdomain_id)
+ * {};
*
- * template <class Iterator>
- * bool operator () (const Iterator &i) const {
- * return (i->subdomain_id() == subdomain_id);
- * }
+ * template <class Iterator>
+ * bool operator () (const Iterator &i) const
+ * {
+ * return (i->subdomain_id() == subdomain_id);
+ * }
*
- * private:
- * const types::subdomain_id subdomain_id;
+ * private:
+ * const types::subdomain_id subdomain_id;
* };
* @endcode
* Objects like <code>SubdomainEqualTo(3)</code> can then be used as
* flag:
* @code
* FilteredIterator<typename Triangulation<dim>::active_cell_iterator>
- * begin (IteratorFilters::UserFlagSet()),
- * end (IteratorFilters::UserFlagSet());
+ * begin (IteratorFilters::UserFlagSet()),
+ * end (IteratorFilters::UserFlagSet());
* begin.set_to_next_positive(tria.begin_active());
* end = tria.end();
* n_flagged_cells = std::distance (begin, end);
* advanced until we either hit the past-the-end iterator, or the
* predicate is satisfied. This allows, for example, to write code like
* @code
- * FilteredIterator<typename Triangulation<dim>::active_cell_iterator>
- * cell (IteratorFilters::SubdomainEqualTo(13),
- * triangulation.begin_active());
+ * FilteredIterator<typename Triangulation<dim>::active_cell_iterator>
+ * cell (IteratorFilters::SubdomainEqualTo(13),
+ * triangulation.begin_active());
* @endcode
*
* If the cell <code>triangulation.begin_active()</code> does not have a
* @code
* DoFHandler<dim> dof_handler;
* ...
- * for (auto cell : dof_handler.active_cell_iterators())
+ * for (const auto &cell : dof_handler.active_cell_iterators())
* {
* if (cell->is_locally_owned())
* {
* @code
* DoFHandler<dim> dof_handler;
* ...
- * for (auto cell : filter_iterators(dof_handler.active_cell_iterators(),
- * IteratorFilters::LocallyOwnedCell())
+ * const auto filtered_iterators_range =
+ * filter_iterators(dof_handler.active_cell_iterators(),
+ * IteratorFilters::LocallyOwned());
+ * for (const auto &cell : filtered_iterators_range)
* {
* fe_values.reinit (cell);
* ...do the local integration on 'cell'...;
* @code
* DoFHandler<dim> dof_handler;
* ...
- * for (auto cell : dof_handler.active_cell_iterators())
+ * for (const auto &cell : dof_handler.active_cell_iterators())
* {
* if (cell->is_locally_owned())
* {
* @code
* DoFHandler<dim> dof_handler;
* ...
- * for (auto cell : filter_iterators(dof_handler.active_cell_iterators(),
- * IteratorFilters::LocallyOwnedCell(),
- * IteratorFilters::AtBoundary())
+ * const auto filtered_iterators_range =
+ * filter_iterators(dof_handler.active_cell_iterators(),
+ * IteratorFilters::LocallyOwnedCell(),
+ * IteratorFilters::AtBoundary());
+ * for (const auto &cell : filter_iterators_range)
* {
* fe_values.reinit (cell);
* ...do the local integration on 'cell'...;
* a runtime parameter, you can write
* @code
* GridOut::OutputFormat grid_format =
- * GridOut::parse_output_format(get_format_name_from_somewhere());
- * ofstream output_file("some_filename" +
- * GridOut::default_suffix(output_format)); GridOut().write (tria, output_file,
- * output_format);
+ * GridOut::parse_output_format(get_format_name_from_somewhere());
+ * ofstream output_file("some_filename"
+ * + GridOut::default_suffix(output_format));
+ * GridOut().write (tria, output_file, output_format);
* @endcode
* The function <tt>get_output_format_names()</tt> provides a list of possible
* names of output formats in a string that is understandable by the
* @note The actual return type of this function, i.e., the type referenced
* above as @p return_type, is
* @code
- * std::tuple<
- * std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator
- * >, std::vector< std::vector< Point<dim> > >, std::vector<
- * std::vector<unsigned int> > >
+ * std::tuple<
+ * std::vector<
+ * typename Triangulation<dim, spacedim>::active_cell_iterator>,
+ * std::vector<std::vector<Point<dim>>>,
+ * std::vector<std::vector<unsigned int>>>
* @endcode
* The type is abbreviated above to improve readability of this page.
*
* above as @p return_type, is
* @code
* std::tuple<
- * std::vector< typename Triangulation<dim, spacedim>::active_cell_iterator
- * >, std::vector< std::vector< Point<dim> > >, std::vector< std::vector<
- * unsigned int > >, std::vector< std::vector< Point<spacedim> > >,
- * std::vector< std::vector< unsigned int > >
- * >
+ * std::vector<
+ * typename Triangulation<dim, spacedim>::active_cell_iterator>,
+ * std::vector<std::vector<Point<dim>>>,
+ * std::vector<std::vector<unsigned int>>,
+ * std::vector<std::vector<Point<spacedim>>>,
+ * std::vector<std::vector<unsigned int>>>
* @endcode
* The type is abbreviated above to improve readability of this page.
*
* equality:
*
* @code
- * used_vertices = extract_used_vertices(tria);
- * all_vertices = tria.get_vertices();
+ * const auto used_vertices = extract_used_vertices(tria);
+ * auto all_vertices = tria.get_vertices();
*
- * for(auto &id_and_v : used_vertices)
- * all_vertices[id_and_v.first] == id_and_v.second; // true
+ * for(const auto &id_and_v : used_vertices)
+ * all_vertices[id_and_v.first] == id_and_v.second; // true
* @endcode
*
* Notice that the above is not satisfied for mappings that change the
* IteratorFilters. For example, it is possible to extract a layer
* of cells around all of those cells with a given material id,
* @code
- * GridTools::compute_active_cell_halo_layer(tria,
- * IteratorFilters::MaterialIdEqualTo(1,
- * true));
+ * GridTools::compute_active_cell_halo_layer(
+ * tria, IteratorFilters::MaterialIdEqualTo(1, true));
* @endcode
* or around all cells with one of a set of active FE indices for an
* hp::DoFHandler
* @code
- * GridTools::compute_active_cell_halo_layer(hp_dof_handler,
- * IteratorFilters::ActiveFEIndexEqualTo({1,2},
- * true));
+ * GridTools::compute_active_cell_halo_layer(
+ * hp_dof_handler, IteratorFilters::ActiveFEIndexEqualTo({1,2}, true));
* @endcode
* Note that in the last two examples we ensure that the predicate returns
* true only for locally owned cells. This means that the halo layer will
* @note The actual return type of this function, i.e., the type referenced
* above as @p return_type, is
* @code
- * std::tuple< std::vector< std::vector< unsigned int > >,
- * std::map< unsigned int, unsigned int>,
- * std::map< unsigned int, std::vector< unsigned int > > >
+ * std::tuple<std::vector<std::vector<unsigned int>>,
+ * std::map< unsigned int, unsigned int>,
+ * std::map< unsigned int, std::vector<unsigned int>>>
* @endcode
* The type is abbreviated above to improve readability of this page.
*
* other processors to ensure that one can query the right value
* also on those processors:
* @code
- * auto pack
- * = [] (const typename
- * dealii::hp::DoFHandler<dim,spacedim>::active_cell_iterator &cell) ->
- * unsigned int
- * {
- * return cell->active_fe_index();
- * };
- *
- * auto unpack
- * = [] (const typename
- * dealii::hp::DoFHandler<dim,spacedim>::active_cell_iterator &cell, const
- * unsigned int &active_fe_index) -> void
- * {
- * cell->set_active_fe_index(active_fe_index);
- * };
- *
- * GridTools::exchange_cell_data_to_ghosts<unsigned int,
- * dealii::hp::DoFHandler<dim,spacedim>> (dof_handler, pack, unpack);
+ * using active_cell_iterator =
+ * typename dealii::hp::DoFHandler<dim,spacedim>::active_cell_iterator;
+ * auto pack = [] (const active_cell_iterator &cell) -> unsigned int
+ * {
+ * return cell->active_fe_index();
+ * };
+ *
+ * auto unpack = [] (const active_cell_iterator &cell,
+ * const unsigned int &active_fe_index) -> void
+ * {
+ * cell->set_active_fe_index(active_fe_index);
+ * };
+ *
+ * GridTools::exchange_cell_data_to_ghosts<
+ * unsigned int, dealii::hp::DoFHandler<dim,spacedim>> (dof_handler,
+ * pack,
+ * unpack);
* @endcode
*
* You will notice that the @p pack lambda function returns an `unsigned int`,
* <ul>
* <li> <em>Counting the number of cells on a specific level</em>
* @code
- * template <int dim, int spacedim>
- * int Triangulation<dim, spacedim>::n_cells (const int level) const
- * {
- * cell_iterator cell = begin (level),
- * endc = end (level);
+ * template <int dim, int spacedim>
+ * int Triangulation<dim, spacedim>::n_cells (const int level) const
+ * {
* int n=0;
- * for (; cell!=endc; ++cell)
+ * for (const auto &cell : cell_iterators_on_level(level))
* ++n;
* return n;
* }
* template <int dim>
* void Triangulation<dim>::refine_global ()
* {
- * active_cell_iterator cell = begin_active(),
- * endc = end();
- *
- * for (; cell != endc; ++cell)
+ * for (const auto &cell : active_cell_iterators())
* cell->set_refine_flag ();
* execute_coarsening_and_refinement ();
* }
*
* Usage of a Triangulation is mainly done through the use of iterators. An
* example probably shows best how to use it:
- * @code
+ * @code
* int main ()
* {
* Triangulation<2> tria;
* ofstream out("grid.1");
* GridOut::write_gnuplot (tria, out);
* }
- * @endcode
+ * @endcode
*
*
* <h3>Creating a triangulation</h3>
* int main ()
* {
* Triangulation<2> triangulation;
- * const Point<2> vertices[8] = {Point<2>(-1,-1),
- * Point<2>(+1,-1),
- * Point<2>(-1,-1)*0.5,
- * Point<2>(+1,-1)*0.5,
- * Point<2>(-1,+1)*0.5,
- * Point<2>(+1,+1)*0.5,
- * Point<2>(-1,+1),
- * Point<2>(+1,+1)};
- * const int cell_vertices[5][4] = {{0, 1, 2, 3},
- * {0, 2, 6, 4},
- * {2, 3, 4, 5},
- * {1, 7, 3, 5},
- * {6, 4, 7, 5}};
- *
- * std::vector<CellData<2>> cells(5, CellData<2>());
- * for (unsigned int i=0; i<5; ++i)
- * for (unsigned int j=0; j<4; ++j)
+ * const std::vector<Point<2>> vertices = {{-1.0,-1.0},
+ * {+1.0,-1.0},
+ * {-0.5,-0.5},
+ * {+0.5,-0.5},
+ * {-0.5,+0.5},
+ * {+1.0,+1.0},
+ * {-1.0,+1.0},
+ * {+1.0,+1.0}};
+ * const std::vector<std::array<int,GeometryInfo<2>::vertices_per_cell>>
+ * cell_vertices = {{0, 1, 2, 3},
+ * {0, 2, 6, 4},
+ * {2, 3, 4, 5},
+ * {1, 7, 3, 5},
+ * {6, 4, 7, 5}};
+ *
+ * std::vector<CellData<2>> cells(cell_vertices.size(), CellData<2>());
+ * for (unsigned int i=0; i<cell_vertices.size(); ++i)
+ * for (unsigned int j=0; j<GeometryInfo<2>::vertices_per_cell; ++j)
* cells[i].vertices[j] = cell_vertices[i][j];
*
- * triangulation.create_triangulation ({std::begin(vertices),
- * std::end(vertices)}, cells, SubCellData());
+ * triangulation.create_triangulation (vertices, cells, SubCellData());
* triangulation.set_all_manifold_ids_on_boundary(42);
- * // set_manifold stores a copy of its second argument, so a temporary is
- * okay triangulation.set_manifold(42, PolarManifold<2>()); for (unsigned int i
- * = 0; i < 4; ++i)
+ *
+ * // set_manifold stores a copy of its second argument,
+ * // so a temporary is ookay
+ * triangulation.set_manifold(42, PolarManifold<2>());
+ * for (unsigned int i = 0; i < 4; ++i)
* {
* // refine all boundary cells
* for (const auto &cell : triangulation.active_cell_iterators())
* has some more error checking and has to handle the case that subsequent
* cells might actually belong to different triangulation, but that is of no
* concern to us here):
- * @code
- * template <int dim>
- * class FEValues
- * {
- * Triangulation<dim>::active_cell_iterator current_cell, previous_cell;
- * public:
- * void reinit (Triangulation<dim>::active_cell_iterator &cell);
- * void invalidate_previous_cell ();
- * };
- *
- * template <int dim>
- * void
- * FEValues<dim>::reinit (Triangulation<dim>::active_cell_iterator &cell)
+ * @code
+ * template <int dim>
+ * class FEValues
+ * {
+ * Triangulation<dim>::active_cell_iterator current_cell, previous_cell;
+ * public:
+ * void reinit (Triangulation<dim>::active_cell_iterator &cell);
+ * void invalidate_previous_cell ();
+ * };
+ *
+ * template <int dim>
+ * void
+ * FEValues<dim>::reinit (Triangulation<dim>::active_cell_iterator &cell)
+ * {
+ * if (previous_cell.status() != valid)
* {
- * if (previous_cell.status() != valid)
- * {
- * // previous_cell has not been set. set it now, and register
- * // with the triangulation that we want to be informed about
- * // mesh refinement
- * previous_cell = current_cell;
- * previous_cell->get_triangulation().signals.post_refinement
- * .connect (std::bind (&FEValues<dim>::invalidate_previous_cell,
- * std::ref (*this)));
- * }
- * else
- * previous_cell = current_cell;
- *
- * current_cell = cell;
- * // ... do something with the cell...
+ * // previous_cell has not been set. set it now, and register with the
+ * // triangulation that we want to be informed about mesh refinement
+ * previous_cell = current_cell;
+ * previous_cell->get_triangulation().signals.post_refinement.connect(
+ * std::bind (&FEValues<dim>::invalidate_previous_cell,
+ * std::ref (*this)));
* }
+ * else
+ * previous_cell = current_cell;
*
+ * current_cell = cell;
+ * // ... do something with the cell...
+ * }
*
- * template <int dim>
- * void
- * FEValues<dim>::invalidate_previous_cell ()
- * {
- * previous_cell = Triangulation<dim>::active_cell_iterator();
- * }
- * @endcode
+ * template <int dim>
+ * void
+ * FEValues<dim>::invalidate_previous_cell ()
+ * {
+ * previous_cell = Triangulation<dim>::active_cell_iterator();
+ * }
+ * @endcode
* Here, whenever the triangulation is refined, it triggers the post-
* refinement signal which calls the function object attached to it. This
* function object is the member function
* does not contain any active cells (i.e., all cells on this level are
* further refined, then this function returns
* <code>end_active(level)</code> so that loops of the kind
- * @code
- * for (cell=tria.begin_active(level); cell!=tria.end_active(level);
- * ++cell)
- * ...
+ * @code
+ * for (const auto cell=tria.begin_active(level);
+ * cell!=tria.end_active(level);
+ * ++cell)
+ * {
+ * ...
+ * }
* @endcode
* have zero iterations, as may be expected if there are no active cells on
* this level.
* @code
* Triangulation<dim> triangulation;
* ...
- * for (auto cell : triangulation.active_cell_iterators())
+ * for (const auto &cell : triangulation.active_cell_iterators())
* cell->set_user_flag();
* @endcode
*
* In addition to the standard interface, an iterator of this class provides a
* <tt>-@></tt> operator, i.e. you can write statements like
* @code
- * i->set_refine_flag ();
+ * cell->set_refine_flag ();
* @endcode
*
- * Iterators are used whenever a loop over all lines, quads, cells etc. is to
+ * Iterators are used whenever a loop over all lines, quads, cells etc. is to
* be performed. These loops can then be coded like this:
* @code
- * cell_iterator i = tria.begin();
- * cell_iterator end = tria.end();
- * for (; i!=end; ++i)
- * if (cell->at_boundary())
- * cell->set_refine_flag();
+ * cell_iterator cell = tria.begin();
+ * cell_iterator end = tria.end();
+ * for (; cell!=end; ++cell)
+ * if (cell->at_boundary())
+ * cell->set_refine_flag();
* @endcode
*
- * Note the usage of <tt>++i</tt> instead of <tt>i++</tt> since this does not
- * involve temporaries and copying. It is recommended to use a fixed value
+ * Note the usage of <tt>++cell</tt> instead of <tt>cell++</tt> since this does
+ * not involve temporaries and copying. It is recommended to use a fixed value
* <tt>end</tt> inside the loop instead of <tt>tria.end()</tt>, since the
* creation and copying of these iterators is rather expensive compared to
* normal pointers.
* derived iterators:
* @code
* DoFCellAccessor dof_accessor;
- * Triangulation::active_cell_iterator cell
- * = accessor;
+ * Triangulation::active_cell_iterator cell = dof_accessor;
* @endcode
*/
explicit TriaRawIterator(const Accessor &a);