Skip to content

Commit d356553

Browse files
committed
Start working on IO for DistArrays
1 parent 1079387 commit d356553

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

mpi4py_fft/distarray.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,10 @@ def redistribute(self, axis=None, out=None):
322322
p1, transfer = self.get_pencil_and_transfer(axis)
323323
if out is None:
324324
out = DistArray(self.global_shape,
325-
subcomm=p1.subcomm,
326-
dtype=self.dtype,
327-
alignment=axis,
328-
rank=self.rank)
325+
subcomm=p1.subcomm,
326+
dtype=self.dtype,
327+
alignment=axis,
328+
rank=self.rank)
329329

330330
if self.rank == 0:
331331
transfer.forward(self, out)

mpi4py_fft/io/file_base.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ class FileBase(object):
88
99
Parameters
1010
----------
11-
T : PFFT
12-
Instance of a :class:`.PFFT` class.
11+
global
12+
u : Distributed array, optional
13+
Instance of :class:`.DistArray`
1314
domain : sequence, optional
1415
The spatial domain. Sequence of either
1516
@@ -18,11 +19,15 @@ class FileBase(object):
1819
- Arrays of coordinates, e.g., np.linspace(0, 2*pi, N). One
1920
array per dimension.
2021
"""
21-
def __init__(self, T, domain=None, **kw):
22+
def __init__(self, global_shape=None, u=None, rank=None, domain=None, **kw):
2223
self.f = None
2324
self.filename = None
24-
self.T = T
25-
self.domain = domain if domain is not None else ((0, 2*np.pi),)*T.dimensions()
25+
if u is not None:
26+
assert isinstance(u, DistArray)
27+
self.global_shape = global_shape if global_shape is not None else u.global_shape
28+
self.rank = rank if rank is not None else u.rank
29+
self.dimensions = len(self.global_shape[self.rank:])
30+
self.domain = domain if domain is not None else ((0, 2*np.pi),)*self.dimensions
2631

2732
def write(self, step, fields, **kw):
2833
"""Write snapshot ``step`` of ``fields`` to file

mpi4py_fft/io/h5py_file.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ class HDF5File(FileBase):
1414
h5name : str
1515
Name of hdf5 file to be created.
1616
T : PFFT
17-
Instance of a :class:`PFFT` class. Must be the same as the space
18-
used for storing with :class:`HDF5Writer.write`.
17+
Instance of a :class:`PFFT` class.
1918
domain : Sequence, optional
2019
The spatial domain. Sequence of either
2120

mpi4py_fft/io/nc_file.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ class NCFile(FileBase):
1717
ncname : str
1818
Name of netcdf file to be created
1919
T : PFFT
20-
Instance of a :class:`.PFFT` class. Must be the same as the space
21-
used for storing with :class:`NCWriter.write`
20+
Instance of a :class:`.PFFT` class.
2221
domain : Sequence
2322
The spatial domain. Sequence of either
2423

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def version():
9090
generate_extensions(fftw_libs)
9191
setup(name="mpi4py-fft",
9292
version=version(),
93-
description="mpi4py-fft -- FFT with MPI",
93+
description="mpi4py-fft -- Parallel Fast Fourier Transforms (FFTs) using MPI for Python",
9494
long_description=long_description,
9595
author="Lisandro Dalcin and Mikael Mortensen",
9696
url='https://bitbucket.org/mpi4py/mpi4py-fft',
@@ -112,5 +112,6 @@ def version():
112112
],
113113
ext_modules=get_extensions(fftw_libs),
114114
install_requires=["mpi4py", "numpy"],
115-
setup_requires=["setuptools>=18.0", "cython>=0.25"]
115+
setup_requires=["setuptools>=18.0", "cython>=0.25"],
116+
keywords=['Python', 'FFTW', 'FFT', 'DCT', 'DST', 'MPI']
116117
)

0 commit comments

Comments
 (0)