Plotting of 1d mesh embedded in 2d/3d shows only a straight line
Issue #543
resolved
Inspecting the coordinate array and writing the manifold line mesh to file to view in paraview shows the mesh is fine.
from dolfin import *
def create_line_mesh(vertices):
"Given list of vertex coordinate tuples, build and return a mesh of intervals."
# Get dimensions
gdim = len(vertices[0])
tdim = 1
# Automatic choice of cellname for simplices
cellname = "interval"
# Indirect error checking and determination of tdim via ufl
ufl_cell = ufl.Cell(cellname, gdim)
assert tdim == ufl_cell.topological_dimension()
# Create mesh to return
mesh = Mesh()
# Open mesh in editor
me = MeshEditor()
me.open(mesh, cellname, tdim, gdim)
# Add vertices to mesh
nv = len(vertices)
me.init_vertices(nv)
for i, v in enumerate(vertices):
me.add_vertex(i, *v)
# Add cells to mesh
me.init_cells(nv-1)
for i in range(nv-1):
c = (i, i+1)
me.add_cell(i, *c)
me.close()
return mesh
def line3d():
n = 100
us = [i/float(n-1) for i in range(n)]
vertices = [(cos(4.0*DOLFIN_PI*u),
sin(4.0*DOLFIN_PI*u),
2.0*u)
for u in us]
return create_line_mesh(vertices)
plot(line3d())
interactive()
Comments (3)
-
reporter -
- marked as minor
-
- changed status to resolved
Fixed by removal of VTK plotting.
- Log in to comment
This works with the new matplotlib backend.