How to find the coordinates of the dofs of a cell given only an element type and the cell coordinates (i.e. without using a function space or a mesh)?
Basically, I want to do something like:
from dolfin import * import numpy as np editor = MeshEditor() mesh = Mesh() editor.open(mesh, "triangle", 2, 2) editor.init_vertices(3) editor.init_cells(1) editor.add_vertex(0, np.array([0.,0.])) editor.add_vertex(1, np.array([1.,0.])) editor.add_vertex(2, np.array([0.,1.])) editor.add_cell(0, np.arange(3).astype(np.uintp)) editor.close() V = FunctionSpace(mesh, "CG", 3) dof_coor = V.tabulate_dof_coordinates().reshape((-1,2)) cell_dofs = dof_coor[V.dofmap().cell_dofs(0),:]
without creating a mesh or a function space, given only the vertex coordinates (0,0), (0,1), (1,0) and the fact that I want the dofs of a P3 element. Is there an easy, efficient way to do this (apart from computing the dof coordinates myself), at least for continuous and discontinuous scalar Lagrange elements (of any degree)? Thanks a lot!
ffc.fiatinterface.create_element(ufl_element)) from which you can query coordinates on reference cell using FIAT's interface. For affine transformed cells (simplices) you get physical coordinates by affine transformation (matrix multiplication). For quads/hexes the transformation is tensor product.
Alternatively one can use code generated by
ffc.jit. For example
ffc.jit(ufl.FiniteElement("P", ufl.triangle, 2))
returns two integers which are pointers to instances of
ufc::dofmap. By some
ctypestrickery one should be able to get to generated
tabulate_dof_coordinateswhich does exactly what you want and its calls should within Numba loop, for example, would be fast. But that's quite tricky to make it working. (Moreover this functionality might be completely different in future FEniCS which will probably abandon UFC. That's why first FIAT solution should be preferable in most circumstances.)