From ac242d4d17c9f0e3f755599aec7905fbb68af5f2 Mon Sep 17 00:00:00 2001
From: Gaetan Bricteux <gaetan.bricteux@uclouvain.be>
Date: Mon, 18 Oct 2010 12:15:10 +0000
Subject: [PATCH] fix parent printing with multiple physicals

---
 Geo/GModelIO_Mesh.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/Geo/GModelIO_Mesh.cpp b/Geo/GModelIO_Mesh.cpp
index 4ae9b44f44..88dcc72821 100644
--- a/Geo/GModelIO_Mesh.cpp
+++ b/Geo/GModelIO_Mesh.cpp
@@ -594,10 +594,14 @@ static void writeElementMSH(FILE *fp, GModel *model, T *ele, bool saveAll,
   if(saveAll)
     ele->writeMSH(fp, version, binary, ++num, elementary, 0,
                   parentNum, dom1Num, dom2Num, &ghosts);
-  else
-    for(unsigned int j = 0; j < physicals.size(); j++)
+  else{
+    if(parentNum) parentNum = parentNum - physicals.size() + 1;
+    for(unsigned int j = 0; j < physicals.size(); j++){
       ele->writeMSH(fp, version, binary, ++num, elementary, physicals[j],
                     parentNum, dom1Num, dom2Num, &ghosts);
+      if(parentNum) parentNum++;
+    }
+  }
 
   model->setMeshElementIndex(ele, num); // should really be a multimap...
 }
-- 
GitLab