From: Wolfgang Bangerth <bangerth@math.tamu.edu>
Date: Mon, 5 Nov 2012 00:44:55 +0000 (+0000)
Subject: Partial merge from the parallel_mg branch: introduce Triangulation::n_global_levels... 
X-Git-Tag: v8.0.0~1870
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4658d075f6fc743be8e8b62e80ac4770bdebbdd3;p=dealii.git

Partial merge from the parallel_mg branch: introduce Triangulation::n_global_levels() on the distributed triangulation.

git-svn-id: https://svn.dealii.org/trunk@27378 0785d39b-7218-0410-832d-ea1e28bc413d
---

diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h
index fe01bd696f..0a6fcfc76b 100644
--- a/deal.II/doc/news/changes.h
+++ b/deal.II/doc/news/changes.h
@@ -154,6 +154,12 @@ DoFHandler, in particular removal of specializations.
 <h3>Specific improvements</h3>
 
 <ol>
+<li> New: The parallel::distributed::Triangulation::n_global_levels()
+function returns the maximal refinement level over all involved
+processors.
+<br>
+(Timo Heister, 2012/11/04)
+
 <li> New: In addition to the regular subdomain ids (see
 @ref GlossSubdomainId) there is now a second set of flags called
 "level subdomain ids" that also assigns a subdomain to every cell
diff --git a/deal.II/include/deal.II/distributed/tria.h b/deal.II/include/deal.II/distributed/tria.h
index 797d8c436f..7516e362e7 100644
--- a/deal.II/include/deal.II/distributed/tria.h
+++ b/deal.II/include/deal.II/distributed/tria.h
@@ -441,6 +441,11 @@ namespace parallel
                                           */
         unsigned int n_global_active_cells () const;
 
+        /**
+         * Returns the global maximum level. This may be bigger than n_levels.
+         */
+        virtual unsigned int n_global_levels () const;
+
                                          /**
                                           * Return the number of
                                           * active cells owned by each
@@ -627,6 +632,7 @@ namespace parallel
         {
             std::vector<unsigned int> n_locally_owned_active_cells;
             unsigned int              n_global_active_cells;
+            unsigned int              n_global_levels;
         };
 
         NumberCache number_cache;
@@ -825,6 +831,7 @@ namespace parallel
                                           * distributed triangulation.
                                           */
         unsigned int n_global_active_cells () const;
+        virtual unsigned int n_global_levels () const;
 
                                          /**
                                           * Returns a permutation vector for the order the coarse
diff --git a/deal.II/source/distributed/tria.cc b/deal.II/source/distributed/tria.cc
index e025665818..6796e1c8d7 100644
--- a/deal.II/source/distributed/tria.cc
+++ b/deal.II/source/distributed/tria.cc
@@ -2816,6 +2816,7 @@ namespace parallel
         = std::accumulate (number_cache.n_locally_owned_active_cells.begin(),
                            number_cache.n_locally_owned_active_cells.end(),
                            0);
+      number_cache.n_global_levels = Utilities::MPI::max(this->n_levels(), mpi_communicator);
     }
 
 
@@ -2848,6 +2849,15 @@ namespace parallel
 
 
 
+    template <int dim, int spacedim>
+    unsigned int
+    Triangulation<dim,spacedim>::n_global_levels () const
+    {
+      return number_cache.n_global_levels;
+    }
+
+
+
     template <int dim, int spacedim>
     const std::vector<unsigned int> &
     Triangulation<dim,spacedim>::n_locally_owned_active_cells_per_processor () const
@@ -2977,6 +2987,7 @@ namespace parallel
         + MemoryConsumption::memory_consumption(triangulation_has_content)
         + MemoryConsumption::memory_consumption(number_cache.n_locally_owned_active_cells)
         + MemoryConsumption::memory_consumption(number_cache.n_global_active_cells)
+        + MemoryConsumption::memory_consumption(number_cache.n_global_levels)
         + MemoryConsumption::memory_consumption(connectivity)
         + MemoryConsumption::memory_consumption(parallel_forest)
         + MemoryConsumption::memory_consumption(refinement_in_progress)
@@ -3099,6 +3110,15 @@ namespace parallel
     }
 
 
+    template <>
+    unsigned int
+    Triangulation<1,1>::n_global_levels () const
+    {
+      Assert (false, ExcNotImplemented());
+      return 0;
+    }
+
+
     template <>
     MPI_Comm
     Triangulation<1,1>::get_communicator () const
@@ -3148,6 +3168,15 @@ namespace parallel
     }
 
 
+    template <>
+    unsigned int
+    Triangulation<1,2>::n_global_levels () const
+    {
+      Assert (false, ExcNotImplemented());
+      return 0;
+    }
+
+
     template <>
     MPI_Comm
     Triangulation<1,2>::get_communicator () const
@@ -3189,6 +3218,15 @@ namespace parallel
     }
 
 
+    template <>
+    unsigned int
+    Triangulation<1,3>::n_global_levels () const
+    {
+      Assert (false, ExcNotImplemented());
+      return 0;
+    }
+
+
     template <>
     MPI_Comm
     Triangulation<1,3>::get_communicator () const