Closed fab6 closed 2 years ago
Hi, for rectilinear grids this should be easy. It's sufficient to pass an array that has dimensions (Nx - 1, Ny - 1, Nz - 1)
instead of (Nx, Ny, Nz)
. Such an array may represent the average of the values of neighbouring vertices, or whatever you want the cell values to be.
This is also briefly described in the docs.
Probably this is also a transformation that can be done in ParaView, although I have never tried it.
Hi,
thank you for the quick help! Yes, paraview is able to do this (I did not think about this) and for the dimensions it would be straight forward. I was thinking that the averaging of the data could be not so straight forward... thanks again
Here's a simple generic function you could use to do the averaging:
function point_average(u)
v = similar(u, size(u) .- 1)
for I ∈ CartesianIndices(v)
J = I + oneunit(I)
v[I] = sum(i -> u[i], I:J) / length(I:J)
end
v
end
u = rand(6, 8, 10)
ucells = point_average(u)
You may want to look at this blog post for details.
Thank you for your help! I did not see this.
Hi,
I would like to convert the available point data for a rectilineargrid to cell data for rectilineargrid. Is this possible? Maybe you have a hint how to do this!?
Thank you in advance! Fab