Salome HOME
Convert .mesh to .med in multithread as before. But don't create joints and xml files... cbr/fix_tetrahpc_with_new_licence V9_8_0a1 V9_8_0a2 V9_8_0b1
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Wed, 6 Oct 2021 06:26:02 +0000 (08:26 +0200)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Wed, 6 Oct 2021 06:26:02 +0000 (08:26 +0200)
src/GHS3DPRLPlugin/GHS3DPRLPlugin_GHS3DPRL.cxx
src/tepal2med/ghs3dprl_mesh_wrap.cxx

index db4f829611840bf71bd44c96e55d872dae77b9ac..8c0f78d90e7bdc68d7260a902dd61a14b7b4dade 100644 (file)
@@ -31,6 +31,7 @@
 #include <SMESH_TypeDefs.hxx>
 #include <SMESH_subMesh.hxx>
 #include <SMESH_MesherHelper.hxx>
+#include <SMESH_File.hxx>
 
 #include "utilities.h"
 
@@ -220,13 +221,13 @@ bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh&         theMesh,
                                       SMESH_MesherHelper* /*theHelper*/)
 {
   bool Ok=false;
-  TCollection_AsciiString pluginerror("ghs3dprl: ");
+  TCollection_AsciiString pluginerror("MG-TETRA_HPC: ");
   SMESHDS_Mesh* meshDS = theMesh.GetMeshDS();
   if ( theMesh.NbTriangles() == 0 )
     return error( COMPERR_BAD_INPUT_MESH, "No triangles in the mesh" );
 
   if (_hypothesis==NULL){
-    pluginerror += "No existing parameters/hypothesis for GHS3DPRL";
+    pluginerror += "No existing parameters/hypothesis for MG-TETRA_HPC";
     cout <<"\n"<<pluginerror<<"\n\n";
     error(COMPERR_ALGO_FAILED, pluginerror.ToCString() );
     return false;
@@ -353,8 +354,8 @@ bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh&         theMesh,
       std::cout << log << std::endl;
       // try to guess an error from the output log
       std::string log2 = mgTetraHPC.GetLog();
-      if ( log2.find(" Dlim "   ) != std::string::npos ||
-          log2.find(" license ") != std::string::npos )
+      if ( log2.find("Dlim"   ) != std::string::npos ||
+          log2.find("icense") != std::string::npos )
         return error("License problem");
       std::cout << log2 << std::endl;
       if ( log2.find("You are using an empty MPI stubs library") != std::string::npos )
@@ -379,44 +380,61 @@ bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh&         theMesh,
     cout<<"  Write input file for mg-tetra_hpc "<<fileskinmesh<<"...";
     cout<<" ...done\n";
   }
-  // if mpi, convert meshes to med with xml master file
+
   if (!_Multithread)
   {
     fileskinmed=path + casenamemed + "_skin.med";
     cout<<"  Write file "<<fileskinmed<<"...";
     theMesh.ExportMED(fileskinmed.ToCString(),"SKIN_INITIAL",true);
     cout<<" ...done\n\n";
+  }
 
-    cout<<"GHS3DPRL command :\n  "<<run_GHS3DPRL.ToCString()<<endl;
-    //sometimes it is better to wait flushing files on slow filesystem...
-    system( "sleep 3" );
-    //launch tetrahpc2med which launch mg-tetra_hpc.py which launch mg-tetra_hpc(_mpi?).exe
-    std::cout << "run_GHS3DPRL cmd: " << run_GHS3DPRL << std::endl;
-    res = system( run_GHS3DPRL.ToCString() );
-    if (res > 0)
-    {
-      pluginerror = pluginerror + "PROBLEM tetrahpc2med command";
-      cout<<pluginerror<<endl;
-      error(COMPERR_ALGO_FAILED, pluginerror.ToCString());
-      return false; //but it is not a problem but if true my message is overwritten
-    }
-    system( "sleep 3" );
+  // convert .mesh (one or several) to med file(s) with xml master file if mpi
+  cout<<"Mesh conversion command :\n  "<<run_GHS3DPRL.ToCString()<<endl;
+  //sometimes it is better to wait flushing files on slow filesystem...
+  //   system( "sleep 3" );
+  //launch tetrahpc2med which launch mg-tetra_hpc.py which launch mg-tetra_hpc(_mpi?).exe
+  res = system( run_GHS3DPRL.ToCString() );
+  if (res > 0)
+  {
+    pluginerror = pluginerror + "PROBLEM tetrahpc2med command";
+    cout<<pluginerror<<endl;
+    error(COMPERR_ALGO_FAILED, pluginerror.ToCString());
+    return false; //but it is not a problem but if true my message is overwritten
+  }
+  //system( "sleep 3" );
+
+  if (_Background) {
+    pluginerror = pluginerror + "backgrounding... plugin is not waiting for output files "+ path +casenamemed + "_*.med";
+    cout<<pluginerror<<endl;
+    error(COMPERR_NO_MESH_ON_SHAPE, pluginerror.ToCString());
+    return false; //but it is not a problem but if true my message is overwritten
+    //return true; //but it is not a problem,
+  }
 
-    if (_Background) {
-      pluginerror = pluginerror + "backgrounding... plugin is not waiting for output files "+ path +casenamemed + "_*.med";
+  if (_Multithread)
+  {
+    // check the med file has been created (only one med file, since multithread)
+    TCollection_AsciiString resuMedFile = TCollection_AsciiString(path) + casenamemed + "_1.med";
+    SMESH_File file( resuMedFile.ToCString() );
+    if (file.exists() && file.size() > 0)
+    {
+      Ok = true;
+      pluginerror = pluginerror + "MG-tetra_hpc mesh not loaded in memory, is stored in file "+ resuMedFile;
       cout<<pluginerror<<endl;
-      error(COMPERR_NO_MESH_ON_SHAPE, pluginerror.ToCString());
-      return false; //but it is not a problem but if true my message is overwritten
-      //return true; //but it is not a problem,
+      error(COMPERR_WARNING, pluginerror.ToCString() );
+      if (!_KeepFiles) system( run_nokeep_files.ToCString() );
     }
-
-    // read a result, GHS3DPRL_Out is the name of master file (previous xml format)
+  }
+  else
+  {
+    // read a result, GHS3DPRL_Outxml is the name of master file (previous xml format)
     FILE * aResultFile = fopen( GHS3DPRL_Outxml.ToCString(), "r" );
     if (aResultFile){
       Ok = true;
       fclose(aResultFile);
-      cout<<"GHS3DPRL OK output master file "<<casenamemed<<".xml exist !\n\n";
-      pluginerror = pluginerror + "MG-tetra_hpc mesh(es) not loaded in memory, are stored in files "+ path + casenamemed + "_*.med";
+      cout<<"MG-TETRA_HPC OK output master file "<<casenamemed<<".xml exist !\n\n";
+      pluginerror = pluginerror + "MG-tetra_hpc meshes not loaded in memory, are stored in files "+ path + casenamemed + "_*.med";
       cout<<pluginerror<<endl;
       error(COMPERR_WARNING, pluginerror.ToCString() );
       if (!_KeepFiles) system( run_nokeep_files.ToCString() );
@@ -426,15 +444,14 @@ bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh&         theMesh,
       pluginerror = pluginerror + "output master file " + casenamemed + ".xml do not exist";
       cout<<pluginerror<<endl;
       error(COMPERR_ALGO_FAILED, pluginerror.ToCString() );
-      cout<<"GHS3DPRL KO output files "<<GHS3DPRL_Out<<" do not exist ! see intermediates files keeped:\n";
+      cout<<"MG-TETRA_HPC KO output files "<<GHS3DPRL_Out<<" do not exist ! see intermediate files kept:\n";
       TCollection_AsciiString run_list_files("ls -alt ");
       run_list_files +=  GHS3DPRL_Out + "* " + GHS3DPRL_In + "* " + logFileName;
       system( run_list_files.ToCString() );
       cout<<endl;
     }
   }
-  else
-    Ok = true;
+
 
   return Ok;
 }
index 4b89aa68542d980c086796d55bcea47f8a43dc62..926fa0e36647907464ec1ddc61d2d903649b6ce6 100644 (file)
@@ -1918,11 +1918,14 @@ bool ghs3dprl_mesh_wrap::Write_MEDfiles_v2(bool /*deletekeys*/)
    }
 
    //create file resume DOMAIN.joints.med of all joints for quick display (...may be...)
