Salome HOME
23288: [CEA 1626] Meshgems v2.3
[plugins/ghs3dprlplugin.git] / src / tepal2med / ghs3dprl_mesh_wrap.cxx
index 51dfbe927380013852794643e6359fcf2a6c56c1..33bc8efb58112023b17aed83038a2db14a8caa93 100755 (executable)
@@ -344,8 +344,8 @@ bool CVWtab::CVWtab_deallocate()
       memoryuse=memoryuse-sizeof(med_float)*size;
       size=-size; //precaution
    }
-   if (memoryuse<0) std::cout<<"***WARNING*** memoryuse <0 "<<memoryuse<<std::endl;
-   if (memoryuse==0) std::cout<<"***CVWtab_deallocate*** memoryuse=0 "<<std::endl;
+   if (memoryuse<0) std::cout<<"ERROR: on arrays deallocate memory use < 0 "<<memoryuse<<std::endl;
+   if (memoryuse==0) std::cout<<"WARNING: on arrays deallocate memory use = 0 "<<std::endl;
    return true;
 }
 
@@ -497,7 +497,7 @@ bool ghs3dprl_mesh_wrap::ReadFileMSGnew(const QString FileName)
       return false;
    }
 
-   //Lit les donns :
+   //Lit les donnees :
    if (!CVW_FindString("<neighbours count=",Ff,nbneighbour)) return false;
    if (verbose>2) std::cout<<"NeighboursCountDomain_"<<this->nofile<<"="<<nbneighbour<<std::endl;
    for (i=1; i<=nbneighbour; i++)
@@ -568,7 +568,7 @@ bool ghs3dprl_mesh_wrap::TestExistingFileMESHnew(const QString FileName)
       return false;
    }
 
-   //Lit les donns au debut du fichier, 1 lignes maxi:
+   //Lit les donnees au debut du fichier, 1 lignes maxi:
    maxline=1;
    if (!CVW_FindStringInFirstLines("MeshVersionFormatted",Ff,maxline)) return false;
    if (verbose>2) std::cout<<"MeshVersionFormatted_"<<this->nofile<<" ok"<<std::endl;
@@ -595,7 +595,7 @@ bool ghs3dprl_mesh_wrap::ReadFileGLO(const QString FileName)
       return false;
    }
 
-   //Lit les donns :
+   //Lit les donnees :
    if (!CVW_FindString("<vertices count=",Ff,count)) return false;
    if (verbose>3) std::cout<<"GloVerticesCount="<<count<<std::endl;
    if (count>0)
@@ -653,6 +653,95 @@ bool ghs3dprl_mesh_wrap::ReadFileGLO(const QString FileName)
    return true;
 }
 
