Skip to content

jorgensd/fenics22-tutorial

Repository files navigation

FEniCSx Tutorial @ FEniCS 2022 in San Diego.

This repository contains the material that was used for the FEniCSx tutorial at the FEniCS 2022 conference.

All the resources from this tutorial can be found in this Jupyter book.

Developer notes

Rendering the HTML presentation files directly on Github

Use githack and add the link to the relevant presentation.

Example:

Adding a tutorial to the book

Add a chapter to _toc.yml.

Inside the Jupyter notebook, go to Property Inspector (the two cogwheels in the top right corner of JupyterLab) and add the following as notebook metadata:

 {
  "jupytext": {
   "formats": "ipynb,py:light"
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.4"
  }
 }

This will choose the default kernel in the dolfinx/lab docker image, and automatically convert the notebooks to a .py file at saving.

If you want to use complex numbers, change:

 "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },

to

  "kernelspec": {
   "display_name": "Python 3 (DOLFINx complex)",
   "language": "python",
   "name": "python3-complex"
  },

Create slides from your notebook

You can use nbconvert (pip3 install nbconvert) to convert the .ipynb to a presentation. The command to run is:

jupyter nbconvert example.ipynb --to html --template reveal

To change what is rendered on each slide, you can change the notebook metadata, which is in Property Inspector (the two cogwheels in the top right corner of JupyterLab), and change the Slide Type to Slide to start a new slide. If you want to add the cell below to the same slide, change the type to -.

If a cell should be revealed with Right Arrow, choose Fragment.

If you want a sub-slide, i.e. navigating downwards with arrows when rendering the presentation, change the type to Sub-Slide.

If a cell should be ignored in presentation mode, set it to Notes.

Hiding cells/output

See https://jupyterbook.org/en/stable/interactive/hiding.htm for more details. The setting is also in advanced tools on the RHS of the Jupyterlab interface

Automatically generate slides

By adding the following file to the (jupyter_server_config.py) .jupyter folder on your system. You might need to rename it to jupyter_notebook_config.py. To check the config paths, call:

jupyter server --show-config
jupyter notebook --show-config

If you run the code with dolfinx/lab:v0.5.0 using for instance:

docker run -ti -p 8888:8888 --rm -v $(pwd):/root/shared -w /root/shared dolfinx/lab:v0.5.0

no copying is required.

About

Tutorial for the FEniCS [22 conference](https://fenicsproject.org/fenics-2022/) in San Diego

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published