firedrakeproject / firedrake

Firedrake is an automated system for the portable solution of partial differential equations using the finite element method (FEM)
https://firedrakeproject.org
Other
498 stars 157 forks source link

SLATE compilation error #1074

Closed stephankramer closed 7 years ago

stephankramer commented 7 years ago

I am trying to use SLATE to implement a preconditioner for a Schur system A11-A10 A00^{-1} A01, where A00 is a DG mass matrix that assembles the Schur system explicitly (on @wence- 's suggestion here: https://github.com/thetisproject/thetis/pull/97#discussion_r116945058). The relevant code is:

    mass = Tensor(dot(v, u)*dx)
    fs = dict(formmanipulation.split_form(a))
    A01 = Tensor(fs[(0, 1)])
    A10 = Tensor(fs[(1, 0)])
    A11 = Tensor(fs[(1, 1)])
    S = A11 - A10*mass.inv*A01

    Smat = assemble(S, form_compiler_parameters=ctx.fc_params)
    Smat.force_evaluation()

here a is the form of the coupled SWE system (only linear terms). This fails in the last step with a compilation error because the generated code contains a subroutine:

static inline void compile_slate (double  A4[6][6] , double **  coords , double *  w_0 , double **  w_1 , double **  w_2_0 , double **  w_2_1 , double *  w_3 , double **  w_4_0 , double **  w_6 , double **  w_5 , double **  w_6 , double **  w_7 , double *  w_8 )

which contains a w_6 argument twice.

Unfortunately I haven't been able to reproduce in a standalone test yet. To reproduce in thetis, checkout the assembledschur-slate branch of thetis, and run py.test -k pressurep -svx test/swe2d/test_standing_wave.py.

thomasgibson commented 7 years ago

I can reproduce this and I'll have a close look at it. Thanks for letting us know

thomasgibson commented 7 years ago

Just an update: I believe I fixed the issue in https://github.com/firedrakeproject/firedrake/tree/slate-coefficient-fix.

I had to make a minor change in thetis/assembledschur.py because cxt was being called out of scope. Making cxt a class attribute fixed that. With my firedrake branch, the test seems to be passing.

I will clean up the branch and submit a PR into Firedrake master soon!

thomasgibson commented 7 years ago

Fixed in https://github.com/firedrakeproject/firedrake/pull/1077.