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

Too many arguments for Rectangle mesh

+3 votes

Hello, I'm new to Fenics (running it in Ubuntu 12.04 LTS) and trying various meshes from the tutorial (Section 1.4.2. in the FEniCS book). However running the code

Theta = pi/2
a, b = 1, 5.0
nr = 10 # divisions in r direction
nt = 20 # divisions in theta direction
mesh = Rectangle(a, 0, b, 1, nr, nt, "crossed")

# First make a denser mesh towards r=a
x = mesh.coordinates()[:,0]
y = mesh.coordinates()[:,1]
s = 1.3

def denser(x, y):
return [a + (b-a)*((x-a)/(b-a))**s, y]
x_bar, y_bar = denser(x, y)
xy_bar_coor = numpy.array([x_bar, y_bar]).transpose() 
mesh.coordinates()[:] = xy_bar_coor
plot(mesh, title="stretched mesh") 

def cylinder(r, s):
return [r*numpy.cos(Theta*s), r*numpy.sin(Theta*s)]
x_hat, y_hat = cylinder(x_bar, y_bar)
xy_hat_coor = numpy.array([x_hat, y_hat]).transpose() 
mesh.coordinates()[:] = xy_hat_coor
plot(mesh, title="hollow cylinder")
interactive()

results in the error message

TypeError: new_Rectangle expected 4 arguments, got 7

Could it be due to differences between my FEniCS version and the one assumed in the book? I've recently upgraded FEniCS via the package manager. How do I check the version by the way?

Thanks a lot.

Seb

asked Jul 13, 2013 by seb FEniCS Novice (190 points)

You can check the version by running dolfin-version in a terminal.

1 Answer

+7 votes
 
Best answer

The Rectangle class is used to build rectangles for use in CSG. Use the RectangleMesh class as described here.

Change

mesh = Rectangle(a, 0, b, 1, nr, nt, "crossed")

to

mesh = RectangleMesh(a, 0, b, 1, nr, nt, "crossed")

Tutorial code refers to old FEniCS 1.0.0. This bug is reported. User better should refer to demos in directory tree of his actual version of FEniCS.

answered Jul 13, 2013 by Vijay Murthy FEniCS Novice (960 points)
selected Jul 13, 2013 by Jan Blechta
...