+///************************************
+bool ghs3dprl_mesh_wrap::ReadFileGLOBAL(const QString FileName)
+//read file .global ascii (no xml)
+//first line: Vertices Edges Triangles Tetrahedra
+{
+   std::string line("                                            ");
+   QString tmp;
+   std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
+   long vert=0,edge=0,tria=0,tetr=0,count=0;
+   med_int *tmint;
+   CVWtab *montab;
+   bool ok;
+   
+   if (verbose>=6)std::cout<<"Read file '"<<FileName.toLatin1().constData()<<std::endl;
+   if (!Ff.is_open()){
+      std::cerr<<"Problem file '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
+      return false;
+   }
+   
+   //Lit les donnees :
+   Ff>>vert>>edge>>tria>>tetr;
+   std::cout<<"First line "<<vert<<" "<<edge<<" "<<tria<<" "<<tetr<<std::endl;
+   
+   if (vert<0)
+   {
+      std::cerr<<"Problem Vertices: a positive integer is expected"<<std::endl;
+      return false;
+   }
+
+   if (edge<0)
+   {
+      std::cerr<<"Problem Edges: a positive integer is expected"<<std::endl;
+      return false;
+   }
+
+   if (tria<0)
+   {
+      std::cerr<<"Problem Triangles: a positive integer is expected"<<std::endl;
+      return false;
+   }
+
+   if (tetr<0)
+   {
+      std::cerr<<"Problem Tetrahedra: a positive integer is expected"<<std::endl;
+      return false;
+   }
+
+   count=vert;
+   tmint=new med_int[count];
+   for (int i=0; i<count; i++) Ff>>tmint[i];
+   if (verbose>4) std::cout<<"Vertices ("<<count<<" ) "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
+
+   montab=new CVWtab(count,tmint);
+   tmp=tmp.sprintf("GL%ld VE",this->nofile);
+   ok=this->insert_key(tmp,montab);
+
+   count=edge;
+   tmint=new med_int[count];
+   for (int i=0; i<count; i++) Ff>>tmint[i];
+   if (verbose>4) std::cout<<"Edges ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
+
+   montab=new CVWtab(count,tmint);
+   tmp=tmp.sprintf("GL%ld ED",this->nofile);
+   ok=this->insert_key(tmp,montab);
+
+   count=tria;
+   tmint=new med_int[count];
+   for (int i=0; i<count; i++) Ff>>tmint[i];
+   if (verbose>4) std::cout<<"Triangles ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
+
+   montab=new CVWtab(count,tmint);
+   tmp=tmp.sprintf("GL%ld FA",this->nofile);
+   ok=this->insert_key(tmp,montab);
+
+   count=tetr;
+   tmint=new med_int[count];
+   for (int i=0; i<count; i++) Ff>>tmint[i];
+   if (verbose>4) std::cout<<"Tetrahedra ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
+
+   montab=new CVWtab(count,tmint);
+   tmp=tmp.sprintf("GL%ld EL",this->nofile);
+   ok=this->insert_key(tmp,montab);
+
+   //Ferme le fichier :
+   Ff.close();
+   this->nbfiles++;
+   return true;
+}
+
 //************************************
 bool ghs3dprl_mesh_wrap::ReadFileFACES(const QString FileName)
 //read file .faces (wrap)
@@ -669,8 +758,8 @@ bool ghs3dprl_mesh_wrap::ReadFileFACES(const QString FileName)
       return false;
    }
 
-   //Lit les donns :
-   //Replace le pointeur de fichier au dut :f.seekg(0);
+   //Lit les donnees :
+   //Replace le pointeur de fichier au debut :f.seekg(0);
    if (getline(Ff,line))
    {
       tmp=line.c_str();
@@ -712,13 +801,14 @@ bool ghs3dprl_mesh_wrap::ReadFileMESH(const QString FileName)
    std::string line("                                            ");
    QString tmp;
    std::fstream Ff(FileName.toLatin1().constData(),std::ios_base::in);
-   long Mversion=0,Mdim=0,Mvert=0,Mtria=0,Mtetra=0;
+   long Mversion=0,Mdim=0,Mvert=0,Mtria=0,Medge=0,Mtetra=0,count=0;
    med_int garbage;
-   //long ne,np,npfixe,subnumber,reste;
+   med_int *tmint;
    bool ok;
-   if (verbose>=6)std::cout<<"Read File '"<<FileName.toLatin1().constData()<<std::endl;
+   
+   if (verbose>=6)std::cout<<"Read file '"<<FileName.toLatin1().constData()<<std::endl;
    if (!Ff.is_open()){
-      std::cerr<<"Problem File '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
+      std::cerr<<"Problem file '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
       return false;
    }
 
@@ -761,29 +851,64 @@ bool ghs3dprl_mesh_wrap::ReadFileMESH(const QString FileName)
    }
    else
    {
-      std::cerr<<"Problem on line 6 of file: a positive integer is expected"<<std::endl;
+      std::cerr<<"Problem Vertices: a positive integer is expected"<<std::endl;
       return false;
    }
    if (Mvert<=0)
    {
-      std::cerr<<"Problem on line 6 of file: a positive integer is expected"<<std::endl;
+      std::cerr<<"Problem Vertices: a positive integer is expected"<<std::endl;
       return false;
    }
 
-   med_float *tmflo=new med_float[Mvert*3];
-   for (int i=0; i<Mvert*3; i=i+3) Ff>>tmflo[i]>>tmflo[i+1]>>tmflo[i+2]>>garbage;
-   if (verbose>4) std::cout<<"Vertices "<<tmflo[0]<<" "<<tmflo[1]<<"... "<<tmflo[Mvert*3-1]<<std::endl;
+   count=Mvert;
+   med_float *tmflo=new med_float[count*3];
+   for (int i=0; i<count*3; i=i+3) Ff>>tmflo[i]>>tmflo[i+1]>>tmflo[i+2]>>garbage;
+   if (verbose>4) std::cout<<"Vertices ("<<count<<") "<<tmflo[0]<<" "<<tmflo[1]<<"... "<<tmflo[count*3-1]<<std::endl;
 
