]> https://gitweb.dealii.org/ - dealii.git/commitdiff
allow parallel::distributed::Triangulation::load/save with different number of CPUs
authorTimo Heister <timo.heister@gmail.com>
Sat, 2 Nov 2013 11:26:56 +0000 (11:26 +0000)
committerTimo Heister <timo.heister@gmail.com>
Sat, 2 Nov 2013 11:26:56 +0000 (11:26 +0000)
git-svn-id: https://svn.dealii.org/trunk@31508 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/distributed/tria.h
deal.II/source/distributed/tria.cc

index 6960664c7e161dca1ae3735f8717ccf357709949..b4eab15de51cf350b93c7e2f52f39adab37d08c9 100644 (file)
@@ -94,10 +94,17 @@ inconvenience this causes.
 
 
 <ol>
+  <li> Changed: It is now possible to restore a parallel Triangulation
+  (and solutions) with a different number of processors it was saved with
+  using Triangulation::save() and Triangulation::load().
+  <br>
+  (Timo Heister, 2013/11/02)
+  </li>
+
   <li> Added support for Windows: It is now possible again to use gcc on Windows
   in order to compile the library. We support gcc-4.8.1 on Cygwin64 and MinGW-w64.
   <br>
-  (Matthias Maier, 2013/11/1)
+  (Matthias Maier, 2013/11/01)
   </li>
 
   <li> Changed: step-9, step-13 and step-14 have been converted to use the
index 7375a4bd29e8bdc1028990faacdad4acbdc16dfb..5cac19d2decabf94453d2a6717e985fd062ffd32 100644 (file)
@@ -622,8 +622,8 @@ namespace parallel
 
       /**
        * Load the refinement information saved with save() back in. The mesh
-       * must contain the same coarse mesh that was used in save(). You need
-       * to load with the same number of CPUs that you saved with.
+       * must contain the same coarse mesh that was used in save(). You no
+       * longer need to load with the same number of CPUs that you saved with.
        */
       void load(const char *filename);
 
index fae79cacfa339ed1506cdf12c58742da814d5949..f61226ea89f1c41f42bb6bb3eebc140e537b652e 100644 (file)
@@ -2096,8 +2096,6 @@ namespace parallel
         std::string fname=std::string(filename)+".info";
         std::ifstream f(fname.c_str());
         f >> numcpus >> attached_size >> attached_count;
-        if (numcpus != Utilities::MPI::n_mpi_processes (mpi_communicator))
-          throw ExcInternalError();
       }
 
       attached_data_size = 0;
@@ -2110,6 +2108,21 @@ namespace parallel
                           this,
                           &connectivity);
 
+      if (numcpus != Utilities::MPI::n_mpi_processes (mpi_communicator))
+        {
+          // We are changing the number of CPUs so we need to repartition.
+          // Note that p4est actually distributes the cells between the changed
+          // number of CPUs and so everything works without this call, but
+          // this command changes the distribution for some reason, so we
+          // will leave it in here.
+          dealii::internal::p4est::functions<dim>::
+                partition (parallel_forest,
+                           /* prepare coarsening */ 1,
+                           /* weight_callback */ NULL);
+
+
+        }
+
       try
         {
           copy_local_forest_to_triangulation ();

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.