Having information of a vector field in some discrete points in 2D space(points and vectors are both in 2D), how can one plots (approximate) divergence of the vector-field in the total space(not in discrete points)? Is there any function in Mathematica which take information of vector field in some discrete points and do that? Any example provided answer is highly appreciated.
I have found this useful link through searching which is relevant: Discrete vector_field
Trying first answer:
field[{x_, y_}] := {Sin[x y], Cos[x + y]};
randomPoints = RandomReal[{-1, 1}, {100, 2}];
discreteField = randomPoints /. p_List?(Length[#] == 2 &) :> {p, field[p]};
Graphics[discreteField /. {pt_List, v_List} :> Arrow[{pt, pt + 0.2 v}]]
VxInt = Interpolation[
discreteField /. {pt_List, {vx_, vy_}} :> {pt, vx},
InterpolationOrder -> All];
VyInt = Interpolation[
discreteField /. {pt_List, {vx_, vy_}} :> {pt, vy},
InterpolationOrder -> All];
VectorPlot[{VxInt[x, y], VyInt[x, y]}, {x, -1, 2}, {y, -1, 2}]
curl[x_, y_] = -Derivative[0, 1][VxInt][x, y] +
Derivative[1, 0][VyInt][x, y]
DensityPlot[
curl[x, y] - Curl[field[{x, y}], {x, y}] // Evaluate, {x, -1,
2}, {y, -1, 2}, PlotLegends -> Automatic, PlotRange -> All]
As it is clear from the first and the second picture, there is a rotation in point (1.5 ,0). But the last output doesn't show a high value of the curl at this point.
InterpolationFunction
is notExtrapolationFunction
. $\endgroup$