Merge branch 'consistent_swapimprove_opt_conform' into 'master'

consistent criterion for conformance optimization in SwapImprove

See merge request jschoeberl/netgen!391
This commit is contained in:
Joachim Schöberl 2021-06-10 09:23:18 +00:00
commit 55175925e3
3 changed files with 157 additions and 143 deletions

View File

@ -2245,7 +2245,7 @@ double MeshOptimize3d :: SwapImproveEdge (Mesh & mesh, OPTIMIZEGOAL goal,
bad2 += 1e4;
if (goal == OPT_CONFORM && bad2 < 1e4)
if (goal == OPT_CONFORM && NotTooBad(bad1, bad2))
{
INDEX_3 face(pi3, pi4, pi5);
face.Sort();
@ -2253,8 +2253,7 @@ double MeshOptimize3d :: SwapImproveEdge (Mesh & mesh, OPTIMIZEGOAL goal,
{
// (*testout) << "3->2 swap, could improve conformity, bad1 = " << bad1
// << ", bad2 = " << bad2 << endl;
if (bad2 < 1e4)
bad1 = 2 * bad2;
bad2 = bad1 + IMPROVEMENT_CONFORMING_EDGE;
}
}
@ -2650,6 +2649,9 @@ double MeshOptimize3d :: SwapImproveEdge (Mesh & mesh, OPTIMIZEGOAL goal,
if (confface != -1)
bestl = confface;
if(confface != -1 || confedge != -1)
badopt = bad1 + IMPROVEMENT_CONFORMING_EDGE;
if (bestl != -1)
{
// (*mycout) << nsuround << "->" << 2 * (nsuround-2) << " " << flush;

View File

@ -12,8 +12,10 @@ def readData(a, files):
ne1d=[]
ne2d=[]
ne3d=[]
file=[]
for f in files:
for t in a[f]:
file.append(f)
if t['ne1d']>0:
ne1d.append(t['ne1d'])
if t['ne2d']>0:
@ -37,6 +39,7 @@ def readData(a, files):
"#edges" : ne1d,
"#trigs" : ne2d,
"#tets" : ne3d,
"file" : file,
}
import matplotlib.pyplot as plt
@ -61,6 +64,15 @@ filenames = [f for f in s if f in s2]
data = readData(s, filenames)
data2 = readData(s2, filenames)
assert(len(data) == len(data2))
for bad1,bad2, f1, f2 in zip(data['badness'], data2['badness'], data['file'], data2['file']):
assert f1==f2
if bad2>0 and bad2>1.1*bad1:
print(f"file {f1} got worse: {bad1} -> {bad2}")
if bad2>0 and bad2<0.9*bad1:
print(f"file {f1} got better: {bad1} -> {bad2}")
n = len(data)+1
fig,ax = plt.subplots(figsize=(10,7))
for i,d in enumerate(['min trig angle','min tet angle','max trig angle','max tet angle']):

View File

@ -486,9 +486,9 @@
],
"ne1d": 134,
"ne2d": 160,
"ne3d": 245,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 25, 37, 40, 42, 43, 30, 15, 3, 2]",
"total_badness": 349.09002466
"ne3d": 244,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 25, 35, 41, 42, 42, 31, 15, 4, 2]",
"total_badness": 346.48816749
},
{
"angles_tet": [
@ -501,9 +501,9 @@
],
"ne1d": 190,
"ne2d": 282,
"ne3d": 589,
"quality_histogram": "[0, 0, 0, 0, 2, 0, 0, 5, 2, 13, 40, 46, 62, 105, 90, 94, 60, 46, 20, 4]",
"total_badness": 862.89134979
"ne3d": 584,
"quality_histogram": "[0, 0, 0, 0, 2, 0, 1, 5, 2, 15, 44, 43, 59, 99, 94, 91, 62, 43, 21, 3]",
"total_badness": 858.49088107
},
{
"angles_tet": [
@ -1290,7 +1290,7 @@
},
{
"angles_tet": [
16.097,
14.707,
160.17
],
"angles_trig": [
@ -1300,8 +1300,8 @@
"ne1d": 104,
"ne2d": 152,
"ne3d": 124,
"quality_histogram": "[0, 0, 0, 0, 10, 19, 39, 26, 9, 3, 1, 1, 5, 1, 3, 2, 3, 2, 0, 0]",
"total_badness": 353.53219387
"quality_histogram": "[0, 0, 0, 1, 8, 21, 38, 26, 9, 3, 1, 1, 5, 1, 3, 2, 3, 2, 0, 0]",
"total_badness": 354.28790114
},
{
"angles_tet": [
@ -1444,7 +1444,7 @@
"frame.step": [
{
"angles_tet": [
2.8491,
2.9086,
171.1
],
"angles_trig": [
@ -1453,39 +1453,39 @@
],
"ne1d": 10108,
"ne2d": 29958,
"ne3d": 152591,
"quality_histogram": "[0, 3, 1, 3, 8, 19, 67, 166, 526, 1268, 2848, 5750, 10287, 16353, 21624, 25759, 26679, 22815, 14557, 3858]",
"total_badness": 201926.65352
"ne3d": 152461,
"quality_histogram": "[0, 3, 1, 3, 6, 18, 51, 153, 539, 1234, 2814, 5708, 10236, 16240, 21696, 25712, 26711, 22859, 14609, 3868]",
"total_badness": 201603.34124
},
{
"angles_tet": [
2.296,
175.61
175.72
],
"angles_trig": [
2.0087,
175.57
3.4731,
146.28
],
"ne1d": 5988,
"ne2d": 10976,
"ne3d": 29065,
"quality_histogram": "[3, 4, 3, 11, 16, 45, 110, 221, 664, 978, 1581, 2526, 3121, 3891, 4274, 4114, 3456, 2388, 1312, 347]",
"total_badness": 43056.520137
"ne3d": 28875,
"quality_histogram": "[3, 4, 4, 9, 16, 45, 103, 213, 662, 993, 1514, 2528, 3069, 3888, 4348, 4102, 3364, 2352, 1334, 324]",
"total_badness": 42759.274327
},
{
"angles_tet": [
2.171,
2.1678,
174.11
],
"angles_trig": [
1.6035,
174.13
150.55
],
"ne1d": 9622,
"ne2d": 23596,
"ne3d": 80062,
"quality_histogram": "[2, 15, 4, 18, 14, 35, 84, 189, 432, 1005, 2118, 4194, 7190, 10267, 12556, 13449, 12163, 9311, 5588, 1428]",
"total_badness": 110028.28336
"ne3d": 79955,
"quality_histogram": "[2, 15, 2, 17, 16, 36, 79, 196, 428, 1003, 2107, 4194, 7142, 10182, 12517, 13476, 12277, 9263, 5564, 1439]",
"total_badness": 109848.90296
}
],
"hinge.stl": [
@ -1500,24 +1500,24 @@
],
"ne1d": 456,
"ne2d": 1212,
"ne3d": 1997,
"quality_histogram": "[0, 0, 0, 0, 0, 2, 3, 13, 16, 45, 74, 128, 187, 237, 290, 279, 264, 264, 149, 46]",
"total_badness": 2785.3969831
"ne3d": 1985,
"quality_histogram": "[0, 0, 0, 0, 0, 3, 3, 11, 21, 48, 78, 121, 177, 243, 281, 291, 257, 267, 140, 44]",
"total_badness": 2774.8392965
},
{
"angles_tet": [
7.7862,
7.6058,
161.84
],
"angles_trig": [
9.6143,
148.89
152.14
],
"ne1d": 298,
"ne2d": 610,
"ne3d": 789,
"quality_histogram": "[0, 0, 1, 10, 9, 4, 22, 15, 40, 43, 68, 84, 103, 96, 83, 85, 48, 49, 25, 4]",
"total_badness": 1364.9012739
"ne3d": 785,
"quality_histogram": "[0, 0, 2, 11, 6, 6, 19, 18, 36, 45, 66, 84, 102, 91, 81, 82, 51, 54, 26, 5]",
"total_badness": 1354.028297
},
{
"angles_tet": [
@ -1525,14 +1525,14 @@
164.51
],
"angles_trig": [
12.656,
152.72
12.725,
144.55
],
"ne1d": 370,
"ne2d": 850,
"ne3d": 1124,
"quality_histogram": "[0, 0, 1, 1, 7, 6, 14, 27, 38, 52, 69, 112, 142, 138, 163, 145, 96, 62, 43, 8]",
"total_badness": 1789.6525041
"ne3d": 1123,
"quality_histogram": "[0, 0, 1, 1, 7, 6, 15, 27, 38, 52, 69, 112, 144, 138, 162, 142, 96, 62, 43, 8]",
"total_badness": 1791.0009554
},
{
"angles_tet": [
@ -1540,29 +1540,29 @@
156.97
],
"angles_trig": [
21.175,
135.02
21.769,
131.54
],
"ne1d": 516,
"ne2d": 1570,
"ne3d": 2567,
"quality_histogram": "[0, 0, 0, 0, 0, 4, 3, 5, 22, 47, 97, 152, 226, 318, 382, 403, 346, 303, 207, 52]",
"total_badness": 3558.447444
"ne3d": 2603,
"quality_histogram": "[0, 0, 0, 0, 0, 4, 3, 5, 24, 49, 99, 162, 236, 315, 392, 410, 338, 298, 213, 55]",
"total_badness": 3617.4946271
},
{
"angles_tet": [
19.878,
145.14
146.81
],
"angles_trig": [
22.16,
131.22
21.108,
133.01
],
"ne1d": 722,
"ne2d": 2856,
"ne3d": 6740,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 1, 3, 20, 38, 63, 161, 381, 636, 854, 1077, 1143, 1240, 851, 272]",
"total_badness": 8654.5076132
"ne3d": 6742,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 1, 2, 22, 37, 55, 164, 381, 655, 846, 1080, 1151, 1213, 867, 268]",
"total_badness": 8659.2800224
},
{
"angles_tet": [
@ -1900,9 +1900,9 @@
],
"ne1d": 248,
"ne2d": 2320,
"ne3d": 16409,
"quality_histogram": "[0, 0, 0, 0, 0, 4, 20, 55, 119, 192, 288, 630, 958, 1489, 2106, 2552, 2926, 2613, 1913, 544]",
"total_badness": 21635.781365
"ne3d": 16407,
"quality_histogram": "[0, 0, 0, 0, 0, 4, 20, 55, 118, 191, 287, 630, 956, 1497, 2097, 2550, 2936, 2608, 1913, 545]",
"total_badness": 21630.784432
},
{
"angles_tet": [
@ -2015,18 +2015,18 @@
"part1.stl": [
{
"angles_tet": [
14.209,
147.23
13.063,
147.22
],
"angles_trig": [
19.94,
127.49
119.28
],
"ne1d": 170,
"ne2d": 448,
"ne3d": 1261,
"quality_histogram": "[0, 0, 0, 0, 0, 1, 3, 8, 15, 25, 35, 78, 97, 157, 211, 199, 161, 144, 100, 27]",
"total_badness": 1752.4668505
"ne3d": 1232,
"quality_histogram": "[0, 0, 0, 0, 0, 1, 3, 7, 14, 22, 38, 66, 91, 150, 218, 198, 155, 156, 86, 27]",
"total_badness": 1707.0143419
},
{
"angles_tet": [
@ -2039,14 +2039,14 @@
],
"ne1d": 134,
"ne2d": 286,
"ne3d": 529,
"quality_histogram": "[0, 0, 0, 2, 4, 2, 4, 5, 13, 31, 36, 45, 51, 81, 71, 56, 62, 43, 20, 3]",
"total_badness": 824.2762646
"ne3d": 509,
"quality_histogram": "[0, 0, 0, 2, 4, 3, 5, 5, 18, 25, 33, 48, 51, 64, 72, 65, 52, 30, 24, 8]",
"total_badness": 798.54900393
},
{
"angles_tet": [
19.623,
148.63
19.624,
148.62
],
"angles_trig": [
19.446,
@ -2054,29 +2054,29 @@
],
"ne1d": 194,
"ne2d": 590,
"ne3d": 1629,
"quality_histogram": "[0, 0, 0, 0, 0, 1, 1, 2, 7, 11, 31, 56, 119, 210, 240, 245, 292, 235, 140, 39]",
"total_badness": 2170.2820961
"ne3d": 1631,
"quality_histogram": "[0, 0, 0, 0, 0, 1, 1, 2, 7, 15, 35, 54, 127, 203, 240, 247, 285, 232, 144, 38]",
"total_badness": 2179.4995302
},
{
"angles_tet": [
21.731,
138.73
20.545,
150.39
],
"angles_trig": [
24.944,
119.75
23.604,
120.32
],
"ne1d": 266,
"ne2d": 980,
"ne3d": 4128,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 0, 1, 1, 5, 20, 83, 161, 326, 494, 640, 851, 800, 593, 153]",
"total_badness": 5188.8712057
"ne3d": 4061,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 1, 1, 2, 5, 30, 78, 131, 284, 527, 619, 852, 827, 552, 152]",
"total_badness": 5098.4284907
},
{
"angles_tet": [
21.099,
146.09
20.783,
146.42
],
"angles_trig": [
24.61,
@ -2084,9 +2084,9 @@
],
"ne1d": 674,
"ne2d": 6832,
"ne3d": 82647,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 0, 1, 4, 17, 101, 396, 1391, 3605, 7593, 12586, 17573, 19510, 15047, 4823]",
"total_badness": 99991.989263
"ne3d": 82637,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 0, 1, 4, 17, 97, 397, 1390, 3595, 7583, 12590, 17553, 19516, 15071, 4823]",
"total_badness": 99971.30166
}
],
"period.geo": [
@ -2107,18 +2107,18 @@
},
{
"angles_tet": [
12.301,
162.28
10.254,
166.55
],
"angles_trig": [
14.767,
140.96
144.13
],
"ne1d": 160,
"ne2d": 280,
"ne3d": 601,
"quality_histogram": "[0, 0, 0, 0, 3, 6, 10, 21, 33, 57, 65, 81, 72, 40, 61, 53, 34, 48, 13, 4]",
"total_badness": 1021.3669479
"ne3d": 581,
"quality_histogram": "[0, 0, 1, 1, 4, 8, 17, 22, 29, 58, 59, 78, 67, 40, 55, 45, 32, 46, 16, 3]",
"total_badness": 1019.9118615
},
{
"angles_tet": [
@ -2193,54 +2193,54 @@
],
"ne1d": 886,
"ne2d": 2528,
"ne3d": 8236,
"quality_histogram": "[5, 8, 33, 42, 41, 52, 40, 53, 84, 115, 226, 410, 616, 890, 1226, 1335, 1291, 1015, 601, 153]",
"total_badness": 12202.367974
"ne3d": 8259,
"quality_histogram": "[5, 8, 29, 42, 47, 53, 42, 53, 86, 127, 234, 422, 649, 869, 1201, 1333, 1280, 1021, 605, 153]",
"total_badness": 12253.881955
},
{
"angles_tet": [
1.181,
1.1793,
174.03
],
"angles_trig": [
2.5404,
170.0
4.4862,
152.74
],
"ne1d": 570,
"ne2d": 1126,
"ne3d": 1625,
"quality_histogram": "[3, 23, 42, 49, 57, 79, 92, 122, 133, 143, 160, 125, 136, 136, 122, 67, 62, 43, 27, 4]",
"total_badness": 4132.7009693
"ne3d": 1585,
"quality_histogram": "[4, 28, 40, 51, 57, 65, 84, 108, 127, 145, 155, 131, 141, 135, 112, 71, 58, 49, 20, 4]",
"total_badness": 4116.4289328
},
{
"angles_tet": [
1.1,
172.16
172.17
],
"angles_trig": [
2.2863,
165.88
3.2068,
163.66
],
"ne1d": 724,
"ne2d": 1662,
"ne3d": 3079,
"quality_histogram": "[2, 13, 28, 54, 52, 45, 53, 71, 110, 127, 187, 249, 337, 394, 368, 357, 294, 200, 113, 25]",
"total_badness": 5638.801451
"ne3d": 3087,
"quality_histogram": "[2, 15, 30, 56, 49, 41, 55, 69, 99, 124, 187, 257, 341, 403, 358, 368, 297, 206, 109, 21]",
"total_badness": 5672.1029809
},
{
"angles_tet": [
1.2152,
169.91
165.67
],
"angles_trig": [
1.1526,
158.98
152.31
],
"ne1d": 956,
"ne2d": 2742,
"ne3d": 8675,
"quality_histogram": "[3, 11, 40, 47, 45, 52, 53, 57, 84, 132, 177, 326, 500, 771, 1187, 1468, 1538, 1257, 742, 185]",
"total_badness": 12664.774403
"ne3d": 8640,
"quality_histogram": "[3, 10, 38, 48, 47, 55, 52, 55, 83, 138, 177, 324, 506, 776, 1201, 1406, 1497, 1301, 722, 201]",
"total_badness": 12611.933258
},
{
"angles_tet": [
@ -2253,9 +2253,9 @@
],
"ne1d": 1554,
"ne2d": 6276,
"ne3d": 30191,
"quality_histogram": "[2, 8, 13, 8, 27, 48, 54, 67, 94, 163, 310, 595, 1224, 2288, 3706, 5135, 6007, 5525, 3828, 1089]",
"total_badness": 39089.872515
"ne3d": 30128,
"quality_histogram": "[2, 8, 13, 8, 26, 47, 54, 67, 97, 161, 296, 601, 1218, 2303, 3660, 5126, 5976, 5561, 3809, 1095]",
"total_badness": 38992.872327
},
{
"angles_tet": [
@ -2268,9 +2268,9 @@
],
"ne1d": 2992,
"ne2d": 23260,
"ne3d": 281899,
"quality_histogram": "[4, 10, 11, 10, 10, 23, 27, 58, 100, 257, 753, 2012, 5557, 13696, 27894, 44772, 59147, 64039, 48573, 14946]",
"total_badness": 344505.69105
"ne3d": 281849,
"quality_histogram": "[4, 10, 11, 10, 9, 25, 27, 57, 103, 264, 751, 2013, 5565, 13730, 27855, 44729, 59205, 63981, 48551, 14949]",
"total_badness": 344465.16205
}
],
"revolution.geo": [
@ -2377,9 +2377,9 @@
],
"ne1d": 400,
"ne2d": 1390,
"ne3d": 2336,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 2, 54, 79, 137, 200, 257, 265, 306, 286, 263, 221, 140, 104, 22]",
"total_badness": 3622.1771287
"ne3d": 2335,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 2, 55, 79, 134, 196, 259, 266, 307, 287, 261, 222, 141, 104, 22]",
"total_badness": 3618.6672084
},
{
"angles_tet": [
@ -2398,8 +2398,8 @@
},
{
"angles_tet": [
20.122,
143.27
20.14,
143.25
],
"angles_trig": [
23.794,
@ -2407,9 +2407,9 @@
],
"ne1d": 666,
"ne2d": 4792,
"ne3d": 31253,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 0, 2, 5, 23, 101, 240, 652, 1499, 3037, 4927, 6557, 7202, 5289, 1719]",
"total_badness": 38131.596693
"ne3d": 31261,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 0, 2, 6, 21, 103, 237, 651, 1503, 3041, 4906, 6579, 7204, 5289, 1719]",
"total_badness": 38140.005778
}
],
"sculpture.geo": [
@ -2425,8 +2425,8 @@
"ne1d": 192,
"ne2d": 410,
"ne3d": 475,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 2, 3, 7, 11, 21, 29, 61, 75, 95, 88, 43, 27, 12, 1]",
"total_badness": 694.76962476
"quality_histogram": "[0, 0, 0, 0, 0, 0, 1, 3, 7, 12, 22, 31, 60, 75, 93, 89, 42, 27, 12, 1]",
"total_badness": 695.03425262
},
{
"angles_tet": [
@ -2470,8 +2470,8 @@
"ne1d": 192,
"ne2d": 410,
"ne3d": 475,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 2, 3, 7, 11, 21, 29, 61, 75, 95, 88, 43, 27, 12, 1]",
"total_badness": 694.76962627
"quality_histogram": "[0, 0, 0, 0, 0, 0, 1, 3, 7, 12, 22, 31, 60, 75, 93, 89, 42, 27, 12, 1]",
"total_badness": 695.03425413
},
{
"angles_tet": [
@ -3161,13 +3161,13 @@
"ne1d": 690,
"ne2d": 1670,
"ne3d": 5169,
"quality_histogram": "[0, 0, 1, 0, 0, 8, 32, 37, 105, 200, 283, 367, 447, 560, 691, 707, 596, 539, 460, 136]",
"total_badness": 7461.9317917
"quality_histogram": "[0, 0, 1, 0, 0, 8, 33, 39, 106, 196, 284, 368, 450, 562, 679, 709, 595, 542, 461, 136]",
"total_badness": 7464.5609796
},
{
"angles_tet": [
8.0938,
167.14
8.1301,
160.14
],
"angles_trig": [
7.7605,
@ -3175,14 +3175,14 @@
],
"ne1d": 390,
"ne2d": 522,
"ne3d": 1351,
"quality_histogram": "[0, 0, 4, 10, 15, 42, 76, 120, 122, 145, 170, 128, 141, 108, 82, 86, 54, 35, 11, 2]",
"total_badness": 2733.6025132
"ne3d": 1382,
"quality_histogram": "[0, 0, 3, 8, 13, 39, 84, 122, 123, 153, 169, 133, 139, 114, 88, 88, 55, 37, 12, 2]",
"total_badness": 2771.9730366
},
{
"angles_tet": [
7.8932,
164.55
8.6612,
163.89
],
"angles_trig": [
14.15,
@ -3190,9 +3190,9 @@
],
"ne1d": 512,
"ne2d": 866,
"ne3d": 2357,
"quality_histogram": "[0, 0, 0, 3, 9, 15, 43, 72, 120, 149, 193, 201, 308, 384, 335, 230, 139, 84, 49, 23]",
"total_badness": 3906.7263127
"ne3d": 2373,
"quality_histogram": "[0, 0, 0, 3, 9, 17, 46, 71, 120, 145, 191, 205, 314, 382, 341, 234, 138, 87, 46, 24]",
"total_badness": 3936.100832
},
{
"angles_tet": [
@ -3205,9 +3205,9 @@
],
"ne1d": 690,
"ne2d": 1670,
"ne3d": 5111,
"quality_histogram": "[0, 0, 1, 0, 0, 3, 21, 38, 107, 192, 269, 348, 432, 542, 664, 707, 611, 564, 471, 141]",
"total_badness": 7317.6330247
"ne3d": 5123,
"quality_histogram": "[0, 0, 1, 0, 0, 3, 22, 38, 106, 190, 271, 350, 435, 551, 670, 694, 624, 558, 468, 142]",
"total_badness": 7336.254691
},
{
"angles_tet": [
@ -3220,9 +3220,9 @@
],
"ne1d": 1050,
"ne2d": 3784,
"ne3d": 17722,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 3, 14, 36, 67, 187, 548, 1407, 2109, 2399, 2596, 2679, 2730, 2285, 662]",
"total_badness": 23125.468501
"ne3d": 17727,
"quality_histogram": "[0, 0, 0, 0, 0, 0, 3, 14, 36, 63, 190, 539, 1406, 2089, 2407, 2557, 2702, 2729, 2318, 674]",
"total_badness": 23111.051534
},
{
"angles_tet": [