From 19ec4fc9ca8592d2fa2631c5df5747acd606d8ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Thu, 4 Jan 2018 18:45:07 +0100 Subject: [PATCH] more tracing and parallelization --- libsrc/interface/nginterface_v2.cpp | 2 +- libsrc/meshing/bisect.cpp | 22 +++++++++++++++++++++- libsrc/meshing/meshclass.cpp | 13 +++++++++++++ libsrc/meshing/meshclass.hpp | 2 ++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/libsrc/interface/nginterface_v2.cpp b/libsrc/interface/nginterface_v2.cpp index 79e5398b..37454db0 100644 --- a/libsrc/interface/nginterface_v2.cpp +++ b/libsrc/interface/nginterface_v2.cpp @@ -1009,7 +1009,7 @@ namespace netgen ref.Bisect (*mesh, biopt); (*tracer)("call updatetop", false); - mesh -> UpdateTopology(task_manager); + mesh -> UpdateTopology(task_manager, tracer); (*tracer)("call updatetop", true); mesh -> GetCurvedElements().SetIsHighOrder (false); } diff --git a/libsrc/meshing/bisect.cpp b/libsrc/meshing/bisect.cpp index ea61b872..ae5843fa 100644 --- a/libsrc/meshing/bisect.cpp +++ b/libsrc/meshing/bisect.cpp @@ -3346,13 +3346,15 @@ namespace netgen //IdentifyCutEdges(mesh, cutedges); - + + (*opt.tracer)("mark elements", false); hangingvol = MarkHangingTets (mtets, cutedges, opt.task_manager) + MarkHangingPrisms (mprisms, cutedges) + MarkHangingIdentifications (mids, cutedges); + (*opt.tracer)("mark elements", true); size_t nsel = mtris.Size(); NgProfiler::StartTimer (timer_bisecttrig); @@ -3625,6 +3627,8 @@ namespace netgen (*opt.tracer)("copy tets", false); mesh.ClearVolumeElements(); mesh.VolumeElements().SetAllocSize (mtets.Size()+mprisms.Size()); + mesh.VolumeElements().SetSize(mtets.Size()); + /* for (int i = 1; i <= mtets.Size(); i++) { Element el(TET); @@ -3634,6 +3638,22 @@ namespace netgen el.SetOrder (mtets.Get(i).order); mesh.AddVolumeElement (el); } + */ + ParallelForRange + (opt.task_manager, mtets.Size(), [&] (size_t begin, size_t end) + { + for (size_t i = begin; i < end; i++) + { + Element el(TET); + auto & tet = mtets[i]; + el.SetIndex (tet.matindex); + el.SetOrder (tet.order); + for (int j = 0; j < 4; j++) + el[j] = tet.pnums[j]; + mesh.SetVolumeElement (ElementIndex(i), el); + } + }); + (*opt.tracer)("copy tets", true); for (int i = 1; i <= mprisms.Size(); i++) diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index fa839789..554609d5 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -402,6 +402,19 @@ namespace netgen return ve; } + void Mesh :: SetVolumeElement (ElementIndex ei, const Element & el) + { + /* + int maxn = el[0]; + for (int i = 1; i < el.GetNP(); i++) + if (el[i] > maxn) maxn = el[i]; + + maxn += 1-PointIndex::BASE; + */ + + volelements[ei] = el; + volelements.Last().flags.illegal_valid = 0; + } diff --git a/libsrc/meshing/meshclass.hpp b/libsrc/meshing/meshclass.hpp index 19b1e65a..e996ef6d 100644 --- a/libsrc/meshing/meshclass.hpp +++ b/libsrc/meshing/meshclass.hpp @@ -307,6 +307,8 @@ namespace netgen DLL_HEADER void GetSurfaceElementsOfFace (int facenr, Array & sei) const; DLL_HEADER ElementIndex AddVolumeElement (const Element & el); + // write to pre-allocated container, thread-safe + DLL_HEADER void SetVolumeElement (ElementIndex sei, const Element & el); int GetNE () const { return volelements.Size(); }