From 27b8b5e7c8156231a39537f178eb1d252d20e0a4 Mon Sep 17 00:00:00 2001 From: "Hochsteger, Matthias" Date: Fri, 27 Sep 2024 16:30:29 +0200 Subject: [PATCH] Fix handling identified points in Compress and MeshVolume --- libsrc/meshing/meshclass.cpp | 2 ++ libsrc/meshing/meshfunc.cpp | 2 ++ libsrc/meshing/meshtype.cpp | 30 ++++++++++++++++++++++++++++++ libsrc/meshing/meshtype.hpp | 3 +++ 4 files changed, 37 insertions(+) diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 74a95f70..0a291e91 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -4214,6 +4214,8 @@ namespace netgen for (int i = 0; i < lockedpoints.Size(); i++) lockedpoints[i] = op2np[lockedpoints[i]]; + + GetIdentifications().MapPoints(op2np); /* for (int i = 0; i < facedecoding.Size(); i++) facedecoding[i].firstelement = -1; diff --git a/libsrc/meshing/meshfunc.cpp b/libsrc/meshing/meshfunc.cpp index db941b53..f187abfa 100644 --- a/libsrc/meshing/meshfunc.cpp +++ b/libsrc/meshing/meshfunc.cpp @@ -539,6 +539,8 @@ namespace netgen } mesh.VolumeElements().DeleteAll(); + mesh.GetIdentifications().GetIdentifiedPoints().DeleteData(); + for(auto & m_ : md) { auto first_new_pi = m_.pmap.Range().Next(); diff --git a/libsrc/meshing/meshtype.cpp b/libsrc/meshing/meshtype.cpp index b754c1f7..5d15dd1b 100644 --- a/libsrc/meshing/meshtype.cpp +++ b/libsrc/meshing/meshtype.cpp @@ -2694,6 +2694,7 @@ namespace netgen { identifiedpoints.DeleteData(); identifiedpoints_nr.DeleteData(); + idpoints_table.SetSize(0); /* delete identifiedpoints; @@ -2821,6 +2822,20 @@ namespace netgen } + Array Identifications :: GetPairs () const + { + Array pairs; + for (auto i : IntRange(1, identifiedpoints.GetNBags()+1)) + for (auto j : IntRange(1, identifiedpoints.GetBagSize(i)+1)) + { + INDEX_2 i2; + int nr; + identifiedpoints.GetData (i, j, i2, nr); + pairs.Append ({i2.I1(), i2.I2(), nr}); + } + return pairs; + } + void Identifications :: GetPairs (int identnr, NgArray & identpairs) const { @@ -2866,6 +2881,21 @@ namespace netgen } } + // Map points in the identifications to new point numbers + // deletes identifications with invalid (mapped) points + void Identifications :: MapPoints(FlatArray op2np) + { + auto pairs = GetPairs(); + Delete(); + + for(auto pair : pairs) + { + auto p1 = op2np[pair.I1()]; + auto p2 = op2np[pair.I2()]; + if(p1.IsValid() && p2.IsValid()) + Add(p1, p2, pair.I3()); + } + } void Identifications :: Print (ostream & ost) const { diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index 634165c6..67928a91 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -1633,6 +1633,7 @@ namespace netgen /// DLL_HEADER void GetPairs (int identnr, NgArray & identpairs) const; + DLL_HEADER Array GetPairs () const; /// int GetMaxNr () const { return maxidentnr; } @@ -1659,6 +1660,8 @@ namespace netgen /// remove secondorder void SetMaxPointNr (int maxpnum); + void MapPoints(FlatArray op2np); + DLL_HEADER void Print (ostream & ost) const; void DoArchive (Archive & ar);