# How to calculate grid function value at arbitrary points

**URL:** <https://bempp.discourse.group/t/how-to-calculate-grid-function-value-at-arbitrary-points/117>\
**Category:** Applications\
**Created:** [9 February 2022 07:55 UTC](https://bempp.discourse.group/t/how-to-calculate-grid-function-value-at-arbitrary-points/117 "2022-02-09T07:55:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![piman](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@piman](https://bempp.discourse.group/u/piman)\
**Post date:** [9 February 2022 07:55 UTC](https://bempp.discourse.group/t/how-to-calculate-grid-function-value-at-arbitrary-points/117/1 "2022-02-09T07:55:29Z")

</div>

Hi all,

I see `bempp.api.GridFunction.evaluate_on_element_centers()` and `bempp.api.GridFunction.evaluate_on_vertices()` functions that evaluate the grid function value at the grid element centers and at the grid vertices.

I’m wondering if it’s possible to compute the value of the grid function at arbitrary points on a surface in bempp? If not in bempp-cl, maybe this feature is available in bem++ 3.3.4?

Best regards,  
Vladimir

---

<div class="post-metadata">

**Author:** ![mscroggs](https://yyz2.discourse-cdn.com/free1/user_avatar/bempp.discourse.group/mscroggs/32/3_2.png) [@mscroggs](https://bempp.discourse.group/u/mscroggs)\
**Post date:** [8 March 2022 09:29 UTC](https://bempp.discourse.group/t/how-to-calculate-grid-function-value-at-arbitrary-points/117/2 "2022-03-08T09:29:47Z")

</div>

Hello,

You can evaluate at an arbitrary points on cells using the following code:

```python
import bempp.api

function = bempp.api.GridFunction(....)

values = function.evaluate(3, np.array([[0.1, 0.3, 0.5], [0.2, 0.1, 0.5]]))

```

This will evaluate the function at the local coordinates `(0.1, 0.2)`, `(0.3, 0.1)`, and `(0.5,0.5)` in cell `3`.

(Using this evaluate function can be a little bit fiddly, as you have to provide the local 2D coordinates in the cell you are evaluating in, as Bempp cannot evaluate a function at an arbitrary point in 3D as the grid function is only defined on the 2D boundary surface.)
