cleanup, more parallel

This commit is contained in:
Matthias Hochsteger 2021-06-04 16:23:18 +02:00
parent 36d9ead3bc
commit ba148e8b3b

View File

@ -737,10 +737,13 @@ namespace netgen
} }
void DelaunayRemoveDegenerated( const Mesh::T_POINTS & points, NgArray<DelaunayTet> & tempels, NgBitArray & badnode, int np ) void DelaunayRemoveDegenerated( const Mesh::T_POINTS & points, NgArray<DelaunayTet> & tempels, int np )
{ {
static Timer tdegenerated("Delaunay - remove degenerated"); RegionTimer rt(tdegenerated); static Timer tdegenerated("Delaunay - remove degenerated"); RegionTimer rt(tdegenerated);
NgBitArray badnode(points.Size());
badnode.Clear();
int ndeg = 0; int ndeg = 0;
for (int i = 1; i <= tempels.Size(); i++) for (int i = 1; i <= tempels.Size(); i++)
{ {
@ -791,7 +794,7 @@ namespace netgen
} }
// Remove flat tets containing two adjacent surface trigs // Remove flat tets containing two adjacent surface trigs
void DelaunayRemoveTwoTriaTets( const Mesh & mesh, NgArray<DelaunayTet> & tempels, NgArray<int> & openels, NgBitArray & badnode, int np ) void DelaunayRemoveTwoTriaTets( const Mesh & mesh, NgArray<DelaunayTet> & tempels, NgArray<int> & openels )
{ {
static Timer topenel("Delaunay - find openel"); RegionTimer rt(topenel); static Timer topenel("Delaunay - find openel"); RegionTimer rt(topenel);
@ -876,8 +879,13 @@ namespace netgen
table.Add(tri[2], openel_i); table.Add(tri[2], openel_i);
}, mesh.GetNP()); }, mesh.GetNP());
for (auto i : openels) ngcore::BitArray badnode(mesh.GetNP()+PointIndex::BASE);
badnode.Clear();
ngcore::ParallelForRange(openels.Size(), [&] (auto myrange) {
for (auto i_ : myrange)
{ {
auto i = openels[i_];
const Element2d & tri = mesh.OpenElement(i); const Element2d & tri = mesh.OpenElement(i);
for( auto edge : Range(3) ) for( auto edge : Range(3) )
@ -929,8 +937,8 @@ namespace netgen
double h = v1.Length() + v2.Length() + v3.Length(); double h = v1.Length() + v2.Length() + v3.Length();
if (fabs (vol) < 1e-4 * (h * h * h)) // old: 1e-12 if (fabs (vol) < 1e-4 * (h * h * h)) // old: 1e-12
{ {
badnode.Set(pi2); badnode.SetBitAtomic(pi2);
badnode.Set(pi3); badnode.SetBitAtomic(pi3);
} }
break; break;
} }
@ -938,14 +946,15 @@ namespace netgen
} }
} }
} }
});
for (int i = ne; i >= 1; i--) for (int i = ne; i >= 1; i--)
{ {
const DelaunayTet & el = tempels.Get(i); const DelaunayTet & el = tempels.Get(i);
if (badnode.Test(el[0]) || if (badnode[el[0]] ||
badnode.Test(el[1]) || badnode[el[1]] ||
badnode.Test(el[2]) || badnode[el[2]] ||
badnode.Test(el[3]) ) badnode[el[3]] )
tempels.DeleteElement(i); tempels.DeleteElement(i);
} }
} }
@ -1643,13 +1652,10 @@ namespace netgen
tempels.Append (el); tempels.Append (el);
} }
NgBitArray badnode(mesh.GetNP()); DelaunayRemoveDegenerated(mesh.Points(), tempels, np);
badnode.Clear();
DelaunayRemoveDegenerated(mesh.Points(), tempels, badnode, np);
NgArray<int> openels; NgArray<int> openels;
DelaunayRemoveTwoTriaTets(mesh, tempels, openels, badnode, np); DelaunayRemoveTwoTriaTets(mesh, tempels, openels);
DelaunayRemoveIntersecting(mesh, tempels, openels, pmin, pmax); DelaunayRemoveIntersecting(mesh, tempels, openels, pmin, pmax);
DelaunayRemoveOuter(mesh, tempels, adfront); DelaunayRemoveOuter(mesh, tempels, adfront);