]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Bug fix for HDF5 output, now properly handles processors with 0 patches
authorheien <heien@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 21 Mar 2013 20:43:30 +0000 (20:43 +0000)
committerheien <heien@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 21 Mar 2013 20:43:30 +0000 (20:43 +0000)
git-svn-id: https://svn.dealii.org/trunk@28978 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/base/data_out_base.cc

index 6ce14e028e628f032a2236d6b4b44db9fc2ba2bd..ec51c103f8c4d7a518bfeec6af09b4a3ad9d14ef 100644 (file)
@@ -5934,6 +5934,22 @@ void DataOutBase::write_hdf5_parallel (const std::vector<Patch<dim,spacedim> > &
   (void)filename;
   (void)comm;
   AssertThrow(false, ExcMessage ("HDF5 support is disabled."));
+#else
+#ifndef DEAL_II_COMPILER_SUPPORTS_MPI
+  // verify that there are indeed
+  // patches to be written out. most
+  // of the times, people just forget 
+  // to call build_patches when there
+  // are no patches, so a warning is
+  // in order. that said, the
+  // assertion is disabled if we
+  // support MPI since then it can
+  // happen that on the coarsest
+  // mesh, a processor simply has no
+  // cells it actually owns, and in
+  // that case it is legit if there
+  // are no patches
+  Assert (patches.size() > 0, ExcNoPatches());
 #else
   hid_t           h5_file_id, plist_id;
   hid_t           node_dataspace, node_dataset, node_file_dataspace, node_memory_dataspace;
@@ -5943,6 +5959,11 @@ void DataOutBase::write_hdf5_parallel (const std::vector<Patch<dim,spacedim> > &
   unsigned int    local_node_cell_count[2], global_node_cell_count[2], global_node_cell_offsets[2];
   hsize_t         count[2], offset[2], node_ds_dim[2], cell_ds_dim[2];
   const unsigned int n_data_sets = data_names.size();
+  bool            empty_proc = false;
+  Table<2,double> data_vectors;
+  Threads::Task<> reorder_task;
+
+  if (patches.size() == 0) empty_proc = true;
 
   // If HDF5 is not parallel and we're using multiple processes, abort
 #ifndef H5_HAVE_PARALLEL
@@ -5954,11 +5975,15 @@ void DataOutBase::write_hdf5_parallel (const std::vector<Patch<dim,spacedim> > &
 #endif
 #endif
 
-  compute_sizes<dim,spacedim>(patches, local_node_cell_count[0], local_node_cell_count[1]);
+  if (empty_proc) {
+    local_node_cell_count[0] = local_node_cell_count[1] = 0;
+  } else {
+    compute_sizes<dim,spacedim>(patches, local_node_cell_count[0], local_node_cell_count[1]);
 
-  Table<2,double> data_vectors (n_data_sets, local_node_cell_count[0]);
-  void (*fun_ptr) (const std::vector<Patch<dim,spacedim> > &, Table<2,double> &) = &DataOutBase::template write_gmv_reorder_data_vectors<dim,spacedim>;
-  Threads::Task<> reorder_task = Threads::new_task (fun_ptr, patches, data_vectors);
+    data_vectors = Table<2,double> (n_data_sets, local_node_cell_count[0]);
+    void (*fun_ptr) (const std::vector<Patch<dim,spacedim> > &, Table<2,double> &) = &DataOutBase::template write_gmv_reorder_data_vectors<dim,spacedim>;
+    reorder_task = Threads::new_task (fun_ptr, patches, data_vectors);
+  }
 
   // Create file access properties
   plist_id = H5Pcreate(H5P_FILE_ACCESS);
@@ -6071,7 +6096,7 @@ void DataOutBase::write_hdf5_parallel (const std::vector<Patch<dim,spacedim> > &
   status = H5Dwrite(cell_dataset, H5T_NATIVE_UINT, cell_memory_dataspace, cell_file_dataspace, plist_id, hdf5_data.cell_data());
   AssertThrow(status >= 0, ExcIO());
 
-  reorder_task.join ();
+  if (!empty_proc) reorder_task.join ();
 
   // when writing, first write out
   // all vector data, then handle the
@@ -6155,7 +6180,7 @@ void DataOutBase::write_hdf5_parallel (const std::vector<Patch<dim,spacedim> > &
 
       // Write point data to the memory array
       r = 0;
-      for (i=0; i<local_node_cell_count[0]; ++i)
+      for (i=0; !empty_proc && i<local_node_cell_count[0]; ++i)
         {
           // Get the offset to the vector
           q = data_set;
@@ -6212,6 +6237,7 @@ void DataOutBase::write_hdf5_parallel (const std::vector<Patch<dim,spacedim> > &
   status = H5Fclose(h5_file_id);
   AssertThrow(status >= 0, ExcIO());
 #endif
+#endif
 }
 
 

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.