firedrakeproject/firedrake — pull request #415 by wence- (2014-12-04 14:28:46+00:00)
Title: Multigrid automation

This implements support for geometric multigrid on triangular meshes for arbitrary order CG and DG spaces. Along with some special-cased support for DG0 on Extruded triangular meshes.

The lovely automatic interface is not there yet. Two sketches of how things can work are implemented in demos/multigrid_sketches. One implementing standard linear MG for the Poisson equation in P2, the other FAS (nonlinear multigrid) for the same problem. I'd like to get this merged now so that the basic support is in place for doing more things.

Minor changes to non-multigrid behaviour:

- Most of the mesh construction (in particular getting the right halos) is now delayed until mesh.init(). This happens automatically in most cases (e.g. building a function space), but sometimes you need to call things manually:

e.g.

Previously
```
from firedrake import *
m = UnitSquareMesh()
c = Constant(1)

assemble(c*dx)
```

will now fail (because the mesh hasn't been fully built and is not attached to the measure). You instead need to do:

```python
from firedrake import *
m = UnitSquareMesh(1, 1)
c = Constant(1, domain=m)
assemble(c*dx)
```

I need this delay because to build a mesh hierarchy in parallel I need to refine the non-overlapped DM, rather than the overlapped one. So the distribution is split into two phases: 1. distribute without overlapping; 2. grow overlap. I can then insert refinement in between 1 and 2.

Comments and suggestions welcome.

To run the demos, you need an up to date petsc4py and petsc (the mapdes firedrake branches will work, as will petsc/petsc4py master). They demonstrate convergence to O(discretisation error) in 1 F-cycle (which is what is expected for such a friendly problem).