mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-12 14:10:34 +05:00
Sort edges by improvement in SwapImprove2
This commit is contained in:
parent
6fb8f90a73
commit
ab024c2e6c
@ -3280,7 +3280,7 @@ void MeshOptimize3d :: SwapImproveSurface (Mesh & mesh, OPTIMIZEGOAL goal,
|
||||
2 -> 3 conversion
|
||||
*/
|
||||
|
||||
bool MeshOptimize3d :: SwapImprove2 ( Mesh & mesh, OPTIMIZEGOAL goal, ElementIndex eli1, int face,
|
||||
double MeshOptimize3d :: SwapImprove2 ( Mesh & mesh, OPTIMIZEGOAL goal, ElementIndex eli1, int face,
|
||||
Table<ElementIndex, PointIndex> & elementsonnode,
|
||||
TABLE<SurfaceElementIndex, PointIndex::BASE> & belementsonnode, bool check_only )
|
||||
{
|
||||
@ -3288,9 +3288,10 @@ bool MeshOptimize3d :: SwapImprove2 ( Mesh & mesh, OPTIMIZEGOAL goal, ElementInd
|
||||
Element el21(TET), el22(TET), el31(TET), el32(TET), el33(TET);
|
||||
int j = face;
|
||||
double bad1, bad2;
|
||||
double d_badness = 0.0;
|
||||
|
||||
Element & elem = mesh[eli1];
|
||||
if (elem.IsDeleted()) return false;
|
||||
if (elem.IsDeleted()) return 0.0;
|
||||
|
||||
int mattyp = elem.GetIndex();
|
||||
|
||||
@ -3336,7 +3337,7 @@ bool MeshOptimize3d :: SwapImprove2 ( Mesh & mesh, OPTIMIZEGOAL goal, ElementInd
|
||||
}
|
||||
}
|
||||
|
||||
if (bface) return false;
|
||||
if (bface) return 0.0;
|
||||
|
||||
|
||||
FlatArray<ElementIndex> row = elementsonnode[pi1];
|
||||
@ -3406,14 +3407,16 @@ bool MeshOptimize3d :: SwapImprove2 ( Mesh & mesh, OPTIMIZEGOAL goal, ElementInd
|
||||
bad2 += 1e4;
|
||||
|
||||
|
||||
bool do_swap = (bad2 < bad1);
|
||||
d_badness = bad2 - bad1;
|
||||
|
||||
if ( ((bad2 < 1e6) || (bad2 < 10 * bad1)) &&
|
||||
mesh.BoundaryEdge (pi4, pi5))
|
||||
do_swap = 1;
|
||||
d_badness = -1e4;
|
||||
|
||||
if(check_only)
|
||||
return d_badness;
|
||||
|
||||
if (!check_only && do_swap)
|
||||
if (d_badness<0.0)
|
||||
{
|
||||
el31.flags.illegal_valid = 0;
|
||||
el32.flags.illegal_valid = 0;
|
||||
@ -3425,12 +3428,11 @@ bool MeshOptimize3d :: SwapImprove2 ( Mesh & mesh, OPTIMIZEGOAL goal, ElementInd
|
||||
mesh.AddVolumeElement (el32);
|
||||
mesh.AddVolumeElement (el33);
|
||||
}
|
||||
return do_swap;
|
||||
return d_badness;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return d_badness;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3573,8 +3575,8 @@ void MeshOptimize3d :: SwapImprove2 (Mesh & mesh, OPTIMIZEGOAL goal)
|
||||
|
||||
int num_threads = ngcore::TaskManager::GetNumThreads();
|
||||
|
||||
Array<std::tuple<ElementIndex, int>> faces_with_improvement;
|
||||
Array<Array<std::tuple<ElementIndex, int>>> faces_with_improvement_threadlocal(num_threads);
|
||||
Array<std::tuple<double, ElementIndex, int>> faces_with_improvement;
|
||||
Array<Array<std::tuple<double, ElementIndex, int>>> faces_with_improvement_threadlocal(num_threads);
|
||||
|
||||
ParallelForRange( Range(ne), [&]( auto myrange )
|
||||
{
|
||||
@ -3601,8 +3603,9 @@ void MeshOptimize3d :: SwapImprove2 (Mesh & mesh, OPTIMIZEGOAL goal)
|
||||
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
if(SwapImprove2( mesh, goal, eli1, j, elementsonnode, belementsonnode, true))
|
||||
my_faces_with_improvement.Append( std::make_tuple(eli1, j) );
|
||||
double d_badness = SwapImprove2( mesh, goal, eli1, j, elementsonnode, belementsonnode, true);
|
||||
if(d_badness<0.0)
|
||||
my_faces_with_improvement.Append( std::make_tuple(d_badness, eli1, j) );
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -3612,8 +3615,9 @@ void MeshOptimize3d :: SwapImprove2 (Mesh & mesh, OPTIMIZEGOAL goal)
|
||||
|
||||
QuickSort(faces_with_improvement);
|
||||
|
||||
for (auto [eli,j] : faces_with_improvement)
|
||||
cnt += SwapImprove2( mesh, goal, eli, j, elementsonnode, belementsonnode, false);
|
||||
for (auto [dummy, eli,j] : faces_with_improvement)
|
||||
if(SwapImprove2( mesh, goal, eli, j, elementsonnode, belementsonnode, false) < 0.0)
|
||||
cnt++;
|
||||
|
||||
PrintMessage (5, cnt, " swaps performed");
|
||||
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
const NgArray< NgArray<int,PointIndex::BASE>* > * idmaps = NULL);
|
||||
void SwapImprove2Sequential (Mesh & mesh, OPTIMIZEGOAL goal = OPT_QUALITY);
|
||||
void SwapImprove2 (Mesh & mesh, OPTIMIZEGOAL goal = OPT_QUALITY);
|
||||
bool SwapImprove2 ( Mesh & mesh, OPTIMIZEGOAL goal, ElementIndex eli1, int face, Table<ElementIndex, PointIndex> & elementsonnode, TABLE<SurfaceElementIndex, PointIndex::BASE> & belementsonnode, bool check_only=false );
|
||||
double SwapImprove2 ( Mesh & mesh, OPTIMIZEGOAL goal, ElementIndex eli1, int face, Table<ElementIndex, PointIndex> & elementsonnode, TABLE<SurfaceElementIndex, PointIndex::BASE> & belementsonnode, bool check_only=false );
|
||||
|
||||
double
|
||||
CalcBad (const Mesh::T_POINTS & points, const Element & elem, double h)
|
||||
|
@ -1391,9 +1391,9 @@
|
||||
],
|
||||
"ne1d": 6026,
|
||||
"ne2d": 11450,
|
||||
"ne3d": 30659,
|
||||
"quality_histogram": "[3, 4, 8, 18, 26, 57, 158, 291, 798, 1106, 1681, 2709, 3238, 4075, 4533, 4309, 3453, 2498, 1351, 343]",
|
||||
"total_badness": 45874.630632
|
||||
"ne3d": 30654,
|
||||
"quality_histogram": "[3, 4, 8, 18, 25, 59, 158, 291, 794, 1103, 1677, 2706, 3249, 4083, 4515, 4321, 3450, 2495, 1353, 342]",
|
||||
"total_badness": 45863.767283
|
||||
},
|
||||
{
|
||||
"angles_tet": [
|
||||
@ -2460,7 +2460,7 @@
|
||||
},
|
||||
{
|
||||
"angles_tet": [
|
||||
4.6838,
|
||||
4.7033,
|
||||
172.82
|
||||
],
|
||||
"angles_trig": [
|
||||
@ -2470,8 +2470,8 @@
|
||||
"ne1d": 510,
|
||||
"ne2d": 1004,
|
||||
"ne3d": 1988,
|
||||
"quality_histogram": "[0, 19, 67, 59, 97, 97, 87, 135, 108, 111, 109, 144, 129, 178, 178, 176, 174, 69, 46, 5]",
|
||||
"total_badness": 4737.8528785
|
||||
"quality_histogram": "[0, 18, 67, 62, 94, 98, 88, 137, 111, 106, 105, 142, 130, 182, 178, 175, 174, 70, 46, 5]",
|
||||
"total_badness": 4736.9626467
|
||||
},
|
||||
{
|
||||
"angles_tet": [
|
||||
|
Loading…
Reference in New Issue
Block a user