-   tmp=path+medname+tmp.sprintf("_joints.med");
-   charendnull(distfilename,tmp,MED_COMMENT_SIZE);
-   fidjoint=MEDfileOpen(distfilename,MED_ACC_CREAT);
-   if (fidjoint<0) std::cerr<<"Problem MEDfileOpen "<<distfilename<<std::endl;
-   if (verbose>0) std::cout<<"CreateMEDFile for all joints <"<<distfilename<<">\n";
+   if (! for_multithread)
+   {
+    tmp=path+medname+tmp.sprintf("_joints.med");
+    charendnull(distfilename,tmp,MED_COMMENT_SIZE);
+    fidjoint=MEDfileOpen(distfilename,MED_ACC_CREAT);
+    if (fidjoint<0) std::cerr<<"Problem MEDfileOpen "<<distfilename<<std::endl;
+    if (verbose>0) std::cout<<"CreateMEDFile for all joints <"<<distfilename<<">\n";
+   }
 
    //copy file source/GHS3DPRL_skin.med as destination/DOMAIN.skin.med
    tmp=path+medname+"_skin.med";
@@ -2084,8 +2087,9 @@ bool ghs3dprl_mesh_wrap::Write_MEDfiles_v2(bool /*deletekeys*/)
       }
     
       MEDfileClose(fid); //no error
-      //master.xml writings
-      /*oktmp=*/Write_masterxmlMEDfile();
+      //master.xml writings if mpi mode
+      if (!for_multithread)
+        /*oktmp=*/Write_masterxmlMEDfile();
       continue;       //and loop on others domains
 
       erreur:         //error
@@ -2094,7 +2098,8 @@ bool ghs3dprl_mesh_wrap::Write_MEDfiles_v2(bool /*deletekeys*/)
 
    }
    
-   MEDfileClose(fidjoint); //no error
+   if (! for_multithread)
+     MEDfileClose(fidjoint); //no error
    if (verbose>0)std::cout<<"\nTotalNumberOftetrahedra="<<nbtetrastotal<<std::endl;
    ok = true;