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

More complicated meshes

+1 vote

I was wondering how to build more complicated meshes, that can be broken down into elementary forms though. In my example I want to mesh a structure like so:

enter image description here

If it is possible with standard tools that would be great, but anyhow how are shapes like the dolfin from the FEniCS demos meshed?

Steffen

asked Dec 5, 2014 by Steffen Wittek FEniCS Novice (210 points)

1 Answer

+3 votes
 
Best answer

Hei Steffen!

This could easily be done with f.ex. MSHR, the default meshing env. in FEniCS. Another option is to use gmsh to mesh everything, then convert it to .xml using dolfin-convert.

Using mshr:

from dolfin import *
from mshr import *

# Create circles as Circle(Center, Radius)
circle1 = Circle(Point(0,0), 5)
circle2 = Circle(Point(-1,0), 0.2)
circle3 = Circle(Point(1,0), 0.2)
circle4 = Circle(Point(0,1), 0.2)
circle5 = Circle(Point(0,-1), 0.2)

domain = circle1 - circle2 - circle3 - circle4 - circle5
r = 150   # Resolution of mesh
mesh = generate_mesh(domain, r)

plot(mesh, interactive=True)

enter image description here

Should be quite straightforward to create your mesh! MSHR also has the possibility to control sizes of cells and so on, check its wiki and API here : https://bitbucket.org/benjamik/mshr/wiki/Home. There are a lot of possibilites!

Hope this helps!

answered Dec 5, 2014 by joakibo FEniCS User (1,140 points)
selected Dec 5, 2014 by Steffen Wittek

Hi Joakibo,

thank you very much for your reply. It definitely goes into the right direction, but is it possible to create a mesh that adapts the density? It doesn't make sense to have a very dense mesh in the outer perimeter while around the holes it definitely does. Furthermore the mesh has to be also inside the holes as I want to solve the Helmholtz Equations in the whole structure. An example for such an adaptive mesh would would be:

enter image description here

Note that they also do not mesh inside the holes. Can mshr also do that?

If you apply GMSH this could be done quite easy by manually controlling the resolution of the cells surrounding the boundary of the inner circles. I'm unsure about MSHR and how to specifically control resolution in 2D, someone with more knowledge should reply on that..

Perfect. I will use GMSH then first. Thank you a lot :).

...