From 2e4b5c8f1cf65ffe3665989c795e9473c04c1a26 Mon Sep 17 00:00:00 2001 From: Angus Gibson Date: Mon, 12 Feb 2024 13:40:17 +1100 Subject: [PATCH 1/6] Add mkdocs-jupyter plugin to display tutorials This requires the notebooks are run using nbconvert and placed in the docs/tutorials/ directory. At the moment, it also requires a fork of mkdocs-jupyter that allows specifying the TOC depth, otherwise it's a bit too cluttered. --- docs/tutorials.md | 2 +- mkdocs.yml | 6 +++++- requirements.txt | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/tutorials.md b/docs/tutorials.md index 79a5bce..90730da 100644 --- a/docs/tutorials.md +++ b/docs/tutorials.md @@ -1,3 +1,3 @@ # Tutorials -This is a list of tutorials, gradually introducing the G-ADOPT library. \ No newline at end of file +This is a list of tutorials, gradually introducing the G-ADOPT library. diff --git a/mkdocs.yml b/mkdocs.yml index 405ab7f..65f31cf 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -44,13 +44,17 @@ plugins: members_order: source import: - https://fenics.readthedocs.io/projects/ufl/en/latest/objects.inv + - mkdocs-jupyter: + toc_depth: 2 nav: - Home: - index.md - About: about.md - Install: install.md - Documentation: documentation.md - - Tutorials: tutorials.md + - Tutorials: + - tutorials.md + - Helmholtz: tutorials/01-spd-helmholtz.nbconvert.ipynb - Benchmarks: benchmarks.md - Team: team.md - Funding: funding.md diff --git a/requirements.txt b/requirements.txt index 4a7ab4b..5b101ae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ mkdocs~=1.5.3 mkdocs-material~=9.5.8 mkdocs-glightbox~=0.3.7 mkdocstrings[python]~=0.24.0 +mkdocs-jupyter~=0.24.6 From e16001fd0a0fc12348a24057e60bbc5ad7f16970 Mon Sep 17 00:00:00 2001 From: Angus Gibson Date: Mon, 12 Feb 2024 14:18:13 +1100 Subject: [PATCH 2/6] Build tutorials from g-adopt/tutorials repository --- .github/workflows/build.yml | 44 +++++++++++++++++++++++++++++++++++++ mkdocs.yml | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3462a17..c46237d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,8 +12,48 @@ permissions: id-token: write jobs: + render: + runs-on: self-hosted + container: + image: firedrakeproject/firedrake:latest + options: --shm-size 2g + + env: + OMP_NUM_THREADS: 1 + + steps: + - uses: actions/checkout@v4 + with: + repository: g-adopt/tutorials + ref: angus-g/website-deploy + path: tutorials + - name: Install dependencies + run: | + sudo apt update + sudo apt install -y libgl1-mesa-glx xvfb + . /home/firedrake/firedrake/bin/activate + python3 -m pip install nbval pyvista nbconvert + python3 -m pip install gadopt[optimisation] + - name: Run test + run: | + . /home/firedrake/firedrake/bin/activate + export DISPLAY=:99 + export PYVISTA_OFF_SCREEN=true + Xvfb $DISPLAY -screen 0 1024x768x24 > /dev/null 2>&1 & + sleep 3 + python3 -m pytest --nbval tutorials/01-*.ipynb + - name: Convert notebooks + run: | + . /home/firedrake/firedrake/bin/activate + python3 -m jupyter nbconvert --to notebook --execute --output-dir=rendered tutorials/01-*.ipynb + - uses: actions/upload-artifact@v4 + with: + name: notebooks + path: rendered + build: runs-on: ubuntu-latest + needs: render steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -28,6 +68,10 @@ jobs: with: repository: g-adopt/g-adopt path: g-adopt + - uses: actions/download-artifact@v4 + with: + name: notebooks + path: docs/tutorials - name: Build site run: | mkdocs build --clean diff --git a/mkdocs.yml b/mkdocs.yml index 65f31cf..0a71725 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -54,7 +54,7 @@ nav: - Documentation: documentation.md - Tutorials: - tutorials.md - - Helmholtz: tutorials/01-spd-helmholtz.nbconvert.ipynb + - Helmholtz: tutorials/01-spd-helmholtz.ipynb - Benchmarks: benchmarks.md - Team: team.md - Funding: funding.md From 5879ec13a08063bcf245c24a2ebb00add1955915 Mon Sep 17 00:00:00 2001 From: Angus Gibson Date: Mon, 12 Feb 2024 14:35:23 +1100 Subject: [PATCH 3/6] Update mkdocs-jupyter version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5b101ae..561ef37 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,4 @@ mkdocs~=1.5.3 mkdocs-material~=9.5.8 mkdocs-glightbox~=0.3.7 mkdocstrings[python]~=0.24.0 -mkdocs-jupyter~=0.24.6 +mkdocs-jupyter~=0.24.7 From 95d9596fc5b382747acacdb1d05580ef9c865c18 Mon Sep 17 00:00:00 2001 From: Angus Gibson Date: Mon, 12 Feb 2024 15:09:33 +1100 Subject: [PATCH 4/6] Add next 4 tutorials --- .github/workflows/build.yml | 4 ++-- mkdocs.yml | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c46237d..56d79a6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,11 +41,11 @@ jobs: export PYVISTA_OFF_SCREEN=true Xvfb $DISPLAY -screen 0 1024x768x24 > /dev/null 2>&1 & sleep 3 - python3 -m pytest --nbval tutorials/01-*.ipynb + python3 -m pytest --nbval tutorials/{01..05}-*.ipynb - name: Convert notebooks run: | . /home/firedrake/firedrake/bin/activate - python3 -m jupyter nbconvert --to notebook --execute --output-dir=rendered tutorials/01-*.ipynb + python3 -m jupyter nbconvert --to notebook --execute --output-dir=rendered tutorials/{01..05}-*.ipynb - uses: actions/upload-artifact@v4 with: name: notebooks diff --git a/mkdocs.yml b/mkdocs.yml index 0a71725..cefc374 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -55,6 +55,10 @@ nav: - Tutorials: - tutorials.md - Helmholtz: tutorials/01-spd-helmholtz.ipynb + - Poisson: tutorials/02-poisson.ipynb + - Elasticity: tutorials/03-elasticity.ipynb + - "Burgers' Equation": tutorials/04-burgers.ipynb + - PDE Constrained Optimisation: tutorials/05-pde-constrained-optimisation.ipynb - Benchmarks: benchmarks.md - Team: team.md - Funding: funding.md From 3422a2c64a75612ec567d2df5c0ebdd7c01fa1e1 Mon Sep 17 00:00:00 2001 From: Rhodri Davies Date: Wed, 6 Mar 2024 10:44:04 +1100 Subject: [PATCH 5/6] Update main tutorials summary and docs. --- docs/tutorials.md | 18 +++++++++++++++++- mkdocs.yml | 14 +++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/docs/tutorials.md b/docs/tutorials.md index 90730da..4037a80 100644 --- a/docs/tutorials.md +++ b/docs/tutorials.md @@ -1,3 +1,19 @@ # Tutorials -This is a list of tutorials, gradually introducing the G-ADOPT library. +Here, we work through a series of tutorials that systematically introduce you to +Firedrake and the G-ADOPT library. + +One the first tab, we include 5 tutorials from Firedrake. + +1. The positive-definite Helmholtz equation. +2. Strong (Dirichlet) boundary conditions. +3. Linear elasticity. +4. A time-dependent problem using Burgers equation. +5. PDE constrained optimisation. + +On the second tab, we include 2 tutorials that are specific to G-ADOPT. + +1. Idealised 2-D mantle convection in a square box. +2. 2-D annulus case. + +We will add to these tutorials over time. diff --git a/mkdocs.yml b/mkdocs.yml index cefc374..2ee3b00 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -54,11 +54,15 @@ nav: - Documentation: documentation.md - Tutorials: - tutorials.md - - Helmholtz: tutorials/01-spd-helmholtz.ipynb - - Poisson: tutorials/02-poisson.ipynb - - Elasticity: tutorials/03-elasticity.ipynb - - "Burgers' Equation": tutorials/04-burgers.ipynb - - PDE Constrained Optimisation: tutorials/05-pde-constrained-optimisation.ipynb + - Firedrake: + - Helmholtz: tutorials/01-spd-helmholtz.ipynb + - Poisson: tutorials/02-poisson.ipynb + - Elasticity: tutorials/03-elasticity.ipynb + - "Burgers' Equation": tutorials/04-burgers.ipynb + - PDE Constrained Optimisation: tutorials/05-pde-constrained-optimisation.ipynb + - G-ADOPT: + - Stokes Square Convection: tutorials/06-GD-2D-convection.ipynb + - Stokes Cylindrical Convection: tutorials/07-GD-2D-cylindrical.ipynb - Benchmarks: benchmarks.md - Team: team.md - Funding: funding.md From 3579a779e472a16db1ab5ff58356ae983206daea Mon Sep 17 00:00:00 2001 From: Angus Gibson Date: Wed, 17 Apr 2024 08:35:23 +0000 Subject: [PATCH 6/6] Fix rendering workflow --- .github/workflows/build.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56d79a6..afb52d1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,18 +34,14 @@ jobs: . /home/firedrake/firedrake/bin/activate python3 -m pip install nbval pyvista nbconvert python3 -m pip install gadopt[optimisation] - - name: Run test + - name: Convert notebooks run: | . /home/firedrake/firedrake/bin/activate export DISPLAY=:99 export PYVISTA_OFF_SCREEN=true Xvfb $DISPLAY -screen 0 1024x768x24 > /dev/null 2>&1 & sleep 3 - python3 -m pytest --nbval tutorials/{01..05}-*.ipynb - - name: Convert notebooks - run: | - . /home/firedrake/firedrake/bin/activate - python3 -m jupyter nbconvert --to notebook --execute --output-dir=rendered tutorials/{01..05}-*.ipynb + python3 -m jupyter nbconvert --to notebook --execute --output-dir=rendered tutorials/*.ipynb - uses: actions/upload-artifact@v4 with: name: notebooks