After finding out the hard way that clone() does not work as intended for multidimensional arrays, now I write
for(int k = 0; k < Nz; k++){
for(int j = 0; j < Ny; j++){
for(int i = 0; i < Nx; i++){
grid_copy[i][j][k] = grid[i][j][k];
}
}
}
for every array. This feels so depressingly low level and anti DRY. Could anyone suggest a more general way of doing this?