From: David Wells Date: Sat, 27 Feb 2016 22:47:51 +0000 (-0500) Subject: Reformat example code in tria.h. X-Git-Tag: v8.5.0-rc1~1278^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c816f179caa0cae45bf8e384a1f7d64e5463953;p=dealii.git Reformat example code in tria.h. --- diff --git a/include/deal.II/grid/tria.h b/include/deal.II/grid/tria.h index 2388994e53..169863e02d 100644 --- a/include/deal.II/grid/tria.h +++ b/include/deal.II/grid/tria.h @@ -491,19 +491,21 @@ namespace internal *
  • Counting the number of cells on a specific level * @code * template - * int Triangulation::n_cells (const int level) const { + * int Triangulation::n_cells (const int level) const + * { * cell_iterator cell = begin (level), - * endc = end(level); + * endc = end (level); * int n=0; * for (; cell!=endc; ++cell) * ++n; * return n; - * }; + * } * @endcode * Another way, which uses std::distance, would be to write * @code * template - * int Triangulation::n_cells (const int level) const { + * int Triangulation::n_cells (const int level) const + * { * int n=0; * distance (begin(level), * (level == levels.size()-1 ? @@ -511,20 +513,21 @@ namespace internal * begin (level+1)), * n); * return n; - * }; + * } * @endcode * *
  • Refining all cells of a triangulation * @code * template - * void Triangulation::refine_global () { + * void Triangulation::refine_global () + * { * active_cell_iterator cell = begin_active(), * endc = end(); * * for (; cell != endc; ++cell) * cell->set_refine_flag (); * execute_coarsening_and_refinement (); - * }; + * } * @endcode * * @@ -534,42 +537,39 @@ namespace internal * Usage of a Triangulation is mainly done through the use of iterators. An * example probably shows best how to use it: * @code - * void main () { - * Triangulation<2> tria; - * - * // read in a coarse grid file - * - * // we want to log the - * // refinement history - * ofstream history ("mesh.history"); - * - * // refine first cell - * tria.begin_active()->set_refine_flag(); - * tria.save_refine_flags (history); - * tria.execute_coarsening_and_refinement (); - * - * // refine first active cell - * // on coarsest level - * tria.begin_active()->set_refine_flag (); - * tria.save_refine_flags (history); - * tria.execute_coarsening_and_refinement (); - * - * Triangulation<2>::active_cell_iterator cell; - * for (int i=0; i<17; ++i) - * { - * // refine the presently - * // second last cell 17 - * // times - * cell = tria.last_active(tria.n_levels()-1); - * --cell; - * cell->set_refine_flag (); - * tria.save_refine_flags (history); - * tria.execute_coarsening_and_refinement (); - * }; - * // output the grid - * ofstream out("grid.1"); - * GridOut::write_gnuplot (tria, out); - * }; + * int main () + * { + * Triangulation<2> tria; + * + * // read in a coarse grid file + * + * // we want to log the refinement history + * ofstream history ("mesh.history"); + * + * // refine first cell + * tria.begin_active()->set_refine_flag(); + * tria.save_refine_flags (history); + * tria.execute_coarsening_and_refinement (); + * + * // refine first active cell on coarsest level + * tria.begin_active()->set_refine_flag (); + * tria.save_refine_flags (history); + * tria.execute_coarsening_and_refinement (); + * + * Triangulation<2>::active_cell_iterator cell; + * for (int i=0; i<17; ++i) + * { + * // refine the presently second last cell 17 times + * cell = tria.last_active(tria.n_levels()-1); + * --cell; + * cell->set_refine_flag (); + * tria.save_refine_flags (history); + * tria.execute_coarsening_and_refinement (); + * }; + * // output the grid + * ofstream out("grid.1"); + * GridOut::write_gnuplot (tria, out); + * } * @endcode * * @@ -800,27 +800,29 @@ namespace internal * be stored and loaded through the @p save_refine_flags and @p * load_refine_flags functions. Normally, the code will look like this: * @code - * // open output file + * // open output file * ofstream history("mesh.history"); - * // do 10 refinement steps - * for (int step=0; step<10; ++step) { - * ...; - * // flag cells according to some criterion - * ...; - * tria.save_refine_flags (history); - * tria.execute_coarsening_and_refinement (); - * }; + * // do 10 refinement steps + * for (unsigned int step=0; step<10; ++step) + * { + * ...; + * // flag cells according to some criterion + * ...; + * tria.save_refine_flags (history); + * tria.execute_coarsening_and_refinement (); + * } * @endcode * * If you want to re-create the grid from the stored information, you write: * @code - * // open input file + * // open input file * ifstream history("mesh.history"); - * // do 10 refinement steps - * for (int step=0; step<10; ++step) { - * tria.load_refine_flags (history); - * tria.execute_coarsening_and_refinement (); - * }; + * // do 10 refinement steps + * for (unsigned int step=0; step<10; ++step) + * { + * tria.load_refine_flags (history); + * tria.execute_coarsening_and_refinement (); + * } * @endcode * * The same scheme is employed for coarsening and the coarsening flags. @@ -881,7 +883,8 @@ namespace internal * class derived from Boundary<2>): * * @code - * void main () { + * int main () + * { * Triangulation<2> tria; * // set the boundary function * // for all boundaries with @@ -889,25 +892,24 @@ namespace internal * Ball ball; * tria.set_boundary (0, ball); * - * // read some coarse grid + * // read some coarse grid * * - * Triangulation<2>::active_cell_iterator cell, endc; - * for (int i=0; i<8; ++i) - * { - * cell = tria.begin_active(); - * endc = tria.end(); + * Triangulation<2>::active_cell_iterator cell, endc; + * for (int i=0; i<8; ++i) + * { + * cell = tria.begin_active(); + * endc = tria.end(); * - * // refine all - * // boundary cells - * for (; cell!=endc; ++cell) - * if (cell->at_boundary()) - * cell->set_refine_flag(); + * // refine all boundary cells + * for (; cell!=endc; ++cell) + * if (cell->at_boundary()) + * cell->set_refine_flag(); * - * tria.execute_coarsening_and_refinement(); - * }; - * }; - * @endcode + * tria.execute_coarsening_and_refinement(); + * } + * } + * @endcode * * You should take note of one caveat: if you have concave boundaries, you * must make sure that a new boundary vertex does not lie too much inside the @@ -940,11 +942,13 @@ namespace internal * As a simple example, the following code will print something to the output * every time the triangulation has just been refined: * @code - * void f() { + * void f() + * { * std::cout << "Triangulation has been refined." << std::endl; * } * - * void run () { + * void run () + * { * Triangulation triangulation; * // fill it somehow * triangulation.signals.post_refinement.connect (&f); @@ -968,16 +972,18 @@ namespace internal * 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 (); + * 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) { + * FEValues::reinit (Triangulation::active_cell_iterator &cell) + * { * if (previous_cell.status() != valid) * { * // previous_cell has not been set. set it now, and register @@ -992,13 +998,14 @@ namespace internal * previous_cell = current_cell; * * current_cell = cell; - * ... do something with the cell... + * // ... do something with the cell... * } * * * template * void - * FEValues::invalidate_previous_cell () { + * FEValues::invalidate_previous_cell () + * { * previous_cell = Triangulation::active_cell_iterator(); * } * @endcode