From 3b3491a597affe1f2cc1da7eb703cda40e4bfc7b Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Thu, 2 Jan 2025 10:17:24 +0100 Subject: [PATCH] some little steps --- libsrc/general/hashtabl.cpp | 14 +++++++++++++- libsrc/general/hashtabl.hpp | 16 +++++++++++----- libsrc/general/template.hpp | 9 ++++----- libsrc/meshing/adfront2.hpp | 25 +++++++------------------ libsrc/meshing/meshtype.hpp | 6 ++++++ 5 files changed, 41 insertions(+), 29 deletions(-) diff --git a/libsrc/general/hashtabl.cpp b/libsrc/general/hashtabl.cpp index 30f6ed1f..c0be3c1c 100644 --- a/libsrc/general/hashtabl.cpp +++ b/libsrc/general/hashtabl.cpp @@ -292,7 +292,19 @@ namespace netgen - + BASE_INDEX_3_CLOSED_HASHTABLE :: + BASE_INDEX_3_CLOSED_HASHTABLE (size_t size) + : hash(RoundUp2(size)) + { + // cout << "orig size = " << size + // << ", roundup size = " << hash.Size(); + size = hash.Size(); + mask = size-1; + // cout << "mask = " << mask << endl; + invalid = -1; + for (size_t i = 0; i < size; i++) + hash[i].I1() = invalid; + } void BASE_INDEX_3_CLOSED_HASHTABLE :: diff --git a/libsrc/general/hashtabl.hpp b/libsrc/general/hashtabl.hpp index 110e4df4..07c0c7b2 100644 --- a/libsrc/general/hashtabl.hpp +++ b/libsrc/general/hashtabl.hpp @@ -861,9 +861,10 @@ inline ostream & operator<< (ostream & ost, const INDEX_2_CLOSED_HASHTABLE & for (int i = 0; i < ht.Size(); i++) if (ht.UsedPos(i)) { - INDEX_2 hash; - T data; - ht.GetData0 (i, hash, data); + // INDEX_2 hash; + // T data; + // ht.GetData0 (i, hash, data); + auto [hash,data] = ht.GetBoth(i); ost << "hash = " << hash << ", data = " << data << endl; } return ost; @@ -880,7 +881,8 @@ protected: size_t mask; protected: - BASE_INDEX_3_CLOSED_HASHTABLE (size_t size) + BASE_INDEX_3_CLOSED_HASHTABLE (size_t size); + /* : hash(RoundUp2(size)) { // cout << "orig size = " << size @@ -892,6 +894,7 @@ protected: for (size_t i = 0; i < size; i++) hash[i].I1() = invalid; } + */ public: int Size() const @@ -1073,9 +1076,12 @@ inline ostream & operator<< (ostream & ost, const INDEX_3_CLOSED_HASHTABLE & for (int i = 0; i < ht.Size(); i++) if (ht.UsedPos(i)) { + /* INDEX_3 hash; T data; - ht.GetData (i, hash, data); + ht.GetData (i, hash, data); + */ + auto [hash, data] = ht.GetBoth(); ost << "hash = " << hash << ", data = " << data << endl; } return ost; diff --git a/libsrc/general/template.hpp b/libsrc/general/template.hpp index a006a5c2..a3b9457d 100644 --- a/libsrc/general/template.hpp +++ b/libsrc/general/template.hpp @@ -114,8 +114,10 @@ class INDEX_2 public: /// + // protected: INDEX_2 () { } INDEX_2 (const INDEX_2&) = default; +public: INDEX_2 (INDEX_2&&) = default; INDEX_2 & operator= (const INDEX_2&) = default; @@ -157,7 +159,7 @@ public: return INDEX_2 (i1,i2); } - + operator std::array() { return { i[0], i[1] }; } /// INDEX & I1 () { return i[0]; } /// @@ -213,13 +215,10 @@ public: /// constexpr INDEX_3 (INDEX ai1, INDEX ai2, INDEX ai3) : i{ai1, ai2, ai3} { } - // { i[0] = ai1; i[1] = ai2; i[2] = ai3; } - /// + /// constexpr INDEX_3 (const INDEX_3 & in2) : i{in2.i[0], in2.i[1], in2.i[2]} { } - // { i[0] = in2.i[0]; i[1] = in2.i[1]; i[2] = in2.i[2]; } - static INDEX_3 Sort (INDEX_3 i3) { diff --git a/libsrc/meshing/adfront2.hpp b/libsrc/meshing/adfront2.hpp index 497580ca..d1d03472 100644 --- a/libsrc/meshing/adfront2.hpp +++ b/libsrc/meshing/adfront2.hpp @@ -95,7 +95,7 @@ namespace netgen { private: /// Point Indizes - INDEX_2 l; + INDEX_2 l; // want to replace by std::array l; /// quality class int lineclass; /// geometry specific data @@ -109,23 +109,12 @@ namespace netgen /// FrontLine (const INDEX_2 & al) - { - l = al; - lineclass = 1; - } - + : l(al), lineclass(1) { } /// - const INDEX_2 & L () const - { - return l; - } - + const auto & L () const { return l; } /// - int LineClass() const - { - return lineclass; - } + int LineClass() const { return lineclass; } /// void IncrementClass () @@ -141,13 +130,13 @@ namespace netgen /// bool Valid () const { - return l.I1() != -1; + return l[0] != -1; } /// void Invalidate () { - l.I1() = -1; - l.I2() = -1; + l[0] = -1; + l[1] = -1; lineclass = 1000; } diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index 6f70248f..1dc2ac98 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -454,6 +454,12 @@ namespace netgen { public: using Index::Index; + /* + private: + operator int() const { return i; } + public: + operator ptrdiff_t() const { return i; } + */ }; inline istream & operator>> (istream & ist, ElementIndex & pi)