Hi,
I am working on a 3D finite element code and would like to use a
cylinder mesh. Since there is no built-in cylinder mesh, I tried
generating one from a the built-in UnitCube mesh:
# Create mesh
mesh = UnitCube(2,2,2)
# Translate origin from (0.5, 0.5, 0.5) to (0.0, 0.0)
for x in mesh.coordinates():
x[0] = x[0] - 0.5
x[1] = x[1] - 0.5
x[2] = 4.0*(x[2] - 0.5)
# Create boundary mesh
boundary = BoundaryMesh(mesh)
# Stretch to a circle
for x in boundary.coordinates():
# Circle parameters
theta = atan2(x[1],x[0])
r = 2.0
x[0] = r*cos(theta)
x[1] = r*sin(theta)
x[2] = x[2]
# Move boundary values of mesh
mesh.move(boundary)
The mesh plots in Viper fine and looks nice, but does not work
properly when I use it in code. When I look at the .xml file, some
identical vertices are numbered twice, as though they are being
interpreted as different vertices. I'm not sure what's causing
this, although it seems to be related to the dimension: when I run
similar code on the UnitSquare in 2D to generate a circle, I don't
encounter this problem
So my questions are these:
1. Is there a way to correct this code so that the mesh can be
generated without repeated vertices?
2. I have Matlab code to generate a cylinder; is there an easy way
to convert that to a form that can be used by fenics?
Any suggestions would be greatly appreciated -- thanks!