delaunay meshing

This commit is contained in:
Joachim Schoeberl 2010-09-23 14:07:12 +00:00
parent b20dda8e4a
commit 834937c671
17 changed files with 967 additions and 682 deletions

View File

@ -228,6 +228,11 @@ namespace netgen
mparam.checkoverlap = 0; mparam.checkoverlap = 0;
/*
if (!mparam.quad)
meshing.Delaunay (*mesh, domnr, mparam);
else
*/
meshing.GenerateMesh (*mesh, h, domnr); meshing.GenerateMesh (*mesh, h, domnr);
for (SurfaceElementIndex sei = oldnf; sei < mesh->GetNSE(); sei++) for (SurfaceElementIndex sei = oldnf; sei < mesh->GetNSE(); sei++)

View File

@ -197,6 +197,14 @@ protected:
Point<D> pmin, pmax; Point<D> pmin, pmax;
public: public:
Box () { ; } 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) Box ( const Point<D> & p1, const Point<D> & p2)
{ {
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)

View File

@ -43,6 +43,7 @@ namespace netgen
{ {
Point3d p; Point3d p;
in >> p.X() >> p.Y() >> p.Z(); in >> p.X() >> p.Y() >> p.Z();
p.Z() *= 10;
mesh.AddPoint (p); mesh.AddPoint (p);
} }

View File

@ -262,6 +262,7 @@ namespace netgen
if (det == 0) if (det == 0)
{ {
(*myerr) << "CalcInverse: Matrix singular" << endl; (*myerr) << "CalcInverse: Matrix singular" << endl;
(*testout) << "CalcInverse: Matrix singular" << endl;
return; return;
} }
@ -488,6 +489,7 @@ namespace netgen
if (max < 1e-20) if (max < 1e-20)
{ {
cerr << "Inverse matrix: matrix singular" << endl; cerr << "Inverse matrix: matrix singular" << endl;
*testout << "Inverse matrix: matrix singular" << endl;
return; return;
} }

View File

@ -16,9 +16,10 @@ clusters.hpp hprefinement.hpp improve3.hpp meshtype.hpp \
METASOURCES = AUTO METASOURCES = AUTO
noinst_LTLIBRARIES = libmesh.la noinst_LTLIBRARIES = libmesh.la
libmesh_la_SOURCES = adfront2.cpp adfront3.cpp bisect.cpp boundarylayer.cpp \ libmesh_la_SOURCES = adfront2.cpp adfront3.cpp bisect.cpp boundarylayer.cpp \
clusters.cpp curvedelems.cpp delaunay.cpp geomsearch.cpp global.cpp \ clusters.cpp curvedelems.cpp delaunay.cpp delaunay2d.cpp \
hprefinement.cpp improve2.cpp improve2gen.cpp improve3.cpp localh.cpp \ geomsearch.cpp global.cpp hprefinement.cpp improve2.cpp \
meshclass.cpp meshfunc.cpp meshfunc2d.cpp meshing2.cpp meshing3.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 \ meshtool.cpp meshtype.cpp msghandler.cpp netrule2.cpp \
netrule3.cpp parser2.cpp parser3.cpp prism2rls.cpp \ netrule3.cpp parser2.cpp parser3.cpp prism2rls.cpp \
pyramid2rls.cpp pyramidrls.cpp quadrls.cpp refine.cpp \ pyramid2rls.cpp pyramidrls.cpp quadrls.cpp refine.cpp \

View File

@ -8,7 +8,7 @@
namespace netgen namespace netgen
{ {
AdFront2::FrontPoint2 :: FrontPoint2 (const Point<3> & ap, PointIndex agi, FrontPoint2 :: FrontPoint2 (const Point<3> & ap, PointIndex agi,
MultiPointGeomInfo * amgi, bool aonsurface) MultiPointGeomInfo * amgi, bool aonsurface)
{ {
p = ap; p = ap;
@ -464,4 +464,45 @@ namespace netgen
ost << flush; 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);
}
} }

View File

@ -13,8 +13,6 @@
Advancing front class for surfaces Advancing front class for surfaces
*/ */
class AdFront2
{
/// ///
class FrontPoint2 class FrontPoint2
@ -163,6 +161,8 @@ class AdFront2
}; };
class AdFront2
{
/// ///
Array<FrontPoint2> points; /// front points Array<FrontPoint2> points; /// front points
@ -202,6 +202,11 @@ public:
} }
/// ///
int GetNFL () const { return nfl; } 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, int SelectBaseLine (Point<3> & p1, Point<3> & p2,
const PointGeomInfo *& geominfo1, const PointGeomInfo *& geominfo1,
@ -250,6 +255,18 @@ public:
{ {
return points[pi].GlobalIndex(); 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 (); void SetStartFront ();
/// ///

View File

@ -772,7 +772,7 @@ void AdFront3 :: SetStartFront (int /* baseelnp */)
bool AdFront3 :: Inside (const Point<3> & p) const bool AdFront3 :: Inside (const Point<3> & p) const
{ {
int i, cnt; int cnt;
Vec3d n, v1, v2; Vec3d n, v1, v2;
DenseMatrix a(3), ainv(3); DenseMatrix a(3), ainv(3);
Vector b(3), u(3); Vector b(3), u(3);
@ -783,7 +783,7 @@ bool AdFront3 :: Inside (const Point<3> & p) const
n.Z() = -0.43989; n.Z() = -0.43989;
cnt = 0; cnt = 0;
for (i = 1; i <= faces.Size(); i++) for (int i = 1; i <= faces.Size(); i++)
if (faces.Get(i).Valid()) if (faces.Get(i).Valid())
{ {
const Point<3> & p1 = points[faces.Get(i).Face().PNum(1)].P(); 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, int AdFront3 :: SameSide (const Point<3> & lp1, const Point<3> & lp2,
const Array<int> * testfaces) const const Array<int> * testfaces) const
{ {
int i, ii, cnt;
const Point<3> *line[2]; const Point<3> *line[2];
line[0] = &lp1; line[0] = &lp1;
line[1] = &lp2; line[1] = &lp2;
cnt = 0;
Point3d pmin(lp1); Point3d pmin(lp1);
Point3d pmax(lp1); Point3d pmax(lp1);
pmin.SetToMin (lp2); pmin.SetToMin (lp2);
pmax.SetToMax (lp2); pmax.SetToMax (lp2);
static Array<int> aprif; ArrayMem<int, 100> aprif;
aprif.SetSize(0); aprif.SetSize(0);
if (!testfaces) if (!testfaces)
facetree->GetIntersecting (pmin, pmax, aprif); facetree->GetIntersecting (pmin, pmax, aprif);
else else
{ for (int i = 1; i <= testfaces->Size(); i++)
for (i = 1; i <= testfaces->Size(); i++)
aprif.Append (testfaces->Get(i)); aprif.Append (testfaces->Get(i));
}
// (*testout) << "test ss, p1,p2 = " << lp1 << lp2 << ", inters = " << aprif.Size() << endl; int cnt = 0;
// for (i = 1; i <= faces.Size(); i++) for (int ii = 1; ii <= aprif.Size(); ii++)
for (ii = 1; ii <= aprif.Size(); ii++)
{ {
i = aprif.Get(ii); int i = aprif.Get(ii);
if (faces.Get(i).Valid()) 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])) if (IntersectTriangleLine (&tri[0], &line[0]))
cnt++; cnt++;
} }
} }

View 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;
}
}

View File

@ -5,22 +5,11 @@
namespace netgen namespace netgen
{ {
GradingBox :: GradingBox (const double * ax1, const double * ax2) GradingBox :: GradingBox (const double * ax1, const double * ax2)
{
h2 = 0.5 * (ax2[0] - ax1[0]);
for (int i = 0; i <= 2; i++)
{ {
/* h2 = 0.5 * (ax2[0] - ax1[0]);
x1[i] = ax1[i]; for (int i = 0; i < 3; i++)
x2[i] = ax2[i];
*/
xmid[i] = 0.5 * (ax1[i] + ax2[i]); xmid[i] = 0.5 * (ax1[i] + ax2[i]);
}
/*
(*testout) << "new box: " << xmid[0] << "-" << xmid[1] << "-" << xmid[2]
<< " h = " << (x2[0] - x1[0]) << endl;
*/
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
childs[i] = NULL; childs[i] = NULL;
@ -31,86 +20,114 @@ GradingBox :: GradingBox (const double * ax1, const double * ax2)
flags.oldcell = 0; flags.oldcell = 0;
flags.pinner = 0; flags.pinner = 0;
// hopt = x2[0] - x1[0];
hopt = 2 * h2; hopt = 2 * h2;
} }
BlockAllocator GradingBox :: ball(sizeof (GradingBox));
BlockAllocator GradingBox :: ball(sizeof (GradingBox)); void * GradingBox :: operator new(size_t)
{
void * GradingBox :: operator new(size_t)
{
return ball.Alloc(); return ball.Alloc();
} }
void GradingBox :: operator delete (void * p) void GradingBox :: operator delete (void * p)
{ {
ball.Free (p); ball.Free (p);
} }
void GradingBox :: DeleteChilds()
{
void GradingBox :: DeleteChilds() for (int i = 0; i < 8; i++)
{
int i;
for (i = 0; i < 8; i++)
if (childs[i]) if (childs[i])
{ {
childs[i]->DeleteChilds(); childs[i]->DeleteChilds();
delete childs[i]; delete childs[i];
childs[i] = NULL; childs[i] = NULL;
} }
} }
LocalH :: LocalH (const Point3d & pmin, const Point3d & pmax, double agrading) LocalH :: LocalH (const Point3d & pmin, const Point3d & pmax, double agrading)
{ {
double x1[3], x2[3]; double x1[3], x2[3];
double hmax; double hmax;
int i;
boundingbox = Box3d (pmin, pmax); boundingbox = Box3d (pmin, pmax);
grading = agrading; grading = agrading;
// a small enlargement, non-regular points // a small enlargement, non-regular points
double val = 0.0879; double val = 0.0879;
for (i = 1; i <= 3; i++) for (int i = 1; i <= 3; i++)
{ {
x1[i-1] = (1 + val * i) * pmin.X(i) - val * i * pmax.X(i); x1[i-1] = (1 + val * i) * pmin.X(i) - val * i * pmax.X(i);
x2[i-1] = 1.1 * pmax.X(i) - 0.1 * pmin.X(i); x2[i-1] = 1.1 * pmax.X(i) - 0.1 * pmin.X(i);
} }
hmax = x2[0] - x1[0]; hmax = x2[0] - x1[0];
for (i = 1; i <= 2; i++) for (int i = 1; i <= 2; i++)
if (x2[i] - x1[i] > hmax) if (x2[i] - x1[i] > hmax)
hmax = x2[i] - x1[i]; hmax = x2[i] - x1[i];
for (i = 0; i <= 2; i++) for (int i = 0; i <= 2; i++)
x2[i] = x1[i] + hmax; x2[i] = x1[i] + hmax;
root = new GradingBox (x1, x2); root = new GradingBox (x1, x2);
boxes.Append (root); boxes.Append (root);
} }
LocalH :: ~LocalH ()
{ LocalH :: LocalH (const Box<3> & box, double agrading)
{
Point3d pmin = box.PMin();
Point3d pmax = box.PMax();
double x1[3], x2[3];
double hmax;
boundingbox = Box3d (pmin, pmax);
grading = agrading;
// a small enlargement, non-regular points
double val = 0.0879;
for (int i = 1; i <= 3; i++)
{
x1[i-1] = (1 + val * i) * pmin.X(i) - val * i * pmax.X(i);
x2[i-1] = 1.1 * pmax.X(i) - 0.1 * pmin.X(i);
}
hmax = x2[0] - x1[0];
for (int i = 1; i <= 2; i++)
if (x2[i] - x1[i] > hmax)
hmax = x2[i] - x1[i];
for (int i = 0; i <= 2; i++)
x2[i] = x1[i] + hmax;
root = new GradingBox (x1, x2);
boxes.Append (root);
}
LocalH :: ~LocalH ()
{
root->DeleteChilds(); root->DeleteChilds();
delete root; delete root;
} }
void LocalH :: Delete () void LocalH :: Delete ()
{ {
root->DeleteChilds(); root->DeleteChilds();
} }
void LocalH :: SetH (const Point3d & p, double h) void LocalH :: SetH (const Point3d & p, double h)
{ {
/* /*
(*testout) << "Set h at " << p << " to " << h << endl; (*testout) << "Set h at " << p << " to " << h << endl;
if (h < 1e-8) if (h < 1e-8)
@ -209,8 +226,7 @@ void LocalH :: SetH (const Point3d & p, double h)
double hnp = h + grading * hbox; double hnp = h + grading * hbox;
Point3d np; Point3d np;
int i; for (int i = 1; i <= 3; i++)
for (i = 1; i <= 3; i++)
{ {
np = p; np = p;
np.X(i) = p.X(i) + hbox; np.X(i) = p.X(i) + hbox;
@ -219,52 +235,32 @@ void LocalH :: SetH (const Point3d & p, double h)
np.X(i) = p.X(i) - hbox; np.X(i) = p.X(i) - hbox;
SetH (np, hnp); SetH (np, hnp);
} }
/*
Point3d np;
int i1, i2, i3;
for (i1 = -1; i1 <= 1; i1++)
for (i2 = -1; i2 <= 1; i2++)
for (i3 = -1; i3 <= 1; i3++)
{
np.X() = p.X() + hbox * i1;
np.Y() = p.Y() + hbox * i2;
np.Z() = p.Z() + hbox * i3;
SetH (np, hnp);
} }
*/
}
double LocalH :: GetH (const Point3d & x) const double LocalH :: GetH (const Point3d & x) const
{ {
const GradingBox * box = root; const GradingBox * box = root;
const GradingBox * nbox;
int childnr;
while (1) while (1)
{ {
childnr = 0; int childnr = 0;
if (x.X() > box->xmid[0]) childnr += 1; if (x.X() > box->xmid[0]) childnr += 1;
if (x.Y() > box->xmid[1]) childnr += 2; if (x.Y() > box->xmid[1]) childnr += 2;
if (x.Z() > box->xmid[2]) childnr += 4; if (x.Z() > box->xmid[2]) childnr += 4;
nbox = box->childs[childnr];
if (nbox) if (box->childs[childnr])
box = nbox; box = box->childs[childnr];
else else
{
// (*testout) << "diam = " << (box->x2[0] - box->x1[0])
// << " h = " << box->hopt << endl;
return box->hopt; return box->hopt;
} }
} }
}
/// minimal h in box (pmin, pmax) /// minimal h in box (pmin, pmax)
double LocalH :: GetMinH (const Point3d & pmin, const Point3d & pmax) const double LocalH :: GetMinH (const Point3d & pmin, const Point3d & pmax) const
{ {
Point3d pmin2, pmax2; Point3d pmin2, pmax2;
for (int j = 1; j <= 3; j++) for (int j = 1; j <= 3; j++)
if (pmin.X(j) < pmax.X(j)) if (pmin.X(j) < pmax.X(j))
@ -273,75 +269,53 @@ double LocalH :: GetMinH (const Point3d & pmin, const Point3d & pmax) const
{ pmin2.X(j) = pmax.X(j); pmax2.X(j) = pmin.X(j); } { pmin2.X(j) = pmax.X(j); pmax2.X(j) = pmin.X(j); }
return GetMinHRec (pmin2, pmax2, root); return GetMinHRec (pmin2, pmax2, root);
} }
double LocalH :: GetMinHRec (const Point3d & pmin, const Point3d & pmax, double LocalH :: GetMinHRec (const Point3d & pmin, const Point3d & pmax,
const GradingBox * box) const const GradingBox * box) const
{ {
double h2 = box->h2; double h2 = box->h2;
if (pmax.X() < box->xmid[0]-h2 || pmin.X() > box->xmid[0]+h2 || if (pmax.X() < box->xmid[0]-h2 || pmin.X() > box->xmid[0]+h2 ||
pmax.Y() < box->xmid[1]-h2 || pmin.Y() > box->xmid[1]+h2 || pmax.Y() < box->xmid[1]-h2 || pmin.Y() > box->xmid[1]+h2 ||
pmax.Z() < box->xmid[2]-h2 || pmin.Z() > box->xmid[2]+h2) pmax.Z() < box->xmid[2]-h2 || pmin.Z() > box->xmid[2]+h2)
return 1e8; return 1e8;
/*
if (pmax.X() < box->x1[0] || pmin.X() > box->x2[0] ||
pmax.Y() < box->x1[1] || pmin.Y() > box->x2[1] ||
pmax.Z() < box->x1[2] || pmin.Z() > box->x2[2])
return 1e8;
*/
double hmin = 2 * box->h2; // box->x2[0] - box->x1[0]; double hmin = 2 * box->h2; // box->x2[0] - box->x1[0];
int i;
for (i = 0; i <= 7; i++) for (int i = 0; i < 8; i++)
{
if (box->childs[i]) if (box->childs[i])
{ hmin = min2 (hmin, GetMinHRec (pmin, pmax, box->childs[i]));
double hi = GetMinHRec (pmin, pmax, box->childs[i]);
if (hi < hmin)
hmin = hi;
}
}
return hmin; return hmin;
} }
void LocalH :: CutBoundaryRec (const Point3d & pmin, const Point3d & pmax, void LocalH :: CutBoundaryRec (const Point3d & pmin, const Point3d & pmax,
GradingBox * box) GradingBox * box)
{ {
double h2 = box->h2; double h2 = box->h2;
if (pmax.X() < box->xmid[0]-h2 || pmin.X() > box->xmid[0]+h2 || if (pmax.X() < box->xmid[0]-h2 || pmin.X() > box->xmid[0]+h2 ||
pmax.Y() < box->xmid[1]-h2 || pmin.Y() > box->xmid[1]+h2 || pmax.Y() < box->xmid[1]-h2 || pmin.Y() > box->xmid[1]+h2 ||
pmax.Z() < box->xmid[2]-h2 || pmin.Z() > box->xmid[2]+h2) pmax.Z() < box->xmid[2]-h2 || pmin.Z() > box->xmid[2]+h2)
return; return;
/*
if (pmax.X() < box->x1[0] || pmin.X() > box->x2[0] ||
pmax.Y() < box->x1[1] || pmin.Y() > box->x2[1] ||
pmax.Z() < box->x1[2] || pmin.Z() > box->x2[2])
return;
*/
box->flags.cutboundary = 1; box->flags.cutboundary = 1;
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
if (box->childs[i]) if (box->childs[i])
CutBoundaryRec (pmin, pmax, box->childs[i]); CutBoundaryRec (pmin, pmax, box->childs[i]);
} }
void LocalH :: FindInnerBoxes ( // int (*sameside)(const Point3d & p1, const Point3d & p2), void LocalH :: FindInnerBoxes (AdFront3 * adfront,
AdFront3 * adfront,
int (*testinner)(const Point3d & p1)) int (*testinner)(const Point3d & p1))
{ {
int i;
int nf = adfront->GetNF(); int nf = adfront->GetNF();
for (i = 0; i < boxes.Size(); i++) for (int i = 0; i < boxes.Size(); i++)
boxes[i] -> flags.isinner = 0; boxes[i] -> flags.isinner = 0;
root->flags.isinner = 0; root->flags.isinner = 0;
@ -361,27 +335,25 @@ void LocalH :: FindInnerBoxes ( // int (*sameside)(const Point3d & p1, const Poi
Array<int> faceinds(nf); Array<int> faceinds(nf);
Array<Box3d> faceboxes(nf); Array<Box3d> faceboxes(nf);
for (i = 1; i <= nf; i++) for (int i = 1; i <= nf; i++)
{ {
faceinds.Elem(i) = i; faceinds.Elem(i) = i;
adfront->GetFaceBoundingBox(i, faceboxes.Elem(i)); adfront->GetFaceBoundingBox(i, faceboxes.Elem(i));
} }
for (i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
FindInnerBoxesRec2 (root->childs[i], adfront, faceboxes, faceinds, nf); FindInnerBoxesRec2 (root->childs[i], adfront, faceboxes, faceinds, nf);
} }
void LocalH :: void LocalH ::
FindInnerBoxesRec2 (GradingBox * box, FindInnerBoxesRec2 (GradingBox * box,
class AdFront3 * adfront, class AdFront3 * adfront,
Array<Box3d> & faceboxes, Array<Box3d> & faceboxes,
Array<int> & faceinds, int nfinbox) Array<int> & faceinds, int nfinbox)
{ {
if (!box) return; if (!box) return;
int i, j;
GradingBox * father = box -> father; GradingBox * father = box -> father;
Point3d c(box->xmid[0], box->xmid[1], box->xmid[2]); Point3d c(box->xmid[0], box->xmid[1], box->xmid[2]);
@ -394,16 +366,17 @@ FindInnerBoxesRec2 (GradingBox * box,
Box3d boxcfc(c,fc); Box3d boxcfc(c,fc);
ArrayMem<int, 100> faceused;
ArrayMem<int, 100> faceused2;
ArrayMem<int, 100> facenotused;
static Array<int> faceused; /*
static Array<int> faceused2;
static Array<int> facenotused;
faceused.SetSize(0); faceused.SetSize(0);
facenotused.SetSize(0); facenotused.SetSize(0);
faceused2.SetSize(0); faceused2.SetSize(0);
*/
for (j = 1; j <= nfinbox; j++) for (int j = 1; j <= nfinbox; j++)
{ {
// adfront->GetFaceBoundingBox (faceinds.Get(j), facebox); // adfront->GetFaceBoundingBox (faceinds.Get(j), facebox);
const Box3d & facebox = faceboxes.Get(faceinds.Get(j)); const Box3d & facebox = faceboxes.Get(faceinds.Get(j));
@ -417,9 +390,9 @@ FindInnerBoxesRec2 (GradingBox * box,
faceused2.Append (faceinds.Get(j)); faceused2.Append (faceinds.Get(j));
} }
for (j = 1; j <= faceused.Size(); j++) for (int j = 1; j <= faceused.Size(); j++)
faceinds.Elem(j) = faceused.Get(j); faceinds.Elem(j) = faceused.Get(j);
for (j = 1; j <= facenotused.Size(); j++) for (int j = 1; j <= facenotused.Size(); j++)
faceinds.Elem(j+faceused.Size()) = facenotused.Get(j); faceinds.Elem(j+faceused.Size()) = facenotused.Get(j);
@ -448,10 +421,30 @@ FindInnerBoxesRec2 (GradingBox * box,
box->flags.isinner = box->flags.pinner; box->flags.isinner = box->flags.pinner;
} }
// cout << "faceused: " << faceused.Size() << ", " << faceused2.Size() << ", " << facenotused.Size() << endl;
int nf = faceused.Size(); int nf = faceused.Size();
for (i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
FindInnerBoxesRec2 (box->childs[i], adfront, faceboxes, faceinds, nf); FindInnerBoxesRec2 (box->childs[i], adfront, faceboxes, faceinds, nf);
} }
void LocalH :: FindInnerBoxesRec ( int (*inner)(const Point3d & p),
GradingBox * box)
{
if (box->flags.cutboundary)
{
for (int i = 0; i < 8; i++)
if (box->childs[i])
FindInnerBoxesRec (inner, box->childs[i]);
}
else
{
if (inner (box->PMid()))
SetInnerBoxesRec (box);
}
}
@ -464,36 +457,97 @@ FindInnerBoxesRec2 (GradingBox * box,
/*
void LocalH :: FindInnerBoxes ( // int (*sameside)(const Point3d & p1, const Point3d & p2),
AdFront3 * adfront,
int (*testinner)(const Point3d & p1))
{
int i;
for (i = 1; i <= boxes.Size(); i++)
boxes.Elem(i)->flags.isinner = 0; void LocalH :: FindInnerBoxes (AdFront2 * adfront,
int (*testinner)(const Point<2> & p1))
{
int nf = adfront->GetNFL();
for (int i = 0; i < boxes.Size(); i++)
boxes[i] -> flags.isinner = 0;
root->flags.isinner = 0; root->flags.isinner = 0;
Point3d rpmid(root->xmid[0], root->xmid[1], root->xmid[2]); Point<2> rpmid(root->xmid[0], root->xmid[1], root->xmid[2]);
Point3d rx2 = rpmid + Vec3d (root->h2, root->h2, root->h2); Vec<2> rv(root->h2, root->h2);
Point<2> rx2 = rpmid + rv;
Point<2> rx1 = rpmid - rv;
root->flags.pinner = !adfront->SameSide (rpmid, rx2); root->flags.pinner = !adfront->SameSide (rpmid, rx2);
if (testinner) if (testinner)
(*testout) << "inner = " << root->flags.pinner << " =?= " (*testout) << "inner = " << root->flags.pinner << " =?= "
<< testinner(Point3d(root->xmid[0], root->xmid[1], root->xmid[2])) << endl; << testinner(rpmid) << endl;
Array<int> faceinds(nf);
Array<Box<3> > faceboxes(nf);
for (i = 2; i <= boxes.Size(); i++) for (int i = 0; i < nf; i++)
{ {
GradingBox * box = boxes.Elem(i); faceinds[i] = i;
// adfront->GetFaceBoundingBox(i, faceboxes.Elem(i));
const FrontLine & line = adfront->GetLine(i);
faceboxes[i].Set (adfront->GetPoint (line.L().I1()));
faceboxes[i].Add (adfront->GetPoint (line.L().I2()));
}
for (int i = 0; i < 8; i++)
FindInnerBoxesRec2 (root->childs[i], adfront, faceboxes, faceinds, nf);
}
void LocalH ::
FindInnerBoxesRec2 (GradingBox * box,
class AdFront2 * adfront,
Array<Box<3> > & faceboxes,
Array<int> & faceinds, int nfinbox)
{
if (!box) return;
GradingBox * father = box -> father; GradingBox * father = box -> father;
Point3d c(box->xmid[0], box->xmid[1], box->xmid[2]); Point3d c(box->xmid[0], box->xmid[1], box->xmid[2]);
Vec3d v(box->h2, box->h2, box->h2); Vec3d v(box->h2, box->h2, box->h2);
Point3d x1 = c-v; Box3d boxc(c-v, c+v);
Point3d x2 = c+v;
Point3d fc(father->xmid[0], father->xmid[1], father->xmid[2]);
Vec3d fv(father->h2, father->h2, father->h2);
Box3d fboxc(fc-fv, fc+fv);
Box3d boxcfc(c,fc);
ArrayMem<int, 100> faceused;
ArrayMem<int, 100> faceused2;
ArrayMem<int, 100> facenotused;
for (int j = 1; j <= nfinbox; j++)
{
// adfront->GetFaceBoundingBox (faceinds.Get(j), facebox);
const Box3d & facebox = faceboxes.Get(faceinds.Get(j));
if (boxc.Intersect (facebox))
faceused.Append(faceinds.Get(j));
else
facenotused.Append(faceinds.Get(j));
if (boxcfc.Intersect (facebox))
faceused2.Append (faceinds.Get(j));
}
for (int j = 1; j <= faceused.Size(); j++)
faceinds.Elem(j) = faceused.Get(j);
for (int j = 1; j <= facenotused.Size(); j++)
faceinds.Elem(j+faceused.Size()) = facenotused.Get(j);
if (!father->flags.cutboundary) if (!father->flags.cutboundary)
@ -509,7 +563,9 @@ void LocalH :: FindInnerBoxes ( // int (*sameside)(const Point3d & p1, const Poi
box->flags.pinner = 1; box->flags.pinner = 1;
else else
{ {
if (adfront->SameSide (c, cf)) Point<2> c2d (c.X(), c.Y());
Point<2> cf2d (cf.X(), cf.Y());
if (adfront->SameSide (c2d, cf2d, &faceused2))
box->flags.pinner = father->flags.pinner; box->flags.pinner = father->flags.pinner;
else else
box->flags.pinner = 1 - father->flags.pinner; box->flags.pinner = 1 - father->flags.pinner;
@ -520,61 +576,73 @@ void LocalH :: FindInnerBoxes ( // int (*sameside)(const Point3d & p1, const Poi
else else
box->flags.isinner = box->flags.pinner; box->flags.isinner = box->flags.pinner;
} }
// cout << "faceused: " << faceused.Size() << ", " << faceused2.Size() << ", " << facenotused.Size() << endl;
int nf = faceused.Size();
for (int i = 0; i < 8; i++)
FindInnerBoxesRec2 (box->childs[i], adfront, faceboxes, faceinds, nf);
} }
// FindInnerBoxesRec (inner, root);
}
*/
void LocalH :: FindInnerBoxesRec ( int (*inner)(const Point3d & p),
void LocalH :: FindInnerBoxesRec ( int (*inner)(const Point<2> & p),
GradingBox * box) GradingBox * box)
{ {
int i;
if (box->flags.cutboundary) if (box->flags.cutboundary)
{ {
for (i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
if (box->childs[i]) if (box->childs[i])
FindInnerBoxesRec (inner, box->childs[i]); FindInnerBoxesRec (inner, box->childs[i]);
} }
else else
{ {
if (inner (Point3d (box->xmid[0], box->xmid[1], box->xmid[2]))) Point<2> p2d(box->PMid()(0), box->PMid()(1));
if (inner (p2d))
SetInnerBoxesRec (box); SetInnerBoxesRec (box);
} }
} }
void LocalH :: SetInnerBoxesRec (GradingBox * box)
{
void LocalH :: SetInnerBoxesRec (GradingBox * box)
{
box->flags.isinner = 1; box->flags.isinner = 1;
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
if (box->childs[i]) if (box->childs[i])
ClearFlagsRec (box->childs[i]); ClearFlagsRec (box->childs[i]);
} }
void LocalH :: ClearFlagsRec (GradingBox * box) void LocalH :: ClearFlagsRec (GradingBox * box)
{ {
box->flags.cutboundary = 0; box->flags.cutboundary = 0;
box->flags.isinner = 0; box->flags.isinner = 0;
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
if (box->childs[i]) if (box->childs[i])
ClearFlagsRec (box->childs[i]); ClearFlagsRec (box->childs[i]);
} }
void LocalH :: WidenRefinement () void LocalH :: WidenRefinement ()
{
int nb = boxes.Size();
int i;
// (*testout) << "old boxes: " << nb << endl;
for (i = 1; i <= nb; i++)
{ {
GradingBox * box = boxes.Get(i); for (int i = 0; i < boxes.Size(); i++)
// double h = box->x2[0] - box->x1[0]; {
double h = box->hopt; double h = boxes[i]->hopt;
Point3d c(box->xmid[0], box->xmid[1], box->xmid[2]); Point3d c = boxes[i]->PMid();
// (*testout) << " i = " << i
// << " c = " << c << " h = " << h << endl;
for (int i1 = -1; i1 <= 1; i1++) for (int i1 = -1; i1 <= 1; i1++)
for (int i2 = -1; i2 <= 1; i2++) for (int i2 = -1; i2 <= 1; i2++)
@ -583,98 +651,58 @@ void LocalH :: WidenRefinement ()
c.Y() + i2 * h, c.Y() + i2 * h,
c.Z() + i3 * h), 1.001 * h); c.Z() + i3 * h), 1.001 * h);
} }
}
void LocalH :: GetInnerPoints (Array<Point3d> & points)
{
int i, nb = boxes.Size();
for (i = 1; i <= nb; i++)
{
GradingBox * box = boxes.Get(i);
/*
if (box->flags.pinner)
points.Append (box->randomip);
*/
// if (box->flags.pinner)
if (box->flags.isinner)
{
Point3d c(box->xmid[0], box->xmid[1], box->xmid[2]);
points.Append (c);
/*
cout << "add point " << c << "; h = " << box->hopt
<< "; max-min = " << (box->x2[0]-box->x1[0]) << endl;
*/
} }
}
}
void LocalH :: GetInnerPoints (Array<Point<3> > & points)
void LocalH :: GetOuterPoints (Array<Point3d> & points)
{
int i, nb = boxes.Size();
for (i = 1; i <= nb; i++)
{ {
GradingBox * box = boxes.Get(i); for (int i = 0; i < boxes.Size(); i++)
if (!box->flags.isinner && if (boxes[i] -> flags.isinner)
!box->flags.cutboundary) points.Append ( boxes[i] -> PMid() );
}
void LocalH :: GetOuterPoints (Array<Point<3> > & points)
{ {
Point3d c(box->xmid[0], box->xmid[1], box->xmid[2]); for (int i = 0; i < boxes.Size(); i++)
points.Append (c); if (!boxes[i]->flags.isinner && !boxes[i]->flags.cutboundary)
points.Append ( boxes[i] -> PMid());
} }
}
}
void LocalH :: Convexify ()
void LocalH :: Convexify () {
{
ConvexifyRec (root); ConvexifyRec (root);
} }
void LocalH :: ConvexifyRec (GradingBox * box) void LocalH :: ConvexifyRec (GradingBox * box)
{ {
Point3d center(box->xmid[0], box->xmid[1], box->xmid[2]); Point<3> center = box -> PMid();
Point3d hp;
double size = 2 * box->h2; // box->x2[0] - box->x1[0]; double size = 2 * box->h2; // box->x2[0] - box->x1[0];
double dx = 0.6 * size; double dx = 0.6 * size;
double maxh = box->hopt; double maxh = box->hopt;
int i;
for (int i = 0; i < 3; i++)
for (i = 1; i <= 6; i++)
{ {
hp = center; Point<3> hp = center;
switch (i) hp(i) += dx;
{ maxh = max2 (maxh, GetH(hp));
case 1: hp.X() += dx; break; hp(i) = center(i)-dx;
case 2: hp.X() -= dx; break; maxh = max2 (maxh, GetH(hp));
case 3: hp.Y() += dx; break;
case 4: hp.Y() -= dx; break;
case 5: hp.Z() += dx; break;
case 6: hp.Z() -= dx; break;
}
double hh = GetH (hp);
if (hh > maxh) maxh = hh;
} }
if (maxh < 0.95 * box->hopt) if (maxh < 0.95 * box->hopt)
SetH (center, maxh); SetH (center, maxh);
for (i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
if (box->childs[i]) if (box->childs[i])
ConvexifyRec (box->childs[i]); ConvexifyRec (box->childs[i]);
} }
void LocalH :: PrintMemInfo (ostream & ost) const void LocalH :: PrintMemInfo (ostream & ost) const
{ {
ost << "LocalH: " << boxes.Size() << " boxes of " << sizeof(GradingBox) ost << "LocalH: " << boxes.Size() << " boxes of " << sizeof(GradingBox)
<< " bytes = " << boxes.Size()*sizeof(GradingBox) << " bytes" << endl; << " bytes = " << boxes.Size()*sizeof(GradingBox) << " bytes" << endl;
} }
} }

View File

@ -13,12 +13,6 @@
/// box for grading /// box for grading
class GradingBox class GradingBox
{ {
/*
/// xmin
float x1[3];
/// xmax
float x2[3];
*/
/// xmid /// xmid
float xmid[3]; float xmid[3];
/// half edgelength /// half edgelength
@ -30,6 +24,8 @@ class GradingBox
/// ///
double hopt; double hopt;
/// ///
public:
struct struct
{ {
unsigned int cutboundary:1; unsigned int cutboundary:1;
@ -37,14 +33,17 @@ class GradingBox
unsigned int oldcell:1; unsigned int oldcell:1;
unsigned int pinner:1; unsigned int pinner:1;
} flags; } flags;
public:
/// ///
GradingBox (const double * ax1, const double * ax2); GradingBox (const double * ax1, const double * ax2);
/// ///
void DeleteChilds(); 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; static BlockAllocator ball;
void * operator new(size_t); void * operator new(size_t);
@ -53,6 +52,7 @@ public:
/** /**
Control of 3D mesh grading Control of 3D mesh grading
*/ */
@ -70,6 +70,8 @@ public:
/// ///
LocalH (const Point3d & pmin, const Point3d & pmax, double grading); LocalH (const Point3d & pmin, const Point3d & pmax, double grading);
/// ///
LocalH (const Box<3> & box, double grading);
///
~LocalH(); ~LocalH();
/// ///
void Delete(); void Delete();
@ -83,14 +85,19 @@ public:
double GetMinH (const Point3d & pmin, const Point3d & pmax) const; double GetMinH (const Point3d & pmin, const Point3d & pmax) const;
/// mark boxes intersecting with boundary-box /// mark boxes intersecting with boundary-box
void CutBoundary (const Point3d & pmin, const Point3d & pmax) // void CutBoundary (const Point3d & pmin, const Point3d & pmax)
{ CutBoundaryRec (pmin, pmax, root); } // { CutBoundaryRec (pmin, pmax, root); }
void CutBoundary (const Box<3> & box)
{ CutBoundaryRec (box.PMin(), box.PMax(), root); }
/// find inner boxes /// find inner boxes
void FindInnerBoxes ( // int (*sameside)(const Point3d & p1, const Point3d & p2), void FindInnerBoxes (class AdFront3 * adfront,
class AdFront3 * adfront,
int (*testinner)(const Point3d & p1)); int (*testinner)(const Point3d & p1));
void FindInnerBoxes (class AdFront2 * adfront,
int (*testinner)(const Point<2> & p1));
/// clears all flags /// clears all flags
void ClearFlags () void ClearFlags ()
{ ClearFlagsRec(root); } { ClearFlagsRec(root); }
@ -99,10 +106,10 @@ public:
void WidenRefinement (); void WidenRefinement ();
/// get points in inner elements /// get points in inner elements
void GetInnerPoints (Array<Point3d> & points); void GetInnerPoints (Array<Point<3> > & points);
/// get points in outer closure /// get points in outer closure
void GetOuterPoints (Array<Point3d> & points); void GetOuterPoints (Array<Point<3> > & points);
/// ///
void Convexify (); void Convexify ();
@ -131,6 +138,18 @@ private:
Array<int> & finds, int nfinbox); 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); void SetInnerBoxesRec (GradingBox * box);
@ -139,7 +158,26 @@ private:
/// ///
void ConvexifyRec (GradingBox * box); 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 #endif

View File

@ -4365,7 +4365,7 @@ namespace netgen
if(el.GetType() == TET || el.GetType() == TET10) if (el.GetType() == TET)
{ {
retval = (lam(0) > -eps && retval = (lam(0) > -eps &&
lam(1) > -eps && lam(1) > -eps &&

View File

@ -54,6 +54,10 @@ public:
/// ///
MESHING2_RESULT GenerateMesh (Mesh & mesh, double gh, int facenr); 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, void AddPoint (const Point3d & p, PointIndex globind, MultiPointGeomInfo * mgi = NULL,
bool pointonsurface = true); bool pointonsurface = true);

View File

@ -1082,7 +1082,7 @@ void Meshing3 :: BlockFill (Mesh & mesh, double gh)
} }
/*
static const AdFront3 * locadfront; static const AdFront3 * locadfront;
static int TestInner (const Point3d & p) static int TestInner (const Point3d & p)
{ {
@ -1092,62 +1092,45 @@ static int TestSameSide (const Point3d & p1, const Point3d & p2)
{ {
return locadfront->SameSide (p1, p2); return locadfront->SameSide (p1, p2);
} }
*/
void Meshing3 :: BlockFillLocalH (Mesh & mesh, void Meshing3 :: BlockFillLocalH (Mesh & mesh,
const MeshingParameters & mp) const MeshingParameters & mp)
{ {
int i, j;
double filldist = mp.filldist; double filldist = mp.filldist;
(*testout) << "blockfill local h" << endl; (*testout) << "blockfill local h" << endl;
(*testout) << "rel filldist = " << filldist << endl; (*testout) << "rel filldist = " << filldist << endl;
PrintMessage (3, "blockfill local h"); PrintMessage (3, "blockfill local h");
/*
(*mycout) << "boxes: " << mesh.LocalHFunction().GetNBoxes() << endl Array<Point<3> > npoints;
<< "filldist = " << filldist << endl;
*/
Array<Point3d> npoints;
adfront -> CreateTrees(); adfront -> CreateTrees();
Point3d mpmin, mpmax; Box<3> bbox ( Box<3>::EMPTY_BOX );
// mesh.GetBox (mpmin, mpmax);
bool firstp = 1;
double maxh = 0; double maxh = 0;
for (i = 1; i <= adfront->GetNF(); i++)
for (int i = 1; i <= adfront->GetNF(); i++)
{ {
const MiniElement2d & el = adfront->GetFace(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 & p1 = adfront->GetPoint (el.PNumMod(j));
const Point3d & p2 = adfront->GetPoint (el.PNumMod(j+1)); const Point3d & p2 = adfront->GetPoint (el.PNumMod(j+1));
double hi = Dist (p1, p2); double hi = Dist (p1, p2);
if (hi > maxh) if (hi > maxh) maxh = hi;
{
maxh = hi;
//(*testout) << "reducing maxh to " << maxh << " because of " << p1 << " and " << p2 << endl;
}
if (firstp) bbox.Add (p1);
{
mpmin = p1;
mpmax = p1;
firstp = 0;
}
else
{
mpmin.SetToMin (p1);
mpmax.SetToMax (p1);
}
} }
} }
Point3d mpmin = bbox.PMin();
Point3d mpmax = bbox.PMax();
Point3d mpc = Center (mpmin, mpmax); Point3d mpc = Center (mpmin, mpmax);
double d = max3(mpmax.X()-mpmin.X(), double d = max3(mpmax.X()-mpmin.X(),
mpmax.Y()-mpmin.Y(), mpmax.Y()-mpmin.Y(),
@ -1158,53 +1141,41 @@ void Meshing3 :: BlockFillLocalH (Mesh & mesh,
LocalH loch2 (mpmin, mpmax, 1); LocalH loch2 (mpmin, mpmax, 1);
if (mp.maxh < maxh) maxh = mp.maxh;
if (mp.maxh < maxh) bool changed;
{
maxh = mp.maxh;
//(*testout) << "reducing maxh to " << maxh << " because of mp.maxh" << endl;
}
int changed;
do do
{ {
mesh.LocalHFunction().ClearFlags(); mesh.LocalHFunction().ClearFlags();
for (i = 1; i <= adfront->GetNF(); i++) for (int i = 1; i <= adfront->GetNF(); i++)
{ {
const MiniElement2d & el = adfront->GetFace(i); const MiniElement2d & el = adfront->GetFace(i);
Point3d pmin = adfront->GetPoint (el.PNum(1));
Point3d pmax = pmin;
for (j = 2; j <= 3; j++) Box<3> bbox (adfront->GetPoint (el[0]));
{ bbox.Add (adfront->GetPoint (el[1]));
const Point3d & p = adfront->GetPoint (el.PNum(j)); bbox.Add (adfront->GetPoint (el[2]));
pmin.SetToMin (p);
pmax.SetToMax (p);
double filld = filldist * bbox.Diam();
bbox.Increase (filld);
mesh.LocalHFunction().CutBoundary (bbox); // .PMin(), bbox.PMax());
} }
// locadfront = adfront;
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);
}
locadfront = adfront;
mesh.LocalHFunction().FindInnerBoxes (adfront, NULL); mesh.LocalHFunction().FindInnerBoxes (adfront, NULL);
npoints.SetSize(0); npoints.SetSize(0);
mesh.LocalHFunction().GetInnerPoints (npoints); mesh.LocalHFunction().GetInnerPoints (npoints);
changed = 0; changed = false;
for (i = 1; i <= npoints.Size(); i++) for (int i = 1; i <= npoints.Size(); i++)
{ {
if (mesh.LocalHFunction().GetH(npoints.Get(i)) > 1.5 * maxh) if (mesh.LocalHFunction().GetH(npoints.Get(i)) > 1.5 * maxh)
{ {
mesh.LocalHFunction().SetH (npoints.Get(i), maxh); mesh.LocalHFunction().SetH (npoints.Get(i), maxh);
changed = 1; changed = true;
} }
} }
} }
@ -1212,7 +1183,7 @@ void Meshing3 :: BlockFillLocalH (Mesh & mesh,
if (debugparam.slowchecks) if (debugparam.slowchecks)
(*testout) << "Blockfill with points: " << endl; (*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))) if (meshbox.IsIn (npoints.Get(i)))
{ {
@ -1238,13 +1209,13 @@ void Meshing3 :: BlockFillLocalH (Mesh & mesh,
loch2.ClearFlags(); loch2.ClearFlags();
for (i = 1; i <= adfront->GetNF(); i++) for (int i = 1; i <= adfront->GetNF(); i++)
{ {
const MiniElement2d & el = adfront->GetFace(i); const MiniElement2d & el = adfront->GetFace(i);
Point3d pmin = adfront->GetPoint (el.PNum(1)); Point3d pmin = adfront->GetPoint (el.PNum(1));
Point3d pmax = pmin; Point3d pmax = pmin;
for (j = 2; j <= 3; j++) for (int j = 2; j <= 3; j++)
{ {
const Point3d & p = adfront->GetPoint (el.PNum(j)); const Point3d & p = adfront->GetPoint (el.PNum(j));
pmin.SetToMin (p); pmin.SetToMin (p);
@ -1254,13 +1225,13 @@ void Meshing3 :: BlockFillLocalH (Mesh & mesh,
loch2.SetH (Center (pmin, pmax), Dist (pmin, pmax)); 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); const MiniElement2d & el = adfront->GetFace(i);
Point3d pmin = adfront->GetPoint (el.PNum(1)); Point3d pmin = adfront->GetPoint (el.PNum(1));
Point3d pmax = pmin; Point3d pmax = pmin;
for (j = 2; j <= 3; j++) for (int j = 2; j <= 3; j++)
{ {
const Point3d & p = adfront->GetPoint (el.PNum(j)); const Point3d & p = adfront->GetPoint (el.PNum(j));
pmin.SetToMin (p); pmin.SetToMin (p);
@ -1270,16 +1241,17 @@ void Meshing3 :: BlockFillLocalH (Mesh & mesh,
double filld = filldist * Dist (pmin, pmax); double filld = filldist * Dist (pmin, pmax);
pmin = pmin - Vec3d (filld, filld, filld); pmin = pmin - Vec3d (filld, filld, filld);
pmax = pmax + 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); loch2.FindInnerBoxes (adfront, NULL);
npoints.SetSize(0); npoints.SetSize(0);
loch2.GetOuterPoints (npoints); loch2.GetOuterPoints (npoints);
for (i = 1; i <= npoints.Size(); i++) for (int i = 1; i <= npoints.Size(); i++)
{ {
if (meshbox.IsIn (npoints.Get(i))) if (meshbox.IsIn (npoints.Get(i)))
{ {

View File

@ -496,6 +496,8 @@ proc saveoptions { } {
puts $datei "stloptions.recalchopt ${stloptions.recalchopt}" puts $datei "stloptions.recalchopt ${stloptions.recalchopt}"
puts $datei "visoptions.subdivisions ${visoptions.subdivisions}" puts $datei "visoptions.subdivisions ${visoptions.subdivisions}"
puts $datei "visoptions.autoredraw ${visoptions.autoredraw}"
puts $datei "visoptions.autoredrawtime ${visoptions.autoredrawtime}"
# trafo options # trafo options

View File

@ -66,7 +66,7 @@ int main (int argc, char ** argv)
Ng_Meshing_Parameters mp; Ng_Meshing_Parameters mp;
mp.maxh = 1.0e+6; mp.maxh = 1.0e+6;
mp.fineness = 0.4; mp.fineness = 0.4;
mp.secondorder = 0; mp.second_order = 0;
cout << "Initialise the STL Geometry structure...." << endl; cout << "Initialise the STL Geometry structure...." << endl;
ng_res = Ng_STL_InitSTLGeometry(stl_geom); ng_res = Ng_STL_InitSTLGeometry(stl_geom);

View File

@ -63,7 +63,7 @@ int main (int argc, char ** argv)
Ng_Meshing_Parameters mp; Ng_Meshing_Parameters mp;
mp.maxh = 1e6; mp.maxh = 1e6;
mp.fineness = 1; mp.fineness = 1;
mp.secondorder = 0; mp.second_order = 0;
cout << "start meshing" << endl; cout << "start meshing" << endl;
Ng_GenerateVolumeMesh (mesh, &mp); Ng_GenerateVolumeMesh (mesh, &mp);