diff --git a/libsrc/meshing/bisect.cpp b/libsrc/meshing/bisect.cpp index f26b1175..ea61b872 100644 --- a/libsrc/meshing/bisect.cpp +++ b/libsrc/meshing/bisect.cpp @@ -3622,7 +3622,7 @@ namespace netgen mtris.SetAllocSize (mtris.Size()); mquads.SetAllocSize (mquads.Size()); - + (*opt.tracer)("copy tets", false); mesh.ClearVolumeElements(); mesh.VolumeElements().SetAllocSize (mtets.Size()+mprisms.Size()); for (int i = 1; i <= mtets.Size(); i++) @@ -3634,6 +3634,8 @@ namespace netgen el.SetOrder (mtets.Get(i).order); mesh.AddVolumeElement (el); } + (*opt.tracer)("copy tets", true); + for (int i = 1; i <= mprisms.Size(); i++) { Element el(PRISM); @@ -3845,7 +3847,10 @@ namespace netgen mesh.ComputeNVertices(); + + (*opt.tracer)("call RebuildSurfElList", false); mesh.RebuildSurfaceElementLists(); + (*opt.tracer)("call RebuildSurfElList", true); // update identification tables @@ -4027,7 +4032,7 @@ namespace netgen NgProfiler::StartTimer (timer3a); (*opt.tracer)("topology from bisect", false); - mesh.UpdateTopology(opt.task_manager); + mesh.UpdateTopology(opt.task_manager, opt.tracer); (*opt.tracer)("topology from bisect", true); NgProfiler::StopTimer (timer3a); diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 3939c4f2..01604766 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -5768,10 +5768,13 @@ namespace netgen return 1; } - void Mesh :: UpdateTopology (TaskManager tm) + void Mesh :: UpdateTopology (TaskManager tm, + Tracer tracer) { - topology.Update(tm); + topology.Update(tm, tracer); + (*tracer)("call update clusters", false); clusters->Update(tm); + (*tracer)("call update clusters", true); #ifdef PARALLEL if (paralleltop) { diff --git a/libsrc/meshing/meshclass.hpp b/libsrc/meshing/meshclass.hpp index 0832fcf8..19b1e65a 100644 --- a/libsrc/meshing/meshclass.hpp +++ b/libsrc/meshing/meshclass.hpp @@ -705,7 +705,8 @@ namespace netgen const MeshTopology & GetTopology () const { return topology; } - DLL_HEADER void UpdateTopology (TaskManager tm = &DummyTaskManager); + DLL_HEADER void UpdateTopology (TaskManager tm = &DummyTaskManager, + Tracer tracer = &DummyTracer); class CurvedElements & GetCurvedElements () const { return *curvedelems; } diff --git a/libsrc/meshing/topology.cpp b/libsrc/meshing/topology.cpp index 83ed7aed..3e4ad494 100644 --- a/libsrc/meshing/topology.cpp +++ b/libsrc/meshing/topology.cpp @@ -4,6 +4,11 @@ namespace netgen { + template + inline atomic & AsAtomic (T & d) + { + return reinterpret_cast&> (d); + } @@ -331,7 +336,7 @@ namespace netgen } - void MeshTopology :: Update (TaskManager tm) + void MeshTopology :: Update (TaskManager tm, Tracer tracer) { static int timer = NgProfiler::CreateTimer ("topology"); NgProfiler::RegionTimer reg (timer); @@ -358,7 +363,8 @@ namespace netgen (*testout) << "nseg = " << nseg << endl; (*testout) << "np = " << np << endl; (*testout) << "nv = " << nv << endl; - + + (*tracer) ("Topology::Update setup tables", false); Array cnt(nv); Array vnums; @@ -369,13 +375,26 @@ namespace netgen vertex to segment */ cnt = 0; + /* for (ElementIndex ei = 0; ei < ne; ei++) { const Element & el = (*mesh)[ei]; for (int j = 0; j < el.GetNV(); j++) cnt[el[j]]++; } - + */ + ParallelForRange + (tm, ne, + [&] (size_t begin, size_t end) + { + for (ElementIndex ei = begin; ei < end; ei++) + { + const Element & el = (*mesh)[ei]; + for (int j = 0; j < el.GetNV(); j++) + AsAtomic(cnt[el[j]])++; + } + }); + vert2element = TABLE (cnt); for (ElementIndex ei = 0; ei < ne; ei++) { @@ -385,12 +404,27 @@ namespace netgen } cnt = 0; + /* for (SurfaceElementIndex sei = 0; sei < nse; sei++) { const Element2d & el = (*mesh)[sei]; for (int j = 0; j < el.GetNV(); j++) cnt[el[j]]++; } + */ + ParallelForRange + (tm, nse, + [&] (size_t begin, size_t end) + { + for (SurfaceElementIndex ei = begin; ei < end; ei++) + { + const Element2d & el = (*mesh)[ei]; + for (int j = 0; j < el.GetNV(); j++) + AsAtomic(cnt[el[j]])++; + } + }); + + vert2surfelement = TABLE (cnt); for (SurfaceElementIndex sei = 0; sei < nse; sei++) @@ -430,6 +464,7 @@ namespace netgen const Element0d & pointel = mesh->pointelements[pei]; vert2pointelement.AddSave (pointel.pnum, pei); } + (*tracer) ("Topology::Update setup tables", true); if (buildedges) diff --git a/libsrc/meshing/topology.hpp b/libsrc/meshing/topology.hpp index aca17d41..831a1ca5 100644 --- a/libsrc/meshing/topology.hpp +++ b/libsrc/meshing/topology.hpp @@ -83,7 +83,7 @@ public: bool HasFaces () const { return buildfaces; } - void Update(TaskManager tm = &DummyTaskManager); + void Update(TaskManager tm = &DummyTaskManager, Tracer tracer = &DummyTracer); int GetNEdges () const { return edge2vert.Size(); }