# Apply different solution on the same mesh

**URL:** https://community.freefem.org/t/apply-different-solution-on-the-same-mesh/1467
**Category:** General Discussion
**Created:** [February 2, 2022, 9:19am UTC](https://community.freefem.org/t/apply-different-solution-on-the-same-mesh/1467 "2022-02-02T09:19:37Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![ruffi92](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/ruffi92/32/921_2.png) [@ruffi92](https://community.freefem.org/u/ruffi92)
#### Post date: [February 2, 2022, 9:19am UTC](https://community.freefem.org/t/apply-different-solution-on-the-same-mesh/1467/1 "2022-02-02T09:19:37Z")

</div>

Hi to all,

i try to estimate the H1-seminorm error of my solution, but unfortunatly i haven’t the analytical solution.

So i calculate my solution on a very dense mesh “mesh1” (around 170k vertices) to obtain the “real” one and after calculate it on a mesh “mesh2” with the same geometry but less dense (around 2000 vertices).

Now i want to compare the value of the “real” solution and the other solution in EACH VERTICES OF THE “mesh2”.  
But seems that the program takes just the first 2000 value of the real solution, and not the ones in the same position. In detail i use this piece of code:

err = sqrt( int2d(Th2)((dx(U2\_exact) - dx(u2))^2) + int2d(Th2)((dy(U2\_exact) - dx(u2))^2) );

How can i apply my “real” solution on a mesh that have less vertices?

Thanks to everyone

---

<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: [February 3, 2022, 12:32pm UTC](https://community.freefem.org/t/apply-different-solution-on-the-same-mesh/1467/2 "2022-02-03T12:32:17Z")

</div>

let call u1 is the solution on mesh Th1, u2 is the solution on mesh Th2

You can compute

```auto
real err2 = sqrt( int2d(Th2)((dx(u1) - dx(u2))^2) + int2d(Th2)((dy(u1) - dx(u2))^2) );
real err1 = sqrt( int2d(Th1)((dx(u1) - dx(u2))^2) + int2d(Th1)((dy(u1) - dx(u2))^2) );

```

and err1 is better because the mesh Th1 is very fine.

---

<div class="post-metadata">

### Author: ![ruffi92](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/ruffi92/32/921_2.png) [@ruffi92](https://community.freefem.org/u/ruffi92)
#### Post date: [February 3, 2022, 12:56pm UTC](https://community.freefem.org/t/apply-different-solution-on-the-same-mesh/1467/3 "2022-02-03T12:56:21Z")

</div>

ok but u1 have much more element wrt u2.

when i subtract u2 from u1 in the integral basically i take the value of the solution in each vertex of the mesh and perform the subtraction “one by one”.

My question is: the algorithm takes the value of u1 calculated in the same position “(x\_vertex, y\_vertex)” of u2 or take just the first 2000 value saved inside the solution (in different position)?

---

<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: [February 3, 2022, 1:18pm UTC](https://community.freefem.org/t/apply-different-solution-on-the-same-mesh/1467/4 "2022-02-03T13:18:51Z")

</div>

when iyou subtract u2 from u1 in the integral basically to take the value at the quadrature points at the quadrature point of each triangle and this depend of the term `int2d(Th2)` or `int2d(Th1)`

---

<div class="post-metadata">

### Author: ![ruffi92](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/ruffi92/32/921_2.png) [@ruffi92](https://community.freefem.org/u/ruffi92)
#### Post date: [February 3, 2022, 1:26pm UTC](https://community.freefem.org/t/apply-different-solution-on-the-same-mesh/1467/5 "2022-02-03T13:26:53Z")

</div>

So, performing the error as you have proposed before, accepting the fact that my “real” solution is not strictly the real one but just an approximation, i obtain a reasonable estimate of the H1-seminorm?

Thanks you prof. @frederichecht

---

<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: [February 3, 2022, 1:54pm UTC](https://community.freefem.org/t/apply-different-solution-on-the-same-mesh/1467/6 "2022-02-03T13:54:12Z")

</div>

Now to be sure you can make test for a solution we a exact solution in compare both erreur.

---

<div class="post-metadata">

### Author: ![ruffi92](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/ruffi92/32/921_2.png) [@ruffi92](https://community.freefem.org/u/ruffi92)
#### Post date: [February 3, 2022, 2:37pm UTC](https://community.freefem.org/t/apply-different-solution-on-the-same-mesh/1467/7 "2022-02-03T14:37:18Z")

</div>

unfortunatly i don’t have any exact solution for checking the result… for this reason is very important that this error is acceptable

---

<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: [February 3, 2022, 3:16pm UTC](https://community.freefem.org/t/apply-different-solution-on-the-same-mesh/1467/8 "2022-02-03T15:16:42Z")

</div>

No, to understand try thy technique on same problem with a manufactured solution.

---

<div class="post-metadata">

### Author: ![ruffi92](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/ruffi92/32/921_2.png) [@ruffi92](https://community.freefem.org/u/ruffi92)
#### Post date: [February 3, 2022, 4:52pm UTC](https://community.freefem.org/t/apply-different-solution-on-the-same-mesh/1467/9 "2022-02-03T16:52:38Z")

</div>

Oh ok now i understand!

I try this method on a very simple problem (2D Poisson problem) in which i know the analitycal solution and the result are more or less the same.

So yes, this method is a good techique to estimate error when exact solution is not available.

Many thanks professor @frederichecht

---

<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: [February 4, 2022, 9:09am UTC](https://community.freefem.org/t/apply-different-solution-on-the-same-mesh/1467/10 "2022-02-04T09:09:13Z")

</div>

Ok, good think. I close this discussion.

---

<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: [February 4, 2022, 9:09am UTC](https://community.freefem.org/t/apply-different-solution-on-the-same-mesh/1467/11 "2022-02-04T09:09:19Z")

</div>


