From 99e001fc4c2d908942151ca388011ef460694652 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Tue, 11 May 2021 18:21:40 +0200 Subject: [PATCH] TABLE -> Table --- libsrc/include/nginterface_v2_impl.hpp | 6 ++-- libsrc/interface/nginterface.cpp | 2 +- libsrc/meshing/topology.cpp | 42 +++++++++----------------- libsrc/meshing/topology.hpp | 8 ++--- 4 files changed, 22 insertions(+), 36 deletions(-) diff --git a/libsrc/include/nginterface_v2_impl.hpp b/libsrc/include/nginterface_v2_impl.hpp index 645eb080..b63a0462 100644 --- a/libsrc/include/nginterface_v2_impl.hpp +++ b/libsrc/include/nginterface_v2_impl.hpp @@ -271,18 +271,18 @@ template <> NGX_INLINE DLL_HEADER const Ng_Node<0> Ngx_Mesh :: GetNode<0> (int v node.elements.ne = ia.Size(); node.elements.ptr = (int*)&ia[0]; - NgFlatArray bia = mesh->GetTopology().GetVertexSegments(vnr); + auto bia = mesh->GetTopology().GetVertexSegments(vnr); node.bnd_elements.ne = bia.Size(); node.bnd_elements.ptr = (int*)&bia[0]; break; } case 1: { - NgFlatArray ia = mesh->GetTopology().GetVertexSegments(vnr); + auto ia = mesh->GetTopology().GetVertexSegments(vnr); node.elements.ne = ia.Size(); node.elements.ptr = (int*)&ia[0]; - NgFlatArray bia = mesh->GetTopology().GetVertexPointElements(vnr); + auto bia = mesh->GetTopology().GetVertexPointElements(vnr); node.bnd_elements.ne = bia.Size(); node.bnd_elements.ptr = (int*)&bia[0]; break; diff --git a/libsrc/interface/nginterface.cpp b/libsrc/interface/nginterface.cpp index 5b329569..24da6783 100644 --- a/libsrc/interface/nginterface.cpp +++ b/libsrc/interface/nginterface.cpp @@ -1653,7 +1653,7 @@ void Ng_GetVertexElements (int vnr, int * els) } case 1: { - NgFlatArray ia = mesh->GetTopology().GetVertexSegments(vnr); + auto ia = mesh->GetTopology().GetVertexSegments(vnr); for (int i = 0; i < ia.Size(); i++) els[i] = ia[i]+1; break; /* diff --git a/libsrc/meshing/topology.cpp b/libsrc/meshing/topology.cpp index e0c1ccf3..2172746e 100644 --- a/libsrc/meshing/topology.cpp +++ b/libsrc/meshing/topology.cpp @@ -408,36 +408,22 @@ namespace netgen vert2element = mesh->CreatePoint2ElementTable(); vert2surfelement = mesh->CreatePoint2SurfaceElementTable(0); - cnt = 0; - for (SegmentIndex si = 0; si < nseg; si++) - { - const Segment & seg = mesh->LineSegment(si); - cnt[seg[0]]++; - cnt[seg[1]]++; - } - - vert2segment = TABLE (cnt); - for (SegmentIndex si = 0; si < nseg; si++) - { - const Segment & seg = mesh->LineSegment(si); - vert2segment.AddSave (seg[0], si); - vert2segment.AddSave (seg[1], si); - } + vert2segment = ngcore::CreateSortedTable( mesh->LineSegments().Range(), + [&](auto & table, SegmentIndex segi) + { + const Segment & seg = (*mesh)[segi]; + table.Add (seg[0], segi); + table.Add (seg[1], segi); + }, np); + + vert2pointelement = ngcore::CreateSortedTable( mesh->pointelements.Range(), + [&](auto & table, int pei) + { + const Element0d & pointel = mesh->pointelements[pei]; + table.Add(pointel.pnum, pei); + }, np); - cnt = 0; - for (int pei = 0; pei < mesh->pointelements.Size(); pei++) - { - const Element0d & pointel = mesh->pointelements[pei]; - cnt[pointel.pnum]++; - } - - vert2pointelement = TABLE (cnt); - for (int pei = 0; pei < mesh->pointelements.Size(); pei++) - { - const Element0d & pointel = mesh->pointelements[pei]; - vert2pointelement.AddSave (pointel.pnum, pei); - } (*tracer) ("Topology::Update setup tables", true); diff --git a/libsrc/meshing/topology.hpp b/libsrc/meshing/topology.hpp index 9ce2e47a..e6bcf76f 100644 --- a/libsrc/meshing/topology.hpp +++ b/libsrc/meshing/topology.hpp @@ -67,8 +67,8 @@ class MeshTopology Array edge2segment; Table vert2element; Table vert2surfelement; - TABLE vert2segment; - TABLE vert2pointelement; + Table vert2segment; + Table vert2pointelement; int timestamp; public: int GetNSurfedges() const {return surfedges.Size();} @@ -183,10 +183,10 @@ public: FlatArray GetVertexSurfaceElements(PointIndex vnr) const { return vert2surfelement[vnr]; } - NgFlatArray GetVertexSegments (int vnr) const + FlatArray GetVertexSegments (int vnr) const { return vert2segment[vnr]; } - NgFlatArray GetVertexPointElements (int vnr) const + FlatArray GetVertexPointElements (int vnr) const { return vert2pointelement[vnr]; } int GetVerticesEdge ( int v1, int v2) const;