{"id":29298665,"url":"https://github.com/bueler/p4pdes","last_synced_at":"2025-07-06T18:14:25.726Z","repository":{"id":20999168,"uuid":"24288784","full_name":"bueler/p4pdes","owner":"bueler","description":"C and Python examples from my book on using PETSc and Firedrake to solve  PDEs","archived":false,"fork":false,"pushed_at":"2025-05-07T21:17:43.000Z","size":4700,"stargazers_count":204,"open_issues_count":0,"forks_count":75,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-07-06T07:16:50.238Z","etag":null,"topics":["advection","c","finite-difference","finite-element-methods","firedrake","fluid-mechanics","krylov","multigrid","newtons-method","ordinary-differential-equations","parallel-computing","partial-differential-equations","petsc","preconditioning","python","scientific-computing","supercomputing","variational-inequality"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bueler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.bib","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-09-21T11:01:32.000Z","updated_at":"2025-07-01T03:04:57.000Z","dependencies_parsed_at":"2023-01-13T21:15:24.530Z","dependency_job_id":"56bec657-a43d-4131-acf7-baf7427b9278","html_url":"https://github.com/bueler/p4pdes","commit_stats":{"total_commits":2445,"total_committers":1,"mean_commits":2445.0,"dds":0.0,"last_synced_commit":"6ecbb06e36399c3544301869ff57c69bc6df5ade"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"purl":"pkg:github/bueler/p4pdes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bueler%2Fp4pdes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bueler%2Fp4pdes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bueler%2Fp4pdes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bueler%2Fp4pdes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bueler","download_url":"https://codeload.github.com/bueler/p4pdes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bueler%2Fp4pdes/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263949408,"owners_count":23534324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["advection","c","finite-difference","finite-element-methods","firedrake","fluid-mechanics","krylov","multigrid","newtons-method","ordinary-differential-equations","parallel-computing","partial-differential-equations","petsc","preconditioning","python","scientific-computing","supercomputing","variational-inequality"],"created_at":"2025-07-06T18:14:25.042Z","updated_at":"2025-07-06T18:14:25.714Z","avatar_url":"https://github.com/bueler.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"p4pdes\n======\n\n_PETSc for Partial Differential Equations_ is a book on using [PETSc](https://petsc.org/release/) and [Firedrake](https://www.firedrakeproject.org/) to solve [partial differential equations](https://en.wikipedia.org/wiki/Partial_differential_equation) by modern numerical methods.\n\n\u003cp align=\"center\"\u003e\n  \u003ca  href=\"https://doi.org/10.1137/1.9781611976311\"\u003e \u003cimg src=\"frontcover.jpg\" alt=\"image of front cover\" /img\u003e \u003c/a\u003e\n\u003c/p\u003e\n\nOrder a paper copy from [SIAM Press](https://doi.org/10.1137/1.9781611976311), or the e-book from [Google Play](https://play.google.com/store/books/details/Ed_Bueler_PETSc_for_Partial_Differential_Equations?id=tgMHEAAAQBAJ).\n\nThis repository contains the C and Python example programs upon which the book is based.\n\n**These example programs will remain here for the long term, and they will be maintained for future versions of PETSc.**\n\n### C examples\n\nTo compile and run the C examples, for Chapters 1 through 12, see the [`README.md`](c/README.md) in the `c/` directory.\n\n### Python/Firedrake examples\n\nChapters 13 and 14 use [Firedrake](https://www.firedrakeproject.org/), a [Python](https://www.python.org/) finite element library based on PETSc.  See the [`README.md`](python/README.md) in the `python/` directory to run these examples.\n\n### Spring 2025 update on managing two PETSc installations:\n\nRunning all the codes from the book can be done with two copies of PETSc.  One copy is any PETSc installation, to be used for the C codes in Chapters 1--12; this one can be updated to follow any branch of PETSc, for example.  The other copy is separate, and configured so that Firedrake works; this one is for the Python codes in Chapters 13 \u0026 14.\n\nNote that, as of March 2025, downloading and installing Firedrake, as in the instructions at the [Install tab on the Firedrake page](https://www.firedrakeproject.org/install.html), is usually done by building a copy of PETSc from source, using Firedrake's recommended configuration flags, and then installing Firedrake via [pip](https://pypi.org/project/pip/).\n\nTo install and manage these two PETSc copies I do the following:\n\n  1. I configure and build one copy with any preferred flags, supporting my development of C programs:\n```\n  git clone -b release https://gitlab.com/petsc/petsc.git petsc\n```\n  Most configuration choices will be compatible with building and running the codes in Chapters 1--12.  Note that Fortran support is not needed for the book's codes.\n\n  2. I follow the instructions at the [Install tab on the Firedrake page](https://www.firedrakeproject.org/install.html) to install Firedrake.  However, I do this inside a directory `Firedrake` so that the second PETSc copy needed by Firedrake is in a different location:\n```\n  mkdir Firedrake\n  cd Firedrake/\n  git clone --depth 1 https://github.com/firedrakeproject/petsc.git petsc\n```\n  I do the installation, also from within `Firedrake/`, making sure that `PETSC_DIR` points to `Firedrake/petsc/`.  For example, in my case I see the environment variables:\n```\n   CC=mpicc CXX=mpicxx PETSC_DIR=/home/bueler/Firedrake/petsc PETSC_ARCH=arch-firedrake-default HDF5_MPI=ON\n```\n  Then the stages of starting the virtual environment and doing `pip install ...` go on as documented at the [Firedrake installation page](https://www.firedrakeproject.org/install.html).\n\n  3. Finally, I add certain convenience functions to `.bashrc` in my home directory:\n```\nparse_git_dirty() {\n    [[ $(git status 2\u003e /dev/null | tail -n1) != \"nothing to commit, working tree clean\" ]] \u0026\u0026 echo \"*\"\n}\nparse_git_branch() {\n    git branch --no-color 2\u003e /dev/null | sed -e '/^[^*]/d' -e \"s/* \\(.*\\)/[\\1$(parse_git_dirty)]/\"\n}\npetscme() {\n    export PETSC_DIR=~/petsc;\n    export PETSC_ARCH=linux-c-dbg;\n    alias mpiexec=$PETSC_DIR/$PETSC_ARCH/bin/mpiexec;\n    export PS1='(petsc) \\[\\033[0;33m\\]\\w\\[\\033[0m\\]$(parse_git_branch)$ '\n}\ndrakeme() {\n    source ~/Firedrake/venv-firedrake/bin/activate\n    export CC=mpicc CXX=mpicxx PETSC_DIR=~/Firedrake/petsc PETSC_ARCH=arch-firedrake-default HDF5_MPI=ON\n}\n```\n  These posix-compatible Bash functions provide informative prompts for what mode I am in, and also what Git branch I am on.  For example, here is how I start to work with the C codes in Chapters 1--12:\n```\n  ~/p4pdes/c[master]$ petscme\n  (petsc) ~/p4pdes/c[master]$\n```\n  For working with the Firedrake Python codes in Chapters 13 \u0026 14, I do:\n```\n  ~/p4pdes/python[master]$ drakeme\n  (venv-firedrake) ~/p4pdes/python[master]$\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbueler%2Fp4pdes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbueler%2Fp4pdes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbueler%2Fp4pdes/lists"}