From: Daniel Arndt Date: Wed, 28 Aug 2019 22:45:18 +0000 (-0400) Subject: Speed parallel::distributed::Triangulation::add_periodicity up X-Git-Tag: v9.2.0-rc1~1162^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4cff70f42721095bd291b48564827e159ef8534b;p=dealii.git Speed parallel::distributed::Triangulation::add_periodicity up --- 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()]