Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write rectilinear grid with celldata #112

Closed
fab6 opened this issue Sep 24, 2022 · 1 comment
Closed

write rectilinear grid with celldata #112

fab6 opened this issue Sep 24, 2022 · 1 comment

Comments

@fab6
Copy link

fab6 commented Sep 24, 2022

Hi,

at the moment I am writing pointData to a vtr file using something similar like this:

vtkfile = vtk_grid(fileName, x, y , z,  ascii = true)
vtkfile[string(fieldName)] = fieldPointDataValues
vtk_save(vtkfile)

where x, y, z are now the actual poinst. This works fine and the resulting vtr can be openend.

Now, I am directly reading cell data, that means xc, yc, zc are the actual cell centers and I would like to write out the data as cellData.
At the moment I am trying:

vtkfile = vtk_grid(fileName, xc, yc , zc,  ascii = true)
vtk_cell_data(vtkfile, fieldCellDataValues, string(fieldName))
vtk_save(vtkfile)

The file gets written with the corresponding CellData item, but I am not able to load the file in paraview or visit.
Do you have a hint, what I am doing wrong and how I can correct this?
Thank you in advance!
Fab

@fab6
Copy link
Author

fab6 commented Sep 24, 2022

ok, I think, I see it now, the dimension is different for writing; vtk_grid needs the point positions x,y,z but the data is the cell centered with a size decreased by one, e.g. something like:

fileName = "vtrtest"
vtk = vtk_grid(fileName, x, y , z)
fieldCellDataValues = rand((xcells[1] - 1) * (ycells[1] - 1)* (zcells[1] - 1))
vtk[string("testdata"), VTKCellData()] = fieldCellDataValues
vtk_save(vtk)

@fab6 fab6 closed this as completed Sep 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant