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

Overview

p4pdes

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

image of front cover

Order the paper book 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. They will remain here for the long term, and 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.

You might also like...
🏅State-of-the-art learned data structure that enables fast lookup, predecessor, range searches and updates in arrays of billions of items using orders of magnitude less space than traditional indexes

The Piecewise Geometric Model index (PGM-index) is a data structure that enables fast lookup, predecessor, range searches and updates in arrays of bil

C++ implementation of a fast hash map and hash set using robin hood hashing

A C++ implementation of a fast hash map and hash set using robin hood hashing The robin-map library is a C++ implementation of a fast hash map and has

Nodable is node-able. The goal of Nodable is to provide an original hybrid source code editor, using both textual and nodal paradigm.
Nodable is node-able. The goal of Nodable is to provide an original hybrid source code editor, using both textual and nodal paradigm.

Nodable is node-able ! Introduction: The goal of Nodable is to provide an original hybrid source code editor, using both textual and nodal paradigm. I

180+ Algorithm & Data Structure Problems using C++
180+ Algorithm & Data Structure Problems using C++

180+ Algorithm & Data Structure Problems using C++

tail multiple files at once using inotify

tailer - tail entire directories at once using inotify This utility is based on Erik Zenker's inotify-cpp library for monitoring file create/modify/re

Collection of all the LeetCode problem solutions using different programming languages.

LeetCode Solutions Collection of all the LeetCode problem solutions using different programming languages. To contribute, you can make a file for the

OS Algos Using C

OperatingSystem_C OS Algos Using C 1.PCB PCB is used to represent the whole process entity, keyboard control method is used to simulate the event gene

Implementing B tree using C++
Implementing B tree using C++

B Tree Implementing B tree using C++ Search Insert Structuring the main Function Delete Demo : Usage : Clone it to some place in your PC. Install Visu

A low-latency LRU approximation cache in C++ using CLOCK second-chance algorithm. Multi level cache too. Up to 2.5 billion lookups per second.
A low-latency LRU approximation cache in C++ using CLOCK second-chance algorithm. Multi level cache too. Up to 2.5 billion lookups per second.

LruClockCache Low-latency LRU approximation cache in C++ using CLOCK second-chance algorithm. (see wiki for details) using MyKeyType = std::string; us

