bempp/bempp — pull request #155 by mdavezac (2014-09-02 11:08:50+00:00)
Title: Rsdt/cython spaces

Adds wrappers for spaces. At this point there are only a few scalar spaces, but adding others should be fairly straight forward.

Usage
--------

~~~~{.ipython}
>>> from os.path import join
>>> from bempp import scalar_space, Grid, config
>>> grid = Grid(topology='triangular', filename=join(config.paths.meshes, 'cube-h-0.1.msh'))
>>> constant = scalar_spaces(grid, 'float32')
~~~~

A number of options are available. For instance:

~~~~{.ipython}
>>> quadratic = scalar_spaces(grid, 'float32', order=2)
~~~~

Trying to create a space for which there is no wrapper will generate a ValueError. A table with the available spaces is located in the docstring of the function.

Implementation
--------------------

A base class Space that wraps the similar class in C++ is created. It contains a number of shared pointer to Space instantiations for each of floats, doubles, and complex. Methods of this class should check which pointer is valid and use it, as is done in the property dtype. The exact number of types can be set in python/mako/space.py:dtypes.

Derived types are created for each specialized space. However, this a flat inheritance hierarchy that does not follow the c++ hierarchy. The derived types are meant to call the right constructor during initialization.

The spaces are declared in python/mako/space.py in the structure spaces. The type of the space (dual, continuous...) is generally guessed from the name. However, any option can be modified by setting it in the space dictionary. Currently, there are two implementations: one for constructors taking only a grid as argument, and another for constructors taking a grid and an integer (for polynomial spaces).