adios4dolfinx 0.8.0.dev0__tar.gz → 0.8.1.post0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. adios4dolfinx-0.8.1.post0/PKG-INFO +208 -0
  2. adios4dolfinx-0.8.1.post0/README.md +176 -0
  3. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/pyproject.toml +2 -2
  4. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/src/adios4dolfinx/adios2_helpers.py +6 -6
  5. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/src/adios4dolfinx/checkpointing.py +84 -29
  6. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/src/adios4dolfinx/legacy_readers.py +7 -6
  7. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/src/adios4dolfinx/original_checkpoint.py +7 -4
  8. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/src/adios4dolfinx/structures.py +8 -5
  9. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/src/adios4dolfinx/utils.py +4 -2
  10. adios4dolfinx-0.8.1.post0/src/adios4dolfinx.egg-info/PKG-INFO +208 -0
  11. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/src/adios4dolfinx.egg-info/requires.txt +1 -1
  12. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/tests/test_meshtags.py +2 -1
  13. adios4dolfinx-0.8.0.dev0/PKG-INFO +0 -145
  14. adios4dolfinx-0.8.0.dev0/README.md +0 -113
  15. adios4dolfinx-0.8.0.dev0/src/adios4dolfinx.egg-info/PKG-INFO +0 -145
  16. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/LICENSE +0 -0
  17. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/setup.cfg +0 -0
  18. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/src/adios4dolfinx/__init__.py +0 -0
  19. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/src/adios4dolfinx/comm_helpers.py +0 -0
  20. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/src/adios4dolfinx/py.typed +0 -0
  21. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/src/adios4dolfinx/snapshot.py +0 -0
  22. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/src/adios4dolfinx/writers.py +0 -0
  23. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/src/adios4dolfinx.egg-info/SOURCES.txt +0 -0
  24. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/src/adios4dolfinx.egg-info/dependency_links.txt +0 -0
  25. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/src/adios4dolfinx.egg-info/top_level.txt +0 -0
  26. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/tests/test_attributes.py +0 -0
  27. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/tests/test_checkpointing.py +0 -0
  28. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/tests/test_checkpointing_vector.py +0 -0
  29. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/tests/test_legacy_readers.py +0 -0
  30. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/tests/test_mesh_writer.py +0 -0
  31. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/tests/test_numpy_vectorization.py +0 -0
  32. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/tests/test_original_checkpoint.py +0 -0
  33. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/tests/test_snapshot_checkpoint.py +0 -0
  34. {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1.post0}/tests/test_version.py +0 -0
