From 201c4376b25162a359ee02252d9819b24c5732f9 Mon Sep 17 00:00:00 2001 From: Marc Fehling Date: Sun, 21 Aug 2022 17:56:55 -0600 Subject: [PATCH] Move active_fe_index_type to types. --- include/deal.II/base/types.h | 5 ++++ include/deal.II/dofs/dof_handler.h | 17 ++++++----- source/dofs/dof_handler.cc | 47 ++++++++++++------------------ source/hp/refinement.cc | 3 +- 4 files changed, 33 insertions(+), 39 deletions(-) diff --git a/include/deal.II/base/types.h b/include/deal.II/base/types.h index c025f887d4..0b8efbc481 100644 --- a/include/deal.II/base/types.h +++ b/include/deal.II/base/types.h @@ -53,6 +53,11 @@ namespace types */ #define DEAL_II_VERTEX_INDEX_MPI_TYPE MPI_UINT64_T + /** + * The type in which we store the active and future FE indices. + */ + using fe_index = unsigned short int; + /** * The type used to denote the global index of degrees of freedom. This * type is then also used for querying the global *number* of degrees diff --git a/include/deal.II/dofs/dof_handler.h b/include/deal.II/dofs/dof_handler.h index 2c9417b7be..f3665f3c3c 100644 --- a/include/deal.II/dofs/dof_handler.h +++ b/include/deal.II/dofs/dof_handler.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -523,8 +524,10 @@ public: /** * The type in which we store the active FE index. + * + * @deprecated Use types::fe_index instead. */ - using active_fe_index_type = unsigned short int; + using active_fe_index_type DEAL_II_DEPRECATED = types::fe_index; /** * The type in which we store the offsets in the CRS data structures. @@ -535,8 +538,8 @@ public: * Invalid active FE index which will be used as a default value to determine * whether a future FE index has been set or not. */ - static const active_fe_index_type invalid_active_fe_index = - static_cast(-1); + static const types::fe_index invalid_active_fe_index = + static_cast(-1); /** * Standard constructor, not initializing any data. After constructing an @@ -1489,7 +1492,7 @@ private: * of the appropriate position of a cell in the vectors is done via * hp_object_fe_ptr (CRS scheme). */ - mutable std::array, dim + 1> + mutable std::array, dim + 1> hp_object_fe_indices; /** @@ -1501,15 +1504,13 @@ private: * Active FE index of an active cell (identified by level and level index). * This vector is only used in hp-mode. */ - mutable std::vector> - hp_cell_active_fe_indices; + mutable std::vector> hp_cell_active_fe_indices; /** * Future FE index of an active cell (identified by level and level index). * This vector is only used in hp-mode. */ - mutable std::vector> - hp_cell_future_fe_indices; + mutable std::vector> hp_cell_future_fe_indices; /** * An array to store the indices for level degrees of freedom located at diff --git a/source/dofs/dof_handler.cc b/source/dofs/dof_handler.cc index bd2b7bc949..1e2a06f6b8 100644 --- a/source/dofs/dof_handler.cc +++ b/source/dofs/dof_handler.cc @@ -47,8 +47,7 @@ const unsigned int DoFHandler::default_fe_index; template -const typename DoFHandler::active_fe_index_type - DoFHandler::invalid_active_fe_index; +const types::fe_index DoFHandler::invalid_active_fe_index; namespace internal @@ -1322,9 +1321,6 @@ namespace internal dof_handler.hp_capability_enabled == true, (typename DoFHandler::ExcOnlyAvailableWithHP())); - using active_fe_index_type = - typename dealii::DoFHandler::active_fe_index_type; - if (const dealii::parallel::shared::Triangulation *tr = dynamic_cast< const dealii::parallel::shared::Triangulation @@ -1340,7 +1336,7 @@ namespace internal // on the other cells to zero. then we add all of these vectors // up, and because every vector entry has exactly one processor // that owns it, the sum is correct - std::vector active_fe_indices( + std::vector active_fe_indices( tr->n_active_cells(), 0u); for (const auto &cell : dof_handler.active_cell_iterators()) if (cell->is_locally_owned()) @@ -1376,17 +1372,15 @@ namespace internal // to have functions that can pack and unpack the data we want to // transport -- namely, the single unsigned int active_fe_index // objects - auto pack = - [](const typename dealii::DoFHandler:: - active_cell_iterator &cell) -> active_fe_index_type { + auto pack = [](const typename dealii::DoFHandler:: + active_cell_iterator &cell) -> types::fe_index { return cell->active_fe_index(); }; - auto unpack = - [&dof_handler]( - const typename dealii::DoFHandler:: - active_cell_iterator & cell, - const active_fe_index_type active_fe_index) -> void { + auto unpack = [&dof_handler]( + const typename dealii::DoFHandler:: + active_cell_iterator &cell, + const types::fe_index active_fe_index) -> void { // we would like to say // cell->set_active_fe_index(active_fe_index); // but this is not allowed on cells that are not @@ -1397,7 +1391,7 @@ namespace internal }; GridTools::exchange_cell_data_to_ghosts< - active_fe_index_type, + types::fe_index, dealii::DoFHandler>(dof_handler, pack, unpack); } else @@ -1434,15 +1428,12 @@ namespace internal dof_handler.hp_capability_enabled == true, (typename DoFHandler::ExcOnlyAvailableWithHP())); - using active_fe_index_type = - typename dealii::DoFHandler::active_fe_index_type; - if (const dealii::parallel::shared::Triangulation *tr = dynamic_cast< const dealii::parallel::shared::Triangulation *>(&dof_handler.get_triangulation())) { - std::vector future_fe_indices( + std::vector future_fe_indices( tr->n_active_cells(), 0u); for (const auto &cell : dof_handler.active_cell_iterators() | IteratorFilters::LocallyOwnedCell()) @@ -1467,26 +1458,24 @@ namespace internal DistributedTriangulationBase *>( &dof_handler.get_triangulation())) { - auto pack = - [&dof_handler]( - const typename dealii::DoFHandler:: - active_cell_iterator &cell) -> active_fe_index_type { + auto pack = [&dof_handler]( + const typename dealii::DoFHandler:: + active_cell_iterator &cell) -> types::fe_index { return dof_handler .hp_cell_future_fe_indices[cell->level()][cell->index()]; }; - auto unpack = - [&dof_handler]( - const typename dealii::DoFHandler:: - active_cell_iterator & cell, - const active_fe_index_type future_fe_index) -> void { + auto unpack = [&dof_handler]( + const typename dealii::DoFHandler:: + active_cell_iterator &cell, + const types::fe_index future_fe_index) -> void { dof_handler .hp_cell_future_fe_indices[cell->level()][cell->index()] = future_fe_index; }; GridTools::exchange_cell_data_to_ghosts< - active_fe_index_type, + types::fe_index, dealii::DoFHandler>(dof_handler, pack, unpack); } else diff --git a/source/hp/refinement.cc b/source/hp/refinement.cc index cd3b3a70a6..a2b8c9fa96 100644 --- a/source/hp/refinement.cc +++ b/source/hp/refinement.cc @@ -811,8 +811,7 @@ namespace hp // there can be as many levels in the hierarchy as active FE indices are // possible - using level_type = - typename DoFHandler::active_fe_index_type; + using level_type = types::fe_index; const auto invalid_level = static_cast(-1); // map from FE index to level in hierarchy -- 2.39.5