Salome HOME
Copyright update 2020
[plugins/ghs3dprlplugin.git] / src / tepal2med / tetrahpc2med.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 9d6d49c..5a47586
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2020  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -45,7 +45,7 @@
 #include <QApplication>
 
 #include "ghs3dprl_msg_parser.h"
-#include "dlg_ghs3dmain.h"
+//#include "dlg_ghs3dmain.h"
 
 #ifdef WIN32
 #include <io.h>
@@ -90,7 +90,7 @@ med_idt ouvre_fichier_MED(char *fichier,int verbose)
   if (ret < 0) return fid;
 
   MEDfileNumVersionRd(fid, &majeur, &mineur, &release);
-  if (majeur < 2 || majeur == 2 && mineur < 2) {
+  if (( majeur < 2 ) || ( majeur == 2 && mineur < 2 )) {
     fprintf(stderr,"File %s from MED V%d.%d.%d not assumed\n",
                    fichier,majeur,mineur,release);
     //" version est ant�ieure �la version 2.2";
@@ -107,7 +107,7 @@ bool ReadFileMED(QString nomfilemed,ghs3dprl_mesh_wrap *mymailw)
 {
    med_err ret;
    med_idt fid=0;
-   med_int i,j,sdim,mdim,nmaa,edim,majeur_lu,mineur_lu,release_lu,nprofils,nstep;
+   med_int i,j,sdim,mdim,nmaa,/*edim,majeur_lu,mineur_lu,release_lu,nprofils,*/nstep;
    med_mesh_type type_maillage;
    char dtunit[MED_SNAME_SIZE+1];
    char axisname[MED_SNAME_SIZE+1];
@@ -174,14 +174,14 @@ bool ReadFileMED(QString nomfilemed,ghs3dprl_mesh_wrap *mymailw)
    }
 
    //nombre d'objets MED : mailles, faces, aretes , ... 
-   med_int nmailles[MED_N_CELL_GEO],nbtria3;
-   med_int nfaces[MED_N_FACE_GEO];
-   med_int naretes[MED_N_EDGE_FIXED_GEO],nbseg2;
+   med_int /*nmailles[MED_N_CELL_GEO],*/nbtria3;
+   //med_int nfaces[MED_N_FACE_GEO];
+   med_int /*naretes[MED_N_EDGE_FIXED_GEO],*/nbseg2;
    //med_int nmailles[MED_NBR_GEOMETRIE_MAILLE],nbtria3;
    //med_int nfaces[MED_NBR_GEOMETRIE_FACE];
    //med_int naretes[MED_NBR_GEOMETRIE_ARETE],nbseg2;
    //polygones et polyedres familles equivalences joints
-   med_int nmpolygones,npolyedres,nfpolygones,nfam,nequ,njnt;
+   med_int /*nmpolygones,npolyedres,nfpolygones,*/nfam/*,nequ,njnt*/;
 
    //Combien de mailles, faces ou aretes pour chaque type geometrique ?
    /*for (i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++){
@@ -216,7 +216,7 @@ std::vector<med_int> famdelete = std::vector<med_int>(nfam);
   char *gro;
   char nomfam[MED_NAME_SIZE+1];
   med_int numfam;
-  char str1[MED_COMMENT_SIZE+1];
+  //char str1[MED_COMMENT_SIZE+1];
   char str2[MED_LNAME_SIZE+1];
   med_err ret = 0;
   
@@ -468,17 +468,196 @@ if (mymailw->verbose>3){
    return true;
 }
 
+/*
+mg-tetra_hpc_mpi.exe --help
+
+    =============================================
+    MG-Tetra_HPC -- MeshGems 2.9-6 (August, 2019)
+    =============================================
+
+        Distene SAS
+           Campus Teratec
+           2, rue de la Piquetterie
+           91680 Bruyeres le Chatel
+           FRANCE
+        Phone: +33(0)970-650-219   Fax: +33(0)169-269-033
+        EMail: <support@distene.com>
+
+        Running MG-Tetra_HPC (Copyright 2014-2019 by Distene SAS)
+           date of run: 25-Feb-2020 AT 08:47:20
+           running on : Linux 3.10.0-1062.9.1.el7.x86_64 x86_64
+           using modules: 
+                MeshGems-Core 2.9-6
+
+        MeshGems is a Registered Trademark of Distene SAS
+
+
+
+Usage: tetra_hpc_mpi.exe [options]
+
+Options: 
+
+     Short option (if it exists)
+    /    Long option
+   |    /   Description
+   |   |   /
+   v   v  v
+
+     --components <components>
+          Selects which mesh components to process.
+          If <components> is:
+              all : all components are to be meshed.
+              outside_components : only the main (outermost) component is to be
+          meshed.
+                    Default: all
+
+     --gradation <g>
+          Sets the size gradation value.
+          <gradation> is the desired maximum ratio between 2 adjacent
+          tetrahedron edges. The closer it is to 1.0, the more uniform the mesh
+          will be.
+          Default: 1.05
+
+     --gradation_mode <mode>
+          Sets the gradation behaviour.
+          Possible values for <mode> are :
+              without_size: apply gradation only when no size is provided by
+          the input sizemap(s)
+              always: always apply the gradation. This can partially smooth the
+          provided input sizemap(s)
+          Default: without_size
+
+     --help
+          Prints this help.
+
+     --in <input mesh file name>
+          Sets the input file.
+          (MANDATORY)
+
+     --max_edge_length <maximum edge length>
+          Sets the desired maximum accepted edge length.
+          Default: 0 (no maximum length).
+
+     --max_size <maximum size>
+          Sets the desired maximum cell size value.
+          Default: 0 (no maximum size).
+
+     --metric <type>
+          Sets the type of metric governing the mesh generation.
+          Possible values for <type> are :
+              isotropic: the metric induces the same size in all directions.
+              anisotropic: the metric induces different sizes depending on the
+          directions.
+          Default: isotropic
+
+     --min_edge_length <minimum edge length>
+          Sets the desired minimum accepted edge length.
+          Default: 0 (no minimum length).
+
+     --min_size <minimum size>
+          Sets the desired minimum cell size value.
+          Default: 0 (no minimum size).
+
+     --optimisation <boolean>
+          Sets whether to optimise mesh quality or not.
+          Default: yes.
+
+     --optimisation_level <level>
+          Sets the desired optimisation level for mesh quality.
+          Possible values for <level> are (in increasing order of quality vs
+          speed ratio): light, standard, strong
+          Default: standard.
+
+     --out <output mesh file name>
+          Sets the output file.
+          Using an existing file is not allowed.
+          Using the same file as --in is not allowed.
+          If unset, _tetra_hpc is appended to the input file basename.
+          
+     --parallel_strategy <strategy>
+          Sets the desired parallel strategy, influencing the level of
+          reproducibility of the result and the potential performances.
+          Possible values for <strategy> are (in decreasing order for
+          reproducibility and increasing order for performances):
+              reproducible: result is entirely reproducible but performances
+          may not be optimal.
+              aggressive: result may not be reproducible but all parallel
+          optimizations are allowed.
+          Default: reproducible.
+
+     --sizemap <input sizemap file name>
+          Sets the optional input sizemap file. The sizemap must provide the
+          requested size at the input surface or volume mesh vertices.
+                    Default : none.
+
+     --split_overconstrained_edges <boolean>
+          Sets whether to split over-constrained edges or not. An edge is
+          considered as over-constrained when its two vertices belong to the
+          surface.
+          If <boolean> is:
+              yes: correction is applied upon mesh generation/optimisation
+              no: no correction is applied.
+          Default: no
+
+     --split_overconstrained_elements <boolean>
+          Sets whether to split over-constrained elements or not. An edge is
+          considered as over-constrained when its two vertices belong to the
+          surface. A tetrahedron is considered as over-constrained  when at
+          least two of its faces belong to the surface.
+          If <boolean> is:
+              yes: correction is applied upon mesh generation/optimisation
+              no: no correction is applied.
+          Default: no
+
+     --split_overconstrained_tetrahedra <boolean>
+          Sets whether to split over-constrained tetrahedra or not. A
+          tetrahedron is considered as over-constrained  when at least two of
+          its faces belong to the surface.
+          If <boolean> is:
+              yes: correction is applied upon mesh generation/optimisation
+              no: no correction is applied.
+          Default: no
+
+     --verbose <verbose>
+          Set the verbosity level, increasing from 0 to 10.
+          Possible <verbose> values are increasing from 0 to 10 :
+             0 : no details.
+            10 : very detailed.
+          Default: 3.
+
+     --volume_proximity_layers <minimum number of layers>
+          Sets the desired minimum number of tetrahedra layers inside the
+          volume.
+          Default: 0 (no minimum).
+
+     --write_sizemap <output sizemap file name>
+          Sets the optional output sizemap file.
+          Using an existing file is not allowed.
+          If unset, the output sizemap will not be written.
+
+
+================================================================================
+                 MG-Tetra_HPC -- MeshGems 2.9-6 (August, 2019)
+       END OF SESSION - MG-Tetra_HPC (Copyright 2014-2019 by Distene SAS)
+                   compiled Sep  2 2019 09:58:40 on Linux_64
+               MeshGems is a Registered Trademark of Distene SAS
+================================================================================
+       ( Distene SAS
+        Phone: +33(0)970-650-219   Fax: +33(0)169-269-033
+        EMail: <support@distene.com> )
+*/
+
 
 //************************************
 int main(int argc, char *argv[])
 {
    bool ok;
-   int i,nb,nbfiles,limit_swap,nbelem_limit_swap,limit_swap_defaut,verbose;
+   int i,nb,nbfiles,limit_swap,nbelem_limit_swap,limit_swap_defaut,verbose,res;
+   float gradation,min_size,max_size;
    QString path,pathini,casename,casenamemed,fileskinmed,
            tmp,cmd,format,format_tetra,
-           test,menu,launchtetra,background,deletegroups,
-           ToMergeSubdomains,ToTagSubdomains,ToOutputInterfaces,ToDiscardSubdomains,
-           version="V3.0 (MED3+tetra-hpc)";
+           test,launchtetra,background,multithread,deletegroups,
+           version="V4.0 (MED3 + tetra-hpc v2.3 Sept 2016)";
    
    char *chelp=NULL,
         *ccasename=NULL,
@@ -486,31 +665,27 @@ int main(int argc, char *argv[])
         *cmedname=NULL,
         *climitswap=NULL,
         *cverbose=NULL,
-        *ctest=NULL,
-        *cmenu=NULL,
         *claunchtetra=NULL,
-        *cToMergeSubdomains=NULL,
-        *cToTagSubdomains=NULL,
-        *cToOutputInterfaces=NULL,
-        *cToDiscardSubdomains=NULL,
+        *cgradation=NULL,
+        *cmin_size=NULL,
+        *cmax_size=NULL,
         *cbackground=NULL,
+        *cmultithread=NULL,
         *cdeletegroups=NULL;
 
    for (i = 0; i < argc; i++){
       if (!strncmp (argv[i], "--help", sizeof ("--help"))) chelp = &(argv[i][0]);
       else if (!strncmp (argv[i], "--casename=", sizeof ("--casename"))) ccasename = &(argv[i][sizeof ("--casename")]);
       else if (!strncmp (argv[i], "--number=", sizeof ("--number"))) cnumber = &(argv[i][sizeof ("--number")]);
-      else if (!strncmp (argv[i], "--medname=", sizeof ("--medname"))) cmedname = &(argv[i][sizeof ("--medname")]);
       else if (!strncmp (argv[i], "--limitswap=", sizeof ("--limitswap"))) climitswap = &(argv[i][sizeof ("--limitswap")]);
+      else if (!strncmp (argv[i], "--medname=", sizeof ("--medname"))) cmedname = &(argv[i][sizeof ("--medname")]);
       else if (!strncmp (argv[i], "--verbose=", sizeof ("--verbose"))) cverbose = &(argv[i][sizeof ("--verbose")]);
-      else if (!strncmp (argv[i], "--test=", sizeof ("--test"))) ctest = &(argv[i][sizeof ("--test")]);
-      else if (!strncmp (argv[i], "--menu=", sizeof ("--menu"))) cmenu = &(argv[i][sizeof ("--menu")]);
       else if (!strncmp (argv[i], "--launchtetra=", sizeof ("--launchtetra"))) claunchtetra = &(argv[i][sizeof ("--launchtetra")]);
-      else if (!strncmp (argv[i], "--merge_subdomains=", sizeof ("--merge_subdomains"))) cToMergeSubdomains = &(argv[i][sizeof ("--")]);
-      else if (!strncmp (argv[i], "--tag_subdomains=", sizeof ("--tag_subdomains"))) cToTagSubdomains = &(argv[i][sizeof ("--")]);
-      else if (!strncmp (argv[i], "--output_interfaces=", sizeof ("--output_interfaces"))) cToOutputInterfaces = &(argv[i][sizeof ("--")]);
-      else if (!strncmp (argv[i], "--discard_subdomains=", sizeof ("--discard_subdomains"))) cToDiscardSubdomains = &(argv[i][sizeof ("--")]);
+      else if (!strncmp (argv[i], "--gradation=", sizeof ("--gradation"))) cgradation = &(argv[i][sizeof ("--gradation")]);
+      else if (!strncmp (argv[i], "--min_size=", sizeof ("--min_size"))) cmin_size = &(argv[i][sizeof ("--min_size")]);
+      else if (!strncmp (argv[i], "--max_size=", sizeof ("--max_size"))) cmax_size = &(argv[i][sizeof ("--max_size")]);
       else if (!strncmp (argv[i], "--background=", sizeof ("--background"))) cbackground = &(argv[i][sizeof ("--background")]);
+      else if (!strncmp (argv[i], "--multithread=", sizeof ("--multithread"))) cmultithread = &(argv[i][sizeof ("--multithread")]);
       else if (!strncmp (argv[i], "--deletegroups=", sizeof ("--deletegroups"))) cdeletegroups = &(argv[i][sizeof ("--deletegroups")]);
       }
 
@@ -525,22 +700,19 @@ int main(int argc, char *argv[])
       "   --medname            : path and name of output MED files\n"<<
       "   --limitswap          : max size of working cpu memory (Mo) (before swapping on .temp files)\n"<<
       "   --verbose            : trace of execution (0->6)\n"<<
-      "   --test               : more tests about joints, before generation of output files\n"<<
-      "   --menu               : a GUI menu for option number\n"<<
-      "   --launchtetra        : also launch tetra-hpc on files casename.mesh and option number\n"<<
-      "   --merge_subdomains   : merge the subdomains into one mesh and write the output .mesh(b) file\n"<<
-      "   --tag_subdomains     : use the parallel subdomain index as tag into the merged output mesh\n"<<
-      "                            to identify the parallel subdomains (used in combination with the merge_subdomains option)\n"<<
-      "   --output_interfaces  : write the parallel subdomains interface triangles into the merged output mesh\n"<<
-      "                            (used in combination with the merge_subdomains option)\n"<<
-      "   --discard_subdomains : discard the parallel subdomains informations output (mesh, global numbering and interfaces)\n"<<
+      "   --launchtetra        : launch mg_tetra_hpc on files casename.mesh and option number,\n"<<
+      "                            else only use existing input/output files\n"<<
+      "   --gradation          : the desired maximum ratio between 2 adjacent tetrahedron edges (Default 1.05). The closer it is to 1.0\n"<<
+      "   --min_size           : the desired maximum cell size value (Default: 0 no maximum size)\n"<<
+      "   --max_size           : the desired minimum cell size value (Default: 0 no minimum size)\n"<<
       "   --background         : force background mode from launch tetra-hpc and generation of final MED files (big meshes)\n"<<
+      "   --multithread        : launch mg_tetra_hpc multithread version, else mpi version\n"<<
       "   --deletegroups       : regular expression (see QRegExp) which matches unwanted groups in final MED files\n"<<
       "                            (try --deletegroups=\"(\\bJOINT)\"\n"<<
       "                            (try --deletegroups=\"(\\bAll_Nodes|\\bAll_Faces)\"\n"<<
       "                            (try --deletegroups=\"((\\bAll_|\\bNew_)(N|F|T))\"\n";
-      std::cout<<"example:\n   tetrahpcl2med --casename=/tmp/GHS3DPRL --number=2 --medname=DOMAIN "<<
-                 "--limitswap=1000 --verbose=0 --test=yes --menu=no --launchtetra=no\n\n";
+      std::cout<<"example:\n   tetrahpc2med --casename=/tmp/GHS3DPRL --number=2 --medname=DOMAIN "<<
+                 "--verbose=0 --launchtetra=no\n\n";
       return 1;  //no output files
    }
    
@@ -563,12 +735,13 @@ int main(int argc, char *argv[])
       std::cerr<<"--number: a positive integer is expected\n\n";
       return 1;
    }
-   if (nbfiles>2048){ //delirium in 2014
+   if (nbfiles>2048){ //delirium in 2016
       std::cerr<<"--number: a positive integer <= 2048 is expected\n\n";
       return 1;
    }
    if (!cmedname) cmedname=ccasename;
    casenamemed=cmedname;
+
    limit_swap_defaut=1000; //1000Mo
    limit_swap=limit_swap_defaut;
    if (climitswap){
@@ -583,10 +756,7 @@ int main(int argc, char *argv[])
          return 1;
       }
    }
-   //default 1GOctet/8(for float)
-   nbelem_limit_swap=limit_swap*1000000; //100%
-   CVWtab::memorymax=nbelem_limit_swap;
-
+   
    verbose=1; //default
    if (cverbose){
       tmp=cverbose;
@@ -601,46 +771,54 @@ int main(int argc, char *argv[])
       }
    }
 
