From e0f3ce9cf02b6c0392ce65cf22f655b5dde8b649 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Tue, 22 Jun 2021 11:57:30 +0200 Subject: [PATCH 1/5] fix loading of short mesh file names --- libsrc/interface/nginterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); From 971d6bb46564b70674148add633f4ccfc2d3dfeb Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Thu, 24 Jun 2021 07:37:53 +0200 Subject: [PATCH 2/5] little tuning of mesh pickling --- libsrc/core/archive.hpp | 12 ++++++++++++ libsrc/meshing/meshtype.hpp | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libsrc/core/archive.hpp b/libsrc/core/archive.hpp index decf8718..298f0395 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 diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index 9bf8084b..978e7b29 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); } }; @@ -845,8 +847,12 @@ namespace netgen ar & _np & _typ & index & _curved; if (ar.Input()) { np = _np; 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); } #ifdef PARALLEL From b65d3c188f1312026e1edfcf6e70cfa10d74a98c Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Thu, 24 Jun 2021 07:38:49 +0200 Subject: [PATCH 3/5] another optional table in Topology --- libsrc/meshing/topology.cpp | 6 +++++- libsrc/meshing/topology.hpp | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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; From f6befbbe0887f33ef520e067c81961198f7c9785 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Thu, 24 Jun 2021 12:55:39 +0200 Subject: [PATCH 4/5] remove cerr << 'BFGS udate error' --- libsrc/linalg/bfgs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; From 72fb819def651a937690a81c7fac422af06ea977 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Thu, 24 Jun 2021 13:21:43 +0200 Subject: [PATCH 5/5] missing overloads for archive (byte) --- libsrc/core/archive.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libsrc/core/archive.hpp b/libsrc/core/archive.hpp index 298f0395..a011b6bf 100644 --- a/libsrc/core/archive.hpp +++ b/libsrc/core/archive.hpp @@ -953,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); }