diff --git a/libsrc/meshing/improve2.hpp b/libsrc/meshing/improve2.hpp index 23d53bfd..315127c6 100644 --- a/libsrc/meshing/improve2.hpp +++ b/libsrc/meshing/improve2.hpp @@ -1,15 +1,42 @@ #ifndef FILE_IMPROVE2 #define FILE_IMPROVE2 +inline void AppendEdges( const Element2d & elem, PointIndex pi, Array> & edges ) +{ + for (int j = 0; j < 3; j++) + { + PointIndex pi0 = elem[j]; + PointIndex pi1 = elem[(j+1)%3]; + if (pi1 < pi0) Swap(pi0, pi1); + if(pi0==pi) + edges.Append(std::make_tuple(pi0, pi1)); + } +} + +inline void AppendEdges( const Element & elem, PointIndex pi, Array> & edges ) +{ + static constexpr int tetedges[6][2] = + { { 0, 1 }, { 0, 2 }, { 0, 3 }, + { 1, 2 }, { 1, 3 }, { 2, 3 } }; + + if(elem.flags.fixed) + return; + for (int j = 0; j < 6; j++) + { + PointIndex pi0 = elem[tetedges[j][0]]; + PointIndex pi1 = elem[tetedges[j][1]]; + if (pi1 < pi0) Swap(pi0, pi1); + if(pi0==pi) + edges.Append(std::make_tuple(pi0, pi1)); + } +} + template void BuildEdgeList( const Mesh & mesh, const Table & elementsonnode, Array> & edges ) { + static_assert(is_same_v||is_same_v, "Invalid type for TINDEX"); static Timer tbuild_edges("Build edges"); RegionTimer reg(tbuild_edges); - static constexpr int tetedges[6][2] = - { { 0, 1 }, { 0, 2 }, { 0, 3 }, - { 1, 2 }, { 1, 3 }, { 2, 3 } }; - int ntasks = 4*ngcore::TaskManager::GetMaxThreads(); Array>> task_edges(ntasks); @@ -26,29 +53,7 @@ void BuildEdgeList( const Mesh & mesh, const Table & element const auto & elem = mesh[ei]; if (elem.IsDeleted()) continue; - static_assert(is_same_v||is_same_v, "Invalid type for TINDEX"); - if constexpr(is_same_v) - { - for (int j = 0; j < 3; j++) - { - PointIndex pi0 = elem[j]; - PointIndex pi1 = elem[(j+1)%3]; - if (pi1 < pi0) Swap(pi0, pi1); - if(pi0==pi) - local_edges.Append(std::make_tuple(pi0, pi1)); - } - } - else if constexpr(is_same_v) - { - for (int j = 0; j < 6; j++) - { - PointIndex pi0 = elem[tetedges[j][0]]; - PointIndex pi1 = elem[tetedges[j][1]]; - if (pi1 < pi0) Swap(pi0, pi1); - if(pi0==pi) - local_edges.Append(std::make_tuple(pi0, pi1)); - } - } + AppendEdges(elem, pi, local_edges); } QuickSort(local_edges); diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 2feb13ec..e23c607f 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -2139,6 +2139,8 @@ namespace netgen [&](auto & table, ElementIndex ei) { const Element & el = (*this)[ei]; + if(el.IsDeleted()) + return; if (dom == 0 || dom == el.GetIndex()) { if (el.GetNP() == 4) @@ -6574,6 +6576,8 @@ namespace netgen [&](auto & table, ElementIndex ei) { const auto & el = (*this)[ei]; + if(el.IsDeleted()) + return; for (PointIndex pi : el.PNums()) if(free_points[pi]) @@ -6585,6 +6589,8 @@ namespace netgen [&](auto & table, ElementIndex ei) { const auto & el = (*this)[ei]; + if(el.IsDeleted()) + return; for (PointIndex pi : el.PNums()) table.Add (pi, ei);