firedrakeproject/firedrake — pull request #410 by miklos1 (2014-12-03 13:00:28+00:00)
Title: Refactor mesh code

This set of changes has started as an attempt to properly fix the ugly ```self.__class__ = QuadrilateralMesh``` hack, but ended up being an extensive refactoring of ```mesh.py```.

I first tried declaring a ```__new__``` method to determine the type before creating the object, but that approach proved insufficient, because it provides no way to change the argument list which is passed to ```__init__```. I tried some metaclass voodoo next, but turned turned out to be especially ugly, since metaclasses are inherited, so additional metaclass voodoo was required to revert the behaviour for ```ExtrudedMesh```. This seemed as too much of magic, when a simple factory function could suffice.

The primary reason of this pull request is to open a discussion and ask for comments. I don't recommend merging yet, as some of the mesh file types lack test coverage.