Hello,
I am trying to run the example in section 1.4.2 of the fenics book to create a hollow cylinder. Here is 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")
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 [rnumpy.cos(Thetas), rnumpy.sin(Thetas)]
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()
I have already realized that 'Rectangle' needs to be changed to 'RectangleMesh'. However, I can't figure out what to do with the next error I get when I run the code:
Traceback (most recent call last):
File "/home/sophia/Documents/fenics_files/cylinder.py", line 17, in
xy_bar_coor = numpy.array([x_bar, y_bar]).transpose()
NameError: name 'numpy' is not defined
Does anyone have a version of this code that works for fenics 1.2.0?
Thank you,
Sophia