This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Aligning Mesh to internal boundarys

+1 vote

Hello everyone,

I have the following problem: I have a rectangle domain, lets say
$$ [0,R]x[0,2*\pi] $$ resulting from some simulation in polar coordinates. I can use the standard RectangleMesh routine to get a first, regular mesh for this domain.
Additionally I have two internal boundaries, e.g. at $$r = r_1$$ and $$r = r_2.$$ These internal boundaries are always shaped like that (so very simple, just r = const), but in general the regular mesh doesn't coincide with these internal boundaries.
What is the best way to change the regular mesh, so that I will get a new mesh with some triangles stretched or moved and having the mesh aligned with the boundaries?
My current implementation is to look for the nearest vertices to the boundary and move them, so that they lie on the $$r = r_i$$ lines, but I think in special cases this can lead to a very unregular and bad mesh. The snap_boundary method didn't work. I think the reason is, that the boundaries are in the inside of the domain.

Thank you for your help :)

asked May 5, 2014 by soply FEniCS Novice (400 points)

1 Answer

+2 votes

I think you are on the right track with finding the closest vertices, but you have to move all of the nodes, i.e. to satisfy the first boundary, you find the vertices below r1 and add
r*dr/max(r1),
where dr is the maximum distance to move in the r-direction (for the closest vertices) and max(r1) is the r value for these close vertices.

The alternative is to stitch together three rectangular meshes.

I guess the general answer is to use a mesh generator with a geometry engine, such as gmesh.

answered May 6, 2014 by KristianE FEniCS Expert (12,900 points)

Hi,
yes you are right, I could avoid having bad meshes with this method. I think I will change my implementation in that way, but I hoped there was a simple method or something like that like snap_boundarys but for internal subdomains.
Is there a method in fenics for stitching together different meshes? I didn't found one, but that would make everything very easy, because I could just use 3 RectangleMeshes and use some method which merges the meshes.

Thanks for your help!

...