From 54693561478321bd9f8ceeb6f85c8a92501a197e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Thu, 4 Jan 2018 10:43:22 +0100 Subject: [PATCH] tracer in Netgen --- libsrc/general/parthreads.hpp | 3 +++ libsrc/include/nginterface_v2.hpp | 4 +++- libsrc/interface/nginterface_v2.cpp | 8 ++++++-- libsrc/meshing/bisect.cpp | 11 +++++++++-- libsrc/meshing/bisect.hpp | 1 + 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/libsrc/general/parthreads.hpp b/libsrc/general/parthreads.hpp index c19bd222..e799b8ab 100644 --- a/libsrc/general/parthreads.hpp +++ b/libsrc/general/parthreads.hpp @@ -97,12 +97,15 @@ void ParallelFor( int first, int next, const TFunc & f ) typedef void (*TaskManager)(std::function); + typedef void (*Tracer)(string, bool); // false .. start, true .. stop inline void DummyTaskManager (std::function func) { func(0,2); func(1,2); } + + inline void DummyTracer (string, bool) { ; } template inline void ParallelFor (TaskManager tm, size_t n, FUNC func) diff --git a/libsrc/include/nginterface_v2.hpp b/libsrc/include/nginterface_v2.hpp index 13d427f8..e5e26442 100644 --- a/libsrc/include/nginterface_v2.hpp +++ b/libsrc/include/nginterface_v2.hpp @@ -199,6 +199,7 @@ namespace netgen inline void DummyTaskManager2 (function func) { func(0,1); } + inline void DummyTracer2 (string, bool) { ; } class DLL_HEADER Ngx_Mesh { @@ -276,7 +277,8 @@ namespace netgen // std::pair GetBoundaryNeighbouringDomains (int bnr); void Refine (NG_REFINEMENT_TYPE reftype, - void (*taskmanager)(function) = &DummyTaskManager2); + void (*taskmanager)(function) = &DummyTaskManager2, + void (*tracer)(string, bool) = &DummyTracer2); // Find element of point, returns local coordinates diff --git a/libsrc/interface/nginterface_v2.cpp b/libsrc/interface/nginterface_v2.cpp index 51161796..79e5398b 100644 --- a/libsrc/interface/nginterface_v2.cpp +++ b/libsrc/interface/nginterface_v2.cpp @@ -989,7 +989,8 @@ namespace netgen void Ngx_Mesh :: Refine (NG_REFINEMENT_TYPE reftype, - void (*task_manager)(function)) + void (*task_manager)(function), + Tracer tracer) { NgLock meshlock (mesh->MajorMutex(), 1); @@ -1002,11 +1003,14 @@ namespace netgen if (reftype == NG_REFINE_HP) biopt.refine_hp = 1; biopt.task_manager = task_manager; + biopt.tracer = tracer; const Refinement & ref = mesh->GetGeometry()->GetRefinement(); ref.Bisect (*mesh, biopt); - + + (*tracer)("call updatetop", false); mesh -> UpdateTopology(task_manager); + (*tracer)("call updatetop", true); mesh -> GetCurvedElements().SetIsHighOrder (false); } diff --git a/libsrc/meshing/bisect.cpp b/libsrc/meshing/bisect.cpp index d08959e1..f26b1175 100644 --- a/libsrc/meshing/bisect.cpp +++ b/libsrc/meshing/bisect.cpp @@ -2667,6 +2667,8 @@ namespace netgen static int timer_bisecttrig = NgProfiler::CreateTimer ("Bisect trigs"); static int timer_bisectsegms = NgProfiler::CreateTimer ("Bisect segms"); NgProfiler::RegionTimer reg1 (timer); + + (*opt.tracer)("Bisect", false); NgProfiler::StartTimer (timer1); NgProfiler::StartTimer (timer1a); @@ -3218,6 +3220,7 @@ namespace netgen { // refine volume elements NgProfiler::StartTimer (timer_bisecttet); + (*opt.tracer)("bisecttet", false); int nel = mtets.Size(); for (int i = 1; i <= nel; i++) if (mtets.Elem(i).marked) @@ -3250,6 +3253,7 @@ namespace netgen mesh.mlparentelement.Append (i); } NgProfiler::StopTimer (timer_bisecttet); + (*opt.tracer)("bisecttet", true); int npr = mprisms.Size(); for (int i = 1; i <= npr; i++) if (mprisms.Elem(i).marked) @@ -3886,7 +3890,8 @@ namespace netgen } } } - + + (*opt.tracer)("Bisect", true); // Repair works only for tets! bool do_repair = mesh.PureTetMesh (); @@ -4020,8 +4025,10 @@ namespace netgen NgProfiler::StopTimer (timer2); NgProfiler::StartTimer (timer3); - NgProfiler::StartTimer (timer3a); + NgProfiler::StartTimer (timer3a); + (*opt.tracer)("topology from bisect", false); mesh.UpdateTopology(opt.task_manager); + (*opt.tracer)("topology from bisect", true); NgProfiler::StopTimer (timer3a); diff --git a/libsrc/meshing/bisect.hpp b/libsrc/meshing/bisect.hpp index 9d0cdb03..3fe0e85f 100644 --- a/libsrc/meshing/bisect.hpp +++ b/libsrc/meshing/bisect.hpp @@ -13,6 +13,7 @@ public: bool refine_hp; bool refine_p; TaskManager task_manager = &DummyTaskManager; + Tracer tracer = &DummyTracer; DLL_HEADER BisectionOptions (); };