From: Pasquale Africa Date: Mon, 15 Mar 2021 14:20:59 +0000 (+0000) Subject: Use std::pair for DistributedTriangulationBase::local_cell... X-Git-Tag: v9.3.0-rc1~316^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aefdde757c6cddc09342962f3a0f0bcebe0c8bc6;p=dealii.git Use std::pair for DistributedTriangulationBase::local_cell_relations --- diff --git a/include/deal.II/distributed/fully_distributed_tria.h b/include/deal.II/distributed/fully_distributed_tria.h index 9f2ad34d6c..4996109c63 100644 --- a/include/deal.II/distributed/fully_distributed_tria.h +++ b/include/deal.II/distributed/fully_distributed_tria.h @@ -266,7 +266,7 @@ namespace parallel /** * Go through all locally owned cells and store the relations between - * cells and their status in the private member local_cell_relations. + * cells and their CellStatus in the private member local_cell_relations. * * The stored vector will be ordered by the occurrence of cells. */ diff --git a/include/deal.II/distributed/shared_tria.h b/include/deal.II/distributed/shared_tria.h index 0d4efafe5e..5c03d90be9 100644 --- a/include/deal.II/distributed/shared_tria.h +++ b/include/deal.II/distributed/shared_tria.h @@ -30,7 +30,6 @@ #include #include #include -#include #include #include diff --git a/include/deal.II/distributed/tria.h b/include/deal.II/distributed/tria.h index dda7535d94..8ba5939840 100644 --- a/include/deal.II/distributed/tria.h +++ b/include/deal.II/distributed/tria.h @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -695,8 +694,8 @@ namespace parallel typename dealii::internal::p4est::types::ghost *parallel_ghost; /** - * Go through all p4est trees and store the relations between the status - * of locally owned quadrants and cells in the private member + * Go through all p4est trees and store the relations between a deal.II + * cell and its current CellStatus in the private member * local_cell_relations. * * The stored vector will be ordered by the occurrence of quadrants in diff --git a/include/deal.II/distributed/tria_base.h b/include/deal.II/distributed/tria_base.h index b9849799ac..235939c50d 100644 --- a/include/deal.II/distributed/tria_base.h +++ b/include/deal.II/distributed/tria_base.h @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -689,9 +688,10 @@ namespace parallel const unsigned int n_attached_deserialize_variable); /** - * Go through all cells and store the relations between locally - * owned quadrants and cells in the private member - * local_cell_relations. + * Go through all cells and store the relations between a deal.II cell and + * its current CellStatus in the private member local_cell_relations. + * For an extensive description of CellStatus, see the documentation + * for the member function register_data_attach(). * * The stored vector will be ordered by the occurrence of quadrants. */ @@ -704,12 +704,12 @@ namespace parallel * description of the latter, see the documentation for the member * function register_data_attach(). */ - using cell_relation_t = typename std::tuple; + using cell_relation_t = typename std::pair; /** - * Vector of tuples, which each contain a deal.II cell + * Vector of pair, each containing a deal.II cell iterator * and their relation after refinement. To update its contents, use the - * compute_cell_relations member function. + * update_cell_relations() member function. * * The size of this vector is assumed to be equal to the number of locally * owned quadrants in the parallel_forest object. diff --git a/source/distributed/fully_distributed_tria.cc b/source/distributed/fully_distributed_tria.cc index 5a964891fb..c49843ccd6 100644 --- a/source/distributed/fully_distributed_tria.cc +++ b/source/distributed/fully_distributed_tria.cc @@ -419,7 +419,7 @@ namespace parallel continue; this->local_cell_relations[cell_id] = - std::make_tuple(Triangulation::CELL_PERSIST, cell); + std::make_pair(cell, Triangulation::CELL_PERSIST); ++cell_id; } } diff --git a/source/distributed/tria.cc b/source/distributed/tria.cc index ceb9d84b5f..0f8d574f3a 100644 --- a/source/distributed/tria.cc +++ b/source/distributed/tria.cc @@ -934,14 +934,14 @@ namespace } template - using cell_relation_t = typename std::tuple< - typename dealii::Triangulation::CellStatus, - typename dealii::Triangulation::cell_iterator>; + using cell_relation_t = typename std::pair< + typename dealii::Triangulation::cell_iterator, + typename dealii::Triangulation::CellStatus>; /** - * Adds a tuple of a p4est quadrant, @p status and @p dealii_cell + * Adds a pair of a @p dealii_cell and its @p status * to the vector containing all relations @p cell_rel. - * The tuple will be inserted in the position corresponding to the one + * The pair will be inserted in the position corresponding to the one * of the p4est quadrant in the underlying p4est sc_array. The position * will be determined from @p idx, which is the position of the quadrant * in its corresponding @p tree. The p4est quadrant will be deduced from @@ -962,7 +962,7 @@ namespace Assert(local_quadrant_index < cell_rel.size(), ExcInternalError()); // store relation - cell_rel[local_quadrant_index] = std::make_tuple(status, dealii_cell); + cell_rel[local_quadrant_index] = std::make_pair(dealii_cell, status); } @@ -1032,7 +1032,7 @@ namespace else if (!p4est_has_children && !dealii_cell->has_children()) { // this active cell didn't change - // save tuple into corresponding position + // save pair into corresponding position add_single_cell_relation( cell_rel, tree, @@ -1455,7 +1455,7 @@ namespace parallel { (void)cell_rel; Assert( - (std::get<0>(cell_rel) == // cell_status + (cell_rel.second == // cell_status parallel::distributed::Triangulation::CELL_PERSIST), ExcInternalError()); } @@ -3391,8 +3391,8 @@ namespace parallel // in the same order p4est will encounter them during repartitioning. for (const auto &cell_rel : this->local_cell_relations) { - const auto &cell_status = std::get<0>(cell_rel); - const auto &cell_it = std::get<1>(cell_rel); + const auto &cell_it = cell_rel.first; + const auto &cell_status = cell_rel.second; switch (cell_status) { diff --git a/source/distributed/tria_base.cc b/source/distributed/tria_base.cc index 515081dac2..203a1365f8 100644 --- a/source/distributed/tria_base.cc +++ b/source/distributed/tria_base.cc @@ -745,7 +745,7 @@ namespace parallel { (void)cell_rel; Assert( - (std::get<0>(cell_rel) == // cell_status + (cell_rel.second == // cell_status parallel::DistributedTriangulationBase::CELL_PERSIST), ExcInternalError()); @@ -819,7 +819,7 @@ namespace parallel { // reset all cell_status entries after coarsening/refinement for (auto &cell_rel : local_cell_relations) - std::get<0>(cell_rel) = + cell_rel.second = parallel::DistributedTriangulationBase::CELL_PERSIST; } } @@ -893,8 +893,8 @@ namespace parallel auto data_cell_variable_it = packed_variable_size_data.begin(); for (; cell_rel_it != cell_relations.cend(); ++cell_rel_it) { - const auto &cell_status = std::get<0>(*cell_rel_it); - const auto &dealii_cell = std::get<1>(*cell_rel_it); + const auto &dealii_cell = cell_rel_it->first; + const auto &cell_status = cell_rel_it->second; // Assertions about the tree structure. switch (cell_status) @@ -1197,7 +1197,7 @@ namespace parallel for (; cell_rel_it != cell_relations.end(); ++cell_rel_it, dest_fixed_it += sizes_fixed_cumulative.back()) { - std::get<0>(*cell_rel_it) = // cell_status + cell_rel_it->second = // cell_status Utilities::unpack::CellStatus>(dest_fixed_it, @@ -1298,8 +1298,8 @@ namespace parallel auto dest_sizes_it = dest_sizes_variable.cbegin(); for (; cell_rel_it != cell_relations.end(); ++cell_rel_it) { - const auto &cell_status = std::get<0>(*cell_rel_it); - const auto &dealii_cell = std::get<1>(*cell_rel_it); + const auto &dealii_cell = cell_rel_it->first; + const auto &cell_status = cell_rel_it->second; if (callback_variable_transfer) {