Question on Dolfin poisson equation for source measurement on borders

the ith row of V.tabulate_dof_coordinates() relates to the ith entry of u.vector().get_local().

You can for instance use

from dolfin import *
import numpy as np

mesh = UnitSquareMesh(4, 4)

V = FunctionSpace(mesh, 'CG', 1)
u = Function(V)
u.interpolate(Expression('x[0]+ 2*x[1]', degree=1))

vertex_function = MeshFunction("size_t", mesh, 0)


class BoundaryMarker(SubDomain):
    def inside(self, x, on_boundary):
        return on_boundary


BoundaryMarker().mark(vertex_function, 1)
boundary_vertices = np.asarray(vertex_function.where_equal(1))

v_to_d = vertex_to_dof_map(V)
dofs = v_to_d[boundary_vertices]

x = V.tabulate_dof_coordinates()
for dof in dofs:
    print(x[dof], u.vector()[dof])
1 Like

Thank you, I think I have understood your code.

Just a small question : What does this mean => vertex_function.where_equal(1) ?

Thnak you.

The solution is to change this line :

v_to_d = vertex_to_dof_map(W)

into this :

v_to_d = np.array(W.dofmap().dofs())

Thank you.

It finds the indices of the vertices marked with 1.

Change this to u,c = w.split(deepcopy=True)

1 Like