- **ParaView**
(*http://www.cfd-online.com/Forums/paraview/*)

- - **Paraview Vector Field
**
(*http://www.cfd-online.com/Forums/paraview/12960-paraview-vector-field.html*)

Paraview Vector Field
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 |

Re: Paraview Vector Field: SOLVED
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; } |

Vector plotting via vtk-file without a "Sample rectilinear grid" data setHello,
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` 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 |

All times are GMT -4. The time now is 10:29. |