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

How to specify cell type in MeshEditor().open()?

0 votes

When I try to open a MeshEditor, using

editor.open( mesh, mesh.type(), mesh.topology().dim(), mesh.geometry().dim() )

I get the following TypeError:

in method 'MeshEditor_open', argument 3 of type 'std::string'

From inspecting the documentation, I would expect this to work. It works when I replace the second argument with "triangle" for 2d meshes. Am I missing something? If not, what's the best way of generically specifying the cell type for both 2d and 3d meshes?

asked Nov 6, 2015 by mcb FEniCS Novice (310 points)

1 Answer

+1 vote
 
Best answer

Hi, in cpp there are three versions of MeshEditor.open. On python side, the function taking 5 arguments whose signature involves CellType is ignored. You get your type error because the remaining function taking five arguments expects string. If you insist on using that signature consider

from dolfin import *

mesh0 = UnitSquareMesh(2, 2)

mesh = Mesh()
editor = MeshEditor()

gdim = mesh0.geometry().dim()
tdim = mesh0.topology().dim()
c_type = mesh0.type()
c_str = c_type.type2string(c_type.cell_type())

editor.open(mesh, c_str, tdim, gdim)
editor.close()
answered Nov 6, 2015 by MiroK FEniCS Expert (80,920 points)
selected Nov 9, 2015 by mcb
...