diff --git a/libsrc/general/array.hpp b/libsrc/general/array.hpp index 4bf7356e..74055662 100644 --- a/libsrc/general/array.hpp +++ b/libsrc/general/array.hpp @@ -774,6 +774,28 @@ namespace netgen } + + + template + ngstd::Archive & operator & (ngstd::Archive & archive, Array & a) + { + if (archive.Output()) + archive << a.Size(); + else + { + size_t size; + archive & size; + a.SetSize (size); + } + + /* + for (auto & ai : a) + archive & ai; + */ + archive.Do (&a[BASE], a.Size()); + return archive; + } + } #endif diff --git a/libsrc/general/mpi_interface.hpp b/libsrc/general/mpi_interface.hpp index ee08cb9b..c45494b6 100644 --- a/libsrc/general/mpi_interface.hpp +++ b/libsrc/general/mpi_interface.hpp @@ -39,20 +39,6 @@ namespace netgen { return MPI_DOUBLE; } - template class Vec; - template <> - inline MPI_Datatype MyGetMPIType > () - { - static MPI_Datatype MPI_T = 0; - if (!MPI_T) - { - MPI_Type_contiguous ( 3, MPI_DOUBLE, &MPI_T); - MPI_Type_commit ( &MPI_T ); - } - return MPI_T; - }; - - inline void MyMPI_Send (int i, int dest, int tag) { int hi = i; diff --git a/libsrc/general/myadt.hpp b/libsrc/general/myadt.hpp index 40279563..7c4374d8 100644 --- a/libsrc/general/myadt.hpp +++ b/libsrc/general/myadt.hpp @@ -21,6 +21,7 @@ #include "parthreads.hpp" // #include "moveablemem.hpp" #include "dynamicmem.hpp" +#include "archive_base.hpp" #include "template.hpp" #include "array.hpp" @@ -44,7 +45,6 @@ #include "mpi_interface.hpp" #include "netgenout.hpp" #include "gzstream.h" -#include "archive_base.hpp" #include "ngsimd.hpp" diff --git a/libsrc/gprim/geomobjects.hpp b/libsrc/gprim/geomobjects.hpp index 5c36ae83..ef5da2c5 100644 --- a/libsrc/gprim/geomobjects.hpp +++ b/libsrc/gprim/geomobjects.hpp @@ -396,6 +396,20 @@ namespace netgen }; +#ifdef PARALLEL + template <> + inline MPI_Datatype MyGetMPIType > () + { + static MPI_Datatype MPI_T = 0; + if (!MPI_T) + { + MPI_Type_contiguous ( 3, MPI_DOUBLE, &MPI_T); + MPI_Type_commit ( &MPI_T ); + } + return MPI_T; + }; +#endif + } diff --git a/libsrc/interface/nginterface_v2.cpp b/libsrc/interface/nginterface_v2.cpp index c23e5194..c95bfcaa 100644 --- a/libsrc/interface/nginterface_v2.cpp +++ b/libsrc/interface/nginterface_v2.cpp @@ -71,7 +71,16 @@ 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->DoArchive(archive); + if (archive.Input()) + { + netgen::mesh = mesh; + SetGlobalMesh (mesh); + } + /* if (archive.Output()) { stringstream str; @@ -86,6 +95,7 @@ namespace netgen stringstream str(st); LoadMesh (str); } + */ } void Ngx_Mesh :: UpdateTopology () diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index b5fd2b50..0c3e75b7 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -1303,7 +1303,34 @@ namespace netgen } + void Mesh :: DoArchive (ngstd::Archive & archive) + { + archive & dimension; + archive & points; + archive & surfelements; + archive & volelements; + archive & facedecoding; + + if (archive.Input()) + { + RebuildSurfaceElementLists(); + for (int faceindex = 1; faceindex <= GetNFD(); faceindex++) + { + Array seia; + GetSurfaceElementsOfFace (faceindex, seia); + cout << "seia = " << seia.Size() << endl; + } + + CalcSurfacesOfNode (); + if (ntasks == 1) // sequential run only + { + topology.Update(); + clusters -> Update(); + } + SetNextMajorTimeStamp(); + } + } void Mesh :: Merge (const string & filename, const int surfindex_offset) diff --git a/libsrc/meshing/meshclass.hpp b/libsrc/meshing/meshclass.hpp index 4cb18140..3ad3df7e 100644 --- a/libsrc/meshing/meshclass.hpp +++ b/libsrc/meshing/meshclass.hpp @@ -509,6 +509,7 @@ namespace netgen DLL_HEADER void Merge (const string & filename, const int surfindex_offset = 0); + DLL_HEADER void DoArchive (ngstd::Archive & archive); /// DLL_HEADER void ImproveMesh (const MeshingParameters & mp, OPTIMIZEGOAL goal = OPT_QUALITY); diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index fd30ebac..98b71989 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -170,8 +170,14 @@ namespace netgen #else enum { BASE = 1 }; #endif + + ngstd::Archive & DoArchive (ngstd::Archive & ar) { return ar & i; } }; + inline ngstd::Archive & operator & (ngstd::Archive & archive, PointIndex & mp) + { return mp.DoArchive(archive); } + + inline istream & operator>> (istream & ist, PointIndex & pi) { int i; ist >> i; pi = PointIndex(i); return ist; @@ -240,8 +246,15 @@ namespace netgen SurfaceElementIndex & operator++ () { ++i; return *this; } SurfaceElementIndex & operator-- () { --i; return *this; } SurfaceElementIndex & operator+= (int inc) { i+=inc; return *this; } + + ngstd::Archive & DoArchive (ngstd::Archive & ar) { return ar & i; } }; + inline ngstd::Archive & operator & (ngstd::Archive & archive, SurfaceElementIndex & mp) + { return mp.DoArchive(archive); } + + + inline istream & operator>> (istream & ist, SurfaceElementIndex & pi) { int i; ist >> i; pi = i; return ist; @@ -324,8 +337,23 @@ namespace netgen static MPI_Datatype MyGetMPIType ( ); #endif + ngstd::Archive & DoArchive (ngstd::Archive & ar) + { + ar & x[0] & x[1] & x[2] & layer & singular; + unsigned char _type; + if (ar.Output()) + { _type = type; ar & _type; } + else + { ar & _type; type = POINTTYPE(_type); } + return ar; + } }; + inline ngstd::Archive & operator & (ngstd::Archive & archive, MeshPoint & mp) + { return mp.DoArchive(archive); } + + + inline ostream & operator<<(ostream & s, const MeshPoint & pt) { return (s << Point<3> (pt)); @@ -349,7 +377,7 @@ namespace netgen PointGeomInfo geominfo[ELEMENT2D_MAXPOINTS]; /// surface nr - int index:16; + short int index; /// ELEMENT_TYPE typ; /// number of points @@ -473,6 +501,22 @@ namespace netgen /// const PointGeomInfo & GeomInfoPiMod (int i) const { return geominfo[(i-1) % np]; } + ngstd::Archive & DoArchive (ngstd::Archive & ar) + { + short _np, _typ; + bool _curved, _vis, _deleted; + if (ar.Output()) + { _np = np; _typ = typ; _curved = is_curved; + _vis = visible; _deleted = deleted; } + ar & _np & _typ & index & _curved & _vis & _deleted; + // ar & next; don't need + if (ar.Input()) + { np = _np; typ = ELEMENT_TYPE(_typ); is_curved = _curved; + visible = _vis; deleted = _deleted; } + for (size_t i = 0; i < np; i++) + ar & pnum[i]; + return ar; + } void SetIndex (int si) { index = si; } /// @@ -590,6 +634,8 @@ namespace netgen #endif }; + inline ngstd::Archive & operator & (ngstd::Archive & archive, Element2d & mp) + { return mp.DoArchive(archive); } ostream & operator<<(ostream & s, const Element2d & el); @@ -731,7 +777,20 @@ namespace netgen PointIndex & PNumMod (int i) { return pnum[(i-1) % np]; } /// const PointIndex & PNumMod (int i) const { return pnum[(i-1) % np]; } - + + ngstd::Archive & DoArchive (ngstd::Archive & ar) + { + short _np, _typ; + if (ar.Output()) + { _np = np; _typ = typ; } + ar & _np & _typ & index; + if (ar.Input()) + { np = _np; typ = ELEMENT_TYPE(_typ); } + for (size_t i = 0; i < np; i++) + ar & pnum[i]; + return ar; + } + /// void SetIndex (int si) { index = si; } /// @@ -873,6 +932,9 @@ namespace netgen int hp_elnr; }; + inline ngstd::Archive & operator & (ngstd::Archive & archive, Element & mp) + { return mp.DoArchive(archive); } + ostream & operator<<(ostream & s, const Element & el); @@ -1079,8 +1141,22 @@ namespace netgen SurfaceElementIndex FirstElement() { return firstelement; } // friend ostream & operator<<(ostream & s, const FaceDescriptor & fd); friend class Mesh; + + ngstd::Archive & DoArchive (ngstd::Archive & ar) + { + return ar & surfnr & domin & domout & tlosurf & bcprop + & surfcolour.X() & surfcolour.Y() & surfcolour.Z() + // & bcname // how to do that ? + // & firstelement // don't need it + & domin_singular & domout_singular ; + } + }; + inline ngstd::Archive & operator & (ngstd::Archive & archive, FaceDescriptor & mp) + { return mp.DoArchive(archive); } + + ostream & operator<< (ostream & s, const FaceDescriptor & fd);