Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.8.1 release #110

Merged
merged 10 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
DEB_PYTHON_INSTALL_LAYOUT: deb_system

runs-on: ubuntu-22.04
container: ghcr.io/fenics/dolfinx/dolfinx:nightly
container: ghcr.io/fenics/dolfinx/dolfinx:v0.8.0
steps:
# This action sets the current path to the root of your github repo
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
DEB_PYTHON_INSTALL_LAYOUT: deb_system

runs-on: ubuntu-22.04
container: ghcr.io/fenics/dolfinx/dolfinx:nightly
container: ghcr.io/fenics/dolfinx/dolfinx:v0.8.0
steps:
# This action sets the current path to the root of your github repo
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
test-code:
runs-on: "ubuntu-22.04"
needs: [create-datasets, create-legacy-datasets, check-formatting]
container: ghcr.io/fenics/dolfinx/dolfinx:nightly
container: ghcr.io/fenics/dolfinx/dolfinx:v0.8.0
env:
DEB_PYTHON_INSTALL_LAYOUT: deb_system

Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/test_package_openmpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
OMPI_ALLOW_RUN_AS_ROOT: 1
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
PRTE_MCA_rmaps_default_mapping_policy: :oversubscribe
working-directory: ./src

strategy:
matrix:
Expand All @@ -48,11 +49,15 @@ jobs:
run: python3 -m pip install --upgrade pip setuptools

- name: Install DOLFINx
uses: jorgensd/actions/install-dolfinx@v0.2.0
uses: jorgensd/actions/install-dolfinx@v0.3.0
with:
adios2: ${{ matrix.adios2 }}
petsc_arch: ${{ env.PETSC_ARCH }}
dolfinx: main
dolfinx: v0.8.0
basix: v0.8.0
ufl: 2024.1.0.post0
ffcx: v0.8.0
working-directory: ${{ env.working-directory}}

- name: Download legacy data
uses: actions/download-artifact@v4
Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/test_redhat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Test package with redhat

on:
push:
# The CI is executed on every push on every branch
branches:
- "**"
pull_request:
# The CI is executed on every pull request to the main branch
branches:
- main

workflow_call:
workflow_dispatch:
schedule:
# The CI is executed every day at 8am
- cron: "0 8 * * *"

jobs:
create-datasets:
uses: ./.github/workflows/create_legacy_data.yml
with:
artifact_name: "legacy_ompi"

create-legacy-datasets:
uses: ./.github/workflows/create_legacy_checkpoint.yml
with:
artifact_name: "legacy_checkpoint_ompi"

test-code:
runs-on: "ubuntu-22.04"
needs: [create-datasets, create-legacy-datasets]
container: docker.io/fenicsproject/test-env:current-redhat
env:
DEB_PYTHON_INSTALL_LAYOUT: deb_system
PETSC_ARCH: ""
PETSC_DIR: "/usr/local/"
PYTHONPATH: "/usr/local/lib/:${PYTHONPATH}"
working-directory: ./src

strategy:
matrix:
adios2: ["v2.10.0"]
steps:
- uses: actions/checkout@v4

- name: Update pip
run: python3 -m pip install --upgrade pip setuptools

- name: Install DOLFINx
uses: jorgensd/actions/[email protected]
with:
adios2: ${{ matrix.adios2 }}
petsc_arch: ${{ env.PETSC_ARCH }}
petsc_dir: ${{ env.PETSC_DIR }}
dolfinx: v0.8.0
basix: v0.8.0
ufl: 2024.1.0.post0
ffcx: v0.8.0
working-directory: ${{ env.working-directory}}

- name: Download legacy data
uses: actions/download-artifact@v4
with:
name: legacy_ompi
path: ./legacy

- name: Download legacy data
uses: actions/download-artifact@v4
with:
name: legacy_checkpoint_ompi
path: ./legacy_checkpoint

- name: Install package
run: python3 -m pip install .[test]

- name: Run tests
run: |
coverage run --rcfile=.coveragerc -m mpi4py -m pytest -xvs ./tests

