From: heister Date: Sat, 2 Nov 2013 11:26:56 +0000 (+0000) Subject: allow parallel::distributed::Triangulation::load/save with different number of CPUs X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb95c3b93f6f45ced5fd9ada03db5d154c4f1156;p=dealii-svn.git allow parallel::distributed::Triangulation::load/save with different number of CPUs git-svn-id: https://svn.dealii.org/trunk@31508 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 6960664c7e..b4eab15de5 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -94,10 +94,17 @@ inconvenience this causes.
    +
  1. 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(). +
    + (Timo Heister, 2013/11/02) +
  2. +
  3. 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.
    - (Matthias Maier, 2013/11/1) + (Matthias Maier, 2013/11/01)
  4. Changed: step-9, step-13 and step-14 have been converted to use the diff --git a/deal.II/include/deal.II/distributed/tria.h b/deal.II/include/deal.II/distributed/tria.h index 7375a4bd29..5cac19d2de 100644 --- a/deal.II/include/deal.II/distributed/tria.h +++ b/deal.II/include/deal.II/distributed/tria.h @@ -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); diff --git a/deal.II/source/distributed/tria.cc b/deal.II/source/distributed/tria.cc index fae79cacfa..f61226ea89 100644 --- a/deal.II/source/distributed/tria.cc +++ b/deal.II/source/distributed/tria.cc @@ -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:: + partition (parallel_forest, + /* prepare coarsening */ 1, + /* weight_callback */ NULL); + + + } + try { copy_local_forest_to_triangulation ();