Custom integrals fail for higher order derivatives

Issue #46 resolved
Anders Logg (Chalmers) created an issue

Code generated for the following example:

a = inner(div(grad(u)), div(grad(v)))*dc

fails to compile (on the C++ side) due to screwed up FE tables:

error: 
redefinition of 'FE0_C0_D11'
std::vector<std::vector<double> > FE0_C0_D11(num_quadrature_points);

Comments (5)

  1. Prof Garth Wells

    Where is the std::vector<std::vector<double> >? In the generated code? std::vector<std::vector<double> > does come with some overhead because of the multiple memory allocations.

  2. Anders Logg (Chalmers) reporter

    It is used in place of the static arrays used for normal quadrature code, for example:

    static const double FE1_C0_D10[6][15]
    

    For custom_integral, the number of quadrature points is not known at compile time so it needs to be dynamics (or of a large fixed max size):

    // Create table FE0_C0_D10 for basis function derivatives on all cells
    std::vector<std::vector<double> > FE0_C0_D10(num_quadrature_points);
    for (std::size_t ip = 0; ip < num_quadrature_points; ip++)
        FE0_C0_D10[ip].resize(15);
    

    Yes, this is likely expensive and can be improved by flattening the arrays, but there are already something like 3 levels of offset computing (basis function index, component, derivative) so I didn't want to add a 4th until I knew things worked ok. Plus the code generation relies on reusing the standard code generation for quadrature as much as possible, hence a similar data structure.

  3. Log in to comment