Skip to content

Commit d2d673a

Browse files
FrederikSchnackcampospintoe-moral-sanchezyguclujowezarek
authored
Reorganize psydac examples (#543)
- Reorganize the `examples` directory - Add Jupyter notebooks to `examples/notebooks/` folder: . Define an equation symbolically, discretize it, compute some error norms, plot solution and error – Poisson 2D on a square with “Collela” mapping . FEEC API multipatch – Maxwell 2D time harmonic . FEM example: L2 projection . 3D example with VTK and Paraview . Get eigenvalues (FEEC) with SciPy (serial) . Get eigenvalues with PETSc + SLEPc (parallel) . FEEC 3D vector potential - Make the notebooks run by the documentation CI, so any errors lead to a failing build of the documentation Fixes #170. --------- Co-authored-by: Martin Campos Pinto <martin.campos-pinto@ipp.mpg.de> Co-authored-by: elmosa <Elena.Moral.Sanchez@ipp.mpg.de> Co-authored-by: Yaman Güçlü <yaman.guclu@gmail.com> Co-authored-by: jowezarek <julian.owezarek@tum.de>
1 parent a24643a commit d2d673a

File tree

81 files changed

+3471
-3047
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+3471
-3047
lines changed

.github/workflows/documentation.yml

Lines changed: 100 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,124 @@ jobs:
2525
runs-on: ubuntu-latest
2626
env:
2727
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN}}
28+
PSYDAC_MESH_DIR: ${{ github.workspace }}/mesh
29+
OMP_NUM_THREADS: 2
2830
steps:
2931
- name: Checkout
30-
uses: actions/checkout@v4
32+
uses: actions/checkout@v5
33+
3134
- name: Set up Python
3235
uses: actions/setup-python@v5
3336
with:
3437
python-version: '3.10'
3538
- name: Install non-Python dependencies on Ubuntu
39+
uses: awalsh128/cache-apt-pkgs-action@latest
40+
with:
41+
packages: gfortran openmpi-bin libopenmpi-dev libhdf5-openmpi-dev
42+
version: 1.0
43+
execute_install_scripts: true
44+
45+
- name: Reconfigure non-Python dependencies on Ubuntu
46+
run: |
47+
sudo apt-get update
48+
sudo apt-get install --reinstall openmpi-bin libhdf5-openmpi-dev liblapack-dev libblas-dev
49+
sudo apt install graphviz pandoc
50+
51+
- name: Print information on MPI and HDF5 libraries
52+
run: |
53+
ompi_info
54+
h5pcc -showconfig -echo || true
55+
56+
- name: Upgrade pip, setuptools, and wheel
57+
run: |
58+
python -m pip install --upgrade pip setuptools wheel
59+
60+
- name: Determine directory of parallel HDF5 library
61+
run: |
62+
if [[ "${{ matrix.os }}" == "ubuntu-24.04" ]]; then
63+
HDF5_DIR=$(dpkg -L libhdf5-openmpi-dev | grep libhdf5.so | xargs dirname)
64+
elif [[ "${{ matrix.os }}" == "macos-14" ]]; then
65+
HDF5_DIR=$(brew list hdf5-mpi | grep "libhdf5.dylib" | xargs dirname | xargs dirname)
66+
fi
67+
echo $HDF5_DIR
68+
echo "HDF5_DIR=$HDF5_DIR" >> $GITHUB_ENV
69+
70+
- name: Cache PETSc
71+
uses: actions/cache@v4
72+
id: cache-petsc
73+
env:
74+
cache-name: cache-PETSc
75+
with:
76+
path: "./petsc"
77+
key: petsc-${{ matrix.os }}-${{ matrix.python-version }}
78+
79+
- if: steps.cache-petsc.outputs.cache-hit != 'true'
80+
name: Download a specific release of PETSc
81+
run: |
82+
git clone --depth 1 --branch v3.23.2 https://gitlab.com/petsc/petsc.git
83+
84+
- if: steps.cache-petsc.outputs.cache-hit != 'true'
85+
name: Install PETSc with complex support
86+
working-directory: ./petsc
87+
run: |
88+
export PETSC_DIR=$(pwd)
89+
export PETSC_ARCH=petsc-cmplx
90+
./configure --with-scalar-type=complex --with-fortran-bindings=0 --have-numpy=1
91+
make all
92+
echo "PETSC_DIR=$PETSC_DIR" > petsc.env
93+
echo "PETSC_ARCH=$PETSC_ARCH" >> petsc.env
94+
95+
# This step is not really necessary and could be combined with PETSc install
96+
# step; however it's good to verify if the cached PETSc installation really works!
97+
- name: Test PETSc installation
98+
working-directory: ./petsc
99+
run: |
100+
source petsc.env
101+
make check
102+
echo "PETSC_DIR=$PETSC_DIR" >> $GITHUB_ENV
103+
echo "PETSC_ARCH=$PETSC_ARCH" >> $GITHUB_ENV
104+
105+
- name: Install petsc4py
106+
working-directory: ./petsc
107+
run: |
108+
python -m pip install wheel Cython numpy
109+
python -m pip install src/binding/petsc4py
110+
111+
- name: Install h5py in parallel mode
112+
run: |
113+
export CC="mpicc"
114+
export HDF5_MPI="ON"
115+
python -m pip install h5py --no-cache-dir --no-binary h5py
116+
python -m pip list
117+
118+
- name: Check parallel h5py installation
119+
run: |
120+
python -c "
121+
from mpi4py import MPI
122+
import h5py
123+
# This particular instantiation of h5py.File will fail if parallel h5py isn't installed
124+
f = h5py.File('parallel_test.hdf5', 'w', driver='mpio', comm=MPI.COMM_WORLD)
125+
print(f)"
126+
127+
- name: Install project
36128
run: |
37-
sudo apt update
38-
sudo apt install graphviz
39-
- name: Install Python dependencies
129+
python -m pip install .[test]
130+
python -m pip freeze
131+
132+
- name: Install Python dependencies for Documentation
40133
run: |
41134
python -m pip install -r docs/requirements.txt
135+
42136
- name: Make the sphinx doc
43137
run: |
44138
rm -rf docs/source/modules/STUBDIR
45139
make -C docs clean
46140
make -C docs html
47141
python docs/update_links.py
142+
48143
- name: Setup Pages
49144
uses: actions/configure-pages@v5
145+
50146
- name: Upload artifact
51147
uses: actions/upload-pages-artifact@v3
52148
with:

