- Thank you received: 0
Boundaries of open surfaces
- Bittermandeln
- Topic Author
- Offline
- Junior Member
Less
More
4 years 6 days ago #3339
by Bittermandeln
Boundaries of open surfaces was created by Bittermandeln
Hi,
I want to do a boundary integral for an open surface, namely a half-cylinder, in order to implement boundary conditions in the Nitsche fashion. Parts of my code now look like
geo = CSGeometry()
r = 1/pi
cyl = Cylinder(Pnt(0,0,0), Pnt(1,0,0),r)
top = Plane(Pnt(0,0,0),Vec(0,0,-1))
left = Plane(Pnt(0,0,0),Vec(-1,0,0))
right =Plane(Pnt(1,0,0),Vec(1,0,0))
shell = (cyl * left*right*top)
geo.AddSurface(cyl, shell)
################
mesh = Mesh(geo.GenerateMesh(maxh=0.3))
bnd_D = mesh.Boundaries("dir")
in order to define the mesh and the boundary. I then perform the integral using e.g.
a += SymbolicBFI(InnerProduct(p*mu, v.Trace()), BND, element_boundary = True, definedon = bnd_D)
However, it seems that NGSolve skips this integral. Does anyone know what I am doing wrong?
Best regards,
Alvar
I want to do a boundary integral for an open surface, namely a half-cylinder, in order to implement boundary conditions in the Nitsche fashion. Parts of my code now look like
geo = CSGeometry()
r = 1/pi
cyl = Cylinder(Pnt(0,0,0), Pnt(1,0,0),r)
top = Plane(Pnt(0,0,0),Vec(0,0,-1))
left = Plane(Pnt(0,0,0),Vec(-1,0,0))
right =Plane(Pnt(1,0,0),Vec(1,0,0))
shell = (cyl * left*right*top)
geo.AddSurface(cyl, shell)
################
mesh = Mesh(geo.GenerateMesh(maxh=0.3))
bnd_D = mesh.Boundaries("dir")
in order to define the mesh and the boundary. I then perform the integral using e.g.
a += SymbolicBFI(InnerProduct(p*mu, v.Trace()), BND, element_boundary = True, definedon = bnd_D)
However, it seems that NGSolve skips this integral. Does anyone know what I am doing wrong?
Best regards,
Alvar
- mneunteufel
- Offline
- Premium Member
Less
More
- Thank you received: 59
4 years 6 days ago #3340
by mneunteufel
Replied by mneunteufel on topic Boundaries of open surfaces
Hi Alvar,
with
you only access boundaries labeled with "dir". But in your presented code no such label appears.
With e.g.
you can label the surface.
Best,
Michael
with
Code:
bnd_D = mesh.Boundaries("dir")
With e.g.
Code:
cyl = Cylinder(Pnt(0,0,0), Pnt(1,0,0),r).bc("dir")
Best,
Michael
- Bittermandeln
- Topic Author
- Offline
- Junior Member
Less
More
- Thank you received: 0
4 years 5 days ago #3345
by Bittermandeln
Replied by Bittermandeln on topic Boundaries of open surfaces
Hi Michael,
Thank you for your answer. I have now rewritten the code to be
r = 1/pi
cyl = Cylinder(Pnt(0,0,0), Pnt(1,0,0),r)
top = Plane(Pnt(0,0,0),Vec(0,0,-1)).bc("dir")
left = Plane(Pnt(0,0,0),Vec(-1,0,0)).bc("dir")
right =Plane(Pnt(1,0,0),Vec(1,0,0)).bc("dir")
shell = (cyl * left*right*top)
geo.AddSurface(cyl, shell)
################
ngmesh = geo.GenerateMesh(maxh=0.3)
ngmesh.SetCD2Name(1,"wall")
ngmesh.SetCD2Name(2,"wall")
ngmesh.SetCD2Name(3,"outflow")
ngmesh.SetCD2Name(4,"inflow")
mesh = Mesh(ngmesh)
bnd_D = mesh.Boundaries("inflow|outflow|wall")
with one of the boundary integrals looking like
a += SymbolicBFI(-2*InnerProduct(epsu*mu, v.Trace()), BND, element_boundary = True, definedon = bnd_D)
It still seems like the integral has no effect. Am I missing it completely? How do you do integrals on boundaries of a surfaces, i.e. with Co-dimension 2?
It is worth pointing out that v is in a SurfaceHDiv space and epsu is the symmetric gradient of such a vector. I also need to integrate vectors in SurfaceL2
Thank you for your answer. I have now rewritten the code to be
r = 1/pi
cyl = Cylinder(Pnt(0,0,0), Pnt(1,0,0),r)
top = Plane(Pnt(0,0,0),Vec(0,0,-1)).bc("dir")
left = Plane(Pnt(0,0,0),Vec(-1,0,0)).bc("dir")
right =Plane(Pnt(1,0,0),Vec(1,0,0)).bc("dir")
shell = (cyl * left*right*top)
geo.AddSurface(cyl, shell)
################
ngmesh = geo.GenerateMesh(maxh=0.3)
ngmesh.SetCD2Name(1,"wall")
ngmesh.SetCD2Name(2,"wall")
ngmesh.SetCD2Name(3,"outflow")
ngmesh.SetCD2Name(4,"inflow")
mesh = Mesh(ngmesh)
bnd_D = mesh.Boundaries("inflow|outflow|wall")
with one of the boundary integrals looking like
a += SymbolicBFI(-2*InnerProduct(epsu*mu, v.Trace()), BND, element_boundary = True, definedon = bnd_D)
It still seems like the integral has no effect. Am I missing it completely? How do you do integrals on boundaries of a surfaces, i.e. with Co-dimension 2?
It is worth pointing out that v is in a SurfaceHDiv space and epsu is the symmetric gradient of such a vector. I also need to integrate vectors in SurfaceL2
- mneunteufel
- Offline
- Premium Member
Less
More
- Thank you received: 59
4 years 5 days ago #3346
by mneunteufel
Replied by mneunteufel on topic Boundaries of open surfaces
Hi Alvar,
I somehow got confused with the boundaries and co-dimensional 2 boundaries. In NGSolve co-dimensional 2 boundaries are called BBoundaries and the surface is still a boundary.
In this tutorial you can find how to define BBoundaries without guessing the right index for SetCD2Name.
So to access only the BBoundaries the correct syntax is
But, I'm afraid that your code
won't work. I guess it will throw an exception concerning the traces. Integrating over edges in three dimensions with a SurfaceHDiv space is not well defined as there is no unique normal vector.
In this example to perform integration over a BBoundary for hyb in SurfaceHDiv the following trick has been used
to loop over all edges with the surface information at hand for the (element)normal vector and being 1 only at the BBoundary.
I hope this helps.
Best,
Michael
I somehow got confused with the boundaries and co-dimensional 2 boundaries. In NGSolve co-dimensional 2 boundaries are called BBoundaries and the surface is still a boundary.
In this tutorial you can find how to define BBoundaries without guessing the right index for SetCD2Name.
So to access only the BBoundaries the correct syntax is
Code:
bnd_D = mesh.BBoundaries("inflow|outflow|wall")
But, I'm afraid that your code
Code:
a += SymbolicBFI(-2*InnerProduct(epsu*mu, v.Trace()), BND, element_boundary = True, definedon = bnd_D)
In this example to perform integration over a BBoundary for hyb in SurfaceHDiv the following trick has been used
Code:
bfA += Variation( -IfPos(x-L+1e-6, 1, 0)*(hyb*nel)*ds(element_boundary=True) )
to loop over all edges with the surface information at hand for the (element)normal vector and being 1 only at the BBoundary.
I hope this helps.
Best,
Michael
The following user(s) said Thank You: Bittermandeln
- Bittermandeln
- Topic Author
- Offline
- Junior Member
Less
More
- Thank you received: 0
4 years 4 days ago #3360
by Bittermandeln
Replied by Bittermandeln on topic Boundaries of open surfaces
Thank you for your help.
Time to create page: 0.146 seconds