|
[Sponsors] |
February 10, 2007, 12:38 |
Paraview Vector Field
|
#1 |
Guest
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 |
|
February 11, 2007, 09:15 |
Re: Paraview Vector Field: SOLVED
|
#2 |
Guest
Posts: n/a
|
I solved it already, and here the C function to write the correct format file for those who need it.
CODE: 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"); else{ 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); } } fclose(vect_field); return; } |
|
April 3, 2013, 07:34 |
Vector plotting via vtk-file without a "Sample rectilinear grid" data set
|
#3 |
Member
Andreas Ruopp
Join Date: Aug 2009
Location: Stuttgart / Germany
Posts: 31
Rep Power: 17 |
Hello,
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. Code:
# vtk DataFile Version 2.0 Unstructured Grid Example ASCII DATASET UNSTRUCTURED_GRID POINTS 3 float 507026.25 6558690 1000 507348.5312 6558335 1000 507662.9062 6558345.5 1000 CELLS 3 6 1 0 1 1 1 2 CELL_TYPES 3 1 1 1 POINT_DATA 3 SCALARS scalarvalue float 1 LOOKUP_TABLE default 48729.0875454011 44707.379470839 48258.346801678 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 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 http://www.vtk.org/VTK/img/file-formats.pdf ) Best regards, Andy |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[OpenFOAM.org] Paraview 5.4 in shell environment of5x - Segmentation fault (core dumped) | dslbkxd | OpenFOAM Installation | 1 | February 3, 2018 01:56 |
[OpenFOAM.org] Two different versions of ParaView with same OpenFOAM release | FJSJ | OpenFOAM Installation | 2 | July 23, 2017 06:48 |
Installing OpenFOAM and ParaView in VirtualBox(Ubuntu on Win8) | chrisb2244 | OpenFOAM Installation | 2 | August 21, 2013 14:24 |
Newbie: Install ParaView 3.81 on OF-1.6-ext/OpenSuse 11.2? | lentschi | OpenFOAM Installation | 1 | March 9, 2011 03:32 |
paraFoam reader for OpenFOAM 1.6 | smart | OpenFOAM Installation | 13 | November 16, 2009 22:41 |