From 001eaa32b6acb995cd579b40f303dcc66288c5b5 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Mon, 29 Mar 2021 13:55:23 +0200 Subject: [PATCH] DoArchive for LocalH --- libsrc/core/archive.hpp | 10 ++++++++++ libsrc/meshing/localh.cpp | 12 ++++++++++++ libsrc/meshing/localh.hpp | 12 ++++++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/libsrc/core/archive.hpp b/libsrc/core/archive.hpp index 3bab01f3..430262bf 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 & (float & d) = 0; virtual Archive & operator & (double & d) = 0; virtual Archive & operator & (int & i) = 0; virtual Archive & operator & (long & i) = 0; @@ -678,6 +679,8 @@ namespace ngcore BinaryOutArchive& operator=(BinaryOutArchive&&) = delete; using Archive::operator&; + Archive & operator & (float & f) override + { return Write(f); } Archive & operator & (double & d) override { return Write(d); } Archive & operator & (int & i) override @@ -749,6 +752,8 @@ namespace ngcore : BinaryInArchive(std::make_shared(filename)) { ; } using Archive::operator&; + Archive & operator & (float & f) override + { Read(f); return *this; } Archive & operator & (double & d) override { Read(d); return *this; } Archive & operator & (int & i) override @@ -813,6 +818,8 @@ namespace ngcore TextOutArchive(std::make_shared(filename)) { } using Archive::operator&; + Archive & operator & (float & f) override + { *stream << f << '\n'; return *this; } Archive & operator & (double & d) override { *stream << d << '\n'; return *this; } Archive & operator & (int & i) override @@ -864,6 +871,8 @@ namespace ngcore : TextInArchive(std::make_shared(filename)) {} using Archive::operator&; + Archive & operator & (float & f) override + { *stream >> f; return *this; } Archive & operator & (double & d) override { *stream >> d; return *this; } Archive & operator & (int & i) override @@ -924,6 +933,7 @@ namespace ngcore { h = (char*)&hash_value; } using Archive::operator&; + Archive & operator & (float & f) override { return ApplyHash(f); } Archive & operator & (double & d) override { return ApplyHash(d); } Archive & operator & (int & i) override { return ApplyHash(i); } Archive & operator & (short & i) override { return ApplyHash(i); } diff --git a/libsrc/meshing/localh.cpp b/libsrc/meshing/localh.cpp index 32298191..3afe8e25 100644 --- a/libsrc/meshing/localh.cpp +++ b/libsrc/meshing/localh.cpp @@ -23,6 +23,13 @@ namespace netgen hopt = 2 * h2; } + void GradingBox :: DoArchive(Archive& ar) + { + ar & xmid[0] & xmid[1] & xmid[2] & h2 & father & hopt & + flags.cutboundary & flags.isinner & flags.oldcell & flags.pinner; + for(auto i : Range(8)) + ar & childs[i]; + } BlockAllocator GradingBox :: ball(sizeof (GradingBox)); @@ -93,6 +100,11 @@ namespace netgen root->DeleteChilds(); } + void LocalH :: DoArchive(Archive& ar) + { + ar & root & grading & boxes & boundingbox & dimension; + } + void LocalH :: SetH (Point<3> p, double h) { if (dimension == 2) diff --git a/libsrc/meshing/localh.hpp b/libsrc/meshing/localh.hpp index 4f6881a0..caff6540 100644 --- a/libsrc/meshing/localh.hpp +++ b/libsrc/meshing/localh.hpp @@ -44,10 +44,14 @@ namespace netgen /// GradingBox (const double * ax1, const double * ax2); + /// default constructor for Archive + GradingBox() = default; /// void DeleteChilds(); /// + void DoArchive(Archive& ar); + Point<3> PMid() const { return Point<3> (xmid[0], xmid[1], xmid[2]); } double H2() const { return h2; } @@ -78,7 +82,7 @@ namespace netgen /// double grading; /// - NgArray boxes; + Array boxes; /// Box<3> boundingbox; /// octree or quadtree @@ -89,11 +93,15 @@ namespace netgen /// LocalH (const Box<3> & box, double grading, int adimension = 3) : LocalH (box.PMin(), box.PMax(), grading, adimension) { ; } - /// + /// Default ctor for archive + LocalH() = default; + ~LocalH(); /// void Delete(); /// + void DoArchive(Archive& ar); + /// void SetGrading (double agrading) { grading = agrading; } /// void SetH (Point<3> x, double h);