# Interpolation of expression inferred from cppyy evaluations

**URL:** <https://fenicsproject.discourse.group/t/interpolation-of-expression-inferred-from-cppyy-evaluations/14489>\
**Category:** General\
**Created:** [April 30, 2024, 9:09am UTC](https://fenicsproject.discourse.group/t/interpolation-of-expression-inferred-from-cppyy-evaluations/14489 "2024-04-30T09:09:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![federicobetti](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@federicobetti](https://fenicsproject.discourse.group/u/federicobetti)\
**Post date:** [April 30, 2024, 9:09am UTC](https://fenicsproject.discourse.group/t/interpolation-of-expression-inferred-from-cppyy-evaluations/14489/1 "2024-04-30T09:09:43Z")

</div>

Hi,

I would like to know whether it is possible to use the `interpolate` routines (or `dolfinx.fem.Expression`) when the function evaluation comes from `cppyy` bindings. Something like this wouldn’t work:

`u.interpolate(lambda x: cppyy.gbl.my_func(x))`

neither it works to define a `dolfinx.fem.Expression(...)`

---

<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:** [May 2, 2024, 6:29pm UTC](https://fenicsproject.discourse.group/t/interpolation-of-expression-inferred-from-cppyy-evaluations/14489/2 "2024-05-02T18:29:56Z")

</div>

Please give a minimal reproducible example.  
In theory the `lambda function going into `interpolate` can do whatever you want, as long as it takes in a (3, num\_points) array and returns a (num\_components\_in\_u\_function\_space, num\_points) array.
