mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
SplitImprove2 - cleanup, badness calculation, add point only when applying optimization
This commit is contained in:
parent
a0a189869e
commit
abe37bf12a
@ -3920,7 +3920,12 @@ void MeshOptimize3d :: SplitImprove2 (Mesh & mesh, OPTIMIZEGOAL goal)
|
|||||||
{
|
{
|
||||||
if(mp.only3D_domain_nr && mp.only3D_domain_nr != mesh[ei].GetIndex())
|
if(mp.only3D_domain_nr && mp.only3D_domain_nr != mesh[ei].GetIndex())
|
||||||
continue;
|
continue;
|
||||||
el_badness[ei] = CalcBad (mesh.Points(), mesh[ei], 0);
|
// el_badness[ei] = CalcBad (mesh.Points(), mesh[ei], 0);
|
||||||
|
const auto & el = mesh[ei];
|
||||||
|
if(el.GetNP()==4)
|
||||||
|
el_badness[ei] = CalcTetBadness (mesh[el[0]], mesh[el[1]], mesh[el[2]], mesh[el[3]], 0, mp);
|
||||||
|
else
|
||||||
|
el_badness[ei] = 0.0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -3986,15 +3991,16 @@ void MeshOptimize3d :: SplitImprove2 (Mesh & mesh, OPTIMIZEGOAL goal)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayMem<ElementIndex, 50> has_one_point0;
|
|
||||||
ArrayMem<ElementIndex, 50> has_one_point1;
|
|
||||||
ArrayMem<ElementIndex, 50> has_both_points0;
|
ArrayMem<ElementIndex, 50> has_both_points0;
|
||||||
ArrayMem<ElementIndex, 50> has_both_points1;
|
ArrayMem<ElementIndex, 50> has_both_points1;
|
||||||
|
|
||||||
Point3d p[4] = { mesh[el[0]], mesh[el[1]], mesh[el[2]], mesh[el[3]] };
|
Point3d p[4] = { mesh[el[0]], mesh[el[1]], mesh[el[2]], mesh[el[3]] };
|
||||||
auto center = Center(p[0], p[1], p[2], p[3]);
|
auto center = Center(p[0], p[1], p[2], p[3]);
|
||||||
PointIndex pinew = mesh.AddPoint (center);
|
MeshPoint pnew;
|
||||||
MeshPoint pnew = mesh[pinew];
|
|
||||||
|
pnew(0) = center.X();
|
||||||
|
pnew(1) = center.Y();
|
||||||
|
pnew(2) = center.Z();
|
||||||
// cout << "check el " << ei << endl;
|
// cout << "check el " << ei << endl;
|
||||||
|
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
@ -4008,16 +4014,10 @@ void MeshOptimize3d :: SplitImprove2 (Mesh & mesh, OPTIMIZEGOAL goal)
|
|||||||
valid = false;
|
valid = false;
|
||||||
|
|
||||||
if (elem[0] == pi1 || elem[1] == pi1 || elem[2] == pi1 || elem[3] == pi1)
|
if (elem[0] == pi1 || elem[1] == pi1 || elem[2] == pi1 || elem[3] == pi1)
|
||||||
{
|
|
||||||
if(!has_both_points0.Contains(ei0))
|
if(!has_both_points0.Contains(ei0))
|
||||||
has_both_points0.Append (ei0);
|
has_both_points0.Append (ei0);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if(!has_one_point0.Contains(ei0))
|
|
||||||
has_one_point0.Append (ei0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto ei1 : elements_of_point[pi2] )
|
for (auto ei1 : elements_of_point[pi2] )
|
||||||
{
|
{
|
||||||
// cout << ei1 << ',';
|
// cout << ei1 << ',';
|
||||||
@ -4028,18 +4028,9 @@ void MeshOptimize3d :: SplitImprove2 (Mesh & mesh, OPTIMIZEGOAL goal)
|
|||||||
valid = false;
|
valid = false;
|
||||||
|
|
||||||
if (elem[0] == pi3 || elem[1] == pi3 || elem[2] == pi3 || elem[3] == pi3)
|
if (elem[0] == pi3 || elem[1] == pi3 || elem[2] == pi3 || elem[3] == pi3)
|
||||||
{
|
|
||||||
if(mesh[ei1].GetNP()!=4)
|
|
||||||
valid = false;
|
|
||||||
if(!has_both_points1.Contains(ei1))
|
if(!has_both_points1.Contains(ei1))
|
||||||
has_both_points1.Append (ei1);
|
has_both_points1.Append (ei1);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if(!has_one_point1.Contains(ei1))
|
|
||||||
has_one_point1.Append (ei1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!valid) continue;
|
if(!valid) continue;
|
||||||
// cout << endl;
|
// cout << endl;
|
||||||
//
|
//
|
||||||
@ -4063,6 +4054,7 @@ void MeshOptimize3d :: SplitImprove2 (Mesh & mesh, OPTIMIZEGOAL goal)
|
|||||||
}
|
}
|
||||||
if(badness_after<badness_before)
|
if(badness_after<badness_before)
|
||||||
{
|
{
|
||||||
|
PointIndex pinew = mesh.AddPoint (center);
|
||||||
el.flags.illegal_valid = 0;
|
el.flags.illegal_valid = 0;
|
||||||
el.Delete();
|
el.Delete();
|
||||||
// cout << "badness " << badness_after << " better than " << badness_before << endl;
|
// cout << "badness " << badness_after << " better than " << badness_before << endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user