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

Creating a structured rectangular mesh

+3 votes

Hi!
I'm relatively new to Fenics and I would like to genrate a strucured rectangular mesh like this:

rectangular mesh

I figuered out, that there is no easy way to create it (like UnitSquareMesh). For this reason I've created a structured rectangular mesh with GMSH. But after using "dolfin-convert test.msh test.xml", I have a mesh of topological dimension 1 ( plot(mesh) shows only a line ).

Here is my geo-file:

Point(1) = {0, 0, 0, 1.0};
Point(2) = {0, 1, 0, 1.0};
Point(3) = {1, 1, 0, 1.0};
Point(4) = {1, 0, 0, 1.0};

Line(1) = {2, 3};
Line(2) = {3, 4};
Line(3) = {4, 1};
Line(4) = {1, 2};

Line Loop(6) = {1, 2, 3, 4};

Plane Surface(7) = {6};

Transfinite Line1,3} = 10 ;
Transfinite Line{2} = 10 ;
Transfinite Line{4} = 10 ;
Transfinite Surface{7} = {2,3,4,1};

Recombine Surface {7} ; 

I guess, the problem is in the last line (Recombine Surface): after removing it, a triangular mesh is created, and I have no problems to plot it with fenics.
Is this the right trial to create a structured rectangular grid in Fenics? Or am I completely wrong? What am I doing wrong?

Thanks very much in advance!

asked Jan 16, 2015 by puffin FEniCS Novice (440 points)

1 Answer

+2 votes
 
Best answer

FEniCS does not yet support quadrilateral elements.

answered Jan 16, 2015 by chris_richardson FEniCS Expert (31,740 points)
selected Jan 19, 2015 by puffin

Thank you very much for your quick reply.
I found in the Fenics Fundamentals Visualization of structured mesh data this plot
Finite element function on a structured 2D grid: surface plot of the solution .

Isn't that a function defined on a quadrilateral mesh (created with scitools/UniformBoxGrid) ?

Of course, you can always set out your vertices in a rectangular grid, which is what RectangleMesh does. However, the cells on which the equation is solved have to be triangular. How you present the results is up to you.

...