From 0605097bdc4ce7f46018a942676e83560cfeaad3 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Thu, 21 Apr 2022 12:28:56 +0200 Subject: [PATCH] Topology: use non-copying access functions, take care of 0/1 - based indexing --- libsrc/meshing/topology.cpp | 21 +++++++++++++++++++-- libsrc/meshing/topology.hpp | 9 +++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/libsrc/meshing/topology.cpp b/libsrc/meshing/topology.cpp index 60df257a..718b5c16 100644 --- a/libsrc/meshing/topology.cpp +++ b/libsrc/meshing/topology.cpp @@ -1483,13 +1483,19 @@ namespace netgen (ne, [&] (IntRange r) { + /* NgArray hfaces; for (ElementIndex ei : r) - { + { GetElementFaces (ei+1, hfaces); for (auto f : hfaces) AsAtomic(face_els[f-1])++; } + */ + for (ElementIndex ei : r) + for (auto f : GetFaces(ei)) + AsAtomic(face_els[f])++; + }, TasksPerThread(4)); for (int i = 1; i <= nse; i++) face_surfels[GetSurfaceElementFace (i)-1]++; @@ -2052,7 +2058,7 @@ namespace netgen } - + int MeshTopology :: GetElementEdges (int elnr, int * eledges, int * orient) const { // int ned = GetNEdges (mesh.VolumeElement(elnr).GetType()); @@ -2166,7 +2172,18 @@ namespace netgen return FlatArray(GetNEdges ( (*mesh)[elnr].GetType()), &surfedges[elnr][0]); } + FlatArray MeshTopology :: GetEdges (ElementIndex elnr) const + { + return FlatArray(GetNEdges ( (*mesh)[elnr].GetType()), &edges[elnr][0]); + } + FlatArray MeshTopology :: GetFaces (ElementIndex elnr) const + { + return FlatArray(GetNFaces ( (*mesh)[elnr].GetType()), &faces[elnr][0]); + } + + + int MeshTopology :: GetSurfaceElementFace (int elnr) const { return surffaces.Get(elnr)+1; diff --git a/libsrc/meshing/topology.hpp b/libsrc/meshing/topology.hpp index 06868197..64848aa7 100644 --- a/libsrc/meshing/topology.hpp +++ b/libsrc/meshing/topology.hpp @@ -103,15 +103,24 @@ public: orient = GetSegmentEdgeOrientation(segnr); } + [[deprecated("use GetEdges (ElementIndex) -> FlatArray")]] void GetElementEdges (int elnr, NgArray & edges) const; + [[deprecated("use GetFaces (ElementIndex) -> FlatArray")]] void GetElementFaces (int elnr, NgArray & faces, bool withorientation = false) const; + FlatArray GetEdges (ElementIndex elnr) const; + FlatArray GetFaces (ElementIndex elnr) const; + + [[deprecated("use GetElementEdge instead")]] void GetElementEdgeOrientations (int elnr, NgArray & eorient) const; [[deprecated("use GetElementEdge instead")]] void GetElementFaceOrientations (int elnr, NgArray & forient) const; + [[deprecated("use GetEdges (ElementIndex) -> FlatArray")]] int GetElementEdges (int elnr, int * edges, int * orient) const; + + [[deprecated("use GetFaces (ElementIndex) -> FlatArray")]] int GetElementFaces (int elnr, int * faces, int * orient) const; [[deprecated("use GetElementEdge instead")]]