From 3cbf1ab42496562b3e24d7e7b5bf4b2aa6f58f61 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Fri, 27 Jan 2017 14:24:19 -0500 Subject: [PATCH] implement custom partitioning for shared::Tria --- include/deal.II/distributed/shared_tria.h | 40 ++++++++++++++++++++++- source/distributed/shared_tria.cc | 23 +++++++++++-- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/include/deal.II/distributed/shared_tria.h b/include/deal.II/distributed/shared_tria.h index 22f671bc75..582c7d6914 100644 --- a/include/deal.II/distributed/shared_tria.h +++ b/include/deal.II/distributed/shared_tria.h @@ -71,6 +71,37 @@ namespace parallel typedef typename dealii::Triangulation::active_cell_iterator active_cell_iterator; typedef typename dealii::Triangulation::cell_iterator cell_iterator; + /** + * Configuration flags for distributed Triangulations to be set in the + * constructor. Settings can be combined using bitwise OR. + */ + enum Settings + { + /** + * Default settings, other options are disabled. + */ + partition_metis = 0x0, + + /** + * + */ + partition_zorder = 0x1, + + /** + * + */ + partition_custom_signal = 0x2, + + /** + * This flags needs to be set to use the geometric multigrid + * functionality. This option requires additional computation and + * communication. Note: geometric multigrid is still a work in + * progress. + */ + construct_multigrid_hierarchy = 0x8, + }; + + /** * Constructor. * @@ -83,7 +114,8 @@ namespace parallel Triangulation (MPI_Comm mpi_communicator, const typename dealii::Triangulation::MeshSmoothing = (dealii::Triangulation::none), - const bool allow_artificial_cells = false); + const bool allow_artificial_cells = false, + const Settings settings = partition_metis); /** * Destructor. @@ -150,6 +182,12 @@ namespace parallel bool with_artificial_cells() const; private: + + /** + * Settings + */ + Settings settings; + /** * A flag to decide whether or not artificial cells are allowed. */ diff --git a/source/distributed/shared_tria.cc b/source/distributed/shared_tria.cc index 409539f5f5..e010eb2fcc 100644 --- a/source/distributed/shared_tria.cc +++ b/source/distributed/shared_tria.cc @@ -36,9 +36,11 @@ namespace parallel template Triangulation::Triangulation (MPI_Comm mpi_communicator, const typename dealii::Triangulation::MeshSmoothing smooth_grid, - const bool allow_artificial_cells): + const bool allow_artificial_cells, + const Settings settings): dealii::parallel::Triangulation(mpi_communicator,smooth_grid,false), - allow_artificial_cells(allow_artificial_cells) + allow_artificial_cells(allow_artificial_cells), + settings (settings) {} @@ -46,7 +48,22 @@ namespace parallel template void Triangulation::partition() { - dealii::GridTools::partition_triangulation (this->n_subdomains, *this); + if (settings & partition_metis) + { + dealii::GridTools::partition_triangulation (this->n_subdomains, *this); + if (settings & construct_multigrid_hierarchy) + dealii::GridTools::partition_multigrid_levels(...); + } + else if (settings & partition_zorder) + { + dealii::GridTools::partition_triangulation_zorder (this->n_subdomains, *this); + if (settings & construct_multigrid_hierarchy) + dealii::GridTools::partition_multigrid_levels(...); + } + else + { + // signal thing + } true_subdomain_ids_of_cells.resize(this->n_active_cells()); -- 2.39.5