# Find coordinates of dof

**URL:** <https://fenicsproject.discourse.group/t/find-coordinates-of-dof/8921>\
**Category:** Uncategorized\
**Created:** [August 4, 2022, 4:10pm UTC](https://fenicsproject.discourse.group/t/find-coordinates-of-dof/8921 "2022-08-04T16:10:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DGarciaLahuerta](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dgarcialahuerta/32/2673_2.png) [@DGarciaLahuerta](https://fenicsproject.discourse.group/u/DGarciaLahuerta)\
**Post date:** [August 4, 2022, 4:10pm UTC](https://fenicsproject.discourse.group/t/find-coordinates-of-dof/8921/1 "2022-08-04T16:10:12Z")

</div>

Hello everyone,

when solving a problem I’m getting an unphysical (negative) value. Following [this question](https://fenicsproject.discourse.group/t/how-to-find-the-coordinate-where-a-vector-function-is-max/5754) I’m trying to find the location of this negative degree of freedom.

```auto
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.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [August 4, 2022, 4:38pm UTC](https://fenicsproject.discourse.group/t/find-coordinates-of-dof/8921/2 "2022-08-04T16:38:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DGarciaLahuerta](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dgarcialahuerta/32/2673_2.png) [@DGarciaLahuerta](https://fenicsproject.discourse.group/u/DGarciaLahuerta)\
**Post date:** [August 5, 2022, 3:03pm UTC](https://fenicsproject.discourse.group/t/find-coordinates-of-dof/8921/3 "2022-08-05T15:03:02Z")

</div>

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.
