From: Daniel Arndt Date: Fri, 6 Jul 2018 10:58:16 +0000 (+0200) Subject: Fix comments in @code blocks in grid headers X-Git-Tag: v9.1.0-rc1~940^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F6893%2Fhead;p=dealii.git Fix comments in @code blocks in grid headers --- diff --git a/include/deal.II/grid/filtered_iterator.h b/include/deal.II/grid/filtered_iterator.h index 7a08dc63be..d4f7189d1c 100644 --- a/include/deal.II/grid/filtered_iterator.h +++ b/include/deal.II/grid/filtered_iterator.h @@ -398,11 +398,12 @@ namespace IteratorFilters * @code * class Active * { - * public: - * template - * bool operator () (const Iterator &i) const { - * return (i->active()); - * } + * public: + * template + * bool operator () (const Iterator &i) const + * { + * return (i->active()); + * } * }; * @endcode * and objects of this type can be used as predicates. Likewise, this more @@ -410,17 +411,19 @@ namespace IteratorFilters * @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 - * bool operator () (const Iterator &i) const { - * return (i->subdomain_id() == subdomain_id); - * } + * template + * 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 SubdomainEqualTo(3) can then be used as @@ -473,8 +476,8 @@ namespace IteratorFilters * flag: * @code * FilteredIterator::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); @@ -546,9 +549,9 @@ public: * 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::active_cell_iterator> - * cell (IteratorFilters::SubdomainEqualTo(13), - * triangulation.begin_active()); + * FilteredIterator::active_cell_iterator> + * cell (IteratorFilters::SubdomainEqualTo(13), + * triangulation.begin_active()); * @endcode * * If the cell triangulation.begin_active() does not have a @@ -836,7 +839,7 @@ namespace internal * @code * DoFHandler dof_handler; * ... - * for (auto cell : dof_handler.active_cell_iterators()) + * for (const auto &cell : dof_handler.active_cell_iterators()) * { * if (cell->is_locally_owned()) * { @@ -849,8 +852,10 @@ namespace internal * @code * DoFHandler 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'...; @@ -879,7 +884,7 @@ filter_iterators(IteratorRange i, const Predicate &p) * @code * DoFHandler dof_handler; * ... - * for (auto cell : dof_handler.active_cell_iterators()) + * for (const auto &cell : dof_handler.active_cell_iterators()) * { * if (cell->is_locally_owned()) * { @@ -895,9 +900,11 @@ filter_iterators(IteratorRange i, const Predicate &p) * @code * DoFHandler 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'...; diff --git a/include/deal.II/grid/grid_out.h b/include/deal.II/grid/grid_out.h index 9d094aa1b3..b221fd6a5e 100644 --- a/include/deal.II/grid/grid_out.h +++ b/include/deal.II/grid/grid_out.h @@ -843,10 +843,10 @@ namespace GridOutFlags * 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 get_output_format_names() provides a list of possible * names of output formats in a string that is understandable by the diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index 546cdded4e..b73d4de5de 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -693,10 +693,11 @@ namespace GridTools * @note The actual return type of this function, i.e., the type referenced * above as @p return_type, is * @code - * std::tuple< - * std::vector::active_cell_iterator - * >, std::vector< std::vector< Point > >, std::vector< - * std::vector > > + * std::tuple< + * std::vector< + * typename Triangulation::active_cell_iterator>, + * std::vector>>, + * std::vector>> * @endcode * The type is abbreviated above to improve readability of this page. * @@ -768,11 +769,12 @@ namespace GridTools * above as @p return_type, is * @code * std::tuple< - * std::vector< typename Triangulation::active_cell_iterator - * >, std::vector< std::vector< Point > >, std::vector< std::vector< - * unsigned int > >, std::vector< std::vector< Point > >, - * std::vector< std::vector< unsigned int > > - * > + * std::vector< + * typename Triangulation::active_cell_iterator>, + * std::vector>>, + * std::vector>, + * std::vector>>, + * std::vector>> * @endcode * The type is abbreviated above to improve readability of this page. * @@ -812,11 +814,11 @@ namespace GridTools * 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 @@ -1265,16 +1267,14 @@ namespace GridTools * 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 @@ -1528,9 +1528,9 @@ namespace GridTools * @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::map< unsigned int, unsigned int>, + * std::map< unsigned int, std::vector>> * @endcode * The type is abbreviated above to improve readability of this page. * @@ -2588,24 +2588,23 @@ namespace GridTools * other processors to ensure that one can query the right value * also on those processors: * @code - * auto pack - * = [] (const typename - * dealii::hp::DoFHandler::active_cell_iterator &cell) -> - * unsigned int - * { - * return cell->active_fe_index(); - * }; - * - * auto unpack - * = [] (const typename - * dealii::hp::DoFHandler::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> (dof_handler, pack, unpack); + * using active_cell_iterator = + * typename dealii::hp::DoFHandler::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> (dof_handler, + * pack, + * unpack); * @endcode * * You will notice that the @p pack lambda function returns an `unsigned int`, diff --git a/include/deal.II/grid/tria.h b/include/deal.II/grid/tria.h index 17cdad1fed..e69f67210a 100644 --- a/include/deal.II/grid/tria.h +++ b/include/deal.II/grid/tria.h @@ -571,13 +571,11 @@ namespace internal *
    *
  • Counting the number of cells on a specific level * @code - * template - * int Triangulation::n_cells (const int level) const - * { - * cell_iterator cell = begin (level), - * endc = end (level); + * template + * int Triangulation::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; * } @@ -602,10 +600,7 @@ namespace internal * template * void Triangulation::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 (); * } @@ -617,7 +612,7 @@ namespace internal * * 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; @@ -651,7 +646,7 @@ namespace internal * ofstream out("grid.1"); * GridOut::write_gnuplot (tria, out); * } - * @endcode + * @endcode * * *

    Creating a triangulation

    @@ -976,31 +971,33 @@ namespace internal * 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> cells(5, CellData<2>()); - * for (unsigned int i=0; i<5; ++i) - * for (unsigned int j=0; j<4; ++j) + * const std::vector> 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::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> cells(cell_vertices.size(), CellData<2>()); + * for (unsigned int i=0; i::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()) @@ -1081,45 +1078,43 @@ namespace internal * 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 - * class FEValues - * { - * Triangulation::active_cell_iterator current_cell, previous_cell; - * public: - * void reinit (Triangulation::active_cell_iterator &cell); - * void invalidate_previous_cell (); - * }; - * - * template - * void - * FEValues::reinit (Triangulation::active_cell_iterator &cell) + * @code + * template + * class FEValues + * { + * Triangulation::active_cell_iterator current_cell, previous_cell; + * public: + * void reinit (Triangulation::active_cell_iterator &cell); + * void invalidate_previous_cell (); + * }; + * + * template + * void + * FEValues::reinit (Triangulation::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::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::invalidate_previous_cell, + * std::ref (*this))); * } + * else + * previous_cell = current_cell; * + * current_cell = cell; + * // ... do something with the cell... + * } * - * template - * void - * FEValues::invalidate_previous_cell () - * { - * previous_cell = Triangulation::active_cell_iterator(); - * } - * @endcode + * template + * void + * FEValues::invalidate_previous_cell () + * { + * previous_cell = Triangulation::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 @@ -2656,10 +2651,13 @@ public: * does not contain any active cells (i.e., all cells on this level are * further refined, then this function returns * end_active(level) 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. @@ -2745,7 +2743,7 @@ public: * @code * Triangulation triangulation; * ... - * for (auto cell : triangulation.active_cell_iterators()) + * for (const auto &cell : triangulation.active_cell_iterators()) * cell->set_user_flag(); * @endcode * diff --git a/include/deal.II/grid/tria_iterator.h b/include/deal.II/grid/tria_iterator.h index 0141c51746..e8b0e3892c 100644 --- a/include/deal.II/grid/tria_iterator.h +++ b/include/deal.II/grid/tria_iterator.h @@ -60,21 +60,21 @@ class TriaActiveIterator; * In addition to the standard interface, an iterator of this class provides a * -@> 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 ++i instead of i++ since this does not - * involve temporaries and copying. It is recommended to use a fixed value + * Note the usage of ++cell instead of cell++ since this does + * not involve temporaries and copying. It is recommended to use a fixed value * end inside the loop instead of tria.end(), since the * creation and copying of these iterators is rather expensive compared to * normal pointers. @@ -255,8 +255,7 @@ public: * 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);