From ff505f1e410578c257a9e8b4bc5ec6af19f5f1d2 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Tue, 2 Apr 2024 21:58:58 +0200 Subject: [PATCH 1/2] Add range check in table --- libsrc/general/table.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libsrc/general/table.hpp b/libsrc/general/table.hpp index a62277fa..54f5be31 100644 --- a/libsrc/general/table.hpp +++ b/libsrc/general/table.hpp @@ -169,6 +169,7 @@ public: /// Inserts element acont into row i. BASE-based. Does not test if already used, assumes to have enough memory inline void AddSave (int i, const T & acont) { + NETGEN_CHECK_RANGE(i, BASE, data.Size()+BASE); ((T*)data[i-BASE].col)[data[i-BASE].size] = acont; data[i-BASE].size++; } From 78a3d24fdeeba9256f78894a998d0be6112e3101 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Tue, 2 Apr 2024 21:59:27 +0200 Subject: [PATCH 2/2] Do bad element Optimization only when requested --- libsrc/meshing/meshfunc.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libsrc/meshing/meshfunc.cpp b/libsrc/meshing/meshfunc.cpp index 0b17572c..c1a23880 100644 --- a/libsrc/meshing/meshfunc.cpp +++ b/libsrc/meshing/meshfunc.cpp @@ -659,13 +659,16 @@ namespace netgen // optimize only bad elements first optmesh.SetMinBadness(1000.); + bool do_split = mp.optimize3d.find('d') != string::npos; + bool do_swap = mp.optimize3d.find('s') != string::npos; + bool do_swap2 = mp.optimize3d.find('t') != string::npos; for(auto i : Range(mp.optsteps3d)) { auto [total_badness, max_badness, bad_els] = optmesh.UpdateBadness(); if(bad_els==0) break; - optmesh.SplitImprove(); - optmesh.SwapImprove(); - optmesh.SwapImprove2(); + if(do_split) optmesh.SplitImprove(); + if(do_swap) optmesh.SwapImprove(); + if(do_swap2) optmesh.SwapImprove2(); } // Now optimize all elements