# Use a computed solution as boundary value

**URL:** https://community.freefem.org/t/use-a-computed-solution-as-boundary-value/2158
**Category:** General Discussion
**Created:** [December 2, 2022, 4:18pm UTC](https://community.freefem.org/t/use-a-computed-solution-as-boundary-value/2158 "2022-12-02T16:18:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Denis](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@Denis](https://community.freefem.org/u/Denis)
#### Post date: [December 2, 2022, 4:18pm UTC](https://community.freefem.org/t/use-a-computed-solution-as-boundary-value/2158/1 "2022-12-02T16:18:44Z")

</div>

Dear all,  
I am new on FreeFem. I want to compute some shape derivatives and therefore I need to Solve first a PDE with a prescribed boundary data and then I need to capture a partial derivative of the computed solution to take it as new data on the boundary.  
I naively tried this (u1,u2) being the computed solution :  
Xh U1 = dx(u1)(x,y);  
Xh U2 = dx(u2)(x,y);  
and then  
on(body,u1=U1([x,y]),u2=U2([x,y]))  
but this does not work.  
Then this :  
Up1([x, y]) = U1(x,y);  
Up2([x, y]) = U2(x,y);  
and then  
on(body,u1=Up1([x,y]),u2=Up2([x,y]))  
This doesn’t work neither.  
I can indeed evaluate U1 and U2 at any given point of the boundary so I have tried to rebuild the new boundary data from an interpolation but I was not successful.  
Does someone know how to solve this ? I have checked the documentation and the forum but I do not find any example I can mirror.  
Thanks in advance and best,  
Denis.

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [December 2, 2022, 4:34pm UTC](https://community.freefem.org/t/use-a-computed-solution-as-boundary-value/2158/2 "2022-12-02T16:34:00Z")

</div>

Theoretical this works:  
but try :  
on(body,u1=U1,u2=U2)

---

<div class="post-metadata">

### Author: ![Denis](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@Denis](https://community.freefem.org/u/Denis)
#### Post date: [December 2, 2022, 4:57pm UTC](https://community.freefem.org/t/use-a-computed-solution-as-boundary-value/2158/3 "2022-12-02T16:57:52Z")

</div>

I restarted from scratch and it works just as I was trying or as you suggest. Probably some other thing was wrong in my code. Thanks for your quick answer !
