Skip to content

Commit b7e8b6c

Browse files
committed
Update JOSS paper
1 parent 56391c6 commit b7e8b6c

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

paper.bib

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ @misc{mypy
1717
url = {https://github.com/python/mypy}
1818
}
1919

20+
@article{numpy,
21+
author = {Harris, Charles R and Millman, K Jarrod and Van Der Walt, St{\'e}fan J and Gommers, Ralf and Virtanen, Pauli and Cournapeau, David and Wieser, Eric and Taylor, Julian and Berg, Sebastian and Smith, Nathaniel J and others},
22+
title = {Array programming with NumPy},
23+
journal = {Nature},
24+
volume = {585},
25+
number = {7825},
26+
pages = {357--362},
27+
year = {2020},
28+
doi = {10.1038/s41586-020-2649-2}
29+
}
30+
2031
@misc{openfoam-app,
2132
author = {Gerlero, Gabriel S.},
2233
title = {{OpenFOAM.app}: Native {OpenFOAM} for {macOS}},

paper.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Besides its obvious use to orchestrate parallel optimization loops, `AsyncFoamCa
101101

102102
The `FoamFile` class offers high-level facilities for reading and writing OpenFOAM files, providing an interface similar to that of a Python `dict`. `FoamFile` fully understands OpenFOAM's file formats, and is able to edit file contents in place without disrupting formatting and comments. All types of OpenFOAM files are supported, meaning that `FoamFile` can be used for both and pre- and post-processing tasks.
103103

104-
OpenFOAM data types stored in files are mapped to built-in Python types as much as possible, making it easy to work with OpenFOAM data in Python. \autoref{datatypes} shows the mapping of OpenFOAM data types to Python data types with `foamlib`. We note that NumPy arrays are accepted as values for fields, even though NumPy is not a required dependency. Also, disambiguation between Python data types that may represent different OpenFOAM data types (e.g. a scalar value and a uniform scalar field) is resolved by `foamlib` at the time of writing by considering their contextual location within the file. The major exception to this preference for built-ins is posed by the `FoamFile.SubDict` class, which is returned for sub-dictionaries contained in `FoamFile`s, and allows for one-step modification of entries in nested dictionary structures—as is commonly required when configuring OpenFOAM cases.
104+
OpenFOAM data types stored in files are mapped to built-in Python or NumPy [@numpy] types as much as possible, making it easy to work with OpenFOAM data in Python. \autoref{datatypes} shows the mapping of OpenFOAM data types to Python data types with `foamlib`. Also, disambiguation between Python data types that may represent different OpenFOAM data types (e.g. a scalar value and a uniform scalar field) is resolved by `foamlib` at the time of writing by considering their contextual location within the file. The major exception to this preference for built-ins is posed by the `FoamFile.SubDict` class, which is returned for sub-dictionaries contained in `FoamFile`s, and allows for one-step modification of entries in nested dictionary structures—as is commonly required when configuring OpenFOAM cases.
105105

106106
For clarity and additional efficiency, `FoamFile` objects can be used as context managers to make multiple reads and writes to the same file while minimizing the number of filesystem and parsing operations required.
107107

@@ -110,21 +110,22 @@ Finally, we note that all OpenFOAM file formats are transparently supported by `
110110

111111
: Mapping of OpenFOAM data types to Python data types with `foamlib`. \label{datatypes}
112112

113-
| OpenFOAM | `foamlib` (accepts and returns) | `foamlib` (also accepts) |
114-
|:-----------------:|:------------------------------------:|:-----------------------------------------------------------------:|
115-
| scalar | `float` | |
116-
| vector/tensor | `list[float]` | `Sequence[float]` \| `numpy.array` |
117-
| label | `int` | |
118-
| switch | `bool` | |
119-
| word | `str` | |
120-
| string | `str` (quoted) | |
121-
| multiple tokens | `tuple` | |
122-
| list | `list` | `Sequence` |
123-
| dictionary | `FoamFile.SubDict` \| `dict` | `Mapping` |
124-
| uniform field | `float` \| `list[float]` | `Sequence[float]` \| `numpy.array` |
125-
| non-uniform field | `list[float]` \| `list[list[float]]` | `Sequence[float]` \| `Sequence[Sequence[float]]` \| `numpy.array` |
126-
| dimension set | `FoamFile.DimensionSet` | `Sequence[float] ` \| `numpy.array` |
127-
| dimensioned | `FoamFile.Dimensioned` | |
113+
| OpenFOAM | `foamlib` (accepts and returns) | `foamlib` (also accepts) |
114+
|:-----------------:|:--------------------------------:|:------------------------------------------------:|
115+
| scalar | `float` | |
116+
| vector/tensor | `numpy.ndarray` \| `list[float]` | `Sequence[float]` |
117+
| label | `int` | |
118+
| switch | `bool` | |
119+
| word | `str` | |
120+
| string | `str` (quoted) | |
121+
| multiple tokens | `tuple` | |
122+
| list | `list` | `Sequence` |
123+
| dictionary | `FoamFile.SubDict` \| `dict` | `Mapping` |
124+
| dictionary entry | `tuple` | |
125+
| uniform field | `float` \| `np.ndarray` | `Sequence[float]` |
126+
| non-uniform field | `numpy.ndarray` | `Sequence[float]` \| `Sequence[Sequence[float]]` |
127+
| dimension set | `FoamFile.DimensionSet` | `Sequence[float]` \| `numpy.ndarray` |
128+
| dimensioned | `FoamFile.Dimensioned` | |
128129

129130

130131
### `FoamFieldFile` class
@@ -145,6 +146,8 @@ Examples of `foamlib` usage are provided in the [README file](https://github.com
145146

146147
`foamlib` contains a full parser for OpenFOAM files, which is able to understand and write to the different types of files used by OpenFOAM. The parser is implemented using the `pyparsing` [@pyparsing] library, which provides a powerful and flexible way to define parsing grammars.
147148

149+
A special case parser is internally used for non-uniform OpenFOAM fields, which can commonly contain very large amounts of data in either ASCII or binary formats. The specialized parser uses the regular expressions to extract these data, which results in greatly improved parsing performance—a more than 25x speedup versus PyFoam—, while not sacrificing any of the generality of the parsing grammar. For extra efficiency and convenience, these fields map to NumPy arrays in Python.
150+
148151
## Asynchronous support
149152

150153
Methods of `FoamCase` and `AsyncFoamCase` have been carefully implemented in a way that greatly avoids duplication of code between the synchronous and asynchronous versions, by factoring out the common logic into a helper intermediate class.

0 commit comments

Comments
 (0)