]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix include/fe 7609/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 5 Jan 2019 22:08:48 +0000 (23:08 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Fri, 18 Jan 2019 10:27:11 +0000 (11:27 +0100)
include/deal.II/fe/block_mask.h
include/deal.II/fe/component_mask.h
include/deal.II/fe/fe_tools.templates.h

index 71a170f6e175b1444255c20c816c64e808e2393a..052ce80a726f278982e521119f29a416817d9db3 100644 (file)
@@ -21,6 +21,7 @@
 #include <deal.II/base/exceptions.h>
 #include <deal.II/base/memory_consumption.h>
 
+#include <algorithm>
 #include <iosfwd>
 #include <vector>
 
@@ -289,11 +290,9 @@ BlockMask::n_selected_blocks(const unsigned int n) const
   else
     {
       AssertDimension(real_n, block_mask.size());
-      unsigned int c = 0;
-      for (unsigned int i = 0; i < block_mask.size(); ++i)
-        if (block_mask[i] == true)
-          ++c;
-      return c;
+      return std::count_if(block_mask.begin(),
+                           block_mask.end(),
+                           [](const bool selected) { return selected; });
     }
 }
 
index 9d1a696da348f780efca1765f2d3260cfeead632..9599ee873a87cb4ebc1bdbee9c3638097a418b0c 100644 (file)
@@ -21,6 +21,7 @@
 #include <deal.II/base/exceptions.h>
 #include <deal.II/base/memory_consumption.h>
 
+#include <algorithm>
 #include <iosfwd>
 #include <vector>
 
@@ -319,11 +320,9 @@ ComponentMask::n_selected_components(const unsigned int n) const
   else
     {
       AssertDimension(real_n, component_mask.size());
-      unsigned int c = 0;
-      for (unsigned int i = 0; i < component_mask.size(); ++i)
-        if (component_mask[i] == true)
-          ++c;
-      return c;
+      return std::count_if(component_mask.begin(),
+                           component_mask.end(),
+                           [](const bool selected) { return selected; });
     }
 }
 
index 7a0f374a300d7e6bdc923185625039557de28fa3..be0bc3ff29b1a66c5a2011f1f21564fee84f8c93 100644 (file)
@@ -642,11 +642,12 @@ namespace FETools
         {
           // The base element establishing a component does not make sense in
           // this case. Set up to something meaningless:
-          for (unsigned int i = 0; i < component_to_base_table.size(); i++)
-            component_to_base_table[i] =
-              std::make_pair(std::make_pair(numbers::invalid_unsigned_int,
-                                            numbers::invalid_unsigned_int),
-                             numbers::invalid_unsigned_int);
+          std::fill(
+            component_to_base_table.begin(),
+            component_to_base_table.end(),
+            std::make_pair(std::make_pair(numbers::invalid_unsigned_int,
+                                          numbers::invalid_unsigned_int),
+                           numbers::invalid_unsigned_int));
         }
 
 
@@ -1403,16 +1404,16 @@ namespace FETools
 
     comp_start.resize(element.n_base_elements());
 
-    unsigned int k = 0;
+    unsigned int index = 0;
     for (unsigned int i = 0; i < comp_start.size(); ++i)
       {
         comp_start[i].resize(element.element_multiplicity(i));
         const unsigned int increment = element.base_element(i).dofs_per_cell;
 
-        for (unsigned int j = 0; j < comp_start[i].size(); ++j)
+        for (unsigned int &first_index_of_component : comp_start[i])
           {
-            comp_start[i][j] = k;
-            k += increment;
+            first_index_of_component = index;
+            index += increment;
           }
       }
 

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.