-   CVWtab *montab=new CVWtab(Mvert*3,tmflo);
+   CVWtab *montab=new CVWtab(count*3,tmflo);
    tmp=tmp.sprintf("NB%ld VC",this->nofile);
    ok=this->insert_key(tmp,montab);
 
+   getline(Ff,line);
+   getline(Ff,line);
+   
+   if (!(getline(Ff,line) && (line.find("Edges")==0)))
+   {
+      std::cerr<<"Problem on line 'Edges' of file '"<<FileName.toLatin1().constData()<<"' :found '"<<line<<"' instead"<<std::endl;
+      return false;
+   }
+   if (getline(Ff,line))
+   {
+      tmp=line.c_str();
+      Medge=tmp.toLong(&ok);
+   }
+   else
+   {
+      std::cerr<<"Problem on line 'Edges' of file: a positive integer is expected"<<std::endl;
+      return false;
+   }
+   if (Medge<=0)
+   {
+      std::cerr<<"Problem on line 'Edges' of file: a positive integer is expected"<<std::endl;
+      return false;
+   }
+
+   count=Medge;
+   tmint=new med_int[count*2]; //*3
+   for (int i=0; i<count*2; i=i+2) {
+     Ff>>tmint[i]>>tmint[i+1]>>garbage;
+   }
+   if (verbose>4) std::cout<<"Edges ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count*2-1]<<std::endl;
+   montab=new CVWtab(count*2,tmint);
+   tmp=tmp.sprintf("NB%ld ED",this->nofile); //TODO see if it could serve
+   ok=this->insert_key(tmp,montab);
+   
    getline(Ff,line);
    getline(Ff,line);
 
    if (!(getline(Ff,line) && (line.find("Triangles")==0)))
    {
-      std::cerr<<"Problem on line 'Triangles' of file: not found"<<line<<std::endl;
+      std::cerr<<"Problem on line 'Triangles' of file '"<<FileName.toLatin1().constData()<<"' :found '"<<line<<"' instead"<<std::endl;
       return false;
    }
    if (getline(Ff,line))
@@ -802,19 +927,16 @@ bool ghs3dprl_mesh_wrap::ReadFileMESH(const QString FileName)
       return false;
    }
 
-   med_int *tmint=new med_int[Mtria*7]; //*7 as older files .faces
-   for (int i=0; i<Mtria*7; i=i+7) {
+   count=Mtria;
+   tmint=new med_int[count*3]; //*7 as older files .faces, obsolete
+   for (int i=0; i<count*3; i=i+3) {
      Ff>>tmint[i]>>tmint[i+1]>>tmint[i+2]>>garbage;
-     tmint[i+3]=0;
-     tmint[i+4]=0;
-     tmint[i+5]=0;
-     tmint[i+6]=0;
    }
-   if (verbose>4) std::cout<<"Triangles "<<tmint[0]<<" "<<tmint[1]<<"... "<<
-       tmint[Mtria*7-5]<<" "<<tmint[Mtria*7-4]<<" "<<tmint[Mtria*7-3]<<" "<<
-      tmint[Mtria*7-2]<<" "<<tmint[Mtria*7-1]<<std::endl;
+   if (verbose>4) std::cout<<"Triangles ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<
+       tmint[count*3-5]<<" "<<tmint[count*3-4]<<" "<<tmint[count*3-3]<<" "<<
+       tmint[count*3-2]<<" "<<tmint[count*3-1]<<std::endl;
 
-   montab=new CVWtab(Mtria*7,tmint);
+   montab=new CVWtab(count*3,tmint);
    tmp=tmp.sprintf("FC%ld",this->nofile);
    ok=this->insert_key(tmp,montab);
    
@@ -847,15 +969,17 @@ bool ghs3dprl_mesh_wrap::ReadFileMESH(const QString FileName)
       std::cout<<"MeshVersionFormatted="<<Mversion<<std::endl;
       std::cout<<"MeshDimension="<<Mdim<<std::endl;
       std::cout<<"MeshNumberOfVertices="<<Mvert<<std::endl;
+      std::cout<<"MeshNumberOfEdges="<<Medge<<std::endl;
       std::cout<<"MeshNumberOfTriangles="<<Mtria<<std::endl;
       std::cout<<"MeshNumberOfTetrahedra="<<Mtetra<<std::endl;
    }
 
