I wonder if someone has some experience using gmsh to generate an adapted mesh inside a Fenics script. Gmsh is more suitable for generating complicated meshes than the mesh generator provided with Fenics.
At this moment I know how to create a new mesh using gmsh and how to import it in a Fenics script, but I do not know how to refine this mesh, keeping all the physical references.
Thanks a lot for your answer!! Only a small question: this will work with a mesh generated by gmsh?
Now I use this to read a xdmf mesh generated by gmsh
mesh = Mesh()
with XDMFFile("../mesh/square_domain.xdmf") as infile:
infile.read(mesh)
#
mvc = MeshValueCollection("size_t", mesh, dim-1)
with XDMFFile("../mesh/square_boundaries.xdmf") as infile:
infile.read(mvc, 'boundaries')
boundaries = cpp.mesh.MeshFunctionSizet(mesh, mvc)
#
mvc2 = MeshValueCollection("size_t", mesh, dim)
with XDMFFile("../mesh/square_domain.xdmf") as infile:
infile.read(mvc2, 'subdomains')
domains = cpp.mesh.MeshFunctionSizet(mesh, mvc2)