Abort the meshing process in multithreading mode
Hello,
When dealing with the multithreaded dynamic library, i'd like to abort the 1d or 2d meshing stages at any moment. To do so, in my program I call msg::Error("Abort")
to increase the number of error and I modified the gmsh source code as follow (same in mesh1D and mesh2D):
volatile bool flag = false;
#pragma omp parallel for schedule(dynamic) num_threads(nthreads)
for(size_t K = 0; K < temp.size(); K++) {
if(isError) continue;
int localPending = 0;
GEdge *ed = temp[K];
if(ed->meshStatistics.status == GEdge::PENDING) {
ed->mesh(true);
#pragma omp atomic capture
{
++nPending;
localPending = nPending;
}
}
if(!nIter) Msg::ProgressMeter(localPending, false, "Meshing 1D...");
#pragma omp critical
if(Msg::GetErrorCount()) {
isError = true;
}
}
if(!nPending || flag) break;
if(nIter++ > CTX::instance()->mesh.maxRetries) break;
}
unfortunatly those modifications make gmsh library crash. I also tried to declare flag
as shared in the parallel loop. Any idea ?
Best regards
Edited by Hamid