From 249d78508433a6e03535a3320f6d62cd4aa0bae3 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Thu, 31 Oct 2019 15:17:28 +0100 Subject: [PATCH] progress bars for find edges, mesh surface,... --- libsrc/meshing/basegeom.cpp | 9 ++++++++- libsrc/meshing/improve3.cpp | 12 ++++++------ libsrc/meshing/meshfunc.cpp | 10 +++++++--- libsrc/meshing/smoothing3.cpp | 10 +++++----- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/libsrc/meshing/basegeom.cpp b/libsrc/meshing/basegeom.cpp index 0e5fa405..eae2031e 100644 --- a/libsrc/meshing/basegeom.cpp +++ b/libsrc/meshing/basegeom.cpp @@ -171,6 +171,7 @@ namespace netgen auto boundary = face.GetBoundary(facebndnr); for(auto enr : Range(boundary)) { + multithread.percent = 100. * ((double(enr)/boundary.Size() + facebndnr)/face.GetNBoundaries() + facenr)/faces.Size(); const auto& oriented_edge = *boundary[enr]; auto edgenr = GetEdgeIndex(oriented_edge); const auto& edge = edges[edgenr]; @@ -298,10 +299,13 @@ namespace netgen const MeshingParameters& mparam) const { static Timer t1("Surface Meshing"); RegionTimer regt(t1); + const char* savetask = multithread.task; + multithread.task = "Mesh Surface"; Array glob2loc(mesh.GetNP()); for(auto k : Range(faces)) { + multithread.percent = 100. * k/faces.Size(); const auto& face = *faces[k]; auto bb = face.GetBoundingBox(); bb.Increase(bb.Diam()/10); @@ -354,6 +358,7 @@ namespace netgen mesh.SurfaceElements()[i].SetIndex(k+1); } } + multithread.task = savetask; } void NetgenGeometry :: OptimizeSurface(Mesh& mesh, const MeshingParameters& mparam) const @@ -366,9 +371,11 @@ namespace netgen auto meshopt = MeshOptimize2d(mesh); for(auto i : Range(mparam.optsteps2d)) { - PrintMessage(2, "Optimization step ", i); + PrintMessage(3, "Optimization step ", i); + int innerstep = 0; for(auto optstep : mparam.optimize2d) { + multithread.percent = 100. * (double(innerstep++)/mparam.optimize2d.size() + i)/mparam.optsteps2d; switch(optstep) { case 's': diff --git a/libsrc/meshing/improve3.cpp b/libsrc/meshing/improve3.cpp index 7138e0ab..d9cc3534 100644 --- a/libsrc/meshing/improve3.cpp +++ b/libsrc/meshing/improve3.cpp @@ -183,7 +183,7 @@ void MeshOptimize3d :: CombineImproveSequential (Mesh & mesh, // mesh.CalcSurfacesOfNode (); const char * savetask = multithread.task; - multithread.task = "Combine Improve"; + multithread.task = "Optimize Volume: Combine Improve"; double totalbad = 0; @@ -435,7 +435,7 @@ void MeshOptimize3d :: CombineImprove (Mesh & mesh, // mesh.CalcSurfacesOfNode (); const char * savetask = multithread.task; - multithread.task = "Combine Improve"; + multithread.task = "Optimize Volume: Combine Improve"; tbad.Start(); @@ -712,7 +712,7 @@ void MeshOptimize3d :: SplitImprove (Mesh & mesh, Array elerrs(ne); const char * savetask = multithread.task; - multithread.task = "Split Improve"; + multithread.task = "Optimize Volume: Split Improve"; PrintMessage (3, "SplitImprove"); (*testout) << "start SplitImprove" << "\n"; @@ -826,7 +826,7 @@ void MeshOptimize3d :: SplitImproveSequential (Mesh & mesh, illegaltet.Clear(); const char * savetask = multithread.task; - multithread.task = "Split Improve"; + multithread.task = "Optimize Volume: Split Improve"; PrintMessage (3, "SplitImprove"); (*testout) << "start SplitImprove" << "\n"; @@ -1121,7 +1121,7 @@ void MeshOptimize3d :: SwapImproveSequential (Mesh & mesh, OPTIMIZEGOAL goal, (*testout) << "\n" << "Start SwapImprove" << endl; const char * savetask = multithread.task; - multithread.task = "Swap Improve"; + multithread.task = "Optimize Volume: Swap Improve"; // mesh.CalcSurfacesOfNode (); @@ -2617,7 +2617,7 @@ void MeshOptimize3d :: SwapImprove (Mesh & mesh, OPTIMIZEGOAL goal, (*testout) << "\n" << "Start SwapImprove" << endl; const char * savetask = multithread.task; - multithread.task = "Swap Improve"; + multithread.task = "Optimize Volume: Swap Improve"; INDEX_3_HASHTABLE faces(mesh.GetNOpenElements()/3 + 2); if (goal == OPT_CONFORM) diff --git a/libsrc/meshing/meshfunc.cpp b/libsrc/meshing/meshfunc.cpp index 4b92ed8f..f21e0812 100644 --- a/libsrc/meshing/meshfunc.cpp +++ b/libsrc/meshing/meshfunc.cpp @@ -646,6 +646,8 @@ namespace netgen { static Timer t("OptimizeVolume"); RegionTimer reg(t); RegionTaskManager rtm(mp.parallel_meshing ? mp.nthreads : 0); + const char* savetask = multithread.task; + multithread.task = "Optimize Volume"; int i; @@ -663,7 +665,7 @@ namespace netgen */ mesh3d.CalcSurfacesOfNode(); - for (i = 1; i <= mp.optsteps3d; i++) + for (auto i : Range(mp.optsteps3d)) { if (multithread.terminate) break; @@ -672,12 +674,13 @@ namespace netgen // teterrpow = mp.opterrpow; // for (size_t j = 1; j <= strlen(mp.optimize3d); j++) - for (size_t j = 1; j <= mp.optimize3d.length(); j++) + for (auto j : Range(mp.optimize3d.size())) { + multithread.percent = 100.* (double(j)/mp.optimize3d.size() + i)/mp.optsteps3d; if (multithread.terminate) break; - switch (mp.optimize3d[j-1]) + switch (mp.optimize3d[j]) { case 'c': optmesh.CombineImprove(mesh3d, OPT_REST); break; case 'd': optmesh.SplitImprove(mesh3d); break; @@ -698,6 +701,7 @@ namespace netgen MeshQuality3d (mesh3d); } + multithread.task = savetask; return MESHING3_OK; } diff --git a/libsrc/meshing/smoothing3.cpp b/libsrc/meshing/smoothing3.cpp index de0b6cb5..e84a18ba 100644 --- a/libsrc/meshing/smoothing3.cpp +++ b/libsrc/meshing/smoothing3.cpp @@ -1164,7 +1164,7 @@ void Mesh :: ImproveMesh (const CSG eometry & geometry, OPTIMIZEGOAL goal) } const char * savetask = multithread.task; - multithread.task = "Smooth Mesh"; + multithread.task = "Optimize Volume: Smooth Mesh"; TABLE surfelementsonpoint(points.Size()); @@ -1398,7 +1398,7 @@ void Mesh :: ImproveMeshSequential (const MeshingParameters & mp, OPTIMIZEGOAL g const char * savetask = multithread.task; - multithread.task = "Smooth Mesh"; + multithread.task = "Optimize Volume: Smooth Mesh"; for (PointIndex pi : points.Range()) if ( (*this)[pi].Type() == INNERPOINT ) @@ -1524,7 +1524,7 @@ void Mesh :: ImproveMesh (const MeshingParameters & mp, OPTIMIZEGOAL goal) } const char * savetask = multithread.task; - multithread.task = "Smooth Mesh"; + multithread.task = "Optimize Volume: Smooth Mesh"; topt.Start(); int counter = 0; @@ -1659,7 +1659,7 @@ void Mesh :: ImproveMeshJacobian (const MeshingParameters & mp, const char * savetask = multithread.task; - multithread.task = "Smooth Mesh Jacobian"; + multithread.task = "Optimize Volume: Smooth Mesh Jacobian"; // for (PointIndex pi = points.Begin(); i < points.End(); pi++) for (PointIndex pi : points.Range()) @@ -1815,7 +1815,7 @@ void Mesh :: ImproveMeshJacobianOnSurface (const MeshingParameters & mp, const char * savetask = multithread.task; - multithread.task = "Smooth Mesh Jacobian"; + multithread.task = "Optimize Volume: Smooth Mesh Jacobian"; // for (PointIndex pi = points.Begin(); pi <= points.End(); pi++) for (PointIndex pi : points.Range())