CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   ParaView (http://www.cfd-online.com/Forums/paraview/)
-   -   Point data Or Cell data (http://www.cfd-online.com/Forums/paraview/125223-point-data-cell-data.html)

chenxizh October 21, 2013 21:48

Point data Or Cell data
 
Hi, I have a problem about the format of data. The problem is as follows: I have a bed as 0~Xmax, 0~Ymax, the size of grid is dx, dy. as in the SIMPLE scheme, the pressure is stored in cell center, so in order to visual the data in paraview, I do the following output
1. first do the loop to output the cell center coordinate, i*dx , i*dy,
2. then I want to output the cell center data of pressure P[i][j],
So the PROBLEM is that should I specific the type of pressure data to be CELL_DATA or POINT_DATA in Paraview?
can any one help me?
Thanks a lot!:)

The code is as follows,
Code:

// the version
    fprintf(output, "# vtk DataFile Version 2.0\n");

    // the title
    fprintf(output, "Fluid Flied\n");

    // the file format
    fprintf(output, "ASCII\n");

    // the datast structure
    fprintf(output, "DATASET STRUCTURED_GRID\n");

    // the datast dimensions
    fprintf(output, "DIMENSIONS %d %d %d\n", NX, NY, NZ); 
  // points info
    fprintf(output, "POINTS %d int\n", NX*NY*NZ);  // this is the position
    for (z=0; z<NZ; z++)
    {
        for (y=0; y<NY; y++)
        {
            for (x=0; x<NX; x++e)
            {
                fprintf(output, "%5d%5d%5d\n", x, y, z);
            }
        }
    }
   
    // the dataset attributes
    // point id
    fprintf(output, "POINT_DATA %d\n", NX*NY*NZ);  // Or This should be CELL_DATA:confused:, the number should be (nx-1)*(ny-1)*(nz-1) and start from 1
    fprintf(output, "SCALARS presuss double %d\n", 1);
    fprintf(output, "LOOKUP_TABLE default\n");

    for (z=0; z<NZ; z++)
    {
        for (y=0; y<NY; y++)
        {
            for (x=0; x<NX; x++)
            {
                fprintf(output, "%lf\n", press[z][y][x]);
            }
        }
    }


wyldckat October 26, 2013 08:20

1 Attachment(s)
Greetings chenxizh,

Let me check an example on OpenFOAM... here you go, a nice example from the "incompressible/icoFoam/cavityGrade" tutorial is inside the attachment file "cavityGrade_320.vtk.zip".

It provides the following data inside it:
  • List of points of the vertexes of the mesh.
  • List of cells, based on the list of existing vertex points.
  • List of cell types, so that it knows how many vertexes are assigned to each cell.
  • Then comes the cell data ("cellID", "p" and "U") and then point data ("p" and "U").
OpenFOAM's source code for foamToVTK is at: https://github.com/OpenFOAM/OpenFOAM...sion/foamToVTK - the entry point is in the file "foamToVTK.C".

Best regards,
Bruno

chenxizh October 27, 2013 00:07

Thanks Bruno ,
I think I find out, the openfoam output the type of grid to be unstructure, so it output the cell and its relation between points, it also ouptut both cell and point data about the variables.
In my case, I define my grid to be structured , so either cell or point data is ok ?
Quote:

Originally Posted by wyldckat (Post 459122)
Greetings chenxizh,

Let me check an example on OpenFOAM... here you go, a nice example from the "incompressible/icoFoam/cavityGrade" tutorial is inside the attachment file "cavityGrade_320.vtk.zip".

It provides the following data inside it:
  • List of points of the vertexes of the mesh.
  • List of cells, based on the list of existing vertex points.
  • List of cell types, so that it knows how many vertexes are assigned to each cell.
  • Then comes the cell data ("cellID", "p" and "U") and then point data ("p" and "U").
OpenFOAM's source code for foamToVTK is at: https://github.com/OpenFOAM/OpenFOAM...sion/foamToVTK - the entry point is in the file "foamToVTK.C".

Best regards,
Bruno


wyldckat October 27, 2013 04:26

1 Attachment(s)
If the mesh is structured, then all that is needed is the box coordinates and the resolution.
As for the data, it should be cell data, since your data is for the center of the cells.

Attached is an example that was generated with the following list of source and filters:
  • Source "Wavelet", with -3 to 3 on all axis.
    • Filter "Elevation", with the default settings. You can change the orientation of the elevation vector, to get a better notion of the order of the cell data.
      • Filter "Point Data to Cell Data", so that the elevation data would be on the center of the cells.
Then I used from the menu the "File -> Save Data" entry to save to VTK the last item on the list.

chenxizh October 28, 2013 08:44

Bruno , Thanks, I get it now.
Quote:

Originally Posted by wyldckat (Post 459208)
If the mesh is structured, then all that is needed is the box coordinates and the resolution.
As for the data, it should be cell data, since your data is for the center of the cells.

Attached is an example that was generated with the following list of source and filters:
  • Source "Wavelet", with -3 to 3 on all axis.
    • Filter "Elevation", with the default settings. You can change the orientation of the elevation vector, to get a better notion of the order of the cell data.
      • Filter "Point Data to Cell Data", so that the elevation data would be on the center of the cells.
Then I used from the menu the "File -> Save Data" entry to save to VTK the last item on the list.



All times are GMT -4. The time now is 14:32.