-   tmint=new med_int[Mtetra*4];
-   for (int i=0; i<Mtetra*4; i=i+4) Ff>>tmint[i]>>tmint[i+1]>>tmint[i+2]>>tmint[i+3]>>garbage;
-   if (verbose>4) std::cout<<"Tetrahedra "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[Mtetra*4-1]<<std::endl;
+   count=Mtetra;
+   tmint=new med_int[count*4];
+   for (int i=0; i<count*4; i=i+4) Ff>>tmint[i]>>tmint[i+1]>>tmint[i+2]>>tmint[i+3]>>garbage;
+   if (verbose>4) std::cout<<"Tetrahedra ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count*4-1]<<std::endl;
 
-   montab=new CVWtab(Mtetra*4,tmint);
+   montab=new CVWtab(count*4,tmint);
    tmp=tmp.sprintf("NB%ld EV",this->nofile);
    ok=this->insert_key(tmp,montab);
 
@@ -886,7 +1010,7 @@ bool ghs3dprl_mesh_wrap::ReadFileNOBOITE(const QString FileName)
       return false;
    }
 
-   //lit les donns :
+   //lit les donnees :
    Ff>>ne>>np>>npfixe;
    if (verbose>3){
       std::cout<<"NoboiteNumberOfElements="<<ne<<std::endl;
@@ -1057,7 +1181,7 @@ bool ghs3dprl_mesh_wrap::ReadFilePOINTS(const QString FileName)
    long maxlen=128;
    bool ok=true;
 
-   //Lit les donns :
+   //Lit les donnees :
    QFile Ff(FileName);
    //NOT Raw because Raw=non-buffered file access
    //qt3 ok=Ff.open(IO_ReadOnly|IO_Translate);
@@ -1250,7 +1374,7 @@ bool ghs3dprl_mesh_wrap::list_onekey_mesh_wrap(const QString &key)
 
 //************************************
 bool ghs3dprl_mesh_wrap::insert_key(const QString &key,CVWtab *tab)
-//insertion conditionn par limite this->nbelem_limit_swap
+//insertion conditionnee par limite this->nbelem_limit_swap
 //si tableaux contenus on dimension superieure
 //alors swap disque dans getenv(tmp) fichier temporaire binaire
 {
@@ -1269,7 +1393,7 @@ bool ghs3dprl_mesh_wrap::insert_key(const QString &key,CVWtab *tab)
 }
 //************************************
 CVWtab* ghs3dprl_mesh_wrap::restore_key(const QString &key)
-//retauration conditionn par limite nbelem
+//retauration conditionnee par limite nbelem
 //si tableaux contenus on dimension superieure a nbelem
 //alors swap disque dans getenv(tmp) fichier temporaire
 //alors lecture du fichier (et reallocate memory)
@@ -1793,13 +1917,18 @@ bool ghs3dprl_mesh_wrap::Write_MEDfiles_v2(bool deletekeys)
    else if (verbose>3) std::cout<<"--deletegroups matches \"New_Tetrahedra\"\n";
 
    if (verbose>6){std::cout<<"\nIntermediatesFamilies\n"; families.write();}
-   if (verbose>6) std::cout<<"\nNumber0fFiles="<<nbfilestot<<std::endl;
+   //if (verbose>6) std::cout<<"\nNumber0fFiles="<<nbfilestot<<std::endl;
    familles intermediatesfamilies=families;
    //initialisations on all domains
    nbtetrastotal=0;
 
    //loop on the domains
    //for (idom=1; idom<=nbfilestot; idom++) {
+   if (for_multithread) {
+     nbfilestot=1;
+     std::cout<<"\nset Number0fFiles as multithread="<<nbfilestot<<std::endl;
+   }
+   if (verbose>6) std::cout<<"\nNumber0fFiles="<<nbfilestot<<std::endl;
    for (idom=1; idom<=nbfilestot; idom++) {
    
       this->nofile=idom;
@@ -1828,44 +1957,51 @@ bool ghs3dprl_mesh_wrap::Write_MEDfiles_v2(bool deletekeys)
       if (err<0) {std::cerr<<"Problem MEDmeshCr"<<nomfinal<<std::endl; goto erreur;}
 
       if (!idom_nodes()) {std::cerr<<"Problem on Nodes"<<std::endl; goto erreur;}
+      if (verbose>4) std::cout<<"\nEnd of Nodes ***\n"<<std::endl;
       if (!idom_edges()) {std::cerr<<"Problem on Edges"<<std::endl; goto erreur;}
+      if (verbose>4) std::cout<<"\nEnd of Edges ***\n"<<std::endl;
       if (!idom_faces()) {std::cerr<<"Problem on Faces"<<std::endl; goto erreur;}
+      if (verbose>4) std::cout<<"\nEnd of Faces ***\n"<<std::endl;
       if (!idom_tetras()) {std::cerr<<"Problem on tetrahedra"<<std::endl; goto erreur;}
-      if (!idom_joints()) {std::cerr<<"Problem on Joints"<<std::endl; goto erreur;}
-
-      if (verbose>6){std::cout<<"\nFinalsFamilies\n"; families.write();}
-      //for nodes families
-      nb=create_families(fid,1);
-      if (verbose>5)std::cout<<"NumberOfFamiliesNodes="<<nb<<std::endl;
-
-      err=MEDmeshEntityFamilyNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nbnodes,famnodes);
-      if (verbose>8)
-         std::cout<<"MEDmeshEntityFamilyNumberWr nodes "<<nbnodes<<":"<<
-               famnodes[0]<<"..."<<famnodes[nbnodes-1]<<" "<<std::endl;
-      delete[] famnodes;
-      if (err<0) std::cerr<<"Problem MEDmeshEntityFamilyNumberWr nodes"<<std::endl;
-
-      //for others families
-      nb=create_families(fid,-1);
-      if (verbose>5)std::cout<<"NumberOfFamiliesFacesAndEdgesEtc="<<nb<<std::endl;
-
-      err=MEDmeshEntityFamilyNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TRIA3,nbtria3,famtria3);
-      if (verbose>8)
-         std::cout<<"MEDmeshEntityFamilyNumberWr tria3 "<<nbtria3<<":"<<
-               famtria3[0]<<"..."<<famtria3[nbtria3-1]<<" "<<std::endl;
-      delete[] famtria3;
-      if (err<0) std::cerr<<"Problem MEDmeshEntityFamilyNumberWr tria3"<<std::endl;
-
-      err=MEDmeshEntityFamilyNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TETRA4,nbtetra4,famtetra4);
-      if (verbose>8)
-         std::cout<<"MEDmeshEntityFamilyNumberWr tetra4 "<<nbtetra4<<":"<<
-               famtetra4[0]<<"..."<<famtetra4[nbtria3-1]<<" "<<std::endl;
-      delete[] famtetra4;
-      if (err<0) std::cerr<<"Problem MEDmeshEntityFamilyNumberWr tria3"<<std::endl;
-
+      if (verbose>4) std::cout<<"\nEnd of Tetrahedra ***\n"<<std::endl;
+      //non existing files msg mh-tetra_hpc v2.1.11
+      //if (!idom_joints()) {std::cerr<<"Problem on Joints"<<std::endl; goto erreur;}
+
+      if (!for_multithread) {
+        if (verbose>6){std::cout<<"\nFinalsFamilies\n"; families.write();}
+        //for nodes families
+        nb=create_families(fid,1);
+        if (verbose>5)std::cout<<"NumberOfFamiliesNodes="<<nb<<std::endl;
+
+        err=MEDmeshEntityFamilyNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nbnodes,famnodes);
+        if (verbose>8)
+          std::cout<<"MEDmeshEntityFamilyNumberWr nodes "<<nbnodes<<":"<<
+                famnodes[0]<<"..."<<famnodes[nbnodes-1]<<" "<<std::endl;
+        delete[] famnodes;
+        if (err<0) std::cerr<<"Problem MEDmeshEntityFamilyNumberWr nodes"<<std::endl;
+
+        //for others families
+        nb=create_families(fid,-1);
+        if (verbose>5)std::cout<<"NumberOfFamiliesFacesAndEdgesEtc="<<nb<<std::endl;
+
+        err=MEDmeshEntityFamilyNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TRIA3,nbtria3,famtria3);
+        if (verbose>8)
+          std::cout<<"MEDmeshEntityFamilyNumberWr tria3 "<<nbtria3<<":"<<
+                famtria3[0]<<"..."<<famtria3[nbtria3-1]<<" "<<std::endl;
+        delete[] famtria3;
+        if (err<0) std::cerr<<"Problem MEDmeshEntityFamilyNumberWr tria3"<<std::endl;
+
+        err=MEDmeshEntityFamilyNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TETRA4,nbtetra4,famtetra4);
+        if (verbose>8)
+          std::cout<<"MEDmeshEntityFamilyNumberWr tetra4 "<<nbtetra4<<":"<<
+                famtetra4[0]<<"..."<<famtetra4[nbtria3-1]<<" "<<std::endl;
+        delete[] famtetra4;
+        if (err<0) std::cerr<<"Problem MEDmeshEntityFamilyNumberWr tria3"<<std::endl;
+      }
+    
       MEDfileClose(fid); //no error
       //master.xml writings
