From 8281d267cbf9508859c54127975f104330bda59f Mon Sep 17 00:00:00 2001 From: YOANN AUDOUIN Date: Mon, 4 Sep 2023 07:57:41 +0200 Subject: [PATCH] Revert "Modifications for multinode parallelism" This reverts commit 90d8d4461e44b60af0362e45804f6b0873bb9887. --- .../NETGENPlugin_NETGEN_3D_Remote.cxx | 102 ++++++++---------- .../NETGENPlugin_NETGEN_3D_SA.cxx | 3 - src/NETGENPlugin/NETGENPlugin_Runner_main.cxx | 3 +- 3 files changed, 46 insertions(+), 62 deletions(-) diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_Remote.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_Remote.cxx index 5d3d1f0..48abebc 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_Remote.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_Remote.cxx @@ -39,7 +39,6 @@ #include #include -#include #include #include #include @@ -230,17 +229,22 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh, SMESH_Hypothesis::Hypothesis_Status hypStatus; NETGENPlugin_NETGEN_3D::CheckHypothesis(aMesh, aShape, hypStatus); } - SMESH_ParallelMesh& aParMesh = dynamic_cast(aMesh); + // Temporary folder for run #ifdef WIN32 - fs::path tmp_folder = aParMesh.GetTmpFolder() / fs::path("Volume-%%%%-%%%%"); + // On windows mesh does not have GetTmpFolder + fs::path tmp_folder = fs::path("Volume-%%%%-%%%%"); #else - fs::path tmp_folder = aParMesh.GetTmpFolder() / fs::unique_path(fs::path("Volume-%%%%-%%%%")); + fs::path tmp_folder = aMesh.GetTmpFolder() / fs::unique_path(fs::path("Volume-%%%%-%%%%")); #endif fs::create_directories(tmp_folder); // Using MESH2D generated after all triangles where created. - fs::path mesh_file=aParMesh.GetTmpFolder() / fs::path("Mesh2D.med"); +#ifdef WIN32 + fs::path mesh_file=fs::path("Mesh2D.med"); +#else + fs::path mesh_file=aMesh.GetTmpFolder() / fs::path("Mesh2D.med"); +#endif fs::path element_orientation_file=tmp_folder / fs::path("element_orientation.dat"); fs::path new_element_file=tmp_folder / fs::path("new_elements.dat"); fs::path tmp_mesh_file=tmp_folder / fs::path("tmp_mesh.med"); @@ -249,8 +253,7 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh, fs::path shape_file=tmp_folder / fs::path("shape.brep"); 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.txt"); - // TODO: See if we can retreived name from aMesh ? + fs::path cmd_file=tmp_folder / fs::path("cmd.log"); std::string mesh_name = "MESH"; { @@ -269,72 +272,57 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh, } // Calling run_mesher - // Path to mesher script - fs::path mesher_launcher = fs::path(std::getenv("SMESH_ROOT_DIR"))/ - fs::path("bin")/ - fs::path("salome")/ - fs::path("mesher_launcher.py"); - - - std::string s_program="python3"; - std::list params; - params.push_back(mesher_launcher.string()); - params.push_back("NETGEN3D"); - params.push_back(mesh_file.string()); - params.push_back(shape_file.string()); - params.push_back(param_file.string()); - params.push_back("--elem-orient-file=" + element_orientation_file.string()); - params.push_back("--new-element-file=" + new_element_file.string()); - - // Parallelism method parameters - int method = aParMesh.GetParallelismMethod(); - if(method == ParallelismMethod::MultiThread){ - params.push_back("--method=local"); - } else if (method == ParallelismMethod::MultiNode){ - // TODO :See what parameters to handle in the end - params.push_back("--method=cluster"); - params.push_back("--resource="+aParMesh.GetResource()); - params.push_back("--wc-key="+aParMesh.GetWcKey()); - params.push_back("--nb-proc=1"); - params.push_back("--nb-proc-per-node="+to_string(aParMesh.GetNbProcPerNode())); - params.push_back("--nb-node="+to_string(aParMesh.GetNbNode())); - } else { - throw SALOME_Exception("Unknown parallelism method "+method); - } - std::string cmd = ""; - cmd += s_program; - for(auto arg: params){ - cmd += " " + arg; - } - MESSAGE("Running command: "); - MESSAGE(cmd); - // Writing command in cmd.log + 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() + " " + + new_element_file.string() + " " + + "NONE"; + // Writing command in log { std::ofstream flog(cmd_file.string()); flog << cmd << endl; + flog << endl; } + MESSAGE("Running command: "); + MESSAGE(cmd); + // Building arguments for QProcess - QString program = QString::fromStdString(s_program); + QString program = run_mesher_exe.string().c_str(); QStringList arguments; - for(auto arg : params){ - arguments << arg.c_str(); - } - + arguments << "NETGEN3D"; + arguments << mesh_file.string().c_str(); + arguments << shape_file.string().c_str(); + arguments << param_file.string().c_str(); + arguments << element_orientation_file.string().c_str(); + arguments << new_element_file.string().c_str(); + arguments << "NONE"; QString out_file = log_file.string().c_str(); QProcess myProcess; - myProcess.setProcessChannelMode(QProcess::MergedChannels); myProcess.setStandardOutputFile(out_file); myProcess.start(program, arguments); // Waiting for process to finish (argument -1 make it wait until the end of // the process otherwise it just waits 30 seconds) - bool finished = myProcess.waitForFinished(-1); - int ret = myProcess.exitCode(); + myProcess.waitForFinished(-1); + int ret = myProcess.exitStatus(); - if(ret != 0 || !finished){ + if(ret != 0){ // Run crahed - std::string msg = "Issue with mesh_launcher: \n"; + std::string msg = "Issue with command: \n"; msg += "See log for more details: " + log_file.string() + "\n"; msg += cmd + "\n"; throw SALOME_Exception(msg); diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.cxx index 66d3954..b12edb7 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.cxx @@ -163,7 +163,6 @@ bool NETGENPlugin_NETGEN_3D_SA::computeFillNewElementFile( int &Netgen_NbOfNodes ) { - MESSAGE("Writting new elements") Ng_Mesh* Netgen_mesh = ngLib.ngMesh(); int Netgen_NbOfNodesNew = Ng_GetNP(Netgen_mesh); @@ -224,7 +223,6 @@ bool NETGENPlugin_NETGEN_3D_SA::Compute( std::string new_element_file, bool output_mesh) { - MESSAGE("Compute"); // vector of nodes in which node index == netgen ID vector< const SMDS_MeshNode* > nodeVec; NETGENPlugin_NetgenLibWrapper ngLib; @@ -235,7 +233,6 @@ bool NETGENPlugin_NETGEN_3D_SA::Compute( // Changing netgen log_file putting it next to new_element_file fs::path netgen_log_file = fs::path(new_element_file).remove_filename() / fs::path("NETGEN.out"); - MESSAGE("netgen ouput"<