From: Timo Heister Date: Fri, 24 Jan 2014 15:47:40 +0000 (+0000) Subject: improve error checks and comments for parallel::distributed::Triangulation::load... X-Git-Tag: v8.2.0-rc1~969 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24d2b4011b12fa7191eb7a11d520a39a7dbaad0b;p=dealii.git improve error checks and comments for parallel::distributed::Triangulation::load/save git-svn-id: https://svn.dealii.org/trunk@32298 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/distributed/tria.h b/deal.II/include/deal.II/distributed/tria.h index ce0a862fb2..b00a01b224 100644 --- a/deal.II/include/deal.II/distributed/tria.h +++ b/deal.II/include/deal.II/distributed/tria.h @@ -514,17 +514,20 @@ namespace parallel * Save the refinement information from the coarse mesh into the given * file. This file needs to be reachable from all nodes in the computation * on a shared network file system. See the SolutionTransfer class - * on how to store solution vectors into this file. + * on how to store solution vectors into this file. Additional cell-based data can be saved + * using register_data_attach(). */ void save(const char *filename) const; /** * Load the refinement information saved with save() back in. The mesh - * must contain the same coarse mesh that was used in save(). You do not + * must contain the same coarse mesh that was used in save() before calling + * this function. You do not * need to load with the same number of MPI processes that you saved * with. Rather, if a mesh is loaded with a different number of MPI * processes than used at the time of saving, the mesh is repartitioned - * appropriately. + * appropriately. Cell-based data that was saved with register_data_attach() + * can be read in with notify_ready_to_unpack() after calling load(). */ void load(const char *filename); diff --git a/deal.II/source/distributed/tria.cc b/deal.II/source/distributed/tria.cc index 4149b6e9a1..45db88fa60 100644 --- a/deal.II/source/distributed/tria.cc +++ b/deal.II/source/distributed/tria.cc @@ -2046,13 +2046,19 @@ namespace parallel if (attached_data_size>0) real_data_size = attached_data_size+sizeof(CellStatus); + Assert(this->n_cells()>0, ExcMessage("Can not save() an empty Triangulation.")); + if (my_subdomain==0) { std::string fname=std::string(filename)+".info"; std::ofstream f(fname.c_str()); - f << Utilities::MPI::n_mpi_processes (mpi_communicator) << " " + f << "version nproc attached_bytes n_attached_objs n_coarse_cells" << std::endl + << 2 << " " + << Utilities::MPI::n_mpi_processes (mpi_communicator) << " " << real_data_size << " " - << attached_data_pack_callbacks.size() << std::endl; + << attached_data_pack_callbacks.size() << " " + << this->n_cells(0) + << std::endl; } if (attached_data_size>0) @@ -2082,6 +2088,10 @@ namespace parallel Triangulation:: load(const char *filename) { + Assert(this->n_cells()>0, ExcMessage("load() only works if Triangulation already contains the same coarse mesh!")); + Assert(this->n_levels()==1, ExcMessage("Triangulation may only contain coarse cells when calling load().")); + + if (parallel_ghost != 0) { dealii::internal::p4est::functions::ghost_destroy (parallel_ghost); @@ -2090,15 +2100,20 @@ namespace parallel dealii::internal::p4est::functions::destroy (parallel_forest); parallel_forest = 0; dealii::internal::p4est::functions::connectivity_destroy (connectivity); - connectivity=0; + connectivity = 0; - unsigned int numcpus, attached_size, attached_count; + unsigned int version, numcpus, attached_size, attached_count, n_coarse_cells; { std::string fname=std::string(filename)+".info"; std::ifstream f(fname.c_str()); - f >> numcpus >> attached_size >> attached_count; + std::string firstline; + getline(f, firstline); //skip first line + f >> version >> numcpus >> attached_size >> attached_count >> n_coarse_cells; } + Assert(version == 2, ExcMessage("Incompatible version found in .info file.")); + Assert(this->n_cells(0) == n_coarse_cells, ExcMessage("Number of coarse cells differ!")); + attached_data_size = 0; n_attached_datas = 0; n_attached_deserialize = attached_count;