]> https://gitweb.dealii.org/ - dealii.git/commitdiff
examples: favor auto & cell
authorMatthias Maier <tamiko@43-1.org>
Sun, 12 May 2019 04:18:32 +0000 (23:18 -0500)
committerMatthias Maier <tamiko@43-1.org>
Sun, 12 May 2019 15:35:20 +0000 (10:35 -0500)
examples/step-1/doc/results.dox
examples/step-1/step-1.cc
examples/step-18/step-18.cc
examples/step-2/step-2.cc
examples/step-49/doc/results.dox
examples/step-49/step-49.cc
examples/step-60/step-60.cc
examples/step-62/step-62.cc

index 438b1473c33317f7a1671687c52ef331ed78ffad..adde1a4d30cd42c4bd20ef65ba3346d558cc4091 100644 (file)
@@ -35,7 +35,7 @@ places where you can play with it. For example, you could modify the
 criterion by which we decide which cells to refine. An example would
 be to change the condition to this:
 @code
-      for (auto cell: triangulation.active_cell_iterators())
+      for (auto cell: triangulation.active_cell_iterators())
         if (cell->center()[1] > 0)
           cell->set_refine_flag ();
 @endcode
index a753e1859b91eff621a397c1571584fa79ab15b0..f9f77369beb729e6dec0521546c370feb2bffe33 100644 (file)
@@ -192,7 +192,7 @@ void second_grid()
       // <a href="http://en.cppreference.com/w/cpp/language/range-for">range-
       // based for loops</a>, which wrap up all of the syntax shown above into a
       // much shorter form:
-      for (auto cell : triangulation.active_cell_iterators())
+      for (auto &cell : triangulation.active_cell_iterators())
         {
           // @note See @ref Iterators for more information about the iterator
           // classes used in deal.II, and @ref CPP11 for more information about
index 50feb3f2a778dd2d40523ebee86f1fd6db113b97..cb6ba6df8a97b6e3a489985434d6429f4696718f 100644 (file)
@@ -774,7 +774,7 @@ namespace Step18
   {
     const double inner_radius = 0.8, outer_radius = 1;
     GridGenerator::cylinder_shell(triangulation, 3, inner_radius, outer_radius);
-    for (auto cell : triangulation.active_cell_iterators())
+    for (auto &cell : triangulation.active_cell_iterators())
       for (unsigned int f = 0; f < GeometryInfo<dim>::faces_per_cell; ++f)
         if (cell->face(f)->at_boundary())
           {
@@ -1228,7 +1228,7 @@ namespace Step18
     Vector<double> norm_of_stress(triangulation.n_active_cells());
     {
       // Loop over all the cells...
-      for (auto cell : triangulation.active_cell_iterators())
+      for (auto &cell : triangulation.active_cell_iterators())
         if (cell->is_locally_owned())
           {
             // On these cells, add up the stresses over all quadrature
@@ -1573,7 +1573,7 @@ namespace Step18
     pcout << "    Moving mesh..." << std::endl;
 
     std::vector<bool> vertex_touched(triangulation.n_vertices(), false);
-    for (auto cell : dof_handler.active_cell_iterators())
+    for (auto &cell : dof_handler.active_cell_iterators())
       for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)
         if (vertex_touched[cell->vertex_index(v)] == false)
           {
@@ -1641,7 +1641,7 @@ namespace Step18
     // quadrature point objects corresponding to this cell in the vector of
     // such objects:
     unsigned int history_index = 0;
-    for (auto cell : triangulation.active_cell_iterators())
+    for (auto &cell : triangulation.active_cell_iterators())
       if (cell->is_locally_owned())
         {
           cell->set_user_pointer(&quadrature_point_history[history_index]);
@@ -1724,7 +1724,7 @@ namespace Step18
 
     // Then loop over all cells and do the job in the cells that belong to our
     // subdomain:
-    for (auto cell : dof_handler.active_cell_iterators())
+    for (auto &cell : dof_handler.active_cell_iterators())
       if (cell->is_locally_owned())
         {
           // Next, get a pointer to the quadrature point history data local to
index bf602061d3db7621db7b69ed8531c30136d45f0e..13984151c12fdfde3754b04fb1b45d716dd4b85b 100644 (file)
@@ -75,7 +75,7 @@ void make_grid(Triangulation<2> &triangulation)
 
   for (unsigned int step = 0; step < 3; ++step)
     {
-      for (auto cell : triangulation.active_cell_iterators())
+      for (auto &cell : triangulation.active_cell_iterators())
         for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_cell; ++v)
           {
             const double distance_from_center =
index 1340bd644977fc229a62e0f5d224dbd808cdf910..47eda4cfa0910b0327b2e9ebf6d195b7c6348381 100644 (file)
@@ -271,7 +271,7 @@ Triangulation<3> triangulation;
 create_3d_grid(triangulation);
 triangulation.set_manifold(cylinder_id, cylinder);
 
-for (auto cell : triangulation.active_cell_iterators())
+for (auto cell : triangulation.active_cell_iterators())
   if (cell->center()[1] >= 3.0)
     cell->set_all_manifold_ids(cylinder_id);
 
@@ -300,11 +300,11 @@ Triangulation<3> triangulation;
 create_3d_grid(triangulation);
 triangulation.set_manifold(cylinder_id, cylinder);
 
-for (auto cell : triangulation.active_cell_iterators())
+for (auto cell : triangulation.active_cell_iterators())
   if (cell->center()[1] >= 3.0)
     cell->set_all_manifold_ids(cylinder_id);
 
-for (auto cell : triangulation.active_cell_iterators())
+for (auto cell : triangulation.active_cell_iterators())
   for (unsigned int face_n = 0; face_n < GeometryInfo<3>::faces_per_cell;
        ++face_n)
     {
index c99e66a0e32a896d735c96a5afb40a4b9f92f327..8508831963074a5b7c0c7de19fc432dc543b4a2b 100644 (file)
@@ -72,7 +72,7 @@ void print_mesh_info(const Triangulation<dim> &triangulation,
   // we then increment it):
   {
     std::map<types::boundary_id, unsigned int> boundary_count;
-    for (auto cell : triangulation.active_cell_iterators())
+    for (auto &cell : triangulation.active_cell_iterators())
       {
         for (unsigned int face = 0; face < GeometryInfo<dim>::faces_per_cell;
              ++face)
index 49b8629f4932d7b2edfc78e7531ee962f43f8b64..4cc7af9fbe0842cc39f7503892497315b614be30 100644 (file)
@@ -769,7 +769,7 @@ namespace Step60
           GridTools::compute_point_locations(*space_grid_tools_cache,
                                              support_points);
         const auto &cells = std::get<0>(point_locations);
-        for (auto cell : cells)
+        for (auto &cell : cells)
           {
             cell->set_refine_flag();
             for (unsigned int face_no = 0;
index c448b476e2a9002e6b25fa9b7f8fb50d13c0ad60..9993acf5fd3ec5eb92a15722e5b05192433b5cbf 100644 (file)
@@ -1133,7 +1133,7 @@ namespace step62
           dim, Vector<double>(triangulation.n_active_cells()));
         Vector<double> rho(triangulation.n_active_cells());
 
-        for (auto cell : triangulation.active_cell_iterators())
+        for (auto &cell : triangulation.active_cell_iterators())
           {
             if (cell->is_locally_owned())
               {

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.