-      oktmp=Write_masterxmlMEDfile();
+      //oktmp=Write_masterxmlMEDfile();
       continue;       //and loop on others domains
 
       erreur:         //error
@@ -1876,7 +2012,8 @@ bool ghs3dprl_mesh_wrap::Write_MEDfiles_v2(bool deletekeys)
    
    MEDfileClose(fidjoint); //no error
    if (verbose>0)std::cout<<"\nTotalNumberOftetrahedra="<<nbtetrastotal<<std::endl;
-
+   ok = true;
+   
    return ok;
 }
 
@@ -1899,7 +2036,7 @@ bool ghs3dprl_mesh_wrap::idom_nodes()
             ok=this->ReadFileNOBOITE(tmp);
          }
          if (for_tetrahpc) {
-            tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".mesh";
+            tmp=pathini+casename+"_out"+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".mesh";
             ok=this->ReadFileMESH(tmp);
          }
          tab=this->restore_key(key); //tab1=this->mestab[key1];
@@ -1911,7 +2048,7 @@ bool ghs3dprl_mesh_wrap::idom_nodes()
       nbnodes=tab->size/3;
       err=MEDmeshNodeCoordinateWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_FULL_INTERLACE,nbnodes,tab->tmflo);
       if (err<0) {std::cerr<<"Problem MEDmeshNodeCoordinateWr"<<std::endl; return false;}
