Salome HOME
Convert .mesh to .med in multithread as before. But don't create joints and xml files...
[plugins/ghs3dprlplugin.git] / src / GHS3DPRLPlugin / GHS3DPRLPlugin_GHS3DPRL.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;
 }