Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/netgen/libsrc/meshing/meshfunc2d.cpp
3206 views
1
#include <mystdlib.h>
2
#include "meshing.hpp"
3
4
namespace netgen
5
{
6
7
void Optimize2d (Mesh & mesh, MeshingParameters & mp)
8
{
9
int i;
10
11
//double h = mp.maxh;
12
13
mesh.CalcSurfacesOfNode();
14
15
const char * optstr = mp.optimize2d;
16
int optsteps = mp.optsteps2d;
17
18
// cout << "optstr = " << optstr << endl;
19
20
for (i = 1; i <= optsteps; i++)
21
for (size_t j = 1; j <= strlen(optstr); j++)
22
{
23
if (multithread.terminate) break;
24
switch (optstr[j-1])
25
{
26
case 's':
27
{ // topological swap
28
MeshOptimize2d meshopt;
29
meshopt.SetMetricWeight (0);
30
meshopt.EdgeSwapping (mesh, 0);
31
break;
32
}
33
case 'S':
34
{ // metric swap
35
MeshOptimize2d meshopt;
36
meshopt.SetMetricWeight (0);
37
meshopt.EdgeSwapping (mesh, 1);
38
break;
39
}
40
case 'm':
41
{
42
MeshOptimize2d meshopt;
43
meshopt.SetMetricWeight (1);
44
meshopt.ImproveMesh(mesh);
45
break;
46
}
47
48
case 'c':
49
{
50
MeshOptimize2d meshopt;
51
meshopt.SetMetricWeight (0.2);
52
meshopt.CombineImprove(mesh);
53
break;
54
}
55
default:
56
cerr << "Optimization code " << optstr[j-1] << " not defined" << endl;
57
}
58
}
59
}
60
61
}
62
63