diff --git a/libsrc/core/archive.hpp b/libsrc/core/archive.hpp index decf8718..a011b6bf 100644 --- a/libsrc/core/archive.hpp +++ b/libsrc/core/archive.hpp @@ -153,6 +153,7 @@ namespace ngcore virtual void NeedsVersion(const std::string& /*unused*/, const std::string& /*unused*/) {} // Pure virtual functions that have to be implemented by In-/OutArchive + virtual Archive & operator & (std::byte & d) = 0; virtual Archive & operator & (float & d) = 0; virtual Archive & operator & (double & d) = 0; virtual Archive & operator & (int & i) = 0; @@ -275,6 +276,9 @@ namespace ngcore Archive & Do (T * data, size_t n) { for (size_t j = 0; j < n; j++) { (*this) & data[j]; }; return *this; }; // NOLINT + virtual Archive & Do (std::byte * d, size_t n) + { for (size_t j = 0; j < n; j++) { (*this) & d[j]; }; return *this; }; // NOLINT + virtual Archive & Do (double * d, size_t n) { for (size_t j = 0; j < n; j++) { (*this) & d[j]; }; return *this; }; // NOLINT @@ -679,6 +683,8 @@ namespace ngcore BinaryOutArchive& operator=(BinaryOutArchive&&) = delete; using Archive::operator&; + Archive & operator & (std::byte & d) override + { return Write(d); } Archive & operator & (float & f) override { return Write(f); } Archive & operator & (double & d) override @@ -755,6 +761,8 @@ namespace ngcore : BinaryInArchive(std::make_shared(filename)) { ; } using Archive::operator&; + Archive & operator & (std::byte & d) override + { Read(d); return *this; } Archive & operator & (float & f) override { Read(f); return *this; } Archive & operator & (double & d) override @@ -826,6 +834,8 @@ namespace ngcore TextOutArchive(std::make_shared(filename)) { } using Archive::operator&; + Archive & operator & (std::byte & d) override + { *stream << std::hex << int(d) << ' '; return *this; } Archive & operator & (float & f) override { *stream << f << '\n'; return *this; } Archive & operator & (double & d) override @@ -879,6 +889,8 @@ namespace ngcore : TextInArchive(std::make_shared(filename)) {} using Archive::operator&; + Archive & operator & (std::byte & d) override + { int tmp; *stream >> std::hex >> tmp; d = std::byte(tmp); return *this; } Archive & operator & (float & f) override { *stream >> f; return *this; } Archive & operator & (double & d) override @@ -941,6 +953,7 @@ namespace ngcore { h = (char*)&hash_value; } using Archive::operator&; + Archive & operator & (std::byte & d) override { return ApplyHash(d); } Archive & operator & (float & f) override { return ApplyHash(f); } Archive & operator & (double & d) override { return ApplyHash(d); } Archive & operator & (int & i) override { return ApplyHash(i); } diff --git a/libsrc/interface/nginterface.cpp b/libsrc/interface/nginterface.cpp index d38b7234..525ed035 100644 --- a/libsrc/interface/nginterface.cpp +++ b/libsrc/interface/nginterface.cpp @@ -150,7 +150,7 @@ void Ng_LoadMesh (const char * filename, ngcore::NgMPI_Comm comm) mesh->SetCommunicator(comm); string fn(filename); - if (fn.substr (fn.length()-8, 8) == ".vol.bin") + if (fn.length() > 8 && fn.substr (fn.length()-8, 8) == ".vol.bin") { mesh -> Load(fn); SetGlobalMesh (mesh); diff --git a/libsrc/linalg/bfgs.cpp b/libsrc/linalg/bfgs.cpp index 65189dee..49fcaa48 100644 --- a/libsrc/linalg/bfgs.cpp +++ b/libsrc/linalg/bfgs.cpp @@ -331,7 +331,7 @@ double BFGS ( { if (LDLtUpdate (l, d, 1 / a1, y) != 0) { - cerr << "BFGS update error1" << endl; + // cerr << "BFGS update error1" << endl; (*testout) << "BFGS update error1" << endl; (*testout) << "l " << endl << l << endl << "d " << d << endl; @@ -341,7 +341,7 @@ double BFGS ( if (LDLtUpdate (l, d, -1 / a2, bs) != 0) { - cerr << "BFGS update error2" << endl; + // cerr << "BFGS update error2" << endl; (*testout) << "BFGS update error2" << endl; (*testout) << "l " << endl << l << endl << "d " << d << endl; diff --git a/libsrc/meshing/meshtype.cpp b/libsrc/meshing/meshtype.cpp index 46ea7b57..4a42abd8 100644 --- a/libsrc/meshing/meshtype.cpp +++ b/libsrc/meshing/meshtype.cpp @@ -1140,8 +1140,8 @@ namespace netgen typ = ELEMENT_TYPE(_typ); is_curved = _curved; - for (size_t i = 0; i < np; i++) - ar & pnum[i]; + static_assert(sizeof(int) == sizeof (PointIndex)); + ar.Do( (int*)&pnum[0], np); } void Element :: SetOrder (const int aorder) diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index 3a63a9ca..21289121 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -377,7 +377,9 @@ namespace netgen void DoArchive (Archive & ar) { - ar & x[0] & x[1] & x[2] & layer & singular; + // ar & x[0] & x[1] & x[2] & layer & singular; + ar.Do(&x[0], 3); + ar & layer & singular; ar & (unsigned char&)(type); } }; diff --git a/libsrc/meshing/topology.cpp b/libsrc/meshing/topology.cpp index f085bcd6..59dd0251 100644 --- a/libsrc/meshing/topology.cpp +++ b/libsrc/meshing/topology.cpp @@ -49,6 +49,7 @@ namespace netgen { buildedges = static_buildedges; buildfaces = static_buildfaces; + buildvertex2element = static_buildvertex2element; timestamp = -1; } @@ -75,6 +76,7 @@ namespace netgen bool MeshTopology :: static_buildedges = true; bool MeshTopology :: static_buildfaces = true; + bool MeshTopology :: static_buildvertex2element = true; void MeshTopology :: EnableTableStatic (string name, bool set) { @@ -82,9 +84,11 @@ namespace netgen static_buildedges = set; else if (name == "faces") static_buildfaces = set; + else if (name == "vertex2element") + static_buildvertex2element = set; else throw Exception ("noting known about table "+name +"\n" - "knwon are 'edges', 'faces'"); + "knwon are 'edges', 'faces', 'vertex2element'"); } diff --git a/libsrc/meshing/topology.hpp b/libsrc/meshing/topology.hpp index eb537a81..b6d700f3 100644 --- a/libsrc/meshing/topology.hpp +++ b/libsrc/meshing/topology.hpp @@ -43,12 +43,12 @@ struct T_FACE class MeshTopology { const Mesh * mesh; - bool buildvertex2element = true; + bool buildvertex2element; bool buildedges; bool buildfaces; bool build_parent_edges = false; // may be changed to default = false bool build_parent_faces = false; // may be changed to default = false - static bool static_buildedges, static_buildfaces; + static bool static_buildedges, static_buildfaces, static_buildvertex2element; NgArray edge2vert; NgArray face2vert;