Skip to content

Commit c51d8d7

Browse files
authored
Merge pull request #1 from scientificcomputing/finsberg/rename
Rename package
2 parents f8e261e + aef36c5 commit c51d8d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+933
-470
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[run]
22
parallel = true
3-
source = adios4dolfinx
3+
source = io4dolfinx
44

55
[html]
66
directory= htmlcov

.github/workflows/build_joss_paper.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,6 @@ output/
137137
.coverage
138138
*.h5
139139
*.xdmf
140-
*.bp/
140+
*.bp/
141+
*.pvd
142+
*.vtu

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Contributor guidelines
2-
When contributing to this repository, please first [create an issue](https://github.com/jorgensd/adios4dolfinx/issues/new/choose) containing information about the missing feature or the bug that you would like to fix. Here you can discuss the change you want to make with the maintainers of the repository.
2+
When contributing to this repository, please first [create an issue](https://github.com/jorgensd/io4dolfinx/issues/new/choose) containing information about the missing feature or the bug that you would like to fix. Here you can discuss the change you want to make with the maintainers of the repository.
33

44
Please note we have a code of conduct, please follow it in all your interactions with the project.
55

66
## New contributor guide
77

8-
To get an overview of the project, read the [documentation](https://jorgensd.github.io/adios4dolfinx). Here are some resources to help you get started with open source contributions:
8+
To get an overview of the project, read the [documentation](https://jorgensd.github.io/io4dolfinx). Here are some resources to help you get started with open source contributions:
99

1010
- [Finding ways to contribute to open source on GitHub](https://docs.github.com/en/get-started/exploring-projects-on-github/finding-ways-to-contribute-to-open-source-on-github)
1111
- [Set up Git](https://docs.github.com/en/get-started/quickstart/set-up-git)

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2023 Jørgen S. Dokken
1+
Copyright 2023 Jørgen S. Dokken, Henrik N.T. Finsberg and Simula Research Laboratory
22

33
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:
44

README.md

Lines changed: 66 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -1,201 +1,110 @@
1-
# ADIOS4DOLFINx - A framework for checkpointing in DOLFINx
1+
# io4dolfinx - A framework for reading and writing data to various mesh formats
22

3-
![MIT](https://img.shields.io/github/license/jorgensd/adios4dolfinx)
4-
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/adios4dolfinx/badges/version.svg)](https://anaconda.org/conda-forge/adios4dolfinx)
3+
**io4dolfinx** is an extension for [DOLFINx](https://github.com/FEniCS/dolfinx/) that provides advanced input/output capabilities. It focuses on **N-to-M checkpointing** (writing data on N processors, reading on M processors) and supports reading/writing various mesh formats using interchangeable backends.
54

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.
195

206
## Installation
217

22-
Compatibility with DOLFINx:
23-
24-
- ADIOS4DOLFINx v0.10.0 is compatible with DOLFINx v0.10.x
25-
- ADIOS4DOLFINx v0.9.6 is compatible with DOLFINx v0.9.x
26-
- ADIOS4DOLFINx v0.8.1 is compatible with DOLFINx v0.8.x
27-
- ADIOS4DOLFINx v0.7.3 is compatible with DOLFINx v0.7.x
28-
29-
### Dependencies
30-
31-
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).
32-
Therefore `ADIOS2` should not be install through PYPI/pip, but has to be installed through Conda, Spack or from source.
33-
34-
> [!IMPORTANT]
35-
> ADIOS2<2.10.2 does not work properly with `numpy>=2.0.0`. Everyone is advised to use the newest version of ADIOS2.
36-
> This is for instance available through `conda` or the `ghcr.io/fenics/dolfinx/dolfinx:nightly` Docker-image.
37-
38-
### Spack
39-
40-
ADIOS4DOLFINx is a [spack package](https://packages.spack.io/package.html?name=py-adios4dolfinx)
41-
which can be installed with
42-
43-
```bash
44-
spack add py-adios4dolfinx ^py-fenics-dolfinx+petsc4py+slepc4py
45-
spack concretize
46-
spack install
47-
```
48-
49-
once you have downloaded spack and set up a new environment, as described in [Spack: Installation notes](https://github.com/spack/spack?tab=readme-ov-file#installation).
50-
To ensure that the spack packages are up to date, please call
8+
The library is compatible with the DOLFINx nightly release, v0.10.0, and v0.9.0.
519

5210
```bash
53-
spack repo update builtin
11+
python3 -m pip install io4dolfinx
5412
```
5513

56-
prior to concretizing.
14+
For specific backend requirements (like ADIOS2 or H5PY), see the [Installation Guide](./docs/installation.md).
5715

58-
### Docker
5916

60-
An MPI build of ADIOS2 is installed in the official DOLFINx containers, and thus there are no additional dependencies required to install `adios4dolfinx`
61-
on top of DOLFINx in these images.
17+
## Quick Start
6218

63-
Create a Docker container, named for instance `dolfinx-checkpoint`.
64-
Use the `nightly` tag to get the main branch of DOLFINx, or `stable` to get the latest stable release
19+
Here is a minimal example of saving and loading a simulation state (Checkpointing).
6520

66-
```bash
67-
docker run -ti -v $(pwd):/root/shared -w /root/shared --name=dolfinx-checkpoint ghcr.io/fenics/dolfinx/dolfinx:nightly
68-
```
21+
```python
22+
from pathlib import Path
23+
from mpi4py import MPI
24+
import dolfinx
25+
import io4dolfinx
6926

70-
For the latest version compatible with nightly (with the ability to run the test suite), use
71-
72-
```bash
73-
python3 -m pip install adios4dolfinx[test]@git+https://github.com/jorgensd/adios4dolfinx@main
74-
```
27+
# 1. Create a mesh and function
28+
comm = MPI.COMM_WORLD
29+
mesh = dolfinx.mesh.create_unit_square(comm, 10, 10)
30+
V = dolfinx.fem.functionspace(mesh, ("Lagrange", 1))
31+
u = dolfinx.fem.Function(V)
32+
u.interpolate(lambda x: x[0] + x[1])
33+
u.name = "my_function"
7534

76-
If you are using the `stable` image, you can install `adios4dolfinx` from [PYPI](https://pypi.org/project/adios4dolfinx/) with
35+
# 2. Write checkpoint
36+
# The mesh must be written before the function
37+
filename = Path("checkpoint.bp")
38+
io4dolfinx.write_mesh(filename, mesh)
39+
io4dolfinx.write_function(filename, u, time=0.0)
7740

78-
```bash
79-
python3 -m pip install adios4dolfinx[test]
80-
```
81-
82-
This docker container can be opened with
83-
84-
```bash
85-
docker container start -i dolfinx-checkpoint
41+
# 3. Read checkpoint
42+
# This works even if the number of MPI processes changes (N-to-M)
43+
mesh_new = io4dolfinx.read_mesh(filename, comm)
44+
V_new = dolfinx.fem.functionspace(mesh_new, ("Lagrange", 1))
45+
u_new = dolfinx.fem.Function(V_new)
46+
io4dolfinx.read_function(filename, u_new, time=0.0, name="my_function")
8647
```
8748

88-
at a later instance
89-
90-
### Conda
9149

92-
> [!NOTE]
93-
> Conda supports the stable release of DOLFINx, and thus the appropriate version should be installed, see the section above for more details.
50+
## Features and Backends
9451

95-
Following is a minimal recipe of how to install adios4dolfinx, given that you have conda installed on your system.
52+
`io4dolfinx` supports custom user backends. You can switch backends by passing `backend="name"` to IO functions.
9653

97-
```bash
98-
conda create -n dolfinx-checkpoint python=3.10
99-
conda activate dolfinx-checkpoint
100-
conda install -c conda-forge adios4dolfinx
101-
```
54+
### Checkpointing (N-to-M)
55+
Many finite element applications requires storage of functions that cannot be associated with the nodes or cells of the mesh. Therefore, we have implemented our own, native checkpointing format that supports N-to-M checkpointing (write data on N processors, read in on M) through the following backends:
10256

103-
> [!NOTE]
104-
> Remember to download the appropriate version of `adios4dolfinx` from Github [adios4dolfinx: Releases](https://github.com/jorgensd/adios4dolfinx/releases)
57+
- [h5py](./docs/backends/h5py.rst): Requires HDF5 with MPI support to work, but can store, meshes, partitioning info, meshtags, function data and more.
58+
- [adios2](./docs/backends/adios2.rst): Requires [ADIOS 2](https://adios2.readthedocs.io/en/latest/) compiled with MPI support and Python bindings. Supports the same set of operations as the `h5py` backend.
10559

106-
To run the test suite, you should also install `ipyparallel`, `pytest` and `coverage`, which can all be installed with conda
60+
The code uses the ADIOS2/Python-wrappers and h5py module to write DOLFINx objects to file, supporting N-to-M (_recoverable_) and N-to-N (_snapshot_) checkpointing.
61+
See: [Checkpointing in DOLFINx - FEniCS 23](https://jsdokken.com/checkpointing-presentation/#/) or the examples in the [Documentation](https://jsdokken.com/io4dolfinx/) for more information.
10762

108-
```bash
109-
conda install -c conda-forge ipyparallel pytest coverage
110-
```
63+
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.
11164

112-
## Functionality
11365

114-
### DOLFINx
66+
### Mesh IO (Import/Export)
67+
Most meshing formats supports associating data with the nodes of the mesh (the mesh can be higher order) and the cells of the mesh. The node data can be read in as P-th order Lagrange functions (where P is the order of the grid), while the cell data can be read in as piecewise constant (DG-0) functions.
11568

116-
- Reading and writing meshes, using `adios4dolfinx.read/write_mesh`
117-
- Reading and writing meshtags associated to meshes `adios4dolfinx.read/write_meshtags`
118-
- Reading checkpoints for any element (serial and parallel, arbitrary number of functions and timesteps per file). Use `adios4dolfinx.read/write_function`.
119-
- Writing standalone function checkpoints relating to "original meshes", i.e. meshes read from `XDMFFile`. Use `adios4dolfinx.write_function_on_input_mesh` for this.
120-
- Store mesh partitioning and re-read the mesh with this information, avoiding calling SCOTCH, Kahip or Parmetis.
69+
- [VTKHDF](./docs/backends/vtkhdf.rst): The new scalable format from VTK, called [VTKHDF](https://docs.vtk.org/en/latest/vtk_file_formats/vtkhdf_file_format/index.html) is supported by the `vtkhdf` backend.
70+
- [XDMF](./docs/backends/xdmf.rst) (eXtensible Model Data Format): `.xdmf`. The `xdmf` backend supports the `HDF5` encoding, to ensure performance in parallel.
71+
- [PyVista](./docs/backends/pyvista.rst) (IO backend is meshio): The [pyvista](https://pyvista.org/) backend uses {py:func}`pyvista.read` to read in meshes, point data and cell data. `pyvista` relies on [meshio](https://github.com/nschloe/meshio) for most reading operations (including the XDMF ascii format).
12172

122-
> [!IMPORTANT]
123-
> For checkpoints written with `write_function` to be valid, you first have to store the mesh with `write_mesh` to the checkpoint file.
12473

125-
> [!IMPORTANT]
126-
> A checkpoint file supports multiple functions and multiple time steps, as long as the functions are associated with the same mesh
12774

128-
> [!IMPORTANT]
129-
> Only one mesh per file is allowed
75+
## Advanced Usage
13076

131-
## Example Usage
77+
The repository contains detailed documented examples in the `docs` folder:
13278

133-
The repository contains many documented examples of usage, in the `docs`-folder, including
79+
* [Reading and writing mesh checkpoints](./docs/writing_mesh_checkpoint.py)
80+
* [Storing mesh partitioning data](./docs/partitioned_mesh.py) (Avoid re-partitioning when restarting)
81+
* [Writing mesh-tags](./docs/meshtags.py)
82+
* [Writing function checkpoints](./docs/writing_functions_checkpoint.py)
83+
* [Checkpoint on input mesh](./docs/original_checkpoint.py)
13484

135-
- [Reading and writing mesh checkpoints](./docs/writing_mesh_checkpoint.py)
136-
- [Storing mesh partitioning data](./docs/partitioned_mesh.py)
137-
- [Writing mesh-tags to a checkpoint](./docs/meshtags.py)
138-
- [Reading and writing function checkpoints](./docs/writing_functions_checkpoint.py)
139-
- [Checkpoint on input mesh](./docs/original_checkpoint.py)
140-
Further examples can be found at [ADIOS4DOLFINx examples](https://jsdokken.com/adios4dolfinx/)
85+
For a full API reference and backend details, see the [Documentation](https://jsdokken.com/io4dolfinx/).
14186

142-
### Backwards compatibility
87+
### Legacy DOLFIN Support
88+
`io4dolfinx` can read checkpoints created by the legacy version of DOLFIN (Lagrange or DG functions).
89+
* Reading meshes from DOLFIN HDF5File-format.
90+
* Reading checkpoints from DOLFIN HDF5File and XDMFFile.
14391

144-
> [!WARNING]
145-
> If you are using v0.7.2, you are advised to upgrade to v0.7.3, as it contains som crucial fixes for openmpi.
92+
## Project Background
14693

147-
### Legacy DOLFIN
94+
### Relation to adios4dolfinx
95+
This library is an evolution of [adios4dolfinx](https://doi.org/10.21105/joss.06451). It includes all functionality of the original library but has been refactored to support multiple IO backends (not just ADIOS2), making it easier to interface with different meshing formats while keeping the library structure sane.
14896

149-
Only checkpoints for `Lagrange` or `DG` functions are supported from legacy DOLFIN
97+
### Statement of Need
98+
As large-scale, long-running simulations on HPC clusters become more common, the need to store intermediate solutions is crucial. If a system crashes or a computational budget is exceeded, checkpoints allow the simulation to resume without restarting from scratch. `io4dolfinx` extends DOLFINx with this essential functionality.
15099

151-
- Reading meshes from the DOLFIN HDF5File-format
152-
- Reading checkpoints from the DOLFIN HDF5File-format (one checkpoint per file only)
153-
- Reading checkpoints from the DOLFIN XDMFFile-format (one checkpoint per file only, and only uses the `.h5` file)
100+
## Contributing
154101

155-
See the [API](./docs/api) for more information.
102+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
156103

157104
## Testing
158105

159-
This library uses `pytest` for testing.
160-
To execute the tests, one should first install the library and its dependencies, as listed above.
161-
Then, can execute all tests by calling
162-
163-
```bash
164-
python3 -m pytest .
165-
```
166-
167-
### Testing against data from legacy dolfin
168-
169-
Some tests check the capability of reading data created with the legacy version of DOLFIN.
170-
To create this dataset, start a docker container with legacy DOLFIN, for instance:
171-
172-
```bash
173-
docker run -ti -v $(pwd):/root/shared -w /root/s
174-
hared --rm ghcr.io/scientificcomputing/fenics:2024-02-19
175-
```
176-
177-
Then, inside this container, call
178-
179-
```bash
180-
python3 ./tests/create_legacy_data.py --output-dir=legacy
181-
```
182-
183-
### Testing against data from older versions of ADIOS4DOLFINx
184-
185-
Some tests check the capability to read data generated by `adios4dolfinx<0.7.2`.
186-
To generate data for these tests use the following commands:
187-
188-
```bash
189-
docker run -ti -v $(pwd):/root/shared -w /root/shared --rm ghcr.io/fenics/dolfinx/dolfinx:v0.7.3
190-
```
191-
192-
Then, inside the container, call
193-
194-
```bash
195-
python3 -m pip install adios4dolfinx==0.7.1
196-
python3 ./tests/create_legacy_checkpoint.py --output-dir=legacy_checkpoint
197-
```
106+
`io4dolfinx` includes a comprehensive test suite that ensures functionality across different backends and compatibility with legacy data formats, see the [Testing Guide](./docs/testing.md) for details.
198107

199-
## Long term plan
200108

201-
The long term plan is to get this library merged into DOLFINx (rewritten in C++ with appropriate Python-bindings).
109+
## LICENSE
110+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ execute:
1414

1515
# Information about where the book exists on the web
1616
repository:
17-
url: https://github.com/jorgensd/adios4dolfinx # Online location of your book
17+
url: https://github.com/jorgensd/io4dolfinx # Online location of your book
1818
branch: main
1919

2020
html:

_toc.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ root: README
44
parts:
55
- caption: How to guides
66
chapters:
7+
- file: "docs/installation"
8+
- file: "docs/quickstart"
79
- file: "docs/adding_backend"
810
- file: "docs/migration_guide"
11+
- file: "docs/testing.md"
12+
- file: "docs/reading_legacy_data"
913

1014
- caption: Introduction to IPyParallel
1115
chapters:
@@ -30,4 +34,9 @@ parts:
3034
- file: "docs/backends/adios2"
3135
- file: "docs/backends/h5py"
3236
- file: "docs/backends/pyvista"
33-
- file: "docs/backends/xdmf"
37+
- file: "docs/backends/xdmf"
38+
- file: "docs/backends/vtkhdf"
39+
40+
- caption: Contributing
41+
chapters:
42+
- file: "CONTRIBUTING"

0 commit comments

Comments
 (0)