netgen/libsrc/meshing/localh.hpp

221 lines
5.2 KiB
C++
Raw Normal View History

2009-01-13 04:40:13 +05:00
#ifndef LOCALH
#define LOCALH
/**************************************************************************/
/* File: localh.hh */
/* Author: Joachim Schoeberl */
/* Date: 29. Jan. 97 */
/**************************************************************************/
2011-03-03 01:50:39 +05:00
namespace netgen
2009-01-13 04:40:13 +05:00
{
2010-09-23 20:07:12 +06:00
2011-03-03 01:50:39 +05:00
/// box for grading
class GradingBox
{
/// xmid
float xmid[3];
/// half edgelength
float h2;
///
GradingBox * childs[8] = {nullptr};
2011-03-03 01:50:39 +05:00
///
GradingBox * father = nullptr;
2011-03-03 01:50:39 +05:00
///
double hopt;
///
public:
struct
{
/*
2011-03-03 01:50:39 +05:00
unsigned int cutboundary:1;
unsigned int isinner:1;
unsigned int oldcell:1;
unsigned int pinner:1;
*/
bool cutboundary;
bool isinner;
bool oldcell;
bool pinner;
2011-03-03 01:50:39 +05:00
} flags;
///
GradingBox (const double * ax1, const double * ax2);
2021-03-29 16:55:23 +05:00
/// default constructor for Archive
GradingBox() = default;
2011-03-03 01:50:39 +05:00
///
void DeleteChilds();
///
2021-03-29 16:55:23 +05:00
void DoArchive(Archive& ar);
2011-03-03 01:50:39 +05:00
Point<3> PMid() const { return Point<3> (xmid[0], xmid[1], xmid[2]); }
double H2() const { return h2; }
2014-12-02 18:23:36 +05:00
bool HasChilds() const
{
for (int i = 0; i < 8; i++)
if (childs[i]) return true;
return false;
}
2011-03-03 01:50:39 +05:00
friend class LocalH;
static BlockAllocator ball;
void * operator new(size_t);
void operator delete (void *);
};
/**
Control of 3D mesh grading
*/
class LocalH
{
///
GradingBox * root;
///
double grading;
///
2021-03-29 16:55:23 +05:00
Array<GradingBox*> boxes;
2011-03-03 01:50:39 +05:00
///
2014-12-02 18:23:36 +05:00
Box<3> boundingbox;
/// octree or quadtree
int dimension;
2011-03-03 01:50:39 +05:00
public:
///
2022-02-16 00:39:24 +05:00
DLL_HEADER LocalH (Point<3> pmin, Point<3> pmax, double grading, int adimension = 3);
2011-03-03 01:50:39 +05:00
///
2014-12-02 18:23:36 +05:00
LocalH (const Box<3> & box, double grading, int adimension = 3)
: LocalH (box.PMin(), box.PMax(), grading, adimension) { ; }
2021-03-29 16:55:23 +05:00
/// Default ctor for archive
LocalH() = default;
2022-02-16 00:39:24 +05:00
DLL_HEADER ~LocalH();
2011-03-03 01:50:39 +05:00
///
2022-02-16 00:39:24 +05:00
DLL_HEADER unique_ptr<LocalH> Copy();
DLL_HEADER unique_ptr<LocalH> Copy( const Box<3> & bbox );
///
2022-02-16 00:39:24 +05:00
DLL_HEADER void Delete();
2011-03-03 01:50:39 +05:00
///
2022-02-16 00:39:24 +05:00
DLL_HEADER void DoArchive(Archive& ar);
2021-03-29 16:55:23 +05:00
///
2011-03-03 01:50:39 +05:00
void SetGrading (double agrading) { grading = agrading; }
///
2022-02-16 00:39:24 +05:00
DLL_HEADER void SetH (Point<3> x, double h);
2011-03-03 01:50:39 +05:00
///
2022-02-16 00:39:24 +05:00
DLL_HEADER double GetH (Point<3> x) const;
2011-03-03 01:50:39 +05:00
/// minimal h in box (pmin, pmax)
2022-02-16 00:39:24 +05:00
DLL_HEADER double GetMinH (Point<3> pmin, Point<3> pmax) const;
2011-03-03 01:50:39 +05:00
/// mark boxes intersecting with boundary-box
// void CutBoundary (const Point3d & pmin, const Point3d & pmax)
// { CutBoundaryRec (pmin, pmax, root); }
2014-12-02 18:23:36 +05:00
2011-03-03 01:50:39 +05:00
void CutBoundary (const Box<3> & box)
{ CutBoundaryRec (box.PMin(), box.PMax(), root); }
2010-09-23 20:07:12 +06:00
2011-03-03 01:50:39 +05:00
/// find inner boxes
void FindInnerBoxes (class AdFront3 * adfront,
int (*testinner)(const Point3d & p1));
2009-01-13 04:40:13 +05:00
2011-03-03 01:50:39 +05:00
void FindInnerBoxes (class AdFront2 * adfront,
int (*testinner)(const Point<2> & p1));
2010-09-23 20:07:12 +06:00
2011-03-03 01:50:39 +05:00
/// clears all flags
void ClearFlags ()
2009-01-13 04:40:13 +05:00
{ ClearFlagsRec(root); }
2020-10-25 20:31:47 +05:00
void ClearRootFlags ();
2011-03-03 01:50:39 +05:00
/// widen refinement zone
void WidenRefinement ();
2009-01-13 04:40:13 +05:00
2011-03-03 01:50:39 +05:00
/// get points in inner elements
2020-10-25 20:31:47 +05:00
void GetInnerPoints (NgArray<Point<3> > & points) const;
void GetInnerPointsRec (const GradingBox * box, NgArray<Point<3> > & points) const;
2009-01-13 04:40:13 +05:00
2011-03-03 01:50:39 +05:00
/// get points in outer closure
2019-07-09 13:39:16 +05:00
void GetOuterPoints (NgArray<Point<3> > & points);
2009-01-13 04:40:13 +05:00
2011-03-03 01:50:39 +05:00
///
void Convexify ();
///
int GetNBoxes () { return boxes.Size(); }
2014-12-02 18:23:36 +05:00
const Box<3> & GetBoundingBox () const
2011-03-03 01:50:39 +05:00
{ return boundingbox; }
///
void PrintMemInfo (ostream & ost) const;
private:
///
double GetMinHRec (const Point3d & pmin, const Point3d & pmax,
const GradingBox * box) const;
///
void CutBoundaryRec (const Point3d & pmin, const Point3d & pmax,
GradingBox * box);
2009-01-13 04:40:13 +05:00
2011-03-03 01:50:39 +05:00
///
void FindInnerBoxesRec ( int (*inner)(const Point3d & p),
GradingBox * box);
2009-01-13 04:40:13 +05:00
2011-03-03 01:50:39 +05:00
///
void FindInnerBoxesRec2 (GradingBox * box,
class AdFront3 * adfront,
2019-07-09 13:39:16 +05:00
NgArray<Box3d> & faceboxes,
NgArray<int> & finds, int nfinbox);
2009-01-13 04:40:13 +05:00
2010-09-23 20:07:12 +06:00
2011-03-03 01:50:39 +05:00
void FindInnerBoxesRec ( int (*inner)(const Point<2> & p),
GradingBox * box);
2010-09-23 20:07:12 +06:00
2011-03-03 01:50:39 +05:00
///
void FindInnerBoxesRec2 (GradingBox * box,
class AdFront2 * adfront,
FlatArray<Box<2>> faceboxes,
FlatArray<int> finds); // , int nfinbox);
2010-09-23 20:07:12 +06:00
2011-03-03 01:50:39 +05:00
///
void SetInnerBoxesRec (GradingBox * box);
2009-01-13 04:40:13 +05:00
2011-03-03 01:50:39 +05:00
///
void ClearFlagsRec (GradingBox * box);
2009-01-13 04:40:13 +05:00
2011-03-03 01:50:39 +05:00
///
void ConvexifyRec (GradingBox * box);
2010-09-23 20:07:12 +06:00
unique_ptr<LocalH> CopyRec( const Box<3> & bbox, GradingBox * current );
2011-03-03 01:50:39 +05:00
friend ostream & operator<< (ostream & ost, const LocalH & loch);
};
2009-01-13 04:40:13 +05:00
2010-09-23 20:07:12 +06:00
2011-03-03 01:50:39 +05:00
inline ostream & operator<< (ostream & ost, const GradingBox & box)
{
ost << "gradbox, pmid = " << box.PMid() << ", h2 = " << box.H2()
<< " cutbound = " << box.flags.cutboundary << " isinner = " << box.flags.isinner
<< endl;
return ost;
}
inline ostream & operator<< (ostream & ost, const LocalH & loch)
{
for (int i = 0; i < loch.boxes.Size(); i++)
ost << "box[" << i << "] = " << *(loch.boxes[i]);
return ost;
}
2010-09-23 20:07:12 +06:00
}
2009-01-13 04:40:13 +05:00
#endif