.github/workflows/testing.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ jobs:
157157
- name: Initialize test directory
158158
run: |
159159
mkdir pytest
160-
cp mpi_tester.py pytest
160+
cp scripts/mpi_tester.py pytest
161161
162162
- name: Run coverage tests on macOS
163163
if: matrix.os == 'macos-14'
@@ -203,6 +203,11 @@ jobs:
203203
run: |
204204
python mpi_tester.py --mpirun="mpiexec -n 4 ${MPI_OPTS}" --pyargs psydac -m "parallel and petsc"
205205
206+
- name: Run single-process example tests with Pytest on Ubuntu
207+
if: matrix.os == 'ubuntu-24.04'
208+
run: |
209+
python -m pytest examples/feec
210+
206211
- name: Remove test directory
207212
if: always()
208213
run: |

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h1 align="center">
2-
<img src="https://raw.githubusercontent.com/pyccel/psydac/devel/docs/source/logo/psydac_banner.svg" width="600" alt="Shows the psydac logo.">
2+
<img src="https://raw.githubusercontent.com/pyccel/psydac/devel/docs/source/logo/psydac_banner.svg" width="600" alt="Shows the psydac logo." class="dark-light">
33
</h1><br>
44

55
[![devel_tests](https://github.com/pyccel/psydac/actions/workflows/testing.yml/badge.svg)](https://github.com/pyccel/psydac/actions/workflows/testing.yml) [![docs](https://github.com/pyccel/psydac/actions/workflows/documentation.yml/badge.svg)](https://github.com/pyccel/psydac/actions/workflows/documentation.yml)
@@ -38,7 +38,7 @@ PSYDAC requires a certain number of components to be installed on the machine:
3838

3939
The installation instructions depend on the operating system and on the packaging manager used.
4040
It is particularly important to determine the **HDF5 root folder**, as this will be needed to install the [`h5py`](https://docs.h5py.org/en/latest/build.html#source-installation) package in parallel mode.
41-
Detailed instructions can be found in the [documentation](https://github.com/pyccel/psydac/blob/devel/docs/installation.md).
41+
Detailed instructions can be found in the [documentation](https://pyccel.github.io/psydac/installation.html).
4242

4343
Once those components are installed, we recommend using [`venv`](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment) to set up a fresh Python virtual environment at a location `<ENV-PATH>`:
4444
```bash
@@ -65,12 +65,12 @@ pip install meson-python "pyccel>=2.1.0"
6565
pip install --no-build-isolation --editable ./psydac
6666
```
6767

68-
Again, for more details we refer to our [documentation](https://github.com/pyccel/psydac/blob/devel/docs/installation.md).
68+
Again, for more details we refer to our [documentation](https://pyccel.github.io/psydac/installation.html).
6969

7070
> [!TIP]
7171
> PSYDAC provides the functionality to convert its MPI-parallel matrices and vectors to their [PETSc](https://petsc.org) equivalent, and back.
7272
> This gives the user access to a wide variety of linear solvers and other algorithms.
73-
> Instructions for installing [PETSc](https://petsc.org) and `petsc4py` can be found in our [documentation](https://github.com/pyccel/psydac/blob/devel/docs/installation.md#optional-petsc-installation).
73+
> Instructions for installing [PETSc](https://petsc.org) and `petsc4py` can be found in our [documentation](https://pyccel.github.io/psydac/installation.html#id9).
7474
7575
## Running Tests
7676

@@ -108,14 +108,15 @@ This command applies Pyccel to all the kernel files in the source directory. The
108108

109109
## Examples and Tutorials
110110

111-
A [tutorial](https://pyccel.github.io/IGA-Python/intro.html) on isogeometric analysis, with many example notebooks where various PDEs are solved with PSYDAC, is under construction in the [IGA-Python](https://github.com/pyccel/IGA-Python) repository.
111+
Our [documentation](https://pyccel.github.io/psydac/examples.html) provides Jupyter notebooks that present many aspects of this library.
112+
Additional [tutorials](https://pyccel.github.io/IGA-Python/intro.html) on isogeometric analysis, with many example notebooks where various PDEs are solved with PSYDAC, is under construction in the [IGA-Python](https://github.com/pyccel/IGA-Python) repository.
112113
Some other examples can be found [here](https://github.com/pyccel/psydac/blob/devel/examples).
113114

114115
## Library Documentation
115116

116-
- [Output formats](https://github.com/pyccel/psydac/blob/devel/docs/output.md)
117-
- [Mesh generation](https://github.com/pyccel/psydac/blob/devel/docs/psydac-mesh.md)
118-
- [Library reference](https://pyccel.github.io/psydac/)
117+
- [Output formats](https://pyccel.github.io/psydac/output.html)
118+
- [Mesh generation](https://pyccel.github.io/psydac/psydac-mesh.html)
119+
- [Modules](https://pyccel.github.io/psydac/modules.html)
119120

120121
## Contributing
121122

docs/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ help:
1717
# Catch-all target: route all unknown targets to Sphinx using the new
1818
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1919
%: Makefile
20+
@mkdir -p source/examples
21+
@cp -r ../examples/notebooks/* source/examples/
22+
@cp *.md source/
23+
2024
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/output.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,4 @@ post.export_to_vtk('filename_vtk', grid=grid, npts_per_cell=npts_per_cell, snaps
159159
```
160160

161161
## Further Examples
162-
Further examples are present in the following files:
163-
164-
* `examples/poisson_3d_target_torus.py`
165-
* `examples/sample_multipatch_parallel.py`
166-
* `examples/notebooks/Poisson_non_periodic.ipynb`
167-
* `psydac/api/tests/test_postprocessing.py`
162+
Further examples are present in the [example notebooks](https://pyccel.github.io/psydac/examples.html).

docs/psydac-mesh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ After installation, the command `psydac-mesh` will be available.
66

77
```bash
88
psydac-mesh -n='16,16' -d='3,3' square mesh.h5
9-
```
9+
```

docs/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ pydata_sphinx_theme
33
numpydoc
44
tomli
55
sphinx-math-dollar
6+
nbsphinx
7+
ipykernel
8+
ipytest
69
myst-parser

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def fixed_init(self, app):
5252
'sphinx.ext.githubpages',
5353
'sphinx_math_dollar',
5454
'sphinx.ext.mathjax',
55+
'nbsphinx',
5556
'myst_parser',
5657
]
5758

docs/source/examples.rst

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,47 @@
11
Examples
22
========
33

4-
+------------------------------------------------------------------------------------------------------------------------+
5-
| Here you will find examples of how to use PSYDAC and explanations thereof as well as links to notebooks in the future. |
6-
+------------------------------------------------------------------------------------------------------------------------+
4+
.. +------------------------------------------------------------------------------------------------------------------------+
5+
.. | Here you will find examples of how to use PSYDAC and explanations thereof as well as links to notebooks in the future. |
6+
.. +------------------------------------------------------------------------------------------------------------------------+
7+
8+
.. The notebooks get copied into the source directory by the continuous integration pipeline.
9+
.. The notebooks should have all output cleared before being committed to the repository.
10+
Notebooks
11+
---------
12+
For the documentation, we provide several Jupyter notebooks that illustrate how to use PSYDAC to solve different types of problems.
13+
They can be found in the `notebooks directory <https://github.com/pyccel/psydac/tree/devel/examples/notebooks>`_,
14+
but are also generated as part of the documentation and can be accessed here:
15+
16+
17+
.. toctree::
18+
:maxdepth: 1
19+
:caption: Notebooks:
20+
21+
examples/poisson_2d_square
22+
examples/Poisson_non_periodic
23+
examples/Helmholtz_non_periodic
24+
examples/fem_L2_projection
25+
examples/regularized_curlcurl_3D_VTK
26+
examples/petsc_eigenvalues_regularized_curlcurl
27+
examples/feec_curlcurl_eigenvalue
28+
examples/feec_time_harmonic_Maxwell
29+
examples/feec_vector_potential_torus
30+
31+
FEEC Examples
32+
-------------
33+
34+
In the `FEEC examples directory <https://github.com/pyccel/psydac/tree/devel/examples/feec>`_,
35+
you will find several examples of how to use PSYDAC to solve problems arising within the Finite Element Exterior Calculus (FEEC) framework.
36+
These examples include:
37+
38+
39+
* Poisson problems
40+
* General curl-curl eigenvalue problems
41+
* Time-harmonic Maxwell equations with source terms
42+
* Time-dependent Maxwell equations
43+
44+
45+
Performance
46+
-----------
47+
There are also some examples in the `performance directory <https://github.com/pyccel/psydac/tree/devel/examples/performance>`_ explaining the assembly algorithms used in PSYDAC.

docs/source/index.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
Welcome to PSYDAC's documentation!
88
==================================
99

10-
.. _note:
11-
.. note::
12-
13-
This documentation is still under construction.
14-
For the time being, its purpose is to assist the developers.
15-
1610
.. include:: ../../README.md
1711
:parser: myst_parser.sphinx_
1812

@@ -21,6 +15,9 @@ Welcome to PSYDAC's documentation!
2115
:maxdepth: 1
2216
:hidden:
2317

24-
modules
18+
installation
2519
examples
20+
output
21+
modules
22+
psydac-mesh
2623
maintenance

0 commit comments

Comments
 (0)