mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 04:50:34 +05:00
delaunay meshing
This commit is contained in:
parent
b20dda8e4a
commit
834937c671
@ -227,8 +227,13 @@ namespace netgen
|
||||
|
||||
|
||||
mparam.checkoverlap = 0;
|
||||
|
||||
meshing.GenerateMesh (*mesh, h, domnr);
|
||||
|
||||
/*
|
||||
if (!mparam.quad)
|
||||
meshing.Delaunay (*mesh, domnr, mparam);
|
||||
else
|
||||
*/
|
||||
meshing.GenerateMesh (*mesh, h, domnr);
|
||||
|
||||
for (SurfaceElementIndex sei = oldnf; sei < mesh->GetNSE(); sei++)
|
||||
(*mesh)[sei].SetIndex (domnr);
|
||||
|
@ -197,6 +197,14 @@ protected:
|
||||
Point<D> pmin, pmax;
|
||||
public:
|
||||
Box () { ; }
|
||||
|
||||
Box ( const Point<D> & p1)
|
||||
{
|
||||
for (int i = 0; i < D; i++)
|
||||
pmin(i) = pmax(i) = p1(i);
|
||||
}
|
||||
|
||||
|
||||
Box ( const Point<D> & p1, const Point<D> & p2)
|
||||
{
|
||||
for (int i = 0; i < D; i++)
|
||||
|
@ -43,6 +43,7 @@ namespace netgen
|
||||
{
|
||||
Point3d p;
|
||||
in >> p.X() >> p.Y() >> p.Z();
|
||||
p.Z() *= 10;
|
||||
mesh.AddPoint (p);
|
||||
}
|
||||
|
||||
|
@ -262,6 +262,7 @@ namespace netgen
|
||||
if (det == 0)
|
||||
{
|
||||
(*myerr) << "CalcInverse: Matrix singular" << endl;
|
||||
(*testout) << "CalcInverse: Matrix singular" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -488,6 +489,7 @@ namespace netgen
|
||||
if (max < 1e-20)
|
||||
{
|
||||
cerr << "Inverse matrix: matrix singular" << endl;
|
||||
*testout << "Inverse matrix: matrix singular" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -15,14 +15,15 @@ clusters.hpp hprefinement.hpp improve3.hpp meshtype.hpp \
|
||||
|
||||
METASOURCES = AUTO
|
||||
noinst_LTLIBRARIES = libmesh.la
|
||||
libmesh_la_SOURCES = adfront2.cpp adfront3.cpp bisect.cpp boundarylayer.cpp \
|
||||
clusters.cpp curvedelems.cpp delaunay.cpp geomsearch.cpp global.cpp \
|
||||
hprefinement.cpp improve2.cpp improve2gen.cpp improve3.cpp localh.cpp \
|
||||
meshclass.cpp meshfunc.cpp meshfunc2d.cpp meshing2.cpp meshing3.cpp \
|
||||
meshtool.cpp meshtype.cpp msghandler.cpp netrule2.cpp \
|
||||
netrule3.cpp parser2.cpp parser3.cpp prism2rls.cpp \
|
||||
pyramid2rls.cpp pyramidrls.cpp quadrls.cpp refine.cpp \
|
||||
ruler2.cpp ruler3.cpp secondorder.cpp smoothing2.5.cpp \
|
||||
smoothing2.cpp smoothing3.cpp specials.cpp tetrarls.cpp \
|
||||
topology.cpp triarls.cpp validate.cpp zrefine.cpp bcfunctions.cpp \
|
||||
libmesh_la_SOURCES = adfront2.cpp adfront3.cpp bisect.cpp boundarylayer.cpp \
|
||||
clusters.cpp curvedelems.cpp delaunay.cpp delaunay2d.cpp \
|
||||
geomsearch.cpp global.cpp hprefinement.cpp improve2.cpp \
|
||||
improve2gen.cpp improve3.cpp localh.cpp meshclass.cpp \
|
||||
meshfunc.cpp meshfunc2d.cpp meshing2.cpp meshing3.cpp \
|
||||
meshtool.cpp meshtype.cpp msghandler.cpp netrule2.cpp \
|
||||
netrule3.cpp parser2.cpp parser3.cpp prism2rls.cpp \
|
||||
pyramid2rls.cpp pyramidrls.cpp quadrls.cpp refine.cpp \
|
||||
ruler2.cpp ruler3.cpp secondorder.cpp smoothing2.5.cpp \
|
||||
smoothing2.cpp smoothing3.cpp specials.cpp tetrarls.cpp \
|
||||
topology.cpp triarls.cpp validate.cpp zrefine.cpp bcfunctions.cpp \
|
||||
parallelmesh.cpp paralleltop.cpp paralleltop.hpp basegeom.cpp
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
AdFront2::FrontPoint2 :: FrontPoint2 (const Point<3> & ap, PointIndex agi,
|
||||
MultiPointGeomInfo * amgi, bool aonsurface)
|
||||
FrontPoint2 :: FrontPoint2 (const Point<3> & ap, PointIndex agi,
|
||||
MultiPointGeomInfo * amgi, bool aonsurface)
|
||||
{
|
||||
p = ap;
|
||||
globalindex = agi;
|
||||
@ -464,4 +464,45 @@ namespace netgen
|
||||
|
||||
ost << flush;
|
||||
}
|
||||
|
||||
|
||||
bool AdFront2 :: Inside (const Point<2> & p) const
|
||||
{
|
||||
int cnt;
|
||||
Vec<2> n;
|
||||
Vec<3> v1;
|
||||
DenseMatrix a(2), ainv(2);
|
||||
Vector b(2), u(2);
|
||||
|
||||
// random numbers:
|
||||
n(0) = 0.123871;
|
||||
n(1) = 0.15432;
|
||||
|
||||
cnt = 0;
|
||||
for (int i = 0; i < lines.Size(); i++)
|
||||
if (lines[i].Valid())
|
||||
{
|
||||
const Point<3> & p1 = points[lines[i].L().I1()].P();
|
||||
const Point<3> & p2 = points[lines[i].L().I2()].P();
|
||||
|
||||
v1 = p2 - p1;
|
||||
|
||||
a(0, 0) = v1(0);
|
||||
a(1, 0) = v1(1);
|
||||
|
||||
a(0, 1) = -n(0);
|
||||
a(1, 1) = -n(1);
|
||||
|
||||
b(0) = p(0) - p1(0);
|
||||
b(1) = p(1) - p1(1);
|
||||
|
||||
CalcInverse (a, ainv);
|
||||
ainv.Mult (b, u);
|
||||
|
||||
if (u(0) >= 0 && u(0) <= 1 && u(1) > 0)
|
||||
cnt++;
|
||||
}
|
||||
|
||||
return ((cnt % 2) != 0);
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,6 @@
|
||||
Advancing front class for surfaces
|
||||
|
||||
*/
|
||||
class AdFront2
|
||||
{
|
||||
|
||||
///
|
||||
class FrontPoint2
|
||||
@ -163,6 +161,8 @@ class AdFront2
|
||||
};
|
||||
|
||||
|
||||
class AdFront2
|
||||
{
|
||||
|
||||
///
|
||||
Array<FrontPoint2> points; /// front points
|
||||
@ -202,6 +202,11 @@ public:
|
||||
}
|
||||
///
|
||||
int GetNFL () const { return nfl; }
|
||||
|
||||
const FrontLine & GetLine (int nr) { return lines[nr]; }
|
||||
const FrontPoint2 & GetPoint (int nr) { return points[nr]; }
|
||||
|
||||
|
||||
///
|
||||
int SelectBaseLine (Point<3> & p1, Point<3> & p2,
|
||||
const PointGeomInfo *& geominfo1,
|
||||
@ -250,6 +255,18 @@ public:
|
||||
{
|
||||
return points[pi].GlobalIndex();
|
||||
}
|
||||
|
||||
|
||||
/// is Point p inside Surface (flat geometry only)
|
||||
bool Inside (const Point<2> & p) const;
|
||||
|
||||
bool SameSide (const Point<2> & lp1, const Point<2> & lp2,
|
||||
const Array<int> * testfaces = NULL) const
|
||||
{
|
||||
return Inside (lp1) == Inside (lp2);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
void SetStartFront ();
|
||||
///
|
||||
|
@ -772,7 +772,7 @@ void AdFront3 :: SetStartFront (int /* baseelnp */)
|
||||
|
||||
bool AdFront3 :: Inside (const Point<3> & p) const
|
||||
{
|
||||
int i, cnt;
|
||||
int cnt;
|
||||
Vec3d n, v1, v2;
|
||||
DenseMatrix a(3), ainv(3);
|
||||
Vector b(3), u(3);
|
||||
@ -783,7 +783,7 @@ bool AdFront3 :: Inside (const Point<3> & p) const
|
||||
n.Z() = -0.43989;
|
||||
|
||||
cnt = 0;
|
||||
for (i = 1; i <= faces.Size(); i++)
|
||||
for (int i = 1; i <= faces.Size(); i++)
|
||||
if (faces.Get(i).Valid())
|
||||
{
|
||||
const Point<3> & p1 = points[faces.Get(i).Face().PNum(1)].P();
|
||||
@ -827,36 +827,29 @@ bool AdFront3 :: Inside (const Point<3> & p) const
|
||||
int AdFront3 :: SameSide (const Point<3> & lp1, const Point<3> & lp2,
|
||||
const Array<int> * testfaces) const
|
||||
{
|
||||
int i, ii, cnt;
|
||||
|
||||
const Point<3> *line[2];
|
||||
line[0] = &lp1;
|
||||
line[1] = &lp2;
|
||||
|
||||
|
||||
cnt = 0;
|
||||
|
||||
Point3d pmin(lp1);
|
||||
Point3d pmax(lp1);
|
||||
pmin.SetToMin (lp2);
|
||||
pmax.SetToMax (lp2);
|
||||
|
||||
static Array<int> aprif;
|
||||
|
||||
ArrayMem<int, 100> aprif;
|
||||
aprif.SetSize(0);
|
||||
|
||||
if (!testfaces)
|
||||
facetree->GetIntersecting (pmin, pmax, aprif);
|
||||
else
|
||||
{
|
||||
for (i = 1; i <= testfaces->Size(); i++)
|
||||
aprif.Append (testfaces->Get(i));
|
||||
}
|
||||
for (int i = 1; i <= testfaces->Size(); i++)
|
||||
aprif.Append (testfaces->Get(i));
|
||||
|
||||
// (*testout) << "test ss, p1,p2 = " << lp1 << lp2 << ", inters = " << aprif.Size() << endl;
|
||||
// for (i = 1; i <= faces.Size(); i++)
|
||||
for (ii = 1; ii <= aprif.Size(); ii++)
|
||||
int cnt = 0;
|
||||
for (int ii = 1; ii <= aprif.Size(); ii++)
|
||||
{
|
||||
i = aprif.Get(ii);
|
||||
int i = aprif.Get(ii);
|
||||
|
||||
if (faces.Get(i).Valid())
|
||||
{
|
||||
@ -867,7 +860,6 @@ int AdFront3 :: SameSide (const Point<3> & lp1, const Point<3> & lp2,
|
||||
|
||||
if (IntersectTriangleLine (&tri[0], &line[0]))
|
||||
cnt++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
174
libsrc/meshing/delaunay2d.cpp
Normal file
174
libsrc/meshing/delaunay2d.cpp
Normal file
@ -0,0 +1,174 @@
|
||||
#include <mystdlib.h>
|
||||
#include "meshing.hpp"
|
||||
|
||||
// not yet working ....
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
|
||||
void Meshing2 :: BlockFillLocalH (Mesh & mesh, const MeshingParameters & mp)
|
||||
{
|
||||
double filldist = mp.filldist;
|
||||
|
||||
cout << "blockfill local h" << endl;
|
||||
cout << "rel filldist = " << filldist << endl;
|
||||
PrintMessage (3, "blockfill local h");
|
||||
|
||||
Array<Point<3> > npoints;
|
||||
|
||||
// adfront -> CreateTrees();
|
||||
|
||||
Box<3> bbox ( Box<3>::EMPTY_BOX );
|
||||
double maxh = 0;
|
||||
|
||||
for (int i = 0; i < adfront->GetNFL(); i++)
|
||||
{
|
||||
const FrontLine & line = adfront->GetLine (i);
|
||||
|
||||
const Point<3> & p1 = adfront->GetPoint(line.L().I1());
|
||||
const Point<3> & p2 = adfront->GetPoint(line.L().I2());
|
||||
|
||||
double hi = Dist (p1, p2);
|
||||
if (hi > maxh) maxh = hi;
|
||||
|
||||
bbox.Add (p1);
|
||||
bbox.Add (p2);
|
||||
}
|
||||
|
||||
|
||||
cout << "bbox = " << bbox << endl;
|
||||
|
||||
|
||||
Point<3> mpc = bbox.Center();
|
||||
bbox.Increase (bbox.Diam()/2);
|
||||
Box<3> meshbox = bbox;
|
||||
|
||||
LocalH loch2 (bbox, 1);
|
||||
|
||||
if (mp.maxh < maxh) maxh = mp.maxh;
|
||||
|
||||
bool changed;
|
||||
do
|
||||
{
|
||||
mesh.LocalHFunction().ClearFlags();
|
||||
|
||||
for (int i = 0; i < adfront->GetNFL(); i++)
|
||||
{
|
||||
const FrontLine & line = adfront->GetLine(i);
|
||||
|
||||
Box<3> bbox (adfront->GetPoint (line.L().I1()));
|
||||
bbox.Add (adfront->GetPoint (line.L().I2()));
|
||||
|
||||
|
||||
double filld = filldist * bbox.Diam();
|
||||
bbox.Increase (filld);
|
||||
|
||||
mesh.LocalHFunction().CutBoundary (bbox);
|
||||
}
|
||||
|
||||
|
||||
mesh.LocalHFunction().FindInnerBoxes (adfront, NULL);
|
||||
|
||||
npoints.SetSize(0);
|
||||
mesh.LocalHFunction().GetInnerPoints (npoints);
|
||||
|
||||
changed = false;
|
||||
for (int i = 0; i < npoints.Size(); i++)
|
||||
{
|
||||
if (mesh.LocalHFunction().GetH(npoints[i]) > 1.5 * maxh)
|
||||
{
|
||||
mesh.LocalHFunction().SetH (npoints[i], maxh);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (changed);
|
||||
|
||||
if (debugparam.slowchecks)
|
||||
(*testout) << "Blockfill with points: " << endl;
|
||||
*testout << "loch = " << mesh.LocalHFunction() << endl;
|
||||
|
||||
*testout << "npoints = " << endl << npoints << endl;
|
||||
|
||||
for (int i = 1; i <= npoints.Size(); i++)
|
||||
{
|
||||
if (meshbox.IsIn (npoints.Get(i)))
|
||||
{
|
||||
int gpnum = mesh.AddPoint (npoints.Get(i));
|
||||
adfront->AddPoint (npoints.Get(i), gpnum);
|
||||
|
||||
if (debugparam.slowchecks)
|
||||
{
|
||||
(*testout) << npoints.Get(i) << endl;
|
||||
|
||||
Point<2> p2d (npoints.Get(i)(0), npoints.Get(i)(1));
|
||||
if (!adfront->Inside(p2d))
|
||||
{
|
||||
cout << "add outside point" << endl;
|
||||
(*testout) << "outside" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// find outer points
|
||||
|
||||
loch2.ClearFlags();
|
||||
|
||||
for (int i = 0; i < adfront->GetNFL(); i++)
|
||||
{
|
||||
const FrontLine & line = adfront->GetLine(i);
|
||||
|
||||
Box<3> bbox (adfront->GetPoint (line.L().I1()));
|
||||
bbox.Add (adfront->GetPoint (line.L().I2()));
|
||||
|
||||
loch2.SetH (bbox.Center(), bbox.Diam());
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < adfront->GetNFL(); i++)
|
||||
{
|
||||
const FrontLine & line = adfront->GetLine(i);
|
||||
|
||||
Box<3> bbox (adfront->GetPoint (line.L().I1()));
|
||||
bbox.Add (adfront->GetPoint (line.L().I2()));
|
||||
|
||||
bbox.Increase (filldist * bbox.Diam());
|
||||
loch2.CutBoundary (bbox);
|
||||
}
|
||||
|
||||
loch2.FindInnerBoxes (adfront, NULL);
|
||||
|
||||
npoints.SetSize(0);
|
||||
loch2.GetOuterPoints (npoints);
|
||||
|
||||
for (int i = 1; i <= npoints.Size(); i++)
|
||||
{
|
||||
if (meshbox.IsIn (npoints.Get(i)))
|
||||
{
|
||||
int gpnum = mesh.AddPoint (npoints.Get(i));
|
||||
adfront->AddPoint (npoints.Get(i), gpnum);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Meshing2 :: Delaunay (Mesh & mesh, int domainnr, const MeshingParameters & mp)
|
||||
{
|
||||
cout << "2D Delaunay meshing (in progress)" << endl;
|
||||
|
||||
int oldnp = mesh.GetNP();
|
||||
|
||||
cout << "np, old = " << mesh.GetNP() << endl;
|
||||
|
||||
BlockFillLocalH (mesh, mp);
|
||||
|
||||
|
||||
cout << "np, now = " << mesh.GetNP() << endl;
|
||||
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -13,12 +13,6 @@
|
||||
/// box for grading
|
||||
class GradingBox
|
||||
{
|
||||
/*
|
||||
/// xmin
|
||||
float x1[3];
|
||||
/// xmax
|
||||
float x2[3];
|
||||
*/
|
||||
/// xmid
|
||||
float xmid[3];
|
||||
/// half edgelength
|
||||
@ -30,6 +24,8 @@ class GradingBox
|
||||
///
|
||||
double hopt;
|
||||
///
|
||||
public:
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned int cutboundary:1;
|
||||
@ -37,14 +33,17 @@ class GradingBox
|
||||
unsigned int oldcell:1;
|
||||
unsigned int pinner:1;
|
||||
} flags;
|
||||
public:
|
||||
|
||||
///
|
||||
GradingBox (const double * ax1, const double * ax2);
|
||||
///
|
||||
void DeleteChilds();
|
||||
///
|
||||
friend class LocalH;
|
||||
|
||||
Point<3> PMid() const { return Point<3> (xmid[0], xmid[1], xmid[2]); }
|
||||
double H2() const { return h2; }
|
||||
|
||||
friend class LocalH;
|
||||
|
||||
static BlockAllocator ball;
|
||||
void * operator new(size_t);
|
||||
@ -53,6 +52,7 @@ public:
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Control of 3D mesh grading
|
||||
*/
|
||||
@ -70,6 +70,8 @@ public:
|
||||
///
|
||||
LocalH (const Point3d & pmin, const Point3d & pmax, double grading);
|
||||
///
|
||||
LocalH (const Box<3> & box, double grading);
|
||||
///
|
||||
~LocalH();
|
||||
///
|
||||
void Delete();
|
||||
@ -83,14 +85,19 @@ public:
|
||||
double GetMinH (const Point3d & pmin, const Point3d & pmax) const;
|
||||
|
||||
/// mark boxes intersecting with boundary-box
|
||||
void CutBoundary (const Point3d & pmin, const Point3d & pmax)
|
||||
{ CutBoundaryRec (pmin, pmax, root); }
|
||||
|
||||
// void CutBoundary (const Point3d & pmin, const Point3d & pmax)
|
||||
// { CutBoundaryRec (pmin, pmax, root); }
|
||||
void CutBoundary (const Box<3> & box)
|
||||
{ CutBoundaryRec (box.PMin(), box.PMax(), root); }
|
||||
|
||||
/// find inner boxes
|
||||
void FindInnerBoxes ( // int (*sameside)(const Point3d & p1, const Point3d & p2),
|
||||
class AdFront3 * adfront,
|
||||
void FindInnerBoxes (class AdFront3 * adfront,
|
||||
int (*testinner)(const Point3d & p1));
|
||||
|
||||
void FindInnerBoxes (class AdFront2 * adfront,
|
||||
int (*testinner)(const Point<2> & p1));
|
||||
|
||||
|
||||
/// clears all flags
|
||||
void ClearFlags ()
|
||||
{ ClearFlagsRec(root); }
|
||||
@ -99,10 +106,10 @@ public:
|
||||
void WidenRefinement ();
|
||||
|
||||
/// get points in inner elements
|
||||
void GetInnerPoints (Array<Point3d> & points);
|
||||
void GetInnerPoints (Array<Point<3> > & points);
|
||||
|
||||
/// get points in outer closure
|
||||
void GetOuterPoints (Array<Point3d> & points);
|
||||
void GetOuterPoints (Array<Point<3> > & points);
|
||||
|
||||
///
|
||||
void Convexify ();
|
||||
@ -131,6 +138,18 @@ private:
|
||||
Array<int> & finds, int nfinbox);
|
||||
|
||||
|
||||
|
||||
void FindInnerBoxesRec ( int (*inner)(const Point<2> & p),
|
||||
GradingBox * box);
|
||||
|
||||
///
|
||||
void FindInnerBoxesRec2 (GradingBox * box,
|
||||
class AdFront2 * adfront,
|
||||
Array<Box<3> > & faceboxes,
|
||||
Array<int> & finds, int nfinbox);
|
||||
|
||||
|
||||
|
||||
///
|
||||
void SetInnerBoxesRec (GradingBox * box);
|
||||
|
||||
@ -139,7 +158,26 @@ private:
|
||||
|
||||
///
|
||||
void ConvexifyRec (GradingBox * box);
|
||||
|
||||
friend ostream & operator<< (ostream & ost, const LocalH & loch);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -4365,7 +4365,7 @@ namespace netgen
|
||||
|
||||
|
||||
|
||||
if(el.GetType() == TET || el.GetType() == TET10)
|
||||
if (el.GetType() == TET)
|
||||
{
|
||||
retval = (lam(0) > -eps &&
|
||||
lam(1) > -eps &&
|
||||
|
@ -54,6 +54,10 @@ public:
|
||||
///
|
||||
MESHING2_RESULT GenerateMesh (Mesh & mesh, double gh, int facenr);
|
||||
|
||||
void Delaunay (Mesh & mesh, int domainnr, const MeshingParameters & mp);
|
||||
void BlockFillLocalH (Mesh & mesh, const MeshingParameters & mp);
|
||||
|
||||
|
||||
///
|
||||
void AddPoint (const Point3d & p, PointIndex globind, MultiPointGeomInfo * mgi = NULL,
|
||||
bool pointonsurface = true);
|
||||
|
@ -1082,7 +1082,7 @@ void Meshing3 :: BlockFill (Mesh & mesh, double gh)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
static const AdFront3 * locadfront;
|
||||
static int TestInner (const Point3d & p)
|
||||
{
|
||||
@ -1092,62 +1092,45 @@ static int TestSameSide (const Point3d & p1, const Point3d & p2)
|
||||
{
|
||||
return locadfront->SameSide (p1, p2);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
void Meshing3 :: BlockFillLocalH (Mesh & mesh,
|
||||
const MeshingParameters & mp)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
double filldist = mp.filldist;
|
||||
|
||||
(*testout) << "blockfill local h" << endl;
|
||||
(*testout) << "rel filldist = " << filldist << endl;
|
||||
PrintMessage (3, "blockfill local h");
|
||||
|
||||
/*
|
||||
(*mycout) << "boxes: " << mesh.LocalHFunction().GetNBoxes() << endl
|
||||
<< "filldist = " << filldist << endl;
|
||||
*/
|
||||
Array<Point3d> npoints;
|
||||
|
||||
Array<Point<3> > npoints;
|
||||
|
||||
adfront -> CreateTrees();
|
||||
|
||||
Point3d mpmin, mpmax;
|
||||
// mesh.GetBox (mpmin, mpmax);
|
||||
bool firstp = 1;
|
||||
|
||||
Box<3> bbox ( Box<3>::EMPTY_BOX );
|
||||
double maxh = 0;
|
||||
for (i = 1; i <= adfront->GetNF(); i++)
|
||||
|
||||
for (int i = 1; i <= adfront->GetNF(); i++)
|
||||
{
|
||||
const MiniElement2d & el = adfront->GetFace(i);
|
||||
for (j = 1; j <= 3; j++)
|
||||
for (int j = 1; j <= 3; j++)
|
||||
{
|
||||
const Point3d & p1 = adfront->GetPoint (el.PNumMod(j));
|
||||
const Point3d & p2 = adfront->GetPoint (el.PNumMod(j+1));
|
||||
double hi = Dist (p1, p2);
|
||||
if (hi > maxh)
|
||||
{
|
||||
maxh = hi;
|
||||
//(*testout) << "reducing maxh to " << maxh << " because of " << p1 << " and " << p2 << endl;
|
||||
}
|
||||
|
||||
if (firstp)
|
||||
{
|
||||
mpmin = p1;
|
||||
mpmax = p1;
|
||||
firstp = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mpmin.SetToMin (p1);
|
||||
mpmax.SetToMax (p1);
|
||||
}
|
||||
double hi = Dist (p1, p2);
|
||||
if (hi > maxh) maxh = hi;
|
||||
|
||||
bbox.Add (p1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Point3d mpmin = bbox.PMin();
|
||||
Point3d mpmax = bbox.PMax();
|
||||
Point3d mpc = Center (mpmin, mpmax);
|
||||
double d = max3(mpmax.X()-mpmin.X(),
|
||||
mpmax.Y()-mpmin.Y(),
|
||||
@ -1158,53 +1141,41 @@ void Meshing3 :: BlockFillLocalH (Mesh & mesh,
|
||||
|
||||
LocalH loch2 (mpmin, mpmax, 1);
|
||||
|
||||
if (mp.maxh < maxh) maxh = mp.maxh;
|
||||
|
||||
if (mp.maxh < maxh)
|
||||
{
|
||||
maxh = mp.maxh;
|
||||
//(*testout) << "reducing maxh to " << maxh << " because of mp.maxh" << endl;
|
||||
}
|
||||
|
||||
int changed;
|
||||
bool changed;
|
||||
do
|
||||
{
|
||||
mesh.LocalHFunction().ClearFlags();
|
||||
|
||||
for (i = 1; i <= adfront->GetNF(); i++)
|
||||
for (int i = 1; i <= adfront->GetNF(); i++)
|
||||
{
|
||||
const MiniElement2d & el = adfront->GetFace(i);
|
||||
Point3d pmin = adfront->GetPoint (el.PNum(1));
|
||||
Point3d pmax = pmin;
|
||||
|
||||
for (j = 2; j <= 3; j++)
|
||||
{
|
||||
const Point3d & p = adfront->GetPoint (el.PNum(j));
|
||||
pmin.SetToMin (p);
|
||||
pmax.SetToMax (p);
|
||||
}
|
||||
|
||||
Box<3> bbox (adfront->GetPoint (el[0]));
|
||||
bbox.Add (adfront->GetPoint (el[1]));
|
||||
bbox.Add (adfront->GetPoint (el[2]));
|
||||
|
||||
double filld = filldist * Dist (pmin, pmax);
|
||||
|
||||
pmin = pmin - Vec3d (filld, filld, filld);
|
||||
pmax = pmax + Vec3d (filld, filld, filld);
|
||||
// (*testout) << "cut : " << pmin << " - " << pmax << endl;
|
||||
mesh.LocalHFunction().CutBoundary (pmin, pmax);
|
||||
|
||||
double filld = filldist * bbox.Diam();
|
||||
bbox.Increase (filld);
|
||||
|
||||
mesh.LocalHFunction().CutBoundary (bbox); // .PMin(), bbox.PMax());
|
||||
}
|
||||
|
||||
locadfront = adfront;
|
||||
// locadfront = adfront;
|
||||
mesh.LocalHFunction().FindInnerBoxes (adfront, NULL);
|
||||
|
||||
npoints.SetSize(0);
|
||||
mesh.LocalHFunction().GetInnerPoints (npoints);
|
||||
|
||||
changed = 0;
|
||||
for (i = 1; i <= npoints.Size(); i++)
|
||||
changed = false;
|
||||
for (int i = 1; i <= npoints.Size(); i++)
|
||||
{
|
||||
if (mesh.LocalHFunction().GetH(npoints.Get(i)) > 1.5 * maxh)
|
||||
{
|
||||
mesh.LocalHFunction().SetH (npoints.Get(i), maxh);
|
||||
changed = 1;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1212,7 +1183,7 @@ void Meshing3 :: BlockFillLocalH (Mesh & mesh,
|
||||
|
||||
if (debugparam.slowchecks)
|
||||
(*testout) << "Blockfill with points: " << endl;
|
||||
for (i = 1; i <= npoints.Size(); i++)
|
||||
for (int i = 1; i <= npoints.Size(); i++)
|
||||
{
|
||||
if (meshbox.IsIn (npoints.Get(i)))
|
||||
{
|
||||
@ -1238,13 +1209,13 @@ void Meshing3 :: BlockFillLocalH (Mesh & mesh,
|
||||
|
||||
loch2.ClearFlags();
|
||||
|
||||
for (i = 1; i <= adfront->GetNF(); i++)
|
||||
for (int i = 1; i <= adfront->GetNF(); i++)
|
||||
{
|
||||
const MiniElement2d & el = adfront->GetFace(i);
|
||||
Point3d pmin = adfront->GetPoint (el.PNum(1));
|
||||
Point3d pmax = pmin;
|
||||
|
||||
for (j = 2; j <= 3; j++)
|
||||
for (int j = 2; j <= 3; j++)
|
||||
{
|
||||
const Point3d & p = adfront->GetPoint (el.PNum(j));
|
||||
pmin.SetToMin (p);
|
||||
@ -1254,13 +1225,13 @@ void Meshing3 :: BlockFillLocalH (Mesh & mesh,
|
||||
loch2.SetH (Center (pmin, pmax), Dist (pmin, pmax));
|
||||
}
|
||||
|
||||
for (i = 1; i <= adfront->GetNF(); i++)
|
||||
for (int i = 1; i <= adfront->GetNF(); i++)
|
||||
{
|
||||
const MiniElement2d & el = adfront->GetFace(i);
|
||||
Point3d pmin = adfront->GetPoint (el.PNum(1));
|
||||
Point3d pmax = pmin;
|
||||
|
||||
for (j = 2; j <= 3; j++)
|
||||
for (int j = 2; j <= 3; j++)
|
||||
{
|
||||
const Point3d & p = adfront->GetPoint (el.PNum(j));
|
||||
pmin.SetToMin (p);
|
||||
@ -1270,16 +1241,17 @@ void Meshing3 :: BlockFillLocalH (Mesh & mesh,
|
||||
double filld = filldist * Dist (pmin, pmax);
|
||||
pmin = pmin - Vec3d (filld, filld, filld);
|
||||
pmax = pmax + Vec3d (filld, filld, filld);
|
||||
loch2.CutBoundary (pmin, pmax);
|
||||
// loch2.CutBoundary (pmin, pmax);
|
||||
loch2.CutBoundary (Box<3> (pmin, pmax)); // pmin, pmax);
|
||||
}
|
||||
|
||||
locadfront = adfront;
|
||||
// locadfront = adfront;
|
||||
loch2.FindInnerBoxes (adfront, NULL);
|
||||
|
||||
npoints.SetSize(0);
|
||||
loch2.GetOuterPoints (npoints);
|
||||
|
||||
for (i = 1; i <= npoints.Size(); i++)
|
||||
for (int i = 1; i <= npoints.Size(); i++)
|
||||
{
|
||||
if (meshbox.IsIn (npoints.Get(i)))
|
||||
{
|
||||
|
@ -496,6 +496,8 @@ proc saveoptions { } {
|
||||
puts $datei "stloptions.recalchopt ${stloptions.recalchopt}"
|
||||
|
||||
puts $datei "visoptions.subdivisions ${visoptions.subdivisions}"
|
||||
puts $datei "visoptions.autoredraw ${visoptions.autoredraw}"
|
||||
puts $datei "visoptions.autoredrawtime ${visoptions.autoredrawtime}"
|
||||
|
||||
|
||||
# trafo options
|
||||
|
@ -66,7 +66,7 @@ int main (int argc, char ** argv)
|
||||
Ng_Meshing_Parameters mp;
|
||||
mp.maxh = 1.0e+6;
|
||||
mp.fineness = 0.4;
|
||||
mp.secondorder = 0;
|
||||
mp.second_order = 0;
|
||||
|
||||
cout << "Initialise the STL Geometry structure...." << endl;
|
||||
ng_res = Ng_STL_InitSTLGeometry(stl_geom);
|
||||
|
@ -63,7 +63,7 @@ int main (int argc, char ** argv)
|
||||
Ng_Meshing_Parameters mp;
|
||||
mp.maxh = 1e6;
|
||||
mp.fineness = 1;
|
||||
mp.secondorder = 0;
|
||||
mp.second_order = 0;
|
||||
|
||||
cout << "start meshing" << endl;
|
||||
Ng_GenerateVolumeMesh (mesh, &mp);
|
||||
|
Loading…
Reference in New Issue
Block a user