Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ jobs:
export PYVISTA_OFF_SCREEN=true
Xvfb $DISPLAY -screen 0 1024x768x24 > /dev/null 2>&1 &
sleep 3
pytest --nbval *.ipynb
pytest --nbval 01-*.ipynb

- name: Build Jupyter Book
run: |
. /home/firedrake/firedrake/bin/activate
python3 -m pip install jupyter-book
for f in *.ipynb; do ln -s ../$f docs; done
for f in 01-*.ipynb; do ln -s ../$f docs; done
ln -s ../stokes-control.msh docs
export DISPLAY=:99
export PYVISTA_OFF_SCREEN=true
Expand Down
56 changes: 49 additions & 7 deletions 01-spd-helmholtz.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To start, we must make Firedrake available in the notebook. It is available as a normal Python package, named `firedrake`. To save on typing, we will import all of the public API into the current namespace"
"To start, we must make Firedrake available in the notebook. We will import it through the `gadopt` package. To save on typing, we will import all of the public API into the current namespace. For plotting within this notebook, we also explicitly import the `triplot` function."
]
},
{
Expand All @@ -131,7 +131,8 @@
"metadata": {},
"outputs": [],
"source": [
"from gadopt import *"
"from gadopt import *\n",
"from firedrake.pyplot import triplot, tripcolor"
]
},
{
Expand Down Expand Up @@ -363,7 +364,15 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"exercise"
]
},
"source": [
"## Exercises\n",
"\n",
Expand All @@ -386,13 +395,29 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"exercise"
]
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"exercise"
]
},
"source": [
"### Exercise 2: convergence of the method\n",
"For solutions with sufficient smoothness (like the choice we have here), this method with a piecewise linear approximation space should converge in the $L_2$ error with rate $\\mathcal{O}(h^{-2})$, where $h$ is the typical mesh spacing. Confirm this for the example in question by computing the $L_2$ error in the solution for a sequence of finer and finer meshes.\n",
Expand All @@ -411,7 +436,16 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"skip-execution",
"exercise"
]
},
"outputs": [],
"source": [
"mesh = UnitSquareMesh(10, 10)\n",
Expand All @@ -433,7 +467,15 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"exercise"
]
},
"outputs": [],
"source": []
},
Expand Down
21 changes: 19 additions & 2 deletions 02-poisson.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
" !wget \"https://github.com/g-adopt/tutorials/releases/latest/download/firedrake-install-real.sh\" -O \"/tmp/firedrake-install.sh\" && bash \"/tmp/firedrake-install.sh\"\n",
" import firedrake\n",
"from gadopt import *\n",
"from firedrake.pyplot import tripcolor\n",
"mesh = UnitSquareMesh(10, 10)\n",
"V = FunctionSpace(mesh, \"Lagrange\", 1)"
]
Expand Down Expand Up @@ -175,7 +176,15 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"exercise"
]
},
"source": [
"## Exercises\n",
"\n",
Expand All @@ -198,7 +207,15 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"exercise"
]
},
"outputs": [],
"source": []
}
Expand Down
41 changes: 37 additions & 4 deletions 03-elasticity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
" !wget \"https://github.com/g-adopt/tutorials/releases/latest/download/firedrake-install-real.sh\" -O \"/tmp/firedrake-install.sh\" && bash \"/tmp/firedrake-install.sh\"\n",
" import firedrake\n",
"from gadopt import *\n",
"from firedrake.pyplot import triplot\n",
"length = 1\n",
"width = 0.2\n",
"mesh = RectangleMesh(40, 20, length, width)"
Expand Down Expand Up @@ -199,7 +200,15 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"exercise"
]
},
"source": [
"## Exercises\n",
"\n",
Expand All @@ -212,7 +221,15 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"exercise"
]
},
"outputs": [],
"source": []
},
Expand Down Expand Up @@ -367,7 +384,15 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"exercise"
]
},
"source": [
"## Exercise\n",
"\n",
Expand All @@ -377,7 +402,15 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"exercise"
]
},
"outputs": [],
"source": []
}
Expand Down
41 changes: 37 additions & 4 deletions 04-burgers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
" !wget \"https://github.com/g-adopt/tutorials/releases/latest/download/firedrake-install-real.sh\" -O \"/tmp/firedrake-install.sh\" && bash \"/tmp/firedrake-install.sh\"\n",
" import firedrake\n",
"from gadopt import *\n",
"from firedrake.pyplot import plot\n",
"\n",
"n = 100\n",
"mesh = PeriodicIntervalMesh(n, length=2)\n",
Expand Down Expand Up @@ -305,7 +306,15 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"exercise"
]
},
"source": [
"## Exercise 1\n",
"\n",
Expand All @@ -317,13 +326,29 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"exercise"
]
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"exercise"
]
},
"source": [
"## Exercise 2\n",
"\n",
Expand All @@ -344,7 +369,15 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"exercise"
]
},
"outputs": [],
"source": []
}
Expand Down
13 changes: 11 additions & 2 deletions 05-pde-constrained-optimisation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"outputs": [],
"source": [
"from gadopt import *\n",
"from gadopt.inverse import *"
"from gadopt.inverse import *\n",
"from firedrake.pyplot import quiver, streamplot, tricontourf, triplot"
]
},
{
Expand Down Expand Up @@ -395,7 +396,15 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"exercise"
]
},
"source": [
"## Exercise:\n",
"\n",
Expand Down
Loading