How can I generate a mesh other than the built-in meshes in FEniCS 2017.2.0

11 weeks ago by
In the version 2017.2.0, I can generate a mesh of unit square by using UnitSquareMesh function. However, if I want to generate a mesh of a square with a hole in it, I could use:
domain = Rectangle(0., 0., 5., 5.) - Circle(4, 4, .25)
mesh2d = Mesh(domain, 45)​

to generate such mesh in elder versions, but these methods are no more supported in 2017.2.0. What should I do if I want to generate such mesh?

Community: FEniCS Project

1 Answer

11 weeks ago by
The following modified code runs correctly for me in the latest 2017.2 Docker container:

from dolfin import *
from mshr import *

domain = Rectangle(Point(0., 0.), Point(5., 5.)) - Circle(Point(4, 4), .25)
mesh2d = generate_mesh(domain, 45)

File("mesh2d.pvd") << mesh2d
Thank you very much. I found I had some other mistakes. Your codes work perfect.
written 11 weeks ago by 翰乔 余  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »