From 1ebc6a0e81e064a157a738212e06f35485d054d6 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Sun, 5 Jan 2025 12:14:08 +0100 Subject: [PATCH] more ngcore::Array in topology, include headers --- libsrc/gprim/geomobjects.hpp | 9 +++++--- libsrc/meshing/bisect.cpp | 5 ++++- libsrc/meshing/curvedelems.cpp | 26 ++++++++++++++++----- libsrc/meshing/curvedelems.hpp | 9 ++++++++ libsrc/meshing/meshclass.hpp | 1 + libsrc/meshing/meshing.hpp | 14 +++++------- libsrc/meshing/meshing2.cpp | 4 +++- libsrc/meshing/meshing2.hpp | 5 +++++ libsrc/meshing/meshing3.cpp | 5 ++++- libsrc/meshing/meshing3.hpp | 1 + libsrc/meshing/meshtool.hpp | 5 +++-- libsrc/meshing/refine.cpp | 4 +++- libsrc/meshing/topology.cpp | 25 +++++++++------------ libsrc/meshing/topology.hpp | 41 +++++++++++++++------------------- libsrc/occ/occ_edge.hpp | 6 ++--- libsrc/occ/occ_face.hpp | 6 ++--- libsrc/occ/occ_utils.hpp | 6 ++--- libsrc/occ/occ_vertex.hpp | 6 ++--- 18 files changed, 106 insertions(+), 72 deletions(-) diff --git a/libsrc/gprim/geomobjects.hpp b/libsrc/gprim/geomobjects.hpp index 5e8e0318..f5336b33 100644 --- a/libsrc/gprim/geomobjects.hpp +++ b/libsrc/gprim/geomobjects.hpp @@ -140,7 +140,8 @@ namespace netgen operator const T* () const { return x; } - void DoArchive(Archive& archive) + template + void DoArchive(ARCHIVE& archive) { for(int i=0; i + void DoArchive(ARCHIVE & ar) { ar.Do(x, H*W); } @@ -440,7 +442,8 @@ namespace netgen pmax = center + factor*(pmax-center); } - void DoArchive(Archive& archive) + template + void DoArchive(ARCHIVE & archive) { archive & pmin & pmax; } }; diff --git a/libsrc/meshing/bisect.cpp b/libsrc/meshing/bisect.cpp index b33787e5..2d7d9af1 100644 --- a/libsrc/meshing/bisect.cpp +++ b/libsrc/meshing/bisect.cpp @@ -1,9 +1,12 @@ #include #include + +#include "meshclass.hpp" #include "bisect.hpp" #include "validate.hpp" +#include "paralleltop.hpp" -#include "meshing.hpp" // quickfix for parallel +// #include "meshing.hpp" // quickfix for parallel #define noDEBUG diff --git a/libsrc/meshing/curvedelems.cpp b/libsrc/meshing/curvedelems.cpp index 52b8f717..e1aa7b3d 100644 --- a/libsrc/meshing/curvedelems.cpp +++ b/libsrc/meshing/curvedelems.cpp @@ -1,7 +1,6 @@ #include #include "meshing.hpp" - // #include "../general/autodiff.hpp" @@ -1667,12 +1666,21 @@ namespace netgen if (info.order > 1) { const MeshTopology & top = mesh.GetTopology(); - + + /* top.GetSurfaceElementEdges (elnr+1, info.edgenrs); for (int i = 0; i < info.edgenrs.Size(); i++) info.edgenrs[i]--; + */ + /* + auto edgs = top.GetEdges(SurfaceElementIndex(elnr)); + info.edgenrs.SetSize(edgs.Size()); + for (auto [i,nr] : Enumerate(edgs)) + info.edgenrs[i] = nr; + */ + info.SetEdges (top.GetEdges(SurfaceElementIndex(elnr))); + info.facenr = top.GetSurfaceElementFace (elnr+1)-1; - 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]; @@ -1748,10 +1756,13 @@ namespace netgen if (info.order > 1) { const MeshTopology & top = mesh.GetTopology(); - + + /* top.GetSurfaceElementEdges (elnr+1, info.edgenrs); for (int i = 0; i < info.edgenrs.Size(); i++) info.edgenrs[i]--; + */ + info.SetEdges(top.GetEdges(SurfaceElementIndex(elnr))); info.facenr = top.GetSurfaceElementFace (elnr+1)-1; @@ -4193,10 +4204,13 @@ namespace netgen if (info.order > 1) { const MeshTopology & top = mesh.GetTopology(); - + + /* top.GetSurfaceElementEdges (elnr+1, info.edgenrs); for (int i = 0; i < info.edgenrs.Size(); i++) info.edgenrs[i]--; + */ + info.SetEdges(top.GetEdges(elnr)); info.facenr = top.GetSurfaceElementFace (elnr+1)-1; @@ -4355,7 +4369,7 @@ namespace netgen const double * xi, size_t sxi, double * x, size_t sx, double * dxdxi, size_t sdxdxi); - + template void CurvedElements :: CalcMultiPointSurfaceTransformation<2> (SurfaceElementIndex elnr, int npts, diff --git a/libsrc/meshing/curvedelems.hpp b/libsrc/meshing/curvedelems.hpp index 08c1bf02..a77391ca 100644 --- a/libsrc/meshing/curvedelems.hpp +++ b/libsrc/meshing/curvedelems.hpp @@ -13,6 +13,7 @@ #include #include "meshtype.hpp" +#include "meshclass.hpp" namespace netgen { @@ -248,6 +249,14 @@ private: int ndof; NgArrayMem edgenrs; int facenr; + + void SetEdges (FlatArray edges) + { + edgenrs.SetSize(edges.Size()); + for (int i = 0; i < edges.Size(); i++) + edgenrs[i] = edges[i]; + } + }; template diff --git a/libsrc/meshing/meshclass.hpp b/libsrc/meshing/meshclass.hpp index 60fb764f..d7afa8ec 100644 --- a/libsrc/meshing/meshclass.hpp +++ b/libsrc/meshing/meshclass.hpp @@ -19,6 +19,7 @@ #include "meshtype.hpp" #include "localh.hpp" #include "topology.hpp" +#include "paralleltop.hpp" namespace netgen { diff --git a/libsrc/meshing/meshing.hpp b/libsrc/meshing/meshing.hpp index 1ee3dd67..188447b3 100644 --- a/libsrc/meshing/meshing.hpp +++ b/libsrc/meshing/meshing.hpp @@ -1,8 +1,6 @@ #ifndef FILE_MESHING #define FILE_MESHING - - #include "../include/myadt.hpp" #include "../include/gprim.hpp" #include "../include/linalg.hpp" @@ -19,12 +17,12 @@ namespace netgen } -#include "msghandler.hpp" -#include "meshtype.hpp" -#include "localh.hpp" -#include "topology.hpp" -#include "meshclass.hpp" -#include "global.hpp" +// #include "msghandler.hpp" +// #include "meshtype.hpp" +// #include "localh.hpp" +// #include "topology.hpp" +// #include "meshclass.hpp" +// #include "global.hpp" #include "meshtool.hpp" diff --git a/libsrc/meshing/meshing2.cpp b/libsrc/meshing/meshing2.cpp index 02f53d7e..96a2fe97 100644 --- a/libsrc/meshing/meshing2.cpp +++ b/libsrc/meshing/meshing2.cpp @@ -1,5 +1,7 @@ #include -#include "meshing.hpp" + +#include "meshing2.hpp" + #include "visual_interface.hpp" namespace netgen diff --git a/libsrc/meshing/meshing2.hpp b/libsrc/meshing/meshing2.hpp index e35d5fab..1cf07222 100644 --- a/libsrc/meshing/meshing2.hpp +++ b/libsrc/meshing/meshing2.hpp @@ -7,6 +7,11 @@ /* Date: 01. Okt. 95 */ /**************************************************************************/ + +#include "adfront2.hpp" +#include "ruler2.hpp" +#include "basegeom.hpp" + namespace netgen { diff --git a/libsrc/meshing/meshing3.cpp b/libsrc/meshing/meshing3.cpp index 0ed40bb1..c83424d4 100644 --- a/libsrc/meshing/meshing3.cpp +++ b/libsrc/meshing/meshing3.cpp @@ -1,5 +1,8 @@ #include -#include "meshing.hpp" + +#include "meshing3.hpp" +#include "findip.hpp" +#include "findip2.hpp" namespace netgen { diff --git a/libsrc/meshing/meshing3.hpp b/libsrc/meshing/meshing3.hpp index 4b7e1082..a4659547 100644 --- a/libsrc/meshing/meshing3.hpp +++ b/libsrc/meshing/meshing3.hpp @@ -1,6 +1,7 @@ #ifndef FILE_MESHING3 #define FILE_MESHING3 +#include "meshclass.hpp" #include "adfront3.hpp" #include "ruler3.hpp" diff --git a/libsrc/meshing/meshtool.hpp b/libsrc/meshing/meshtool.hpp index 135d36ec..10474208 100644 --- a/libsrc/meshing/meshtool.hpp +++ b/libsrc/meshing/meshtool.hpp @@ -4,8 +4,9 @@ // #include "../general/ngarray.hpp" // #include "../gprim/geom3d.hpp" // #include "../gprim/geomobjects.hpp" -// #include "meshtype.hpp" -// #include "meshclass.hpp" + +#include "meshtype.hpp" +#include "meshclass.hpp" namespace netgen { /// diff --git a/libsrc/meshing/refine.cpp b/libsrc/meshing/refine.cpp index dbbfec10..77d18052 100644 --- a/libsrc/meshing/refine.cpp +++ b/libsrc/meshing/refine.cpp @@ -1,5 +1,7 @@ #include -#include "meshing.hpp" +#include "meshclass.hpp" +#include "bisect.hpp" +#include "paralleltop.hpp" namespace netgen diff --git a/libsrc/meshing/topology.cpp b/libsrc/meshing/topology.cpp index 622512fb..81aefc60 100644 --- a/libsrc/meshing/topology.cpp +++ b/libsrc/meshing/topology.cpp @@ -1229,7 +1229,7 @@ namespace netgen face2surfel.SetSize (nfa); face2surfel = 0; for (int i = 1; i <= nse; i++) - face2surfel.Elem(GetSurfaceElementFace(i)) = i; + face2surfel[GetSurfaceElementFace(i)-1] = i; /* cout << "build table complete" << endl; @@ -1243,11 +1243,8 @@ namespace netgen surf2volelement.SetSize (nse); - for (int i = 1; i <= nse; i++) - { - surf2volelement.Elem(i)[0] = 0; - surf2volelement.Elem(i)[1] = 0; - } + surf2volelement = INDEX_2(0,0); + (*tracer) ("Topology::Update build surf2vol", false); // for (int i = 0; i < ne; i++) ParallelFor (ne, [this](auto i) @@ -1256,12 +1253,12 @@ namespace netgen { // int fnum = (faces.Get(i)[j]+7) / 8; int fnum = faces[i][j]+1; - if (fnum > 0 && face2surfel.Elem(fnum)) + if (fnum > 0 && face2surfel[fnum-1]) { - int sel = face2surfel.Elem(fnum); - surf2volelement.Elem(sel)[1] = - surf2volelement.Elem(sel)[0]; - surf2volelement.Elem(sel)[0] = i+1; + int sel = face2surfel[fnum-1]; + surf2volelement[sel-1][1] = + surf2volelement[sel-1][0]; + surf2volelement[sel-1][0] = i+1; } }}); (*tracer) ("Topology::Update build surf2vol", true); @@ -2024,7 +2021,7 @@ namespace netgen int MeshTopology :: GetSurfaceElementFace (int elnr) const { - return surffaces.Get(elnr)+1; + return surffaces[elnr-1]+1; } /* @@ -2101,7 +2098,7 @@ namespace netgen if (orient) orient[0] = segedges.Get(elnr) > 0 ? 1 : -1; */ - eledges[0] = segedges.Get(elnr)+1; + eledges[0] = segedges[elnr-1]+1; if (orient) // orient[0] = segedges.Get(elnr).orient ? -1 : 1; // orient[0] = GetSegmentEdgeOrientation(elnr) ? -1 : 1; @@ -2249,7 +2246,7 @@ namespace netgen void MeshTopology :: GetSegmentEdge (int segnr, int & enr, int & orient) const { - enr = segedges.Get(segnr)+1; + enr = segedges[segnr-1]+1; orient = GetSegmentEdgeOrientation(segnr); } diff --git a/libsrc/meshing/topology.hpp b/libsrc/meshing/topology.hpp index 782d1ba6..4ee0136c 100644 --- a/libsrc/meshing/topology.hpp +++ b/libsrc/meshing/topology.hpp @@ -12,6 +12,8 @@ (Elements, Faces, Edges, Vertices */ +#include "meshtype.hpp" + namespace netgen { @@ -36,10 +38,11 @@ class MeshTopology Array, ElementIndex> faces; Array, SurfaceElementIndex> surfedges; - NgArray segedges; - NgArray surffaces; - NgArray surf2volelement; - NgArray face2surfel; + Array segedges; + Array surffaces; + Array surf2volelement; + Array face2surfel; + Array edge2segment; Table vert2element; Table vert2surfelement; @@ -47,8 +50,6 @@ class MeshTopology Table vert2pointelement; int timestamp; public: - int GetNSurfedges() const {return surfedges.Size();} - MeshTopology () = default; MeshTopology (MeshTopology && top) = default; DLL_HEADER MeshTopology (const Mesh & amesh); @@ -72,8 +73,8 @@ public: bool NeedsUpdate() const; - int GetNEdges () const { return edge2vert.Size(); } - int GetNFaces () const { return face2vert.Size(); } + size_t GetNEdges () const { return edge2vert.Size(); } + size_t GetNFaces () const { return face2vert.Size(); } static inline short int GetNVertices (ELEMENT_TYPE et); static inline short int GetNPoints (ELEMENT_TYPE et); @@ -88,19 +89,12 @@ public: inline static const ELEMENT_FACE * GetFaces0 (ELEMENT_TYPE et); [[deprecated("use GetEdge(SegmentIndex) instead")]] - int GetSegmentEdge (int segnr) const { return segedges[segnr-1]+1; } + T_EDGE GetSegmentEdge (int segnr) const { return segedges[segnr-1]+1; } - int GetEdge (SegmentIndex segnr) const { return segedges[segnr]; } + T_EDGE GetEdge (SegmentIndex segnr) const { return segedges[segnr]; } [[deprecated("use GetEdge(SegmentIndex) instead")]] void GetSegmentEdge (int segnr, int & enr, int & orient) const; - /* - { - enr = segedges.Get(segnr)+1; - // orient = segedges.Get(segnr).orient; - orient = GetSegmentEdgeOrientation(segnr); - } - */ [[deprecated("use GetEdges (ElementIndex) -> FlatArray")]] void GetElementEdges (int elnr, NgArray & edges) const; @@ -143,15 +137,15 @@ public: DLL_HEADER void GetEdgeVertices (int enr, int & v1, int & v2) const; [[deprecated("use GetEdgeVertices -> tupe(v0,v1) instead")]] DLL_HEADER void GetEdgeVertices (int enr, PointIndex & v1, PointIndex & v2) const; - auto GetEdgeVertices (int enr) const { return tuple(edge2vert[enr][0], edge2vert[enr][1]); } + auto GetEdgeVertices (int enr) const { return std::array{edge2vert[enr][0], edge2vert[enr][1]}; } auto GetEdgeVerticesPtr (int enr) const { return &edge2vert[enr][0]; } auto GetFaceVerticesPtr (int fnr) const { return &face2vert[fnr][0]; } DLL_HEADER void GetFaceEdges (int fnr, NgArray & edges, bool withorientation = false) const; ELEMENT_TYPE GetFaceType (int fnr) const - // { return (face2vert.Get(fnr)[3] == 0) ? TRIG : QUAD; } { return (!face2vert[fnr-1][3].IsValid()) ? TRIG : QUAD; } + [[deprecated("use GetEdges (SurfaceElementIndex) -> FlatArray")]] void GetSurfaceElementEdges (int elnr, NgArray & edges) const; int GetSurfaceElementFace (int elnr) const; [[deprecated("orientation is outdated")]] @@ -170,6 +164,7 @@ public: int GetSurfaceElementEdges (int elnr, int * edges, int * orient) const; + int GetNSurfedges() const {return surfedges.Size();} [[deprecated("use GetEdges(ElementIndex) instead")]] const T_EDGE * GetElementEdgesPtr (int elnr) const { return &edges[IndexBASE()+elnr][0]; } const T_EDGE * GetSurfaceElementEdgesPtr (int selnr) const { return &surfedges[selnr][0]; } @@ -181,14 +176,14 @@ public: void GetSurface2VolumeElement (int selnr, int & elnr1, int & elnr2) const { - elnr1 = surf2volelement.Get(selnr)[0]; - elnr2 = surf2volelement.Get(selnr)[1]; + elnr1 = surf2volelement[selnr-1][0]; + elnr2 = surf2volelement[selnr-1][1]; } std::array GetSurface2VolumeElement (SurfaceElementIndex sei) { - return { ElementIndex( surf2volelement.Get(sei+1)[0] - 1), - ElementIndex( surf2volelement.Get(sei+1)[1] - 1) }; + return { ElementIndex( surf2volelement[sei][0] - 1), + ElementIndex( surf2volelement[sei][1] - 1) }; } diff --git a/libsrc/occ/occ_edge.hpp b/libsrc/occ/occ_edge.hpp index d96b7d8f..a5f54ebf 100644 --- a/libsrc/occ/occ_edge.hpp +++ b/libsrc/occ/occ_edge.hpp @@ -2,8 +2,8 @@ #define FILE_OCC_EDGE_INCLUDED -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" +// #pragma clang diagnostic push +// #pragma clang diagnostic ignored "-Wdeprecated-declarations" #include #include @@ -12,7 +12,7 @@ #include #include -#pragma clang diagnostic pop +// #pragma clang diagnostic pop #include "occ_vertex.hpp" #include "meshing.hpp" diff --git a/libsrc/occ/occ_face.hpp b/libsrc/occ/occ_face.hpp index 0d3a75a8..71e583c7 100644 --- a/libsrc/occ/occ_face.hpp +++ b/libsrc/occ/occ_face.hpp @@ -1,15 +1,15 @@ #ifndef FILE_OCC_FACE_INCLUDED #define FILE_OCC_FACE_INCLUDED -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" +// #pragma clang diagnostic push +// #pragma clang diagnostic ignored "-Wdeprecated-declarations" #include #include #include #include -#pragma clang diagnostic pop +// #pragma clang diagnostic pop #include "occ_vertex.hpp" #include "meshing.hpp" diff --git a/libsrc/occ/occ_utils.hpp b/libsrc/occ/occ_utils.hpp index 04973789..12a89693 100644 --- a/libsrc/occ/occ_utils.hpp +++ b/libsrc/occ/occ_utils.hpp @@ -3,8 +3,8 @@ #include -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" +// #pragma clang diagnostic push +// #pragma clang diagnostic ignored "-Wdeprecated-declarations" #include #include @@ -17,7 +17,7 @@ #include #include -#pragma clang diagnostic pop +// #pragma clang diagnostic pop #include "meshing.hpp" diff --git a/libsrc/occ/occ_vertex.hpp b/libsrc/occ/occ_vertex.hpp index bfd1479d..7207ac32 100644 --- a/libsrc/occ/occ_vertex.hpp +++ b/libsrc/occ/occ_vertex.hpp @@ -1,13 +1,13 @@ #ifndef FILE_OCC_VERTEX_INCLUDED #define FILE_OCC_VERTEX_INCLUDED -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" +// #pragma clang diagnostic push +// #pragma clang diagnostic ignored "-Wdeprecated-declarations" #include #include -#pragma clang diagnostic pop +// #pragma clang diagnostic pop #include "meshing.hpp" #include "occ_utils.hpp"