# calculate MSE between two vtu files with diffrent mesh structures

**URL:** https://discourse.paraview.org/t/calculate-mse-between-two-vtu-files-with-diffrent-mesh-structures/13768
**Category:** ParaView Support
**Created:** [January 22, 2024, 2:30pm UTC](https://discourse.paraview.org/t/calculate-mse-between-two-vtu-files-with-diffrent-mesh-structures/13768 "2024-01-22T14:30:24Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![zj519](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/z/8797f3/32.png) [@zj519](https://discourse.paraview.org/u/zj519)
#### Post date: [January 22, 2024, 2:30pm UTC](https://discourse.paraview.org/t/calculate-mse-between-two-vtu-files-with-diffrent-mesh-structures/13768/1 "2024-01-22T14:30:24Z")

</div>

Dear ParaView Support,

I have two vtu files with 3D mesh, but with different number of cells, and different number of points. The vtu files have solution of density, pressure, and velocity. I want to compute MSE of density between the two vtu files, could you please help me how to do it?

Thanks and looking forward to your kind reply!

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [January 22, 2024, 3:11pm UTC](https://discourse.paraview.org/t/calculate-mse-between-two-vtu-files-with-diffrent-mesh-structures/13768/2 "2024-01-22T15:11:59Z")

</div>

One way to do this is to resample the datasets onto an identical mesh using the [**Resample With Dataset** filter](https://docs.paraview.org/en/latest/UsersGuide/filteringData.html#resample-with-dataset). You can sample one dataset onto the other and then do your comparison.

---

<div class="post-metadata">

### Author: ![zj519](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/z/8797f3/32.png) [@zj519](https://discourse.paraview.org/u/zj519)
#### Post date: [January 22, 2024, 4:00pm UTC](https://discourse.paraview.org/t/calculate-mse-between-two-vtu-files-with-diffrent-mesh-structures/13768/3 "2024-01-22T16:00:12Z")

</div>

Hi Cory, Thank you very much for your prompt reply!  
Say now I have two datasets, file A: lc0.04\_test4.vtu, file B. lc0.065\_test3.vtu, where file A is finer than file B mesh, so I assume I use resample with dataset on file B. and now, this is what i get (screenshot)

ResampleWithDataset1 has the same number of points and cells as file A now. Then what shall I do to compute MSE please?  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/5/54cdbabe9b8702a37e7ef42409467a261c3b4b08.png)

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [January 22, 2024, 4:35pm UTC](https://discourse.paraview.org/t/calculate-mse-between-two-vtu-files-with-diffrent-mesh-structures/13768/4 "2024-01-22T16:35:31Z")

</div>

Before resampling, you might actually need to rename one of your data arrays - it looks like **Resample With Dataset** will overwrite an array with the same name in your destination mesh. Fortunately you can use the **RenameArrays** filter to change one input’s arrays to a different name. I would rename the array on the ParaView source that serves as the “Source” dataset for the resampling operation.

Now, I assume MSE is “mean squared error”. Since this is a summation over all points/cells, I would use the [**Python Annotation** filter](https://docs.paraview.org/en/latest/ReferenceManual/annotations.html#python-annotation-filter). Set the expression to something like

`sum(var-var_resampled)`

where `var` is the data array from your destination mesh and `var_resampled` is the renamed array from the source mesh.

The result will be shown in the Render View in the upper left corner, and it will also be available in the Information tab in a string array named “Text”.

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [January 22, 2024, 4:37pm UTC](https://discourse.paraview.org/t/calculate-mse-between-two-vtu-files-with-diffrent-mesh-structures/13768/5 "2024-01-22T16:37:14Z")

</div>

By the way, a similar conversation is happening over here: [Difference between 2 Datasets](https://discourse.paraview.org/t/difference-between-2-datasets/7337)

---

<div class="post-metadata">

### Author: ![zj519](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/z/8797f3/32.png) [@zj519](https://discourse.paraview.org/u/zj519)
#### Post date: [January 22, 2024, 4:50pm UTC](https://discourse.paraview.org/t/calculate-mse-between-two-vtu-files-with-diffrent-mesh-structures/13768/6 "2024-01-22T16:50:00Z")

</div>

Hi Cory,

Thank you so much for the issue you identified. Yes, after renaming the array, I’ve successfully computed MSE.

---

<div class="post-metadata">

### Author: ![zj519](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/z/8797f3/32.png) [@zj519](https://discourse.paraview.org/u/zj519)
#### Post date: [January 22, 2024, 4:58pm UTC](https://discourse.paraview.org/t/calculate-mse-between-two-vtu-files-with-diffrent-mesh-structures/13768/7 "2024-01-22T16:58:53Z")

</div>

As a quick follow up, I’m conducting mesh study to compare the accuracy of a coarser mesh with a finer mesh. Although from visual inspection, a coarser mesh’s giving coarser results, the computed MSE is unexpectedly low.

I wonder if this is because of the interpolation between points, when I applied the “resample with dataset” filter to make the coarser mesh with fewer cells (points) to have the same number of cells (points) as the finer mesh? Is it possible to compute MSE between finer and coarser results without using resampler?
