Generate factory functions to construct ufc classes from python

Issue #89 resolved
Martin Sandve Alnæs created an issue
  1. Add factory function ufc::foo * create_%(classname)s() to templates in ffc/backends/ufc for all ufc classes. See dijitso, use DLLEXPORT defines found there. Templates should contain function declaration (header template), function definition (implementation template) or inline definition (combined template) respectively.

  2. Use these factory functions to construct form and elements in ffc jit, i.e. module.create_foo() instead of module.foo(). This construction approach will work with ctypes later.

Dolfin will still depend on some small parts of the ufc swig interface. One possibility in the short term might be to move ufc.i to dolfin while keeping ufc.h in ffc. Removing ufc.i completely is not possible before the ctypes based jit is completed.

Comments (7)

  1. Martin Sandve Alnæs reporter

    The end goal of this issue is that these functions:

    def _instantiate_form(module, prefix):
        "Extract the form from module with only one form."
        form_id = 0
        classname = make_classname(prefix, "form", form_id)
        return getattr(module, classname)()
    
    def _instantiate_element_and_dofmap(module, prefix):
        """Extract element and dofmap from module."""
        form = _instantiate_form(module, prefix)
        fe = form.create_finite_element(0)
        dm = form.create_dofmap(0)
        return (fe, dm)
    

    are changed to call a standalone factory function module.create_<hash>() instead of the C++ constructor of form (which requires swig) and the form.create_foo(0) (which requires swig).

  2. Martin Sandve Alnæs reporter

    There are already some facatory function templates in ffc/backends/ufc/ but they're not in use.

  3. Log in to comment