Releases(v3.18.0)
  • v3.18.0(Oct 10, 2022)

    C codes (Chapters 1--12) were tested with PETSc v3.18.0 (commit 54841b124fc) and v3.18.1 (commit 08ba72b19cc)

    Python codes (Chapters 13--14) were tested with Firedrake commit 729b7b4f1b

    Gmsh version 4.9.3 (and 4.9.0)

    Test machine: thelio ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.17.4(Aug 6, 2022)

    C codes (Chapters 1--12) were tested with PETSc v3.17.4 (commit 20ebc7bc82d)

    Python codes (Chapters 13--14) were tested with Firedrake commit 8f746bec

    Gmsh version 4.9.3 (and 4.9.0)

    (Note this is not master branch of p4pdes.)

    Test machine: thelio ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • post-v3.17.3(Jul 30, 2022)

    Changes to C-style error checking are needed post v3.17.3. This release makes those changes.

    C codes (Chapters 1--12) were tested with PETSc main (commit a8029add on 30 July 2022)

    Python codes (Chapters 13--14) were tested with Firedrake commit 8f746bec

    Gmsh version 4.9.3 (and 4.9.0)

    Test machine: thelio ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.17.3(Jun 30, 2022)

    C codes (Chapters 1--12) were tested with PETSc 3.17.3 (v3.17.3 tag, commit )

    Python codes (Chapters 13--14) were tested with Firedrake commit e5c4aa61

    Gmsh version 4.9.3 (and 4.9.0)

    Test machine: thelio ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.17.1(May 2, 2022)

    C codes (Chapters 1--12) were tested with PETSc 3.17.1 (v3.17.1 tag, commit 8ed8779e017) and 3.17.2 (v3.17.2 tag, commit 32a6fd01d7f)

    Python codes (Chapters 13--14) were tested with Firedrake commit bc795025

    Gmsh version 4.9.3

    Test machines: galago ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.17.0(Apr 2, 2022)

    C codes (Chapters 1--12) were tested with PETSc 3.17.0 (main branch, commit 24d29bbf)

    Python codes (Chapters 13--14) were tested with Firedrake commit bc795025

    Gmsh version 4.9.3 (and 4.9.0)

    Test machine: ed-galago ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.16.5(Mar 5, 2022)

    C codes (Chapters 1--12) were tested with PETSc 3.16.5 (main branch, commit 383c7071)

    Python codes (Chapters 13--14) were tested with Firedrake commit e5c4aa61

    Gmsh version 4.9.3 (and 4.9.0)

    Test machine: bueler-thelio ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.16.4(Feb 2, 2022)

    C codes (Chapters 1--12) were tested with PETSc 3.16.4 (main branch, commit 5b3d6503)

    Python codes (Chapters 13--14) were tested with Firedrake commit bdffc92d

    Gmsh version 4.9.3.

    Test machine: ed-galago ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.16.3(Jan 6, 2022)

    C codes (Chapters 1--12) were tested with PETSc 3.16.3 (main branch, commit e83d203c)

    Python codes (Chapters 13--14) were tested with Firedrake commit bdffc92d

    Gmsh version 4.9.3.

    Test machine: ed-galago ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.16.2(Dec 11, 2021)

    C codes (Chapters 1--12) were tested with PETSc 3.16.2 (main branch, commit 6e923442)

    Python codes (Chapters 13--14) were tested with Firedrake commit 9ce1619d

    Gmsh version 4.9.0.

    Test machine: bueler-thelio ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.16.1(Nov 2, 2021)

    C codes (Chapters 1--12) were tested with PETSc 3.16.1 (main branch, commit 680c40f5)

    Python codes (Chapters 13--14) were tested with Firedrake commit 9ce1619d

    Gmsh version 4.6.0.

    Test machine: bueler-thelio ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.16.0(Oct 1, 2021)

    C codes (Chapters 1--12) were tested with PETSc v3.16.0 and v3.16.1 (main branch, commit 680c40f5)

    Python codes (Chapters 13--14) were tested with Firedrake commit 9ce1619d

    Gmsh version 4.6.0.

    Test machine: bueler-thelio ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.15.4(Sep 2, 2021)

    C codes (Chapters 1--12) were tested with PETSc v3.15.4 (commit 230bc508)

    Python codes (Chapters 13--14) were tested with Firedrake commit 9ce1619d

    Gmsh version 4.6.0.

    Test machine: bueler-thelio ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.15.3(Aug 8, 2021)

    C codes (Chapters 1--12) were tested with PETSc v3.15.3 (a5b4347eab)

    Python codes (Chapters 13--14) were tested with Firedrake commit bdffc92d downloaded 3 June 2021.

    Gmsh version 4.6.0.

    Test machine: bueler-galago ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.15.0-v2(May 15, 2021)

    C codes (Chapters 1--12) were tested with PETSc main (e45b2479) and v3.15.0 (81b4a8f0)

    Python codes (Chapters 13--14) were tested with Firedrake commit 9ce1619d downloaded 14May2021.

    Gmsh version 4.6.0.

    Test machine: bueler-galago ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.15.0(Apr 2, 2021)

    C codes (Chapters 1--12) were tested with PETSc main (e45b2479) and v3.15.0 (81b4a8f0) and v3.14.6 (096591eb)

    Python codes (Chapters 13--14) were tested with Firedrake commit dbe39dbf; PETSc v3.4.2-33053-ge85aaad7c1

    Gmsh version 4.6.0.

    Test machine: bueler-galago ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.14.4(Feb 27, 2021)

    C codes (Chapters 1--12) were tested with PETSc main (235129d7) and v3.14.5 (ebc4da3f)

    Python codes (Chapters 13--14) were tested with Firedrake commit dbe39dbf; PETSc v3.4.2-33053-ge85aaad7c1

    Gmsh version 4.6.0.

    Test machine: bueler-galago ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.14.2(Dec 5, 2020)

    C codes (Chapters 1--12) were tested with PETSc tag v3.14.2 (94fb59f4) and v3.14.3 (195253b0)

    Python codes (Chapters 13--14) were tested with Firedrake commit a2eb2c7d; PETSc v3.4.2-33053-ge85aaad7c1

    Gmsh version 4.6.0.

    Test machine: bueler-galago ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.14.1(Nov 4, 2020)

    C codes (Chapters 1--12) were tested with PETSc v3.14.1 tag (b01fa4f6d0).

    Python codes (Chapters 13--14) were tested with a Firedrake commit on 1 November 2020 (e519d8c2); Firedrake PETSc v3.4.2-33053-ge85aaad7c1

    Test machine: bueler-galago ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.14(Sep 30, 2020)

    C codes (Chapters 1--12) were tested with PETSc master branch at v3.14 (fc0d1852).

    Python codes (Chapters 13--14) were tested with Firedrake downloaded 11 July 2020 (8e730839); Firedrake PETSc v3.4.2-30276-g8aecd4c38f.

    Test machine: bueler-galago ubuntu 20.04

    Note: The p4pdes examples are unchanged since the v3.13.5 release, but they were retested with PETSc v3.14.

    Source code(tar.gz)
    Source code(zip)
  • v3.13.5(Sep 28, 2020)

    C codes (Chapters 1--12) were tested with PETSc master branch at v3.13.5 (75ec080748).

    Python codes (Chapters 13--14) were tested with Firedrake downloaded 11 July 2020 (8e730839); Firedrake PETSc v3.4.2-30276-g8aecd4c38f.

    Test machine: bueler-thelio ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.13.4(Aug 14, 2020)

    C codes (Chapters 1--12) were tested with PETSc maint branch at v3.13.4 (df0e4300), and with v3.13.4 (edb2a3a2).

    Python codes (Chapters 13--14) were tested with Firedrake downloaded 11 July 2020 (8e730839); Firedrake PETSc v3.4.2-30276-g8aecd4c38f.

    Test machine: ed-galago ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.13.3(Jul 2, 2020)

    C codes (Chapters 1--12) were tested with PETSc maint branch (ed4d31eeb7) at v3.13.3.

    Python codes (Chapters 13--14) were tested with Firedrake downloaded 29 June 2020; Firedrake PETSc v3.4.2-30067-g937e954191.

    Test machine: bueler-thelio ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.13.2+3(Jun 29, 2020)

    C codes (Chapters 1--12) were tested with PETSc master branch at v3.13.2.

    Python codes (Chapters 13--14) were tested with Firedrake downloaded 29 June 2020; Firedrake PETSc v3.4.2-30067-g937e954191.

    Test machine: bueler-thelio ubuntu 20.04

    Changes: mesh._plex --> mesh._topology_dm in python/ch13/fish.py and python/ch14/fish.py

    Source code(tar.gz)
    Source code(zip)
  • v3.13.2+2(Jun 22, 2020)

    C codes (Chapters 1--12) were tested with PETSc master branch at v3.13.2.

    Python codes (Chapters 13--14) were tested with Firedrake downloaded 18 June 2020.

    Test machine: bueler-thelio ubuntu 20.04

    Changes: Issue #46 is fixed. The script c/ch10/msh2petsc.py now reads both current (4.1) and legacy (2.2) Gmsh formats.

    Source code(tar.gz)
    Source code(zip)
  • v3.13.2+1(Jun 18, 2020)

    C codes (Chapters 1--12) were tested with PETSc master branch at v3.13.2.

    Python codes (Chapters 13--14) were tested with Firedrake downloaded 18 June 2020.

    Gmsh version 4.5.6 was used in testing Chapter 10, but with -format msh22 to generate legacy (version 2.2) format. The default format is 4.1 now. When issue #46 is fixed, it should not matter which gmsh is used, and the -format option should be unnecessary.

    Test machine: bueler-thelio ubuntu 20.04

    Source code(tar.gz)
    Source code(zip)
  • v3.13.2(Jun 3, 2020)

    C codes (Chapters 1--12) were tested with PETSc master branch at v3.13.2.

    Python codes (Chapters 13--14) were tested with Firedrake downloaded 20 April 2020.

    Source code(tar.gz)
    Source code(zip)
  • v3.13.1(May 17, 2020)

    C codes (Chapters 1--12) were tested with PETSc master branch at v3.13.1.

    Python codes (Chapters 13--14) were tested with Firedrake downloaded 20 April 2020.

    Source code(tar.gz)
    Source code(zip)
  • v3.12.2(Nov 24, 2019)

  • v3.12.1(Oct 23, 2019)

