# Difficulty with transforming bilinear form between coordinate systems

**URL:** <https://fenicsproject.discourse.group/t/difficulty-with-transforming-bilinear-form-between-coordinate-systems/2856>\
**Category:** Uncategorized\
**Created:** [April 10, 2020, 10:50am UTC](https://fenicsproject.discourse.group/t/difficulty-with-transforming-bilinear-form-between-coordinate-systems/2856 "2020-04-10T10:50:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![moritz\_braun](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/moritz_braun/32/1028_2.png) [@moritz\_braun](https://fenicsproject.discourse.group/u/moritz_braun)\
**Post date:** [April 10, 2020, 10:50am UTC](https://fenicsproject.discourse.group/t/difficulty-with-transforming-bilinear-form-between-coordinate-systems/2856/1 "2020-04-10T10:50:56Z")

</div>

Dear All

For my reserarch i need to transform  
the bilinear form corresponding to the Laplace equation in 2D  
between two sets of coordinates i.e.  
xp,yp=F(xc,yc)  
Let J be the Jacobian for this transfomation , detJ its determinant  
and JinvT the tranpose of the inverse of J  
in fenics we would write  
a\_p = inner(grad(u), grad(v))_dxp  
In terms of xc and yc it should become  
a\_c =inner(JinvT_grad(u),JinvT\*grad(v))_detJ_dxc  
I have implemented the above but the  
solutions obtained in both coordinate system do not agree with each other.  
However, in 1D a simple example works perfectly.  
Any suggestions would be appreciated.

Regards Moritz

---

<div class="post-metadata">

**Author:** ![kamensky](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kamensky](https://fenicsproject.discourse.group/u/kamensky)\
**Post date:** [April 10, 2020, 5:59pm UTC](https://fenicsproject.discourse.group/t/difficulty-with-transforming-bilinear-form-between-coordinate-systems/2856/2 "2020-04-10T17:59:43Z")

</div>

I do these transformations a lot in my own research and have never run into problems with them. If you post an example where it’s failing, I can take a look.

---

<div class="post-metadata">

**Author:** ![moritz\_braun](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/moritz_braun/32/1028_2.png) [@moritz\_braun](https://fenicsproject.discourse.group/u/moritz_braun)\
**Post date:** [April 14, 2020, 6:44pm UTC](https://fenicsproject.discourse.group/t/difficulty-with-transforming-bilinear-form-between-coordinate-systems/2856/3 "2020-04-14T18:44:40Z")

</div>

Thanks!

In the attached zip file there are 4 python scripts.  
There are 2 scripts for the one dimensional  
laplace problem and 2 for the two dimensional laplace problem.  
the 1D problem is with the boundary condition f(0)=0 f(1)=0  
while 2D problem has the boundary condition f(x,y)=x+y.  
The 1D scripts produce the expected output  
while the 2D scripts gives a difference between the obtained and expected  
results.  
I would appreciate if you could send me one of your scripts where you  
do a similar thing which works, also indicating the exact version of fenics that  
you are using.

Regards

Moritz

---

<div class="post-metadata">

**Author:** ![moritz\_braun](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/moritz_braun/32/1028_2.png) [@moritz\_braun](https://fenicsproject.discourse.group/u/moritz_braun)\
**Post date:** [April 14, 2020, 6:48pm UTC](https://fenicsproject.discourse.group/t/difficulty-with-transforming-bilinear-form-between-coordinate-systems/2856/4 "2020-04-14T18:48:03Z")

</div>

Hi there  
I would appreciate if you could  
tell me how to attach /send a zip file!

Regards

Moritz

---

<div class="post-metadata">

**Author:** ![kamensky](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kamensky](https://fenicsproject.discourse.group/u/kamensky)\
**Post date:** [April 14, 2020, 7:09pm UTC](https://fenicsproject.discourse.group/t/difficulty-with-transforming-bilinear-form-between-coordinate-systems/2856/5 "2020-04-14T19:09:02Z")

</div>

I’m not sure how to attach files on here. Based on your description, my first debugging step would be to double check that you’re defining the boundary data f correctly. Using your earlier notation, if you want to impose boundary data f on the boundary of the mapped domain, you would need to use boundary data f\circ\mathbf{F} in your FEniCS formulation, since functions are all defined on the un-mapped domain.

The main place I personally use transformations of forms is in an open-source library I wrote to do isogeometric analysis (IGA) with FEniCS, called tIGAr. The changes of variable are all implemented in this file

> <https://github.com/david-kamensky/tIGAr/blob/master/tIGAr/calculusUtils.py>

although possibly with more generality than is needed for your specific case.

---

<div class="post-metadata">

**Author:** ![moritz\_braun](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/moritz_braun/32/1028_2.png) [@moritz\_braun](https://fenicsproject.discourse.group/u/moritz_braun)\
**Post date:** [April 15, 2020, 6:21am UTC](https://fenicsproject.discourse.group/t/difficulty-with-transforming-bilinear-form-between-coordinate-systems/2856/6 "2020-04-15T06:21:23Z")

</div>

Hi David  
If you don’t mind I will rather send you the scripts  
via email.

Regards

Moritz
