Salome HOME
Adding number of thread to netgen hypo + windows corrections
authorYoann Audouin <yoann.audouin@edf.fr>
Mon, 3 Oct 2022 16:11:35 +0000 (18:11 +0200)
committerYoann Audouin <yoann.audouin@edf.fr>
Mon, 3 Oct 2022 16:11:35 +0000 (18:11 +0200)
src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_3D_Remote.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.hxx
src/NETGENPlugin/NETGENPlugin_Runner_main.cxx

index b256eab51308e5d072215bef46fa13255c2fcd83..dd209162f745eef046fd04f3c2b42874ea017977 100644 (file)
@@ -32,9 +32,6 @@
 
 #include "NETGENPlugin_Hypothesis.hxx"
 
-// TODO: remove use of netgen_param
-#include "NETGENPlugin_DriverParam.hxx"
-
 #include <SMDS_MeshElement.hxx>
 #include <SMDS_MeshNode.hxx>
 #include <SMESHDS_Mesh.hxx>
index bc81359fa0edc2c5aa078e0ec05e2b7d2c581333..a50073cb4f8fe9ead8a98f95a42cdd3e7b5bb7e4 100644 (file)
@@ -220,7 +220,6 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh&         aMesh,
   fs::path param_file=tmp_folder / fs::path("netgen3d_param.txt");
   fs::path log_file=tmp_folder / fs::path("run.log");
   fs::path cmd_file=tmp_folder / fs::path("cmd.log");
-  //TODO: Handle variable mesh_name
   std::string mesh_name = "MESH";
 
   {
@@ -239,20 +238,22 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh&         aMesh,
   }
 
   // Calling run_mesher
-  // TODO: check if we need to handle the .exe for windows
   std::string cmd;
   fs::path run_mesher_exe =
     fs::path(std::getenv("NETGENPLUGIN_ROOT_DIR"))/
     fs::path("bin")/
     fs::path("salome")/
+#ifdef WIN32
+    fs::path("NETGENPlugin_Runner.exe");
+#else
     fs::path("NETGENPlugin_Runner");
+#endif
 
   cmd = run_mesher_exe.string() +
                   " NETGEN3D " + mesh_file.string() + " "
                                + shape_file.string() + " "
                                + param_file.string() + " "
                                + element_orientation_file.string() + " "
-                               + std::to_string(aMesh.GetMesherNbThreads()) + " "
                                + new_element_file.string() + " "
                                + "NONE";
   // Writing command in log
@@ -273,7 +274,6 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh&         aMesh,
   arguments << shape_file.c_str();
   arguments << param_file.c_str();
   arguments << element_orientation_file.c_str();
-  arguments << std::to_string(aMesh.GetMesherNbThreads()).c_str();
   arguments << new_element_file.c_str();
   arguments << "NONE";
   QString out_file = log_file.c_str();
index 6dfc1003a59579c18255f6085aca1268d48b07b4..9d2bf43166a41ac010ccce3c3bd0ffb40d82e37a 100644 (file)
@@ -227,8 +227,7 @@ int NETGENPlugin_NETGEN_3D_SA::run(const std::string input_mesh_file,
           const std::string hypo_file,
           const std::string element_orientation_file,
           const std::string new_element_file,
-          const std::string output_mesh_file,
-          int nbThreads)
+          const std::string output_mesh_file)
 {
 
   _element_orientation_file = element_orientation_file;
@@ -248,8 +247,6 @@ int NETGENPlugin_NETGEN_3D_SA::run(const std::string input_mesh_file,
 
   importNetgenParams(hypo_file, myParams);
   fillHyp(myParams, &gen);
-  // Setting number of threads for netgen
-  myParams.nbThreads = nbThreads;
 
   MESSAGE("Meshing with netgen3d");
   int ret = Compute(myShape, *myMesh, myParams,
index 36eb2666b797c48bab1ce3d275f3ae70ccc17d27..62e9059228af7032d1351785609e8910b29c9bd9 100644 (file)
@@ -57,10 +57,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D_SA: public NETGENPlugin_NETGEN_
           const std::string hypo_file,
           const std::string element_orientation_file,
           const std::string new_element_file,
-          const std::string output_mesh_file,
-          int nbThreads);
-
-
+          const std::string output_mesh_file);
 
  protected:
 
index 8d2e11bdff106f44c81204bd37329f873df8d00e..95cc741b8d34d07c6d0e084b4df336e576171d33 100644 (file)
  */
 int main(int argc, char *argv[]){
 
-  if(argc!=9||(argc==2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help")==0))){
-    std::cout << "Error in number of arguments "<< argc<<" given expected 8" <<std::endl;
+  if(argc!=8||(argc==2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help")==0))){
+    std::cout << "Error in number of arguments "<< argc-1<<" given expected 7" <<std::endl;
     std::cout << "Syntax:"<<std::endl;
     std::cout << "run_mesher MESHER INPUT_MESH_FILE SHAPE_FILE HYPO_FILE" << std::endl;
-    std::cout << "           ELEM_ORIENT_FILE NB_THREADS" << std::endl;
+    std::cout << "           ELEM_ORIENT_FILE " << std::endl;
     std::cout << "           NEW_ELEMENT_FILE OUTPUT_MESH_FILE" << std::endl;
     std::cout << std::endl;
     std::cout << " Set argument to NONE to ignore them " << std::endl;
@@ -57,7 +57,6 @@ int main(int argc, char *argv[]){
     std::cout << "  SHAPE_FILE: STEP file containing the shape to mesh" << std::endl;
     std::cout << "  HYPO_FILE: Ascii file containint the list of parameters" << std::endl;
     std::cout << "  (optional) ELEM_ORIENT_FILE: binary file containing the list of element from INPUT_MESH_FILE associated to the shape and their orientation" << std::endl;
-    std::cout << "  NB_THREADS: Number of thread to use for the mesher" << std::endl;
     std::cout << "  (optional) NEW_ELEMENT_FILE: (out) contains elements and nodes added by the meshing" << std::endl;
     std::cout << "  (optional) OUTPUT_MESH_FILE: (out) MED File containing the mesh after the run of the mesher" << std::endl;
     return 0;
@@ -67,9 +66,8 @@ int main(int argc, char *argv[]){
   std::string shape_file=argv[3];
   std::string hypo_file=argv[4];
   std::string element_orientation_file=argv[5];
-  int nbThreads=std::stoi(argv[6]);
-  std::string new_element_file=argv[7];
-  std::string output_mesh_file=argv[8];
+  std::string new_element_file=argv[6];
+  std::string output_mesh_file=argv[7];
 
   //std::string thing;
   //std::cin >> thing;
@@ -82,18 +80,13 @@ int main(int argc, char *argv[]){
     new_element_file = "";
 
   if (mesher=="NETGEN3D"){
-    auto begin = std::chrono::high_resolution_clock::now();
     NETGENPlugin_NETGEN_3D_SA myplugin;
     myplugin.run(input_mesh_file,
              shape_file,
              hypo_file,
              element_orientation_file,
              new_element_file,
-             output_mesh_file,
-             nbThreads);
-    auto end = std::chrono::high_resolution_clock::now();
-    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
-    std::cout << "Time elapsed: " << elapsed.count()*1e-9 << std::endl;
+             output_mesh_file);
   } else {
     std::cerr << "Unknown mesher:" << mesher << std::endl;
   }