Interpolate values to grid function in 2D


I am given coordinates (x_i, y_j) of points in my computational domain together with the corresponding function values z_ij. I would like to interpolate the function values and assign the interpolated function to a GridFunction. For 1D domains this works fine using BSplines which return a CoefficientFunction.

Is it possible to interpolate my data using a Bspline surface which I can then assign to the GridFunction living on a 2D domain?

I tried scipy.interpolate.interp2d (scipy.interpolate.interp2d — SciPy v1.10.1 Manual), but I cannot assign the resulting interpolating function to a GridFunction.

Thank you very much in advance for your help!

Best regards,

Hi Peter,

you can use a GridFunction on a secondary finite element mesh (maybe structured) to represent your given data.

This GridFunction you can use as a coefficient in your formulation, or you can interpolate this data onto your unstructured finite element mesh.

Interpolating between different meshes obviously has some costs, but we use geometric search trees to keep the asymptotic costs low.

Hope this helps,