Hello,
When I copy the local part of a distributed mesh, I notice that the cell orientations do not match those of the original mesh. The following is a code snippet that demonstrates the effect.
from dolfin import *
tdim = 2
comm = mpi_comm_world()
mpirank = MPI.rank(comm)
ny = 4
mesh = UnitSquareMesh(ny-1, ny-1)
# Copy local parts of mesh
mesh_local = Mesh(mpi_comm_self())
mesh_editor = MeshEditor()
mesh_editor.open(mesh_local, tdim, tdim)
mesh_editor.init_vertices(mesh.num_vertices())
mesh_editor.init_cells(mesh.num_cells())
used_verts = []
for ci in range(mesh.num_cells()):
c = Cell(mesh,ci)
vs = []
for v in vertices(c):
if v.index() not in used_verts:
mesh_editor.add_vertex(v.index(), v.x(0), v.x(1))
used_verts.append(v.index())
vs.append(v.index())
mesh_editor.add_cell(ci, vs[0], vs[1], vs[2])
mesh_editor.close()
for ci in range(mesh_local.num_cells()):
cg = Cell(mesh, ci)
cl = Cell(mesh_local, ci)
if mpirank == 0:
print mpirank, cg.orientation(), cl.orientation()
Is there a different way to get the local mesh while preserving the orientations? Or a way to change the orientations after copying?
Thanks,
Ben