Form Compilation On Subdomains

Hi,

I am not entirely sure whether this is the correct category. In my Fenics Code I use avoided assembly to preassemble fixed parts of my problem like so:

def assemble_stiffness_matrices(trial1,trial2,test1,test2,measure,subdomain=None):
    """ Assembly of stiffness matrices

    Parameters
    ----------
    trial[1,2]: UFL TrialFunctions, the Legendremoments of the flux
    test[1,2]:  UFL TestFunctions, the test functions for the weak formulation
                from the same functionspace as trial[1,2]
    measure:    UFL Measure, spatial measure to use in assembly of weak form
    subdomain:  int, identifier for subdomain, needs to be plain python int! If
                not set, the whole domain is taken into account

    Returns
    -------
    K00, K02, K22:  Assembled matrices of determined la backend, default is PETSc
    """
    if subdomain is not None:
        a_K00 = inner(grad(trial1),grad(test1)) * measure(subdomain)
        a_K20 = inner(grad(trial2),grad(test1)) * measure(subdomain)
        a_K22 = inner(grad(trial2),grad(test2)) * measure(subdomain)
    else:
        a_K00 = inner(grad(trial1),grad(test1)) * measure
        a_K20 = inner(grad(trial2),grad(test1)) * measure
        a_K22 = inner(grad(trial2),grad(test2)) * measure
    return assemble(a_K00), assemble(a_K20), assemble(a_K22)

Because I am interested in the solution spatially integrated over each subdomain I define the measure to be specific for each subdomain. When I look at the code generated by dijitso it only differs in ids for the different classes. So is there a way to use the function without the subdomain specification and still get results integrated over each subdomain, respectively, after the code is finished?

Besides the case with subdomain != None uses humongous amounts of RAM on FFC-compilation.
Thanks in advance for your help.