CFD Online Logo CFD Online URL
Home > Forums > ParaView

Paraview Vector Field

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By andyru

LinkBack Thread Tools Display Modes
Old   February 10, 2007, 12:38
Default Paraview Vector Field
simone Marras
Posts: n/a
Hello, I need help: with my code I generate 2 output files with the values of the U and V component of a vector field on my computational grid. How do I view the vector field given by the twe velocity components written in the output files? What type of file do I need to write for paraview to see it? do I need 2 scalar field? one scalar file with the 2 matrix components of U and V? I tried to understand it from the User guide, but it is not clear for this purpose. Also, once I figured out how to view one vector field at time step t(n), how can I tell Paraview to subsequently open all of the files to generate a movie?

Thank you very much,

best regards

simone marras

  Reply With Quote

Old   February 11, 2007, 09:15
Default Re: Paraview Vector Field: SOLVED
simone Marras
Posts: n/a
I solved it already, and here the C function to write the correct format file for those who need it.


void PRINT_VECT_VTK(int imax, int jmax, char *vector_field_name, float **U, float **V, float *x, float *y) {

int i,j,k;

int nx,ny,nz;

float z = 0.0;

FILE *vect_field;

nx = imax;

ny = jmax;

nz = 1;

/* File grid.vtk*/

if((vect_field = fopen(vector_field_name, "w")) == NULL)

printf("The grid file could not be open\n");


fprintf(vect_field, "# vtk DataFile Version 2.0\n");

fprintf(vect_field, "Sample rectilinear grid\n");

fprintf(vect_field, "ASCII\n");

fprintf(vect_field, "DATASET RECTILINEAR_GRID\n");

fprintf(vect_field, "DIMENSIONS %d %d %d\n", nx, ny, nz);

fprintf(vect_field, "X_COORDINATES %d float\n", nx);

for(i=0; i<=nx-1; i++)

fprintf(vect_field, "%f\n", x[i]);

fprintf(vect_field, "Y_COORDINATES %d float\n", ny);

for(j=0; j<=ny-1; j++)

fprintf(vect_field, "%f\n", y[j]);

fprintf(vect_field, "Z_COORDINATES %d float\n", nz);

fprintf(vect_field, "%f\n", z);

fprintf(vect_field, "POINT_DATA %d\n", (nx)*(ny)*(nz));

fprintf(vect_field, "VECTORS vectors float\n");

for(i=0; i<=nx-1; i++)

for(j=0; j<=ny-1; j++){

fprintf(vect_field, "%f\t %f\t %f\n", U[j][i], V[j][i], 0.0);




return; }

  Reply With Quote

Old   April 3, 2013, 06:34
Default Vector plotting via vtk-file without a "Sample rectilinear grid" data set
Andreas Ruopp
Join Date: Aug 2009
Location: Stuttgart / Germany
Posts: 31
Rep Power: 9
andyru is on a distinguished road

I found this thread here, because I faced the same problem. This helped a lot. But since the code example above uses a rectilinear grid, here comes my way, if you know coordinates and vector data, but the data set consists of a unstructured grid.
This is a short example using three points, 3 scalar values and 3 different vector data sets for each point.

# vtk DataFile Version 2.0
Unstructured Grid Example
POINTS 3 float
507026.25 6558690 1000
507348.5312 6558335 1000
507662.9062 6558345.5 1000
1 0
1 1
1 2
SCALARS scalarvalue float 1
VECTORS firstDirection float
0.419849547889549 -0.9075937181013 0
0.413814690673992 -0.910361138110798 0
0.412805482528595 -0.910819210158819 0
VECTORS secondDirection float
-0.424308102831314 0.905517881585831 0
-0.470514354339469 0.882392340379557 0
-0.53338593729323 0.84587200089483 0
VECTORS thirdDirection float
0.42459451128102 -0.905383620897811 0
0.428540938206614 -0.903522365124956 0
0.459812358448163 -0.88801610065265 0
Hope this helps!

First you define the coordinates.
Second the cells are related to the coordinates.
Then you define each cell type. 1 stands for cell type only consist of one point. This is trivial.
Then comes the point data with scalar values, followed by the vector data.

Then the import in paraview is possible and all features can be used.

(Detailed information for vtk is given in )

Best regards,

hwangpo likes this.
andyru is offline   Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Paraview nice animation PyGloo ParaView 4 June 7, 2012 12:34
Newbie: Install ParaView 3.81 on OF-1.6-ext/OpenSuse 11.2? lentschi OpenFOAM Installation 1 March 9, 2011 03:32
Paraview not found fusij OpenFOAM Installation 2 January 1, 2011 21:44
Distributed ParaView and PV3FoamReader micalil OpenFOAM Paraview & paraFoam 4 July 1, 2010 05:09
paraFoam reader for OpenFOAM 1.6 smart OpenFOAM Installation 13 November 16, 2009 22:41

All times are GMT -4. The time now is 03:13.