Merge branch 'better_combine_improve_2d' into 'master'

evalute localh in multiple points and take average

See merge request jschoeberl/netgen!498
This commit is contained in:
Joachim Schöberl 2022-04-13 17:34:53 +00:00
commit ab462237af
3 changed files with 1286 additions and 1284 deletions

View File

@ -145,7 +145,7 @@ namespace netgen
}
else
{
double loch = mesh.GetH(mesh[pi1]);
double loch = 0.25*(mesh.GetH(pi1) + mesh.GetH(pi2) + mesh.GetH(pi3) + mesh.GetH(pi4));
should =
CalcTriangleBadness (mesh[pi4], mesh[pi3], mesh[pi1], metricweight, loch) +
CalcTriangleBadness (mesh[pi3], mesh[pi4], mesh[pi2], metricweight, loch) <
@ -383,21 +383,10 @@ namespace netgen
<< "pi1 = " << pi1 << " pi2 = " << pi2 << endl;
}
/*
// save version:
if (fixed.Get(pi1) || fixed.Get(pi2))
return 0.0;
if (pi2 < pi1) swap (pi1, pi2);
*/
// more general
if (fixed[pi2])
Swap (pi1, pi2);
if (fixed[pi2])
return 0.0;
double loch = mesh.GetH (mesh[pi1]);
double loch = 0.5*(mesh.GetH(pi1) + mesh.GetH(pi2));
int faceindex = -1;
for (SurfaceElementIndex sei2 : elementsonnode[pi1])
@ -655,6 +644,9 @@ namespace netgen
double d_badness = CombineImproveEdge(mesh, elementsonnode, normals, fixed, pi1, pi2, metricweight, true);
if(d_badness < 0.0)
candidate_edges[improvement_counter++] = make_tuple(d_badness, i);
d_badness = CombineImproveEdge(mesh, elementsonnode, normals, fixed, pi2, pi1, metricweight, true);
if(d_badness < 0.0)
candidate_edges[improvement_counter++] = make_tuple(d_badness, -i);
}, TasksPerThread(4));
auto edges_with_improvement = candidate_edges.Part(0, improvement_counter.load());
@ -662,7 +654,9 @@ namespace netgen
for(auto [d_badness, ei] : edges_with_improvement)
{
auto [pi1, pi2] = edges[ei];
auto [pi1, pi2] = edges[ei < 0 ? -ei : ei];
if(ei<0)
Swap(pi1,pi2);
CombineImproveEdge(mesh, elementsonnode, normals, fixed, pi1, pi2, metricweight, false);
}

View File

@ -66,19 +66,27 @@ data2 = readData(s2, filenames)
assert(len(data) == len(data2))
w = 90
GREEN = '\033[92m'
RED = '\033[91m'
RESET = '\033[0m'
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}")
diff = f"{100*(bad2-bad1)/bad1:+.2f}%"
if bad2>0 and bad2>1.2*bad1:
print(f"{RED}badness {f1} got worse: {bad1} -> {bad2}".ljust(w) + diff + RESET)
if bad2>0 and bad2<0.8*bad1:
print(f"{GREEN}badness {f1} got better: {bad1} -> {bad2}".ljust(w) + diff + RESET)
for bad1,bad2, f1, f2 in zip(data['#trigs'], data2['#trigs'], 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}")
diff = f"{100*(bad2-bad1)/bad1:+.2f}%"
if bad2>0 and bad2>1.2*bad1:
print(f"{RED}ntrigs {f1} got worse: {bad1} -> {bad2}".ljust(w) + diff + RESET)
if bad2>0 and bad2<0.8*bad1:
print(f"{GREEN}ntrigs {f1} got better: {bad1} -> {bad2}".ljust(w) + diff + RESET)
n = len(data)+1
fig,ax = plt.subplots(figsize=(10,7))

File diff suppressed because it is too large Load Diff