Subfunction assign broken with Real functionspaces

Issue #160 duplicate
Simon Funke created an issue

Assigning a function to a subfunction produces unexpected results if the MixedFunctionSpace contains a real FunctionSpace:

from dolfin import *
mesh = UnitSquareMesh(32, 32)
Rho = FunctionSpace(mesh, "CG", 1)
R = FunctionSpace(mesh, "R", 0)

W = MixedFunctionSpace([Rho, R])
w = Function(W)
rho_init = project(Expression("x[0]"), Rho)

assign(w.sub(0), rho_init)  # Assign subspace, requires dolfin trunk 
plot(w[0])
interactive()

Comments (13)

  1. Johan Hake

    I think this can be traced to the DofMapBuilder. I would like to exclude global dofs from the graph reordering and block size estimation so that the same graph reordering is done for the CG sub space and the CG scalar space is the same.

    I also suggest we move all global dofs to the first dofs, which means that all dofs calculated by the graph reordering could just be offset with the number of global dofs. If you @garth.wells does not see any immediate troubles I will try to implement this. To accomplish this we might consider add DofMap::tabulate_local_cell_dofs which returns the indices into DofMap::cell_dofs for mesh entity dofs, that is excluding the global dofs. Such a method can come handy other places too.

  2. Johan Hake

    Yes, @blechta, the suggestion I sketch above would also fix the quadratic scaling as the global dof will be removed from the graph reordering.

  3. Johan Hake

    I just looked at the email thread again @blechta. Fixing the issue of assembling the global dofs is slightly different than fixing the graph sorting which screws up dof ordering for MixedSpaces with global dofs.

    However, if we add some sort of tabulation method to identify the global dofs to the DofMap, as sketched above, we can use that in the assembler to also try fixing the slowness of assemble global dofs and the non working OpenMPAssembler together with global dofs.

  4. Prof Garth Wells

    The proper fix is more fundamental. We need to allow sub-dofmap re-ordering - this is needed for efficient fieldsplit support.This will appear after v1.3 is released, and be available in v1.4.

    The performance of Real spaces is not a big deal - the design is fundamentally slow. A dense matrix row in a large sparse matrix is not good.

  5. Johan Hake

    Should there be a "not" between "will" and "appear"?

    I agree that sub-doffmap re-ordering should also be fixed in the same overhaul. But that can be accomplished by going through the hierarchy of dofmaps recursively while collecting the block structure. I then had in mind that leaf dofmaps with a single global dof should just be ignored in such a search, as they should be extracted from the graph algorithm anyhow.

    Your point that having a dense row in a sparse matrix is a bad idea is of course correct. But Real spaces are very useful and there are parts in the DOLFIN design which can be improved to adrdess some of the slowness.

  6. Prof Garth Wells

    @johanhake I've edited by comment - it will arrive post v1.3, and will be available in the dev version pre v1.4.

  7. Johan Hake

    Ok, do you think we should add some sort of warning for the FunctionAssigner as this fix will not go into the 1.3 release?

  8. Log in to comment