cout replaced by MESSAGE + clean up

This commit is contained in:
Yoann Audouin 2022-09-21 16:36:10 +02:00
parent b3018b01b0
commit 4264181864
4 changed files with 15 additions and 27 deletions

View File

@ -354,8 +354,8 @@ bool NETGENPlugin_NETGEN_2D_ONLY::RemoteCompute(SMESH_Mesh& aMesh,
+ output_mesh_file.string() + + output_mesh_file.string() +
" >> " + log_file.string(); " >> " + log_file.string();
std::cout << "Running command: " << std::endl; MESSAGE("Running command: ");
std::cout << cmd << std::endl; MESSAGE(cmd);
// Writing command in log // Writing command in log
std::ofstream flog(log_file.string()); std::ofstream flog(log_file.string());
@ -410,8 +410,8 @@ bool NETGENPlugin_NETGEN_2D_ONLY::RemoteCompute(SMESH_Mesh& aMesh,
} }
} }
if(nodeVec.at(nodeIndex) == nullptr){ if(nodeVec.at(nodeIndex) == nullptr){
std::cout << "Error could not identify id"; std::cerr << "Error could not identify id";
return false; return true;
} }
} }

View File

@ -627,8 +627,6 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
vector< const SMDS_MeshNode* >& nodeVec, vector< const SMDS_MeshNode* >& nodeVec,
NETGENPlugin_NetgenLibWrapper& ngLib) NETGENPlugin_NetgenLibWrapper& ngLib)
{ {
auto time0 = std::chrono::high_resolution_clock::now();
netgen::multithread.terminate = 0; netgen::multithread.terminate = 0;
netgen::Mesh* ngMesh = ngLib._ngMesh; netgen::Mesh* ngMesh = ngLib._ngMesh;
@ -691,7 +689,6 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
try try
{ {
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
auto time0 = std::chrono::high_resolution_clock::now();
ngLib.CalcLocalH(ngMesh); ngLib.CalcLocalH(ngMesh);
err = ngLib.GenerateMesh(occgeo, startWith, endWith); err = ngLib.GenerateMesh(occgeo, startWith, endWith);
@ -725,9 +722,6 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
str << " at " << netgen::multithread.task; str << " at " << netgen::multithread.task;
error(str); error(str);
} }
auto time1 = std::chrono::high_resolution_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time1-time0);
std::cout << "Time for seq:compute: " << elapsed.count() * 1e-9 << std::endl;
int Netgen_NbOfNodesNew = Ng_GetNP(Netgen_mesh); int Netgen_NbOfNodesNew = Ng_GetNP(Netgen_mesh);
int Netgen_NbOfTetra = Ng_GetNE(Netgen_mesh); int Netgen_NbOfTetra = Ng_GetNE(Netgen_mesh);
@ -774,10 +768,6 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
} }
} }
} }
auto time2 = std::chrono::high_resolution_clock::now();
elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time2-time1);
std::cout << "Time for seq:compute: " << elapsed.count() * 1e-9 << std::endl;
return !err; return !err;
} }
@ -903,14 +893,12 @@ double NETGENPlugin_NETGEN_3D::GetProgress() const
strncmp( netgen::multithread.task, volMeshing, 3 ) == 0 )) strncmp( netgen::multithread.task, volMeshing, 3 ) == 0 ))
{ {
res = 0.001 + meshingRatio * netgen::multithread.percent / 100.; res = 0.001 + meshingRatio * netgen::multithread.percent / 100.;
//cout << netgen::multithread.task << " " <<_progressTic << "-" << netgen::multithread.percent << endl;
} }
else // different otimizations else // different otimizations
{ {
if ( _progressByTic < 0. ) if ( _progressByTic < 0. )
((NETGENPlugin_NETGEN_3D*)this)->_progressByTic = meshingRatio / _progressTic; ((NETGENPlugin_NETGEN_3D*)this)->_progressByTic = meshingRatio / _progressTic;
res = _progressByTic * _progressTic; res = _progressByTic * _progressTic;
//cout << netgen::multithread.task << " " << _progressTic << " " << res << endl;
} }
return Min ( res, 0.98 ); return Min ( res, 0.98 );
} }

