I have a following problem: I have an uneven 2D grid of points with unknown function value. Let's take some nasty region:
region = ImplicitRegion[x^2 + y^2 - (1/2)^2 >= 0, {{x, -1, 1}, {y, -1, 1}}];
ToElementMesh
will create an approximate mesh of region:
mesh = ToElementMesh[region, "MaxBoundaryCellMeasure" -> 0.05];
We can draw mesh:
MeshRegion[mesh]
mesh consists of some black magic box, but we can find a list of coordinates:
mesh[[1]]
{{0.5,-1.11022*10^-15}, {0.497508, 0.04986}, ..., {-0.701033, -0.460366}}
The next step is to feed this list with yet unknown functional values:
values = ToExpression[Table["f" <> ToString[k], {k, Length[mesh[[1]]]}]];
FEMvalues = Table[{mesh[[1, i]], values[[i]]}, {i, Length[mesh[[1]]]}]
The result is:
{{{0.5,-1.11022*10^-15}, f1}, {{0.497508, 0.04986},f2}, ..., {{-0.701033, -0.460366},f2240}
I'm interested in approximate first and second-order derivatives in grid points. Very popular and frequently advised approach would be to use Interpolation
(Interpolation[FEMvalues]
) and then ask for derivative in some point. The error message appears: "Interpolation on unstructured grids is currently only supported for
InterpolationOrder->1 or InterpolationOrder->All. Order will be
reduced to 1.".
Of course, first order interpolation produces piecewise linear function, so no derivative exists in grid points. Is there another way to automatically express derivative in some (bulk) grid point as expression of few neigbour functional values? I'm sure Mathematica has some built-in function to do this, but I could not find anything...thanks in advance!