io4dolfinx 2.0.0__tar.gz → 2.1.0__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.
- {io4dolfinx-2.0.0/src/io4dolfinx.egg-info → io4dolfinx-2.1.0}/PKG-INFO +16 -1
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/README.md +15 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/pyproject.toml +24 -3
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/__init__.py +88 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/adios2/backend.py +52 -18
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/adios2/helpers.py +23 -0
- io4dolfinx-2.1.0/src/io4dolfinx/backends/adios2_serial/backend.py +146 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/h5py/backend.py +105 -39
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/h5py/storage.py +42 -1
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/h5py_serial/backend.py +9 -1
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/serial.py +38 -16
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/vtkhdf/backend.py +1 -1
- io4dolfinx-2.1.0/src/io4dolfinx/backends/xdmf/__init__.py +3 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/checkpointing.py +15 -37
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/converter.py +1 -1
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/readers.py +4 -19
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/submesh.py +4 -4
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0/src/io4dolfinx.egg-info}/PKG-INFO +16 -1
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx.egg-info/SOURCES.txt +3 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_attributes.py +2 -2
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_backends.py +65 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_checkpointing.py +62 -3
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_converter.py +1 -1
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_format_version.py +1 -1
- io4dolfinx-2.1.0/tests/test_h5py_compression.py +321 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_meshtags.py +1 -1
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_original_checkpoint.py +2 -2
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_snapshot_checkpoint.py +1 -1
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_submesh.py +1 -1
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_vtkhdf.py +88 -32
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_vtkhdf_compression.py +1 -1
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/LICENSE +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/setup.cfg +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/__init__.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/ascii_helpers.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/adios2/__init__.py +0 -0
- {io4dolfinx-2.0.0/src/io4dolfinx/backends/exodus → io4dolfinx-2.1.0/src/io4dolfinx/backends/adios2_serial}/__init__.py +0 -0
- {io4dolfinx-2.0.0/src/io4dolfinx/backends/gmsh → io4dolfinx-2.1.0/src/io4dolfinx/backends/exodus}/__init__.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/exodus/backend.py +0 -0
- {io4dolfinx-2.0.0/src/io4dolfinx/backends/h5py → io4dolfinx-2.1.0/src/io4dolfinx/backends/gmsh}/__init__.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/gmsh/backend.py +0 -0
- {io4dolfinx-2.0.0/src/io4dolfinx/backends/h5py_serial → io4dolfinx-2.1.0/src/io4dolfinx/backends/h5py}/__init__.py +0 -0
- {io4dolfinx-2.0.0/src/io4dolfinx/backends/med → io4dolfinx-2.1.0/src/io4dolfinx/backends/h5py_serial}/__init__.py +0 -0
- {io4dolfinx-2.0.0/src/io4dolfinx/backends/nastran → io4dolfinx-2.1.0/src/io4dolfinx/backends/med}/__init__.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/med/backend.py +0 -0
- {io4dolfinx-2.0.0/src/io4dolfinx/backends/opencarp → io4dolfinx-2.1.0/src/io4dolfinx/backends/nastran}/__init__.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/nastran/backend.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/nastran/helpers.py +0 -0
- {io4dolfinx-2.0.0/src/io4dolfinx/backends/openfoam → io4dolfinx-2.1.0/src/io4dolfinx/backends/opencarp}/__init__.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/opencarp/backend.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/opencarp/helpers.py +0 -0
- {io4dolfinx-2.0.0/src/io4dolfinx/backends/pyvista → io4dolfinx-2.1.0/src/io4dolfinx/backends/openfoam}/__init__.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/openfoam/backend.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/openfoam/helpers.py +0 -0
- {io4dolfinx-2.0.0/src/io4dolfinx/backends/vtkhdf → io4dolfinx-2.1.0/src/io4dolfinx/backends/pyvista}/__init__.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/pyvista/backend.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/pyvista/helpers.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/vtk_cell_types.py +0 -0
- {io4dolfinx-2.0.0/src/io4dolfinx/backends/vtkhdf_serial → io4dolfinx-2.1.0/src/io4dolfinx/backends/vtkhdf}/__init__.py +0 -0
- {io4dolfinx-2.0.0/src/io4dolfinx/backends/xdmf → io4dolfinx-2.1.0/src/io4dolfinx/backends/vtkhdf_serial}/__init__.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/vtkhdf_serial/backend.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/backends/xdmf/backend.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/comm_helpers.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/format.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/original_checkpoint.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/py.typed +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/snapshot.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/structures.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/utils.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx/writers.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx.egg-info/dependency_links.txt +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx.egg-info/entry_points.txt +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx.egg-info/requires.txt +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/src/io4dolfinx.egg-info/top_level.txt +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_checkpointing_vector.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_exodus.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_geometry_dofmap_reconstruction.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_gmsh.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_legacy_readers.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_med.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_mesh_writer.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_nastran.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_numpy_vectorization.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_opencarp.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_openfoam.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_pyvista.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_version.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_write_data_input_order.py +0 -0
- {io4dolfinx-2.0.0 → io4dolfinx-2.1.0}/tests/test_xdmf.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: io4dolfinx
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: Checkpointing functionality for DOLFINx meshes/functions with ADIOS2
|
|
5
5
|
Author-email: "Jørgen S. Dokken" <dokken@simula.no>, "Henrik N.T. Finsberg" <henriknf@simula.no>
|
|
6
6
|
License: Copyright 2023 Jørgen S. Dokken, Henrik N.T. Finsberg and Simula Research Laboratory
|
|
@@ -150,6 +150,21 @@ Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduc
|
|
|
150
150
|
|
|
151
151
|
`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.
|
|
152
152
|
|
|
153
|
+
## Releasing
|
|
154
|
+
Versions are managed with [bump-my-version](https://callowayproject.github.io/bump-my-version/), configured in `pyproject.toml`. Between releases the version is a development version, `X.Y.Z.devN`; a release drops the suffix. Each bump commits the version change, so start from a clean working tree.
|
|
155
|
+
|
|
156
|
+
To release the current development version, e.g. `2.1.0.dev0`, and start the next one:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
bump-my-version bump release --no-tag # 2.1.0.dev0 -> 2.1.0
|
|
160
|
+
bump-my-version bump minor --no-tag # 2.1.0 -> 2.2.0.dev0
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
For a patch release of 2.1, bump `patch` instead of `minor` (`2.1.0 -> 2.1.1.dev0`), then `release` (`2.1.1.dev0 -> 2.1.1`). `bump-my-version show-bump` previews what each bump gives.
|
|
164
|
+
|
|
165
|
+
The bumps do not tag. A `v*` tag publishes to PyPI and the documentation, so tag the release commit (`Bump version: 2.1.0.dev0 → 2.1.0`) as `v2.1.0`, for instance by creating a GitHub release from it.
|
|
166
|
+
|
|
167
|
+
Releasing a new minor version also adds it to `.github/docs-versions.toml`, which lists the versions on the documentation website, built in the DOLFINx image of the previous one; edit that image afterwards if a newer DOLFINx release should be used. A patch release needs no entry, as each minor version is built from its newest tag.
|
|
153
168
|
|
|
154
169
|
## LICENSE
|
|
155
170
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
@@ -111,6 +111,21 @@ Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduc
|
|
|
111
111
|
|
|
112
112
|
`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.
|
|
113
113
|
|
|
114
|
+
## Releasing
|
|
115
|
+
Versions are managed with [bump-my-version](https://callowayproject.github.io/bump-my-version/), configured in `pyproject.toml`. Between releases the version is a development version, `X.Y.Z.devN`; a release drops the suffix. Each bump commits the version change, so start from a clean working tree.
|
|
116
|
+
|
|
117
|
+
To release the current development version, e.g. `2.1.0.dev0`, and start the next one:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
bump-my-version bump release --no-tag # 2.1.0.dev0 -> 2.1.0
|
|
121
|
+
bump-my-version bump minor --no-tag # 2.1.0 -> 2.2.0.dev0
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
For a patch release of 2.1, bump `patch` instead of `minor` (`2.1.0 -> 2.1.1.dev0`), then `release` (`2.1.1.dev0 -> 2.1.1`). `bump-my-version show-bump` previews what each bump gives.
|
|
125
|
+
|
|
126
|
+
The bumps do not tag. A `v*` tag publishes to PyPI and the documentation, so tag the release commit (`Bump version: 2.1.0.dev0 → 2.1.0`) as `v2.1.0`, for instance by creating a GitHub release from it.
|
|
127
|
+
|
|
128
|
+
Releasing a new minor version also adds it to `.github/docs-versions.toml`, which lists the versions on the documentation website, built in the DOLFINx image of the previous one; edit that image afterwards if a newer DOLFINx release should be used. A patch release needs no entry, as each minor version is built from its newest tag.
|
|
114
129
|
|
|
115
130
|
## LICENSE
|
|
116
131
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
@@ -11,7 +11,7 @@ build-backend = "setuptools.build_meta"
|
|
|
11
11
|
|
|
12
12
|
[project]
|
|
13
13
|
name = "io4dolfinx"
|
|
14
|
-
version = "2.
|
|
14
|
+
version = "2.1.0"
|
|
15
15
|
description = "Checkpointing functionality for DOLFINx meshes/functions with ADIOS2"
|
|
16
16
|
authors = [
|
|
17
17
|
{ name = "Jørgen S. Dokken", email = "dokken@simula.no" },
|
|
@@ -141,9 +141,30 @@ tag = true
|
|
|
141
141
|
sign_tags = false
|
|
142
142
|
tag_name = "v{new_version}"
|
|
143
143
|
tag_message = "Bump version: {current_version} → {new_version}"
|
|
144
|
-
current_version = "2.
|
|
144
|
+
current_version = "2.1.0"
|
|
145
|
+
# X.Y.Z.devN while developing, X.Y.Z when released
|
|
146
|
+
parse = '(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>dev)(?P<pre_n>\d+))?'
|
|
147
|
+
serialize = ["{major}.{minor}.{patch}.{release}{pre_n}", "{major}.{minor}.{patch}"]
|
|
148
|
+
|
|
149
|
+
[tool.bumpversion.parts.release]
|
|
150
|
+
# "final" is the released state: never written in the version, reached with `bump release`
|
|
151
|
+
values = ["dev", "final"]
|
|
152
|
+
optional_value = "final"
|
|
145
153
|
|
|
146
154
|
[[tool.bumpversion.files]]
|
|
147
155
|
filename = "pyproject.toml"
|
|
148
|
-
|
|
156
|
+
# Anchored, so it is the [project] version and not current_version
|
|
157
|
+
regex = true
|
|
158
|
+
search = '^version = "{current_version}"$'
|
|
149
159
|
replace = 'version = "{new_version}"'
|
|
160
|
+
|
|
161
|
+
# Releasing a new minor version (`bump release` to X.Y.0) adds its documentation version, built
|
|
162
|
+
# in the DOLFINx image of the previous minor release. Update that image if a newer DOLFINx
|
|
163
|
+
# release is stable. A patch release needs no entry, as each minor is built from its newest tag.
|
|
164
|
+
[[tool.bumpversion.files]]
|
|
165
|
+
filename = ".github/docs-versions.toml"
|
|
166
|
+
include_bumps = ["release"]
|
|
167
|
+
ignore_missing_version = true
|
|
168
|
+
regex = true
|
|
169
|
+
search = '(?P<last>^"(?!{new_major}\.{new_minor}")\d+\.\d+" = "(?P<image>[^"]+)"\n)\Z'
|
|
170
|
+
replace = '\g<last>"{new_major}.{new_minor}" = "\g<image>"\n'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import warnings
|
|
2
|
+
from collections.abc import Iterable
|
|
2
3
|
from enum import Enum
|
|
3
4
|
from importlib import import_module
|
|
4
5
|
from pathlib import Path
|
|
@@ -23,9 +24,11 @@ __all__ = [
|
|
|
23
24
|
"DEFAULT_MESH_NAME",
|
|
24
25
|
"FileMode",
|
|
25
26
|
"IOBackend",
|
|
27
|
+
"function_not_found",
|
|
26
28
|
"get_backend",
|
|
27
29
|
"get_mesh_name",
|
|
28
30
|
"set_default_backend",
|
|
31
|
+
"with_mesh_name",
|
|
29
32
|
]
|
|
30
33
|
|
|
31
34
|
_DEFAULT_BACKEND = "h5py"
|
|
@@ -55,6 +58,70 @@ def get_mesh_name(backend_args: dict[str, Any] | None) -> str:
|
|
|
55
58
|
return DEFAULT_MESH_NAME if name is None else str(name)
|
|
56
59
|
|
|
57
60
|
|
|
61
|
+
def with_mesh_name(
|
|
62
|
+
backend_args: dict[str, Any] | None, mesh_name: str | None
|
|
63
|
+
) -> dict[str, Any] | None:
|
|
64
|
+
"""Backend arguments selecting the mesh ``mesh_name``, as backends expect them.
|
|
65
|
+
|
|
66
|
+
Public functions take the mesh as ``mesh_name``, while backends read it from
|
|
67
|
+
``backend_args["name"]`` (see :func:`get_mesh_name`). Passing the mesh name in
|
|
68
|
+
``backend_args`` to a public function is deprecated.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
backend_args: Backend arguments of the caller, not modified.
|
|
72
|
+
mesh_name: Name of the mesh, or ``None`` for the default mesh.
|
|
73
|
+
|
|
74
|
+
Returns:
|
|
75
|
+
``backend_args`` with ``"name"`` set to ``mesh_name``.
|
|
76
|
+
|
|
77
|
+
Raises:
|
|
78
|
+
ValueError: If ``backend_args["name"]`` and ``mesh_name`` name different meshes.
|
|
79
|
+
"""
|
|
80
|
+
if backend_args is not None and "name" in backend_args:
|
|
81
|
+
if mesh_name is not None and backend_args["name"] != mesh_name:
|
|
82
|
+
raise ValueError(
|
|
83
|
+
f"backend_args['name']={backend_args['name']!r} and mesh_name={mesh_name!r} "
|
|
84
|
+
"name different meshes; pass mesh_name only."
|
|
85
|
+
)
|
|
86
|
+
warnings.warn(
|
|
87
|
+
"Passing the mesh name as backend_args['name'] is deprecated; use mesh_name.",
|
|
88
|
+
DeprecationWarning,
|
|
89
|
+
stacklevel=3,
|
|
90
|
+
)
|
|
91
|
+
return backend_args
|
|
92
|
+
if mesh_name is None:
|
|
93
|
+
return backend_args
|
|
94
|
+
return {**(backend_args or {}), "name": mesh_name}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def function_not_found(
|
|
98
|
+
filename: Path | str, function_name: str, mesh_name: str, function_names: Iterable[str]
|
|
99
|
+
) -> KeyError:
|
|
100
|
+
"""The error for a function a checkpoint does not hold, naming the ones it does.
|
|
101
|
+
|
|
102
|
+
The names tell a misspelt name, or one written on another mesh, from a function that
|
|
103
|
+
was never written.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
filename: Path to the file
|
|
107
|
+
function_name: Name of the function asked for
|
|
108
|
+
mesh_name: Name of the mesh it was asked for on
|
|
109
|
+
function_names: Names of the functions the file holds on that mesh
|
|
110
|
+
|
|
111
|
+
Returns:
|
|
112
|
+
The error to raise
|
|
113
|
+
"""
|
|
114
|
+
names = sorted(set(function_names))
|
|
115
|
+
holds = (
|
|
116
|
+
f"Functions on that mesh: {', '.join(map(repr, names))}."
|
|
117
|
+
if names
|
|
118
|
+
else "There are no functions on that mesh."
|
|
119
|
+
)
|
|
120
|
+
return KeyError(
|
|
121
|
+
f"Function {function_name!r} not found on mesh {mesh_name!r} in {filename}. {holds}"
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
|
|
58
125
|
def set_default_backend(backend: str):
|
|
59
126
|
"""Set the global default backend for io4dolfinx."""
|
|
60
127
|
global _DEFAULT_BACKEND
|
|
@@ -177,6 +244,11 @@ class IOBackend(Protocol):
|
|
|
177
244
|
|
|
178
245
|
Returns:
|
|
179
246
|
Numpy array of timestamps read from file
|
|
247
|
+
|
|
248
|
+
Raises:
|
|
249
|
+
KeyError: In the adios2 and h5py backends, if the file does not hold the
|
|
250
|
+
function on that mesh. The message names the functions it does hold
|
|
251
|
+
(:func:`function_not_found`).
|
|
180
252
|
"""
|
|
181
253
|
|
|
182
254
|
def write_mesh(
|
|
@@ -501,6 +573,17 @@ def get_backend(backend: str | None = None) -> IOBackend:
|
|
|
501
573
|
stacklevel=2,
|
|
502
574
|
)
|
|
503
575
|
backend = f"{backend}-serial"
|
|
576
|
+
elif backend == "adios2":
|
|
577
|
+
import adios2
|
|
578
|
+
|
|
579
|
+
if not adios2.is_built_with_mpi:
|
|
580
|
+
warnings.warn(
|
|
581
|
+
"ADIOS2 is built without MPI, so the adios2 backend runs as adios2-serial, "
|
|
582
|
+
"which writes all data through rank 0. Install ADIOS2 with MPI for parallel IO, "
|
|
583
|
+
"see the io4dolfinx installation guide.",
|
|
584
|
+
stacklevel=2,
|
|
585
|
+
)
|
|
586
|
+
backend = "adios2-serial"
|
|
504
587
|
|
|
505
588
|
if backend == "h5py":
|
|
506
589
|
from .h5py import backend as H5PYInterface
|
|
@@ -518,6 +601,10 @@ def get_backend(backend: str | None = None) -> IOBackend:
|
|
|
518
601
|
from .adios2 import backend as ADIOS2Interface
|
|
519
602
|
|
|
520
603
|
return ADIOS2Interface
|
|
604
|
+
elif backend == "adios2-serial":
|
|
605
|
+
from .adios2_serial import backend as ADIOS2SerialInterface
|
|
606
|
+
|
|
607
|
+
return ADIOS2SerialInterface
|
|
521
608
|
elif backend == "pyvista":
|
|
522
609
|
from .pyvista import backend as PYVISTAInterface
|
|
523
610
|
|
|
@@ -563,6 +650,7 @@ BUILTIN_BACKENDS = (
|
|
|
563
650
|
"h5py-serial",
|
|
564
651
|
"vtkhdf-serial",
|
|
565
652
|
"adios2",
|
|
653
|
+
"adios2-serial",
|
|
566
654
|
"pyvista",
|
|
567
655
|
"xdmf",
|
|
568
656
|
"vtkhdf",
|
|
@@ -13,11 +13,12 @@ import numpy.typing as npt
|
|
|
13
13
|
from ...format import METADATA_KEYS, stamp
|
|
14
14
|
from ...structures import ArrayData, FunctionData, MeshData, MeshTagsData, ReadMeshData
|
|
15
15
|
from ...utils import check_file_exists
|
|
16
|
-
from .. import DEFAULT_MESH_NAME, FileMode, ReadMode, get_mesh_name
|
|
16
|
+
from .. import DEFAULT_MESH_NAME, FileMode, ReadMode, function_not_found, get_mesh_name
|
|
17
17
|
from .helpers import (
|
|
18
18
|
ADIOSFile,
|
|
19
19
|
adios_to_numpy_dtype,
|
|
20
20
|
check_variable_exists,
|
|
21
|
+
create_adios,
|
|
21
22
|
read_adjacency_list,
|
|
22
23
|
read_array,
|
|
23
24
|
read_local_rows,
|
|
@@ -68,6 +69,29 @@ def mesh_prefix(backend_args: dict[str, Any] | None) -> str:
|
|
|
68
69
|
return "" if name == DEFAULT_MESH_NAME else f"{name}/"
|
|
69
70
|
|
|
70
71
|
|
|
72
|
+
def _function_names(variables, prefix: str) -> set[str]:
|
|
73
|
+
"""Names of the functions of the mesh with ``prefix`` among ADIOS2 ``variables``.
|
|
74
|
+
|
|
75
|
+
Every function has a ``<prefix><name>_time`` variable. The default mesh's prefix is
|
|
76
|
+
empty, so a name holding ``/`` there belongs to another mesh and is left out.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
variables: Names of the variables of a step
|
|
80
|
+
prefix: The mesh's prefix (:func:`mesh_prefix`)
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
The function names
|
|
84
|
+
"""
|
|
85
|
+
suffix = "_time"
|
|
86
|
+
names = set()
|
|
87
|
+
for variable in variables:
|
|
88
|
+
if variable.startswith(prefix) and variable.endswith(suffix):
|
|
89
|
+
name = variable[len(prefix) : -len(suffix)]
|
|
90
|
+
if name and "/" not in name:
|
|
91
|
+
names.add(name)
|
|
92
|
+
return names
|
|
93
|
+
|
|
94
|
+
|
|
71
95
|
def _seek_step(adios_file, variable: str, start: int = 0) -> int:
|
|
72
96
|
"""Advance the reader to the first step at or after ``start`` holding ``variable``.
|
|
73
97
|
|
|
@@ -155,7 +179,7 @@ def read_metadata(
|
|
|
155
179
|
attribute_prefix = _metadata_prefix(kind, name, backend_args)
|
|
156
180
|
wanted = {f"{attribute_prefix}{key}": key for key in METADATA_KEYS}
|
|
157
181
|
metadata: dict[str, Any] = {}
|
|
158
|
-
adios =
|
|
182
|
+
adios = create_adios(comm)
|
|
159
183
|
with ADIOSFile(
|
|
160
184
|
adios=adios,
|
|
161
185
|
filename=filename,
|
|
@@ -194,7 +218,7 @@ def write_attributes(
|
|
|
194
218
|
engine: ADIOS2 engine to use
|
|
195
219
|
"""
|
|
196
220
|
|
|
197
|
-
adios =
|
|
221
|
+
adios = create_adios(comm)
|
|
198
222
|
backend_args = get_default_backend_args(backend_args)
|
|
199
223
|
|
|
200
224
|
with ADIOSFile(
|
|
@@ -230,7 +254,7 @@ def read_attributes(
|
|
|
230
254
|
The attributes
|
|
231
255
|
"""
|
|
232
256
|
check_file_exists(filename)
|
|
233
|
-
adios =
|
|
257
|
+
adios = create_adios(comm)
|
|
234
258
|
backend_args = get_default_backend_args(backend_args)
|
|
235
259
|
with ADIOSFile(
|
|
236
260
|
adios=adios,
|
|
@@ -265,10 +289,13 @@ def read_timestamps(
|
|
|
265
289
|
backend: What backend to use for writing.
|
|
266
290
|
Returns:
|
|
267
291
|
The time-stamps
|
|
292
|
+
|
|
293
|
+
Raises:
|
|
294
|
+
KeyError: If the file does not hold the function on that mesh, naming those it does
|
|
268
295
|
"""
|
|
269
296
|
check_file_exists(filename)
|
|
270
297
|
|
|
271
|
-
adios =
|
|
298
|
+
adios = create_adios(comm)
|
|
272
299
|
backend_args = get_default_backend_args(backend_args)
|
|
273
300
|
prefix = mesh_prefix(backend_args)
|
|
274
301
|
with ADIOSFile(
|
|
@@ -280,9 +307,12 @@ def read_timestamps(
|
|
|
280
307
|
) as adios_file:
|
|
281
308
|
time_name = f"{prefix}{function_name}_time"
|
|
282
309
|
time_stamps = []
|
|
310
|
+
function_names: set[str] = set()
|
|
283
311
|
for _ in range(adios_file.file.Steps()):
|
|
284
312
|
adios_file.file.BeginStep()
|
|
285
|
-
|
|
313
|
+
variables = adios_file.io.AvailableVariables()
|
|
314
|
+
function_names |= _function_names(variables, prefix)
|
|
315
|
+
if time_name in variables.keys():
|
|
286
316
|
arr = adios_file.io.InquireVariable(time_name)
|
|
287
317
|
time_shape = arr.Shape()
|
|
288
318
|
arr.SetSelection([[0], [time_shape[0]]])
|
|
@@ -294,6 +324,10 @@ def read_timestamps(
|
|
|
294
324
|
time_stamps.append(times[0])
|
|
295
325
|
adios_file.file.EndStep()
|
|
296
326
|
|
|
327
|
+
if not time_stamps: # Every write of a function writes its time
|
|
328
|
+
raise function_not_found(
|
|
329
|
+
filename, function_name, get_mesh_name(backend_args), function_names
|
|
330
|
+
)
|
|
297
331
|
return np.array(time_stamps)
|
|
298
332
|
|
|
299
333
|
|
|
@@ -322,7 +356,7 @@ def write_mesh(
|
|
|
322
356
|
|
|
323
357
|
mode = convert_file_mode(mode)
|
|
324
358
|
gdim = mesh.local_geometry.shape[1]
|
|
325
|
-
adios =
|
|
359
|
+
adios = create_adios(comm)
|
|
326
360
|
|
|
327
361
|
# Topology is constant in time and written once. In append mode it may
|
|
328
362
|
# already be present either because this mesh was written at an earlier time
|
|
@@ -441,7 +475,7 @@ def read_mesh_data(
|
|
|
441
475
|
The mesh topology, geometry, UFL domain and partition function
|
|
442
476
|
"""
|
|
443
477
|
|
|
444
|
-
adios =
|
|
478
|
+
adios = create_adios(comm)
|
|
445
479
|
backend_args = get_default_backend_args(backend_args)
|
|
446
480
|
legacy = backend_args.get("legacy", False)
|
|
447
481
|
if legacy:
|
|
@@ -569,7 +603,7 @@ def write_meshtags(
|
|
|
569
603
|
io_name = backend_args.get("io_name", "MeshTagWriter")
|
|
570
604
|
engine = backend_args.get("engine", "BP4")
|
|
571
605
|
prefix = mesh_prefix(backend_args)
|
|
572
|
-
adios =
|
|
606
|
+
adios = create_adios(comm)
|
|
573
607
|
with ADIOSFile(
|
|
574
608
|
adios=adios,
|
|
575
609
|
filename=filename,
|
|
@@ -624,7 +658,7 @@ def read_meshtags_data(
|
|
|
624
658
|
Internal data structure for the mesh tags read from file
|
|
625
659
|
"""
|
|
626
660
|
|
|
627
|
-
adios =
|
|
661
|
+
adios = create_adios(comm)
|
|
628
662
|
backend_args = get_default_backend_args(backend_args)
|
|
629
663
|
io_name = backend_args.get("io_name", "MeshTagsReader")
|
|
630
664
|
engine = backend_args["engine"]
|
|
@@ -754,7 +788,7 @@ def read_dofmap(
|
|
|
754
788
|
|
|
755
789
|
engine = backend_args.get("engine", "BP4")
|
|
756
790
|
|
|
757
|
-
adios =
|
|
791
|
+
adios = create_adios(comm)
|
|
758
792
|
check_file_exists(filename)
|
|
759
793
|
assert isinstance(xdofmap_path, str)
|
|
760
794
|
return read_adjacency_list(adios, comm, filename, dofmap_path, xdofmap_path, engine=engine)
|
|
@@ -788,7 +822,7 @@ def read_dofs(
|
|
|
788
822
|
io_name = backend_args.get("io_name", f"{name}_FunctionReader")
|
|
789
823
|
prefix = mesh_prefix(backend_args)
|
|
790
824
|
# Check that file contains the function to read
|
|
791
|
-
adios =
|
|
825
|
+
adios = create_adios(comm)
|
|
792
826
|
check_file_exists(filename)
|
|
793
827
|
|
|
794
828
|
if not legacy:
|
|
@@ -843,7 +877,7 @@ def read_cell_perms(
|
|
|
843
877
|
.. note::
|
|
844
878
|
No MPI communication is done during this call
|
|
845
879
|
"""
|
|
846
|
-
adios =
|
|
880
|
+
adios = create_adios(comm)
|
|
847
881
|
check_file_exists(filename)
|
|
848
882
|
|
|
849
883
|
# Open ADIOS engine
|
|
@@ -864,7 +898,7 @@ def read_hdf5_array(
|
|
|
864
898
|
group: str,
|
|
865
899
|
backend_args: dict[str, Any] | None = None,
|
|
866
900
|
) -> tuple[np.ndarray, int]:
|
|
867
|
-
adios =
|
|
901
|
+
adios = create_adios(comm)
|
|
868
902
|
"""Read an array from an HDF5 file.
|
|
869
903
|
|
|
870
904
|
Args:
|
|
@@ -908,7 +942,7 @@ def write_function(
|
|
|
908
942
|
io_name = backend_args.get("io_name", "{name}_writer")
|
|
909
943
|
prefix = mesh_prefix(backend_args)
|
|
910
944
|
|
|
911
|
-
adios =
|
|
945
|
+
adios = create_adios(comm)
|
|
912
946
|
cell_permutations_exists = False
|
|
913
947
|
dofmap_exists = False
|
|
914
948
|
XDofmap_exists = False
|
|
@@ -1001,7 +1035,7 @@ def read_format0_checkpoint(
|
|
|
1001
1035
|
The mesh, and for each function in the order of the file the arguments of its
|
|
1002
1036
|
:class:`io4dolfinx.structures.FunctionData` except the name.
|
|
1003
1037
|
"""
|
|
1004
|
-
adios =
|
|
1038
|
+
adios = create_adios(comm)
|
|
1005
1039
|
mesh: MeshData | None = None
|
|
1006
1040
|
cell_permutations = None
|
|
1007
1041
|
functions: list[dict[str, Any]] = []
|
|
@@ -1084,7 +1118,7 @@ def read_legacy_mesh(
|
|
|
1084
1118
|
- Cell type as a string (e.g. "tetrahedron") or None if not found
|
|
1085
1119
|
"""
|
|
1086
1120
|
# Create ADIOS2 reader
|
|
1087
|
-
adios =
|
|
1121
|
+
adios = create_adios(comm)
|
|
1088
1122
|
with ADIOSFile(
|
|
1089
1123
|
adios=adios,
|
|
1090
1124
|
filename=filename,
|
|
@@ -1133,7 +1167,7 @@ def snapshot_checkpoint(
|
|
|
1133
1167
|
backend_args: Arguments to backend
|
|
1134
1168
|
"""
|
|
1135
1169
|
adios_mode = convert_file_mode(mode)
|
|
1136
|
-
adios =
|
|
1170
|
+
adios = create_adios(u.function_space.mesh.comm)
|
|
1137
1171
|
backend_args = {} if backend_args is None else backend_args
|
|
1138
1172
|
io_name = backend_args.get("io_name", "SnapshotCheckPoint")
|
|
1139
1173
|
engine = backend_args.get("engine", "BP4")
|
|
@@ -4,6 +4,7 @@ Helpers reading/writing data with ADIOS2
|
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
+
import contextvars
|
|
7
8
|
import shutil
|
|
8
9
|
from contextlib import contextmanager
|
|
9
10
|
from pathlib import Path
|
|
@@ -23,6 +24,8 @@ adios2 = fenicsx_compat.resolve_adios_scope(adios2)
|
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
__all__ = [
|
|
27
|
+
"force_serial_adios",
|
|
28
|
+
"create_adios",
|
|
26
29
|
"AdiosFile",
|
|
27
30
|
"ADIOSFile",
|
|
28
31
|
"check_variable_exists",
|
|
@@ -44,6 +47,26 @@ adios_to_numpy_dtype = {
|
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
|
|
50
|
+
#: Create ADIOS objects without MPI on every rank, even with ADIOS2 built with MPI. Set by the
|
|
51
|
+
#: adios2-serial backend, see :mod:`io4dolfinx.backends.serial`.
|
|
52
|
+
force_serial_adios = contextvars.ContextVar("force_serial_adios", default=False)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def create_adios(comm: MPI.Comm) -> adios2.ADIOS:
|
|
56
|
+
"""Create an ADIOS object.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
comm: The communicator of the processes opening files with it.
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
An ADIOS object on ``comm``, or one without MPI that opens files on this process
|
|
63
|
+
only, if ADIOS2 is built without MPI or :data:`force_serial_adios` is set.
|
|
64
|
+
"""
|
|
65
|
+
if adios2.is_built_with_mpi and not force_serial_adios.get():
|
|
66
|
+
return adios2.ADIOS(comm)
|
|
67
|
+
return adios2.ADIOS()
|
|
68
|
+
|
|
69
|
+
|
|
47
70
|
class AdiosFile(NamedTuple):
|
|
48
71
|
io: adios2.IO
|
|
49
72
|
file: adios2.Engine
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""The ADIOS2 backend for ADIOS2 built without MPI.
|
|
2
|
+
|
|
3
|
+
Files are read by every process on its own and written through rank 0, see
|
|
4
|
+
:mod:`io4dolfinx.backends.serial`. They are the files of the ADIOS2 backend.
|
|
5
|
+
|
|
6
|
+
SPDX License identifier: MIT
|
|
7
|
+
|
|
8
|
+
Copyright: Jørgen S. Dokken, Simula Research Laboratory
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import functools
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
from mpi4py import MPI
|
|
16
|
+
|
|
17
|
+
import dolfinx
|
|
18
|
+
import numpy as np
|
|
19
|
+
|
|
20
|
+
from ...structures import FunctionData, MeshData, MeshTagsData
|
|
21
|
+
from .. import FileMode
|
|
22
|
+
from ..adios2 import backend as parallel
|
|
23
|
+
from ..adios2.helpers import ADIOSFile, create_adios, force_serial_adios
|
|
24
|
+
from ..serial import gather_function, gather_mesh, gather_meshtags, serial, write_on_root
|
|
25
|
+
|
|
26
|
+
serial_adios = functools.partial(serial, flag=force_serial_adios)
|
|
27
|
+
write_on_root_adios = functools.partial(write_on_root, flag=force_serial_adios)
|
|
28
|
+
|
|
29
|
+
read_mode = parallel.read_mode
|
|
30
|
+
get_default_backend_args = parallel.get_default_backend_args
|
|
31
|
+
convert_file_mode = parallel.convert_file_mode
|
|
32
|
+
|
|
33
|
+
read_metadata = serial_adios(parallel.read_metadata)
|
|
34
|
+
read_attributes = serial_adios(parallel.read_attributes)
|
|
35
|
+
read_timestamps = serial_adios(parallel.read_timestamps)
|
|
36
|
+
read_mesh_data = serial_adios(parallel.read_mesh_data)
|
|
37
|
+
read_meshtags_data = serial_adios(parallel.read_meshtags_data)
|
|
38
|
+
read_dofmap = serial_adios(parallel.read_dofmap)
|
|
39
|
+
read_dofs = serial_adios(parallel.read_dofs)
|
|
40
|
+
read_cell_perms = serial_adios(parallel.read_cell_perms)
|
|
41
|
+
read_hdf5_array = serial_adios(parallel.read_hdf5_array)
|
|
42
|
+
read_legacy_mesh = serial_adios(parallel.read_legacy_mesh)
|
|
43
|
+
read_function_names = parallel.read_function_names
|
|
44
|
+
read_point_data = parallel.read_point_data
|
|
45
|
+
read_cell_data = parallel.read_cell_data
|
|
46
|
+
write_data = parallel.write_data
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def write_attributes(
|
|
50
|
+
filename: Path | str,
|
|
51
|
+
comm: MPI.Comm,
|
|
52
|
+
name: str,
|
|
53
|
+
attributes: dict[str, np.ndarray],
|
|
54
|
+
backend_args: dict[str, Any] | None = None,
|
|
55
|
+
):
|
|
56
|
+
"""Write attributes to file, see :func:`io4dolfinx.backends.adios2.backend.write_attributes`."""
|
|
57
|
+
write_on_root_adios(
|
|
58
|
+
comm,
|
|
59
|
+
attributes,
|
|
60
|
+
lambda d: parallel.write_attributes(filename, MPI.COMM_SELF, name, d, backend_args),
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def write_mesh(
|
|
65
|
+
filename: Path | str,
|
|
66
|
+
comm: MPI.Comm,
|
|
67
|
+
mesh: MeshData,
|
|
68
|
+
backend_args: dict[str, Any] | None = None,
|
|
69
|
+
mode: FileMode = FileMode.write,
|
|
70
|
+
time: float = 0.0,
|
|
71
|
+
):
|
|
72
|
+
"""Write a mesh to file, see :func:`io4dolfinx.backends.adios2.backend.write_mesh`."""
|
|
73
|
+
data = gather_mesh(comm, mesh)
|
|
74
|
+
write_on_root_adios(
|
|
75
|
+
comm,
|
|
76
|
+
data,
|
|
77
|
+
lambda d: parallel.write_mesh(filename, MPI.COMM_SELF, d, backend_args, mode, time),
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def write_meshtags(
|
|
82
|
+
filename: str | Path,
|
|
83
|
+
comm: MPI.Comm,
|
|
84
|
+
data: MeshTagsData,
|
|
85
|
+
backend_args: dict[str, Any] | None = None,
|
|
86
|
+
):
|
|
87
|
+
"""Write mesh tags to file, see :func:`io4dolfinx.backends.adios2.backend.write_meshtags`."""
|
|
88
|
+
tags = gather_meshtags(comm, data)
|
|
89
|
+
write_on_root_adios(
|
|
90
|
+
comm, tags, lambda d: parallel.write_meshtags(filename, MPI.COMM_SELF, d, backend_args)
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def write_function(
|
|
95
|
+
filename: Path,
|
|
96
|
+
comm: MPI.Comm,
|
|
97
|
+
u: FunctionData,
|
|
98
|
+
time: float = 0.0,
|
|
99
|
+
mode: FileMode = FileMode.append,
|
|
100
|
+
backend_args: dict[str, Any] | None = None,
|
|
101
|
+
):
|
|
102
|
+
"""Write a function to file, see :func:`io4dolfinx.backends.adios2.backend.write_function`."""
|
|
103
|
+
data = gather_function(comm, u)
|
|
104
|
+
write_on_root_adios(
|
|
105
|
+
comm,
|
|
106
|
+
data,
|
|
107
|
+
lambda d: parallel.write_function(filename, MPI.COMM_SELF, d, time, mode, backend_args),
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def snapshot_checkpoint(
|
|
112
|
+
filename: Path | str,
|
|
113
|
+
mode: FileMode,
|
|
114
|
+
u: dolfinx.fem.Function,
|
|
115
|
+
backend_args: dict[str, Any] | None,
|
|
116
|
+
):
|
|
117
|
+
"""Create or read a snapshot checkpoint, see
|
|
118
|
+
:func:`io4dolfinx.backends.adios2.backend.snapshot_checkpoint`.
|
|
119
|
+
|
|
120
|
+
Rank 0 writes the dofs of each process as a block of its own, in rank order, so that
|
|
121
|
+
each process reads its block back, as from a file of the ADIOS2 backend.
|
|
122
|
+
"""
|
|
123
|
+
if mode != FileMode.write:
|
|
124
|
+
return serial_adios(parallel.snapshot_checkpoint)(filename, mode, u, backend_args)
|
|
125
|
+
comm = u.function_space.mesh.comm
|
|
126
|
+
dofmap = u.function_space.dofmap
|
|
127
|
+
num_dofs_local = dofmap.index_map.size_local * dofmap.index_map_bs
|
|
128
|
+
blocks = comm.gather(u.x.array[:num_dofs_local].copy(), root=0)
|
|
129
|
+
backend_args = {} if backend_args is None else backend_args
|
|
130
|
+
|
|
131
|
+
def write(blocks: list[np.ndarray]):
|
|
132
|
+
with ADIOSFile(
|
|
133
|
+
adios=create_adios(MPI.COMM_SELF),
|
|
134
|
+
filename=filename,
|
|
135
|
+
mode=convert_file_mode(FileMode.write),
|
|
136
|
+
io_name=backend_args.get("io_name", "SnapshotCheckPoint"),
|
|
137
|
+
engine=backend_args.get("engine", "BP4"),
|
|
138
|
+
) as adios_file:
|
|
139
|
+
adios_file.file.BeginStep()
|
|
140
|
+
dofs = adios_file.io.DefineVariable("dofs", blocks[0], count=[len(blocks[0])])
|
|
141
|
+
for block in blocks:
|
|
142
|
+
dofs.SetSelection([[], [len(block)]])
|
|
143
|
+
adios_file.file.Put(dofs, block, parallel.adios2.Mode.Sync)
|
|
144
|
+
adios_file.file.EndStep()
|
|
145
|
+
|
|
146
|
+
write_on_root_adios(comm, blocks, write)
|