← Back to team overview

dolfin team mailing list archive

Re: cylindrical mesh

 


On Aug 10, 2009, at 10:06 PM, Catherine Micek wrote:

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!

An addendum to my earlier email: the crux of the problem (which I realized after sending my email) is that there are no interior nodes in the mesh. I thought I was missing something relatively simple, but it seems that the answer to my question may be more involved than I initially thought -- sorry for the long email. (If there *do* happen to be relatively easy answers, however, I am still interested.)

Thanks!


Katy

---
Catherine (Katy) A. Micek
Graduate Assistant, U of MN Mathematics Department
http://www.math.umn.edu/~mice0012




_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev


References