Merge branch 'archive_localh' into 'master'

DoArchive for LocalH

See merge request jschoeberl/netgen!375
This commit is contained in:
Joachim Schöberl 2021-03-29 12:46:18 +00:00
commit f63734e4a0
3 changed files with 32 additions and 2 deletions

View File

@ -153,6 +153,7 @@ namespace ngcore
virtual void NeedsVersion(const std::string& /*unused*/, const std::string& /*unused*/) {} virtual void NeedsVersion(const std::string& /*unused*/, const std::string& /*unused*/) {}
// Pure virtual functions that have to be implemented by In-/OutArchive // 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 & (double & d) = 0;
virtual Archive & operator & (int & i) = 0; virtual Archive & operator & (int & i) = 0;
virtual Archive & operator & (long & i) = 0; virtual Archive & operator & (long & i) = 0;
@ -678,6 +679,8 @@ namespace ngcore
BinaryOutArchive& operator=(BinaryOutArchive&&) = delete; BinaryOutArchive& operator=(BinaryOutArchive&&) = delete;
using Archive::operator&; using Archive::operator&;
Archive & operator & (float & f) override
{ return Write(f); }
Archive & operator & (double & d) override Archive & operator & (double & d) override
{ return Write(d); } { return Write(d); }
Archive & operator & (int & i) override Archive & operator & (int & i) override
@ -749,6 +752,8 @@ namespace ngcore
: BinaryInArchive(std::make_shared<std::ifstream>(filename)) { ; } : BinaryInArchive(std::make_shared<std::ifstream>(filename)) { ; }
using Archive::operator&; using Archive::operator&;
Archive & operator & (float & f) override
{ Read(f); return *this; }
Archive & operator & (double & d) override Archive & operator & (double & d) override
{ Read(d); return *this; } { Read(d); return *this; }
Archive & operator & (int & i) override Archive & operator & (int & i) override
@ -813,6 +818,8 @@ namespace ngcore
TextOutArchive(std::make_shared<std::ofstream>(filename)) { } TextOutArchive(std::make_shared<std::ofstream>(filename)) { }
using Archive::operator&; using Archive::operator&;
Archive & operator & (float & f) override
{ *stream << f << '\n'; return *this; }
Archive & operator & (double & d) override Archive & operator & (double & d) override
{ *stream << d << '\n'; return *this; } { *stream << d << '\n'; return *this; }
Archive & operator & (int & i) override Archive & operator & (int & i) override
@ -864,6 +871,8 @@ namespace ngcore
: TextInArchive(std::make_shared<std::ifstream>(filename)) {} : TextInArchive(std::make_shared<std::ifstream>(filename)) {}
using Archive::operator&; using Archive::operator&;
Archive & operator & (float & f) override
{ *stream >> f; return *this; }
Archive & operator & (double & d) override Archive & operator & (double & d) override
{ *stream >> d; return *this; } { *stream >> d; return *this; }
Archive & operator & (int & i) override Archive & operator & (int & i) override
@ -924,6 +933,7 @@ namespace ngcore
{ h = (char*)&hash_value; } { h = (char*)&hash_value; }
using Archive::operator&; using Archive::operator&;
Archive & operator & (float & f) override { return ApplyHash(f); }
Archive & operator & (double & d) override { return ApplyHash(d); } Archive & operator & (double & d) override { return ApplyHash(d); }
Archive & operator & (int & i) override { return ApplyHash(i); } Archive & operator & (int & i) override { return ApplyHash(i); }
Archive & operator & (short & i) override { return ApplyHash(i); } Archive & operator & (short & i) override { return ApplyHash(i); }

View File

@ -23,6 +23,13 @@ namespace netgen
hopt = 2 * h2; 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)); BlockAllocator GradingBox :: ball(sizeof (GradingBox));
@ -93,6 +100,11 @@ namespace netgen
root->DeleteChilds(); root->DeleteChilds();
} }
void LocalH :: DoArchive(Archive& ar)
{
ar & root & grading & boxes & boundingbox & dimension;
}
void LocalH :: SetH (Point<3> p, double h) void LocalH :: SetH (Point<3> p, double h)
{ {
if (dimension == 2) if (dimension == 2)

View File

@ -44,10 +44,14 @@ namespace netgen
/// ///
GradingBox (const double * ax1, const double * ax2); GradingBox (const double * ax1, const double * ax2);
/// default constructor for Archive
GradingBox() = default;
/// ///
void DeleteChilds(); void DeleteChilds();
/// ///
void DoArchive(Archive& ar);
Point<3> PMid() const { return Point<3> (xmid[0], xmid[1], xmid[2]); } Point<3> PMid() const { return Point<3> (xmid[0], xmid[1], xmid[2]); }
double H2() const { return h2; } double H2() const { return h2; }
@ -78,7 +82,7 @@ namespace netgen
/// ///
double grading; double grading;
/// ///
NgArray<GradingBox*> boxes; Array<GradingBox*> boxes;
/// ///
Box<3> boundingbox; Box<3> boundingbox;
/// octree or quadtree /// octree or quadtree
@ -89,11 +93,15 @@ namespace netgen
/// ///
LocalH (const Box<3> & box, double grading, int adimension = 3) LocalH (const Box<3> & box, double grading, int adimension = 3)
: LocalH (box.PMin(), box.PMax(), grading, adimension) { ; } : LocalH (box.PMin(), box.PMax(), grading, adimension) { ; }
/// /// Default ctor for archive
LocalH() = default;
~LocalH(); ~LocalH();
/// ///
void Delete(); void Delete();
/// ///
void DoArchive(Archive& ar);
///
void SetGrading (double agrading) { grading = agrading; } void SetGrading (double agrading) { grading = agrading; }
/// ///
void SetH (Point<3> x, double h); void SetH (Point<3> x, double h);