foamlib 0.4.4__py3-none-any.whl → 0.5.1__py3-none-any.whl
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/__init__.py +1 -3
- foamlib/_cases/__init__.py +1 -2
- foamlib/_cases/_async.py +112 -61
- foamlib/_cases/_base.py +3 -253
- foamlib/_cases/_recipes.py +299 -0
- foamlib/_cases/_subprocess.py +86 -0
- foamlib/_cases/_sync.py +100 -46
- foamlib/_cases/_util.py +38 -24
- foamlib/_files/_files.py +4 -8
- foamlib/_files/_serialization.py +1 -1
- {foamlib-0.4.4.dist-info → foamlib-0.5.1.dist-info}/METADATA +29 -1
- foamlib-0.5.1.dist-info/RECORD +21 -0
- foamlib-0.4.4.dist-info/RECORD +0 -19
- /foamlib/{_util.py → _files/_util.py} +0 -0
- {foamlib-0.4.4.dist-info → foamlib-0.5.1.dist-info}/LICENSE.txt +0 -0
- {foamlib-0.4.4.dist-info → foamlib-0.5.1.dist-info}/WHEEL +0 -0
- {foamlib-0.4.4.dist-info → foamlib-0.5.1.dist-info}/top_level.txt +0 -0
foamlib/_files/_files.py
CHANGED
@@ -16,10 +16,10 @@ if sys.version_info >= (3, 11):
|
|
16
16
|
else:
|
17
17
|
from typing_extensions import Self
|
18
18
|
|
19
|
-
from .._util import is_sequence
|
20
19
|
from ._base import FoamFileBase
|
21
20
|
from ._io import _FoamFileIO
|
22
21
|
from ._serialization import Kind, dumpb
|
22
|
+
from ._util import is_sequence
|
23
23
|
|
24
24
|
try:
|
25
25
|
import numpy as np
|
@@ -105,13 +105,9 @@ class FoamFile(
|
|
105
105
|
"""
|
106
106
|
Create the file.
|
107
107
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
If False (the default), raise a FileExistsError if the file already exists.
|
112
|
-
If True, do nothing if the file already exists.
|
113
|
-
parents : bool, optional
|
114
|
-
If True, also create parent directories as needed.
|
108
|
+
:param exist_ok: If False, raise a FileExistsError if the file already exists.
|
109
|
+
|
110
|
+
:param parents: If True, also create parent directories as needed.
|
115
111
|
"""
|
116
112
|
if self.path.exists():
|
117
113
|
if not exist_ok:
|
foamlib/_files/_serialization.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: foamlib
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.5.1
|
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
|
@@ -19,6 +19,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.10
|
20
20
|
Classifier: Programming Language :: Python :: 3.11
|
21
21
|
Classifier: Programming Language :: Python :: 3.12
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
22
23
|
Classifier: Topic :: Scientific/Engineering
|
23
24
|
Classifier: Topic :: Software Development
|
24
25
|
Classifier: Typing :: Typed
|
@@ -123,6 +124,14 @@ my_pitz.clean()
|
|
123
124
|
my_pitz.control_dict["writeInterval"] = 10
|
124
125
|
```
|
125
126
|
|
127
|
+
### Make multiple file reads and writes in a single go
|
128
|
+
|
129
|
+
```python
|
130
|
+
with my_pitz.fv_schemes as f:
|
131
|
+
f["gradSchemes"]["default"] = f["divSchemes"]["default"]
|
132
|
+
f["snGradSchemes"]["default"] = "uncorrected"
|
133
|
+
```
|
134
|
+
|
126
135
|
### Run a case asynchronously
|
127
136
|
|
128
137
|
```python
|
@@ -146,6 +155,25 @@ U = FoamFieldFile(Path(my_pitz) / "0/U")
|
|
146
155
|
print(U.internal_field)
|
147
156
|
```
|
148
157
|
|
158
|
+
### Run an optimization loop in parallel
|
159
|
+
|
160
|
+
```python
|
161
|
+
import os
|
162
|
+
from pathlib import Path
|
163
|
+
from foamlib import AsyncFoamCase
|
164
|
+
from scipy.optimize import differential_evolution
|
165
|
+
|
166
|
+
base = AsyncFoamCase(Path(os.environ["FOAM_TUTORIALS"]) / "incompressible/simpleFoam/pitzDaily")
|
167
|
+
|
168
|
+
async def cost(x):
|
169
|
+
async with base.clone() as clone:
|
170
|
+
clone[0]["U"].boundary_field["inlet"].value = [x[0], 0, 0]
|
171
|
+
await clone.run()
|
172
|
+
return abs(clone[-1]["U"].internal_field[0][0])
|
173
|
+
|
174
|
+
result = differential_evolution(cost, bounds=[(-1, 1)], workers=AsyncFoamCase.map, polish=False)
|
175
|
+
```
|
176
|
+
|
149
177
|
## Documentation
|
150
178
|
|
151
179
|
For more information, check out the [documentation](https://foamlib.readthedocs.io/).
|
@@ -0,0 +1,21 @@
|
|
1
|
+
foamlib/__init__.py,sha256=bRzkPtbKy1RniCL9eYinI6Yc8g8utDoXrPV6hFimMZY,392
|
2
|
+
foamlib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
foamlib/_cases/__init__.py,sha256=C0mpRu7c-X-4uVMKmVrZhwIyhBNyvUoCv0o-BQ72RC0,236
|
4
|
+
foamlib/_cases/_async.py,sha256=um1nrAjGcT8Vp1hz8XvC_87xVBjfeU3MrpnuzAHN5GY,8251
|
5
|
+
foamlib/_cases/_base.py,sha256=1CUkkK4afBxDgP79dmho97WJdj-GLgYhnrCSf_52Eao,6604
|
6
|
+
foamlib/_cases/_recipes.py,sha256=UTFnVuTvEf-9wn-Fr30a9wOOmyOxvWeDhbqBhdtbhzA,9692
|
7
|
+
foamlib/_cases/_subprocess.py,sha256=CfUy_LrqLnMLR9FHINqInCd3soN6eYvonwZ30epiLu8,2234
|
8
|
+
foamlib/_cases/_sync.py,sha256=R32Ea4BTOPq-x9OIndObcYZACF8e0RnzB4TywNvDxbA,6733
|
9
|
+
foamlib/_cases/_util.py,sha256=BpPW_91bFLzV3b4r50u-2pGMR3tfQQfY2xqToOHCUBk,1204
|
10
|
+
foamlib/_files/__init__.py,sha256=-UqB9YTH6mrJfXCX00kPTAAY20XG64u1MGPw_1ewLVs,148
|
11
|
+
foamlib/_files/_base.py,sha256=zaFDjLE6jB7WtGWk8hfKusjLtlGu6CZV16AHJpRUibs,1929
|
12
|
+
foamlib/_files/_files.py,sha256=6Fdrc0lksFK99i1a6wEsBi-BtYgSQnUc5s10h2LQ9ew,16091
|
13
|
+
foamlib/_files/_io.py,sha256=f_tYI7AqaFsQ8mtK__fEoIUqpYb3YmrI8X5D8updmNM,2084
|
14
|
+
foamlib/_files/_parsing.py,sha256=8V2CKZ45mKE3f9fP8lAfexIdhPGrq7elIZkpBkkGB6Q,8773
|
15
|
+
foamlib/_files/_serialization.py,sha256=pb8_cIVgRhGS_ZV2p3x8p5_lK1SS6xzQHscAYYuOgFY,3407
|
16
|
+
foamlib/_files/_util.py,sha256=UMzXmTFgvbp46w6k3oEZJoYC98pFgEK6LN5uLOwrlCg,397
|
17
|
+
foamlib-0.5.1.dist-info/LICENSE.txt,sha256=5Dte9TUnLZzPRs4NQzl-Jc2-Ljd-t_v0ZR5Ng5r0UsY,35131
|
18
|
+
foamlib-0.5.1.dist-info/METADATA,sha256=4Fq_okfGu-zY0IGrcUCD5IuuJxAESwNtr0EgXD0NzF8,6338
|
19
|
+
foamlib-0.5.1.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
20
|
+
foamlib-0.5.1.dist-info/top_level.txt,sha256=ZdVYtetXGwPwyfL-WhlhbTFQGAwKX5P_gXxtH9JYFPI,8
|
21
|
+
foamlib-0.5.1.dist-info/RECORD,,
|
foamlib-0.4.4.dist-info/RECORD
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
foamlib/__init__.py,sha256=r8VZ1cNvef7NfWWxf7GzPuveJO3LrXVwrF5pwgok-eg,446
|
2
|
-
foamlib/_util.py,sha256=UMzXmTFgvbp46w6k3oEZJoYC98pFgEK6LN5uLOwrlCg,397
|
3
|
-
foamlib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
foamlib/_cases/__init__.py,sha256=xnQpR64EvFtCh07qnSz7kjQ1IhJXjRDwaZWwQGZhGv4,280
|
5
|
-
foamlib/_cases/_async.py,sha256=WgEunau8GvkI-k4amS98Uxz8O0fZBxLWqzUY3uiAmQQ,6345
|
6
|
-
foamlib/_cases/_base.py,sha256=4sndDYfXPWhkSel41e8d00xX3PX22wMrYniA_zb0luo,14958
|
7
|
-
foamlib/_cases/_sync.py,sha256=S-9-TOK7PTC3NMKgIdvKWTn4fS34FPccedvm-lpjpH8,5037
|
8
|
-
foamlib/_cases/_util.py,sha256=v6sHxHCEgagsVuup0S1xJW-x9py5xj3bUye8PiFfb3o,925
|
9
|
-
foamlib/_files/__init__.py,sha256=-UqB9YTH6mrJfXCX00kPTAAY20XG64u1MGPw_1ewLVs,148
|
10
|
-
foamlib/_files/_base.py,sha256=zaFDjLE6jB7WtGWk8hfKusjLtlGu6CZV16AHJpRUibs,1929
|
11
|
-
foamlib/_files/_files.py,sha256=-3mDRIsaQaxHF74q0Zfzlrhfieb7w_EPOFScSx8wRPE,16245
|
12
|
-
foamlib/_files/_io.py,sha256=f_tYI7AqaFsQ8mtK__fEoIUqpYb3YmrI8X5D8updmNM,2084
|
13
|
-
foamlib/_files/_parsing.py,sha256=8V2CKZ45mKE3f9fP8lAfexIdhPGrq7elIZkpBkkGB6Q,8773
|
14
|
-
foamlib/_files/_serialization.py,sha256=3yb9fgjCpDoRfZoLsbZaIFrkZ3vGBzleFRw6IbaZuuY,3408
|
15
|
-
foamlib-0.4.4.dist-info/LICENSE.txt,sha256=5Dte9TUnLZzPRs4NQzl-Jc2-Ljd-t_v0ZR5Ng5r0UsY,35131
|
16
|
-
foamlib-0.4.4.dist-info/METADATA,sha256=i9qq7ZU7oFhmn1BO0rz-53wueFfOvEziP4am3x3qBA4,5496
|
17
|
-
foamlib-0.4.4.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
18
|
-
foamlib-0.4.4.dist-info/top_level.txt,sha256=ZdVYtetXGwPwyfL-WhlhbTFQGAwKX5P_gXxtH9JYFPI,8
|
19
|
-
foamlib-0.4.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|