Topology: use non-copying access functions, take care of 0/1 - based indexing

This commit is contained in:
Joachim Schoeberl 2022-04-21 12:28:56 +02:00
parent 6fd99a5a29
commit 0605097bdc
2 changed files with 28 additions and 2 deletions

View File

@ -1483,13 +1483,19 @@ namespace netgen
(ne, (ne,
[&] (IntRange r) [&] (IntRange r)
{ {
/*
NgArray<int> hfaces; NgArray<int> hfaces;
for (ElementIndex ei : r) for (ElementIndex ei : r)
{ {
GetElementFaces (ei+1, hfaces); GetElementFaces (ei+1, hfaces);
for (auto f : hfaces) for (auto f : hfaces)
AsAtomic(face_els[f-1])++; AsAtomic(face_els[f-1])++;
} }
*/
for (ElementIndex ei : r)
for (auto f : GetFaces(ei))
AsAtomic(face_els[f])++;
}, TasksPerThread(4)); }, TasksPerThread(4));
for (int i = 1; i <= nse; i++) for (int i = 1; i <= nse; i++)
face_surfels[GetSurfaceElementFace (i)-1]++; face_surfels[GetSurfaceElementFace (i)-1]++;
@ -2052,7 +2058,7 @@ namespace netgen
} }
int MeshTopology :: GetElementEdges (int elnr, int * eledges, int * orient) const int MeshTopology :: GetElementEdges (int elnr, int * eledges, int * orient) const
{ {
// int ned = GetNEdges (mesh.VolumeElement(elnr).GetType()); // int ned = GetNEdges (mesh.VolumeElement(elnr).GetType());
@ -2166,7 +2172,18 @@ namespace netgen
return FlatArray<T_EDGE>(GetNEdges ( (*mesh)[elnr].GetType()), &surfedges[elnr][0]); return FlatArray<T_EDGE>(GetNEdges ( (*mesh)[elnr].GetType()), &surfedges[elnr][0]);
} }
FlatArray<T_EDGE> MeshTopology :: GetEdges (ElementIndex elnr) const
{
return FlatArray<T_EDGE>(GetNEdges ( (*mesh)[elnr].GetType()), &edges[elnr][0]);
}
FlatArray<T_FACE> MeshTopology :: GetFaces (ElementIndex elnr) const
{
return FlatArray<T_FACE>(GetNFaces ( (*mesh)[elnr].GetType()), &faces[elnr][0]);
}
int MeshTopology :: GetSurfaceElementFace (int elnr) const int MeshTopology :: GetSurfaceElementFace (int elnr) const
{ {
return surffaces.Get(elnr)+1; return surffaces.Get(elnr)+1;

View File

@ -103,15 +103,24 @@ public:
orient = GetSegmentEdgeOrientation(segnr); orient = GetSegmentEdgeOrientation(segnr);
} }
[[deprecated("use GetEdges (ElementIndex) -> FlatArray")]]
void GetElementEdges (int elnr, NgArray<int> & edges) const; void GetElementEdges (int elnr, NgArray<int> & edges) const;
[[deprecated("use GetFaces (ElementIndex) -> FlatArray")]]
void GetElementFaces (int elnr, NgArray<int> & faces, bool withorientation = false) const; void GetElementFaces (int elnr, NgArray<int> & faces, bool withorientation = false) const;
FlatArray<T_EDGE> GetEdges (ElementIndex elnr) const;
FlatArray<T_FACE> GetFaces (ElementIndex elnr) const;
[[deprecated("use GetElementEdge instead")]] [[deprecated("use GetElementEdge instead")]]
void GetElementEdgeOrientations (int elnr, NgArray<int> & eorient) const; void GetElementEdgeOrientations (int elnr, NgArray<int> & eorient) const;
[[deprecated("use GetElementEdge instead")]] [[deprecated("use GetElementEdge instead")]]
void GetElementFaceOrientations (int elnr, NgArray<int> & forient) const; void GetElementFaceOrientations (int elnr, NgArray<int> & forient) const;
[[deprecated("use GetEdges (ElementIndex) -> FlatArray")]]
int GetElementEdges (int elnr, int * edges, int * orient) const; int GetElementEdges (int elnr, int * edges, int * orient) const;
[[deprecated("use GetFaces (ElementIndex) -> FlatArray")]]
int GetElementFaces (int elnr, int * faces, int * orient) const; int GetElementFaces (int elnr, int * faces, int * orient) const;
[[deprecated("use GetElementEdge instead")]] [[deprecated("use GetElementEdge instead")]]