- Thank you received: 6
How to manually generate a rectangular mesh with subdomains
- Guosheng Fu
- Topic Author
- Offline
- Elite Member
Less
More
5 years 6 months ago #1589
by Guosheng Fu
Hello, I would like to manually generate a rectangular mesh with two subdomains, one square on the left and another on the right, like the domain in this link
ngsolve.org/docu/latest/netgen_tutorials...e_2d_geometries.html
But the following link only show a manual one-domain rectangular mesh, is there an easy way to modify it to include multiple subdomains? I can't figure it out...
ngsolve.org/docu/latest/netgen_tutorials...mesh_generation.html
ngsolve.org/docu/latest/netgen_tutorials...e_2d_geometries.html
But the following link only show a manual one-domain rectangular mesh, is there an easy way to modify it to include multiple subdomains? I can't figure it out...
ngsolve.org/docu/latest/netgen_tutorials...mesh_generation.html
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
5 years 6 months ago #1590
by christopher
Replied by christopher on topic How to manually generate a rectangular mesh with subdomains
Hi. In the source code folder python/meshes.py there are some examples of structured meshes. These should be easy to modify to contain multiple subdomains.
Best Christopher
Best Christopher
- Guosheng Fu
- Topic Author
- Offline
- Elite Member
Less
More
- Thank you received: 6
5 years 6 months ago #1591
by Guosheng Fu
Replied by Guosheng Fu on topic How to manually generate a rectangular mesh with subdomains
I noticed that file.
But the only 2D mesh therein is MakeStructured2DMesh, which is a one-domain mesh. I simply don't know how to add another domain...
I tried to use
mesh.Add(FaceDescriptor(surfnr=1,domin=1,bc=1))
mesh.Add(FaceDescriptor(surfnr=2,domin=1,bc=1))
which apparently didn't workout.
But the only 2D mesh therein is MakeStructured2DMesh, which is a one-domain mesh. I simply don't know how to add another domain...
I tried to use
mesh.Add(FaceDescriptor(surfnr=1,domin=1,bc=1))
mesh.Add(FaceDescriptor(surfnr=2,domin=1,bc=1))
which apparently didn't workout.
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
5 years 6 months ago #1592
by christopher
Replied by christopher on topic How to manually generate a rectangular mesh with subdomains
The facedescriptor describe boundary conditions, to add another domain you just have to add elements with index 2:
You can name the domains with:
Indices are 1-based here.
Best
Christopher
Code:
Element2D(2, points)
Code:
mesh.SetMaterial(index, name)
Best
Christopher
- Guosheng Fu
- Topic Author
- Offline
- Elite Member
Less
More
- Thank you received: 6
5 years 6 months ago #1593
by Guosheng Fu
Replied by Guosheng Fu on topic How to manually generate a rectangular mesh with subdomains
That's exactly what I did. I am definitely missing something here.
Attached code is my implementation of a square pml domain, with four domains, inner should be in the inner rectangle, pmlx should be the left and right middle rectangles, pmly should be the top and bottom rectangles, and pmlxy should be the four corners.
But the mesh didn't have material set properly...
V1.FreeDofs() should give me 1, and V2.FreeDofs() should give me 2....
Attached code is my implementation of a square pml domain, with four domains, inner should be in the inner rectangle, pmlx should be the left and right middle rectangles, pmly should be the top and bottom rectangles, and pmlxy should be the four corners.
But the mesh didn't have material set properly...
V1.FreeDofs() should give me 1, and V2.FreeDofs() should give me 2....
Attachments:
5 years 6 months ago #1594
by matthiash
Replied by matthiash on topic How to manually generate a rectangular mesh with subdomains
For a 2d mesh, you need to set the boundary condition of the face descriptors accordingly:
Code:
ngmesh.Add (FaceDescriptor(bc=3))
Time to create page: 0.107 seconds