Owner
Ed Bueler
Professor of Mathematics (Applied)
Ed Bueler
Generic parse tree, configurable lexer, `lemon` parser generator, wrapped for C++17 and Python 3.

This project augments the Lemon parser generator with a high-level parse tree interface, grammar action DSL, and an integrated, configurable lexer allowing the creation of an entire standalone, object-oriented parser from a single input grammar file. The entire parser is written in native C/C++, and the parser interface is made comfortably available to both C++ and Python3 applications.

Aubrey R. Jones 12 Dec 8, 2022
algos - Leetcode Algorithms with Python and C++

algos - Leetcode Algorithms with Python and C++ Dependencies (C++) C++ Compiler ( g++ or clang++ ) (C++) cmake (optional but recommended) (Python) Pyt

Alfonso Gonzalez 5 May 6, 2022
Tuplex is a parallel big data processing framework that runs data science pipelines written in Python at the speed of compiled code

Tuplex is a parallel big data processing framework that runs data science pipelines written in Python at the speed of compiled code. Tuplex has similar Python APIs to Apache Spark or Dask, but rather than invoking the Python interpreter, Tuplex generates optimized LLVM bytecode for the given pipeline and input data set.

Tuplex 791 Jan 4, 2023
A fast Python Common substrings of multiple strings library with C++ implementation

A fast Python Common substrings of multiple strings library with C++ implementation Having a bunch of strings, can I print some substrings which appea

Đào Nguyên Dương 7 Aug 21, 2022
Rajesh Kumar Sah 1 Nov 20, 2021
C++ DataFrame for statistical, Financial, and ML analysis -- in modern C++ using native types, continuous memory storage, and no pointers are involved

C++ DataFrame for statistical, Financial, and ML analysis -- in modern C++ using native types, continuous memory storage, and no pointers are involved

Hossein Moein 1.7k Jan 9, 2023
A simple single header 64 and 32 bit hash function using only add, sub, ror, and xor.

K-HASH A simple single header 64 bit hash function using only add, sub, ror, and xor. This a just general-purpose hash function for like making hash m

null 70 Dec 27, 2022
C header library for typed lists (using macros and "template" C).

vector.h C header library for typed lists (using macros and "template" C). Essentially, this is a resizable array of elements of your choosing that is

Christopher Swenson 33 Dec 19, 2022
C++ implementation of a fast hash map and hash set using hopscotch hashing

A C++ implementation of a fast hash map and hash set using hopscotch hashing The hopscotch-map library is a C++ implementation of a fast hash map and

Thibaut Goetghebuer-Planchon 578 Dec 23, 2022