- name: Run tests in parallel
run: |
mpirun -n 4 coverage run --rcfile=.coveragerc -m mpi4py -m pytest -xvs ./tests
10 changes: 5 additions & 5 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Dokken"
given-names: "Jørgen S."
orcid: "0000-0001-6489-8858"
- family-names: "Dokken"
given-names: "Jørgen S."
orcid: "0000-0001-6489-8858"
title: "ADIOS2Wrappers"
version: "0.7.2"
date-released: "2023-02-07"
version: "0.8.1"
date-released: "2023-04-25"
48 changes: 37 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
![MIT](https://img.shields.io/github/license/jorgensd/adios4dolfinx)
[![status](https://joss.theoj.org/papers/7866cb142db8a803e32d79a109573d25/status.svg)](https://joss.theoj.org/papers/7866cb142db8a803e32d79a109573d25)


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/).

The code uses the ADIOS2 Python-wrappers to write DOLFINx objects to file, supporting N-to-M (_recoverable_) and N-to-N (_snapshot_) checkpointing.
Expand All @@ -12,40 +11,53 @@ See: [Checkpointing in DOLFINx - FEniCS 23](https://jsdokken.com/checkpointing-p
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.

## Statement of Need

As the usage of high performance computing clusters increases, more and more large-scale, long-running simulations are deployed.
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.
Having a checkpoint of related variables, such as the solutions to partial differential equations (PDEs) is therefore essential.
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.


## Installation

Compatibility with DOLFINx:

- ADIOS4DOLFINx v0.7.3 is compatible with DOLFINx v0.7.x
- ADIOS4DOLFINx v0.8.x is compatible with the main branch of DOLFINx
- ADIOS4DOLFINx v0.8.1 is compatible with DOLFINx v0.8.x

### Dependencies

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.

### Docker

ADIOS2 is installed in the official DOLFINx containers, and thus there are no additional dependencies required to install `adios4dolfinx`
An MPI build of ADIOS2 is installed in the official DOLFINx containers, and thus there are no additional dependencies required to install `adios4dolfinx`
on top of DOLFINx in these images.

Create a Docker container, named for instance `dolfinx-checkpoint`.
Use the `nightly` tag to get the main branch of DOLFINx, or `stable` to get the lastest stable release
Use the `nightly` tag to get the main branch of DOLFINx, or `stable` to get the latest stable release

```bash
docker run -ti -v $(pwd):/root/shared -w /root/shared --name=dolfinx-checkpoint ghcr.io/fenics/dolfinx/dolfinx:nightly
```

For the latest version compatible with nightly (with the ability to run the test suite), use

```bash
python3 -m pip install adios4dolfinx[test]@git+https://github.com/jorgensd/adios4dolfinx@main
```

If you are using the `stable` image, you can install `adios4dolfinx` from [PYPI](https://pypi.org/project/adios4dolfinx/) with

```bash
python3 -m pip install adios4dolfinx[test]
```

This docker container can be opened with

```bash
docker container start -i dolfinx-checkpoint
```

at a later instance

### Conda
Expand All @@ -54,18 +66,21 @@ at a later instance
> Conda supports the stable release of DOLFINx, and thus the appropriate version should be installed, see the section above for more details.

Following is a minimal recipe of how to install adios4dolfinx, given that you have conda installed on your system.

```bash
conda create -n dolfinx-checkpoint python=3.10
conda activate dolfinx-checkpoint
conda install -c conda-forge fenics-dolfinx pip adios2
python3 -m pip install adios4dolfinx[test]@git+https://github.com/jorgensd/adios4dolfinx@v0.7.3
conda install -c conda-forge fenics-dolfinx pip adios2=*=mpi_*
python3 -m pip install adios4dolfinx[test]@git+https://github.com/jorgensd/adios4dolfinx@v0.8.1
```

> [!NOTE]
> To run the tests or demos associated with the code, install `ipyparallel` in your environment, for instance by calling
>
> ```bash
> python3 -m pip install adios4dolfinx[test]@git+https://github.com/jorgensd/adios4dolfinx@v0.7.3
> python3 -m pip install adios4dolfinx[test]@git+https://github.com/jorgensd/adios4dolfinx@v0.8.1
> ```

## Functionality

### DOLFINx
Expand All @@ -86,13 +101,15 @@ python3 -m pip install adios4dolfinx[test]@git+https://github.com/jorgensd/adios
> Only one mesh per file is allowed

## Example Usage

The repository contains many documented examples of usage, in the `docs`-folder, including

- [Reading and writing mesh checkpoints](./docs/writing_mesh_checkpoint.py)
- [Storing mesh partitioning data](./docs/partitioned_mesh.py)
- [Writing mesh-tags to a checkpoint](./docs/meshtags.py)
- [Reading and writing function checkpoints](./docs/writing_functions_checkpoint.py)
- [Checkpoint on input mesh](./docs/original_checkpoint.py)
Further examples can be found at [ADIOS4DOLFINx examples](https://jsdokken.com/adios4dolfinx/)
Further examples can be found at [ADIOS4DOLFINx examples](https://jsdokken.com/adios4dolfinx/)

### Backwards compatibility

Expand All @@ -113,30 +130,39 @@ See the [API](./docs/api) for more information.

This library uses `pytest` for testing.
To execute the tests, one should first install the library and its dependencies, as listed above.
Then, can execute all tests by calling
Then, can execute all tests by calling

```bash
python3 -m pytest .
```

### Testing against data from legacy dolfin

Some tests check the capability of reading data created with the legacy version of DOLFIN.
To create this dataset, start a docker container with legacy DOLFIN, for instance:
To create this dataset, start a docker container with legacy DOLFIN, for instance:

```bash
docker run -ti -v $(pwd):/root/shared -w /root/s
hared --rm ghcr.io/scientificcomputing/fenics:2024-02-19
```

Then, inside this container, call

```bash
python3 ./tests/create_legacy_data.py --output-dir=legacy
```

### Testing against data from older versions of ADIOS4DOLFINx

Some tests check the capability to read data generated by `adios4dolfinx<0.7.2`.
To generate data for these tests use the following commands:

```bash
docker run -ti -v $(pwd):/root/shared -w /root/shared --rm ghcr.io/fenics/dolfinx/dolfinx:v0.7.3
```

Then, inside the container, call

```bash
python3 -m pip install adios4dolfinx==0.7.1
python3 ./tests/create_legacy_checkpoint.py --output-dir=legacy_checkpoint
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ requires = ["setuptools>=61.0.0", "wheel"]

[project]
name = "adios4dolfinx"
version = "0.8.0.dev0"
version = "0.8.1"
description = "Checkpointing functionality for DOLFINx meshes/functions with ADIOS2"
authors = [{ name = "Jørgen S. Dokken", email = "[email protected]" }]
license = { file = "LICENSE" }
readme = "README.md"
dependencies = ["fenics-dolfinx>=0.8.0.dev0"]
dependencies = ["fenics-dolfinx>=0.8.0"]

[project.optional-dependencies]
test = ["pytest", "coverage", "ipyparallel"]
Expand Down
12 changes: 6 additions & 6 deletions src/adios4dolfinx/adios2_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from contextlib import contextmanager
from pathlib import Path
from typing import NamedTuple
from typing import NamedTuple, Union

from mpi4py import MPI

Expand Down Expand Up @@ -44,7 +44,7 @@ class AdiosFile(NamedTuple):
@contextmanager
def ADIOSFile(
adios: adios2.ADIOS,
filename: Path | str,
filename: Union[Path, str],
engine: str,
mode: adios2.Mode,
io_name: str,
Expand All @@ -62,7 +62,7 @@ def ADIOSFile(
def read_cell_perms(
adios: adios2.ADIOS,
comm: MPI.Intracomm,
filename: Path | str,
filename: Union[Path, str],
variable: str,
num_cells_global: np.int64,
engine: str,
Expand Down Expand Up @@ -126,12 +126,12 @@ def read_cell_perms(
def read_adjacency_list(
adios: adios2.ADIOS,
comm: MPI.Intracomm,
filename: Path | str,
filename: Union[Path, str],
dofmap: str,
dofmap_offsets: str,
num_cells_global: np.int64,
engine: str,
) -> dolfinx.cpp.graph.AdjacencyList_int64 | dolfinx.cpp.graph.AdjacencyList_int32:
) -> Union[dolfinx.cpp.graph.AdjacencyList_int64, dolfinx.cpp.graph.AdjacencyList_int32]:
"""
Read an adjacency-list from an ADIOS file with given communicator.
The adjancency list is split in to a flat array (data) and its corresponding offset.
Expand Down Expand Up @@ -205,7 +205,7 @@ def read_adjacency_list(

def read_array(
adios: adios2.ADIOS,
filename: Path | str,
filename: Union[Path, str],
array_name: str,
engine: str,
comm: MPI.Intracomm,
Expand Down
Loading