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

Merging nodes

0 votes

Hi!

I want to make a hollow circular structured mesh. I am using the code below. How can I make the first and last edge be the same?

from dolfin import *
import numpy

Theta = 2*pi
ri = 1.0      # Inner radius
ro = 5.0      # Outer radius
nr = 10       # Divisions in r direction
nt = 50       # Divisions in theta direction
mesh = RectangleMesh(Point(ri, 0), Point(ro, 1), nr, nt, "crossed")

x = mesh.coordinates()[:,0]
y = mesh.coordinates()[:,1]
s = 1.3

def cylinder(r, s):
    return [r*numpy.cos(Theta*s),r*numpy.sin(Theta*s)]
x_circ, y_circ = cylinder(x, y)
xy_circ_coor = numpy.array([x_circ, y_circ]).transpose()
mesh.coordinates()[:] = xy_circ_coor
plot(mesh, title="hollow cylinder")
interactive()
asked Feb 7, 2016 by C. Okubo FEniCS Novice (470 points)

1 Answer

0 votes
 
Best answer

You can't modify the topology of the mesh without creating a new mesh. You can try iterating over your rectangle mesh and create new vertices and cells as you go. These can be inserted into a new mesh using MeshEditor.

answered Feb 23, 2016 by Garth N. Wells FEniCS Expert (35,930 points)
selected Feb 25, 2016 by C. Okubo

Hi Garth!

Thanks for the answer!

...