-      if (verbose>4)std::cout<<"NumberOfNodes="<<nbnodes<<std::endl;
+      if (verbose>4) std::cout<<"NumberOfNodes="<<nbnodes<<std::endl;
 
       //writing indices of nodes
       arrayi=new med_int[nbnodes];
@@ -1920,6 +2057,7 @@ bool ghs3dprl_mesh_wrap::idom_nodes()
       delete[] arrayi;
       if (err<0) {std::cerr<<"Problem MEDmeshEntityNumberWr of nodes"<<std::endl; return false;}
 
+    if (!for_multithread) {
       key1=key1.sprintf("GL%d VE",idom); //global numerotation 
       tab1=this->restore_key(key1); //tab1=this->mestab[key1];
       if (!tab1) {
@@ -1928,8 +2066,8 @@ bool ghs3dprl_mesh_wrap::idom_nodes()
             ok=this->ReadFileGLO(tmp);
          }
          if (for_tetrahpc) {
-            tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".glo";
-            ok=this->ReadFileGLO(tmp);
+            tmp=pathini+casename+"_out"+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".global";
+            ok=this->ReadFileGLOBAL(tmp);
          }
          if (!ok) {std::cerr<<"Problem file "<<tmp.toLatin1().constData()<<std::endl; return false;}
          tab1=this->restore_key(key1); //tab1=this->mestab[key1];
@@ -1967,7 +2105,8 @@ bool ghs3dprl_mesh_wrap::idom_nodes()
       //writing nodes(vertices) global numbering
       err=MEDmeshGlobalNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nbnodes,tab1->tmint);
       if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr nodes"<<std::endl; return false;}
-
+    }
+    
    return ok;
 }
 
@@ -2088,18 +2227,19 @@ bool ghs3dprl_mesh_wrap::idom_faces()
          tab1=this->restore_key(key1);
          if (!tab1) return false;
       }
