Reduce number of ufc::form functions

Issue #31 new
Martin Sandve Alnæs created an issue

Along one dimension, ufc::form has a number of functions for each integral type:

    /// Return the number of cell domains
    virtual std::size_t num_cell_domains() const = 0;

    /// Return whether form has any cell integrals
    virtual bool has_cell_integrals() const = 0;

    /// Create a new cell integral on sub domain i
    virtual cell_integral* create_cell_integral(std::size_t i) const = 0;

    /// Create a new cell integral on everywhere else
    virtual cell_integral* create_default_cell_integral() const = 0;

This can be reduced to:

    /// Create new cell integrals, default and on all sub domains
    virtual std::pair<cell_integral*, std::vector<cell_integral*>> create_cell_integrals() const = 0;

or something similar, whatever is most convenient in dolfin.

Along another dimension, there are many integral types: cell, exterior_facet, interior_facet, point, custom. These can be made into enums or we can even use strings for full flexibility because these functions are only called rarely. Then we get:

    /// Create new integrals of given type, default and on all sub domains
    virtual std::pair<integral*, std::vector<integral*>> create_integrals(std::string type) const = 0;

instead of the 20 functions we have today. We might want to keep "has_integrals" in a generic form for convenience in dolfin:

    /// Has integrals of given type
    virtual bool has_integrals(std::string type) const = 0;

All details subject to whatever's convenient in dolfin code that uses this, these things are easy to generate however we want from ffc.

Comments (7)

  1. Martin Sandve Alnæs reporter

    The backside of doing this would be the need to do dynamic_cast<cell_integral*> etc. a few places in dolfin. Is that an ok tradeoff? I think it can be limited to UFC.cpp.

  2. Log in to comment