foamlib 0.6.8__tar.gz → 0.6.10__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.
Files changed (27) hide show
  1. {foamlib-0.6.8 → foamlib-0.6.10}/PKG-INFO +1 -1
  2. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/__init__.py +1 -1
  3. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/_files/_files.py +14 -6
  4. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/_files/_serialization.py +18 -18
  5. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib.egg-info/PKG-INFO +1 -1
  6. {foamlib-0.6.8 → foamlib-0.6.10}/LICENSE.txt +0 -0
  7. {foamlib-0.6.8 → foamlib-0.6.10}/README.md +0 -0
  8. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/_cases/__init__.py +0 -0
  9. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/_cases/_async.py +0 -0
  10. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/_cases/_base.py +0 -0
  11. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/_cases/_run.py +0 -0
  12. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/_cases/_slurm.py +0 -0
  13. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/_cases/_subprocess.py +0 -0
  14. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/_cases/_sync.py +0 -0
  15. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/_cases/_util.py +0 -0
  16. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/_files/__init__.py +0 -0
  17. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/_files/_base.py +0 -0
  18. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/_files/_io.py +0 -0
  19. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/_files/_parsing.py +0 -0
  20. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/_files/_util.py +0 -0
  21. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib/py.typed +0 -0
  22. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib.egg-info/SOURCES.txt +0 -0
  23. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib.egg-info/dependency_links.txt +0 -0
  24. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib.egg-info/requires.txt +0 -0
  25. {foamlib-0.6.8 → foamlib-0.6.10}/foamlib.egg-info/top_level.txt +0 -0
  26. {foamlib-0.6.8 → foamlib-0.6.10}/pyproject.toml +0 -0
  27. {foamlib-0.6.8 → foamlib-0.6.10}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: foamlib
3
- Version: 0.6.8
3
+ Version: 0.6.10
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
@@ -1,6 +1,6 @@
1
1
  """A Python interface for interacting with OpenFOAM."""
2
2
 
3
- __version__ = "0.6.8"
3
+ __version__ = "0.6.10"
4
4
 