-      nbtria3=tab1->size/7;
+      nbtria3=tab1->size/3;
       if (verbose>4) std::cout<<"NumberOfTriangles="<<nbtria3<<std::endl;
-      arrayi=new med_int[nbtria3*3];
-      ii=0,i=0 ;
-      for (j=0; j<nbtria3 ; j++){
-         arrayi[ii]=tab1->tmint[i]; ii++;
-         arrayi[ii]=tab1->tmint[i+1]; ii++;
-         arrayi[ii]=tab1->tmint[i+2]; ii++;
-         i=i+7;
-      }
-      err=MEDmeshElementConnectivityWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_TRIA3,MED_NODAL,MED_FULL_INTERLACE,nbtria3,arrayi);
-      delete[] arrayi; //need immediately more little array
+      //arrayi=new med_int[nbtria3*3];
+      //ii=0,i=0 ;
+      //for (j=0; j<nbtria3 ; j++){
+      //   arrayi[ii]=tab1->tmint[i]; ii++;
+      //   arrayi[ii]=tab1->tmint[i+1]; ii++;
+      //   arrayi[ii]=tab1->tmint[i+2]; ii++;
+      //   i=i+7;
+      //}
+      //err=MEDmeshElementConnectivityWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_TRIA3,MED_NODAL,MED_FULL_INTERLACE,nbtria3,arrayi);
+      err=MEDmeshElementConnectivityWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_TRIA3,MED_NODAL,MED_FULL_INTERLACE,nbtria3,tab1->tmint);
+      //delete[] arrayi; //need immediately more little array
       if (err<0){std::cerr<<"Problem MEDmeshElementConnectivityWr for triangles connectivity"<<std::endl; return false;}
       
       //writing indices of faces triangles of wrap
@@ -2113,45 +2253,48 @@ bool ghs3dprl_mesh_wrap::idom_faces()
       if (err<0){std::cerr<<"Problem MEDmeshEntityNumberWr of triangles"<<std::endl; return false;}
 
       //GLx FA=files.GLo FAces
-      key1=key1.sprintf("GL%d FA",idom);
-      tab1=this->restore_key(key1); //tab1=this->mestab[key1];
-      if (nbtria3!=tab1->size){std::cerr<<"Problem size GLi FA!=nbtria3!"<<std::endl; return false;}
-
-      key2=key2.sprintf("SKIN_TRIA3_FAMILIES",idom); //on global numerotation 
-      tab2=this->restore_key(key2); //tab1=this->mestab[key1];
-      med_int nbskin=0; 
-      if (tab2) nbskin=tab2->size;
+      if (!for_multithread) {
+        key1=key1.sprintf("GL%d FA",idom);
+        tab1=this->restore_key(key1); //tab1=this->mestab[key1];
+        if (nbtria3!=tab1->size){std::cerr<<"Problem size GLi FA!=nbtria3!"<<std::endl; return false;}
       
-      //set families of faces existing in GHS3DPRL_skin.med
-      med_int nb=nbtria3;
-      famtria3=new med_int[nb];
-      for (i=0; i<nb ; i++) famtria3[i]=famalltria3;
-      med_int * fammore=new med_int[nb];
-      for (i=0; i<nb ; i++) fammore[i]=famnewtria3;
-
-      //set families of faces of skin
-      for (i=0; i<nb ; i++){
-         j=tab1->tmint[i]-1; //
-         if (j<nbskin){
-            fammore[i]=tab2->tmint[j];
-         }
-      }
-      ok=set_one_more_family(famtria3,fammore,nb);
-      delete[] fammore;
       
-      //writing faces(triangles) global numbering
-      if (verbose>2)
-         std::cout<<"CreateMEDglobalNumerotation_Faces "<<key1.toLatin1().constData()<<" "<<tab1->size<<std::endl;
-      err=MEDmeshGlobalNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TRIA3,tab1->size,tab1->tmint);
-      if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr faces"<<std::endl; return false;}
-
-      //xx=this->remove_key_mesh_wrap(QRegExp("FC*",true,true));
-      tmp=tmp.sprintf("GL%d FA",idom);
-      //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
-      xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
-      tmp=tmp.sprintf("GL%d VE",idom);
-      //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
-      xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
+        key2=key2.sprintf("SKIN_TRIA3_FAMILIES",idom); //on global numerotation 
+        tab2=this->restore_key(key2); //tab1=this->mestab[key1];
+        med_int nbskin=0; 
+        if (tab2) nbskin=tab2->size;
+        
+        //set families of faces existing in GHS3DPRL_skin.med
+        med_int nb=nbtria3;
+        famtria3=new med_int[nb];
+        for (i=0; i<nb ; i++) famtria3[i]=famalltria3;
+        med_int * fammore=new med_int[nb];
+        for (i=0; i<nb ; i++) fammore[i]=famnewtria3;
+
+        //set families of faces of skin
+        for (i=0; i<nb ; i++){
+          j=tab1->tmint[i]-1; //
+          if (j<nbskin){
+              fammore[i]=tab2->tmint[j];
+          }
+        }
+        ok=set_one_more_family(famtria3,fammore,nb);
+        delete[] fammore;
+        
+        //writing faces(triangles) global numbering
+        if (verbose>2)
+          std::cout<<"CreateMEDglobalNumerotation_Faces "<<key1.toLatin1().constData()<<" "<<tab1->size<<std::endl;
+        err=MEDmeshGlobalNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TRIA3,tab1->size,tab1->tmint);
+        if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr faces"<<std::endl; return false;}
+
+        //xx=this->remove_key_mesh_wrap(QRegExp("FC*",true,true));
+        tmp=tmp.sprintf("GL%d FA",idom);
+        //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
+        xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
+        tmp=tmp.sprintf("GL%d VE",idom);
+        //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
+        xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
+      }
 
    return ok;
 }
