This is my first time using FEniCS. I am trying to solve an elliptic PDE, fairly similar to the Laplace equation, on a rectangle with two holes in it. The holes are level sets of an energy function, so I am not completely in control over their geometry. For a first approximation I can use ellipses, but I would like to still use an extensible technique so that the potential can be varied flexibly. The tutorial mentions that mesh preprocessors are usually required to initialize problems with complex geometry, but I was unable to find an actual example of how to do this. Can anyone suggest a method for building the mesh?

  • 1
    $\begingroup$ Way how to do it is: use external mesh generator (this is not naturally covered in FEniCS documentation), use meshconvert (usage covered sufficiently), import mesh in DOLFIN using Mesh(filename) constructor. $\endgroup$ – Jan Blechta May 29 '13 at 10:22

Take a look at the CSG (Constructive Solid Geometry) demos in DOLFIN. You should be able to generate a rectangle with two holes with something like

mesh = Mesh(Rectangle(...) - Ellipse(...) - Ellipse(...), resolution)
| cite | improve this answer | |
  • $\begingroup$ Thanks, that will definitely help to get me off the ground. I'm not sure ellipses will be adequate overall, but it would be great to be able to get started. $\endgroup$ – Ian May 29 '13 at 13:47

If your mesh depends on solution you can do fixed-point iteration:

  • compute solution,
  • move mesh,
  • if mesh is deformed to much, create new one and project solution on it.

If you use CSG in DOLFIN, then you can handle all three steps within DOLFIN. If using external mesh generator third step requires instructing mesh generator by DOLFIN. One way to do it is:

  • prepare input for mesh generator parametrized by few floats,
  • subprocess.call mesh generator, meshconvert,
  • read in new mesh

Triangle can generate triangulations of domain with holes in 2D. meshconvert handles also facet and cell markers produced Triangle.

| cite | improve this answer | |
  • $\begingroup$ I should have clarified that the energy function is a function only of space, not of the solution. So I only need to compute the mesh once each time I solve the problem. Also, thank you for that link; I read the name of Triangle elsewhere, but was unable to find it by searching. $\endgroup$ – Ian May 29 '13 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.