How to have access to all cell data?

This is only a warning and it is not necessarily a cause for concern. It is fine if you have a very small fraction of cells that are not exactly adding up to one. You can try tightening the linear equation tolerances or switching to the SMART discretization with Chi-scheme correction for the species equations to see it it helps. This may take longer to run.

Thank you Jeff! Actually I still need access to all the cell data during training to try out some machine learning projects. Is there a way to do so?

Thanks,
Jack

Can you read VTK files through your ML code? You can save each species mass fraction in the vtu files. We don’t save the sum, but you could add species together if needed in your code or by modifying vtk_out.f.

1 Like

I see. Thanks a lot Jeff! I’ll look into vtk_out.f

Hey Jeff,

Actually I have a follow up question. Could you help me with it? Thank you!

If I extract data from vtu files produced in the simulation (for example u velocity), does it give me the actual u velocity, or does it give me the pixel value?

Also could you recommend me some good resources on how to post process the vtk/vtu files produced by MFiX using python? I was so confused about the data structure.

Thanks,
Jack

VTK is a very large package and there are a few books that cover it, available for free in PDF format. See Documentation | VTK
There are also some Python-specific tutorials and examples at https://kitware.github.io/vtk-examples/site/Python/

1 Like

MFiX uses a staggered grid for velocity. Each component is stored along the face center (u is stored at the east face, v at the north face in 2D). This can be confusing because Paraview assumes all components are store at the same location. For example, if you have a wall along the east (right) boundary with no-slip wall, then u=0 (falls exactly on top of the wall) but v is not zero (half a cell away from the wall). Along a wall at the west boundary (left), then both u and v will be non-zero (u is one cell width away from the wall, v is half a cell away).

Thank you Jeff! I noticed that the vtu data are pixel values that ranges from 0 to 255. Is it possible to convert it back to original values of velocity, pressure, and etc?

I think I misunderstood your question about “pixel value”. I was trying the make the point that contrary to scalar quantities (pressure, temperature etc.) which are stored at the center of each cell, the velocity components are stores at the face centers. Now this is probably not what you are asking for. The data MFiX stores in the vtu files are usually physical quantities and are not discretized to some range of integers: Pressure is in Pascals, velocity in m/s etc. The only integers I can think of right now would be the cell indices, BC ID or the partition ID. For example, if you run the simulation in parallel with 256 cores and store the partition, it would range from 0 to 255. Maybe you are just looking at the array index, not the array value itself.

Yeah I think I was getting the cell indices information. I thought all information was stored in cells because I got no point data in my vtu, so I naively used vtk_to_numpy(data.GetCells().GetData()). How should I access the velocity information please?

Also, I thought that the cell data relies on point data. How can I have a non-empty cell data array in my vtu file while having an empty point data array?

Thanks,
Jack

Please see Saving data as .csv files - #14 by cgw

Cell data and point data are separate sets of dat. MFiX only stores cell data (one value per cell). If you want point data you need to apply a cell to point data filter. This will generate one value at each cell corner.

I see. Thanks Jeff! In that case, how does MFiX know the location information of the cells without the point data then? Does it have to apply each cell to point data filter?

Thanks,
Jack

The point coordinates are stored in the file but there is no data (i.e. field variable values) stored at those points. In the GUI, when you visualize a vtu file, you can look at the cell data or point data by changing the “style” of the plot. Point data is labeled “nodes” in the drop down. The GUI applies a “cell to point data” filter. If you visualize the vtu file in Paraview , you will need to manually apply the “cell to point data” filter if you are interested in point data.

Hi, Jeff, I think jack7z wants to ask how to know a cell data belongs to which cell. I also encounter the same problem that I obtain the velocities of all the cells, but I do not know these velocities correspond to which cell.

Hi Ahjinger,

Yes that was exactly what I was asking. I think this thread might help you.

Jack

You need to distinguish MFiX at run time (solver) and the data in the VTK files. MFiX doesn’t need to know the actual coordinates of where the data is stored during the time marching procedure. For a given cell, It needs to know data in its neighbors and the distance to the neighbors. The whole procedure is based on scalars (pressure, temperature etc.) being stored at the cell centers and velocity components being stored at face centers (staggered representation). We don’t say at x=1.2, y=2.5, z=1.7, T=325.1K, we say at cell ID=27, T=325.1K.

The purpose of the VTK is to visualize the data, not to display a table of coordinates and variables. In the VTK files, we write out the values at each cell, so you know that cell ID=52 has a temperature of T=325.1K (cell numbers are not the same in MFiX and VTK file because MFiX uses Ghost cells to apply boundary conditions). We also write the coordinates (x,y in 2D, x,y,z in 3D) of each point in the mesh (cell corners) and the connectivity, i.e. the list of points making up each cell. For example, cell 52 is made up of corner points 82, 83, 124, 127 (say 4 points in 2D). The key here is there is no data at points 82, 83, 124 and 127, there is only data at cell 52.

The cell_to_point filter will take the data in cell 52 and interpolate the data at points 82,83,124,127, but this is only accurate for scalar quantities. It is not accurate for velocity vectors because vtk doesn’t know it is a staggered representation. I think (I have never tried) you could also use the CellCenter filter to convert the cell data into point data where the point is located at the cell center. Again this is only good for scalar quantities.

Now to get the coordinates of each point in a cell, take al look at How to get IDs of points attached to the cell? - #3 by Andrei - ParaView Support - ParaView
Once you have the coordinates of the corner points, you can compute the cell center (the above post seems to indicate there is a bug in the CellCenter filter). You should also be able to compute the face centers coordinates which is where the velocity components are located.

Hi, jack7z. Thanks very much for your help!

Hi, Dr. Dietiker

Other than the field variables stored in cells, how can we access the location information of cells? Such as the lateral location and height of cell. You know, for some cases, we have to invoke these location variable of cells in UDFs. I searched relevant keywords in the source code, but it failed. Can you please tell me if we can easily access these variables and where can we get the corresponding keywords?
Thank you.

You can access the East, North and Top face locations of a scalar cell with

use cutcell, only: xg_e, yg_n, zg_t

at the top of the routine (with other “use” statements). Then if you want the location in a cell that has I,J,K indices, use XG_E(I) , YG_N(J), and ZG_T(K) .

If you need the cell center coordinate, you have to offset the face location by half the cell size (dx,dy,dz). These are in the “geometry” module:

USE geometry, only: dx,dy,dz

so the cell center would be at

xc = XG_E(I) - 0.5 * dx(I)
yc = YG_N(J) - 0.5 * dy(J)
zc = ZG_T(K) - 0.5 * dz(K)
1 Like