Modifications for multinode parallelism (with windows fixed)
Adding walltime to multinode parameters bos #37471: fix compilation on Windows operating system
This commit is contained in:
parent
8281d267cb
commit
dae130623f
@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include <SMESH_Gen.hxx>
|
#include <SMESH_Gen.hxx>
|
||||||
#include <SMESH_Mesh.hxx>
|
#include <SMESH_Mesh.hxx>
|
||||||
|
#include <SMESH_ParallelMesh.hxx>
|
||||||
#include <SMESH_MesherHelper.hxx>
|
#include <SMESH_MesherHelper.hxx>
|
||||||
#include <SMESH_DriverShape.hxx>
|
#include <SMESH_DriverShape.hxx>
|
||||||
#include <SMESH_DriverMesh.hxx>
|
#include <SMESH_DriverMesh.hxx>
|
||||||
@ -48,14 +49,8 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#include <filesystem>
|
|
||||||
namespace fs = std::filesystem;
|
|
||||||
#else
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Netgen include files
|
Netgen include files
|
||||||
*/
|
*/
|
||||||
@ -229,22 +224,17 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh,
|
|||||||
SMESH_Hypothesis::Hypothesis_Status hypStatus;
|
SMESH_Hypothesis::Hypothesis_Status hypStatus;
|
||||||
NETGENPlugin_NETGEN_3D::CheckHypothesis(aMesh, aShape, hypStatus);
|
NETGENPlugin_NETGEN_3D::CheckHypothesis(aMesh, aShape, hypStatus);
|
||||||
}
|
}
|
||||||
|
SMESH_ParallelMesh& aParMesh = dynamic_cast<SMESH_ParallelMesh&>(aMesh);
|
||||||
|
|
||||||
// Temporary folder for run
|
// Temporary folder for run
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
// On windows mesh does not have GetTmpFolder
|
fs::path tmp_folder = aParMesh.GetTmpFolder() / fs::path("Volume-%%%%-%%%%");
|
||||||
fs::path tmp_folder = fs::path("Volume-%%%%-%%%%");
|
|
||||||
#else
|
#else
|
||||||
fs::path tmp_folder = aMesh.GetTmpFolder() / fs::unique_path(fs::path("Volume-%%%%-%%%%"));
|
fs::path tmp_folder = aParMesh.GetTmpFolder() / fs::unique_path(fs::path("Volume-%%%%-%%%%"));
|
||||||
#endif
|
#endif
|
||||||
fs::create_directories(tmp_folder);
|
fs::create_directories(tmp_folder);
|
||||||
// Using MESH2D generated after all triangles where created.
|
// Using MESH2D generated after all triangles where created.
|
||||||
#ifdef WIN32
|
fs::path mesh_file=aParMesh.GetTmpFolder() / fs::path("Mesh2D.med");
|
||||||
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 element_orientation_file=tmp_folder / fs::path("element_orientation.dat");
|
||||||
fs::path new_element_file=tmp_folder / fs::path("new_elements.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");
|
fs::path tmp_mesh_file=tmp_folder / fs::path("tmp_mesh.med");
|
||||||
@ -253,7 +243,8 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh,
|
|||||||
fs::path shape_file=tmp_folder / fs::path("shape.brep");
|
fs::path shape_file=tmp_folder / fs::path("shape.brep");
|
||||||
fs::path param_file=tmp_folder / fs::path("netgen3d_param.txt");
|
fs::path param_file=tmp_folder / fs::path("netgen3d_param.txt");
|
||||||
fs::path log_file=tmp_folder / fs::path("run.log");
|
fs::path log_file=tmp_folder / fs::path("run.log");
|
||||||
fs::path cmd_file=tmp_folder / fs::path("cmd.log");
|
fs::path cmd_file=tmp_folder / fs::path("cmd.txt");
|
||||||
|
// TODO: See if we can retreived name from aMesh ?
|
||||||
std::string mesh_name = "MESH";
|
std::string mesh_name = "MESH";
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -272,57 +263,72 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calling run_mesher
|
// Calling run_mesher
|
||||||
std::string cmd;
|
// Path to mesher script
|
||||||
fs::path run_mesher_exe =
|
fs::path mesher_launcher = fs::path(std::getenv("SMESH_ROOT_DIR"))/
|
||||||
fs::path(std::getenv("NETGENPLUGIN_ROOT_DIR"))/
|
fs::path("bin")/
|
||||||
fs::path("bin")/
|
fs::path("salome")/
|
||||||
fs::path("salome")/
|
fs::path("mesher_launcher.py");
|
||||||
#ifdef WIN32
|
|
||||||
fs::path("NETGENPlugin_Runner.exe");
|
|
||||||
#else
|
|
||||||
fs::path("NETGENPlugin_Runner");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cmd = run_mesher_exe.string() +
|
|
||||||
" NETGEN3D " + mesh_file.string() + " "
|
std::string s_program="python3";
|
||||||
+ shape_file.string() + " "
|
std::list<std::string> params;
|
||||||
+ param_file.string() + " "
|
params.push_back(mesher_launcher.string());
|
||||||
+ element_orientation_file.string() + " "
|
params.push_back("NETGEN3D");
|
||||||
+ new_element_file.string() + " "
|
params.push_back(mesh_file.string());
|
||||||
+ "NONE";
|
params.push_back(shape_file.string());
|
||||||
// Writing command in log
|
params.push_back(param_file.string());
|
||||||
{
|
params.push_back("--elem-orient-file=" + element_orientation_file.string());
|
||||||
std::ofstream flog(cmd_file.string());
|
params.push_back("--new-element-file=" + new_element_file.string());
|
||||||
flog << cmd << endl;
|
|
||||||
flog << endl;
|
// Parallelism method parameters
|
||||||
|
int method = aParMesh.GetParallelismMethod();
|
||||||
|
if(method == ParallelismMethod::MultiThread){
|
||||||
|
params.push_back("--method=local");
|
||||||
|
} else if (method == ParallelismMethod::MultiNode){
|
||||||
|
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()));
|
||||||
|
params.push_back("--walltime="+aParMesh.GetWalltime());
|
||||||
|
} else {
|
||||||
|
throw SALOME_Exception("Unknown parallelism method "+method);
|
||||||
|
}
|
||||||
|
std::string cmd = "";
|
||||||
|
cmd += s_program;
|
||||||
|
for(auto arg: params){
|
||||||
|
cmd += " " + arg;
|
||||||
}
|
}
|
||||||
MESSAGE("Running command: ");
|
MESSAGE("Running command: ");
|
||||||
MESSAGE(cmd);
|
MESSAGE(cmd);
|
||||||
|
// Writing command in cmd.log
|
||||||
|
{
|
||||||
|
std::ofstream flog(cmd_file.string());
|
||||||
|
flog << cmd << endl;
|
||||||
|
}
|
||||||
|
|
||||||
// Building arguments for QProcess
|
// Building arguments for QProcess
|
||||||
QString program = run_mesher_exe.string().c_str();
|
QString program = QString::fromStdString(s_program);
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments << "NETGEN3D";
|
for(auto arg : params){
|
||||||
arguments << mesh_file.string().c_str();
|
arguments << arg.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();
|
QString out_file = log_file.string().c_str();
|
||||||
QProcess myProcess;
|
QProcess myProcess;
|
||||||
|
myProcess.setProcessChannelMode(QProcess::MergedChannels);
|
||||||
myProcess.setStandardOutputFile(out_file);
|
myProcess.setStandardOutputFile(out_file);
|
||||||
|
|
||||||
myProcess.start(program, arguments);
|
myProcess.start(program, arguments);
|
||||||
// Waiting for process to finish (argument -1 make it wait until the end of
|
// Waiting for process to finish (argument -1 make it wait until the end of
|
||||||
// the process otherwise it just waits 30 seconds)
|
// the process otherwise it just waits 30 seconds)
|
||||||
myProcess.waitForFinished(-1);
|
bool finished = myProcess.waitForFinished(-1);
|
||||||
int ret = myProcess.exitStatus();
|
int ret = myProcess.exitCode();
|
||||||
|
|
||||||
if(ret != 0){
|
if(ret != 0 || !finished){
|
||||||
// Run crahed
|
// Run crahed
|
||||||
std::string msg = "Issue with command: \n";
|
std::string msg = "Issue with mesh_launcher: \n";
|
||||||
msg += "See log for more details: " + log_file.string() + "\n";
|
msg += "See log for more details: " + log_file.string() + "\n";
|
||||||
msg += cmd + "\n";
|
msg += cmd + "\n";
|
||||||
throw SALOME_Exception(msg);
|
throw SALOME_Exception(msg);
|
||||||
|
@ -163,6 +163,7 @@ bool NETGENPlugin_NETGEN_3D_SA::computeFillNewElementFile(
|
|||||||
int &Netgen_NbOfNodes
|
int &Netgen_NbOfNodes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
MESSAGE("Writting new elements")
|
||||||
Ng_Mesh* Netgen_mesh = ngLib.ngMesh();
|
Ng_Mesh* Netgen_mesh = ngLib.ngMesh();
|
||||||
|
|
||||||
int Netgen_NbOfNodesNew = Ng_GetNP(Netgen_mesh);
|
int Netgen_NbOfNodesNew = Ng_GetNP(Netgen_mesh);
|
||||||
@ -223,6 +224,7 @@ bool NETGENPlugin_NETGEN_3D_SA::Compute(
|
|||||||
std::string new_element_file,
|
std::string new_element_file,
|
||||||
bool output_mesh)
|
bool output_mesh)
|
||||||
{
|
{
|
||||||
|
MESSAGE("Compute");
|
||||||
// vector of nodes in which node index == netgen ID
|
// vector of nodes in which node index == netgen ID
|
||||||
vector< const SMDS_MeshNode* > nodeVec;
|
vector< const SMDS_MeshNode* > nodeVec;
|
||||||
NETGENPlugin_NetgenLibWrapper ngLib;
|
NETGENPlugin_NetgenLibWrapper ngLib;
|
||||||
@ -233,6 +235,7 @@ bool NETGENPlugin_NETGEN_3D_SA::Compute(
|
|||||||
|
|
||||||
// Changing netgen log_file putting it next to new_element_file
|
// 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");
|
fs::path netgen_log_file = fs::path(new_element_file).remove_filename() / fs::path("NETGEN.out");
|
||||||
|
MESSAGE("netgen ouput"<<netgen_log_file.string());
|
||||||
|
|
||||||
ngLib.setOutputFile(netgen_log_file.string());
|
ngLib.setOutputFile(netgen_log_file.string());
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ int main(int argc, char *argv[]){
|
|||||||
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 << " (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 << " (optional) NEW_ELEMENT_FILE: (out) contains elements and nodes added by the meshing" << 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;
|
std::cout << " (optional) OUTPUT_MESH_FILE: (out) MED File containing the mesh after the run of the mesher" << std::endl;
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
std::string mesher=argv[1];
|
std::string mesher=argv[1];
|
||||||
std::string input_mesh_file=argv[2];
|
std::string input_mesh_file=argv[2];
|
||||||
@ -89,6 +89,7 @@ int main(int argc, char *argv[]){
|
|||||||
output_mesh_file);
|
output_mesh_file);
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "Unknown mesher:" << mesher << std::endl;
|
std::cerr << "Unknown mesher:" << mesher << std::endl;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user