Hello All,
please consider the following to extract DoF indices for a certain line
import dolfin as df
from itertools import chain
mesh = df.UnitSquareMesh(5, 5)
V = df.VectorFunctionSpace(mesh, "CG", 1)
u = df.interpolate(df.Expression(("x[0]", "x[1]"), degree=1), V)
LineDomain = df.CompiledSubDomain('near(x[0], x[1])')
line_function = df.MeshFunction('size_t', mesh, mesh.topology().dim() - 1, 0)
LineDomain.mark(line_function, 1)
# list of unique vertices of above line
vertices = list(set(sum((l.entities(0).tolist() for l in df.SubsetIterator(line_function, 1)), [])))
# vertex to dof map
v2d = df.vertex_to_dof_map(V)
# list comprehension with two results: dof_x, dof_y
line_dofs = list(chain.from_iterable((v2d[2 * vi], v2d[2 * vi + 1]) for vi in vertices))
# will get values of u in the order of vertices
uvec = u.vector()[:]
res = uvec[line_dofs]
How can I get the DoFs associated with the above line, if I have defined
V = df.VectorFunctionSpace(mesh, "CG", 2)
?