From: Peter Munch Date: Wed, 14 Sep 2022 07:08:27 +0000 (+0200) Subject: Triangulation: implement global_*_cell_index_partitioner() X-Git-Tag: v9.5.0-rc1~962^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F14270%2Fhead;p=dealii.git Triangulation: implement global_*_cell_index_partitioner() --- diff --git a/include/deal.II/distributed/tria_base.h b/include/deal.II/distributed/tria_base.h index 011c2d3229..012de34920 100644 --- a/include/deal.II/distributed/tria_base.h +++ b/include/deal.II/distributed/tria_base.h @@ -202,21 +202,12 @@ namespace parallel const std::set & level_ghost_owners() const; - /** - * Return partitioner for the global indices of the cells on the active - * level of the triangulation, which is returned by the function - * CellAccessor::global_active_cell_index(). - */ const std::weak_ptr - global_active_cell_index_partitioner() const; + global_active_cell_index_partitioner() const override; - /** - * Return partitioner for the global indices of the cells on the given @p - * level of the triangulation, which is returned by the function - * CellAccessor::global_level_cell_index(). - */ const std::weak_ptr - global_level_cell_index_partitioner(const unsigned int level) const; + global_level_cell_index_partitioner( + const unsigned int level) const override; /** * @copydoc dealii::Triangulation::get_boundary_ids() diff --git a/include/deal.II/grid/tria.h b/include/deal.II/grid/tria.h index ae36c0c9b8..3f792c8e6a 100644 --- a/include/deal.II/grid/tria.h +++ b/include/deal.II/grid/tria.h @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -176,6 +177,18 @@ namespace internal */ std::vector n_active_lines_level; + /** + * Partitioner for the global active cell indices. + */ + std::shared_ptr + active_cell_index_partitioner; + + /** + * Partitioner for the global level cell indices for each level. + */ + std::vector> + level_cell_index_partitioners; + /** * Constructor. Set values to zero by default. */ @@ -1615,6 +1628,22 @@ public: virtual MPI_Comm get_communicator() const; + /** + * Return the partitioner for the global indices of the cells on the active + * level of the triangulation, which is returned by the function + * CellAccessor::global_active_cell_index(). + */ + virtual const std::weak_ptr + global_active_cell_index_partitioner() const; + + /** + * Return the partitioner for the global indices of the cells on the given @p + * level of the triangulation, which is returned by the function + * CellAccessor::global_level_cell_index(). + */ + virtual const std::weak_ptr + global_level_cell_index_partitioner(const unsigned int level) const; + /** * Set the mesh smoothing to @p mesh_smoothing. This overrides the * MeshSmoothing given to the constructor. It is allowed to call this diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 44abfd59e7..87f10c5d23 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -1757,7 +1757,7 @@ namespace internal */ template static void - compute_number_cache( + compute_number_cache_dim( const Triangulation & triangulation, const unsigned int level_objects, internal::TriangulationImplementation::NumberCache<1> &number_cache) @@ -1845,7 +1845,7 @@ namespace internal */ template static void - compute_number_cache( + compute_number_cache_dim( const Triangulation & triangulation, const unsigned int level_objects, internal::TriangulationImplementation::NumberCache<2> &number_cache) @@ -1858,7 +1858,7 @@ namespace internal void (*)(const Triangulation &, const unsigned int, internal::TriangulationImplementation::NumberCache<1> &)>( - &compute_number_cache), + &compute_number_cache_dim), triangulation, level_objects, static_cast &>( @@ -1952,7 +1952,7 @@ namespace internal */ template static void - compute_number_cache( + compute_number_cache_dim( const Triangulation & triangulation, const unsigned int level_objects, internal::TriangulationImplementation::NumberCache<3> &number_cache) @@ -1965,7 +1965,7 @@ namespace internal void (*)(const Triangulation &, const unsigned int, internal::TriangulationImplementation::NumberCache<2> &)>( - &compute_number_cache), + &compute_number_cache_dim), triangulation, level_objects, static_cast &>( @@ -2043,6 +2043,27 @@ namespace internal } + template + static void + compute_number_cache( + const Triangulation & triangulation, + const unsigned int level_objects, + internal::TriangulationImplementation::NumberCache &number_cache) + { + compute_number_cache_dim(triangulation, level_objects, number_cache); + + number_cache.active_cell_index_partitioner = + std::make_shared( + triangulation.n_active_cells()); + + number_cache.level_cell_index_partitioners.resize( + triangulation.n_levels()); + for (unsigned int level = 0; level < triangulation.n_levels(); ++level) + number_cache.level_cell_index_partitioners[level] = + std::make_shared( + triangulation.n_cells(level)); + } + template static void @@ -11207,6 +11228,27 @@ Triangulation::get_communicator() const +template +const std::weak_ptr +Triangulation::global_active_cell_index_partitioner() const +{ + return number_cache.active_cell_index_partitioner; +} + + + +template +const std::weak_ptr +Triangulation::global_level_cell_index_partitioner( + const unsigned int level) const +{ + AssertIndexRange(level, this->n_levels()); + + return number_cache.level_cell_index_partitioners[level]; +} + + + template void Triangulation::set_mesh_smoothing(