- Thank you received: 0
Naming mesh boundaries
4 years 2 weeks ago #3293
by rgs
Naming mesh boundaries was created by rgs
Hello!
Is there a way to name mesh boundaries? The tutorial pages show how to name boundaries for geometries created using CSGeometry, but I don't see any similar options for imported geometries or meshes.
For instance, if I import an STL file with the following script:
The function STLGeometry does not have .bc() or .Add() functions like in CSGeometry.
Another question I have is, is there a difference between the libngpy and the normal versions of the modules?
Thank you in advance!
Is there a way to name mesh boundaries? The tutorial pages show how to name boundaries for geometries created using CSGeometry, but I don't see any similar options for imported geometries or meshes.
For instance, if I import an STL file with the following script:
Code:
from netgen.stl import *
#from netgen.libngpy._stl import*
geo = STLGeometry('netgenSTL_05.stl')
geo.GenerateMesh()
The function STLGeometry does not have .bc() or .Add() functions like in CSGeometry.
Another question I have is, is there a difference between the libngpy and the normal versions of the modules?
Thank you in advance!
- mneunteufel
- Offline
- Premium Member
Less
More
- Thank you received: 59
4 years 2 weeks ago #3295
by mneunteufel
Replied by mneunteufel on topic Naming mesh boundaries
Hi,
the Netgen mesh class has the method SetBCName to name boundaries (0-based index) after you created a mesh from the geometry.
Best,
Michael
the Netgen mesh class has the method SetBCName to name boundaries (0-based index) after you created a mesh from the geometry.
Code:
from ngsolve import *
from netgen.geom2d import unit_square
mesh = Mesh(unit_square.GenerateMesh(maxh=0.1))
print("before: ", mesh.GetBoundaries())
mesh.ngmesh.SetBCName(0,"newname")
print("after : ", mesh.GetBoundaries())
Best,
Michael
The following user(s) said Thank You: rgs
4 years 2 weeks ago - 4 years 2 weeks ago #3303
by rgs
Replied by rgs on topic Naming mesh boundaries
Thank you!
I can set the boundary name for a particular boundary if I know the boundary index. Is there a way to set the names of boundaries that I do not know the indices of? I am looking for something like the bcmod argument of the Add() function in the following script:
I would also be interested to know about any other ways we can specify which boundary we want to name.
I can set the boundary name for a particular boundary if I know the boundary index. Is there a way to set the names of boundaries that I do not know the indices of? I am looking for something like the bcmod argument of the Add() function in the following script:
Code:
from netgen.csg import *
sphere=Sphere(Pnt(0,0,0),0.55).bc('FSI')
pX=Plane(Pnt(0.5,0,0),Vec(1,0,0))
nX=Plane(Pnt(-0.5,0,0),Vec(-1,0,0))
pY=Plane(Pnt(0,0.5,0),Vec(0,1,0))
nY=Plane(Pnt(0,-0.5,0),Vec(0,-1,0))
pZ=Plane(Pnt(0,0,0.5),Vec(0,0,1))
nZ=Plane(Pnt(0,0,-0.5),Vec(0,0,-1))
Geom=sphere*pX*nX*pY*nY*pZ*nZ
geo=CSGeometry()
geo.Add(Geom.mat("domain"), bcmod=[(pX,"xplus"),(nX,"xminus"),(pY,"yplus"),(nY,"yminus"),(pZ,"zplus"),(nZ,"zminus")])
I would also be interested to know about any other ways we can specify which boundary we want to name.
Last edit: 4 years 2 weeks ago by rgs.
4 years 6 days ago - 4 years 6 days ago #3347
by rgs
Replied by rgs on topic Naming mesh boundaries
I noticed that the ngsolve mesh class has a function Boundaries() which according to the Python documentation "Return(s) boundary mesh-region matching the given regex pattern" for the syntax "Boundaries(self: ngsolve.comp.Mesh, pattern: str)". Can someone please give me an example of a regular expression I can use in this function? Can this be used to find the boundary index of a surface?
Edit: I am aware that one possible regex is the name of the boundary
Thank you in advance!
Edit: I am aware that one possible regex is the name of the boundary
Thank you in advance!
Last edit: 4 years 6 days ago by rgs.
Time to create page: 0.104 seconds