|
14 | 14 | Example |
15 | 15 | ------- |
16 | 16 | >>> import numpy as np |
17 | | ->>> from pySDC.helpers.fieldsIO import Rectilinear, FieldsIO |
| 17 | +>>> from pySDC.helpers.fieldsIO import Rectilinear |
18 | 18 | >>> |
19 | 19 | >>> # Write some fields in files |
20 | | ->>> x = np.linspace(0, 1, 101) |
| 20 | +>>> x = np.linspace(0, 1, 128) |
| 21 | +>>> y = np.linspace(0, 1, 64) |
21 | 22 | >>> fOut = Rectilinear(np.float64, "file.pysdc") |
22 | | ->>> fOut.setHeader(nVar=2, coords=x) |
| 23 | +>>> fOut.setHeader(nVar=2, coords=[x, y]) |
23 | 24 | >>> fOut.initialize() |
24 | 25 | >>> times = [0, 1, 2] |
25 | | ->>> u0 = np.array([-1, 1])[:, None]*x[None, :] |
| 26 | +>>> xGrid, yGrid = np.meshgrid(x, y, indexing="ij") |
| 27 | +>>> u0 = np.array([-1, 1]).reshape((-1, 1, 1))*xGrid*yGrid |
| 28 | +>>> # u0 has shape [2, nX, nY] |
26 | 29 | >>> for t in times: |
27 | 30 | >>> fOut.addField(t, t*u0) |
28 | 31 | >>> |
29 | | ->>> # Read the file using a the generic interface |
| 32 | +>>> # Read the file using the generic interface |
| 33 | +>>> from pySDC.helpers.fieldsIO import FieldsIO |
30 | 34 | >>> fIn = FieldsIO.fromFile("file.pysdc") |
31 | 35 | >>> times = fIn.times |
32 | 36 | >>> assert len(times) == fIn.nFields |
|
36 | 40 | Notes |
37 | 41 | ----- |
38 | 42 | 🚀 :class:`Rectilinear` is compatible with a MPI-based cartesian decomposition. |
39 | | -See :class:`pySDC.tests.test_helpers.test_fieldsIO.writeFields_MPI` for an illustrative example. |
| 43 | +See :class:`pySDC.helpers.fieldsIO.writeFields_MPI` for an illustrative example. |
40 | 44 |
|
41 | 45 | Warning |
42 | 46 | ------- |
|
0 commit comments