# Proper coordinates for eval()-method

**URL:** <https://fenicsproject.discourse.group/t/proper-coordinates-for-eval-method/1635>\
**Category:** Uncategorized\
**Created:** [September 26, 2019, 8:00pm UTC](https://fenicsproject.discourse.group/t/proper-coordinates-for-eval-method/1635 "2019-09-26T20:00:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pflaume](https://avatars.discourse-cdn.com/v4/letter/p/58f4c7/32.png) [@pflaume](https://fenicsproject.discourse.group/u/pflaume)\
**Post date:** [September 26, 2019, 8:00pm UTC](https://fenicsproject.discourse.group/t/proper-coordinates-for-eval-method/1635/1 "2019-09-26T20:00:10Z")

</div>

Hello,

I’m fairly new to fenics and I need to evaluate a Function-object on specific points of the mesh. For example, take the [non-linear poisson example](https://fenicsproject.org/docs/dolfin/1.4.0/python/demo/documented/nonlinear-poisson/python/documentation.html) (code see there). What I would now like to do is to specify the points, at which I want to evaluate the solution, and basically get the values at that point. After reading some other posts I came with the following:

```
dkiCoordX = np.linspace(0,1, 100)
dkiCoordY = np.linspace(0,1, 100)

# basically the cartesian product of the coordinate vectors, format 10000x2
dkiGrid = np.array(np.meshgrid(dkiCoordX, dkiCoordY)).T.reshape(-1,2) 

values1 = np.ones(10000)
values2 = np.ones(10000)
u.eval(values1, dkiGrid.flatten())
u.eval(values2, mesh.coordinates().flatten())

```

Apparently, this is not what eval() is expecting from me. Though I get no errors, the only thing that happens to the _values_ vectors is that the first entry changes, everything else stays 1. I’ve also tried a lower number (5x5), but it still doesn’t work.

I would be thankful for any hints and, of course, solutions. It doens’t even have to be the eval()-method, I really just need to evaluate the solution at given points.

---

<div class="post-metadata">

**Author:** ![volkerk](https://avatars.discourse-cdn.com/v4/letter/v/9d8465/32.png) [@volkerk](https://fenicsproject.discourse.group/u/volkerk)\
**Post date:** [September 27, 2019, 8:36am UTC](https://fenicsproject.discourse.group/t/proper-coordinates-for-eval-method/1635/2 "2019-09-27T08:36:34Z")

</div>

Does

```python
value = u(Point(x,y,z))

```

work?

---

<div class="post-metadata">

**Author:** ![pflaume](https://avatars.discourse-cdn.com/v4/letter/p/58f4c7/32.png) [@pflaume](https://fenicsproject.discourse.group/u/pflaume)\
**Post date:** [September 27, 2019, 1:18pm UTC](https://fenicsproject.discourse.group/t/proper-coordinates-for-eval-method/1635/3 "2019-09-27T13:18:28Z")

</div>

I’m sorry I should’ve been more specific; it does indeed work, just as

```
value = u(x,y)

```

but I need a fast way to evaluate u at many points. I really don’t want to loop over the coordinates in plain python and evaluate u pointwise, that would just take way too much time.

---

<div class="post-metadata">

**Author:** ![volkerk](https://avatars.discourse-cdn.com/v4/letter/v/9d8465/32.png) [@volkerk](https://fenicsproject.discourse.group/u/volkerk)\
**Post date:** [September 27, 2019, 1:55pm UTC](https://fenicsproject.discourse.group/t/proper-coordinates-for-eval-method/1635/4 "2019-09-27T13:55:48Z")

</div>

There seems to be no other way:  
[https://fenicsproject.org/qa/6374/what-is-the-best-way-to-evaluate-function-in-list-coordinates/](https://fenicsproject.org/qa/6374/what-is-the-best-way-to-evaluate-function-in-list-coordinates/)

---

<div class="post-metadata">

**Author:** ![pflaume](https://avatars.discourse-cdn.com/v4/letter/p/58f4c7/32.png) [@pflaume](https://fenicsproject.discourse.group/u/pflaume)\
**Post date:** [September 28, 2019, 9:33pm UTC](https://fenicsproject.discourse.group/t/proper-coordinates-for-eval-method/1635/5 "2019-09-28T21:33:13Z")

</div>

Ah yes, I’ve already stumbled upon that post. I hoped that maybe in Fenics 2018 there would be some way. And fenicstools seems to be only offering a Python2 interface… At least that’s what I got when I tried it out, I didn’t spend that much time on it, though.

Anyway, thanks for your answers. I’ve written myself small wrapper function via loops now… But it looks like the performance bottleneck actually is not even the loop, but the evaluation process in itself. It still works surprisingly fast.
