p4pdes

C and Python examples from my book on using PETSc and Firedrake to solve PDEs

https://github.com/bueler/p4pdes

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    1 of 1 committers (100.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.1%) to scientific vocabulary

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
Last synced: 6 months ago · JSON representation ·

Repository

C and Python examples from my book on using PETSc and Firedrake to solve PDEs

Basic Info
  • Host: GitHub
  • Owner: bueler
  • License: mit
  • Language: C
  • Default Branch: master
  • Homepage:
  • Size: 4.48 MB
Statistics
  • Stars: 209
  • Watchers: 20
  • Forks: 76
  • Open Issues: 0
  • Releases: 50
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
Created over 11 years ago · Last pushed 6 months ago
Metadata Files
Readme License Citation

README.md

p4pdes

PETSc for Partial Differential Equations is a book on using PETSc and Firedrake to solve partial differential equations by modern numerical methods.

image of front cover

Order a paper copy from SIAM Press, or the e-book from Google Play.

This repository contains the C and Python example programs upon which the book is based.

These example programs will remain here for the long term, and they will be maintained for future versions of PETSc.

C examples

To compile and run the C examples, for Chapters 1 through 12, see the README.md in the c/ directory.

Python/Firedrake examples

Chapters 13 and 14 use Firedrake, a Python finite element library based on PETSc. See the README.md in the python/ directory to run these examples.

Spring 2025 update on managing two PETSc installations:

Running 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 & 14.

Note that, as of March 2025, downloading and installing Firedrake, as in the instructions at the Install tab on the Firedrake page, is usually done by building a copy of PETSc from source, using Firedrake's recommended configuration flags, and then installing Firedrake via pip.

To install and manage these two PETSc copies I do the following:

  1. I configure and build one copy with any preferred flags, supporting my development of C programs: git clone -b release https://gitlab.com/petsc/petsc.git petsc 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.

  2. I follow the instructions at the Install tab on the Firedrake page 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: mkdir Firedrake cd Firedrake/ git clone --depth 1 https://github.com/firedrakeproject/petsc.git petsc 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: CC=mpicc CXX=mpicxx PETSC_DIR=/home/bueler/Firedrake/petsc PETSC_ARCH=arch-firedrake-default HDF5_MPI=ON Then the stages of starting the virtual environment and doing pip install ... go on as documented at the Firedrake installation page.

  3. Finally, I add certain convenience functions to .bashrc in my home directory: parse_git_dirty() { [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "*" } parse_git_branch() { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" } petscme() { export PETSC_DIR=~/petsc; export PETSC_ARCH=linux-c-dbg; alias mpiexec=$PETSC_DIR/$PETSC_ARCH/bin/mpiexec; export PS1='(petsc) \[\033[0;33m\]\w\[\033[0m\]$(parse_git_branch)$ ' } drakeme() { source ~/Firedrake/venv-firedrake/bin/activate export CC=mpicc CXX=mpicxx PETSC_DIR=~/Firedrake/petsc PETSC_ARCH=arch-firedrake-default HDF5_MPI=ON } 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: ~/p4pdes/c[master]$ petscme (petsc) ~/p4pdes/c[master]$ For working with the Firedrake Python codes in Chapters 13 & 14, I do: ~/p4pdes/python[master]$ drakeme (venv-firedrake) ~/p4pdes/python[master]$

Owner

  • Name: Ed Bueler
  • Login: bueler
  • Kind: user
  • Location: Fairbanks, Alaska, USA
  • Company: University of Alaska Fairbanks

Professor of Mathematics (Applied)

Citation (CITATION.bib)

@Book{Bueler2021,
  AUTHOR    = {E. Bueler},
  TITLE     = {{PETSc} for {P}artial {D}ifferential {E}quations: {N}umerical
               {S}olutions in {C} and {P}ython},
  PUBLISHER = {SIAM Press},
  ADDRESS   = {Philadelphia},
  YEAR      = {2021},
  ISBN      = {9781611976304},
  URL       = {https://github.com/bueler/p4pdes},
}

GitHub Events

Total
  • Create event: 4
  • Issues event: 1
  • Release event: 5
  • Watch event: 21
  • Push event: 12
  • Fork event: 4
Last Year
  • Create event: 4
  • Issues event: 1
  • Release event: 5
  • Watch event: 21
  • Push event: 12
  • Fork event: 4

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 2,468
  • Total Committers: 1
  • Avg Commits per committer: 2,468.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 16
  • Committers: 1
  • Avg Commits per committer: 16.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Ed Bueler e****r@a****u 2,468
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 57
  • Total pull requests: 1
  • Average time to close issues: 11 months
  • Average time to close pull requests: less than a minute
  • Total issue authors: 13
  • Total pull request authors: 1
  • Average comments per issue: 1.47
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • bueler (40)
  • QwZhang (3)
  • ckhroulev (3)
  • BarrySmith (2)
  • knepley (1)
  • debasishuiuc (1)
  • mapengfei-nwpu (1)
  • shaoyaoqian (1)
  • ssilverman999 (1)
  • miaodi (1)
  • issabass (1)
  • ophirnt (1)
  • thw1021 (1)
Pull Request Authors
  • wd15 (3)
Top Labels
Issue Labels
do_next (4) chap:un (3)
Pull Request Labels