adios4dolfinx 0.8.0.dev0__tar.gz → 0.8.1__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.
- adios4dolfinx-0.8.1/PKG-INFO +205 -0
- adios4dolfinx-0.8.1/README.md +173 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/pyproject.toml +2 -2
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/src/adios4dolfinx/adios2_helpers.py +6 -6
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/src/adios4dolfinx/checkpointing.py +84 -29
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/src/adios4dolfinx/legacy_readers.py +7 -6
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/src/adios4dolfinx/original_checkpoint.py +7 -4
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/src/adios4dolfinx/structures.py +8 -5
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/src/adios4dolfinx/utils.py +4 -2
- adios4dolfinx-0.8.1/src/adios4dolfinx.egg-info/PKG-INFO +205 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/src/adios4dolfinx.egg-info/requires.txt +1 -1
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/tests/test_meshtags.py +2 -1
- adios4dolfinx-0.8.0.dev0/PKG-INFO +0 -145
- adios4dolfinx-0.8.0.dev0/README.md +0 -113
- adios4dolfinx-0.8.0.dev0/src/adios4dolfinx.egg-info/PKG-INFO +0 -145
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/LICENSE +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/setup.cfg +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/src/adios4dolfinx/__init__.py +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/src/adios4dolfinx/comm_helpers.py +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/src/adios4dolfinx/py.typed +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/src/adios4dolfinx/snapshot.py +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/src/adios4dolfinx/writers.py +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/src/adios4dolfinx.egg-info/SOURCES.txt +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/src/adios4dolfinx.egg-info/dependency_links.txt +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/src/adios4dolfinx.egg-info/top_level.txt +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/tests/test_attributes.py +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/tests/test_checkpointing.py +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/tests/test_checkpointing_vector.py +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/tests/test_legacy_readers.py +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/tests/test_mesh_writer.py +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/tests/test_numpy_vectorization.py +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/tests/test_original_checkpoint.py +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/tests/test_snapshot_checkpoint.py +0 -0
- {adios4dolfinx-0.8.0.dev0 → adios4dolfinx-0.8.1}/tests/test_version.py +0 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: adios4dolfinx
|
|
3
|
+
Version: 0.8.1
|
|
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
|
+

