aParams.meshsizefilename = hyp->GetMeshSizeFile();
#else
// const char*
- aParams.meshsizefilename = hyp->GetMeshSizeFile().empty() ? 0 : hyp->GetMeshSizeFile().c_str();
+ aParams.meshsizefilename = hyp->GetMeshSizeFile();
#endif
#ifdef NETGEN_V6
aParams.closeedgefac = 2;
+ shape_file.string() + " "
+ param_file.string() + " "
+ element_orientation_file.string() + " "
+ + std::to_string(aMesh.GetMesherNbThreads()) + " "
+ new_element_file.string() + " "
+ std::to_string(0) + " "
+ output_mesh_file.string() +
#ifdef NETGEN_V6
//netgen::mparam.nthreads = std::thread::hardware_concurrency();
- netgen::mparam.nthreads = 2;
- //netgen::mparam.parallel_meshing = false;
+ netgen::mparam.nthreads = aParams.nbThreads;
+ netgen::mparam.parallel_meshing = aParams.nbThreads > 1;
if ( getenv( "SALOME_NETGEN_DISABLE_MULTITHREADING" ))
#else
// const char*
- netgen::mparam.meshsizefilename= aParams.meshsizefilename ? 0 : aParams.meshsizefilename.c_str();
+ netgen::mparam.meshsizefilename= aParams.meshsizefilename.empty() ? 0 : aParams.meshsizefilename.c_str();
#endif
}
const std::string element_orientation_file,
const std::string new_element_file,
bool output_mesh,
- const std::string output_mesh_file)
+ const std::string output_mesh_file,
+ int nbThreads)
{
auto time0 = std::chrono::high_resolution_clock::now();
// Importing mesh
auto time3 = std::chrono::high_resolution_clock::now();
elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time3-time2);
std::cout << "Time for import_netgen_param: " << elapsed.count() * 1e-9 << std::endl;
+ // Setting number of threads for netgen
+ myParams.nbThreads = nbThreads;
std::cout << "Meshing with netgen3d" << std::endl;
int ret = netgen3d_internal(myShape, *myMesh, myParams,
return true;
-}
\ No newline at end of file
+}
const std::string element_orienation_file,
const std::string new_element_file,
bool output_mesh,
- const std::string output_mesh_file);
+ const std::string output_mesh_file,
+ int nbThreads);
//TODO: Tmp function replace by real error handling
int error(int error_type, std::string msg);
// Params from NETGEN2D
bool has_LengthFromEdges_hyp=false;
+
+ // Number of threads for the mesher
+ int nbThreads;
};
void print_netgen_params(netgen_params& aParams);
"element_orient.dat",
"new_element.dat",
true,
- "box_with3D.med");
+ "box_with3D.med",
+ 1);
// TODO: Check result
}
*/
int main(int argc, char *argv[]){
- if(argc!=9||(argc==2 && (argv[1] == "-h" || argv[1]=="--help"))){
+ if(argc!=10||(argc==2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help")==0))){
std::cout << "Error in number of argument"<<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 NEW_ELEMENT_FILE OUTPUT_MESH_FILE" << std::endl;
+ std::cout << " ELEM_ORIENT_FILE NB_THREADS" << std::endl;
+ std::cout << " NEW_ELEMENT_FILE OUTPUT_MESH_FILE" << std::endl;
std::cout << std::endl;
std::cout << "Args:" << std::endl;
std::cout << " MESHER: mesher to use from (NETGEN3D, NETGEN2D)" << 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 << " 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 << " NEW_ELEMENT_FILE: (out) contains elements and nodes added by the meshing" << std::endl;
std::cout << " OUTPUT_MESH: If !=0 will export mesh into OUTPUT_MESH_FILE " << std::endl;
std::cout << " OUTPUT_MESH_FILE: MED File containing the mesh after the run of the mesher" << std::endl;
std::string shape_file=argv[3];
std::string hypo_file=argv[4];
std::string element_orientation_file=argv[5];
- std::string new_element_file=argv[6];
- bool output_mesh = std::stoi(argv[7]) != 0;
- std::string output_mesh_file=argv[8];
+ int nbThreads=std::stoi(argv[6]);
+ std::string new_element_file=argv[7];
+ bool output_mesh = std::stoi(argv[8]) != 0;
+ std::string output_mesh_file=argv[9];
if (mesher=="test"){
std::cout << "Running tests" << std::endl;
element_orientation_file,
new_element_file,
output_mesh,
- 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;