diff --git a/libsrc/include/nginterface_v2_impl.hpp b/libsrc/include/nginterface_v2_impl.hpp index 305c0073..d732285e 100644 --- a/libsrc/include/nginterface_v2_impl.hpp +++ b/libsrc/include/nginterface_v2_impl.hpp @@ -328,7 +328,7 @@ template <> NGX_INLINE DLL_HEADER const Ng_Node<2> Ngx_Mesh :: GetNode<2> (int n Ng_Node<2> node; node.vertices.ptr = (const int*)mesh->GetTopology().GetFaceVerticesPtr(nr); node.vertices.nv = (node.vertices.ptr[3]+1 == PointIndex::BASE) ? 3 : 4; - node.surface_el = mesh->GetTopology().GetFace2SurfaceElement (nr+1)-1; + node.surface_el = mesh->GetTopology().GetFace2SurfaceElement (nr); return node; } diff --git a/libsrc/interface/nginterface.cpp b/libsrc/interface/nginterface.cpp index 6ceeed96..8945c970 100644 --- a/libsrc/interface/nginterface.cpp +++ b/libsrc/interface/nginterface.cpp @@ -1571,10 +1571,11 @@ int Ng_GetSurfaceElement_Face (int selnr, int * orient) { if (mesh->GetDimension() == 3) { + SurfaceElementIndex sei = selnr-1; const MeshTopology & topology = mesh->GetTopology(); if (orient) *orient = topology.GetSurfaceElementFaceOrientation (selnr); - return topology.GetSurfaceElementFace (selnr); + return topology.GetFace(sei); } return -1; } @@ -2343,7 +2344,7 @@ int Ng_GetElementClosureNodes (int dim, int elementnr, int nodeset, int * nodes) if (nodeset & 4) // Faces { - int face = mesh->GetTopology().GetSurfaceElementFace (elementnr+1); + int face = mesh->GetTopology().GetFace (SurfaceElementIndex(elementnr))+1; nodes[cnt++] = 2; nodes[cnt++] = face-1; } diff --git a/libsrc/interface/nginterface_v2.cpp b/libsrc/interface/nginterface_v2.cpp index 782a3381..ab8e7fe2 100644 --- a/libsrc/interface/nginterface_v2.cpp +++ b/libsrc/interface/nginterface_v2.cpp @@ -1326,7 +1326,7 @@ int Ngx_Mesh::GetSurfaceElement_Face (int selnr, int * orient) const const MeshTopology & topology = mesh->GetTopology(); if (orient) *orient = topology.GetSurfaceElementFaceOrientation (selnr+1); - return topology.GetSurfaceElementFace (selnr+1)-1; + return topology.GetFace (SurfaceElementIndex(selnr)); } return -1; } diff --git a/libsrc/interface/writeOpenFOAM15x.cpp b/libsrc/interface/writeOpenFOAM15x.cpp index 56b5780e..21eac489 100644 --- a/libsrc/interface/writeOpenFOAM15x.cpp +++ b/libsrc/interface/writeOpenFOAM15x.cpp @@ -215,7 +215,7 @@ namespace netgen // Check if the face is a surface element (boundary face) // if not, add the current volume element and the corresponding face into // the owner list - int surfelem = meshtopo.GetFace2SurfaceElement(absfacenr); + int surfelem = meshtopo.GetFace2SurfaceElement1(absfacenr); if(!surfelem) { // If it is a new face which has not been listed before, diff --git a/libsrc/meshing/clusters.cpp b/libsrc/meshing/clusters.cpp index c71bc733..a2532678 100644 --- a/libsrc/meshing/clusters.cpp +++ b/libsrc/meshing/clusters.cpp @@ -152,7 +152,7 @@ namespace netgen NgArrayMem nnums; // , ednums; for (SurfaceElementIndex i_ : myrange) { - int i = i_+1; + // int i = i_+1; const Element2d & el = mesh[i_]; // .SurfaceElement(i); ELEMENT_TYPE typ = el.GetType(); @@ -160,7 +160,7 @@ namespace netgen auto ednums = top.GetEdges (i_); // cout << "ednums = " << ednums << endl; - int fanum = top.GetSurfaceElementFace (i); + int fanum = top.GetFace(i_)+1; int elnv = top.GetNVertices (typ); int elned = ednums.Size(); diff --git a/libsrc/meshing/curvedelems.cpp b/libsrc/meshing/curvedelems.cpp index e1aa7b3d..84e681c3 100644 --- a/libsrc/meshing/curvedelems.cpp +++ b/libsrc/meshing/curvedelems.cpp @@ -1278,7 +1278,7 @@ namespace netgen with MPI and an interior surface element between volume elements assigned to different procs, only one of them has the surf-el **/ - SurfaceElementIndex sei = top.GetFace2SurfaceElement (f+1)-1; + SurfaceElementIndex sei = top.GetFace2SurfaceElement(f); if (sei != SurfaceElementIndex(-1)) { PointGeomInfo gi = mesh[sei].GeomInfoPi(1); // use improved initial guess @@ -1680,7 +1680,7 @@ namespace netgen */ info.SetEdges (top.GetEdges(SurfaceElementIndex(elnr))); - info.facenr = top.GetSurfaceElementFace (elnr+1)-1; + info.facenr = top.GetFace(elnr); for (int i = 0; i < info.edgenrs.Size(); i++) info.ndof += edgecoeffsindex[info.edgenrs[i]+1] - edgecoeffsindex[info.edgenrs[i]]; info.ndof += facecoeffsindex[info.facenr+1] - facecoeffsindex[info.facenr]; @@ -1763,7 +1763,7 @@ namespace netgen info.edgenrs[i]--; */ info.SetEdges(top.GetEdges(SurfaceElementIndex(elnr))); - info.facenr = top.GetSurfaceElementFace (elnr+1)-1; + info.facenr = top.GetFace(elnr); bool firsttry = true; @@ -4211,7 +4211,7 @@ namespace netgen info.edgenrs[i]--; */ info.SetEdges(top.GetEdges(elnr)); - info.facenr = top.GetSurfaceElementFace (elnr+1)-1; + info.facenr = top.GetFace (elnr); bool firsttry = true; diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index ad5e2dd2..0843350a 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -99,7 +99,7 @@ namespace netgen //(*testout) << "faces " << faces << endl; for(int i=0; i 0 && face2surfel[fnum-1]) + int fnum = faces[i][j]; + if (fnum >= 0 && face2surfel[fnum].IsValid()) { - int sel = face2surfel[fnum-1]; - surf2volelement[sel-1][1] = - surf2volelement[sel-1][0]; - surf2volelement[sel-1][0] = i+1; + SurfaceElementIndex sel = face2surfel[fnum]; + surf2volelement[sel][1] = surf2volelement[sel][0]; + surf2volelement[sel][0] = i; // +1; } }}); (*tracer) ("Topology::Update build surf2vol", true); @@ -1296,8 +1296,12 @@ namespace netgen AsAtomic(face_els[f])++; }, TasksPerThread(4)); + /* for (int i = 1; i <= nse; i++) - face_surfels[GetSurfaceElementFace (i)-1]++; + face_surfels[GetSurfaceElementFace1 (i)-1]++; + */ + for (auto sei : Range(mesh->SurfaceElements())) + face_surfels[GetFace(sei)]++; (*tracer) ("Topology::Update count face_els", true); @@ -2019,12 +2023,12 @@ namespace netgen */ + /* int MeshTopology :: GetSurfaceElementFace (int elnr) const { return surffaces[elnr-1]+1; } - /* int MeshTopology :: GetFace (SurfaceElementIndex elnr) const { return surffaces[elnr].fnr; @@ -2400,10 +2404,11 @@ namespace netgen } } - int surfel = GetFace2SurfaceElement(fnr); - if (surfel != 0) + SurfaceElementIndex surfel = GetFace2SurfaceElement(fnr); + if (!surfel.IsValid()) { - GetSurfaceElementEdges (surfel, fedges); + // GetSurfaceElementEdges (surfel, fedges); + GetEdges (surfel, fedges); return; } } diff --git a/libsrc/meshing/topology.hpp b/libsrc/meshing/topology.hpp index 4ee0136c..8a4d1fd0 100644 --- a/libsrc/meshing/topology.hpp +++ b/libsrc/meshing/topology.hpp @@ -16,11 +16,10 @@ namespace netgen { - typedef int T_EDGE; typedef int T_FACE; - + class MeshTopology { const Mesh * mesh; @@ -40,8 +39,9 @@ class MeshTopology Array segedges; Array surffaces; - Array surf2volelement; - Array face2surfel; + // Array surf2volelement; + Array, SurfaceElementIndex> surf2volelement; + Array face2surfel; Array edge2segment; Table vert2element; @@ -147,7 +147,8 @@ public: [[deprecated("use GetEdges (SurfaceElementIndex) -> FlatArray")]] void GetSurfaceElementEdges (int elnr, NgArray & edges) const; - int GetSurfaceElementFace (int elnr) const; + [[deprecated("use GetFace(SurfaceElementIndex")]] + int GetSurfaceElementFace1 (int elnr) const { return surffaces[elnr-1]+1; } [[deprecated("orientation is outdated")]] void GetSurfaceElementEdgeOrientations (int elnr, NgArray & eorient) const; // [[deprecated("orientation is outdated")]] @@ -176,18 +177,22 @@ public: void GetSurface2VolumeElement (int selnr, int & elnr1, int & elnr2) const { - elnr1 = surf2volelement[selnr-1][0]; - elnr2 = surf2volelement[selnr-1][1]; + elnr1 = surf2volelement[selnr-1][0]+1; + elnr2 = surf2volelement[selnr-1][1]+1; } std::array GetSurface2VolumeElement (SurfaceElementIndex sei) { + return surf2volelement[sei]; + /* return { ElementIndex( surf2volelement[sei][0] - 1), ElementIndex( surf2volelement[sei][1] - 1) }; + */ } - - int GetFace2SurfaceElement (int fnr) const { return face2surfel[fnr-1]; } + [[deprecated("use GetSurfaceEleement -> SurfaceElementIndex")]] + int GetFace2SurfaceElement1 (int fnr) const { return face2surfel[fnr-1]+1; } + SurfaceElementIndex GetFace2SurfaceElement (int fnr) const { return face2surfel[fnr]; } SegmentIndex GetSegmentOfEdge(int edgenr) const { return edge2segment[edgenr-1]; }