Adding number of thread to netgen hypo + windows corrections

This commit is contained in:
Yoann Audouin 2022-10-03 18:11:35 +02:00
parent 3d82214289
commit fbfd90a1f8
5 changed files with 12 additions and 28 deletions

View File

@ -32,9 +32,6 @@
#include "NETGENPlugin_Hypothesis.hxx" #include "NETGENPlugin_Hypothesis.hxx"
// TODO: remove use of netgen_param
#include "NETGENPlugin_DriverParam.hxx"
#include <SMDS_MeshElement.hxx> #include <SMDS_MeshElement.hxx>
#include <SMDS_MeshNode.hxx> #include <SMDS_MeshNode.hxx>
#include <SMESHDS_Mesh.hxx> #include <SMESHDS_Mesh.hxx>

View 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 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.log");
//TODO: Handle variable mesh_name
std::string mesh_name = "MESH"; std::string mesh_name = "MESH";
{ {
@ -239,20 +238,22 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh,
} }
// Calling run_mesher // Calling run_mesher
// TODO: check if we need to handle the .exe for windows
std::string cmd; std::string cmd;
fs::path run_mesher_exe = fs::path run_mesher_exe =
fs::path(std::getenv("NETGENPLUGIN_ROOT_DIR"))/ fs::path(std::getenv("NETGENPLUGIN_ROOT_DIR"))/
fs::path("bin")/ fs::path("bin")/
fs::path("salome")/ fs::path("salome")/
#ifdef WIN32
fs::path("NETGENPlugin_Runner.exe");
#else
fs::path("NETGENPlugin_Runner"); fs::path("NETGENPlugin_Runner");
#endif
cmd = run_mesher_exe.string() + cmd = run_mesher_exe.string() +
" NETGEN3D " + mesh_file.string() + " " " NETGEN3D " + mesh_file.string() + " "
+ shape_file.string() + " " + shape_file.string() + " "
+ param_file.string() + " " + param_file.string() + " "
+ element_orientation_file.string() + " " + element_orientation_file.string() + " "
+ std::to_string(aMesh.GetMesherNbThreads()) + " "
+ new_element_file.string() + " " + new_element_file.string() + " "
+ "NONE"; + "NONE";
// Writing command in log // Writing command in log
@ -273,7 +274,6 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh,
arguments << shape_file.c_str(); arguments << shape_file.c_str();
arguments << param_file.c_str(); arguments << param_file.c_str();
arguments << element_orientation_file.c_str(); arguments << element_orientation_file.c_str();
arguments << std::to_string(aMesh.GetMesherNbThreads()).c_str();
arguments << new_element_file.c_str(); arguments << new_element_file.c_str();
arguments << "NONE"; arguments << "NONE";
QString out_file = log_file.c_str(); QString out_file = log_file.c_str();

View 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 hypo_file,
const std::string element_orientation_file, const std::string element_orientation_file,
const std::string new_element_file, const std::string new_element_file,
const std::string output_mesh_file, const std::string output_mesh_file)
int nbThreads)
{ {
_element_orientation_file = element_orientation_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); importNetgenParams(hypo_file, myParams);
fillHyp(myParams, &gen); fillHyp(myParams, &gen);
// Setting number of threads for netgen
myParams.nbThreads = nbThreads;
MESSAGE("Meshing with netgen3d"); MESSAGE("Meshing with netgen3d");
int ret = Compute(myShape, *myMesh, myParams, int ret = Compute(myShape, *myMesh, myParams,

View File

@ -57,10 +57,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D_SA: public NETGENPlugin_NETGEN_
const std::string hypo_file, const std::string hypo_file,
const std::string element_orientation_file, const std::string element_orientation_file,
const std::string new_element_file, const std::string new_element_file,
const std::string output_mesh_file, const std::string output_mesh_file);
int nbThreads);
protected: protected:

View File

@ -42,11 +42,11 @@
*/ */
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
if(argc!=9||(argc==2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help")==0))){ if(argc!=8||(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; std::cout << "Error in number of arguments "<< argc-1<<" given expected 7" <<std::endl;
std::cout << "Syntax:"<<std::endl; std::cout << "Syntax:"<<std::endl;
std::cout << "run_mesher MESHER INPUT_MESH_FILE SHAPE_FILE HYPO_FILE" << 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 << " NEW_ELEMENT_FILE OUTPUT_MESH_FILE" << std::endl;
std::cout << std::endl; std::cout << std::endl;
std::cout << " Set argument to NONE to ignore them " << 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 << " 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 << " 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 << " (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) 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 0;
@ -67,9 +66,8 @@ int main(int argc, char *argv[]){
std::string shape_file=argv[3]; std::string shape_file=argv[3];
std::string hypo_file=argv[4]; std::string hypo_file=argv[4];
std::string element_orientation_file=argv[5]; std::string element_orientation_file=argv[5];
int nbThreads=std::stoi(argv[6]); std::string new_element_file=argv[6];
std::string new_element_file=argv[7]; std::string output_mesh_file=argv[7];
std::string output_mesh_file=argv[8];
//std::string thing; //std::string thing;
//std::cin >> thing; //std::cin >> thing;
@ -82,18 +80,13 @@ int main(int argc, char *argv[]){
new_element_file = ""; new_element_file = "";
if (mesher=="NETGEN3D"){ if (mesher=="NETGEN3D"){
auto begin = std::chrono::high_resolution_clock::now();
NETGENPlugin_NETGEN_3D_SA myplugin; NETGENPlugin_NETGEN_3D_SA myplugin;
myplugin.run(input_mesh_file, myplugin.run(input_mesh_file,
shape_file, shape_file,
hypo_file, hypo_file,
element_orientation_file, element_orientation_file,
new_element_file, new_element_file,
output_mesh_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;
} else { } else {
std::cerr << "Unknown mesher:" << mesher << std::endl; std::cerr << "Unknown mesher:" << mesher << std::endl;
} }