Find coordinates of dof

Hello everyone,

when solving a problem I’m getting an unphysical (negative) value. Following this question I’m trying to find the location of this negative degree of freedom.

min_index = np.argmin(n.vector()[:])
coords= V.tabulate_dof_coordinates()
print(coords[min_index])

However when I evaluate my function at coords[min_index] the value doesn’t match with that of np.min(n.vector()[:])

I am using DG elements in my discretization (V = df.FunctionSpace(mesh, 'DG', 1))

I’m sorry I didn’t provide a MWE but the code I’m using is quite complex.

As you have not provided how you call evaluate on this function, there is a potential pitfall:

  • A DG-1 functions has multiple dofs at the same coordinate (at vertices shared between cells). An evaluation without supplying the correct cell will give a non-unique result.
1 Like

Indeed, that was the problem, there is a discontinuity between both elements and I was evaluating it in the neighbouring cell. Should have thought of that.

Thank you.