diff --git a/libsrc/meshing/improve3.cpp b/libsrc/meshing/improve3.cpp index beb3cd5a..d9ff8c61 100644 --- a/libsrc/meshing/improve3.cpp +++ b/libsrc/meshing/improve3.cpp @@ -897,7 +897,7 @@ bool MeshOptimize3d :: SwapImproveEdge (Mesh & mesh, OPTIMIZEGOAL goal, const NgBitArray * working_elements, TABLE & elementsonnode, INDEX_3_HASHTABLE & faces, - PointIndex pi1, PointIndex pi2, bool check_only + PointIndex pi1, PointIndex pi2 ) { PointIndex pi3(PointIndex::INVALID), pi4(PointIndex::INVALID), @@ -1100,7 +1100,6 @@ bool MeshOptimize3d :: SwapImproveEdge (Mesh & mesh, OPTIMIZEGOAL goal, // (*mycout) << "3->2 " << flush; // (*testout) << "3->2 conversion" << endl; do_swap = true; - if(check_only) return do_swap; /* @@ -1329,7 +1328,6 @@ bool MeshOptimize3d :: SwapImproveEdge (Mesh & mesh, OPTIMIZEGOAL goal, { // (*mycout) << "4->4 " << flush; do_swap = true; - if(check_only) return do_swap; // (*testout) << "4->4 conversion" << "\n"; /* (*testout) << "bad1 = " << bad1 @@ -1592,7 +1590,6 @@ bool MeshOptimize3d :: SwapImproveEdge (Mesh & mesh, OPTIMIZEGOAL goal, { // (*mycout) << nsuround << "->" << 2 * (nsuround-2) << " " << flush; do_swap = true; - if(check_only) return do_swap; for (int k = bestl+1; k <= nsuround + bestl - 2; k++) { @@ -1656,8 +1653,6 @@ void MeshOptimize3d :: SwapImprove (Mesh & mesh, OPTIMIZEGOAL goal, int np = mesh.GetNP(); int ne = mesh.GetNE(); - mesh.BoundaryEdge (1,2); // ensure the boundary-elements table is built - // contains at least all elements at node TABLE elementsonnode(np); @@ -1669,6 +1664,8 @@ void MeshOptimize3d :: SwapImprove (Mesh & mesh, OPTIMIZEGOAL goal, const char * savetask = multithread.task; multithread.task = "Swap Improve"; + // mesh.CalcSurfacesOfNode (); + INDEX_3_HASHTABLE faces(mesh.GetNOpenElements()/3 + 2); if (goal == OPT_CONFORM) { @@ -1696,52 +1693,42 @@ void MeshOptimize3d :: SwapImprove (Mesh & mesh, OPTIMIZEGOAL goal, Array> edges; BuildEdgeList(mesh, elementsonnode, edges); - Array candidate_edges(edges.Size()); - std::atomic improvement_counter(0); - tloop.Start(); - ParallelForRange(Range(edges), [&] (auto myrange) - { - for(auto i : myrange) - { - if (multithread.terminate) - break; - - auto [pi0, pi1] = edges[i]; - if(SwapImproveEdge (mesh, goal, working_elements, elementsonnode, faces, pi0, pi1, true)) - candidate_edges[improvement_counter++] = i; - } - }); - // Sequential version: - /* - for(auto i : edges.Range()) + for (auto [pi1, pi2] : edges) { if (multithread.terminate) break; - - auto [pi0, pi1] = edges[i]; - if(SwapImproveEdge (mesh, goal, working_elements, elementsonnode, faces, pi0, pi1, true)) - candidate_edges[improvement_counter++] = i; + cnt += SwapImproveEdge (mesh, goal, working_elements, elementsonnode, faces, pi1, pi2); } - */ - - auto edges_with_improvement = candidate_edges.Part(0, improvement_counter.load()); - QuickSort(edges_with_improvement); - - for(auto ei : edges_with_improvement) - { - auto [pi0,pi1] = edges[ei]; - if(SwapImproveEdge (mesh, goal, working_elements, elementsonnode, faces, pi0, pi1, false)) - cnt++; - } - tloop.Stop(); PrintMessage (5, cnt, " swaps performed"); + + + + mesh.Compress (); + /* + if (goal == OPT_QUALITY) + { + bad1 = CalcTotalBad (mesh.Points(), mesh.VolumeElements()); + // (*testout) << "Total badness = " << bad1 << endl; + } + */ + + /* + for (i = 1; i <= GetNE(); i++) + if (volelements.Get(i)[0]) + if (!mesh.LegalTet (volelements.Get(i))) + { + cout << "detected illegal tet, 2" << endl; + (*testout) << "detected illegal tet1: " << i << endl; + } + */ + multithread.task = savetask; } diff --git a/libsrc/meshing/improve3.hpp b/libsrc/meshing/improve3.hpp index 36500d00..798db3d8 100644 --- a/libsrc/meshing/improve3.hpp +++ b/libsrc/meshing/improve3.hpp @@ -27,7 +27,7 @@ public: void SplitImprove (Mesh & mesh, OPTIMIZEGOAL goal = OPT_QUALITY); - bool SwapImproveEdge (Mesh & mesh, OPTIMIZEGOAL goal, const NgBitArray * working_elements, TABLE & elementsonnode, INDEX_3_HASHTABLE & faces, PointIndex pi1, PointIndex pi2, bool check_only=false); + bool SwapImproveEdge (Mesh & mesh, OPTIMIZEGOAL goal, const NgBitArray * working_elements, TABLE & elementsonnode, INDEX_3_HASHTABLE & faces, PointIndex pi1, PointIndex pi2); void SwapImprove (Mesh & mesh, OPTIMIZEGOAL goal = OPT_QUALITY, const NgBitArray * working_elements = NULL); void SwapImproveSurface (Mesh & mesh, OPTIMIZEGOAL goal = OPT_QUALITY,