Passing SubDomains to assembler from Python is broken
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)
-
-
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).
-
I actually didn't know it was there until recently. And the behaviour surprised me.
-
reporter It can be documented, but that doesn't make code that did work, then silently stopped working, start working again.
-
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.
-
Agree that it should be removed.
-
It's used in the book tests though. What do we do with those? Rewrite them so they do the equivalent thing?
-
I fixed the demo.
-
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
-
-
assigned issue to
-
assigned issue to
-
Fix on its way.
-
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.
-
- changed status to resolved
The automatic conversion of SubDomain to MeshFunction in assemble() and friends is removed in 249cb38e367bd555cf28a19b8424cf33e36230fd / c5a21c63570c53a25a29927bfae3f38823495394
-
reporter - removed milestone
Removing milestone: 1.4 (automated comment)
- Log in to comment
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.