From: Peter Munch Date: Fri, 16 Aug 2019 05:27:23 +0000 (+0200) Subject: Introduce DistributedTrinagulationBase X-Git-Tag: v9.2.0-rc1~1199^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c076858bbe645ed99bfa47beec2776c60df0c978;p=dealii.git Introduce DistributedTrinagulationBase Conflicts: include/deal.II/distributed/tria.h include/deal.II/distributed/tria_base.h source/distributed/tria.cc --- diff --git a/doc/news/changes/minor/20190817PeterMunch b/doc/news/changes/minor/20190817PeterMunch new file mode 100644 index 0000000000..80e03e27fd --- /dev/null +++ b/doc/news/changes/minor/20190817PeterMunch @@ -0,0 +1,4 @@ +New: Introduce new class parallel::DistributedTriangulationBase +between parallel::TriangulationBase and parallel::distributed::Triangulation. +
+(Peter Munch, 2019/08/17) diff --git a/include/deal.II/distributed/tria.h b/include/deal.II/distributed/tria.h index cb70df8a58..3737ca094a 100644 --- a/include/deal.II/distributed/tria.h +++ b/include/deal.II/distributed/tria.h @@ -249,7 +249,7 @@ namespace parallel */ template class Triangulation - : public dealii::parallel::TriangulationBase + : public dealii::parallel::DistributedTriangulationBase { public: /** @@ -383,6 +383,12 @@ namespace parallel virtual void clear() override; + /** + * Return if multilevel hierarchy is supported and has been constructed. + */ + bool + is_multilevel_hierarchy_constructed() const override; + /** * Implementation of the same function as in the base class. * @@ -1247,7 +1253,7 @@ namespace parallel */ template class Triangulation<1, spacedim> - : public dealii::parallel::TriangulationBase<1, spacedim> + : public dealii::parallel::DistributedTriangulationBase<1, spacedim> { public: /** @@ -1335,6 +1341,9 @@ namespace parallel void save(const std::string &filename) const; + bool + is_multilevel_hierarchy_constructed() const override; + /** * This function is not implemented, but needs to be present for the * compiler. diff --git a/include/deal.II/distributed/tria_base.h b/include/deal.II/distributed/tria_base.h index 09f5fa3e3a..53749beb99 100644 --- a/include/deal.II/distributed/tria_base.h +++ b/include/deal.II/distributed/tria_base.h @@ -246,6 +246,32 @@ namespace parallel template using Triangulation DEAL_II_DEPRECATED = TriangulationBase; + /** + * A base class for distributed triangulations. It can be used to test + * (via dynamic_cast) whether a particular triangulation object + * is able to distribute meshes between processes. + */ + template + class DistributedTriangulationBase + : public dealii::parallel::TriangulationBase + { + public: + /** + * Constructor. + */ + DistributedTriangulationBase( + MPI_Comm mpi_communicator, + const typename dealii::Triangulation::MeshSmoothing + smooth_grid = (dealii::Triangulation::none), + const bool check_for_distorted_cells = false); + + /** + * Return if multilevel hierarchy is supported and has been constructed. + */ + virtual bool + is_multilevel_hierarchy_constructed() const = 0; + }; + } // namespace parallel DEAL_II_NAMESPACE_CLOSE diff --git a/include/deal.II/dofs/dof_handler_policy.h b/include/deal.II/dofs/dof_handler_policy.h index 9f08546f61..4c66167050 100644 --- a/include/deal.II/dofs/dof_handler_policy.h +++ b/include/deal.II/dofs/dof_handler_policy.h @@ -215,7 +215,7 @@ namespace internal /** * This class implements the policy for operations when we use a - * parallel::distributed::Triangulation object. + * parallel::DistributedTriangulationBase object. */ template class ParallelDistributed diff --git a/source/distributed/tria.cc b/source/distributed/tria.cc index a186866e3d..58d00ebd91 100644 --- a/source/distributed/tria.cc +++ b/source/distributed/tria.cc @@ -2127,7 +2127,7 @@ namespace parallel : // Do not check for distorted cells. // For multigrid, we need limit_level_difference_at_vertices // to make sure the transfer operators only need to consider two levels. - dealii::parallel::TriangulationBase( + dealii::parallel::DistributedTriangulationBase( mpi_communicator, (settings_ & construct_multigrid_hierarchy) ? static_cast< @@ -2597,6 +2597,16 @@ namespace parallel + template + bool + Triangulation::is_multilevel_hierarchy_constructed() const + { + return settings & + Triangulation::construct_multigrid_hierarchy; + } + + + template bool Triangulation::has_hanging_nodes() const @@ -4967,9 +4977,10 @@ namespace parallel const typename dealii::Triangulation<1, spacedim>::MeshSmoothing smooth_grid, const Settings /*settings*/) - : dealii::parallel::TriangulationBase<1, spacedim>(mpi_communicator, - smooth_grid, - false) + : dealii::parallel::DistributedTriangulationBase<1, spacedim>( + mpi_communicator, + smooth_grid, + false) { Assert(false, ExcNotImplemented()); } @@ -5104,6 +5115,16 @@ namespace parallel Assert(false, ExcNotImplemented()); } + + + template + bool + Triangulation<1, spacedim>::is_multilevel_hierarchy_constructed() const + { + Assert(false, ExcNotImplemented()); + return false; + } + } // namespace distributed } // namespace parallel diff --git a/source/distributed/tria_base.cc b/source/distributed/tria_base.cc index 1fd06d8820..44252fa12f 100644 --- a/source/distributed/tria_base.cc +++ b/source/distributed/tria_base.cc @@ -392,6 +392,18 @@ namespace parallel return result; } + template + DistributedTriangulationBase::DistributedTriangulationBase( + MPI_Comm mpi_communicator, + const typename dealii::Triangulation::MeshSmoothing + smooth_grid, + const bool check_for_distorted_cells) + : dealii::parallel::TriangulationBase( + mpi_communicator, + smooth_grid, + check_for_distorted_cells) + {} + } // end namespace parallel diff --git a/source/distributed/tria_base.inst.in b/source/distributed/tria_base.inst.in index 3a6096f7ec..861531c392 100644 --- a/source/distributed/tria_base.inst.in +++ b/source/distributed/tria_base.inst.in @@ -28,5 +28,15 @@ for (deal_II_dimension : DIMENSIONS) template class TriangulationBase; #endif + + template class DistributedTriangulationBase; +#if deal_II_dimension < 3 + template class DistributedTriangulationBase; +#endif +#if deal_II_dimension < 2 + template class DistributedTriangulationBase; +#endif \} } diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index 4cb6d6228a..bc0c94a411 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -1446,7 +1446,7 @@ namespace internal std::vector include_vertex( dof_handler.get_triangulation().n_vertices(), false); if (dynamic_cast< - const parallel::distributed::Triangulation *>( + const parallel::DistributedTriangulationBase *>( &dof_handler.get_triangulation()) != nullptr) for (const auto &cell : dof_handler.active_cell_iterators()) if (cell->is_ghost()) @@ -3616,7 +3616,7 @@ namespace internal /** * level subdomain association. Similar to the above function only * for level meshes. This function assigns boundary dofs in - * the same way as parallel::distributed::Triangulation (proc with + * the same way as parallel::DistributedTriangulationBase (proc with * smallest index) instead of the coin flip method above. */ template @@ -4366,7 +4366,7 @@ namespace internal template void get_mg_dofindices_recursively( - const parallel::distributed::Triangulation &tria, + const parallel::DistributedTriangulationBase &tria, const typename dealii::internal::p4est::types::quadrant &p4est_cell, const typename DoFHandler::level_cell_iterator @@ -4420,7 +4420,7 @@ namespace internal template void find_marked_mg_ghost_cells_recursively( - const typename parallel::distributed::Triangulation + const typename parallel::DistributedTriangulationBase & tria, const unsigned int tree_index, const typename DoFHandler::level_cell_iterator @@ -4465,7 +4465,7 @@ namespace internal template void set_mg_dofindices_recursively( - const parallel::distributed::Triangulation &tria, + const parallel::DistributedTriangulationBase &tria, const typename dealii::internal::p4est::types::quadrant &p4est_cell, const typename DoFHandler::level_cell_iterator @@ -4536,7 +4536,7 @@ namespace internal template void communicate_mg_ghost_cells( - const typename parallel::distributed::Triangulation + const typename parallel::DistributedTriangulationBase & tria, DoFHandlerType &dof_handler) { @@ -4961,7 +4961,7 @@ namespace internal // barrier is negligible compared to everything else we do // here if (const auto *triangulation = dynamic_cast< - const parallel::distributed::Triangulation *>( + const parallel::DistributedTriangulationBase *>( &dof_handler.get_triangulation())) { const int ierr = MPI_Barrier(triangulation->get_communicator()); @@ -5004,10 +5004,10 @@ namespace internal const unsigned int dim = DoFHandlerType::dimension; const unsigned int spacedim = DoFHandlerType::space_dimension; - parallel::distributed::Triangulation *triangulation = - (dynamic_cast *>( - const_cast *>( - &dof_handler->get_triangulation()))); + parallel::DistributedTriangulationBase *triangulation = + (dynamic_cast + *>(const_cast *>( + &dof_handler->get_triangulation()))); Assert(triangulation != nullptr, ExcInternalError()); const types::subdomain_id subdomain_id = @@ -5241,15 +5241,13 @@ namespace internal const unsigned int dim = DoFHandlerType::dimension; const unsigned int spacedim = DoFHandlerType::space_dimension; - parallel::distributed::Triangulation *triangulation = - (dynamic_cast *>( - const_cast *>( - &dof_handler->get_triangulation()))); + parallel::DistributedTriangulationBase *triangulation = + (dynamic_cast + *>(const_cast *>( + &dof_handler->get_triangulation()))); Assert(triangulation != nullptr, ExcInternalError()); - AssertThrow((triangulation->settings & - parallel::distributed::Triangulation:: - construct_multigrid_hierarchy), + AssertThrow((triangulation->is_multilevel_hierarchy_constructed()), ExcMessage( "Multigrid DoFs can only be distributed on a parallel " "Triangulation if the flag construct_multigrid_hierarchy " @@ -5470,10 +5468,10 @@ namespace internal const unsigned int dim = DoFHandlerType::dimension; const unsigned int spacedim = DoFHandlerType::space_dimension; - parallel::distributed::Triangulation *triangulation = - (dynamic_cast *>( - const_cast *>( - &dof_handler->get_triangulation()))); + parallel::DistributedTriangulationBase *triangulation = + (dynamic_cast + *>(const_cast *>( + &dof_handler->get_triangulation()))); Assert(triangulation != nullptr, ExcInternalError());