]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Speed parallel::distributed::Triangulation::add_periodicity up
authorDaniel Arndt <arndtd@ornl.gov>
Wed, 28 Aug 2019 22:45:18 +0000 (18:45 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Wed, 28 Aug 2019 22:46:34 +0000 (18:46 -0400)
source/distributed/tria.cc

index 33686a11866560b563f20e8f45432927b1ce0592..c09f51806ac1d5b72e584abc042a7e6b23bd82f4 100644 (file)
@@ -4598,6 +4598,8 @@ namespace parallel
       it           = periodicity_vector.begin();
       periodic_end = periodicity_vector.end();
 
+      const auto begin_cell = this->begin();
+
       for (; it < periodic_end; ++it)
         {
           const cell_iterator first_cell  = it->cell[0];
@@ -4607,11 +4609,11 @@ namespace parallel
 
           // respective cells of the matching faces in p4est
           const unsigned int tree_left =
-            coarse_cell_to_p4est_tree_permutation[std::distance(this->begin(),
-                                                                first_cell)];
+            coarse_cell_to_p4est_tree_permutation[first_cell->index() -
+                                                  begin_cell->index()];
           const unsigned int tree_right =
-            coarse_cell_to_p4est_tree_permutation[std::distance(this->begin(),
-                                                                second_cell)];
+            coarse_cell_to_p4est_tree_permutation[second_cell->index() -
+                                                  begin_cell->index()];
 
           // p4est wants to know which corner the first corner on
           // the face with the lower id is mapped to on the face with
@@ -4666,23 +4668,23 @@ namespace parallel
               Assert(first_dealii_idx_on_face != numbers::invalid_unsigned_int,
                      ExcInternalError());
               // Now map dealii_idx_on_face according to the orientation
-              const unsigned int left_to_right[8][4] = {{0, 2, 1, 3},
-                                                        {0, 1, 2, 3},
-                                                        {3, 1, 2, 0},
-                                                        {3, 2, 1, 0},
-                                                        {2, 3, 0, 1},
-                                                        {1, 3, 0, 2},
-                                                        {1, 0, 3, 2},
-                                                        {2, 0, 3, 1}};
-              const unsigned int right_to_left[8][4] = {{0, 2, 1, 3},
-                                                        {0, 1, 2, 3},
-                                                        {3, 1, 2, 0},
-                                                        {3, 2, 1, 0},
-                                                        {2, 3, 0, 1},
-                                                        {2, 0, 3, 1},
-                                                        {1, 0, 3, 2},
-                                                        {1, 3, 0, 2}};
-              const unsigned int second_dealii_idx_on_face =
+              constexpr unsigned int left_to_right[8][4] = {{0, 2, 1, 3},
+                                                            {0, 1, 2, 3},
+                                                            {3, 1, 2, 0},
+                                                            {3, 2, 1, 0},
+                                                            {2, 3, 0, 1},
+                                                            {1, 3, 0, 2},
+                                                            {1, 0, 3, 2},
+                                                            {2, 0, 3, 1}};
+              constexpr unsigned int right_to_left[8][4] = {{0, 2, 1, 3},
+                                                            {0, 1, 2, 3},
+                                                            {3, 1, 2, 0},
+                                                            {3, 2, 1, 0},
+                                                            {2, 3, 0, 1},
+                                                            {2, 0, 3, 1},
+                                                            {1, 0, 3, 2},
+                                                            {1, 3, 0, 2}};
+              const unsigned int     second_dealii_idx_on_face =
                 lower_idx == 0 ? left_to_right[it->orientation.to_ulong()]
                                               [first_dealii_idx_on_face] :
                                  right_to_left[it->orientation.to_ulong()]

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.