calculate MSE between two vtu files with diffrent mesh structures

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!

One way to do this is to resample the datasets onto an identical mesh using the Resample With Dataset filter. You can sample one dataset onto the other and then do your comparison.

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

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. 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”.

By the way, a similar conversation is happening over here: Difference between 2 Datasets

Hi Cory,

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

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?