From bbc3661bfe808d48beba9e24246b14e22ed7ba01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Wed, 7 Aug 2019 07:47:08 +0200 Subject: [PATCH] remove timer, PointIndex::INVALID --- libsrc/meshing/improve2.cpp | 3 ++- libsrc/meshing/improve3.cpp | 6 ++++-- libsrc/meshing/meshing3.cpp | 20 ++++++++++---------- libsrc/meshing/meshtype.hpp | 13 ++++++++++++- libsrc/meshing/ruler3.cpp | 14 +++++++------- 5 files changed, 35 insertions(+), 21 deletions(-) diff --git a/libsrc/meshing/improve2.cpp b/libsrc/meshing/improve2.cpp index 022debba..582839e3 100644 --- a/libsrc/meshing/improve2.cpp +++ b/libsrc/meshing/improve2.cpp @@ -533,7 +533,8 @@ namespace netgen NgArray,PointIndex::BASE> normals(np); - for (PointIndex pi = mesh.Points().Begin(); pi < mesh.Points().End(); pi++) + // for (PointIndex pi = mesh.Points().Begin(); pi < mesh.Points().End(); pi++) + for (PointIndex pi : mesh.Points().Range()) { if (elementsonnode[pi].Size()) { diff --git a/libsrc/meshing/improve3.cpp b/libsrc/meshing/improve3.cpp index 98400ded..8d6482d0 100644 --- a/libsrc/meshing/improve3.cpp +++ b/libsrc/meshing/improve3.cpp @@ -576,7 +576,8 @@ void MeshOptimize3d :: SwapImprove (Mesh & mesh, OPTIMIZEGOAL goal, static Timer t("MeshOptimize3d::SwapImprove"); RegionTimer reg(t); static Timer tloop("MeshOptimize3d::SwapImprove loop"); - PointIndex pi3(0), pi4(0), pi5(0), pi6(0); + PointIndex pi3(PointIndex::INVALID), pi4(PointIndex::INVALID), + pi5(PointIndex::INVALID), pi6(PointIndex::INVALID); int cnt = 0; Element el21(TET), el22(TET), el31(TET), el32(TET), el33(TET); @@ -1178,6 +1179,7 @@ void MeshOptimize3d :: SwapImprove (Mesh & mesh, OPTIMIZEGOAL goal, } } + // if (goal == OPT_QUALITY) if (nsuround >= 5) { Element hel(TET); @@ -1209,7 +1211,7 @@ void MeshOptimize3d :: SwapImprove (Mesh & mesh, OPTIMIZEGOAL goal, // suroundpts.SetSize (nsuround); - suroundpts = -17; + suroundpts = PointIndex::INVALID; suroundpts[0] = pi3; suroundpts[1] = pi4; diff --git a/libsrc/meshing/meshing3.cpp b/libsrc/meshing/meshing3.cpp index 5030470f..6957251c 100644 --- a/libsrc/meshing/meshing3.cpp +++ b/libsrc/meshing/meshing3.cpp @@ -169,10 +169,10 @@ MESHING3_RESULT Meshing3 :: GenerateMesh (Mesh & mesh, const MeshingParameters & mp) { static Timer t("Meshing3::GenerateMesh"); RegionTimer reg(t); - static Timer meshing3_timer_a("Meshing3::GenerateMesh a", 2); - static Timer meshing3_timer_b("Meshing3::GenerateMesh b", 2); - static Timer meshing3_timer_c("Meshing3::GenerateMesh c", 1); - static Timer meshing3_timer_d("Meshing3::GenerateMesh d", 2); + // static Timer meshing3_timer_a("Meshing3::GenerateMesh a", 2); + // static Timer meshing3_timer_b("Meshing3::GenerateMesh b", 2); + // static Timer meshing3_timer_c("Meshing3::GenerateMesh c", 1); + // static Timer meshing3_timer_d("Meshing3::GenerateMesh d", 2); // static int meshing3_timer = NgProfiler::CreateTimer ("Meshing3::GenerateMesh"); // static int meshing3_timer_a = NgProfiler::CreateTimer ("Meshing3::GenerateMesh a"); // static int meshing3_timer_b = NgProfiler::CreateTimer ("Meshing3::GenerateMesh b"); @@ -293,13 +293,13 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp) double hinner = hmax * (1 + stat.qualclass); double houter = hmax * (1 + 2 * stat.qualclass); - meshing3_timer_a.Start(); + // meshing3_timer_a.Start(); stat.qualclass = adfront -> GetLocals (baseelem, locpoints, locfaces, pindex, findex, connectedpairs, houter, hinner, locfacesplit); - meshing3_timer_a.Stop(); + // meshing3_timer_a.Stop(); // (*testout) << "locfaces = " << endl << locfaces << endl; @@ -355,7 +355,7 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp) if (stat.qualclass >= mp.starshapeclass && mp.baseelnp != 4) { - NgProfiler::RegionTimer reg1 (meshing3_timer_b); + // NgProfiler::RegionTimer reg1 (meshing3_timer_b); // star-shaped domain removing grouppoints.SetSize (0); @@ -478,7 +478,7 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp) } // NgProfiler::StartTimer (meshing3_timer_c); - meshing3_timer_c.Start(); + // meshing3_timer_c.Start(); found = ApplyRules (plainpoints, allowpoint, locfaces, locfacesplit, connectedpairs, @@ -488,12 +488,12 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp) if (found >= 0) impossible = 0; if (found < 0) found = 0; - meshing3_timer_c.Stop(); + // meshing3_timer_c.Stop(); // NgProfiler::StopTimer (meshing3_timer_c); if (!found) loktestmode = 0; - NgProfiler::RegionTimer reg2 (meshing3_timer_d); + // NgProfiler::RegionTimer reg2 (meshing3_timer_d); if (loktestmode) { diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index a850fb32..700727e7 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -153,13 +153,24 @@ namespace netgen { int i; public: + class t_invalid { }; + static constexpr t_invalid INVALID; + PointIndex () = default; PointIndex (const PointIndex&) = default; PointIndex (PointIndex &&) = default; PointIndex & operator= (const PointIndex&) = default; PointIndex & operator= (PointIndex&&) = default; - PointIndex (int ai) : i(ai) { ; } + PointIndex (int ai) : i(ai) + { +#ifdef DEBUG + if (ai < PointIndex::BASE) + cout << "illegal PointIndex, use PointIndex::INVALID instead" << endl; + // throw Exception("illegal PointIndex, use PointIndex::INVALID instead"); +#endif + } + PointIndex (t_invalid inv) : i(PointIndex::BASE-1) { ; } // PointIndex & operator= (const PointIndex &ai) { i = ai.i; return *this; } operator int () const { return i; } PointIndex operator++ (int) { PointIndex hi(*this); i++; return hi; } diff --git a/libsrc/meshing/ruler3.cpp b/libsrc/meshing/ruler3.cpp index a853de03..42c1d83f 100644 --- a/libsrc/meshing/ruler3.cpp +++ b/libsrc/meshing/ruler3.cpp @@ -63,11 +63,11 @@ int Meshing3 :: ApplyRules ) { - static Timer t("ruler3 - all"); RegionTimer reg(t); - static Timer tstart("ruler3 - rule start"); - static Timer tloop("ruler3 - rule loop"); + // static Timer t("ruler3 - all"); RegionTimer reg(t); + // static Timer tstart("ruler3 - rule start"); + // static Timer tloop("ruler3 - rule loop"); - tstart.Start(); + // tstart.Start(); float err, minerr, teterr, minteterr; char ok, found, hc; // vnetrule * rule; @@ -224,8 +224,8 @@ int Meshing3 :: ApplyRules // check each rule: - tstart.Stop(); - tloop.Start(); + // tstart.Stop(); + // tloop.Start(); for (int ri = 1; ri <= rules.Size(); ri++) { int base = (lfaces[0].GetNP() == 3) ? 100 : 200; @@ -1115,7 +1115,7 @@ int Meshing3 :: ApplyRules if (loktestmode) (*testout) << "end rule" << endl; } - tloop.Stop(); + // tloop.Stop(); if (found) {