Passing SubDomains to assembler from Python is broken

Issue #226 resolved
Prof Garth Wells created an issue

Passing SubDomains to a Python assembler doesn't make sense following the change that dx != dx(0) in forms. Demo demo/undocumented/lift-drag result is wrong because of this bug.

Comments (14)

  1. Martin Sandve Alnæs

    It never made sense to me, I always use markers. It still works with dx (0), it just needs to be documented what it does.

  2. Prof Garth Wells reporter

    Should we deprecate or maybe remove it? An argument in favour of removal is that code that uses it an has not been updated will behave unexpectedly (as is the case for the lift-drag demo).

  3. Prof Garth Wells reporter

    It can be documented, but that doesn't make code that did work, then silently stopped working, start working again.

  4. Martin Sandve Alnæs

    I say remove it completely. It doesn't and never did conform to the documentation of the role of domain data in ufl. There are probably other pitfalls with its use.

  5. Martin Sandve Alnæs

    It's used in the book tests though. What do we do with those? Rewrite them so they do the equivalent thing?

  6. Martin Sandve Alnæs

    I'm removing it from the assembler. If anyone needs to transition their code to proper meshfunctions, here's a helper function:

    def subdomain_to_meshfunction(subdomain, codim, marked_value=1, unmarked_value=0):
        dim = mesh.topology().dim() - codim
        mf = cpp.MeshFunction("size_t", mesh, dim)
        mf.set_all(unmarked_value)
        subdomain.mark(mf, marked_value)
        return mf
    
  7. Martin Sandve Alnæs

    The book test that uses this feature (chapter10.py, TestPage30.test_box_1) doesn't assemble the form, so the test doesn't fail, but that doesn't make it valid code. Maybe someone should update the book text as well. I don't feel particularly responsible for that task.

    I suspect there may be other book tests that don't fail for similar reasons, i.e. defining something is possible but using it in the intended way is not. In other words the protection we get from the book unit tests is fairly weak.

  8. Log in to comment