mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
more archive
This commit is contained in:
parent
f85b51496f
commit
bda771f86f
@ -259,7 +259,7 @@ namespace netgen
|
||||
first_id.Set();
|
||||
|
||||
|
||||
if (mesh.GetIdentifications().HasIdentifiedPoints())
|
||||
// if (mesh.GetIdentifications().HasIdentifiedPoints())
|
||||
{
|
||||
INDEX_2_HASHTABLE<int> & identpts =
|
||||
mesh.GetIdentifications().GetIdentifiedPoints ();
|
||||
|
@ -81,6 +81,8 @@ protected:
|
||||
|
||||
public:
|
||||
///
|
||||
BASE_INDEX_2_HASHTABLE () { ; }
|
||||
|
||||
BASE_INDEX_2_HASHTABLE (int size)
|
||||
: hash (size) { };
|
||||
|
||||
@ -113,6 +115,8 @@ class INDEX_2_HASHTABLE : public BASE_INDEX_2_HASHTABLE
|
||||
|
||||
public:
|
||||
///
|
||||
INDEX_2_HASHTABLE () { ; }
|
||||
|
||||
INDEX_2_HASHTABLE (int size)
|
||||
: BASE_INDEX_2_HASHTABLE (size), cont(size)
|
||||
{ ; }
|
||||
@ -254,8 +258,19 @@ public:
|
||||
|
||||
const T & GetData (const Iterator & it) const
|
||||
{ return cont[it.BagNr()][it.Pos()]; }
|
||||
|
||||
ngstd::Archive & DoArchive (ngstd::Archive & ar)
|
||||
{
|
||||
ar & hash & cont;
|
||||
return ar;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline ngstd::Archive & operator & (ngstd::Archive & archive, INDEX_2_HASHTABLE<T> & mp)
|
||||
{ return mp.DoArchive(archive); }
|
||||
|
||||
|
||||
|
||||
template <typename T>
|
||||
@ -285,6 +300,7 @@ protected:
|
||||
|
||||
public:
|
||||
///
|
||||
BASE_INDEX_3_HASHTABLE () { ; }
|
||||
BASE_INDEX_3_HASHTABLE (int size)
|
||||
: hash (size) { };
|
||||
|
||||
@ -322,6 +338,7 @@ class INDEX_3_HASHTABLE : private BASE_INDEX_3_HASHTABLE
|
||||
|
||||
public:
|
||||
///
|
||||
inline INDEX_3_HASHTABLE () { ; }
|
||||
inline INDEX_3_HASHTABLE (int size);
|
||||
///
|
||||
inline void Set (const INDEX_3 & ahash, const T & acont);
|
||||
@ -419,11 +436,21 @@ public:
|
||||
{ return cont[it.BagNr()][it.Pos()]; }
|
||||
|
||||
|
||||
ngstd::Archive & DoArchive (ngstd::Archive & ar)
|
||||
{
|
||||
ar & hash & cont;
|
||||
return ar;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline ngstd::Archive & operator & (ngstd::Archive & archive, INDEX_3_HASHTABLE<T> & mp)
|
||||
{ return mp.DoArchive(archive); }
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -211,4 +211,40 @@ namespace netgen
|
||||
data[i].size = data[i].maxsize;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ngstd::Archive & BASE_TABLE :: DoArchive (ngstd::Archive & ar, int elemsize)
|
||||
{
|
||||
if (ar.Output())
|
||||
{
|
||||
size_t entries = 0, size = data.Size();
|
||||
for (size_t i = 0; i < data.Size(); i++)
|
||||
entries += data[i].size;
|
||||
ar & size & entries;
|
||||
for (size_t i = 0; i < data.Size(); i++)
|
||||
{
|
||||
ar & data[i].size;
|
||||
ar.Do ((unsigned char*)data[i].col, data[i].size*elemsize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t entries, size;
|
||||
ar & size & entries;
|
||||
data.SetSize(size);
|
||||
oneblock = new char [entries*elemsize];
|
||||
char * ptr = oneblock;
|
||||
for (size_t i = 0; i < data.Size(); i++)
|
||||
{
|
||||
ar & data[i].size;
|
||||
data[i].col = ptr;
|
||||
data[i].maxsize = data[i].size;
|
||||
ar.Do ((unsigned char*)data[i].col, data[i].size*elemsize);
|
||||
ptr += size*elemsize;
|
||||
}
|
||||
}
|
||||
return ar;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -88,6 +88,8 @@ public:
|
||||
size_t UsedElements () const;
|
||||
|
||||
void SetElementSizesToMaxSizes ();
|
||||
|
||||
ngstd::Archive & DoArchive (ngstd::Archive & ar, int elemsize);
|
||||
};
|
||||
|
||||
|
||||
@ -235,8 +237,21 @@ public:
|
||||
|
||||
return FlatArray<T> (data[i-BASE].size, (T*)data[i-BASE].col);
|
||||
}
|
||||
|
||||
ngstd::Archive & DoArchive (ngstd::Archive & ar)
|
||||
{
|
||||
return BASE_TABLE::DoArchive(ar, sizeof(T));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <typename T, int BASE>
|
||||
inline ngstd::Archive & operator & (ngstd::Archive & archive, TABLE<T,BASE> & mp)
|
||||
{ return mp.DoArchive(archive); }
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T, int BASE>
|
||||
inline ostream & operator<< (ostream & ost, const TABLE<T,BASE> & table)
|
||||
|
@ -71,8 +71,6 @@ namespace netgen
|
||||
|
||||
void Ngx_Mesh :: DoArchive (ngstd::Archive & archive)
|
||||
{
|
||||
cout << "ngx_mesh, doarchive, output = " << archive.Output() << endl;
|
||||
cout << "mesh = " << mesh.get() << endl;
|
||||
if (archive.Input()) mesh = make_shared<Mesh>();
|
||||
mesh->DoArchive(archive);
|
||||
if (archive.Input())
|
||||
|
@ -1312,6 +1312,14 @@ namespace netgen
|
||||
archive & segments;
|
||||
archive & facedecoding;
|
||||
archive & materials & bcnames & cd2names;
|
||||
|
||||
if (archive.Output())
|
||||
archive & *ident;
|
||||
else
|
||||
{
|
||||
// ident = new Identifications(*this);
|
||||
archive & *ident;
|
||||
}
|
||||
|
||||
if (archive.Input())
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ namespace netgen
|
||||
epgeominfo[1].dist = 0;
|
||||
*/
|
||||
|
||||
bcname = 0;
|
||||
bcname = nullptr;
|
||||
}
|
||||
|
||||
Segment::Segment (const Segment & other)
|
||||
@ -2433,25 +2433,31 @@ namespace netgen
|
||||
|
||||
|
||||
Identifications :: Identifications (Mesh & amesh)
|
||||
: mesh(amesh)
|
||||
: mesh(amesh), identifiedpoints(100), identifiedpoints_nr(100)
|
||||
{
|
||||
identifiedpoints = new INDEX_2_HASHTABLE<int>(100);
|
||||
identifiedpoints_nr = new INDEX_3_HASHTABLE<int>(100);
|
||||
// identifiedpoints = new INDEX_2_HASHTABLE<int>(100);
|
||||
// identifiedpoints_nr = new INDEX_3_HASHTABLE<int>(100);
|
||||
maxidentnr = 0;
|
||||
}
|
||||
|
||||
Identifications :: ~Identifications ()
|
||||
{
|
||||
delete identifiedpoints;
|
||||
delete identifiedpoints_nr;
|
||||
;
|
||||
// delete identifiedpoints;
|
||||
// delete identifiedpoints_nr;
|
||||
}
|
||||
|
||||
void Identifications :: Delete ()
|
||||
{
|
||||
identifiedpoints.DeleteData();
|
||||
identifiedpoints_nr.DeleteData();
|
||||
|
||||
/*
|
||||
delete identifiedpoints;
|
||||
identifiedpoints = new INDEX_2_HASHTABLE<int>(100);
|
||||
delete identifiedpoints_nr;
|
||||
identifiedpoints_nr = new INDEX_3_HASHTABLE<int>(100);
|
||||
*/
|
||||
maxidentnr = 0;
|
||||
}
|
||||
|
||||
@ -2459,10 +2465,10 @@ namespace netgen
|
||||
{
|
||||
// (*testout) << "Identification::Add, pi1 = " << pi1 << ", pi2 = " << pi2 << ", identnr = " << identnr << endl;
|
||||
INDEX_2 pair (pi1, pi2);
|
||||
identifiedpoints->Set (pair, identnr);
|
||||
identifiedpoints.Set (pair, identnr);
|
||||
|
||||
INDEX_3 tripl (pi1, pi2, identnr);
|
||||
identifiedpoints_nr->Set (tripl, 1);
|
||||
identifiedpoints_nr.Set (tripl, 1);
|
||||
|
||||
if (identnr > maxidentnr) maxidentnr = identnr;
|
||||
|
||||
@ -2476,8 +2482,8 @@ namespace netgen
|
||||
int Identifications :: Get (PointIndex pi1, PointIndex pi2) const
|
||||
{
|
||||
INDEX_2 pair(pi1, pi2);
|
||||
if (identifiedpoints->Used (pair))
|
||||
return identifiedpoints->Get(pair);
|
||||
if (identifiedpoints.Used (pair))
|
||||
return identifiedpoints.Get(pair);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@ -2485,7 +2491,7 @@ namespace netgen
|
||||
bool Identifications :: Get (PointIndex pi1, PointIndex pi2, int nr) const
|
||||
{
|
||||
INDEX_3 tripl(pi1, pi2, nr);
|
||||
if (identifiedpoints_nr->Used (tripl))
|
||||
if (identifiedpoints_nr.Used (tripl))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
@ -2496,12 +2502,12 @@ namespace netgen
|
||||
int Identifications :: GetSymmetric (PointIndex pi1, PointIndex pi2) const
|
||||
{
|
||||
INDEX_2 pair(pi1, pi2);
|
||||
if (identifiedpoints->Used (pair))
|
||||
return identifiedpoints->Get(pair);
|
||||
if (identifiedpoints.Used (pair))
|
||||
return identifiedpoints.Get(pair);
|
||||
|
||||
pair = INDEX_2 (pi2, pi1);
|
||||
if (identifiedpoints->Used (pair))
|
||||
return identifiedpoints->Get(pair);
|
||||
if (identifiedpoints.Used (pair))
|
||||
return identifiedpoints.Get(pair);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2525,12 +2531,12 @@ namespace netgen
|
||||
{
|
||||
cout << "getmap, identnr = " << identnr << endl;
|
||||
|
||||
for (int i = 1; i <= identifiedpoints_nr->GetNBags(); i++)
|
||||
for (int j = 1; j <= identifiedpoints_nr->GetBagSize(i); j++)
|
||||
for (int i = 1; i <= identifiedpoints_nr.GetNBags(); i++)
|
||||
for (int j = 1; j <= identifiedpoints_nr.GetBagSize(i); j++)
|
||||
{
|
||||
INDEX_3 i3;
|
||||
int dummy;
|
||||
identifiedpoints_nr->GetData (i, j, i3, dummy);
|
||||
identifiedpoints_nr.GetData (i, j, i3, dummy);
|
||||
|
||||
if (i3.I3() == identnr || !identnr)
|
||||
{
|
||||
@ -2550,21 +2556,21 @@ namespace netgen
|
||||
identpairs.SetSize(0);
|
||||
|
||||
if (identnr == 0)
|
||||
for (int i = 1; i <= identifiedpoints->GetNBags(); i++)
|
||||
for (int j = 1; j <= identifiedpoints->GetBagSize(i); j++)
|
||||
for (int i = 1; i <= identifiedpoints.GetNBags(); i++)
|
||||
for (int j = 1; j <= identifiedpoints.GetBagSize(i); j++)
|
||||
{
|
||||
INDEX_2 i2;
|
||||
int nr;
|
||||
identifiedpoints->GetData (i, j, i2, nr);
|
||||
identifiedpoints.GetData (i, j, i2, nr);
|
||||
identpairs.Append (i2);
|
||||
}
|
||||
else
|
||||
for (int i = 1; i <= identifiedpoints_nr->GetNBags(); i++)
|
||||
for (int j = 1; j <= identifiedpoints_nr->GetBagSize(i); j++)
|
||||
for (int i = 1; i <= identifiedpoints_nr.GetNBags(); i++)
|
||||
for (int j = 1; j <= identifiedpoints_nr.GetBagSize(i); j++)
|
||||
{
|
||||
INDEX_3 i3;
|
||||
int dummy;
|
||||
identifiedpoints_nr->GetData (i, j, i3 , dummy);
|
||||
identifiedpoints_nr.GetData (i, j, i3 , dummy);
|
||||
|
||||
if (i3.I3() == identnr)
|
||||
identpairs.Append (INDEX_2(i3.I1(), i3.I2()));
|
||||
@ -2574,17 +2580,17 @@ namespace netgen
|
||||
|
||||
void Identifications :: SetMaxPointNr (int maxpnum)
|
||||
{
|
||||
for (int i = 1; i <= identifiedpoints->GetNBags(); i++)
|
||||
for (int j = 1; j <= identifiedpoints->GetBagSize(i); j++)
|
||||
for (int i = 1; i <= identifiedpoints.GetNBags(); i++)
|
||||
for (int j = 1; j <= identifiedpoints.GetBagSize(i); j++)
|
||||
{
|
||||
INDEX_2 i2;
|
||||
int nr;
|
||||
identifiedpoints->GetData (i, j, i2, nr);
|
||||
identifiedpoints.GetData (i, j, i2, nr);
|
||||
|
||||
if (i2.I1() > maxpnum || i2.I2() > maxpnum)
|
||||
{
|
||||
i2.I1() = i2.I2() = -1;
|
||||
identifiedpoints->SetData (i, j, i2, -1);
|
||||
identifiedpoints.SetData (i, j, i2, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2593,8 +2599,8 @@ namespace netgen
|
||||
void Identifications :: Print (ostream & ost) const
|
||||
{
|
||||
ost << "Identifications:" << endl;
|
||||
ost << "pairs: " << endl << *identifiedpoints << endl;
|
||||
ost << "pairs and nr: " << endl << *identifiedpoints_nr << endl;
|
||||
ost << "pairs: " << endl << identifiedpoints << endl;
|
||||
ost << "pairs and nr: " << endl << identifiedpoints_nr << endl;
|
||||
ost << "table: " << endl << idpoints_table << endl;
|
||||
}
|
||||
|
||||
|
@ -1445,17 +1445,17 @@ namespace netgen
|
||||
class Identifications
|
||||
{
|
||||
public:
|
||||
enum ID_TYPE { UNDEFINED = 1, PERIODIC = 2, CLOSESURFACES = 3, CLOSEEDGES = 4};
|
||||
enum ID_TYPE : unsigned char { UNDEFINED = 1, PERIODIC = 2, CLOSESURFACES = 3, CLOSEEDGES = 4};
|
||||
|
||||
|
||||
private:
|
||||
class Mesh & mesh;
|
||||
|
||||
/// identify points (thin layers, periodic b.c.)
|
||||
INDEX_2_HASHTABLE<int> * identifiedpoints;
|
||||
INDEX_2_HASHTABLE<int> identifiedpoints;
|
||||
|
||||
/// the same, with info about the id-nr
|
||||
INDEX_3_HASHTABLE<int> * identifiedpoints_nr;
|
||||
INDEX_3_HASHTABLE<int> identifiedpoints_nr;
|
||||
|
||||
/// sorted by identification nr
|
||||
TABLE<INDEX_2> idpoints_table;
|
||||
@ -1486,23 +1486,23 @@ namespace netgen
|
||||
bool Get (PointIndex pi1, PointIndex pi2, int identnr) const;
|
||||
bool GetSymmetric (PointIndex pi1, PointIndex pi2, int identnr) const;
|
||||
|
||||
bool HasIdentifiedPoints() const { return identifiedpoints != nullptr; }
|
||||
// bool HasIdentifiedPoints() const { return identifiedpoints != nullptr; }
|
||||
///
|
||||
INDEX_2_HASHTABLE<int> & GetIdentifiedPoints ()
|
||||
{
|
||||
return *identifiedpoints;
|
||||
return identifiedpoints;
|
||||
}
|
||||
|
||||
bool Used (PointIndex pi1, PointIndex pi2)
|
||||
{
|
||||
return identifiedpoints->Used (INDEX_2 (pi1, pi2));
|
||||
return identifiedpoints.Used (INDEX_2 (pi1, pi2));
|
||||
}
|
||||
|
||||
bool UsedSymmetric (PointIndex pi1, PointIndex pi2)
|
||||
{
|
||||
return
|
||||
identifiedpoints->Used (INDEX_2 (pi1, pi2)) ||
|
||||
identifiedpoints->Used (INDEX_2 (pi2, pi1));
|
||||
identifiedpoints.Used (INDEX_2 (pi1, pi2)) ||
|
||||
identifiedpoints.Used (INDEX_2 (pi2, pi1));
|
||||
}
|
||||
|
||||
///
|
||||
@ -1531,9 +1531,39 @@ namespace netgen
|
||||
void SetMaxPointNr (int maxpnum);
|
||||
|
||||
DLL_HEADER void Print (ostream & ost) const;
|
||||
|
||||
ngstd::Archive & DoArchive (ngstd::Archive & ar)
|
||||
{
|
||||
ar & maxidentnr;
|
||||
ar & identifiedpoints & identifiedpoints_nr;
|
||||
ar & idpoints_table;
|
||||
if (ar.Output())
|
||||
{
|
||||
size_t s = type.Size();
|
||||
ar & s;
|
||||
for (auto & t : type)
|
||||
ar & (unsigned char&)(t);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t s;
|
||||
ar & s;
|
||||
type.SetSize(s);
|
||||
for (auto & t : type)
|
||||
ar & (unsigned char&)(t);
|
||||
}
|
||||
|
||||
cout << "identifiedpoints = " << identifiedpoints << endl;
|
||||
cout << "identifiedpoints_nr = " << identifiedpoints_nr << endl;
|
||||
cout << "idpoints_table = " << idpoints_table << endl;
|
||||
cout << "type = " << type << endl;
|
||||
return ar;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
inline ngstd::Archive & operator & (ngstd::Archive & archive, Identifications & mp)
|
||||
{ return mp.DoArchive(archive); }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -861,7 +861,7 @@ namespace netgen
|
||||
|
||||
if (mesh -> HasIdentifications() )
|
||||
{
|
||||
if (mesh->GetIdentifications().HasIdentifiedPoints())
|
||||
// if (mesh->GetIdentifications().HasIdentifiedPoints())
|
||||
{
|
||||
INDEX_2_HASHTABLE<int> & idpts =
|
||||
mesh->GetIdentifications().GetIdentifiedPoints();
|
||||
|
Loading…
Reference in New Issue
Block a user