]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify some GridTools functions. 15958/head
authorDavid Wells <drwells@email.unc.edu>
Mon, 4 Sep 2023 18:05:32 +0000 (14:05 -0400)
committerDavid Wells <drwells@email.unc.edu>
Mon, 4 Sep 2023 18:07:50 +0000 (14:07 -0400)
We added Triangulation::get_communicator() awhile back so we don't need the cast
any more.

source/grid/grid_tools.cc

index 32448796bda6916d0b6f7e0a20d83c569d92ff6e..0fb44268a9ab09d02c60a23c8bb560624d19ab27 100644 (file)
@@ -218,17 +218,8 @@ namespace GridTools
             local_volume += fe_values.JxW(q);
         }
 
-    double global_volume = 0;
-
-#ifdef DEAL_II_WITH_MPI
-    if (const parallel::TriangulationBase<dim, spacedim> *p_tria =
-          dynamic_cast<const parallel::TriangulationBase<dim, spacedim> *>(
-            &triangulation))
-      global_volume =
-        Utilities::MPI::sum(local_volume, p_tria->get_communicator());
-    else
-#endif
-      global_volume = local_volume;
+    const double global_volume =
+      Utilities::MPI::sum(local_volume, triangulation.get_communicator());
 
     return global_volume;
   }
@@ -4461,18 +4452,8 @@ namespace GridTools
       if (!cell->is_artificial())
         min_diameter = std::min(min_diameter, cell->diameter(mapping));
 
-    double global_min_diameter = 0;
-
-#ifdef DEAL_II_WITH_MPI
-    if (const parallel::TriangulationBase<dim, spacedim> *p_tria =
-          dynamic_cast<const parallel::TriangulationBase<dim, spacedim> *>(
-            &triangulation))
-      global_min_diameter =
-        Utilities::MPI::min(min_diameter, p_tria->get_communicator());
-    else
-#endif
-      global_min_diameter = min_diameter;
-
+    const double global_min_diameter =
+      Utilities::MPI::min(min_diameter, triangulation.get_communicator());
     return global_min_diameter;
   }
 
@@ -4488,18 +4469,8 @@ namespace GridTools
       if (!cell->is_artificial())
         max_diameter = std::max(max_diameter, cell->diameter(mapping));
 
-    double global_max_diameter = 0;
-
-#ifdef DEAL_II_WITH_MPI
-    if (const parallel::TriangulationBase<dim, spacedim> *p_tria =
-          dynamic_cast<const parallel::TriangulationBase<dim, spacedim> *>(
-            &triangulation))
-      global_max_diameter =
-        Utilities::MPI::max(max_diameter, p_tria->get_communicator());
-    else
-#endif
-      global_max_diameter = max_diameter;
-
+    const double global_max_diameter =
+      Utilities::MPI::max(max_diameter, triangulation.get_communicator());
     return global_max_diameter;
   }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.