View File

@ -226,7 +226,6 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh,
//Writing hypo //Writing hypo
netgen_params aParams; netgen_params aParams;
std::cout << _hypParameters << std::endl;
fillParameters(_hypParameters, aParams); fillParameters(_hypParameters, aParams);
exportNetgenParams(param_file.string(), aParams); exportNetgenParams(param_file.string(), aParams);
@ -258,8 +257,8 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh,
flog << cmd << endl; flog << cmd << endl;
flog << endl; flog << endl;
} }
//std::cout << "Running command: " << std::endl; MESSAGE("Running command: ");
//std::cout << cmd << std::endl; MESSAGE(cmd);
// Building arguments for QProcess // Building arguments for QProcess
@ -283,9 +282,9 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh,
if(ret != 0){ if(ret != 0){
// Run crahed // Run crahed
std::cout << "Issue with command: " << std::endl; std::cerr << "Issue with command: " << std::endl;
std::cout << "See log for more details: " << log_file.string() << std::endl; std::cerr << "See log for more details: " << log_file.string() << std::endl;
std::cout << cmd << std::endl; std::cerr << cmd << std::endl;
return false; return false;
} }

View File

@ -214,19 +214,20 @@ int NETGENPlugin_NETGEN_3D_SA::run(const std::string input_mesh_file,
// Setting number of threads for netgen // Setting number of threads for netgen
myParams.nbThreads = nbThreads; myParams.nbThreads = nbThreads;
std::cout << "Meshing with netgen3d" << std::endl; MESSAGE("Meshing with netgen3d");
int ret = Compute(myShape, *myMesh, myParams, int ret = Compute(myShape, *myMesh, myParams,
new_element_file, element_orientation_file, new_element_file, element_orientation_file,
!output_mesh_file.empty()); !output_mesh_file.empty());
if(ret){ if(ret){
std::cout << "Meshing failed" << std::endl; std::cerr << "Meshing failed" << std::endl;
return ret; return ret;
} }
if(!output_mesh_file.empty()){ if(!output_mesh_file.empty()){
exportMesh(output_mesh_file, *myMesh, mesh_name); std::string meshName = "MESH";
exportMesh(output_mesh_file, *myMesh, meshName);
} }
return ret; return ret;
@ -250,7 +251,7 @@ bool NETGENPlugin_NETGEN_3D_SA::getSurfaceElements(
{ {
// Setting all element orientation to false if there no element orientation file // Setting all element orientation to false if there no element orientation file
if(_element_orientation_file.empty()){ if(_element_orientation_file.empty()){
std::cout << "No element orientation file" << std::endl; MESSAGE("No element orientation file");
SMDS_ElemIteratorPtr iteratorElem = meshDS->elementsIterator(SMDSAbs_Face); SMDS_ElemIteratorPtr iteratorElem = meshDS->elementsIterator(SMDSAbs_Face);
while ( iteratorElem->more() ) // loop on elements on a geom face while ( iteratorElem->more() ) // loop on elements on a geom face
@ -260,7 +261,7 @@ bool NETGENPlugin_NETGEN_3D_SA::getSurfaceElements(
elemOrientation[elem->GetID()] = false; elemOrientation[elem->GetID()] = false;
} }
} else { } else {
std::cout << "Reading from elements from file: " << _element_orientation_file << std::endl; MESSAGE("Reading from elements from file: " << _element_orientation_file);
std::ifstream df(_element_orientation_file, ios::binary|ios::in); std::ifstream df(_element_orientation_file, ios::binary|ios::in);
int nbElement; int nbElement;
bool orient; bool orient;