@@ -0,0 +1,208 @@
1
+ Metadata-Version: 2.1
2
+ Name: adios4dolfinx
3
+ Version: 0.8.1.post0
4
+ Summary: Checkpointing functionality for DOLFINx meshes/functions with ADIOS2
5
+ Author-email: "Jørgen S. Dokken" <dokken@simula.no>
6
+ License: Copyright 2023 Jørgen S. Dokken
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: fenics-dolfinx>=0.8.0
17
+ Provides-Extra: test
18
+ Requires-Dist: pytest; extra == "test"
19
+ Requires-Dist: coverage; extra == "test"
20
+ Requires-Dist: ipyparallel; extra == "test"
21
+ Provides-Extra: dev
22
+ Requires-Dist: pdbpp; extra == "dev"
23
+ Requires-Dist: ipython; extra == "dev"
24
+ Requires-Dist: mypy; extra == "dev"
25
+ Requires-Dist: ruff; extra == "dev"
26
+ Provides-Extra: docs
27
+ Requires-Dist: jupyter-book; extra == "docs"
28
+ Requires-Dist: ipyparallel; extra == "docs"
29
+ Requires-Dist: ipywidgets; extra == "docs"
30
+ Provides-Extra: all
31
+ Requires-Dist: adios4dolfinx[dev,docs,test]; extra == "all"
32
+
33
+ # ADIOS4DOLFINx - A framework for checkpointing in DOLFINx
34
+
35
+ ![MIT](https://img.shields.io/github/license/jorgensd/adios4dolfinx)
36
+ [![status](https://joss.theoj.org/papers/7866cb142db8a803e32d79a109573d25/status.svg)](https://joss.theoj.org/papers/7866cb142db8a803e32d79a109573d25)
37
+ [![Anaconda-Server Badge](https://anaconda.org/conda-forge/adios4dolfinx/badges/version.svg)](https://anaconda.org/conda-forge/adios4dolfinx)
38
+
39
+ ADIOS4DOLFINx is an extension for [DOLFINx](https://github.com/FEniCS/dolfinx/) to checkpoint meshes, meshtags and functions using [ADIOS 2](https://adios2.readthedocs.io/en/latest/).
40
+
41
+ The code uses the ADIOS2 Python-wrappers to write DOLFINx objects to file, supporting N-to-M (_recoverable_) and N-to-N (_snapshot_) checkpointing.
42
+ See: [Checkpointing in DOLFINx - FEniCS 23](https://jsdokken.com/checkpointing-presentation/#/) or the examples in the [Documentation](https://jsdokken.com/adios4dolfinx/) for more information.
43
+
44
+ For scalability, the code uses [MPI Neighbourhood collectives](https://www.mpi-forum.org/docs/mpi-3.1/mpi31-report/node200.htm) for communication across processes.
45
+
46
+ ## Statement of Need
47
+
48
+ As the usage of high performance computing clusters increases, more and more large-scale, long-running simulations are deployed.
49
+ The need for storing intermediate solutions from such simulations are crucial, as the HPC system might crash, or the simulation might crash or exceed the alloted computational budget.
50
+ Having a checkpoint of related variables, such as the solutions to partial differential equations (PDEs) is therefore essential.
51
+ The `adios4dolfinx` library extends the [DOLFINx](https://github.com/FEniCS/dolfinx/) computational framework for solving PDEs with checkpointing functionality, such that immediate solutions and mesh information can be stored and re-used in another simulation.
52
+
53
+ ## Installation
54
+
55
+ Compatibility with DOLFINx:
56
+
57
+ - ADIOS4DOLFINx v0.8.1 is compatible with DOLFINx v0.8.x
58
+ - ADIOS4DOLFINx v0.7.3 is compatible with DOLFINx v0.7.x
59
+
60
+ ### Dependencies
61
+
62
+ The library depends on the Python-interface of [DOLFINx](https://github.com/) and an MPI-build of [ADIOS2](https://adios2.readthedocs.io/en/latest/setting_up/setting_up.html#as-package).
63
+ Therefore `ADIOS2` should not be install through PYPI/pip, but has to be installed through Conda, Spack or from source.
64
+
65
+ ### Docker
66
+
67
+ An MPI build of ADIOS2 is installed in the official DOLFINx containers, and thus there are no additional dependencies required to install `adios4dolfinx`
68
+ on top of DOLFINx in these images.
69
+
70
+ Create a Docker container, named for instance `dolfinx-checkpoint`.
71
+ Use the `nightly` tag to get the main branch of DOLFINx, or `stable` to get the latest stable release
72
+
73
+ ```bash
74
+ docker run -ti -v $(pwd):/root/shared -w /root/shared --name=dolfinx-checkpoint ghcr.io/fenics/dolfinx/dolfinx:nightly
75
+ ```
76
+
77
+ For the latest version compatible with nightly (with the ability to run the test suite), use
78
+
79
+ ```bash
80
+ python3 -m pip install adios4dolfinx[test]@git+https://github.com/jorgensd/adios4dolfinx@main
81
+ ```
82
+
83
+ If you are using the `stable` image, you can install `adios4dolfinx` from [PYPI](https://pypi.org/project/adios4dolfinx/) with
84
+
85
+ ```bash
86
+ python3 -m pip install adios4dolfinx[test]
87
+ ```
88
+
89
+ This docker container can be opened with
90
+
91
+ ```bash
92
+ docker container start -i dolfinx-checkpoint
93
+ ```
94
+
95
+ at a later instance
96
+
97
+ ### Conda
98
+
99
+ > [!NOTE]
100
+ > Conda supports the stable release of DOLFINx, and thus the appropriate version should be installed, see the section above for more details.
101
+
102
+ Following is a minimal recipe of how to install adios4dolfinx, given that you have conda installed on your system.
103
+
104
+ ```bash
105
+ conda create -n dolfinx-checkpoint python=3.10
106
+ conda activate dolfinx-checkpoint
107
+ conda install -c conda-forge adios4dolfinx
108
+ ```
109
+
110
+ > [!NOTE]
111
+ > Remember to download the appropriate version of `adios4dolfinx` from Github [adios4dolfinx: Releases](https://github.com/jorgensd/adios4dolfinx/releases)
112
+
113
+ To run the test suite, you should also install `ipyparallel`, `pytest` and `coverage`, which can all be installed with conda
114
+
115
+ ```bash
116
+ conda install -c conda-forge ipyparallel pytest coverage
117
+ ```
118
+
119
+ ## Functionality
120
+
121
+ ### DOLFINx
122
+
123
+ - Reading and writing meshes, using `adios4dolfinx.read/write_mesh`
124
+ - Reading and writing meshtags associated to meshes `adios4dolfinx.read/write_meshtags`
125
+ - Reading checkpoints for any element (serial and parallel, arbitrary number of functions and timesteps per file). Use `adios4dolfinx.read/write_function`.
126
+ - Writing standalone function checkpoints relating to "original meshes", i.e. meshes read from `XDMFFile`. Use `adios4dolfinx.write_function_on_input_mesh` for this.
127
+ - Store mesh partitioning and re-read the mesh with this information, avoiding calling SCOTCH, Kahip or Parmetis.
128
+
129
+ > [!IMPORTANT]
130
+ > For checkpoints written with `write_function` to be valid, you first have to store the mesh with `write_mesh` to the checkpoint file.
131
+
132
+ > [!IMPORTANT]
133
+ > A checkpoint file supports multiple functions and multiple time steps, as long as the functions are associated with the same mesh
134
+
135
+ > [!IMPORTANT]
136
+ > Only one mesh per file is allowed
137
+
138
+ ## Example Usage
139
+
140
+ The repository contains many documented examples of usage, in the `docs`-folder, including
141
+
142
+ - [Reading and writing mesh checkpoints](./docs/writing_mesh_checkpoint.py)
143
+ - [Storing mesh partitioning data](./docs/partitioned_mesh.py)
144
+ - [Writing mesh-tags to a checkpoint](./docs/meshtags.py)
145
+ - [Reading and writing function checkpoints](./docs/writing_functions_checkpoint.py)
146
+ - [Checkpoint on input mesh](./docs/original_checkpoint.py)
147
+ Further examples can be found at [ADIOS4DOLFINx examples](https://jsdokken.com/adios4dolfinx/)
148
+
149
+ ### Backwards compatibility
150
+
151
+ > [!WARNING]
152
+ > If you are using v0.7.2, you are adviced to upgrade to v0.7.3, as it contains som crucial fixes for openmpi.
153
+
154
+ ### Legacy DOLFIN
155
+
156
+ Only checkpoints for `Lagrange` or `DG` functions are supported from legacy DOLFIN
157
+
158
+ - Reading meshes from the DOLFIN HDF5File-format
159
+ - Reading checkpoints from the DOLFIN HDF5File-format (one checkpoint per file only)
160
+ - Reading checkpoints from the DOLFIN XDMFFile-format (one checkpoint per file only, and only uses the `.h5` file)
161
+
162
+ See the [API](./docs/api) for more information.
163
+
164
+ ## Testing
165
+
166
+ This library uses `pytest` for testing.
167
+ To execute the tests, one should first install the library and its dependencies, as listed above.
168
+ Then, can execute all tests by calling
169
+
170
+ ```bash
171
+ python3 -m pytest .
172
+ ```
173
+
174
+ ### Testing against data from legacy dolfin
175
+
176
+ Some tests check the capability of reading data created with the legacy version of DOLFIN.
177
+ To create this dataset, start a docker container with legacy DOLFIN, for instance:
178
+
179
+ ```bash
180
+ docker run -ti -v $(pwd):/root/shared -w /root/s
181
+ hared --rm ghcr.io/scientificcomputing/fenics:2024-02-19
182
+ ```
183
+
184
+ Then, inside this container, call
185
+
186
+ ```bash
187
+ python3 ./tests/create_legacy_data.py --output-dir=legacy
188
+ ```
189
+
190
+ ### Testing against data from older versions of ADIOS4DOLFINx
191
+
192
+ Some tests check the capability to read data generated by `adios4dolfinx<0.7.2`.
193
+ To generate data for these tests use the following commands:
194
+
195
+ ```bash
196
+ docker run -ti -v $(pwd):/root/shared -w /root/shared --rm ghcr.io/fenics/dolfinx/dolfinx:v0.7.3
197
+ ```
198
+
199
+ Then, inside the container, call
200
+
201
+ ```bash
202
+ python3 -m pip install adios4dolfinx==0.7.1
203
+ python3 ./tests/create_legacy_checkpoint.py --output-dir=legacy_checkpoint
204
+ ```
205
+
206
+ ## Long term plan
207
+
208
+ The long term plan is to get this library merged into DOLFINx (rewritten in C++ with appropriate Python-bindings).
@@ -0,0 +1,176 @@
1
+ # ADIOS4DOLFINx - A framework for checkpointing in DOLFINx
2
+
3
+ ![MIT](https://img.shields.io/github/license/jorgensd/adios4dolfinx)
4
+ [![status](https://joss.theoj.org/papers/7866cb142db8a803e32d79a109573d25/status.svg)](https://joss.theoj.org/papers/7866cb142db8a803e32d79a109573d25)
5
+ [![Anaconda-Server Badge](https://anaconda.org/conda-forge/adios4dolfinx/badges/version.svg)](https://anaconda.org/conda-forge/adios4dolfinx)
6
+
7
+ ADIOS4DOLFINx is an extension for [DOLFINx](https://github.com/FEniCS/dolfinx/) to checkpoint meshes, meshtags and functions using [ADIOS 2](https://adios2.readthedocs.io/en/latest/).
8
+
9
+ The code uses the ADIOS2 Python-wrappers to write DOLFINx objects to file, supporting N-to-M (_recoverable_) and N-to-N (_snapshot_) checkpointing.
10
+ See: [Checkpointing in DOLFINx - FEniCS 23](https://jsdokken.com/checkpointing-presentation/#/) or the examples in the [Documentation](https://jsdokken.com/adios4dolfinx/) for more information.
11
+
12
+ For scalability, the code uses [MPI Neighbourhood collectives](https://www.mpi-forum.org/docs/mpi-3.1/mpi31-report/node200.htm) for communication across processes.
13
+
14
+ ## Statement of Need
15
+
16
+ As the usage of high performance computing clusters increases, more and more large-scale, long-running simulations are deployed.
17
+ The need for storing intermediate solutions from such simulations are crucial, as the HPC system might crash, or the simulation might crash or exceed the alloted computational budget.
18
+ Having a checkpoint of related variables, such as the solutions to partial differential equations (PDEs) is therefore essential.
19
+ The `adios4dolfinx` library extends the [DOLFINx](https://github.com/FEniCS/dolfinx/) computational framework for solving PDEs with checkpointing functionality, such that immediate solutions and mesh information can be stored and re-used in another simulation.
20
+
21
+ ## Installation
22
+
23
+ Compatibility with DOLFINx:
24
+
25
+ - ADIOS4DOLFINx v0.8.1 is compatible with DOLFINx v0.8.x
26
+ - ADIOS4DOLFINx v0.7.3 is compatible with DOLFINx v0.7.x
27
+
28
+ ### Dependencies
29
+
30
+ The library depends on the Python-interface of [DOLFINx](https://github.com/) and an MPI-build of [ADIOS2](https://adios2.readthedocs.io/en/latest/setting_up/setting_up.html#as-package).
31
+ Therefore `ADIOS2` should not be install through PYPI/pip, but has to be installed through Conda, Spack or from source.
32
+
33
+ ### Docker
34
+
35
+ An MPI build of ADIOS2 is installed in the official DOLFINx containers, and thus there are no additional dependencies required to install `adios4dolfinx`
36
+ on top of DOLFINx in these images.
37
+
38
+ Create a Docker container, named for instance `dolfinx-checkpoint`.
39
+ Use the `nightly` tag to get the main branch of DOLFINx, or `stable` to get the latest stable release
40
+
41
+ ```bash
42
+ docker run -ti -v $(pwd):/root/shared -w /root/shared --name=dolfinx-checkpoint ghcr.io/fenics/dolfinx/dolfinx:nightly
43
+ ```
44
+
45
+ For the latest version compatible with nightly (with the ability to run the test suite), use
46
+
47
+ ```bash
48
+ python3 -m pip install adios4dolfinx[test]@git+https://github.com/jorgensd/adios4dolfinx@main
49
+ ```
50
+
51
+ If you are using the `stable` image, you can install `adios4dolfinx` from [PYPI](https://pypi.org/project/adios4dolfinx/) with
52
+
53
+ ```bash
54
+ python3 -m pip install adios4dolfinx[test]
55
+ ```
56
+
57
+ This docker container can be opened with
58
+
59
+ ```bash
60
+ docker container start -i dolfinx-checkpoint
61
+ ```
62
+
63
+ at a later instance
64
+
65
+ ### Conda
66
+
67
+ > [!NOTE]
68
+ > Conda supports the stable release of DOLFINx, and thus the appropriate version should be installed, see the section above for more details.
69
+
70
+ Following is a minimal recipe of how to install adios4dolfinx, given that you have conda installed on your system.
71
+
72
+ ```bash
73
+ conda create -n dolfinx-checkpoint python=3.10
74
+ conda activate dolfinx-checkpoint
75
+ conda install -c conda-forge adios4dolfinx
76
+ ```
77
+
78
+ > [!NOTE]
79
+ > Remember to download the appropriate version of `adios4dolfinx` from Github [adios4dolfinx: Releases](https://github.com/jorgensd/adios4dolfinx/releases)
80
+
81
+ To run the test suite, you should also install `ipyparallel`, `pytest` and `coverage`, which can all be installed with conda
82
+
83
+ ```bash
84
+ conda install -c conda-forge ipyparallel pytest coverage
85
+ ```
86
+
87
+ ## Functionality
88
+
89
+ ### DOLFINx
90
+
91
+ - Reading and writing meshes, using `adios4dolfinx.read/write_mesh`
92
+ - Reading and writing meshtags associated to meshes `adios4dolfinx.read/write_meshtags`
93
+ - Reading checkpoints for any element (serial and parallel, arbitrary number of functions and timesteps per file). Use `adios4dolfinx.read/write_function`.
94
+ - Writing standalone function checkpoints relating to "original meshes", i.e. meshes read from `XDMFFile`. Use `adios4dolfinx.write_function_on_input_mesh` for this.
95
+ - Store mesh partitioning and re-read the mesh with this information, avoiding calling SCOTCH, Kahip or Parmetis.
96
+
97
+ > [!IMPORTANT]
98
+ > For checkpoints written with `write_function` to be valid, you first have to store the mesh with `write_mesh` to the checkpoint file.
99
+
100
+ > [!IMPORTANT]
101
+ > A checkpoint file supports multiple functions and multiple time steps, as long as the functions are associated with the same mesh
102
+
103
+ > [!IMPORTANT]
104
+ > Only one mesh per file is allowed
105
+
106
+ ## Example Usage
107
+
108
+ The repository contains many documented examples of usage, in the `docs`-folder, including
109
+
110
+ - [Reading and writing mesh checkpoints](./docs/writing_mesh_checkpoint.py)
111
+ - [Storing mesh partitioning data](./docs/partitioned_mesh.py)
112
+ - [Writing mesh-tags to a checkpoint](./docs/meshtags.py)
113
+ - [Reading and writing function checkpoints](./docs/writing_functions_checkpoint.py)
114
+ - [Checkpoint on input mesh](./docs/original_checkpoint.py)
115
+ Further examples can be found at [ADIOS4DOLFINx examples](https://jsdokken.com/adios4dolfinx/)
116
+
117
+ ### Backwards compatibility
118
+
119
+ > [!WARNING]
120
+ > If you are using v0.7.2, you are adviced to upgrade to v0.7.3, as it contains som crucial fixes for openmpi.
121
+
122
+ ### Legacy DOLFIN
123
+
124
+ Only checkpoints for `Lagrange` or `DG` functions are supported from legacy DOLFIN
125
+
126
+ - Reading meshes from the DOLFIN HDF5File-format
127
+ - Reading checkpoints from the DOLFIN HDF5File-format (one checkpoint per file only)
128
+ - Reading checkpoints from the DOLFIN XDMFFile-format (one checkpoint per file only, and only uses the `.h5` file)
129
+
130
+ See the [API](./docs/api) for more information.
131
+
132
+ ## Testing
133
+
134
+ This library uses `pytest` for testing.
135
+ To execute the tests, one should first install the library and its dependencies, as listed above.
136
+ Then, can execute all tests by calling
137
+
138
+ ```bash
139
+ python3 -m pytest .
140
+ ```
141
+
142
+ ### Testing against data from legacy dolfin
143
+
144
+ Some tests check the capability of reading data created with the legacy version of DOLFIN.
145
+ To create this dataset, start a docker container with legacy DOLFIN, for instance:
146
+
147
+ ```bash
148
+ docker run -ti -v $(pwd):/root/shared -w /root/s
149
+ hared --rm ghcr.io/scientificcomputing/fenics:2024-02-19
150
+ ```
151
+
152
+ Then, inside this container, call
153
+
154
+ ```bash
155
+ python3 ./tests/create_legacy_data.py --output-dir=legacy
156
+ ```
157
+
158
+ ### Testing against data from older versions of ADIOS4DOLFINx
159
+
160
+ Some tests check the capability to read data generated by `adios4dolfinx<0.7.2`.
161
+ To generate data for these tests use the following commands:
162
+
163
+ ```bash
164
+ docker run -ti -v $(pwd):/root/shared -w /root/shared --rm ghcr.io/fenics/dolfinx/dolfinx:v0.7.3
165
+ ```
166
+
167
+ Then, inside the container, call
168
+
169
+ ```bash
170
+ python3 -m pip install adios4dolfinx==0.7.1
171
+ python3 ./tests/create_legacy_checkpoint.py --output-dir=legacy_checkpoint
172
+ ```
173
+
174
+ ## Long term plan
175
+
176
+ The long term plan is to get this library merged into DOLFINx (rewritten in C++ with appropriate Python-bindings).
@@ -3,12 +3,12 @@ requires = ["setuptools>=61.0.0", "wheel"]
3
3
 
4
4
  [project]
5
5
  name = "adios4dolfinx"
6
- version = "0.8.0.dev0"
6
+ version = "0.8.1.post0"
7
7
  description = "Checkpointing functionality for DOLFINx meshes/functions with ADIOS2"
8
8
  authors = [{ name = "Jørgen S. Dokken", email = "dokken@simula.no" }]
9
9
  license = { file = "LICENSE" }
10
10
  readme = "README.md"
11
- dependencies = ["fenics-dolfinx>=0.8.0.dev0"]
11
+ dependencies = ["fenics-dolfinx>=0.8.0"]
12
12
 
13
13
  [project.optional-dependencies]
14
14
  test = ["pytest", "coverage", "ipyparallel"]
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from contextlib import contextmanager
4
4
  from pathlib import Path
5
- from typing import NamedTuple
5
+ from typing import NamedTuple, Union
6
6
 
7
7
  from mpi4py import MPI
8
8
 
@@ -44,7 +44,7 @@ class AdiosFile(NamedTuple):
44
44
  @contextmanager
45
45
  def ADIOSFile(
46
46
  adios: adios2.ADIOS,
47
- filename: Path | str,
47
+ filename: Union[Path, str],
48
48
  engine: str,
49
49
  mode: adios2.Mode,
50
50
  io_name: str,
@@ -62,7 +62,7 @@ def ADIOSFile(
62
62
  def read_cell_perms(
63
63
  adios: adios2.ADIOS,
64
64
  comm: MPI.Intracomm,
65
- filename: Path | str,
65
+ filename: Union[Path, str],
66
66
  variable: str,
67
67
  num_cells_global: np.int64,
68
68
  engine: str,
@@ -126,12 +126,12 @@ def read_cell_perms(
126
126
  def read_adjacency_list(
127
127
  adios: adios2.ADIOS,
128
128
  comm: MPI.Intracomm,
129
- filename: Path | str,
129
+ filename: Union[Path, str],
130
130
  dofmap: str,
131
131
  dofmap_offsets: str,
132
132
  num_cells_global: np.int64,
133
133
  engine: str,
134
- ) -> dolfinx.cpp.graph.AdjacencyList_int64 | dolfinx.cpp.graph.AdjacencyList_int32:
134
+ ) -> Union[dolfinx.cpp.graph.AdjacencyList_int64, dolfinx.cpp.graph.AdjacencyList_int32]:
135
135
  """
136
136
  Read an adjacency-list from an ADIOS file with given communicator.
137
137
  The adjancency list is split in to a flat array (data) and its corresponding offset.
@@ -205,7 +205,7 @@ def read_adjacency_list(
205
205
 
206
206
  def read_array(
207
207
  adios: adios2.ADIOS,
208
- filename: Path | str,
208
+ filename: Union[Path, str],
209
209
  array_name: str,
210
210
  engine: str,
211
211
  comm: MPI.Intracomm,
@@ -6,6 +6,7 @@
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
+ import typing
9
10
  from pathlib import Path
10
11
 
11
12
  from mpi4py import MPI
@@ -30,13 +31,20 @@ from .comm_helpers import (
30
31
  send_dofs_and_recv_values,
31
32
  )
32
33
  from .structures import FunctionData, MeshData
33
- from .utils import compute_dofmap_pos, compute_local_range, index_owner, unroll_dofmap
34
+ from .utils import (
35
+ compute_dofmap_pos,
36
+ compute_local_range,
37
+ index_owner,
38
+ unroll_dofmap,
39
+ unroll_insert_position,
40
+ )
34
41
  from .writers import write_function as _internal_function_writer
35
42
  from .writers import write_mesh as _internal_mesh_writer
36
43
 
37
44
  adios2 = resolve_adios_scope(adios2)
38
45
 
39
46
  __all__ = [
47
+ "read_mesh_data",
40
48
  "read_mesh",
41
49
  "write_function",
42
50
  "read_function",
@@ -49,7 +57,7 @@ __all__ = [
49
57
 
50
58
 
51
59
  def write_attributes(
52
- filename: Path | str,
60
+ filename: typing.Union[Path, str],
53
61
  comm: MPI.Intracomm,
54
62
  name: str,
55
63
  attributes: dict[str, np.ndarray],
@@ -64,6 +72,7 @@ def write_attributes(
64
72
  attributes: Dictionary of attributes to write to file
65
73
  engine: ADIOS2 engine to use
66
74
  """
75
+
67
76
  adios = adios2.ADIOS(comm)
68
77
  with ADIOSFile(
69
78
  adios=adios,
@@ -82,7 +91,7 @@ def write_attributes(
82
91
 
83
92
 
84
93
  def read_attributes(
85
- filename: Path | str,
94
+ filename: typing.Union[Path, str],
86
95
  comm: MPI.Intracomm,
87
96
  name: str,
88
97
  engine: str = "BP4",
@@ -97,7 +106,6 @@ def read_attributes(
97
106
  Returns:
98
107
  The attributes
99
108
  """
100
-
101
109
  adios = adios2.ADIOS(comm)
102
110
  with ADIOSFile(
103
111
  adios=adios,
@@ -117,11 +125,11 @@ def read_attributes(
117
125
 
118
126
 
119
127
  def write_meshtags(
120
- filename: Path | str,
128
+ filename: typing.Union[Path, str],
121
129
  mesh: dolfinx.mesh.Mesh,
122
130
  meshtags: dolfinx.mesh.MeshTags,
123
131
  engine: str = "BP4",
124
- meshtag_name: str | None = None,
132
+ meshtag_name: typing.Optional[str] = None,
125
133
  ):
126
134
  """
127
135
  Write meshtags associated with input mesh to file.
@@ -196,7 +204,7 @@ def write_meshtags(
196
204
 
197
205
 
198
206
  def read_meshtags(
199
- filename: Path | str,
207
+ filename: typing.Union[Path, str],
200
208
  mesh: dolfinx.mesh.Mesh,
201
209
  meshtag_name: str,
202
210
  engine: str = "BP4",
@@ -276,8 +284,8 @@ def read_meshtags(
276
284
  adios_file.file.PerformGets()
277
285
  adios_file.file.EndStep()
278
286
 
279
- local_entities, local_values = dolfinx.cpp.io.distribute_entity_data(
280
- mesh._cpp_object, int(dim), mesh_entities, tag_values
287
+ local_entities, local_values = dolfinx.io.distribute_entity_data(
288
+ mesh, int(dim), mesh_entities.astype(np.int32), tag_values
281
289
  )
282
290
  mesh.topology.create_connectivity(dim, 0)
283
291
  mesh.topology.create_connectivity(dim, mesh.topology.dim)
@@ -293,12 +301,12 @@ def read_meshtags(
293
301
 
294
302
 
295
303
  def read_function(
296
- filename: Path | str,
304
+ filename: typing.Union[Path, str],
297
305
  u: dolfinx.fem.Function,
298
306
  engine: str = "BP4",
299
307
  time: float = 0.0,
300
308
  legacy: bool = False,
301
- name: str | None = None,
309
+ name: typing.Optional[str] = None,
302
310
  ):
303
311
  """
304
312
  Read checkpoint from file and fill it into `u`.
@@ -376,18 +384,27 @@ def read_function(
376
384
  input_perms = read_cell_perms(
377
385
  adios, comm, filename, "CellPermutations", num_cells_global, engine
378
386
  )
387
+ # Start by sorting data array by cell permutation
388
+ num_dofs_per_cell = input_dofmap.offsets[1:] - input_dofmap.offsets[:-1]
389
+ assert np.allclose(num_dofs_per_cell, num_dofs_per_cell[0])
390
+
391
+ # Sort dofmap by input local cell index
392
+ input_perms_sorted = input_perms[input_local_cell_index]
393
+ unrolled_dofmap_position = unroll_insert_position(
394
+ input_local_cell_index, num_dofs_per_cell[0]
395
+ )
396
+ dofmap_sorted_by_input = recv_array[unrolled_dofmap_position]
379
397
 
380
398
  # First invert input data to reference element then transform to current mesh
381
- for i, l_cell in enumerate(input_local_cell_index):
382
- start, end = input_dofmap.offsets[l_cell : l_cell + 2]
383
- # FIXME: Tempoary cast uint32 to integer as transformations
384
- # doesn't support uint32 with the switch to nanobind
385
- element.pre_apply_transpose_dof_transformation(
386
- recv_array[int(start) : int(end)], int(input_perms[l_cell]), bs
387
- )
388
- element.pre_apply_inverse_transpose_dof_transformation(
389
- recv_array[int(start) : int(end)], int(inc_perms[i]), bs
390
- )
399
+ element.Tt_apply(dofmap_sorted_by_input, input_perms_sorted, bs)
400
+ element.Tt_inv_apply(dofmap_sorted_by_input, inc_perms, bs)
401
+ # Compute invert permutation
402
+ inverted_perm = np.empty_like(unrolled_dofmap_position)
403
+ inverted_perm[unrolled_dofmap_position] = np.arange(
404
+ len(unrolled_dofmap_position), dtype=inverted_perm.dtype
405
+ )
406
+ recv_array = dofmap_sorted_by_input[inverted_perm]
407
+
391
408
  # ------------------Step 6----------------------------------------
392
409
  # For each dof owned by a process, find the local position in the dofmap.
393
410
  V = u.function_space
@@ -419,17 +436,17 @@ def read_function(
419
436
  u.x.scatter_forward()
420
437
 
421
438
 
422
- def read_mesh(
423
- filename: Path | str,
439
+ def read_mesh_data(
440
+ filename: typing.Union[Path, str],
424
441
  comm: MPI.Intracomm,
425
442
  engine: str = "BP4",
426
443
  ghost_mode: dolfinx.mesh.GhostMode = dolfinx.mesh.GhostMode.shared_facet,
427
444
  time: float = 0.0,
428
445
  legacy: bool = False,
429
446
  read_from_partition: bool = False,
430
- ) -> dolfinx.mesh.Mesh:
447
+ ) -> tuple[np.ndarray, np.ndarray, ufl.Mesh, typing.Callable]:
431
448
  """
432
- Read an ADIOS2 mesh into DOLFINx.
449
+ Read an ADIOS2 mesh data for use with DOLFINx.
433
450
 
434
451
  Args:
435
452
  filename: Path to input file
@@ -441,7 +458,7 @@ def read_mesh(
441
458
  legacy: If checkpoint was made prior to time-dependent mesh-writer set to True
442
459
  read_from_partition: Read mesh with partition from file
443
460
  Returns:
444
- The distributed mesh
461
+ The mesh topology, geometry, UFL domain and partition function
445
462
  """
446
463
  adios = adios2.ADIOS(comm)
447
464
 
@@ -552,7 +569,45 @@ def read_mesh(
552
569
  else:
553
570
  partitioner = dolfinx.cpp.mesh.create_cell_partitioner(ghost_mode)
554
571
 
555
- return dolfinx.mesh.create_mesh(comm, mesh_topology, mesh_geometry, domain, partitioner)
572
+ return mesh_topology, mesh_geometry, domain, partitioner
573
+
574
+
575
+ def read_mesh(
576
+ filename: typing.Union[Path, str],
577
+ comm: MPI.Intracomm,
578
+ engine: str = "BP4",
579
+ ghost_mode: dolfinx.mesh.GhostMode = dolfinx.mesh.GhostMode.shared_facet,
580
+ time: float = 0.0,
581
+ legacy: bool = False,
582
+ read_from_partition: bool = False,
583
+ ) -> dolfinx.mesh.Mesh:
584
+ """
585
+ Read an ADIOS2 mesh into DOLFINx.
586
+
587
+ Args:
588
+ filename: Path to input file
589
+ comm: The MPI communciator to distribute the mesh over
590
+ engine: ADIOS engine to use for reading (BP4, BP5 or HDF5)
591
+ ghost_mode: Ghost mode to use for mesh. If `read_from_partition`
592
+ is set to `True` this option is ignored.
593
+ time: Time stamp associated with mesh
594
+ legacy: If checkpoint was made prior to time-dependent mesh-writer set to True
595
+ read_from_partition: Read mesh with partition from file
596
+ Returns:
597
+ The distributed mesh
598
+ """
599
+ return dolfinx.mesh.create_mesh(
600
+ comm,
601
+ *read_mesh_data(
602
+ filename,
603
+ comm,
604
+ engine=engine,
605
+ ghost_mode=ghost_mode,
606
+ time=time,
607
+ legacy=legacy,
608
+ read_from_partition=read_from_partition,
609
+ ),
610
+ )
556
611
 
557
612
 
558
613
  def write_mesh(
@@ -654,12 +709,12 @@ def write_mesh(
654
709
 
655
710
 
656
711
  def write_function(
657
- filename: Path | str,
712
+ filename: typing.Union[Path, str],
658
713
  u: dolfinx.fem.Function,
659
714
  engine: str = "BP4",
660
715
  mode: adios2.Mode = adios2.Mode.Append,
661
716
  time: float = 0.0,
662
- name: str | None = None,
717
+ name: typing.Optional[str] = None,
663
718
  ):
664
719
  """
665
720
  Write function checkpoint to file.