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

get_local_wavenumbermesh() returns a list #10

Open
natschil opened this issue May 8, 2017 · 1 comment
Open

get_local_wavenumbermesh() returns a list #10

natschil opened this issue May 8, 2017 · 1 comment

Comments

@natschil
Copy link

natschil commented May 8, 2017

I've noticed that get_local_wavenumbermesh() returns a list as opposed to a numpy array(at least for scaled=False, and using one process). Is this intentional?

@mikaem
Copy link
Member

mikaem commented May 8, 2017

Yes, this is intentional. It's sparse storage. The wavenumers in 3D are now computed first as

Ks = np.meshgrid(kx, ky, kz, indexing='ij', sparse=True)

where Ks = [Kx, Ky, Kz], and where Kx has shape (Nx, 1, 1), Ky has shape (1, Ny, 1) and Kz (1, 1, Nz). Each one may then be used as a 3D array by itself, and Numpy will take care of the rest due to broadcasting. Before returning, the arrays are broadcasted manually, though, using

K = [np.broadcast_to(k, self.complex_shape()) for k in Ks]

This does not allocate any data, though, and the storage is still for three 1D arrays, even though K[0].shape now is the same as complex_shape. You can still get the old dense array by taking numpy.array(K). Look at K[0].strides, it's really cool:-)

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

2 participants