From e4291173cbfa02b765969bd200e76834ef3937db Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sat, 9 Jan 2010 19:11:16 +0000
Subject: [PATCH] polish split-file IO

---
 Geo/GModelIO_Mesh.cpp | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/Geo/GModelIO_Mesh.cpp b/Geo/GModelIO_Mesh.cpp
index e24524e8c3..7fb5b4b280 100644
--- a/Geo/GModelIO_Mesh.cpp
+++ b/Geo/GModelIO_Mesh.cpp
@@ -586,6 +586,12 @@ int GModel::writeMSH(const std::string &name, double version, bool binary,
     return 0;
   }
 
+  // binary format exists only in version 2
+  if(version > 1 || binary) 
+    version = 2.2;
+  else
+    version = 1.0;
+
   // if there are no physicals we save all the elements
   if(noPhysicalGroups()) saveAll = true;
 
@@ -593,15 +599,6 @@ int GModel::writeMSH(const std::string &name, double version, bool binary,
   // sequence
   int numVertices = indexMeshVertices(saveAll, saveSinglePartition);
 
-  // FIXME if saveSinglePartition, re-tag some nodes with '0' index
-  // and recompute numVertices
-  
-  // binary format exists only in version 2
-  if(version > 1 || binary) 
-    version = 2.2;
-  else
-    version = 1.0;
-  
   // get the number of elements we need to save
   int numElements = getNumElementsMSH(this, saveAll, saveSinglePartition);
 
@@ -616,13 +613,6 @@ int GModel::writeMSH(const std::string &name, double version, bool binary,
       if((*it)->polyhedra[i]->ownsParent())
         parents[1][(*it)->polyhedra[i]->getParent()] = (*it);
 
-  // get ghost cells
-  std::multimap<MElement*, int> ghostCells;
-  if(saveSinglePartition && getGhostCells().size()){
-    // XXXX
-    numElements += ghostCells.size();    
-  }
-
   if(version >= 2.0){
     fprintf(fp, "$MeshFormat\n");
     fprintf(fp, "%g %d %d\n", version, binary ? 1 : 0, (int)sizeof(double));
@@ -818,7 +808,7 @@ int GModel::writePartitionedMSH(const std::string &baseName, bool binary,
     index++;
   }
 
-#if 1
+#if 0
   if(_ghostCells.size()){
     Msg::Info("Writing ghost cells in debug file 'ghosts.pos'");
     FILE *fp = fopen("ghosts.pos", "w");
-- 
GitLab