Skip to content

Commit 1a46978

Browse files
authored
Merge pull request #254 from precice/python-bindings-v3.4.0
Release v3.4.0
2 parents 313441c + c3a9eff commit 1a46978

File tree

10 files changed

+194
-36
lines changed

10 files changed

+194
-36
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
.idea # Pycharm related file
33
*.so
44
build
5+
docs/_build
6+
docs/.docs_venv
57
*.egg-info
68
__pycache__
79
env

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## 3.4.0
6+
7+
* Added support for documentation rendering https://github.com/precice/python-bindings/pull/250
8+
59
## 3.3.1
610

711
* Remove root user option from the usage of the preCICE image in the release workflow https://github.com/precice/python-bindings/commit/0a9ccd449e875f0165bebc968b3a23d6d9094b0d

README.md

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ Please refer to [the preCICE documentation](https://www.precice.org/installation
1212

1313
## Required dependencies
1414

15-
**preCICE**: Refer to [the preCICE documentation](https://precice.org/installation-overview.html) for information on building and installation.
16-
17-
**C++**: A working C++ compiler, e.g., `g++`.
18-
19-
**MPI**: `mpi4py` requires MPI to be installed on your system.
15+
- preCICE: Refer to [the preCICE documentation](https://precice.org/installation-overview.html) for information on building and installation.
16+
- A working C++ compiler, e.g., `g++`.
17+
- `mpi4py` requires MPI to be installed on your system.
18+
- pkg-config.
2019

2120
## Installing the package
2221

@@ -42,19 +41,19 @@ We recommend using `pip` (version 19.0.0 or newer required). You can check your
4241

4342
For system installs of preCICE, installation works out of the box. There are different ways how pip can be used to install pyprecice. pip will fetch cython and other build-time dependencies, compile the bindings and finally install the package pyprecice.
4443

45-
* (recommended) install [pyprecice from PyPI](https://pypi.org/project/pyprecice/)
44+
- (recommended) install [pyprecice from PyPI](https://pypi.org/project/pyprecice/)
4645

4746
```bash
4847
$ pip install pyprecice
4948
```
5049

51-
* provide the link to this repository to pip (replace `<branch>` with the branch you want to use, preferably `master` or `develop`)
50+
- provide the link to this repository to pip (replace `<branch>` with the branch you want to use, preferably `master` or `develop`)
5251

5352
```bash
5453
$ pip install https://github.com/precice/python-bindings.git@<branch>
5554
```
5655

57-
* if you already cloned this repository, execute the following command from this directory:
56+
- if you already cloned this repository, execute the following command from this directory:
5857

5958
```bash
6059
$ pip install .
@@ -66,8 +65,8 @@ For system installs of preCICE, installation works out of the box. There are dif
6665

6766
If preCICE (the C++ library) was installed in a custom prefix, or only built but not installed at all, you have to extend the following environment variables:
6867

69-
* `LIBRARY_PATH`, `LD_LIBRARY_PATH` to the library location, or `$prefix/lib`
70-
* `CPATH` either to the `src` directory or the `$prefix/include`
68+
- `LIBRARY_PATH`, `LD_LIBRARY_PATH` to the library location, or `$prefix/lib`
69+
- `CPATH` either to the `src` directory or the `$prefix/include`
7170

7271
The preCICE documentation provides more information on [linking preCICE](https://precice.org/installation-linking.html).
7372

@@ -109,13 +108,13 @@ $ python3 setup.py install
109108
```
110109

111110
**Options:**
112-
* `--include-dirs=`, default: `''`
111+
- `--include-dirs=`, default: `''`
113112
Path to the headers of preCICE, point to the sources `$PRECICE_ROOT/src`, or the your custom install prefix `$prefix/include`.
114113

115114
**NOTES:**
116115

117-
* If you have built preCICE using CMake, you can pass the path to the CMake binary directory using `--library-dirs`.
118-
* It is recommended to use preCICE as a shared library here.
116+
- If you have built preCICE using CMake, you can pass the path to the CMake binary directory using `--library-dirs`.
117+
- It is recommended to use preCICE as a shared library here.
119118

120119
4. Install the bindings
121120

@@ -264,8 +263,8 @@ boost 1.65.1 was installed per the `boost and yaml-cpp` guide above.
264263
In order to have the right python dependencies, a packaged conda environment was transferred to
265264
SuperMUC. The following dependencies were installed:
266265

267-
* numpy
268-
* mpi4py
266+
- numpy
267+
- mpi4py
269268

270269
With the python environment active, we have to feed the right python file directories to the cmake command.
271270
Note that -DPYTHON_LIBRARY expects a python shared library. You can likely modify the version to fit what is required.
@@ -335,10 +334,10 @@ Bindings versions up to `v3.0.0.0` have four digits, where the first three digit
335334

336335
## Contributors
337336

338-
* [Benjamin Rodenberg](https://github.com/BenjaminRodenberg)
339-
* [Ishaan Desai](https://github.com/IshaanDesai)
340-
* [Saumitra Vinay Joshi](https://github.com/saumiJ) contributed first working prototype in [`3db9c9` on `precice/precice`](https://github.com/precice/precice/commit/3db9c95e527db1e1cacb2fd116a5ce13ee877513)
341-
* [Frédéric Simonis](https://github.com/fsimonis)
342-
* [Florian Lindner](https://github.com/floli)
343-
* [Benjamin Uekermann](https://github.com/uekerman)
344-
* [Gerasimos Chourdakis](https://github.com/MakisH)
337+
- [Benjamin Rodenberg](https://github.com/BenjaminRodenberg)
338+
- [Ishaan Desai](https://github.com/IshaanDesai)
339+
- [Saumitra Vinay Joshi](https://github.com/saumiJ) contributed first working prototype in [`3db9c9` on `precice/precice`](https://github.com/precice/precice/commit/3db9c95e527db1e1cacb2fd116a5ce13ee877513)
340+
- [Frédéric Simonis](https://github.com/fsimonis)
341+
- [Florian Lindner](https://github.com/floli)
342+
- [Benjamin Uekermann](https://github.com/uekerman)
343+
- [Gerasimos Chourdakis](https://github.com/MakisH)

cyprecice/cyprecice.pyx

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ cdef class Participant:
3939
"""
4040
Main Application Programming Interface of preCICE.
4141
To adapt a solver to preCICE, follow the following main structure:
42-
- Create an object of Participant with Participant()
43-
- Initialize preCICE with Participant::initialize()
44-
- Advance to the next (time)step with Participant::advance()
45-
- Finalize preCICE with Participant::finalize()
46-
- We use solver, simulation code, and participant as synonyms.
47-
- The preferred name in the documentation is participant.
42+
43+
- Create an object of Participant with Participant()
44+
- Initialize preCICE with Participant::initialize()
45+
- Advance to the next (time)step with Participant::advance()
46+
- Finalize preCICE with Participant::finalize()
47+
- We use solver, simulation code, and participant as synonyms.
48+
- The preferred name in the documentation is participant.
4849
"""
4950

5051
# fake __init__ needed to display docstring for __cinit__ (see https://stackoverflow.com/a/42733794/5158031)
@@ -105,10 +106,10 @@ cdef class Participant:
105106
method to finally exchange the data.
106107
107108
This function handles:
108-
- Parallel communication to the coupling partner/s is setup.
109-
- Meshes are exchanged between coupling partners and the parallel partitions are created.
110-
- [Serial Coupling Scheme] If the solver is not starting the simulation, coupling data is received
111-
from the coupling partner's first computation.
109+
110+
- Parallel communication to the coupling partner/s is setup.
111+
- Meshes are exchanged between coupling partners and the parallel partitions are created.
112+
- [Serial Coupling Scheme] If the solver is not starting the simulation, coupling data is received from the coupling partner's first computation.
112113
113114
Returns
114115
-------
@@ -206,8 +207,10 @@ cdef class Participant:
206207
"""
207208
Checks if the coupled simulation is still ongoing.
208209
A coupling is ongoing as long as
209-
- the maximum number of timesteps has not been reached, and
210-
- the final time has not been reached.
210+
211+
- the maximum number of timesteps has not been reached, and
212+
- the final time has not been reached.
213+
211214
The user should call finalize() after this function returns false.
212215
213216
Returns
@@ -227,8 +230,9 @@ cdef class Participant:
227230
"""
228231
Checks if the current coupling timewindow is completed.
229232
The following reasons require several solver time steps per coupling time step:
230-
- A solver chooses to perform subcycling.
231-
- An implicit coupling timestep iteration is not yet converged.
233+
234+
- A solver chooses to perform subcycling.
235+
- An implicit coupling timestep iteration is not yet converged.
232236
233237
Returns
234238
-------
@@ -790,27 +794,31 @@ cdef class Participant:
790794
Examples
791795
--------
792796
Write scalar data for a 2D problem with 5 vertices:
797+
793798
>>> mesh_name = "MeshOne"
794799
>>> data_name = "DataOne"
795800
>>> vertex_ids = [1, 2, 3, 4, 5]
796801
>>> values = np.array([v1, v2, v3, v4, v5])
797802
>>> participant.write_data(mesh_name, data_name, vertex_ids, values)
798803
799804
Write vector data for a 2D problem with 5 vertices:
805+
800806
>>> mesh_name = "MeshOne"
801807
>>> data_name = "DataOne"
802808
>>> vertex_ids = [1, 2, 3, 4, 5]
803809
>>> values = np.array([[v1_x, v1_y], [v2_x, v2_y], [v3_x, v3_y], [v4_x, v4_y], [v5_x, v5_y]])
804810
>>> participant.write_data(mesh_name, data_name, vertex_ids, values)
805811
806812
Write vector data for a 3D (D=3) problem with 5 (N=5) vertices:
813+
807814
>>> mesh_name = "MeshOne"
808815
>>> data_name = "DataOne"
809816
>>> vertex_ids = [1, 2, 3, 4, 5]
810817
>>> values = np.array([[v1_x, v1_y, v1_z], [v2_x, v2_y, v2_z], [v3_x, v3_y, v3_z], [v4_x, v4_y, v4_z], [v5_x, v5_y, v5_z]])
811818
>>> participant.write_data(mesh_name, data_name, vertex_ids, values)
812819
813820
Write vector data for a 3D (D=3) problem with 5 (N=5) vertices, where the values are provided as a list of tuples:
821+
814822
>>> mesh_name = "MeshOne"
815823
>>> data_name = "DataOne"
816824
>>> vertex_ids = [1, 2, 3, 4, 5]
@@ -873,6 +881,7 @@ cdef class Participant:
873881
Examples
874882
--------
875883
Read scalar data for a 2D problem with 5 vertices:
884+
876885
>>> mesh_name = "MeshOne"
877886
>>> data_name = "DataOne"
878887
>>> vertex_ids = [1, 2, 3, 4, 5]
@@ -882,6 +891,7 @@ cdef class Participant:
882891
>>> (5, )
883892
884893
Read vector data for a 2D problem with 5 vertices:
894+
885895
>>> mesh_name = "MeshOne"
886896
>>> data_name = "DataOne"
887897
>>> vertex_ids = [1, 2, 3, 4, 5]
@@ -891,6 +901,7 @@ cdef class Participant:
891901
>>> (5, 2)
892902
893903
Read vector data for a 3D system with 5 vertices:
904+
894905
>>> mesh_name = "MeshOne"
895906
>>> data_name = "DataOne"
896907
>>> vertex_ids = [1, 2, 3, 4, 5]
@@ -951,13 +962,15 @@ cdef class Participant:
951962
Examples
952963
--------
953964
Write scalar data for a 2D problem with 5 vertices:
965+
954966
>>> mesh_name = "MeshOne"
955967
>>> data_name = "DataOne"
956968
>>> coordinates = np.array([[c1_x, c1_y], [c2_x, c2_y], [c3_x, c3_y], [c4_x, c4_y], [c5_x, c5_y]])
957969
>>> values = np.array([v1, v2, v3, v4, v5])
958970
>>> participant.write_and_map_data(mesh_name, data_name, coordinates, values)
959971
960972
Write scalar data for a 2D problem with 5 vertices, where the coordinates are provided as a list of tuples, and the values are provided as a list of scalars:
973+
961974
>>> mesh_name = "MeshOne"
962975
>>> data_name = "DataOne"
963976
>>> coordinates = [(c1_x, c1_y), (c2_x, c2_y), (c3_x, c3_y), (c4_x, c4_y), (c5_x, c5_y)]
@@ -1008,6 +1021,7 @@ cdef class Participant:
10081021
Examples
10091022
--------
10101023
Read scalar data for a 2D problem with 2 vertices:
1024+
10111025
>>> mesh_name = "MeshOne"
10121026
>>> data_name = "DataOne"
10131027
>>> coordinates = np.array([[1.0, 1.0], [2.0, 2.0]])
@@ -1017,6 +1031,7 @@ cdef class Participant:
10171031
>>> (2, )
10181032
10191033
Read scalar data for a 2D problem with 2 vertices, where the coordinates are provided as a list of tuples:
1034+
10201035
>>> mesh_name = "MeshOne"
10211036
>>> data_name = "DataOne"
10221037
>>> coordinates = [(1.0, 1.0), (2.0, 2.0)]
@@ -1075,20 +1090,23 @@ cdef class Participant:
10751090
Examples
10761091
--------
10771092
Write gradient vector data for a 2D problem with 2 vertices:
1093+
10781094
>>> mesh_name = "MeshOne"
10791095
>>> data_name = "DataOne"
10801096
>>> vertex_ids = [1, 2]
10811097
>>> gradients = np.array([[v1x_dx, v1y_dx, v1x_dy, v1y_dy], [v2x_dx, v2y_dx, v2x_dy, v2y_dy]])
10821098
>>> participant.write_gradient_data(mesh_name, data_name, vertex_ids, gradients)
10831099
10841100
Write gradient vector data for a 2D problem with 2 vertices, where the gradients are provided as a list of tuples:
1101+
10851102
>>> mesh_name = "MeshOne"
10861103
>>> data_name = "DataOne"
10871104
>>> vertex_ids = [1, 2]
10881105
>>> gradients = [(v1x_dx, v1y_dx, v1x_dy, v1y_dy), (v2x_dx, v2y_dx, v2x_dy, v2y_dy)]
10891106
>>> participant.write_gradient_data(mesh_name, data_name, vertex_ids, gradients)
10901107
10911108
Write vector data for a 3D problem with 2 vertices:
1109+
10921110
>>> mesh_name = "MeshOne"
10931111
>>> data_name = "DataOne"
10941112
>>> vertex_ids = [1, 2]
@@ -1134,6 +1152,7 @@ cdef class Participant:
11341152
Examples
11351153
--------
11361154
Check if gradient data is required for a data:
1155+
11371156
>>> mesh_name = "MeshOne"
11381157
>>> data_name = "DataOne"
11391158
>>> participant.is_gradient_data_required(mesh_name, data_name)
@@ -1238,6 +1257,7 @@ cdef class Participant:
12381257
Examples
12391258
--------
12401259
Start a profiling section with the event name "EventOne":
1260+
12411261
>>> event_name = "EventOne"
12421262
>>> participant.start_profiling_section(event_name)
12431263
"""
@@ -1250,6 +1270,7 @@ cdef class Participant:
12501270
Examples
12511271
--------
12521272
Stop the last profiling section:
1273+
12531274
>>> participant.stop_last_profiling_section()
12541275
"""
12551276
self.thisptr.stopLastProfilingSection()

docs/build.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ ! -f "../pyproject.toml" ]]; then
4+
echo "Please run from the docs directory."
5+
exit 1
6+
fi
7+
8+
TARGET=singlehtml
9+
10+
python3 -m venv --clear .docs_venv
11+
12+
echo "Installing dependencies"
13+
.docs_venv/bin/pip install sphinx myst_parser sphinx-rtd-theme
14+
15+
echo "Installing python bindings"
16+
.docs_venv/bin/pip install --force --no-cache ..
17+
18+
echo "Building the website"
19+
.docs_venv/bin/sphinx-build -M ${TARGET} . _build

docs/conf.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
import datetime
7+
8+
project = "pyprecice"
9+
author = "The preCICE developers"
10+
copyright = f"{datetime.datetime.now().year}, {author}"
11+
12+
extensions = [
13+
"sphinx.ext.autodoc",
14+
"sphinx.ext.intersphinx",
15+
"myst_parser",
16+
]
17+
18+
intersphinx_mapping = {
19+
"python": ("https://docs.python.org/3/", None),
20+
"numpy": ("https://numpy.org/doc/stable/", None),
21+
"mpi4py": ("https://mpi4py.readthedocs.io/en/latest/", None),
22+
}
23+
24+
# exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".docs_venv"]
25+
include_patterns = ["*.rst", "*.md"]
26+
27+
html_theme = "sphinx_rtd_theme"
28+
29+
source_suffix = {
30+
".rst": "restructuredtext",
31+
".md": "markdown",
32+
}
33+
34+
autodoc_class_signature = "separated"
35+
autodoc_typehints = "description"
36+
autodoc_typehints_format = "short"
37+
autodoc_member_order = "bysource"
38+
39+
suppress_warnings = ["myst.xref_missing"]
40+
41+
# The cython detection relyies on a built and installed version of the package
42+
try:
43+
import precice
44+
except:
45+
raise RuntimeError("Cannot import precice. Please install pyprecice first")

docs/index.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
The preCICE python bindings
2+
===========================
3+
4+
.. toctree::
5+
:maxdepth: 1
6+
:caption: Contents:
7+
8+
precice
9+
MigrationGuide
10+
ReleaseGuide

docs/precice.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The pyprecice package
2+
=====================
3+
4+
.. automodule:: cyprecice
5+
:members:
6+
:undoc-members:

0 commit comments

Comments
 (0)