From ec20b74722eca539f10ca52d585d43f51de8f923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Thu, 13 Apr 2017 10:40:47 +0200 Subject: [PATCH] make Element default constructable/movable --- libsrc/meshing/bisect.cpp | 61 ++++++++++++++++++++-------------- libsrc/meshing/meshclass.cpp | 6 ++-- libsrc/meshing/meshing3.cpp | 2 +- libsrc/meshing/meshtype.cpp | 12 ++++--- libsrc/meshing/meshtype.hpp | 9 +++-- libsrc/meshing/refine.cpp | 2 +- libsrc/meshing/secondorder.cpp | 2 +- 7 files changed, 56 insertions(+), 38 deletions(-) diff --git a/libsrc/meshing/bisect.cpp b/libsrc/meshing/bisect.cpp index 5f073dc2..35e27ed9 100644 --- a/libsrc/meshing/bisect.cpp +++ b/libsrc/meshing/bisect.cpp @@ -1663,32 +1663,43 @@ namespace netgen int MarkHangingTets (T_MTETS & mtets, - const INDEX_2_CLOSED_HASHTABLE & cutedges) + const INDEX_2_CLOSED_HASHTABLE & cutedges, + TaskManager tm) { + static int timer = NgProfiler::CreateTimer ("MarkHangingTets"); + NgProfiler::RegionTimer reg (timer); + int hanging = 0; - for (int i = 1; i <= mtets.Size(); i++) - { - MarkedTet & teti = mtets.Elem(i); - - if (teti.marked) - { - hanging = 1; - continue; - } - - for (int j = 0; j < 3; j++) - for (int k = j+1; k < 4; k++) - { - INDEX_2 edge(teti.pnums[j], - teti.pnums[k]); - edge.Sort(); - if (cutedges.Used (edge)) - { - teti.marked = 1; - hanging = 1; - } - } - } + // for (int i = 1; i <= mtets.Size(); i++) + ParallelForRange + (tm, mtets.Size(), [&] (size_t begin, size_t end) + { + bool my_hanging = false; + for (size_t i = begin; i < end; i++) + { + MarkedTet & teti = mtets[i]; + + if (teti.marked) + { + my_hanging = true; + continue; + } + + for (int j = 0; j < 3; j++) + for (int k = j+1; k < 4; k++) + { + INDEX_2 edge(teti.pnums[j], + teti.pnums[k]); + edge.Sort(); + if (cutedges.Used (edge)) + { + teti.marked = 1; + my_hanging = true; + } + } + } + if (my_hanging) hanging = true; + }); return hanging; } @@ -3336,7 +3347,7 @@ namespace netgen hangingvol = - MarkHangingTets (mtets, cutedges) + + MarkHangingTets (mtets, cutedges, opt.task_manager) + MarkHangingPrisms (mprisms, cutedges) + MarkHangingIdentifications (mids, cutedges); diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 6b55df4a..81d7ead7 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -926,7 +926,7 @@ namespace netgen PrintMessage (3, n, " volume elements"); for (i = 1; i <= n; i++) { - Element el; + Element el(TET); int hi, nep; infile >> hi; if (hi == 0) hi = 1; @@ -1423,7 +1423,7 @@ namespace netgen PrintMessage (3, n, " volume elements"); for (i = 1; i <= n; i++) { - Element el; + Element el(TET); int hi, nep; infile >> hi; if (hi == 0) hi = 1; @@ -1960,7 +1960,7 @@ namespace netgen { for (int j = 1; j <= el.GetNFaces(); j++) { - Element2d hel; + Element2d hel(TRIG); el.GetFace (j, hel); hel.Invert(); hel.NormalizeNumbering(); diff --git a/libsrc/meshing/meshing3.cpp b/libsrc/meshing/meshing3.cpp index 9bb6b584..65854e62 100644 --- a/libsrc/meshing/meshing3.cpp +++ b/libsrc/meshing/meshing3.cpp @@ -390,7 +390,7 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp) delfaces.SetSize (0); INDEX npi; - Element newel; + Element newel(TET); npi = mesh.AddPoint (inp); newel.SetNP(4); diff --git a/libsrc/meshing/meshtype.cpp b/libsrc/meshing/meshtype.cpp index 1d01fb4c..5fab1c5d 100644 --- a/libsrc/meshing/meshtype.cpp +++ b/libsrc/meshing/meshtype.cpp @@ -967,7 +967,7 @@ namespace netgen return s; } - + /* Element :: Element () { typ = TET; @@ -990,9 +990,8 @@ namespace netgen #ifdef PARALLEL partitionNumber = -1; #endif - } - + */ Element :: Element (int anp) { @@ -1061,12 +1060,15 @@ namespace netgen flags.fixed = 0; orderx = ordery = orderz = 1; is_curved = typ != TET; // false; +#ifdef PARALLEL + partitionNumber = -1; +#endif } - + /* Element & Element :: operator= (const Element & el2) { typ = el2.typ; @@ -1083,7 +1085,7 @@ namespace netgen is_curved = el2.is_curved; return *this; } - + */ void Element :: SetNP (int anp) diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index a735047c..129e1fce 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -660,13 +660,18 @@ namespace netgen flagstruct flags; /// - DLL_HEADER Element (); + DLL_HEADER Element () = default; + Element (const Element &) = default; + Element (Element &&) = default; + Element & operator= (const Element &) = default; + Element & operator= (Element &&) = default; + /// Element (int anp); /// Element (ELEMENT_TYPE type); /// - Element & operator= (const Element & el2); + // Element & operator= (const Element & el2); /// void SetNP (int anp); diff --git a/libsrc/meshing/refine.cpp b/libsrc/meshing/refine.cpp index 3cb40d18..e6e1f7cb 100644 --- a/libsrc/meshing/refine.cpp +++ b/libsrc/meshing/refine.cpp @@ -436,7 +436,7 @@ namespace netgen int ind = el.GetIndex(); for (int j = 0; j < 8; j++) { - Element nel; + Element nel(TET); for (int k = 1; k <= 4; k++) nel.PNum(k) = pnums.Get(reftab[j][k-1]); nel.SetIndex(ind); diff --git a/libsrc/meshing/secondorder.cpp b/libsrc/meshing/secondorder.cpp index c7d906c3..861f99ed 100644 --- a/libsrc/meshing/secondorder.cpp +++ b/libsrc/meshing/secondorder.cpp @@ -204,7 +204,7 @@ namespace netgen const Element & el = mesh.VolumeElement(i); int onp = 0; - Element newel; + Element newel(TET); newel.SetIndex (el.GetIndex()); static int betw_tet[6][3] =