Node and Element Ids


244
views
0
5 months ago by
Hello all,

I am trying to figure out how to get the node and elements ids from the mesh. Is there any sub-function to get node IDs as an array ? And even for quadratic elements FEniCS only provides the element connectivity by vertex ids, is it possible to get the connectivity by node ids ?

Best Regards,
Community: FEniCS Project

1 Answer


3
5 months ago by
Ovais  
have you tried dofmap ?

you should read Sec 5.4 Page(123) of The Fenics Tutorial I (here)

you can get a mapping from vertex to degree of freedom (nodal values) and vice versa using following :-
v2d = vertex_to_dof_map(V)

for details on code and complete understanding read the above mentioned section in the fenics tutorial

Thanks Ovais for your comments and recommendation. I understand the structure of the mapping. However, v2d=vertex_to_dof_map(V) works only for P1 (linear) elements. For quadratic elements type;

mesh = UnitSquareMesh(1, 1)
Q = FunctionSpace(mesh, 'P', 2)
v = interpolate(Expression('x[0] + x[1]', degree=1), Q)
element = Q.element()
dofmap = Q.dofmap()
for cell in cells(mesh):
     print(element.tabulate_dof_coordinates(cell))
     print(dofmap.cell_dofs(cell.index()))

gives the output as :

[[ 0. 0. ]
[ 1. 0. ]
[ 1. 1. ]
[ 1. 0.5]
[ 0.5 0.5]
[ 0.5 0. ]]
[1 6 2 7 3 8]
[[ 0. 0. ]
[ 0. 1. ]
[ 1. 1. ]
[ 0.5 1. ]
[ 0.5 0.5]
[ 0. 0.5]]
[1 0 2 4 3 5]

the node numbering for element1 -->1 6 2 7 3 8 seems strange to me if you compare with the coordinates. It seems like nodes were created randomly orders and does not follow the counterclockwise direction.

Additionally, I am trying to undertand what is FEniCS exactly doing by defining element=Q.element(). When I compile "element" output is :

<dolfin.cpp.fem.FiniteElement; proxy of <Swig Object of type 'std::shared_ptr< dolfin::FiniteElement > *' at 0x7f6a5161cb10> >

Is there any way to print them out with a understandable way, like array etc ?

Best Regards

written 5 months ago by Christian  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »