I'm writing my own FEM Poisson equation solver in C++ and I'm using Mathematica as a benchmark - currently it seems that my program outputs a correct solution, however I want to check whether the laplacian of the result is equal to the right-hand side. Unfortunately, the interpolation itself raises a warning "Interpolation on unstructured grids is currently only supported for InterpolationOrder->1 or InterpolationOrder->All. Order will be reduced to 1". FEM deals with mostly unstructured grids, so as a result, the order of interpolation is now 1 (piecewise linear functions). It is no surprise that when I try to compute the laplacian of the result, I get flat zero function.
For the sake of simplicty, let's use the following code
ClearAll[x, y]
c = {}; n = 10000;
For[i = 0, i <= n, i++,
p = {x -> Random[], y -> Random[]};
AppendTo[c, {x, y, Sin[5 x] Sinh[5 y] + 1/6 x^3 - 1/12 y^4} /. p];
]
The following
f = Interpolation@c;
lapf = D[f[x, y], {x, 2}] + D[f[x, y], {y, 2}];
Plot3D[lapf, {x, 0, 1}, {y, 0, 1}]
gives flat zero function, although the laplacian of Sin[5 x] Sinh[5 y] + 1/6 x^3 - 1/12 y^4
is x - y^2
. What can be done in case I have only numerical data on an unstructured grid and I need to evaluate laplacian at some point?