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

Importing and creating meshes with mshr in python

+1 vote

I have a file "mesh2d.off" with a 2D geometry I want to use as a mesh for Fenics. I was following this tutorial on how to do this, but apparently PolygonalMeshGenerator used in the tutorial does not exist anymore and I'm supposed to use mshr instead. So my question is: how do I import this .off file into Fenics now? The tutorials I found from mshr webpage didn't really touch this issue.

asked Feb 17, 2015 by Ech FEniCS Novice (570 points)

1 Answer

+2 votes

Hi!

This is really not well documented. You have, in fact, to use mshr:

from mshr import *

Firstly, you have to use the Surface3D method to import the OFF file:

domain = Surface3D("shape.off")

Then, you use the generate_mesh method:

mesh = generate_mesh(domain,10)

where 10 is the "resolution".

Cheers!

answered Mar 9, 2015 by amigoricardo FEniCS Novice (340 points)
...