How could I export a VectorPlot3D object to VTK format?

I wish to export a vector field created by Mathematica in a VTK format to visualize in Paraview. All I have are coordinates and vectors defined at each co-ordinate.

I can't figure out how to use Export to do this. I keep getting the error message: List cannot be exported to the VTK format.

I am able to reproduce this stack exchange post which is very related but of course this involves glyphs that I don't want since I would like to visualize the flow in different ways.

Thank you!


Export to "VTK" does not handle Arrow, not even Arrow[Tube[..]]; but it can handle Tube and Cone:

$maxlen = 0.08;
$aratio = 4.;
tubeArrow[p : {p1_, p2_}, radius_: 0.05] := Module[{len, v, r},
   v = p2 - p1;
   len = 0.5 Norm[v];
   len = Min[$maxlen, len];
   v = len*Normalize[v];
   r = len/$aratio;
   {Tube[{p1, p2 - v}, 0.5 r], Cone[{p2 - v, p2}, r]}

VectorPlot3D[{x, y, z}, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}] /. 
 Arrow -> tubeArrow

enter image description here

 foo = VectorPlot3D[{x, y, z}, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}] /. 
   Arrow -> tubeArrow]
(*  "/tmp/foo.vtk"  *)


enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.