- Thank you received: 0
Orientation of the normal in 2D
2 years 6 months ago #4416
by pbmonk
Orientation of the normal in 2D was created by pbmonk
I would like to solve a scattering problem in 2D. The scatterer is a subdomain for example:
def square(hmax=0.1,pml_rad=2,delta_pml=1):
geo = SplineGeometry()
L2=.5
geo.AddRectangle(p1=(-L2,-L2),p2=(L2,L2),bc="trans",leftdomain=3,rightdomain=1)
geo.AddCircle( (0,0),pml_rad+delta_pml , leftdomain=2, rightdomain=0, bc="outerbnd")
geo.AddCircle( (0,0), pml_rad, leftdomain=1, rightdomain=2)
geo.SetMaterial(1, "air")
geo.SetMaterial(2, "PML")
geo.SetMaterial(3, "scatterer")
mesh = Mesh(geo.GenerateMesh(maxh=hmax))
return(mesh,pml_rad,ngmesh)
I get the normal via
nv=specialcf.normal(mesh.dim)
Is there some way to test that the normal in nv is outwards from the scatterer (so I can set transmission conditions), and reverse the normal if needed?
Thanks in advance for your help.
Best
Peter
def square(hmax=0.1,pml_rad=2,delta_pml=1):
geo = SplineGeometry()
L2=.5
geo.AddRectangle(p1=(-L2,-L2),p2=(L2,L2),bc="trans",leftdomain=3,rightdomain=1)
geo.AddCircle( (0,0),pml_rad+delta_pml , leftdomain=2, rightdomain=0, bc="outerbnd")
geo.AddCircle( (0,0), pml_rad, leftdomain=1, rightdomain=2)
geo.SetMaterial(1, "air")
geo.SetMaterial(2, "PML")
geo.SetMaterial(3, "scatterer")
mesh = Mesh(geo.GenerateMesh(maxh=hmax))
return(mesh,pml_rad,ngmesh)
I get the normal via
nv=specialcf.normal(mesh.dim)
Is there some way to test that the normal in nv is outwards from the scatterer (so I can set transmission conditions), and reverse the normal if needed?
Thanks in advance for your help.
Best
Peter
- mneunteufel
- Offline
- Premium Member
Less
More
- Thank you received: 59
2 years 6 months ago #4417
by mneunteufel
Replied by mneunteufel on topic Orientation of the normal in 2D
Hi Peter,
you can visualize the normal vector by interpolating it into a VectorH1 GridFunction, e.g.
mesh, pml, ngmesh = square()
gfnv = GridFunction(VectorH1(mesh,order=1))
gfnv.Set(specialcf.normal(2),definedon=mesh.Boundaries(".*"))
Draw(gfnv, mesh, "nv")
In the Netgen GUI in Visual by enabling "Draw Surface Vectors" on the bottom right (and maybe increasing the Grid at the top left) the drawn arrows should show the direction of the normal vector. It looks like that in this example all normal vectors point outwards the whole domain.
Best,
Michael
you can visualize the normal vector by interpolating it into a VectorH1 GridFunction, e.g.
mesh, pml, ngmesh = square()
gfnv = GridFunction(VectorH1(mesh,order=1))
gfnv.Set(specialcf.normal(2),definedon=mesh.Boundaries(".*"))
Draw(gfnv, mesh, "nv")
In the Netgen GUI in Visual by enabling "Draw Surface Vectors" on the bottom right (and maybe increasing the Grid at the top left) the drawn arrows should show the direction of the normal vector. It looks like that in this example all normal vectors point outwards the whole domain.
Best,
Michael
Time to create page: 0.101 seconds