foamlib 0.6.5__tar.gz → 0.6.7__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.
- {foamlib-0.6.5 → foamlib-0.6.7}/PKG-INFO +18 -7
- {foamlib-0.6.5 → foamlib-0.6.7}/README.md +15 -5
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/__init__.py +1 -1
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/_cases/_async.py +3 -3
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/_cases/_subprocess.py +19 -10
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/_cases/_sync.py +0 -4
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/_files/_files.py +11 -11
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/_files/_parsing.py +21 -4
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib.egg-info/PKG-INFO +18 -7
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib.egg-info/requires.txt +4 -1
- {foamlib-0.6.5 → foamlib-0.6.7}/pyproject.toml +5 -2
- {foamlib-0.6.5 → foamlib-0.6.7}/LICENSE.txt +0 -0
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/_cases/__init__.py +0 -0
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/_cases/_base.py +0 -0
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/_cases/_run.py +0 -0
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/_cases/_slurm.py +0 -0
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/_cases/_util.py +0 -0
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/_files/__init__.py +0 -0
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/_files/_base.py +0 -0
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/_files/_io.py +0 -0
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/_files/_serialization.py +0 -0
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/_files/_util.py +0 -0
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib/py.typed +0 -0
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib.egg-info/SOURCES.txt +0 -0
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib.egg-info/dependency_links.txt +0 -0
- {foamlib-0.6.5 → foamlib-0.6.7}/foamlib.egg-info/top_level.txt +0 -0
- {foamlib-0.6.5 → foamlib-0.6.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: foamlib
|
3
|
-
Version: 0.6.
|
3
|
+
Version: 0.6.7
|
4
4
|
Summary: A Python interface for interacting with OpenFOAM
|
5
5
|
Author-email: "Gabriel S. Gerlero" <ggerlero@cimec.unl.edu.ar>
|
6
6
|
Project-URL: Homepage, https://github.com/gerlero/foamlib
|
@@ -30,6 +30,7 @@ Requires-Dist: aioshutil<2,>=1
|
|
30
30
|
Requires-Dist: pyparsing<4,>=3
|
31
31
|
Requires-Dist: typing-extensions<5,>=4; python_version < "3.11"
|
32
32
|
Provides-Extra: numpy
|
33
|
+
Requires-Dist: numpy<3,>=1.25.0; python_version >= "3.10" and extra == "numpy"
|
33
34
|
Requires-Dist: numpy<3,>=1; extra == "numpy"
|
34
35
|
Provides-Extra: lint
|
35
36
|
Requires-Dist: ruff; extra == "lint"
|
@@ -43,7 +44,7 @@ Requires-Dist: foamlib[test]; extra == "typing"
|
|
43
44
|
Requires-Dist: mypy<2,>=1; extra == "typing"
|
44
45
|
Provides-Extra: docs
|
45
46
|
Requires-Dist: foamlib[numpy]; extra == "docs"
|
46
|
-
Requires-Dist: sphinx<9,>=
|
47
|
+
Requires-Dist: sphinx<9,>=5; extra == "docs"
|
47
48
|
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
48
49
|
Provides-Extra: dev
|
49
50
|
Requires-Dist: foamlib[numpy]; extra == "dev"
|
@@ -59,7 +60,9 @@ Requires-Dist: foamlib[docs]; extra == "dev"
|
|
59
60
|
[](https://codecov.io/gh/gerlero/foamlib)
|
60
61
|
[](http://mypy-lang.org/)
|
61
62
|
[](https://github.com/astral-sh/ruff)
|
63
|
+
[](https://github.com/astral-sh/uv)
|
62
64
|
[](https://pypi.org/project/foamlib/)
|
65
|
+
[](https://anaconda.org/conda-forge/foamlib)
|
63
66
|
[](https://pypi.org/project/foamlib/)
|
64
67
|

|
65
68
|
[](https://hub.docker.com/r/microfluidica/foamlib/)
|
@@ -68,19 +71,26 @@ Requires-Dist: foamlib[docs]; extra == "dev"
|
|
68
71
|
|
69
72
|
It offers the following classes:
|
70
73
|
|
71
|
-
* [`FoamFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFile) (and [`FoamFieldFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFieldFile)): read-write access to OpenFOAM configuration and field files as if they were Python `dict`s, using `foamlib`'s own parser. Supports
|
74
|
+
* [`FoamFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFile) (and [`FoamFieldFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFieldFile)): read-write access to OpenFOAM configuration and field files as if they were Python `dict`s, using `foamlib`'s own parser. Supports ASCII and binary field formats (with or without compression).
|
72
75
|
* [`FoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.FoamCase): a class for configuring, running, and accessing the results of OpenFOAM cases.
|
73
76
|
* [`AsyncFoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.AsyncFoamCase): variant of `FoamCase` with asynchronous methods for running multiple cases at once.
|
77
|
+
* [`AsyncSlurmFoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.AsyncSlurmFoamCase): subclass of `AsyncFoamCase` used for running cases on a Slurm cluster.
|
74
78
|
|
75
79
|
## Get started
|
76
80
|
|
77
81
|
### Install
|
78
82
|
|
79
|
-
|
83
|
+
* With [pip](https://pypi.org/project/pip/):
|
80
84
|
|
81
|
-
```bash
|
82
|
-
pip install foamlib
|
83
|
-
```
|
85
|
+
```bash
|
86
|
+
pip install foamlib
|
87
|
+
```
|
88
|
+
|
89
|
+
* With [conda](https://docs.conda.io/en/latest/):
|
90
|
+
|
91
|
+
```bash
|
92
|
+
conda install -c conda-forge foamlib
|
93
|
+
```
|
84
94
|
|
85
95
|
### Clone a case
|
86
96
|
|
@@ -164,6 +174,7 @@ from foamlib import AsyncFoamCase
|
|
164
174
|
from scipy.optimize import differential_evolution
|
165
175
|
|
166
176
|
base = AsyncFoamCase(Path(os.environ["FOAM_TUTORIALS"]) / "incompressible/simpleFoam/pitzDaily")
|
177
|
+
# Replace with `AsyncSlurmFoamCase` if on a cluster and you want cases to be run as Slurm jobs
|
167
178
|
|
168
179
|
async def cost(x):
|
169
180
|
async with base.clone() as clone:
|
@@ -5,7 +5,9 @@
|
|
5
5
|
[](https://codecov.io/gh/gerlero/foamlib)
|
6
6
|
[](http://mypy-lang.org/)
|
7
7
|
[](https://github.com/astral-sh/ruff)
|
8
|
+
[](https://github.com/astral-sh/uv)
|
8
9
|
[](https://pypi.org/project/foamlib/)
|
10
|
+
[](https://anaconda.org/conda-forge/foamlib)
|
9
11
|
[](https://pypi.org/project/foamlib/)
|
10
12
|

|
11
13
|
[](https://hub.docker.com/r/microfluidica/foamlib/)
|
@@ -14,19 +16,26 @@
|
|
14
16
|
|
15
17
|
It offers the following classes:
|
16
18
|
|
17
|
-
* [`FoamFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFile) (and [`FoamFieldFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFieldFile)): read-write access to OpenFOAM configuration and field files as if they were Python `dict`s, using `foamlib`'s own parser. Supports
|
19
|
+
* [`FoamFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFile) (and [`FoamFieldFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFieldFile)): read-write access to OpenFOAM configuration and field files as if they were Python `dict`s, using `foamlib`'s own parser. Supports ASCII and binary field formats (with or without compression).
|
18
20
|
* [`FoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.FoamCase): a class for configuring, running, and accessing the results of OpenFOAM cases.
|
19
21
|
* [`AsyncFoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.AsyncFoamCase): variant of `FoamCase` with asynchronous methods for running multiple cases at once.
|
22
|
+
* [`AsyncSlurmFoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.AsyncSlurmFoamCase): subclass of `AsyncFoamCase` used for running cases on a Slurm cluster.
|
20
23
|
|
21
24
|
## Get started
|
22
25
|
|
23
26
|
### Install
|
24
27
|
|
25
|
-
|
28
|
+
* With [pip](https://pypi.org/project/pip/):
|
26
29
|
|
27
|
-
```bash
|
28
|
-
pip install foamlib
|
29
|
-
```
|
30
|
+
```bash
|
31
|
+
pip install foamlib
|
32
|
+
```
|
33
|
+
|
34
|
+
* With [conda](https://docs.conda.io/en/latest/):
|
35
|
+
|
36
|
+
```bash
|
37
|
+
conda install -c conda-forge foamlib
|
38
|
+
```
|
30
39
|
|
31
40
|
### Clone a case
|
32
41
|
|
@@ -110,6 +119,7 @@ from foamlib import AsyncFoamCase
|
|
110
119
|
from scipy.optimize import differential_evolution
|
111
120
|
|
112
121
|
base = AsyncFoamCase(Path(os.environ["FOAM_TUTORIALS"]) / "incompressible/simpleFoam/pitzDaily")
|
122
|
+
# Replace with `AsyncSlurmFoamCase` if on a cluster and you want cases to be run as Slurm jobs
|
113
123
|
|
114
124
|
async def cost(x):
|
115
125
|
async with base.clone() as clone:
|
@@ -101,7 +101,7 @@ class AsyncFoamCase(FoamCaseRunBase):
|
|
101
101
|
async def _rmtree(
|
102
102
|
path: Union["os.PathLike[str]", str], ignore_errors: bool = False
|
103
103
|
) -> None:
|
104
|
-
await aioshutil.rmtree(path, ignore_errors=ignore_errors)
|
104
|
+
await aioshutil.rmtree(path, ignore_errors=ignore_errors)
|
105
105
|
|
106
106
|
@staticmethod
|
107
107
|
async def _copytree(
|
@@ -188,7 +188,7 @@ class AsyncFoamCase(FoamCaseRunBase):
|
|
188
188
|
@asynccontextmanager
|
189
189
|
async def copy(
|
190
190
|
self, dst: Optional[Union["os.PathLike[str]", str]] = None
|
191
|
-
) ->
|
191
|
+
) -> AsyncGenerator[Self, None]:
|
192
192
|
"""
|
193
193
|
Make a copy of this case.
|
194
194
|
|
@@ -209,7 +209,7 @@ class AsyncFoamCase(FoamCaseRunBase):
|
|
209
209
|
@asynccontextmanager
|
210
210
|
async def clone(
|
211
211
|
self, dst: Optional[Union["os.PathLike[str]", str]] = None
|
212
|
-
) ->
|
212
|
+
) -> AsyncGenerator[Self, None]:
|
213
213
|
"""
|
214
214
|
Clone this case (make a clean copy).
|
215
215
|
|
@@ -2,6 +2,7 @@ import asyncio
|
|
2
2
|
import os
|
3
3
|
import subprocess
|
4
4
|
import sys
|
5
|
+
from io import BytesIO
|
5
6
|
from typing import IO, Optional, Union
|
6
7
|
|
7
8
|
if sys.version_info >= (3, 9):
|
@@ -48,22 +49,26 @@ def run_sync(
|
|
48
49
|
shell=isinstance(cmd, str),
|
49
50
|
)
|
50
51
|
|
51
|
-
error = b""
|
52
|
-
|
53
52
|
if stderr == STDOUT:
|
54
53
|
stderr = stdout
|
55
54
|
if stderr not in (PIPE, DEVNULL):
|
55
|
+
stderr_copy = BytesIO()
|
56
|
+
|
56
57
|
assert not isinstance(stderr, int)
|
57
58
|
if stderr is None:
|
58
59
|
stderr = sys.stderr.buffer
|
59
60
|
|
60
61
|
assert proc.stderr is not None
|
61
62
|
for line in proc.stderr:
|
62
|
-
error += line
|
63
63
|
stderr.write(line)
|
64
|
+
stderr_copy.write(line)
|
65
|
+
|
66
|
+
output, _ = proc.communicate()
|
67
|
+
assert not _
|
68
|
+
error = stderr_copy.getvalue()
|
69
|
+
else:
|
70
|
+
output, error = proc.communicate()
|
64
71
|
|
65
|
-
output, _ = proc.communicate()
|
66
|
-
assert not _
|
67
72
|
assert proc.returncode is not None
|
68
73
|
|
69
74
|
if check and proc.returncode != 0:
|
@@ -108,22 +113,26 @@ async def run_async(
|
|
108
113
|
stderr=PIPE,
|
109
114
|
)
|
110
115
|
|
111
|
-
error = b""
|
112
|
-
|
113
116
|
if stderr == STDOUT:
|
114
117
|
stderr = stdout
|
115
118
|
if stderr not in (PIPE, DEVNULL):
|
119
|
+
stderr_copy = BytesIO()
|
120
|
+
|
116
121
|
assert not isinstance(stderr, int)
|
117
122
|
if stderr is None:
|
118
123
|
stderr = sys.stderr.buffer
|
119
124
|
|
120
125
|
assert proc.stderr is not None
|
121
126
|
async for line in proc.stderr:
|
122
|
-
error += line
|
123
127
|
stderr.write(line)
|
128
|
+
stderr_copy.write(line)
|
129
|
+
|
130
|
+
output, _ = await proc.communicate()
|
131
|
+
assert not _
|
132
|
+
error = stderr_copy.getvalue()
|
133
|
+
else:
|
134
|
+
output, error = await proc.communicate()
|
124
135
|
|
125
|
-
output, _ = await proc.communicate()
|
126
|
-
assert not _
|
127
136
|
assert proc.returncode is not None
|
128
137
|
|
129
138
|
if check and proc.returncode != 0:
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import os
|
2
2
|
import shutil
|
3
3
|
import sys
|
4
|
-
from pathlib import Path
|
5
4
|
from types import TracebackType
|
6
5
|
from typing import Any, Callable, Optional, Type, Union, overload
|
7
6
|
|
@@ -49,9 +48,6 @@ class FoamCase(FoamCaseRunBase):
|
|
49
48
|
|
50
49
|
return calls.value
|
51
50
|
|
52
|
-
def __init__(self, path: Union["os.PathLike[str]", str] = Path()):
|
53
|
-
super().__init__(path)
|
54
|
-
|
55
51
|
@staticmethod
|
56
52
|
def _run(
|
57
53
|
cmd: Union[Sequence[Union[str, "os.PathLike[str]"]], str],
|
@@ -86,7 +86,7 @@ class FoamFile(
|
|
86
86
|
|
87
87
|
def as_dict(self) -> FoamFileBase._Dict:
|
88
88
|
"""Return a nested dict representation of the dictionary."""
|
89
|
-
ret = self._file.as_dict()
|
89
|
+
ret = self._file.as_dict(include_header=True)
|
90
90
|
|
91
91
|
for k in self._keywords:
|
92
92
|
assert isinstance(ret, dict)
|
@@ -294,15 +294,10 @@ class FoamFile(
|
|
294
294
|
|
295
295
|
def _iter(self, keywords: Tuple[str, ...] = ()) -> Iterator[Optional[str]]:
|
296
296
|
_, parsed = self._read()
|
297
|
-
|
298
|
-
yield from (
|
299
|
-
k[-1] if k else None
|
300
|
-
for k in parsed
|
301
|
-
if k != ("FoamFile",) and k[:-1] == keywords
|
302
|
-
)
|
297
|
+
yield from (k[-1] if k else None for k in parsed if k[:-1] == keywords)
|
303
298
|
|
304
299
|
def __iter__(self) -> Iterator[Optional[str]]:
|
305
|
-
|
300
|
+
yield from (k for k in self._iter() if k != "FoamFile")
|
306
301
|
|
307
302
|
def __contains__(self, keywords: object) -> bool:
|
308
303
|
if not keywords:
|
@@ -328,11 +323,16 @@ class FoamFile(
|
|
328
323
|
def __fspath__(self) -> str:
|
329
324
|
return str(self.path)
|
330
325
|
|
331
|
-
def as_dict(self) -> FoamFileBase._File:
|
332
|
-
"""
|
326
|
+
def as_dict(self, *, include_header: bool = False) -> FoamFileBase._File:
|
327
|
+
"""
|
328
|
+
Return a nested dict representation of the file.
|
329
|
+
|
330
|
+
:param include_header: Whether to include the "FoamFile" header in the output.
|
331
|
+
"""
|
333
332
|
_, parsed = self._read()
|
334
333
|
d = parsed.as_dict()
|
335
|
-
|
334
|
+
if not include_header:
|
335
|
+
d.pop("FoamFile", None)
|
336
336
|
return d
|
337
337
|
|
338
338
|
|
@@ -95,18 +95,35 @@ def _unpack_binary_field(
|
|
95
95
|
return [all]
|
96
96
|
|
97
97
|
|
98
|
+
_IDENTCHARS = identchars + "$"
|
99
|
+
_IDENTBODYCHARS = (
|
100
|
+
printables.replace(";", "")
|
101
|
+
.replace("{", "")
|
102
|
+
.replace("}", "")
|
103
|
+
.replace("[", "")
|
104
|
+
.replace("]", "")
|
105
|
+
)
|
106
|
+
|
98
107
|
_SWITCH = (
|
99
|
-
Keyword("yes"
|
108
|
+
Keyword("yes", _IDENTBODYCHARS)
|
109
|
+
| Keyword("true", _IDENTBODYCHARS)
|
110
|
+
| Keyword("on", _IDENTBODYCHARS)
|
111
|
+
| Keyword("y", _IDENTBODYCHARS)
|
112
|
+
| Keyword("t", _IDENTBODYCHARS)
|
100
113
|
).set_parse_action(lambda: True) | (
|
101
|
-
Keyword("no"
|
114
|
+
Keyword("no", _IDENTBODYCHARS)
|
115
|
+
| Keyword("false", _IDENTBODYCHARS)
|
116
|
+
| Keyword("off", _IDENTBODYCHARS)
|
117
|
+
| Keyword("n", _IDENTBODYCHARS)
|
118
|
+
| Keyword("f", _IDENTBODYCHARS)
|
102
119
|
).set_parse_action(lambda: False)
|
103
120
|
_DIMENSIONS = (
|
104
121
|
Literal("[").suppress() + common.number[0, 7] + Literal("]").suppress()
|
105
122
|
).set_parse_action(lambda tks: FoamFileBase.DimensionSet(*tks))
|
106
123
|
_TENSOR = _list_of(common.number) | common.number
|
107
124
|
_IDENTIFIER = Combine(
|
108
|
-
Word(
|
109
|
-
+ Opt(Literal("(") + Word(
|
125
|
+
Word(_IDENTCHARS, _IDENTBODYCHARS, exclude_chars="()")
|
126
|
+
+ Opt(Literal("(") + Word(_IDENTBODYCHARS, exclude_chars="()") + Literal(")"))
|
110
127
|
)
|
111
128
|
_DIMENSIONED = (Opt(_IDENTIFIER) + _DIMENSIONS + _TENSOR).set_parse_action(
|
112
129
|
lambda tks: FoamFileBase.Dimensioned(*reversed(tks.as_list()))
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: foamlib
|
3
|
-
Version: 0.6.
|
3
|
+
Version: 0.6.7
|
4
4
|
Summary: A Python interface for interacting with OpenFOAM
|
5
5
|
Author-email: "Gabriel S. Gerlero" <ggerlero@cimec.unl.edu.ar>
|
6
6
|
Project-URL: Homepage, https://github.com/gerlero/foamlib
|
@@ -30,6 +30,7 @@ Requires-Dist: aioshutil<2,>=1
|
|
30
30
|
Requires-Dist: pyparsing<4,>=3
|
31
31
|
Requires-Dist: typing-extensions<5,>=4; python_version < "3.11"
|
32
32
|
Provides-Extra: numpy
|
33
|
+
Requires-Dist: numpy<3,>=1.25.0; python_version >= "3.10" and extra == "numpy"
|
33
34
|
Requires-Dist: numpy<3,>=1; extra == "numpy"
|
34
35
|
Provides-Extra: lint
|
35
36
|
Requires-Dist: ruff; extra == "lint"
|
@@ -43,7 +44,7 @@ Requires-Dist: foamlib[test]; extra == "typing"
|
|
43
44
|
Requires-Dist: mypy<2,>=1; extra == "typing"
|
44
45
|
Provides-Extra: docs
|
45
46
|
Requires-Dist: foamlib[numpy]; extra == "docs"
|
46
|
-
Requires-Dist: sphinx<9,>=
|
47
|
+
Requires-Dist: sphinx<9,>=5; extra == "docs"
|
47
48
|
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
48
49
|
Provides-Extra: dev
|
49
50
|
Requires-Dist: foamlib[numpy]; extra == "dev"
|
@@ -59,7 +60,9 @@ Requires-Dist: foamlib[docs]; extra == "dev"
|
|
59
60
|
[](https://codecov.io/gh/gerlero/foamlib)
|
60
61
|
[](http://mypy-lang.org/)
|
61
62
|
[](https://github.com/astral-sh/ruff)
|
63
|
+
[](https://github.com/astral-sh/uv)
|
62
64
|
[](https://pypi.org/project/foamlib/)
|
65
|
+
[](https://anaconda.org/conda-forge/foamlib)
|
63
66
|
[](https://pypi.org/project/foamlib/)
|
64
67
|

|
65
68
|
[](https://hub.docker.com/r/microfluidica/foamlib/)
|
@@ -68,19 +71,26 @@ Requires-Dist: foamlib[docs]; extra == "dev"
|
|
68
71
|
|
69
72
|
It offers the following classes:
|
70
73
|
|
71
|
-
* [`FoamFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFile) (and [`FoamFieldFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFieldFile)): read-write access to OpenFOAM configuration and field files as if they were Python `dict`s, using `foamlib`'s own parser. Supports
|
74
|
+
* [`FoamFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFile) (and [`FoamFieldFile`](https://foamlib.readthedocs.io/en/stable/files.html#foamlib.FoamFieldFile)): read-write access to OpenFOAM configuration and field files as if they were Python `dict`s, using `foamlib`'s own parser. Supports ASCII and binary field formats (with or without compression).
|
72
75
|
* [`FoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.FoamCase): a class for configuring, running, and accessing the results of OpenFOAM cases.
|
73
76
|
* [`AsyncFoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.AsyncFoamCase): variant of `FoamCase` with asynchronous methods for running multiple cases at once.
|
77
|
+
* [`AsyncSlurmFoamCase`](https://foamlib.readthedocs.io/en/stable/cases.html#foamlib.AsyncSlurmFoamCase): subclass of `AsyncFoamCase` used for running cases on a Slurm cluster.
|
74
78
|
|
75
79
|
## Get started
|
76
80
|
|
77
81
|
### Install
|
78
82
|
|
79
|
-
|
83
|
+
* With [pip](https://pypi.org/project/pip/):
|
80
84
|
|
81
|
-
```bash
|
82
|
-
pip install foamlib
|
83
|
-
```
|
85
|
+
```bash
|
86
|
+
pip install foamlib
|
87
|
+
```
|
88
|
+
|
89
|
+
* With [conda](https://docs.conda.io/en/latest/):
|
90
|
+
|
91
|
+
```bash
|
92
|
+
conda install -c conda-forge foamlib
|
93
|
+
```
|
84
94
|
|
85
95
|
### Clone a case
|
86
96
|
|
@@ -164,6 +174,7 @@ from foamlib import AsyncFoamCase
|
|
164
174
|
from scipy.optimize import differential_evolution
|
165
175
|
|
166
176
|
base = AsyncFoamCase(Path(os.environ["FOAM_TUTORIALS"]) / "incompressible/simpleFoam/pitzDaily")
|
177
|
+
# Replace with `AsyncSlurmFoamCase` if on a cluster and you want cases to be run as Slurm jobs
|
167
178
|
|
168
179
|
async def cost(x):
|
169
180
|
async with base.clone() as clone:
|
@@ -13,7 +13,7 @@ foamlib[docs]
|
|
13
13
|
|
14
14
|
[docs]
|
15
15
|
foamlib[numpy]
|
16
|
-
sphinx<9,>=
|
16
|
+
sphinx<9,>=5
|
17
17
|
sphinx_rtd_theme
|
18
18
|
|
19
19
|
[lint]
|
@@ -22,6 +22,9 @@ ruff
|
|
22
22
|
[numpy]
|
23
23
|
numpy<3,>=1
|
24
24
|
|
25
|
+
[numpy:python_version >= "3.10"]
|
26
|
+
numpy<3,>=1.25.0
|
27
|
+
|
25
28
|
[test]
|
26
29
|
foamlib[numpy]
|
27
30
|
pytest<9,>=7
|
@@ -37,7 +37,10 @@ dependencies = [
|
|
37
37
|
dynamic = ["version"]
|
38
38
|
|
39
39
|
[project.optional-dependencies]
|
40
|
-
numpy = [
|
40
|
+
numpy = [
|
41
|
+
"numpy>=1.25.0,<3; python_version>='3.10'",
|
42
|
+
"numpy>=1,<3"
|
43
|
+
]
|
41
44
|
lint = ["ruff"]
|
42
45
|
test = [
|
43
46
|
"foamlib[numpy]",
|
@@ -51,7 +54,7 @@ typing = [
|
|
51
54
|
]
|
52
55
|
docs = [
|
53
56
|
"foamlib[numpy]",
|
54
|
-
"sphinx>=
|
57
|
+
"sphinx>=5,<9",
|
55
58
|
"sphinx_rtd_theme",
|
56
59
|
]
|
57
60
|
dev = [
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|