some little steps

This commit is contained in:
Joachim Schoeberl 2025-01-02 10:17:24 +01:00
parent e926071bb2
commit 3b3491a597
5 changed files with 41 additions and 29 deletions

View File

@ -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 :: void BASE_INDEX_3_CLOSED_HASHTABLE ::

View File

@ -861,9 +861,10 @@ inline ostream & operator<< (ostream & ost, const INDEX_2_CLOSED_HASHTABLE<T> &
for (int i = 0; i < ht.Size(); i++) for (int i = 0; i < ht.Size(); i++)
if (ht.UsedPos(i)) if (ht.UsedPos(i))
{ {
INDEX_2 hash; // INDEX_2 hash;
T data; // T data;
ht.GetData0 (i, hash, data); // ht.GetData0 (i, hash, data);
auto [hash,data] = ht.GetBoth(i);
ost << "hash = " << hash << ", data = " << data << endl; ost << "hash = " << hash << ", data = " << data << endl;
} }
return ost; return ost;
@ -880,7 +881,8 @@ protected:
size_t mask; size_t mask;
protected: protected:
BASE_INDEX_3_CLOSED_HASHTABLE (size_t size) BASE_INDEX_3_CLOSED_HASHTABLE (size_t size);
/*
: hash(RoundUp2(size)) : hash(RoundUp2(size))
{ {
// cout << "orig size = " << size // cout << "orig size = " << size
@ -892,6 +894,7 @@ protected:
for (size_t i = 0; i < size; i++) for (size_t i = 0; i < size; i++)
hash[i].I1() = invalid; hash[i].I1() = invalid;
} }
*/
public: public:
int Size() const int Size() const
@ -1073,9 +1076,12 @@ inline ostream & operator<< (ostream & ost, const INDEX_3_CLOSED_HASHTABLE<T> &
for (int i = 0; i < ht.Size(); i++) for (int i = 0; i < ht.Size(); i++)
if (ht.UsedPos(i)) if (ht.UsedPos(i))
{ {
/*
INDEX_3 hash; INDEX_3 hash;
T data; T data;
ht.GetData (i, hash, data); ht.GetData (i, hash, data);
*/
auto [hash, data] = ht.GetBoth();
ost << "hash = " << hash << ", data = " << data << endl; ost << "hash = " << hash << ", data = " << data << endl;
} }
return ost; return ost;

View File

@ -114,8 +114,10 @@ class INDEX_2
public: public:
/// ///
// protected:
INDEX_2 () { } INDEX_2 () { }
INDEX_2 (const INDEX_2&) = default; INDEX_2 (const INDEX_2&) = default;
public:
INDEX_2 (INDEX_2&&) = default; INDEX_2 (INDEX_2&&) = default;
INDEX_2 & operator= (const INDEX_2&) = default; INDEX_2 & operator= (const INDEX_2&) = default;
@ -157,7 +159,7 @@ public:
return INDEX_2 (i1,i2); return INDEX_2 (i1,i2);
} }
operator std::array<INDEX,2>() { return { i[0], i[1] }; }
/// ///
INDEX & I1 () { return i[0]; } INDEX & I1 () { return i[0]; }
/// ///
@ -213,13 +215,10 @@ public:
/// ///
constexpr INDEX_3 (INDEX ai1, INDEX ai2, INDEX ai3) constexpr INDEX_3 (INDEX ai1, INDEX ai2, INDEX ai3)
: i{ai1, ai2, ai3} { } : i{ai1, ai2, ai3} { }
// { i[0] = ai1; i[1] = ai2; i[2] = ai3; }
/// ///
constexpr INDEX_3 (const INDEX_3 & in2) constexpr INDEX_3 (const INDEX_3 & in2)
: i{in2.i[0], in2.i[1], in2.i[2]} { } : 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) static INDEX_3 Sort (INDEX_3 i3)
{ {

View File

@ -95,7 +95,7 @@ namespace netgen
{ {
private: private:
/// Point Indizes /// Point Indizes
INDEX_2 l; INDEX_2 l; // want to replace by std::array<int,2> l;
/// quality class /// quality class
int lineclass; int lineclass;
/// geometry specific data /// geometry specific data
@ -109,23 +109,12 @@ namespace netgen
/// ///
FrontLine (const INDEX_2 & al) FrontLine (const INDEX_2 & al)
{ : l(al), lineclass(1) { }
l = al;
lineclass = 1;
}
/// ///
const INDEX_2 & L () const const auto & L () const { return l; }
{
return l;
}
/// ///
int LineClass() const int LineClass() const { return lineclass; }
{
return lineclass;
}
/// ///
void IncrementClass () void IncrementClass ()
@ -141,13 +130,13 @@ namespace netgen
/// ///
bool Valid () const bool Valid () const
{ {
return l.I1() != -1; return l[0] != -1;
} }
/// ///
void Invalidate () void Invalidate ()
{ {
l.I1() = -1; l[0] = -1;
l.I2() = -1; l[1] = -1;
lineclass = 1000; lineclass = 1000;
} }

View File

@ -454,6 +454,12 @@ namespace netgen
{ {
public: public:
using Index<int,ElementIndex,0>::Index; using Index<int,ElementIndex,0>::Index;
/*
private:
operator int() const { return i; }
public:
operator ptrdiff_t() const { return i; }
*/
}; };
inline istream & operator>> (istream & ist, ElementIndex & pi) inline istream & operator>> (istream & ist, ElementIndex & pi)