@@ -2471,23 +2614,37 @@ bool ghs3dprl_mesh_wrap::idom_tetras()
       famtetra4=new med_int[nbtetra4];
       for (i=0; i<nbtetra4 ; i++) famtetra4[i]=famnewtetra4;
 
-      //writing tetrahedra global numbering
-      //GLx EL=files.GLo ELements
-      key1=key1.sprintf("GL%d EL",idom);
-      tab1=this->restore_key(key1); //tab1=this->mestab[key1];
-      if (!tab1) {
-         tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".glo";
-         ok=this->ReadFileGLO(tmp);
-         tab1=this->restore_key(key1);
-         if (!tab1) return false;
-      }
+      if (!for_multithread) {
+        //writing tetrahedra global numbering
+        //GLx EL=files.GLo ELements
+        key1=key1.sprintf("GL%d EL",idom);
+        tab1=this->restore_key(key1); //tab1=this->mestab[key1];
+        if (!tab1) {
+          //tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".glo";
+          //ok=this->ReadFileGLO(tmp);
+          //tab1=this->restore_key(key1);
+          //if (!tab1) return false;
+
+          if (!for_tetrahpc) {
+              tmp=pathini+casename+tmp.sprintf(format.toLatin1().constData(),nbfilestot,idom)+".glo";
+              ok=this->ReadFileGLO(tmp);
+          }
+          if (for_tetrahpc) {
+              tmp=pathini+casename+"_out"+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".global";
+              ok=this->ReadFileGLOBAL(tmp);
+          }
+          tab1=this->restore_key(key1);
+          if (!tab1) return false;
 
-      if (tab1->size!=nbtetra4){
-         std::cerr<<"Problem incorrect size of tetrahedra global numbering"<<std::endl; return false;}
-      if (verbose>2)
-         std::cout<<"CreateMEDglobalNumerotation_tetrahedra "<<key1.toLatin1().constData()<<" "<<tab1->size<<std::endl;
-      err=MEDmeshGlobalNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TETRA4,tab1->size,tab1->tmint);
-      if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr tetrahedra"<<std::endl; return false;}
+        }
+
+        if (tab1->size!=nbtetra4){
+          std::cerr<<"Problem incorrect size of tetrahedra global numbering"<<std::endl; return false;}
+        if (verbose>2)
+          std::cout<<"CreateMEDglobalNumerotation_tetrahedra "<<key1.toLatin1().constData()<<" "<<tab1->size<<std::endl;
+        err=MEDmeshGlobalNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TETRA4,tab1->size,tab1->tmint);
+        if (err<0){std::cerr<<"Problem MEDmeshGlobalNumberWr tetrahedra"<<std::endl; return false;}
+      }
 
       tmp=tmp.sprintf("NB%d EV",idom);
       //qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));