From 4468d9a55e0199490d56076d48c2447aa2df98b0 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 26 Mar 2018 21:39:04 +0200 Subject: [PATCH] Let GridTools::minimal/maximal_cell_diameter return global values --- doc/news/changes/minor/20180325DanielArndt | 4 ++-- include/deal.II/grid/grid_tools.h | 7 +++--- source/grid/grid_tools.cc | 26 ++++++++++++++++++++-- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/doc/news/changes/minor/20180325DanielArndt b/doc/news/changes/minor/20180325DanielArndt index cacbfd088d..ff5ceb4ff8 100644 --- a/doc/news/changes/minor/20180325DanielArndt +++ b/doc/news/changes/minor/20180325DanielArndt @@ -1,5 +1,5 @@ Fixed: GridTools::minimal_cell_diameter() and GridTools::maximal_cell_diameter() -return the maximal respectively minimal cell diameter of the non-artifical part -of a Triangulation object. +return the maximal respectively minimal cell diameter over the whole mesh for +parallel::distributed::Triangulation object, too.
(Daniel Arndt, 2018/03/25) diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index c72ffa5cfb..38807c8455 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -154,16 +154,15 @@ namespace GridTools const Mapping &mapping = (StaticMappingQ1::mapping)); /** - * Return the diameter of the smallest active cell of the non-artificial part - * of a triangulation. See step-24 for an example of use of this function. + * Return the diameter of the smallest active cell of a triangulation. See + * step-24 for an example of use of this function. */ template double minimal_cell_diameter (const Triangulation &triangulation); /** - * Return the diameter of the largest active cell of the non-artificial part - * of a triangulation. + * Return the diameter of the largest active cell of a triangulation. */ template double diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 23ef95321d..d54431ac8f 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -2712,7 +2712,18 @@ next_cell: if (!cell->is_artificial()) min_diameter = std::min (min_diameter, cell->diameter()); - return min_diameter; + + double global_min_diameter = 0; + +#ifdef DEAL_II_WITH_MPI + if (const parallel::Triangulation *p_tria + = dynamic_cast*>(&triangulation)) + global_min_diameter = Utilities::MPI::min (min_diameter, p_tria->get_communicator()); + else +#endif + global_min_diameter = min_diameter; + + return global_min_diameter; } @@ -2726,7 +2737,18 @@ next_cell: if (!cell->is_artificial()) max_diameter = std::max (max_diameter, cell->diameter()); - return max_diameter; + + double global_max_diameter = 0; + +#ifdef DEAL_II_WITH_MPI + if (const parallel::Triangulation *p_tria + = dynamic_cast*>(&triangulation)) + global_max_diameter = Utilities::MPI::max (max_diameter, p_tria->get_communicator()); + else +#endif + global_max_diameter = max_diameter; + + return global_max_diameter; } -- 2.39.5