Merge branch 'fix_identified_point_handling' into 'master'

Fix handling identified points in Compress and MeshVolume

See merge request ngsolve/netgen!676
This commit is contained in:
Schöberl, Joachim 2024-09-27 16:30:29 +02:00
commit 592221ee19
4 changed files with 37 additions and 0 deletions

View File

@ -4214,6 +4214,8 @@ namespace netgen
for (int i = 0; i < lockedpoints.Size(); i++) for (int i = 0; i < lockedpoints.Size(); i++)
lockedpoints[i] = op2np[lockedpoints[i]]; lockedpoints[i] = op2np[lockedpoints[i]];
GetIdentifications().MapPoints(op2np);
/* /*
for (int i = 0; i < facedecoding.Size(); i++) for (int i = 0; i < facedecoding.Size(); i++)
facedecoding[i].firstelement = -1; facedecoding[i].firstelement = -1;

View File

@ -539,6 +539,8 @@ namespace netgen
} }
mesh.VolumeElements().DeleteAll(); mesh.VolumeElements().DeleteAll();
mesh.GetIdentifications().GetIdentifiedPoints().DeleteData();
for(auto & m_ : md) for(auto & m_ : md)
{ {
auto first_new_pi = m_.pmap.Range().Next(); auto first_new_pi = m_.pmap.Range().Next();

View File

@ -2694,6 +2694,7 @@ namespace netgen
{ {
identifiedpoints.DeleteData(); identifiedpoints.DeleteData();
identifiedpoints_nr.DeleteData(); identifiedpoints_nr.DeleteData();
idpoints_table.SetSize(0);
/* /*
delete identifiedpoints; delete identifiedpoints;
@ -2821,6 +2822,20 @@ namespace netgen
} }
Array<INDEX_3> Identifications :: GetPairs () const
{
Array<INDEX_3> 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, void Identifications :: GetPairs (int identnr,
NgArray<INDEX_2> & identpairs) const NgArray<INDEX_2> & 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<PointIndex, PointIndex> 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 void Identifications :: Print (ostream & ost) const
{ {

View File

@ -1633,6 +1633,7 @@ namespace netgen
/// ///
DLL_HEADER void GetPairs (int identnr, NgArray<INDEX_2> & identpairs) const; DLL_HEADER void GetPairs (int identnr, NgArray<INDEX_2> & identpairs) const;
DLL_HEADER Array<INDEX_3> GetPairs () const;
/// ///
int GetMaxNr () const { return maxidentnr; } int GetMaxNr () const { return maxidentnr; }
@ -1659,6 +1660,8 @@ namespace netgen
/// remove secondorder /// remove secondorder
void SetMaxPointNr (int maxpnum); void SetMaxPointNr (int maxpnum);
void MapPoints(FlatArray<PointIndex, PointIndex> op2np);
DLL_HEADER void Print (ostream & ost) const; DLL_HEADER void Print (ostream & ost) const;
void DoArchive (Archive & ar); void DoArchive (Archive & ar);