5.0

5.0 | 3 ratings Rate this file 39 Downloads (last 30 days) File Size: 678.25 KB File ID: #30011
image thumbnail

Tutorial: Put 3D Vector Field data into ParaView

by Daniel Gallichan

 

12 Jan 2011

ParaView is open-source software for 3D visualization - but getting data in is non-trivial.

| Watch this File

File Information
Description

I spent some time working out how to export data from Matlab (specifically a 3D vector field) in a way which could then successfully imported into ParaView (www.paraview.org).
I made this tutorial to summarize the method I found - which I hope others will also find useful.

Acknowledgements
This submission has inspired the following:
Matlab 3D vectors to Paraview (via binary VTK file)
MATLAB release MATLAB 7.10 (2010a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
06 Apr 2011 Marmago

I have a problem. How I can describe in matlab matrices bx, by and bz 50x50?
Please, I need to Know soon!! Thnks!!

06 Apr 2011 Leo Charleston

Thanks for the tutorial, it worked for me!

06 Apr 2011 Leo Charleston

By the way, only IBM machines produces "BigEndian" binary files, all x86 are LittleEndian.

30 Nov 2011 Paddy

Could you please show how you calculated your vector field? I calculate a field in Matlab, visualise it with e.g. quiver3 (and looks as expected), but the field looks very different (i.e. wrong) in Paraview after I export it as per your instructions. A simple example of what I am doing is below. I then read the resulting field in as per your instructions, and the resulting plots in paraview aren't correct?

Thanks alot!

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% visualise Taylor-Green vortex
clear all;

% coordinates
x = linspace(0,1,100);
y = linspace(0,1,100);
z = linspace(0,1,100);
[xx,yy,zz] = meshgrid(x,y,z);

% x,y,z components of vector field
u = sin(pi*xx).*cos(pi*yy).*cos(pi*zz);
v = -cos(pi*xx).*sin(pi*yy).*cos(pi*zz);
w = sqrt(2/3).*cos(pi*xx).*cos(pi*yy).*sin(pi*zz);

% write for paraview
V = cat(4,u,v,w);
B = permute(V,[4 1 2 3]);
fid = fopen('V.raw','w');
fwrite(fid,V,'float');
fclose(fid);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

01 Dec 2011 Daniel Gallichan

@Paddy - I would suggest you try swapping x and y. Matlab has for me a rather annoying habit of defining x as the *second* coordinate, and y as the first. To get your code to work in Paraview, you should just need to swap x and y in your meshgrid call - or use ndgrid which keeps x as the first coordinate.

01 Dec 2011 Paddy

Great, thanks Daniel - works perfectly now.

16 Dec 2011 W Thielicke

Great starting point! Thank you!

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
data export Daniel Gallichan 13 Jan 2011 08:51:56
3d visualization Daniel Gallichan 13 Jan 2011 08:51:56
vector field Daniel Gallichan 13 Jan 2011 08:51:56
paraview Daniel Gallichan 13 Jan 2011 08:51:56
graphics Daniel Gallichan 14 Jan 2011 09:34:13
3d visualization Matthew 25 Feb 2011 14:11:29
3d visualization Marmago 06 Apr 2011 04:58:40
paraview Marmago 06 Apr 2011 04:58:47
data export Marmago 06 Apr 2011 04:58:51
graphics Marmago 06 Apr 2011 04:58:52
vector field Marmago 06 Apr 2011 04:58:55

Contact us at files@mathworks.com