5
5
  from ._cases import (
6
6
  AsyncFoamCase,
@@ -13,7 +13,7 @@ else:
13
13
 
14
14
  from ._base import FoamFileBase
15
15
  from ._io import FoamFileIO
16
- from ._serialization import Kind, dumpb
16
+ from ._serialization import Kind, dumps
17
17
  from ._util import is_sequence
18
18
 
19
19
  if TYPE_CHECKING:
@@ -202,7 +202,11 @@ class FoamFile(
202
202
  if keywords == ("internalField",) or (
203
203
  len(keywords) == 3
204
204
  and keywords[0] == "boundaryField"
205
- and keywords[2] == "value"
205
+ and (
206
+ keywords[2] in ("value", "gradient")
207
+ or keywords[2].endswith("Value")
208
+ or keywords[2].endswith("Gradient")
209
+ )
206
210
  ):
207
211
  kind = Kind.BINARY_FIELD if self.format == "binary" else Kind.FIELD
208
212
  elif keywords == ("dimensions",):
@@ -251,7 +255,7 @@ class FoamFile(
251
255
  self._write(
252
256
  before
253
257
  + indentation
254
- + dumpb(keywords[-1])
258
+ + dumps(keywords[-1])
255
259
  + b"\n"
256
260
  + indentation
257
261
  + b"{\n"
@@ -267,15 +271,15 @@ class FoamFile(
267
271
  self._write(
268
272
  before
269
273
  + indentation
270
- + dumpb(keywords[-1])
274
+ + dumps(keywords[-1])
271
275
  + b" "
272
- + dumpb(data, kind=kind)
276
+ + dumps(data, kind=kind)
273
277
  + b";"
274
278
  + after
275
279
  )
276
280
 
277
281
  else:
278
- self._write(before + dumpb(data, kind=kind) + after)
282
+ self._write(before + dumps(data, kind=kind) + after)
279
283
 
280
284
  def __delitem__(self, keywords: Optional[Union[str, Tuple[str, ...]]]) -> None:
281
285
  if not keywords:
@@ -468,3 +472,7 @@ class FoamFieldFile(FoamFile):
468
472
  assert not isinstance(ret, FoamFile.SubDict)
469
473
  raise TypeError("boundaryField is not a dictionary")
470
474
  return ret
475
+
476
+ @boundary_field.setter
477
+ def boundary_field(self, value: Mapping[str, FoamFile._Dict]) -> None:
478
+ self["boundaryField"] = value
@@ -27,31 +27,31 @@ class Kind(Enum):
27
27
  DIMENSIONS = auto()
28
28
 
29
29
 
30
- def dumpb(
30
+ def dumps(
31
31
  data: FoamFileBase._SetData,
32
32
  *,
33
33
  kind: Kind = Kind.DEFAULT,
34
34
  ) -> bytes:
35
35
  if numpy and isinstance(data, np.ndarray):
36
- return dumpb(data.tolist(), kind=kind)
36
+ return dumps(data.tolist(), kind=kind)
37
37
 
38
38
  if isinstance(data, Mapping):
39
39
  entries = []
40
40
  for k, v in data.items():
41
- b = dumpb(v, kind=kind)
41
+ b = dumps(v, kind=kind)
42
42
  if isinstance(v, Mapping):
43
- entries.append(dumpb(k) + b" {" + b + b"}")
43
+ entries.append(dumps(k) + b" {" + b + b"}")
44
44
  elif not b:
45
- entries.append(dumpb(k) + b";")
45
+ entries.append(dumps(k) + b";")
46
46
  else:
47
- entries.append(dumpb(k) + b" " + b + b";")
47
+ entries.append(dumps(k) + b" " + b + b";")
48
48
 
49
49
  return b" ".join(entries)
50
50
 
51
51
  if isinstance(data, FoamFileBase.DimensionSet) or (
52
52
  kind == Kind.DIMENSIONS and is_sequence(data) and len(data) == 7
53
53
  ):
54
- return b"[" + b" ".join(dumpb(v) for v in data) + b"]"
54
+ return b"[" + b" ".join(dumps(v) for v in data) + b"]"
55
55
 
56
56
  if (kind == Kind.FIELD or kind == Kind.BINARY_FIELD) and (
57
57
  isinstance(data, (int, float))
@@ -60,7 +60,7 @@ def dumpb(
60
60
  and isinstance(data[0], (int, float))
61
61
  and len(data) in (3, 6, 9)
62
62
  ):
63
- return b"uniform " + dumpb(data, kind=Kind.SINGLE_ENTRY)
63
+ return b"uniform " + dumps(data, kind=Kind.SINGLE_ENTRY)
64
64
 
65
65
  if (kind == Kind.FIELD or kind == Kind.BINARY_FIELD) and is_sequence(data):
66
66
  if isinstance(data[0], (int, float)):
@@ -72,7 +72,7 @@ def dumpb(
72
72
  elif len(data[0]) == 9:
73
73
  tensor_kind = b"tensor"
74
74
  else:
75
- return dumpb(data)
75
+ return dumps(data)
76
76
 
77
77
  if kind == Kind.BINARY_FIELD:
78
78
  if tensor_kind == b"scalar":
@@ -84,30 +84,30 @@ def dumpb(
84
84
  + b")"
85
85
  )
86
86
  else:
87
- contents = dumpb(data, kind=Kind.SINGLE_ENTRY)
87
+ contents = dumps(data, kind=Kind.SINGLE_ENTRY)
88
88
 
89
- return b"nonuniform List<" + tensor_kind + b"> " + dumpb(len(data)) + contents
89
+ return b"nonuniform List<" + tensor_kind + b"> " + dumps(len(data)) + contents
90
90
 
91
91
  if kind != Kind.SINGLE_ENTRY and isinstance(data, tuple):
92
- return b" ".join(dumpb(v) for v in data)
92
+ return b" ".join(dumps(v) for v in data)
93
93
 
94
94
  if isinstance(data, FoamFileBase.Dimensioned):
95
95
  if data.name is not None:
96
96
  return (
97
- dumpb(data.name)
97
+ dumps(data.name)
98
98
  + b" "
99
- + dumpb(data.dimensions, kind=Kind.DIMENSIONS)
99
+ + dumps(data.dimensions, kind=Kind.DIMENSIONS)
100
100
  + b" "
101
- + dumpb(data.value, kind=Kind.SINGLE_ENTRY)
101
+ + dumps(data.value, kind=Kind.SINGLE_ENTRY)
102
102
  )
103
103
  return (
104
- dumpb(data.dimensions, kind=Kind.DIMENSIONS)
104
+ dumps(data.dimensions, kind=Kind.DIMENSIONS)
105
105
  + b" "
106
- + dumpb(data.value, kind=Kind.SINGLE_ENTRY)
106
+ + dumps(data.value, kind=Kind.SINGLE_ENTRY)
107
107
  )
108
108
 
109
109
  if is_sequence(data):
110
- return b"(" + b" ".join(dumpb(v, kind=Kind.SINGLE_ENTRY) for v in data) + b")"
110
+ return b"(" + b" ".join(dumps(v, kind=Kind.SINGLE_ENTRY) for v in data) + b")"
111
111
 
112
112
  if data is True:
113
113
  return b"yes"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: foamlib
3
- Version: 0.6.8
3
+ Version: 0.6.10
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes