Software for Numerical Methods for Partial Differential Equations

This software was developed for and by the students in CS 615, Numerical Methods for Partial Differential Equations. Its goal is to implement the finite element method in two dimensions. It is written in Scheme, and uses some features of Gambit-C, the Scheme->C compiler written by Marc Feeley. It uses Meroon, developed by Christian Queinnec, as its object system. (The version of Meroon we used is available here.) The last two files are the files used to build this index page.

Note: This software is a work in progress. While much of it works as intended, much of it has not yet even been tested.

The code passes the tests in final-tests.scm. Note that with the infrastructure that we have built, it is trivial to compute things like the L2 and H1 norms of the error.

The file parabolic.scm contains a solver for parabolic differential equations, and the file mmoc.scm contains a solver for transport-dominated diffusion problems.

Changelog

all.scm

• Pervasive macros:
• (FLOAT . rest)
• (FIX . rest)
• Includes:
• utilities.scm
• sort.scm
• linear-algebra.scm
• sparse-linear-algebra.scm
• points.scm
• geometry.scm
• geometry-code.scm
• linear-elements.scm
• linear-elements-code.scm
• problem-descriptions.scm
• intergrid.scm
• multigrid.scm
• obstacle.scm
• parabolic.scm
• mmoc.scm
• polygon.scm

utilities.scm

• Generic functions:
• (check-same-class (x Object) y)
• Functions:
• (reverse-append! xrev y)
• (keep p l)
• (map1 f l)
• (map2 f l1 l2)
• (mappend1 f l)
• (reduce-from-left op id l)
• (reduce-from-right op id l)
• (vector-for-each-1 proc v)
• (vector-for-each-with-index-1 proc v)
• (vector-map-1 f v)
• (vector-map-2 f v1 v2)

sort.scm

• Functions:
• (sorted? seq less?)
• (merge a b less?)
• (merge! a b less?)
• (sort! seq less?)
• (sort seq less?)

linear-algebra.scm

• Classes:
• Operator
• Blocked-vector
• Matrix-operator
• Generic functions:
• (Vector-subtract (x) y)
• (Vector-scale x (y))
• (Vector-*axpy a (x) y)
• (Vector-copy (x))
• (Lattice-max (x) y)
• (Lattice-min (x) y)
• (Vector-dimension (x))
• (Vector-zero (x))
• (Vector-dot-product (x) y)
• (Vector-inner-product (x) (operator Operator) y)
• (Vector-L2-norm (x))
• (Vector-Linf-norm (x))
• (Vector-L1-norm (x))
• (Operator-compose (op1 Operator) (op2 Operator))
• (Operator->identity (op Operator))
• Methods:
• (Vector-subtract (x Blocked-vector) y)
• (Vector-scale a (x Blocked-vector))
• (Vector-*axpy a (x Blocked-vector) y)
• (Vector-copy (x Blocked-vector))
• (Vector-zero (x Blocked-vector))
• (Lattice-max (x Blocked-vector) y)
• (Lattice-min (x Blocked-vector) y)
• (initialize! (op Matrix-operator))
• Functions:
• (Operator-apply op v)
• Other objects:
• identity-operator

sparse-linear-algebra.scm

• Classes:
• Sparse-matrix
• Sparse-matrix-operator
• Operator-with-matrix-implementation
• Methods:
• (check-same-class (m Sparse-matrix) n)
• (Vector-subtract (m Sparse-matrix) n)
• (Vector-scale a (m Sparse-matrix))
• (Vector-*axpy a (m Sparse-matrix) n)
• (Operator-compose (m Sparse-matrix) (n Sparse-matrix))
• (initialize! (m Sparse-matrix-operator))
• (->Sparse-matrix (m Sparse-matrix-operator))
• (->Sparse-matrix-operator (m Sparse-matrix))
• (Vector-subtract (m Sparse-matrix-operator) n)
• (Vector-scale a (m Sparse-matrix-operator))
• (Vector-*axpy a (m Sparse-matrix-operator) n)
• (Vector-Linf-norm (m Sparse-matrix-operator))
• (Operator->identity (m Sparse-matrix-operator))
• (Operator-compose (op1 Sparse-matrix-operator) (op2 Sparse-matrix-operator))
• Functions:
• (Sparse-vector-subtract x-entries y-entries)
• (Sparse-vector-scale x y-entries)
• (Sparse-vector-*axpy a x-entries y-entries)
• (Sparse-matrix-operator-increment-entry m i j value)
• Other objects:
• Sparse-vector-zero
• Local macros:
• (make-Entry index coefficient)
• (Entry-index e)
• (Entry-coefficient e)
• (setup-indices)

