]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use an easier to read style for declaring iterator variables. 3246/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 14 Oct 2016 10:14:21 +0000 (04:14 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 14 Oct 2016 10:14:21 +0000 (04:14 -0600)
For first-time readers of deal.II programs (who may be used to other languages than C++),
our declarations of 'cell' and 'endc' that span multiple lines may be difficult to read.

For the first three tutorial programs, use a simpler syntax where each variable declaration
only requires a single line of code.

examples/step-1/step-1.cc
examples/step-2/step-2.cc
examples/step-3/step-3.cc

index 42c437ba8b2ba7e5759a769ca96d714d09c51248..a3873359283d0da601d1cd4072de9bc073e3d49e 100644 (file)
@@ -146,7 +146,7 @@ void second_grid ()
       // Next, we need an iterator that points to a cell and which we will
       // move over all active cells one by one. In a sense, you can think of a
       // triangulation as a collection of cells. If it was an array, you would
-      // just get a pointer that you move from one to the next. In
+      // just get a pointer that you move from one array element to the next. In
       // triangulations, cells aren't stored as an array, so simple pointers
       // do not work, but one can generalize pointers to iterators (see <a
       // href="http://en.wikipedia.org/wiki/Iterator#C.2B.2B">this wikipedia
@@ -173,9 +173,8 @@ void second_grid ()
       // After declaring the iterator variable, the loop over all cells is
       // then rather trivial, and looks like any loop involving pointers
       // instead of iterators:
-      Triangulation<2>::active_cell_iterator
-      cell = triangulation.begin_active(),
-      endc = triangulation.end();
+      Triangulation<2>::active_cell_iterator cell = triangulation.begin_active();
+      Triangulation<2>::active_cell_iterator endc = triangulation.end();
       for (; cell!=endc; ++cell)
         {
           // @note Writing a loop like this requires a lot of typing, but it
index 9bd4d3661c7b6fc9ca65130678cae8b5a8083f3d..d07a0e17fd57d99bebfdd0728bc11d94b7c74ed2 100644 (file)
@@ -93,9 +93,8 @@ void make_grid (Triangulation<2> &triangulation)
 
   for (unsigned int step=0; step<3; ++step)
     {
-      Triangulation<2>::active_cell_iterator
-      cell = triangulation.begin_active(),
-      endc = triangulation.end();
+      Triangulation<2>::active_cell_iterator cell = triangulation.begin_active();
+      Triangulation<2>::active_cell_iterator endc = triangulation.end();
 
       for (; cell!=endc; ++cell)
         for (unsigned int v=0;
index b71f63cec9790de841864326049cb8891274d5d7..ba73fbd015be2339c2d05d003654ebce223b77b8 100644 (file)
@@ -390,9 +390,8 @@ void Step3::assemble_system ()
   // Now for the loop over all cells. We have seen before how this works, so
   // the following code should be familiar including the conventional names
   // for these variables:
-  DoFHandler<2>::active_cell_iterator
-  cell = dof_handler.begin_active(),
-  endc = dof_handler.end();
+  DoFHandler<2>::active_cell_iterator cell = dof_handler.begin_active();
+  DoFHandler<2>::active_cell_iterator endc = dof_handler.end();
   for (; cell!=endc; ++cell)
     {
       // @note As already mentioned in step-1, there is a more convenient way

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.