reuse netrules, implant adfront into meshing class

This commit is contained in:
Joachim Schöberl 2019-07-28 21:31:05 +02:00
parent 321bee9b02
commit 168df170ec
4 changed files with 87 additions and 65 deletions

View File

@ -81,12 +81,12 @@ namespace netgen
Box<3> bbox ( Box<3>::EMPTY_BOX );
double maxh = 0;
for (int i = 0; i < adfront->GetNFL(); i++)
for (int i = 0; i < adfront.GetNFL(); i++)
{
const FrontLine & line = adfront->GetLine (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());
const Point<3> & p1 = adfront.GetPoint(line.L().I1());
const Point<3> & p2 = adfront.GetPoint(line.L().I2());
maxh = max (maxh, Dist (p1, p2));
@ -115,12 +115,12 @@ namespace netgen
{
mesh.LocalHFunction().ClearFlags();
for (int i = 0; i < adfront->GetNFL(); i++)
for (int i = 0; i < adfront.GetNFL(); i++)
{
const FrontLine & line = adfront->GetLine(i);
const FrontLine & line = adfront.GetLine(i);
Box<3> bbox (adfront->GetPoint (line.L().I1()));
bbox.Add (adfront->GetPoint (line.L().I2()));
Box<3> bbox (adfront.GetPoint (line.L().I1()));
bbox.Add (adfront.GetPoint (line.L().I2()));
double filld = filldist * bbox.Diam();
@ -130,7 +130,7 @@ namespace netgen
}
mesh.LocalHFunction().FindInnerBoxes (adfront, NULL);
mesh.LocalHFunction().FindInnerBoxes (&adfront, NULL);
npoints.SetSize(0);
mesh.LocalHFunction().GetInnerPoints (npoints);
@ -162,14 +162,14 @@ namespace netgen
if (meshbox.IsIn (npoints.Get(i)))
{
PointIndex gpnum = mesh.AddPoint (npoints.Get(i));
adfront->AddPoint (npoints.Get(i), gpnum);
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))
if (!adfront.Inside(p2d))
{
cout << "add outside point" << endl;
(*testout) << "outside" << endl;
@ -187,29 +187,29 @@ namespace netgen
loch2.ClearFlags();
for (int i = 0; i < adfront->GetNFL(); i++)
for (int i = 0; i < adfront.GetNFL(); i++)
{
const FrontLine & line = adfront->GetLine(i);
const FrontLine & line = adfront.GetLine(i);
Box<3> bbox (adfront->GetPoint (line.L().I1()));
bbox.Add (adfront->GetPoint (line.L().I2()));
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++)
for (int i = 0; i < adfront.GetNFL(); i++)
{
const FrontLine & line = adfront->GetLine(i);
const FrontLine & line = adfront.GetLine(i);
Box<3> bbox (adfront->GetPoint (line.L().I1()));
bbox.Add (adfront->GetPoint (line.L().I2()));
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);
loch2.FindInnerBoxes (&adfront, NULL);
// outer points : smooth mesh-grading
npoints.SetSize(0);
@ -220,7 +220,7 @@ namespace netgen
if (meshbox.IsIn (npoints.Get(i)))
{
PointIndex gpnum = mesh.AddPoint (npoints.Get(i));
adfront->AddPoint (npoints.Get(i), gpnum);
adfront.AddPoint (npoints.Get(i), gpnum);
}
}
@ -257,11 +257,11 @@ namespace netgen
// face bounding box:
Box<3> bbox (Box<3>::EMPTY_BOX);
for (int i = 0; i < adfront->GetNFL(); i++)
for (int i = 0; i < adfront.GetNFL(); i++)
{
const FrontLine & line = adfront->GetLine(i);
bbox.Add (Point<3> (adfront->GetPoint (line.L()[0])));
bbox.Add (Point<3> (adfront->GetPoint (line.L()[1])));
const FrontLine & line = adfront.GetLine(i);
bbox.Add (Point<3> (adfront.GetPoint (line.L()[0])));
bbox.Add (Point<3> (adfront.GetPoint (line.L()[1])));
}
for (int i = 0; i < mesh.LockedPoints().Size(); i++)
@ -402,7 +402,7 @@ namespace netgen
if (trig[0] < 0) continue;
Point<3> c = Center (mesh[trig[0]], mesh[trig[1]], mesh[trig[2]]);
if (!adfront->Inside (Point<2> (c(0),c(1)))) continue;
if (!adfront.Inside (Point<2> (c(0),c(1)))) continue;
Vec<3> n = Cross (mesh[trig[1]]-mesh[trig[0]],
mesh[trig[2]]-mesh[trig[0]]);

View File

@ -19,16 +19,33 @@ namespace netgen
// static int qualclass;
static Array<unique_ptr<netrule>> global_trig_rules;
static Array<unique_ptr<netrule>> global_quad_rules;
Meshing2 :: Meshing2 (const MeshingParameters & mp, const Box<3> & aboundingbox)
: adfront(aboundingbox), boundingbox(aboundingbox)
{
static Timer t("Mesing2::Meshing2"); RegionTimer r(t);
boundingbox = aboundingbox;
LoadRules (NULL, mp.quad);
auto & globalrules = mp.quad ? global_quad_rules : global_trig_rules;
if (!globalrules.Size())
{
LoadRules (NULL, mp.quad);
for (auto * rule : rules)
globalrules.Append (unique_ptr<netrule>(rule));
}
else
{
for (auto i : globalrules.Range())
rules.Append (globalrules[i].get());
}
// LoadRules ("rules/quad.rls");
// LoadRules ("rules/triangle.rls");
adfront = new AdFront2(boundingbox);
// adfront = new AdFront2(boundingbox);
starttime = GetTime();
maxarea = -1;
@ -37,9 +54,11 @@ namespace netgen
Meshing2 :: ~Meshing2 ()
{
delete adfront;
// delete adfront;
/*
for (int i = 0; i < rules.Size(); i++)
delete rules[i];
*/
}
void Meshing2 :: AddPoint (const Point3d & p, PointIndex globind,
@ -47,7 +66,7 @@ namespace netgen
bool pointonsurface)
{
//(*testout) << "add point " << globind << endl;
adfront ->AddPoint (p, globind, mgi, pointonsurface);
adfront.AddPoint (p, globind, mgi, pointonsurface);
}
void Meshing2 :: AddBoundaryElement (int i1, int i2,
@ -58,7 +77,7 @@ namespace netgen
{
PrintSysError ("addboundaryelement: illegal geominfo");
}
adfront -> AddLine (i1-1, i2-1, gi1, gi2);
adfront. AddLine (i1-1, i2-1, gi1, gi2);
}
@ -341,7 +360,7 @@ namespace netgen
const char * savetask = multithread.task;
multithread.task = "Surface meshing";
adfront ->SetStartFront ();
adfront.SetStartFront ();
int plotnexttrial = 999;
@ -350,7 +369,7 @@ namespace netgen
NgProfiler::StopTimer (ts3);
while (!adfront ->Empty() && !multithread.terminate)
while (!adfront.Empty() && !multithread.terminate)
{
NgProfiler::RegionTimer reg1 (timer1);
@ -393,7 +412,7 @@ namespace netgen
mpgeominfo.SetSize(0);
nfaces = adfront->GetNFL();
nfaces = adfront.GetNFL();
trials ++;
@ -410,7 +429,7 @@ namespace netgen
}
int baselineindex = adfront -> SelectBaseLine (p1, p2, blgeominfo1, blgeominfo2, qualclass);
int baselineindex = adfront. SelectBaseLine (p1, p2, blgeominfo1, blgeominfo2, qualclass);
found = 1;
@ -427,7 +446,7 @@ namespace netgen
double hinner = (3 + qualclass) * max2 (his, hshould);
adfront ->GetLocals (baselineindex, locpoints, mpgeominfo, loclines,
adfront.GetLocals (baselineindex, locpoints, mpgeominfo, loclines,
pindex, lindex, 2*hinner);
@ -441,7 +460,7 @@ namespace netgen
if (qualclass > mp.giveuptol2d)
{
PrintMessage (3, "give up with qualclass ", qualclass);
PrintMessage (3, "number of frontlines = ", adfront->GetNFL());
PrintMessage (3, "number of frontlines = ", adfront.GetNFL());
// throw NgException ("Give up 2d meshing");
break;
}
@ -457,8 +476,8 @@ namespace netgen
morerisc = 0;
PointIndex gpi1 = adfront -> GetGlobalIndex (pindex.Get(loclines[0].I1()));
PointIndex gpi2 = adfront -> GetGlobalIndex (pindex.Get(loclines[0].I2()));
PointIndex gpi1 = adfront. GetGlobalIndex (pindex.Get(loclines[0].I1()));
PointIndex gpi2 = adfront. GetGlobalIndex (pindex.Get(loclines[0].I2()));
debugflag =
@ -580,7 +599,7 @@ namespace netgen
if (IsLineVertexOnChart (locpoints.Get(loclines.Get(i).I1()),
locpoints.Get(loclines.Get(i).I2()),
innerp,
adfront->GetLineGeomInfo (lindex.Get(i), innerp)))
adfront.GetLineGeomInfo (lindex.Get(i), innerp)))
// pgeominfo.Get(loclines.Get(i).I(innerp))))
{
@ -759,7 +778,7 @@ namespace netgen
{
multithread.drawing = 1;
glrender(1);
cout << "qualclass 100, nfl = " << adfront->GetNFL() << endl;
cout << "qualclass 100, nfl = " << adfront.GetNFL() << endl;
}
*/
@ -819,7 +838,7 @@ namespace netgen
// for (i = 1; i <= oldnl; i++)
// adfront -> ResetClass (lindex[i]);
// adfront. ResetClass (lindex[i]);
/*
@ -948,7 +967,7 @@ namespace netgen
for (j = 1; j <= 2; j++)
{
upgeominfo.Elem(loclines.Get(dellines.Get(i)).I(j)) =
adfront -> GetLineGeomInfo (lindex.Get(dellines.Get(i)), j);
adfront. GetLineGeomInfo (lindex.Get(dellines.Get(i)), j);
}
*/
@ -1146,7 +1165,7 @@ namespace netgen
// cout << "overlap !!!" << endl;
#endif
for (int k = 1; k <= 5; k++)
adfront -> IncrementClass (lindex.Get(1));
adfront. IncrementClass (lindex.Get(1));
found = 0;
@ -1180,10 +1199,10 @@ namespace netgen
int nlgpi2 = loclines.Get(i).I2();
if (nlgpi1 <= pindex.Size() && nlgpi2 <= pindex.Size())
{
nlgpi1 = adfront->GetGlobalIndex (pindex.Get(nlgpi1));
nlgpi2 = adfront->GetGlobalIndex (pindex.Get(nlgpi2));
nlgpi1 = adfront.GetGlobalIndex (pindex.Get(nlgpi1));
nlgpi2 = adfront.GetGlobalIndex (pindex.Get(nlgpi2));
int exval = adfront->ExistsLine (nlgpi1, nlgpi2);
int exval = adfront.ExistsLine (nlgpi1, nlgpi2);
if (exval)
{
cout << "ERROR: new line exits, val = " << exval << endl;
@ -1212,8 +1231,8 @@ namespace netgen
int tpi2 = locelements.Get(i).PNumMod (j+1);
if (tpi1 <= pindex.Size() && tpi2 <= pindex.Size())
{
tpi1 = adfront->GetGlobalIndex (pindex.Get(tpi1));
tpi2 = adfront->GetGlobalIndex (pindex.Get(tpi2));
tpi1 = adfront.GetGlobalIndex (pindex.Get(tpi1));
tpi2 = adfront.GetGlobalIndex (pindex.Get(tpi2));
if (doubleedge.Used (INDEX_2(tpi1, tpi2)))
{
@ -1242,7 +1261,7 @@ namespace netgen
for (int i = oldnp+1; i <= locpoints.Size(); i++)
{
PointIndex globind = mesh.AddPoint (locpoints.Get(i));
pindex.Elem(i) = adfront -> AddPoint (locpoints.Get(i), globind);
pindex.Elem(i) = adfront. AddPoint (locpoints.Get(i), globind);
}
for (int i = oldnl+1; i <= loclines.Size(); i++)
@ -1272,7 +1291,7 @@ namespace netgen
cout << "new el: illegal geominfo" << endl;
}
adfront -> AddLine (pindex.Get(loclines.Get(i).I1()),
adfront. AddLine (pindex.Get(loclines.Get(i).I1()),
pindex.Get(loclines.Get(i).I2()),
upgeominfo.Get(loclines.Get(i).I1()),
upgeominfo.Get(loclines.Get(i).I2()));
@ -1297,7 +1316,7 @@ namespace netgen
{
mtri.PNum(j) =
locelements.Elem(i).PNum(j) =
adfront -> GetGlobalIndex (pindex.Get(locelements.Get(i).PNum(j)));
adfront. GetGlobalIndex (pindex.Get(locelements.Get(i).PNum(j)));
}
@ -1376,7 +1395,7 @@ namespace netgen
}
for (int i = 1; i <= dellines.Size(); i++)
adfront -> DeleteLine (lindex.Get(dellines.Get(i)));
adfront. DeleteLine (lindex.Get(dellines.Get(i)));
// rname = rules.Get(rulenr)->Name();
#ifdef MYGRAPH
@ -1399,7 +1418,7 @@ namespace netgen
if ( debugparam.haltsuccess || debugflag )
{
// adfront -> PrintOpenSegments (*testout);
// adfront. PrintOpenSegments (*testout);
cout << "success of rule" << rules.Get(rulenr)->Name() << endl;
multithread.drawing = 1;
multithread.testmode = 1;
@ -1421,7 +1440,7 @@ namespace netgen
(*testout) << "locpoints " << endl;
for (int i = 1; i <= pindex.Size(); i++)
(*testout) << adfront->GetGlobalIndex (pindex.Get(i)) << endl;
(*testout) << adfront.GetGlobalIndex (pindex.Get(i)) << endl;
(*testout) << "old number of lines = " << oldnl << endl;
for (int i = 1; i <= loclines.Size(); i++)
@ -1432,7 +1451,7 @@ namespace netgen
int hi = 0;
if (loclines.Get(i).I(j) >= 1 &&
loclines.Get(i).I(j) <= pindex.Size())
hi = adfront->GetGlobalIndex (pindex.Get(loclines.Get(i).I(j)));
hi = adfront.GetGlobalIndex (pindex.Get(loclines.Get(i).I(j)));
(*testout) << hi << " ";
}
@ -1451,7 +1470,7 @@ namespace netgen
}
else
{
adfront -> IncrementClass (lindex.Get(1));
adfront. IncrementClass (lindex.Get(1));
if ( debugparam.haltnosuccess || debugflag )
{
@ -1484,7 +1503,7 @@ namespace netgen
int hi = 0;
if (loclines.Get(i).I(j) >= 1 &&
loclines.Get(i).I(j) <= pindex.Size())
hi = adfront->GetGlobalIndex (pindex.Get(loclines.Get(i).I(j)));
hi = adfront.GetGlobalIndex (pindex.Get(loclines.Get(i).I(j)));
(*testout) << hi << " ";
}
@ -1523,7 +1542,7 @@ namespace netgen
PrintMessage (3, "Surface meshing done");
adfront->PrintOpenSegments (*testout);
adfront.PrintOpenSegments (*testout);
multithread.task = savetask;
@ -1531,7 +1550,7 @@ namespace netgen
EndMesh ();
if (!adfront->Empty())
if (!adfront.Empty())
return MESHING2_GIVEUP;
return MESHING2_OK;

View File

@ -29,7 +29,7 @@ derive from Meshing2, and replace transformation.
class Meshing2
{
/// the current advancing front
AdFront2 * adfront;
AdFront2 adfront;
/// rules for mesh generation
NgArray<netrule*> rules;
/// statistics

View File

@ -578,7 +578,9 @@ void Meshing2 :: LoadRules (const char * filename, bool quad)
delete ist;
exit (1);
}
Timer t("Parsing rules");
t.Start();
while (!ist->eof())
{
buf[0] = 0;
@ -597,7 +599,8 @@ void Meshing2 :: LoadRules (const char * filename, bool quad)
//(*testout) << "loop" << endl;
}
//(*testout) << "POS3" << endl;
t.Stop();
delete ist;
//delete [] tr1;
}