-   test="no"; //default
-   if (ctest){
-      tmp=ctest;
-      if (tmp=="yes") test="yes";
-   }
-
-   menu="no"; //default
-   if (cmenu){
-      tmp=cmenu;
-      if (tmp=="yes") menu="yes";
-   }
-
    launchtetra="no"; //default
    if (claunchtetra){
       tmp=claunchtetra;
       if (tmp=="yes") launchtetra="yes";
    }
 
-   ToMergeSubdomains="no"; //default
-   if (cToMergeSubdomains){
-      tmp=cToMergeSubdomains;
-      if (tmp=="yes") ToMergeSubdomains="yes";
-   }
-
-   ToTagSubdomains="no"; //default
-   if (cToTagSubdomains){
-      tmp=cToTagSubdomains;
-      if (tmp=="yes") ToTagSubdomains="yes";
+   gradation=1.05; //default
+   if (cgradation){
+      tmp=cgradation;
+      gradation=tmp.toFloat(&ok);
+      if (!ok){
+         std::cerr<<"--gradation: a float { 0; ]1,3] } is expected\n\n";
+         return 1;
+      }
+      if (gradation>3.){
+         std::cerr<<"--gradation: a float <= 3. is expected\n\n";
+         return 1;
+      }
+      if (gradation<0.){
+         std::cerr<<"--gradation: a float >= 0. is expected\n\n";
+         return 1;
+      }
    }
 
-   ToOutputInterfaces="no"; //default
-   if (cToOutputInterfaces){
-      tmp=cToOutputInterfaces;
-      if (tmp=="yes") ToOutputInterfaces="yes";
+   if (cmin_size){
+      tmp=cmin_size;
+      min_size=tmp.toFloat(&ok);
+      if (!ok){
+         std::cerr<<"--min_size: a float >= 0. is expected\n\n";
+         return 1;
+      }
+      if (gradation<0.){
+         std::cerr<<"--min_size: a float >= 0. is expected\n\n";
+         return 1;
+      }
    }
 
-   ToDiscardSubdomains="no"; //default
-   if (cToDiscardSubdomains){
-      tmp=cToDiscardSubdomains;
-      if (tmp=="yes") ToDiscardSubdomains="yes";
+   if (cmax_size){
+      tmp=cmax_size;
+      max_size=tmp.toFloat(&ok);
+      if (!ok){
+         std::cerr<<"--max_size: a float >= 0. is expected\n\n";
+         return 1;
+      }
+      if (gradation<0.){
+         std::cerr<<"--max_size: a float >= 0. is expected\n\n";
+         return 1;
+      }
    }
 
    background="no"; //default
@@ -649,24 +827,13 @@ int main(int argc, char *argv[])
       if (tmp=="yes") background="yes";
    }
 
-
-   // We must always have an application
-   if (menu=="yes") {
-    QApplication a(argc,argv);
-    dlg_ghs3dmain *m = new dlg_ghs3dmain();
-    m->setWindowTitle("tetrahpc2med 3.0");
-    m->show();
-    a.exec();
-    if ( m->result() == QDialog::Accepted ) {
-      std::cout<<"parameters "<<m->KeepFiles()<<" "<<m->NbPart()<<std::endl;
-      nbfiles=m->NbPart();
-    }
-    else {
-      return 1;
-    }
-    delete m;
+   multithread="no"; //default
+   if (cmultithread){
+      tmp=cmultithread;
+      if (tmp=="yes") multithread="yes";
    }
 
+
    int n=casenamemed.count('/');
    if (n>0)
       path=casenamemed.section('/',-n-1,-2)+"/";
@@ -689,8 +856,8 @@ int main(int argc, char *argv[])
       casename.truncate(20);
    }
 
-   /*std::cout<<"CaseNameMed="<<casenamemed<<std::endl;
-   std::cout<<"PathMed="<<path<<std::endl;*/
+   //std::cout<<"CaseNameMed="<<casenamemed.toLatin1().constData()<<std::endl;
+   //std::cout<<"PathMed="<<path.toLatin1().constData()<<std::endl;
 
    deletegroups="(\\bxyz)"; //default improbable name
    if (cdeletegroups){
@@ -699,23 +866,45 @@ int main(int argc, char *argv[])
    
    //verbose=5;
    if (verbose>0)
-   std::cout<<"tetrahpc2med "<<version.toLatin1().constData()<<" parameters:"<<
+   std::cout<<
+           "tetrahpc2med "<<version.toLatin1().constData()<<" parameters:"<<
          "\n   --casename="<<pathini.toLatin1().constData()<<casename.toLatin1().constData()<<
          "\n   --number="<<nbfiles<<
          "\n   --medname="<<path.toLatin1().constData()<<casenamemed.toLatin1().constData()<<
-         "\n   --limitswap="<<limit_swap<<
          "\n   --verbose="<<verbose<<
-         "\n   --test="<<test.toLatin1().constData()<<
-         "\n   --menu="<<menu.toLatin1().constData()<<
          "\n   --launchtetra="<<launchtetra.toLatin1().constData()<<
-         "\n   --merge_subdomains="<<ToMergeSubdomains.toLatin1().constData()<<
-         "\n   --tag_subdomains="<<ToTagSubdomains.toLatin1().constData()<<
-         "\n   --output_interfaces="<<ToOutputInterfaces.toLatin1().constData()<<
-         "\n   --discard_subdomains="<<ToDiscardSubdomains.toLatin1().constData()<<
+         "\n   --gradation="<<gradation<<
+         "\n   --min_size="<<min_size<<
+         "\n   --max_size="<<max_size<<
          "\n   --background="<<background.toLatin1().constData()<<
+         "\n   --multithread="<<multithread.toLatin1().constData()<<
          "\n   --deletegroups=\""<<deletegroups.toLatin1().constData()<<"\"\n";
+         
+   if (launchtetra=="yes"){
+     
+      //call tetra_hpc.py is python script which assumes mpirun or else if no multithread
+      //after compilation openmpi or else acrobatic DISTENE_LICENCE change...
+      
+      cmd="mg-tetra_hpc.py --number=" + QString::number(nbfiles)+
+          " --in=" + pathini+casename + ".mesh" +
+          " --out=" + pathini+casename + "_out.mesh" +
+          " --gradation=" + QString::number(gradation) +
+          " --min_size=" + QString::number(min_size) +
+          " --max_size=" + QString::number(max_size) +
+          " --multithread=" + multithread.toLatin1().constData() +
+          " > " + path + "tetrahpc.log";
+      std::cout<<"\nlaunch tetra_hpc command:"<<
+                 "\n   "<<cmd.toLatin1().constData()<<"\n"<<std::endl;
+   }
+   else if ( std::ifstream(( pathini+casename + "_out.mesh").toLatin1().constData() ).is_open() )
+   {
+     // mesh file exists (created by using MG as a library), copy it to *.000001.mesh
+     QString copyCmd = ( QString("cp -f %1_out.mesh %2_out.000001.mesh")
+                         .arg( pathini+casename ).arg( pathini+casename ));
+     system( copyCmd.toLatin1().constData()); // run
+   }
    
-   //utile si appel par plugin ghs3dprl sur big meshes et tetrahpc sur plusieurs jours
+   //utile si appel par plugin ghs3dprl sur big meshes et tetra_hpc sur plusieurs jours
 #ifndef WIN32
    if (background=="yes"){
       pid_t pid = fork();
@@ -733,41 +922,30 @@ int main(int argc, char *argv[])
    printf("background mode is not supported on win32 platform !\n");
 #endif
 
-   //"tetrahpc -f exemple1 -n 4"
    if (launchtetra=="yes"){
-      //tetra_hpc.exe --help
-      //mpirun -n 3 mg-tetra_hpc.exe --in GHS3DPRL.mesh --out TOTO.mesh
-      
-      //direct mpirun cause problem: invalid
-      //cmd="mpirun -n "+cmd.sprintf("%d",nbfiles)+" mg-tetra_hpc.exe --in "+
-      
-      //call tetra_hpc.bash is script which assumes mpirun after compilation openmpi etc...
-      cmd="mg-tetra_hpc.bash -n "+cmd.sprintf("%d",nbfiles)+" --in "+
-          pathini+casename+".mesh --out "+
-          pathini+casename+".mesh"+
-          " --merge_subdomains "+ToMergeSubdomains+
-          " --tag_subdomains "+ToTagSubdomains+
-          " --output_interfaces "+ToOutputInterfaces+
-          " --discard_subdomains "+ToDiscardSubdomains+
-          " > "+path+"tetrahpc.log";
-      std::cout<<"\nlaunchtetra command: background="<<cbackground<<
-                 "\n      "<<cmd.toLatin1().constData()<<std::endl;
-      system(cmd.toLatin1().constData()); // run
       //sometimes it is better to wait flushing files on slow filesystem...
       system("sleep 3");
+      res = system(cmd.toLatin1().constData()); // run
+      if (res>0) 
+      {
+        std::cout<<std::endl<<"===end KO PROBLEM of "<<argv[0]<<"==="<<std::endl;
+        return res; // KO
+      }
+      system("sleep 3");
    }
    ghs3dprl_mesh_wrap *mymailw=new ghs3dprl_mesh_wrap;
    //no constructor, later maybe
    mymailw->nbfiles=0;
    mymailw->nbfilestot=nbfiles;
    //for huge cases big array swap in huge binary files
-   mymailw->nbelem_limit_swap=nbelem_limit_swap;
    mymailw->verbose=verbose;
    mymailw->casename=casename;
    mymailw->medname=casenamemed;
    mymailw->path=path;
    mymailw->pathini=pathini;
    mymailw->deletegroups=QRegExp(deletegroups,Qt::CaseSensitive,QRegExp::RegExp);
+   mymailw->for_multithread=false;
+   if (multithread=="yes") mymailw->for_multithread=true;
    ghs3dprl_msg_parser handler;
    //constructor later maybe
    //handler.verbose=true;
@@ -778,13 +956,19 @@ int main(int argc, char *argv[])
    format=format.sprintf("%d",nbfiles);
    int nbf=format.length();
    format=format.sprintf(".%%0%dd.%%0%dd",nbf,nbf);
-   format_tetra=".%05d";
+   format_tetra=".%06d";
    if (verbose>10)std::cout<<"format "<<format.toLatin1().constData()<<std::endl;
    if (verbose>10)std::cout<<"format_tetra "<<format_tetra.toLatin1().constData()<<std::endl;
    mymailw->format=format;
    mymailw->format_tetra=format_tetra;
    mymailw->for_tetrahpc=true; //to know what files to read: .noboite or .mesh
    
+   //default 1GOctet/8(for float)
+   nbelem_limit_swap=limit_swap*1000000; //100%
+   CVWtab::memorymax=nbelem_limit_swap;
+   mymailw->nbelem_limit_swap=nbelem_limit_swap;
+
+   
    //something like "/home/wambeke/tmp/GHS3DPRL_skin.med"
    fileskinmed=pathini+casename+"_skin.med";
    //fileskinmed="/home/wambeke/tmp/GHS3DPRL_skin.med";
@@ -800,31 +984,32 @@ int main(int argc, char *argv[])
       if (verbose>0)std::cout<<"Initial skin file <"<<fileskinmed.toLatin1().constData()<<"> does not exist\n"; }
    
 
-//if test quickly read all files before (or only small files)
- if (test=="yes"){
-   if (verbose>0) std::cout<<"\nReading output files of tetrahpc as input files of tetrahpc2med...\n";
-   //only read beginning of files .xxxxx.mesh
-   //supposed big files big arrays so only see first lines
-   mymailw->nbfiles=0;
-   for (int i=1; i<=nbfiles; i++){
-      mymailw->nofile=i;
-      tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),i)+".mesh";
-      if (verbose>0) std::cout<<"FileName="<<tmp.toLatin1().constData()<<std::endl;
-      ok=mymailw->TestExistingFileMESHnew(tmp);
-   }
-   if (verbose>0)
-      std::cout<<"NumberOfFilesMESHTested="<<mymailw->nbfiles<<": ok\n\n";
-   if (mymailw->nbfiles != nbfiles){
-      std::cerr<<"NumberOfFiles != NumberOfFilesTested is unexpected\n\n";
-      return 1;
-   }
- }  //end if test
+   //if test quickly read all files before (or only small files)
  if (test=="yes"){
+     if (verbose>0) std::cout<<"\nReading output files of tetrahpc as input files of tetrahpc2med...\n";
+     //only read beginning of files .xxxxx.mesh
+     //supposed big files big arrays so only see first lines
+     mymailw->nbfiles=0;
+     for (int i=1; i<=nbfiles; i++){
+        mymailw->nofile=i;
+        tmp=pathini+casename+tmp.sprintf(format_tetra.toLatin1().constData(),i)+".mesh";
+        if (verbose>0) std::cout<<"FileName="<<tmp.toLatin1().constData()<<std::endl;
+        ok=mymailw->TestExistingFileMESHnew(tmp);
+     }
+     if (verbose>0)
+        std::cout<<"NumberOfFilesMESHTested="<<mymailw->nbfiles<<": ok\n\n";
+     if (mymailw->nbfiles != nbfiles){
+        std::cerr<<"NumberOfFiles != NumberOfFilesTested is unexpected\n\n";
+        return 1;
+     }
  }  //end if test
  
    ok=mymailw->Write_MEDfiles_v2(true); //deletekeys=true
    
    nb=mymailw->remove_all_keys_mesh_wrap();
    if (verbose>3)std::cout<<"***remove_all_key_mesh_wrap*** "<<nb<<" keys removed\n";
-   if (verbose>0)std::cout<<std::endl<<"===end of "<<argv[0]<<"==="<<std::endl;
+
+   if (verbose>=0)std::cout<<std::endl<<"===end OK of "<<argv[0]<<"==="<<std::endl;
 
    //for debug
    //int res=dumpMED("/home/wambeke/tmp/DOMAIN_1.med",1);