parallel clusters

This commit is contained in:
Joachim Schöberl 2016-11-20 19:55:17 +01:00
parent 9014669c56
commit 0edd570990
3 changed files with 43 additions and 6 deletions

View File

@ -16,11 +16,13 @@ namespace netgen
; ;
} }
void AnisotropicClusters :: Update() void AnisotropicClusters :: Update(TaskManager tm)
{ {
static int timer = NgProfiler::CreateTimer ("clusters"); static int timer = NgProfiler::CreateTimer ("clusters");
static int timer1 = NgProfiler::CreateTimer ("clusters1");
static int timer2 = NgProfiler::CreateTimer ("clusters2");
NgProfiler::RegionTimer reg (timer); NgProfiler::RegionTimer reg (timer);
const MeshTopology & top = mesh.GetTopology(); const MeshTopology & top = mesh.GetTopology();
bool hasedges = top.HasEdges(); bool hasedges = top.HasEdges();
@ -46,8 +48,10 @@ namespace netgen
Array<int> nnums, ednums, fanums; Array<int> nnums, ednums, fanums;
int changed; int changed;
NgProfiler::StartTimer(timer1);
/*
for (int i = 1; i <= ne; i++) for (int i = 1; i <= ne; i++)
{ {
const Element & el = mesh.VolumeElement(i); const Element & el = mesh.VolumeElement(i);
@ -72,8 +76,41 @@ namespace netgen
for (int j = 0; j < nnums.Size(); j++) for (int j = 0; j < nnums.Size(); j++)
cluster_reps.Elem(nnums[j]) = nnums[j]; cluster_reps.Elem(nnums[j]) = nnums[j];
} }
*/
ParallelForRange
(tm, ne,
[&] (size_t begin, size_t end)
{
Array<int> nnums, ednums, fanums;
for (int i = begin+1; i <= end; i++)
{
const Element & el = mesh.VolumeElement(i);
ELEMENT_TYPE typ = el.GetType();
top.GetElementEdges (i, ednums);
top.GetElementFaces (i, fanums);
int elnv = top.GetNVertices (typ);
int elned = ednums.Size();
int elnfa = fanums.Size();
nnums.SetSize(elnv+elned+elnfa+1);
for (int j = 1; j <= elnv; j++)
nnums.Elem(j) = el.PNum(j);
for (int j = 1; j <= elned; j++)
nnums.Elem(elnv+j) = nv+ednums.Elem(j);
for (int j = 1; j <= elnfa; j++)
nnums.Elem(elnv+elned+j) = nv+ned+fanums.Elem(j);
nnums.Elem(elnv+elned+elnfa+1) = nv+ned+nfa+i;
for (int j = 0; j < nnums.Size(); j++)
cluster_reps.Elem(nnums[j]) = nnums[j];
}
});
NgProfiler::StopTimer(timer1);
NgProfiler::StartTimer(timer2);
for (int i = 1; i <= nse; i++) for (int i = 1; i <= nse; i++)
{ {
@ -264,7 +301,7 @@ namespace netgen
} }
} }
while (changed); while (changed);
NgProfiler::StopTimer(timer2);
/* /*
(*testout) << "cluster reps:" << endl; (*testout) << "cluster reps:" << endl;
for (i = 1; i <= cluster_reps.Size(); i++) for (i = 1; i <= cluster_reps.Size(); i++)

View File

@ -27,7 +27,7 @@ public:
AnisotropicClusters (const Mesh & amesh); AnisotropicClusters (const Mesh & amesh);
~AnisotropicClusters(); ~AnisotropicClusters();
void Update(); void Update(TaskManager tm = &DummyTaskManager);
int GetVertexRepresentant (int vnr) const int GetVertexRepresentant (int vnr) const
{ return cluster_reps.Get(vnr); } { return cluster_reps.Get(vnr); }

View File

@ -5670,7 +5670,7 @@ namespace netgen
void Mesh :: UpdateTopology (TaskManager tm) void Mesh :: UpdateTopology (TaskManager tm)
{ {
topology->Update(tm); topology->Update(tm);
clusters->Update(); clusters->Update(tm);
#ifdef PARALLEL #ifdef PARALLEL
if (paralleltop) if (paralleltop)
{ {