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
https://ngsolve.org/docu/latest/netgen_tutorials/define_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…
https://ngsolve.org/docu/latest/netgen_tutorials/manual_mesh_generation.html
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
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.
The facedescriptor describe boundary conditions, to add another domain you just have to add elements with index 2:
Element2D(2, points)
You can name the domains with:
mesh.SetMaterial(index, name)
Indices are 1-based here.
Best
Christopher
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…
Attachment: meshQuad.py
For a 2d mesh, you need to set the boundary condition of the face descriptors accordingly:
ngmesh.Add (FaceDescriptor(bc=3))
Ah-ha, that’s the cause…I was very puzzled by this FaceDescriptor…
So, domin, domout, and surfnr flags are never used in 2D mesh, right?
domin and domout are used if you have a 2D surface mesh in 3D. In your case they are not used.