compute mean squared errors using two solution files with same number of cells and points

Dear ParaView Support,

I have asked before for the steps to compute MSE between two files with different number of cells and points. And the technician has kindly provided me with solution: rename filter — resample with dataset filter — python calculator.

Now, I want to compute MSE between two solution files with the same number of cells and points. Do I need “resample with dataset filter” too? Could you please advise me on the complete steps?

Thanks and looking forward to you kind reply!

No, you shouldn’t need to resample as long as the cells and points that you want to compare are directly comparable, which to me means they are in the same physical space, but to you that might mean something different. Simply use the Python Calculator and skip the rename filter and resample with dataset filter.

Hi Cory,

Thanks for your kind reply!
The two solution files with same point and cell numbers, have same output variable names too. So I think we do need a rename filter, otherwise the output name will get overwritten. And now, without using resample with dataset filter, I want to calculate MSE between solution 1’s density, which is renamed as “density1”, and solution2’s density which is still “density”. Then I apply a python calculator with the equation as shown in the screenshot, but it has error saying ""density1"is not defined.

Is this because the filter is under solution 2’s file? In this case, which calculator filter shall we use to compute MSE values between two solution files?

I don’t believe this is necessary since you are free to choose the output Array Name in the **Python Calculator••.

Before you add the Python Calculator, make sure you select the RenameArrays1 and ExtractCellsByRegion2 filters in the Pipeline Browser. Now, create the Python Calculator. Both filters will now be inputs to the Python Calculator that you can access independently like so:

np.mean(inputs[0].PointData['density'] - inputs[1].PointData['density'] ** 2)

or whatever the variables are you want to subtract. inputs[0] should be the first filter you selected, and inputs[1] should be the second. Note that the variable names here are both ‘density’ which is totally fine - since you are not using the Resample With DataSet filter, no overwriting of the original data array will occur, so no Rename Arrays filter should be needed.

Here’s a picture of an example pipeline I created:

Attached also is the statefile if you want to load it in ParaView 5.12.0 or later to see how it works.

mse.pvsm (681.7 KB)

Hi Cory,
Thanks for your reply. I followed your instructions and yes, it works to compute MSE values without using rename filter.

I have a question regarding the filter “resample with dataset”:

May I know what’s the working principle of this filter to interpolate data points. Say I use “resample with data” filter to make coarser solution to have the same number of point data as the finer solution file, will it introduce errors during the interpolation?

When computing MSE between two different mesh solution files, is there any other way rather than using “resample with dataset” filter?

Not that I know. The error you will have is whatever is introduced by the linear interpolation methods used by Resample with Dataset.