Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/netgen/libsrc/meshing/boundarylayer.cpp
3206 views
1
#include <mystdlib.h>
2
#include "meshing.hpp"
3
4
namespace netgen
5
{
6
7
void InsertVirtualBoundaryLayer (Mesh & mesh)
8
{
9
cout << "Insert virt. b.l." << endl;
10
11
int surfid;
12
13
cout << "Boundary Nr:";
14
cin >> surfid;
15
16
int i, j;
17
int np = mesh.GetNP();
18
19
cout << "Old NP: " << mesh.GetNP() << endl;
20
cout << "Trigs: " << mesh.GetNSE() << endl;
21
22
BitArray bndnodes(np);
23
ARRAY<int> mapto(np);
24
25
bndnodes.Clear();
26
for (i = 1; i <= mesh.GetNSeg(); i++)
27
{
28
int snr = mesh.LineSegment(i).edgenr;
29
cout << "snr = " << snr << endl;
30
if (snr == surfid)
31
{
32
bndnodes.Set (mesh.LineSegment(i).p1);
33
bndnodes.Set (mesh.LineSegment(i).p2);
34
}
35
}
36
for (i = 1; i <= mesh.GetNSeg(); i++)
37
{
38
int snr = mesh.LineSegment(i).edgenr;
39
if (snr != surfid)
40
{
41
bndnodes.Clear (mesh.LineSegment(i).p1);
42
bndnodes.Clear (mesh.LineSegment(i).p2);
43
}
44
}
45
46
for (i = 1; i <= np; i++)
47
{
48
if (bndnodes.Test(i))
49
mapto.Elem(i) = mesh.AddPoint (mesh.Point (i));
50
else
51
mapto.Elem(i) = 0;
52
}
53
54
for (i = 1; i <= mesh.GetNSE(); i++)
55
{
56
Element2d & el = mesh.SurfaceElement(i);
57
for (j = 1; j <= el.GetNP(); j++)
58
if (mapto.Get(el.PNum(j)))
59
el.PNum(j) = mapto.Get(el.PNum(j));
60
}
61
62
63
int nq = 0;
64
for (i = 1; i <= mesh.GetNSeg(); i++)
65
{
66
int snr = mesh.LineSegment(i).edgenr;
67
if (snr == surfid)
68
{
69
int p1 = mesh.LineSegment(i).p1;
70
int p2 = mesh.LineSegment(i).p2;
71
int p3 = mapto.Get (p1);
72
if (!p3) p3 = p1;
73
int p4 = mapto.Get (p2);
74
if (!p4) p4 = p2;
75
76
Element2d el(QUAD);
77
el.PNum(1) = p1;
78
el.PNum(2) = p2;
79
el.PNum(3) = p3;
80
el.PNum(4) = p4;
81
el.SetIndex (2);
82
mesh.AddSurfaceElement (el);
83
nq++;
84
}
85
}
86
87
cout << "New NP: " << mesh.GetNP() << endl;
88
cout << "Quads: " << nq << endl;
89
}
90
91
}
92
93
94