Fields output incorrect dimensions
michaeljehan opened this issue · 4 comments
The computational method relies on a staggered grid, so all of these quantities "live" at different places. u sits on the vertical edges of the cells, v sits on the horizontal edges of the cells --- collectively, these are Edges{Primal}
--- and pressure sits at the center of the cells (Nodes{Primal}
). The size 78 x 78 is the number of corners of the cells (Nodes{Dual}
) in the grid. Each of the other data types is smaller in at least one dimension.
Why do you need for them to all be the same size array?
I am trying to use the u, v, and p data as input for deep learning training where x and y acts as inputs, and the u, v, and p values are the output. the u,v, and p need to correspond the x,y positions for the training to work.
You can use grid_interpolate!
for that, e.g., to force everything to live at the cell centers (where pressure already lives), then:
uc, vc = similar(p), similar(p)
grid_interpolate!(uc,vel.u)
grid_interpolate!(vc,vel.v)
Now, uc
and vc
are interpolated onto the cell centers. (I've assumed here that p
is pressure and vel
is the original velocity.)
You can get the x and y coordinates of the cell centers with the coordinates
function,
xc, yc = coordinates(p,sys.grid)
I'll give it a try, Thank you so much