netgen
netgen copied to clipboard
Extending the i-tutorial 1.7.1 Perfectly matched layers (PML) (can't create mesh – getting loclines.Size = 1 ) ?
Hello
I am trying to build upon the Helmholtz equation solver with PML example (1.7.1) by extending the geometry and mesh originally defined with the SplineGeometry.
Specifically, I want to add another PML subdomain, so I am adding two points, and connecting them with 3 lines.
geo = SplineGeometry()
pnums = [geo.AddPoint(x, y, maxh=maxh)
for x,y,maxh in
[
(-2, 0, 1), #1
(-1, 0, 1), #2
(-0.2, 0, 0.01), #3
(-0.2, -0.8, 1), #4
(0.2, -0.8, 1), #5
(0.2, 0, 0.01), #6
(1,0,1), #7
(2,0,1), #8
(2,2,1), #9
(0,2,1), #10
(-2,2,1), #11
(1,1,1), #12
(0,1,1), #13
(-1,1,1), #14
(-2, -2, 1), #15
(2, -2, 1) #16
]
]
lines = [
(1,2,"dir", 1,0),
(2,3,"dir",1,0),
(3,4,"dir",1,0),
(4,5,"dir",1,0),
(5,6,"dir",1,0),
(6,7,"dir",2,0),
(1,14,"dir",3,0),
(14,15,"dir",3,0),
(15,7,"dir",3,0)
# (1,15,"dir",3,0), INDEX ERROR: list index out of range
# (15,16,"dir",3,0),
# (16,7,"dir",3,0)
]
curves = [
(7,8,9,"outer",2,0),
(9,10,0,"outer",2,0),
(6,11,12,"inner",1,2),
(12,13,1,"inner",1,2)
]
print(pnums)
for p1,p2,bc,left,right in lines:
print((p1,p2,bc,left,right))
geo.Append(["line", pnums[p1], pnums[p2]], bc=bc, leftdomain=left, rightdomain=right)
for p1,p2,p3,bc,left,right in curves:
geo.Append(["spline3", pnums[p1], pnums[p2], pnums[p3]], bc=bc, leftdomain=left, rightdomain=right)
geo.SetMaterial(1, "air")
geo.SetMaterial(2, "pml")
geo.SetMaterial(3, "pml2")
mesh = Mesh(geo.GenerateMesh(maxh=0.1))
mesh.Curve(5)
Draw(mesh)
However when I try to execute to generate and draw the mesh, I get this infinite output message
loclines.Size = 1
loclines.Size = 1
loclines.Size = 1
loclines.Size = 1
loclines.Size = 1
loclines.Size = 1
loclines.Size = 1
loclines.Size = 1
loclines.Size = 1
loclines.Size = 1
loclines.Size = 1
I can't understand what I'm doing wrong. Could you provide feedback on my code and help me debug?
thanks, Francisco