points.scm

• Functions:
• (make-Point x y)
• (Point-x p)
• (Point-y p)
• (Point-x-set! p val)
• (Point-y-set! p val)
• (Point? p)
• (Point-subtract p1 p2)
• (Point-scale x p)
• (Point-dot-product p1 p2)
• (Point-L2-norm p)
• (Point-zero)

geometry.scm

• Classes:
• Vertex
• Boundary-vertex
• Edge
• Boundary-edge
• Triangle
• Triangulation
• Curved-edge
• Triangle-with-curved-side
• Methods:
• (initialize! (t Triangulation))
• Functions:
• (Vertex-for-each-edge proc v)
• (Vertex-edges<-list l)
• (Vertex-edges->list e)
• (Vertex-edges-length v)
• (Vertex-contains-edge? v e)
• (Boundary-vertex-for-each-boundary-edge proc v)
• (Boundary-vertex-boundary-edges<-list l)
• (Boundary-vertex-boundary-edges->list e)
• (Boundary-vertex-boundary-edges-length v)
• (Boundary-vertex-contains-boundary-edge? v e)
• (Edge-for-each-vertex proc e)
• (Edge-contains-vertex? e v)
• (Edge-length e)
• (Triangle-for-each-vertex proc t)
• (Triangle-for-each-edge proc t)
• (Triangle-contains-vertex? t v)
• (Triangle-contains-edge? t e)
• (Triangle-area t)
• (make-limits #!optional (x-max -inf.) (x-min +inf.) (y-max -inf.) (y-min +inf.))
• (x-min limits)
• (x-min-set! limits val)
• (x-max limits)
• (x-max-set! limits val)
• (y-min limits)
• (y-min-set! limits val)
• (y-max limits)
• (y-max-set! limits val)
• (Triangulation-Hilbert-curve-sort! t)
• (Triangulation-z-curve-sort! t)
• (Triangulation-Gray-code-curve-sort! t)
• (Triangulation-Sierpinski-curve-sort! t)
• (Triangulation-lexicographical-sort! t)
• (Triangulation-vertices<-list l)
• (Triangulation-vertices->list v)
• (Triangulation-vertices-length t)
• (Triangulation-boundary-vertices<-list l)
• (Triangulation-boundary-vertices->list v)
• (Triangulation-boundary-vertices-length t)
• (Triangulation-edges<-list l)
• (Triangulation-edges->list e)
• (Triangulation-edges-length t)
• (Triangulation-boundary-edges<-list l)
• (Triangulation-boundary-edges->list e)
• (Triangulation-boundary-edges-length t)
• (Triangulation-triangles<-list l)
• (Triangulation-triangles->list t)
• (Triangulation-triangles-length t)
• (Triangulation-for-each-vertex proc t)
• (Triangulation-for-each-edge proc t)
• (Triangulation-for-each-triangle proc t)
• (Triangulation-for-each-boundary-vertex proc t)
• (Triangulation-for-each-boundary-edge proc t)
• Other objects:
• Triangulation-sort!

geometry-code.scm

• Generic functions:
• (refine (o))
• Methods:
• (refine (v Vertex))
• (refine (v Boundary-vertex))
• (refine (e Edge))
• (refine (e Boundary-edge))
• (refine (t Triangle))
• (refine (t Triangulation))
• Functions:
• (Triangulation-consistent? t)
• Other objects:
• coarse-square-triangulation

linear-elements.scm

• Classes:
• Element
• Linear-element
• Finite-element-space
• Linear-finite-element-space
• Finite-element-vector
• Linear-finite-element-vector
• Methods:
• (initialize! (e Element))
• (initialize! (v Finite-element-vector))
• (Vector-dimension (x Finite-element-vector))
• (check-same-class (x Finite-element-vector) y)
• (Vector-subtract (x Finite-element-vector) y)
• (Vector-scale x (y Finite-element-vector))
• (Vector-*axpy a (x Finite-element-vector) y)
• (Vector-dot-product (x Finite-element-vector) y)
• (Vector-zero (x Finite-element-vector))
• (Vector-copy (x Finite-element-vector))
• (Lattice-min (x Linear-finite-element-vector) y)
• (Lattice-max (x Linear-finite-element-vector) y)
• Functions:
• (Neighbors->list n)
• (Neighbors<-list l)
• (Neighbors-ref n i)
• (Neighbors-set! n i val)
• (Neighbors-length n)
• (Finite-element-space-elements->list e)
• (Finite-element-space-elements<-list l)
• (Finite-element-space-neighbors->list e)
• (Finite-element-space-neighbors<-list l)
• (Finite-element-space-neighbors-length space)

linear-elements-code.scm

• Classes:
• Finite-element-operator
• Linear-finite-element-operator
• Generic functions:
• (Edge-midpoint (e))
• (Triangle-stiffness (t Triangle) as m)
• (Triangle-transport (t Triangle) bs m)
• (Triangle-mass (t Triangle) cs m)
• (Edge-boundary-term (e Edge) gamma m)
• (Triangle-interior-integral (t Triangle) fs data)
• (Edge-boundary-integral (e Edge) g data)
• Methods:
• (initialize! (o Linear-finite-element-operator))
• (->Linear-finite-element-operator (space Linear-finite-element-space))
• (check-same-class (m Linear-finite-element-operator) n)
• (Vector-subtract (m Linear-finite-element-operator) n)
• (Vector-scale a (m Linear-finite-element-operator))
• (Vector-*axpy a (m Linear-finite-element-operator) n)
• (Vector-Linf-norm (m Operator-with-matrix-implementation))
• (Operator-compose (op1 Linear-finite-element-operator) (op2 Linear-finite-element-operator op2))
• (Operator->identity (m Linear-finite-element-operator))
• (Edge-midpoint (e Edge))
• Functions:
• (Triangulation->Linear-finite-element-space t)
• (wrap-matrix-implementation-in-linear-finite-element-operator matrix domain-space range-space)
• Other objects:
• left-gauss-point
• right-gauss-point

problem-descriptions.scm

• Classes:
• Problem-data

• Classes:
• Generic functions:
• (diagonal-preconditioner (m))
• (gauss-seidel-smoother! (m))
• (richardson-smoother! (m))
• (jacobi-smoother! (m))
• (gauss-seidel-preconditioner (m))
• Methods:
• (diagonal-preconditioner (m Sparse-matrix-operator))
• (diagonal-preconditioner (m Linear-finite-element-operator))
• (gauss-seidel-smoother! (m Sparse-matrix-operator))
• (gauss-seidel-smoother! (m Linear-finite-element-operator))
• (richardson-smoother! (m Sparse-matrix-operator))
• (richardson-smoother! (m Linear-finite-element-operator))
• (jacobi-smoother! (m Sparse-matrix-operator))
• (jacobi-smoother! (m Linear-finite-element-operator))
• (gauss-seidel-preconditioner (m Linear-finite-element-operator))
• Functions:
• (CG-build-data triangulation space)
• (CG-add-solver-information! cg-data preconditioner-operator preconditioner-description iteration-limit residual-limit)
• (conjugate-gradient A b stop-iterations? #!optional (preconditioner identity-operator))

intergrid.scm

• Functions:
• (coarse<-fine coarse-space fine-space)
• (projector->injector m)

multigrid.scm

• Classes:
• Multigrid-data
• Generic functions:
• (MG-solver (data))
• (MG-build-data (data) coarse-triangulation number-of-refinements)
• (MG-propagate-level-information! (multigrid-data))
• (MG-add-solver-information! (multigrid-data) smoother-maker smoother-name r m1 m2 p)
• Methods:
• (MG-solver (data Multigrid-data))
• (MG-build-data (data Multigrid-data) coarse-triangulation number-of-refinements)
• (MG-propagate-level-information! (multigrid-data Multigrid-data))
• (MG-add-solver-information! (multigrid-data Multigrid-data) smoother-maker smoother-name r m1 m2 p)
• Functions:
• (MG-step data smoothers! m1 m2 p k z0 rhs)

parabolic.scm

• Functions:
• (parabolic-equation-solution a c f g gamma u0 fes T n backward-difference-steps)

mmoc.scm

• Functions:
• (add-displaced-capacity-terms! rhs u characteristic-bases capacity)
• (cu-at-displaced-edge-midpoints c u characteristic-bases)
• (calculate-characteristic-bases triangulation flow)
• (Point-in-triangle? p t)
• (solve-transport-problem c a b u0 f delta-t space N)

obstacle.scm

• Classes:
• Obstacle-multigrid-data
• Obstacle-problem-data
• Methods:
• (MG-solver (data Obstacle-multigrid-data))
• (MG-build-data (data Obstacle-multigrid-data) coarse-triangulation number-of-refinements)
• (MG-propagate-level-information! (multigrid-data Obstacle-multigrid-data))
• (MG-add-solver-information! (multigrid-data Obstacle-multigrid-data) smoother-maker smoother-name r m1 m2 p)
• Functions:
• (Obstacle-MG-step data smoothers! m1 m2 p k z0 rhs obstacle)

polygon.scm

• Classes:
• Polygon-vertex
• Functions:
• (next-polygon-vertex v)
• (previous-polygon-vertex v)
• (Triangulation<-points l)

final-tests.scm

• Functions:
• (run-test check solver-thunk)
• (run-multigrid-tests tests)
• (run-cg-tests tests)
• Other objects:
• number-of-refinements
• mg-data
• t
• fes
• cg-data
• fine-t
• fine-fes
• L2-inner-product-operator
• H1-inner-product-operator
• coarse->fine-operator
• symmetric-tests
• nonsymmetric-tests
• Includes:
• points.scm

final-tests-obstacle.scm

• Functions:
• (run-test check solver-thunk)
• (run-multigrid-tests tests)
• Other objects:
• number-of-refinements
• fine-mg-data
• mg-data
• t
• fes
• fine-t
• fine-fes
• L2-inner-product-operator
• H1-inner-product-operator
• coarse->fine-operator
• symmetric-tests
• Includes:
• points.scm

test.scm

• Functions:
• (iter i)
• Other objects:
• t
• fes
• m
• vec1
• result
• check
• Includes:
• points.scm

test-parabolic.scm

• Functions:
• (u t p)
• (test-solution)
• Other objects:
• a
• c
• f
• g
• gamma
• u0
• N
• T
• K
• delta-t
• triangulation
• fes
• L2-inner-product-operator
• stopping-criterion
• Includes:
• points.scm

test-mmoc.scm

• Functions:
• (square x)
• Other objects:
• triangulation
• space
• u
• L2-inner-product-operator
• H1-inner-product-operator
• solution
• difference
• L2-error
• H1-error
• Includes:
• points.scm

tex.scm

• Generic functions:
• (->texdraw (p))
• Methods:
• (->texdraw (e Edge))
• (->texdraw (e Curved-edge))
• Functions:
• (printable x)
• (texdraw-text text location)
• (Triangulation-edges->texdraw t)
• (Triangulation-triangles->texdraw t #!optional (label-vertices? #t))
• (draw-triangulation-debug-diagram t name)
• (draw-linear-finite-element-vector-debug-diagram v name)

html-lib.scm

• Functions:
• (html->string x)
• (html-display x . possible-port)
• (<unprotected> . args)
• (html-parse-args form-name end-tag? attribute-alist single-attribute-alist args)
• (html-build-form tag-name attribute-alist single-attribute-alist args start-newline? end-tag-start-newline? end-tag?)
• Other objects:
• html:degree
• HTML tags:
• a
• abbr
• acronym
• applet
• area
• b
• base
• basefont
• bdo
• big
• blockquote
• body
• br
• button
• caption
• center
• cite
• code
• col
• colgroup
• dd
• del
• dfn
• dir
• div
• dl
• dt
• em
• field-set
• font
• form
• frame
• frameset
• h1
• h2
• h3
• h4
• h5
• h6
• hr
• html
• i
• iframe
• img
• ins
• isindex
• kbd
• label
• legend
• li
• map
• meta
• noframes
• noscript
• object
• ol
• optgroup
• option
• p
• param
• plaintext
• pre
• q
• s
• samp
• script
• select
• small
• span
• strike
• strong
• style
• sub
• sup
• table
• td
• textarea
• tfoot
• th
• title
• tr
• tt
• u
• ul
• var

describe.scm

• Functions:
• (display-objects title os)
• (all-null? l)
• (category-name c)
• (category-recognizer c)
• (category-extractor c)
• (get-forms)
• (make-page all-forms)
• (display-page page)
• (build-index)
• Other objects:
• input-files
• categories
• Includes:
• html-lib.scm