|
|
36
|
+
[](https://joss.theoj.org/papers/7866cb142db8a803e32d79a109573d25)
|
|
37
|
+
|
|
38
|
+
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/).
|
|
39
|
+
|
|
40
|
+
The code uses the ADIOS2 Python-wrappers to write DOLFINx objects to file, supporting N-to-M (_recoverable_) and N-to-N (_snapshot_) checkpointing.
|
|
41
|
+
See: [Checkpointing in DOLFINx - FEniCS 23](https://jsdokken.com/checkpointing-presentation/#/) or the examples in the [Documentation](https://jsdokken.com/adios4dolfinx/) for more information.
|
|
42
|
+
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
## Statement of Need
|
|
46
|
+
|
|
47
|
+
As the usage of high performance computing clusters increases, more and more large-scale, long-running simulations are deployed.
|
|
48
|
+
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.
|
|
49
|
+
Having a checkpoint of related variables, such as the solutions to partial differential equations (PDEs) is therefore essential.
|
|
50
|
+
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.
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
Compatibility with DOLFINx:
|
|
55
|
+
|
|
56
|
+
- ADIOS4DOLFINx v0.7.3 is compatible with DOLFINx v0.7.x
|
|
57
|
+
- ADIOS4DOLFINx v0.8.1 is compatible with DOLFINx v0.8.x
|
|
58
|
+
|
|
59
|
+
### Dependencies
|
|
60
|
+
|
|
61
|
+
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) and can therefore not be installed through PyPi, but has to be installed through Conda, Spack or from source.
|
|
62
|
+
|
|
63
|
+
### Docker
|
|
64
|
+
|
|
65
|
+
An MPI build of ADIOS2 is installed in the official DOLFINx containers, and thus there are no additional dependencies required to install `adios4dolfinx`
|
|
66
|
+
on top of DOLFINx in these images.
|
|
67
|
+
|
|
68
|
+
Create a Docker container, named for instance `dolfinx-checkpoint`.
|
|
69
|
+
Use the `nightly` tag to get the main branch of DOLFINx, or `stable` to get the latest stable release
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
docker run -ti -v $(pwd):/root/shared -w /root/shared --name=dolfinx-checkpoint ghcr.io/fenics/dolfinx/dolfinx:nightly
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
For the latest version compatible with nightly (with the ability to run the test suite), use
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
python3 -m pip install adios4dolfinx[test]@git+https://github.com/jorgensd/adios4dolfinx@main
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
If you are using the `stable` image, you can install `adios4dolfinx` from [PYPI](https://pypi.org/project/adios4dolfinx/) with
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
python3 -m pip install adios4dolfinx[test]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This docker container can be opened with
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
docker container start -i dolfinx-checkpoint
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
at a later instance
|
|
94
|
+
|
|
95
|
+
### Conda
|
|
96
|
+
|
|
97
|
+
> [!NOTE]
|
|
98
|
+
> Conda supports the stable release of DOLFINx, and thus the appropriate version should be installed, see the section above for more details.
|
|
99
|
+
|
|
100
|
+
Following is a minimal recipe of how to install adios4dolfinx, given that you have conda installed on your system.
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
conda create -n dolfinx-checkpoint python=3.10
|
|
104
|
+
conda activate dolfinx-checkpoint
|
|
105
|
+
conda install -c conda-forge fenics-dolfinx pip adios2=*=mpi_*
|
|
106
|
+
python3 -m pip install adios4dolfinx[test]@git+https://github.com/jorgensd/adios4dolfinx@v0.8.1
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
> [!NOTE]
|
|
110
|
+
> To run the tests or demos associated with the code, install `ipyparallel` in your environment, for instance by calling
|
|
111
|
+
>
|
|
112
|
+
> ```bash
|
|
113
|
+
> python3 -m pip install adios4dolfinx[test]@git+https://github.com/jorgensd/adios4dolfinx@v0.8.1
|
|
114
|
+
> ```
|
|
115
|
+
|
|
116
|
+
## Functionality
|
|
117
|
+
|
|
118
|
+
### DOLFINx
|
|
119
|
+
|
|
120
|
+
- Reading and writing meshes, using `adios4dolfinx.read/write_mesh`
|
|
121
|
+
- Reading and writing meshtags associated to meshes `adios4dolfinx.read/write_meshtags`
|
|
122
|
+
- Reading checkpoints for any element (serial and parallel, arbitrary number of functions and timesteps per file). Use `adios4dolfinx.read/write_function`.
|
|
123
|
+
- Writing standalone function checkpoints relating to "original meshes", i.e. meshes read from `XDMFFile`. Use `adios4dolfinx.write_function_on_input_mesh` for this.
|
|
124
|
+
- Store mesh partitioning and re-read the mesh with this information, avoiding calling SCOTCH, Kahip or Parmetis.
|
|
125
|
+
|
|
126
|
+
> [!IMPORTANT]
|
|
127
|
+
> For checkpoints written with `write_function` to be valid, you first have to store the mesh with `write_mesh` to the checkpoint file.
|
|
128
|
+
|
|
129
|
+
> [!IMPORTANT]
|
|
130
|
+
> A checkpoint file supports multiple functions and multiple time steps, as long as the functions are associated with the same mesh
|
|
131
|
+
|
|
132
|
+
> [!IMPORTANT]
|
|
133
|
+
> Only one mesh per file is allowed
|
|
134
|
+
|
|
135
|
+
## Example Usage
|
|
136
|
+
|
|
137
|
+
The repository contains many documented examples of usage, in the `docs`-folder, including
|
|
138
|
+
|
|
139
|
+
- [Reading and writing mesh checkpoints](./docs/writing_mesh_checkpoint.py)
|
|
140
|
+
- [Storing mesh partitioning data](./docs/partitioned_mesh.py)
|
|
141
|
+
- [Writing mesh-tags to a checkpoint](./docs/meshtags.py)
|
|
142
|
+
- [Reading and writing function checkpoints](./docs/writing_functions_checkpoint.py)
|
|
143
|
+
- [Checkpoint on input mesh](./docs/original_checkpoint.py)
|
|
144
|
+
Further examples can be found at [ADIOS4DOLFINx examples](https://jsdokken.com/adios4dolfinx/)
|
|
145
|
+
|
|
146
|
+
### Backwards compatibility
|
|
147
|
+
|
|
148
|
+
> [!WARNING]
|
|
149
|
+
> If you are using v0.7.2, you are adviced to upgrade to v0.7.3, as it contains som crucial fixes for openmpi.
|
|
150
|
+
|
|
151
|
+
### Legacy DOLFIN
|
|
152
|
+
|
|
153
|
+
Only checkpoints for `Lagrange` or `DG` functions are supported from legacy DOLFIN
|
|
154
|
+
|
|
155
|
+
- Reading meshes from the DOLFIN HDF5File-format
|
|
156
|
+
- Reading checkpoints from the DOLFIN HDF5File-format (one checkpoint per file only)
|
|
157
|
+
- Reading checkpoints from the DOLFIN XDMFFile-format (one checkpoint per file only, and only uses the `.h5` file)
|
|
158
|
+
|
|
159
|
+
See the [API](./docs/api) for more information.
|
|
160
|
+
|
|
161
|
+
## Testing
|
|
162
|
+
|
|
163
|
+
This library uses `pytest` for testing.
|
|
164
|
+
To execute the tests, one should first install the library and its dependencies, as listed above.
|
|
165
|
+
Then, can execute all tests by calling
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
python3 -m pytest .
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Testing against data from legacy dolfin
|
|
172
|
+
|
|
173
|
+
Some tests check the capability of reading data created with the legacy version of DOLFIN.
|
|
174
|
+
To create this dataset, start a docker container with legacy DOLFIN, for instance:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
docker run -ti -v $(pwd):/root/shared -w /root/s
|
|
178
|
+
hared --rm ghcr.io/scientificcomputing/fenics:2024-02-19
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Then, inside this container, call
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
python3 ./tests/create_legacy_data.py --output-dir=legacy
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Testing against data from older versions of ADIOS4DOLFINx
|
|
188
|
+
|
|
189
|
+
Some tests check the capability to read data generated by `adios4dolfinx<0.7.2`.
|
|
190
|
+
To generate data for these tests use the following commands:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
docker run -ti -v $(pwd):/root/shared -w /root/shared --rm ghcr.io/fenics/dolfinx/dolfinx:v0.7.3
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Then, inside the container, call
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
python3 -m pip install adios4dolfinx==0.7.1
|
|
200
|
+
python3 ./tests/create_legacy_checkpoint.py --output-dir=legacy_checkpoint
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Long term plan
|
|
204
|
+
|
|
205
|
+
The long term plan is to get this library merged into DOLFINx (rewritten in C++ with appropriate Python-bindings).
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# ADIOS4DOLFINx - A framework for checkpointing in DOLFINx
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
[](https://joss.theoj.org/papers/7866cb142db8a803e32d79a109573d25)
|
|
5
|
+
|
|
6
|
+
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/).
|
|
7
|
+
|
|
8
|
+
The code uses the ADIOS2 Python-wrappers to write DOLFINx objects to file, supporting N-to-M (_recoverable_) and N-to-N (_snapshot_) checkpointing.
|
|
9
|
+
See: [Checkpointing in DOLFINx - FEniCS 23](https://jsdokken.com/checkpointing-presentation/#/) or the examples in the [Documentation](https://jsdokken.com/adios4dolfinx/) for more information.
|
|
10
|
+
|
|
11
|
+
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.
|
|
12
|
+
|
|
13
|
+
## Statement of Need
|
|
14
|
+
|
|
15
|
+
As the usage of high performance computing clusters increases, more and more large-scale, long-running simulations are deployed.
|
|
16
|
+
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.
|
|
17
|
+
Having a checkpoint of related variables, such as the solutions to partial differential equations (PDEs) is therefore essential.
|
|
18
|
+
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.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
Compatibility with DOLFINx:
|
|
23
|
+
|
|
24
|
+
- ADIOS4DOLFINx v0.7.3 is compatible with DOLFINx v0.7.x
|
|
25
|
+
- ADIOS4DOLFINx v0.8.1 is compatible with DOLFINx v0.8.x
|
|
26
|
+
|
|
27
|
+
### Dependencies
|
|
28
|
+
|
|
29
|
+
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) and can therefore not be installed through PyPi, but has to be installed through Conda, Spack or from source.
|
|
30
|
+
|
|
31
|
+
### Docker
|
|
32
|
+
|
|
33
|
+
An MPI build of ADIOS2 is installed in the official DOLFINx containers, and thus there are no additional dependencies required to install `adios4dolfinx`
|
|
34
|
+
on top of DOLFINx in these images.
|
|
35
|
+
|
|
36
|
+
Create a Docker container, named for instance `dolfinx-checkpoint`.
|
|
37
|
+
Use the `nightly` tag to get the main branch of DOLFINx, or `stable` to get the latest stable release
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
docker run -ti -v $(pwd):/root/shared -w /root/shared --name=dolfinx-checkpoint ghcr.io/fenics/dolfinx/dolfinx:nightly
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
For the latest version compatible with nightly (with the ability to run the test suite), use
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
python3 -m pip install adios4dolfinx[test]@git+https://github.com/jorgensd/adios4dolfinx@main
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
If you are using the `stable` image, you can install `adios4dolfinx` from [PYPI](https://pypi.org/project/adios4dolfinx/) with
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
python3 -m pip install adios4dolfinx[test]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This docker container can be opened with
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
docker container start -i dolfinx-checkpoint
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
at a later instance
|
|
62
|
+
|
|
63
|
+
### Conda
|
|
64
|
+
|
|
65
|
+
> [!NOTE]
|
|
66
|
+
> Conda supports the stable release of DOLFINx, and thus the appropriate version should be installed, see the section above for more details.
|
|
67
|
+
|
|
68
|
+
Following is a minimal recipe of how to install adios4dolfinx, given that you have conda installed on your system.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
conda create -n dolfinx-checkpoint python=3.10
|
|
72
|
+
conda activate dolfinx-checkpoint
|
|
73
|
+
conda install -c conda-forge fenics-dolfinx pip adios2=*=mpi_*
|
|
74
|
+
python3 -m pip install adios4dolfinx[test]@git+https://github.com/jorgensd/adios4dolfinx@v0.8.1
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
> [!NOTE]
|
|
78
|
+
> To run the tests or demos associated with the code, install `ipyparallel` in your environment, for instance by calling
|
|
79
|
+
>
|
|
80
|
+
> ```bash
|
|
81
|
+
> python3 -m pip install adios4dolfinx[test]@git+https://github.com/jorgensd/adios4dolfinx@v0.8.1
|
|
82
|
+
> ```
|
|
83
|
+
|
|
84
|
+
## Functionality
|
|
85
|
+
|
|
86
|
+
### DOLFINx
|
|
87
|
+
|
|
88
|
+
- Reading and writing meshes, using `adios4dolfinx.read/write_mesh`
|
|
89
|
+
- Reading and writing meshtags associated to meshes `adios4dolfinx.read/write_meshtags`
|
|
90
|
+
- Reading checkpoints for any element (serial and parallel, arbitrary number of functions and timesteps per file). Use `adios4dolfinx.read/write_function`.
|
|
91
|
+
- Writing standalone function checkpoints relating to "original meshes", i.e. meshes read from `XDMFFile`. Use `adios4dolfinx.write_function_on_input_mesh` for this.
|
|
92
|
+
- Store mesh partitioning and re-read the mesh with this information, avoiding calling SCOTCH, Kahip or Parmetis.
|
|
93
|
+
|
|
94
|
+
> [!IMPORTANT]
|
|
95
|
+
> For checkpoints written with `write_function` to be valid, you first have to store the mesh with `write_mesh` to the checkpoint file.
|
|
96
|
+
|
|
97
|
+
> [!IMPORTANT]
|
|
98
|
+
> A checkpoint file supports multiple functions and multiple time steps, as long as the functions are associated with the same mesh
|
|
99
|
+
|
|
100
|
+
> [!IMPORTANT]
|
|
101
|
+
> Only one mesh per file is allowed
|
|
102
|
+
|
|
103
|
+
## Example Usage
|
|
104
|
+
|
|
105
|
+
The repository contains many documented examples of usage, in the `docs`-folder, including
|
|
106
|
+
|
|
107
|
+
- [Reading and writing mesh checkpoints](./docs/writing_mesh_checkpoint.py)
|
|
108
|
+
- [Storing mesh partitioning data](./docs/partitioned_mesh.py)
|
|
109
|
+
- [Writing mesh-tags to a checkpoint](./docs/meshtags.py)
|
|
110
|
+
- [Reading and writing function checkpoints](./docs/writing_functions_checkpoint.py)
|
|
111
|
+
- [Checkpoint on input mesh](./docs/original_checkpoint.py)
|
|
112
|
+
Further examples can be found at [ADIOS4DOLFINx examples](https://jsdokken.com/adios4dolfinx/)
|
|
113
|
+
|
|
114
|
+
### Backwards compatibility
|
|
115
|
+
|
|
116
|
+
> [!WARNING]
|
|
117
|
+
> If you are using v0.7.2, you are adviced to upgrade to v0.7.3, as it contains som crucial fixes for openmpi.
|
|
118
|
+
|
|
119
|
+
### Legacy DOLFIN
|
|
120
|
+
|
|
121
|
+
Only checkpoints for `Lagrange` or `DG` functions are supported from legacy DOLFIN
|
|
122
|
+
|
|
123
|
+
- Reading meshes from the DOLFIN HDF5File-format
|
|
124
|
+
- Reading checkpoints from the DOLFIN HDF5File-format (one checkpoint per file only)
|
|
125
|
+
- Reading checkpoints from the DOLFIN XDMFFile-format (one checkpoint per file only, and only uses the `.h5` file)
|
|
126
|
+
|
|
127
|
+
See the [API](./docs/api) for more information.
|
|
128
|
+
|
|
129
|
+
## Testing
|
|
130
|
+
|
|
131
|
+
This library uses `pytest` for testing.
|
|
132
|
+
To execute the tests, one should first install the library and its dependencies, as listed above.
|
|
133
|
+
Then, can execute all tests by calling
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
python3 -m pytest .
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Testing against data from legacy dolfin
|
|
140
|
+
|
|
141
|
+
Some tests check the capability of reading data created with the legacy version of DOLFIN.
|
|
142
|
+
To create this dataset, start a docker container with legacy DOLFIN, for instance:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
docker run -ti -v $(pwd):/root/shared -w /root/s
|
|
146
|
+
hared --rm ghcr.io/scientificcomputing/fenics:2024-02-19
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Then, inside this container, call
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
python3 ./tests/create_legacy_data.py --output-dir=legacy
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Testing against data from older versions of ADIOS4DOLFINx
|
|
156
|
+
|
|
157
|
+
Some tests check the capability to read data generated by `adios4dolfinx<0.7.2`.
|
|
158
|
+
To generate data for these tests use the following commands:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
docker run -ti -v $(pwd):/root/shared -w /root/shared --rm ghcr.io/fenics/dolfinx/dolfinx:v0.7.3
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Then, inside the container, call
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
python3 -m pip install adios4dolfinx==0.7.1
|
|
168
|
+
python3 ./tests/create_legacy_checkpoint.py --output-dir=legacy_checkpoint
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Long term plan
|
|
172
|
+
|
|
173
|
+
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.
|
|
6
|
+
version = "0.8.1"
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
280
|
-
mesh
|
|
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
|
|
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
|
|
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
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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
|
|
423
|
-
filename: Path
|
|
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
|
-
) ->
|
|
447
|
+
) -> tuple[np.ndarray, np.ndarray, ufl.Mesh, typing.Callable]:
|
|
431
448
|
"""
|
|
432
|
-
Read an ADIOS2 mesh
|
|
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
|
|
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
|
|
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
|
|
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
|
|
717
|
+
name: typing.Optional[str] = None,
|
|
663
718
|
):
|
|
664
719
|
"""
|
|
665
720
|
Write function checkpoint to file.
|