From 4cff70f42721095bd291b48564827e159ef8534b Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Wed, 28 Aug 2019 18:45:18 -0400 Subject: [PATCH] Speed parallel::distributed::Triangulation::add_periodicity up --- source/distributed/tria.cc | 44 ++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/source/distributed/tria.cc b/source/distributed/tria.cc index 33686a1186..c09f51806a 100644 --- a/source/distributed/tria.cc +++ b/source/distributed/tria.cc @@ -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()] -- 2.39.5