-
assigned issue to
CompiledSubDomain weird behaviour
Issue #125
resolved
The code is self-explanatory:
from dolfin import *
import sys
def only_top(bfun) :
top = CompiledSubDomain("near(x[1], 1.0) && on_boundary")
bfun.set_all(0)
top.mark(bfun, 1)
print(bfun.array())
def only_bottom(bfun) :
bottom = CompiledSubDomain("near(x[1], 0.0) && on_boundary")
bfun.set_all(0)
bottom.mark(bfun, 2)
print(bfun.array())
if __name__ == "__main__" :
mesh = UnitSquareMesh(2, 2)
bfun = FacetFunctionSizet(mesh)
if len(sys.argv) < 2 :
sys.exit("Usage: %s [top|bottom]" % sys.argv[0])
if "top" in sys.argv[1:] :
only_top(bfun)
if "bottom" in sys.argv[1:] :
only_bottom(bfun)
The output for different calls:
ok-mbpro:pkgs simone$ python compilesubdomain_bug.py top
[0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1]
ok-mbpro:pkgs simone$ python compilesubdomain_bug.py bottom
[0 0 2 0 0 0 0 2 0 0 0 0 0 0 0 0]
ok-mbpro:pkgs simone$ python compilesubdomain_bug.py top bottom
[0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1]
[0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 2]
I wasn't able to track the problem. It might be related to my current installation (SWIG 2.0.11, just updated), or to the code.
The first can be easily ruled out once you try the code too on a different configuration.
About the second possibility, "bottom" and "top" objects points to different generated code (by looking at the signature), and the generated codes in .i files are different. But when I load both, the "top" hides "bottom".
So I conclude that the problem is the loading, not the compiling.
Comments (3)
-
-
It is not clear to me what is wrong? My output is:
[hake@skalman] ~/tmp/simone > py test_subdomains.py top Calling DOLFIN just-in-time (JIT) compiler, this may take some time. [0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1] [hake@skalman] ~/tmp/simone > py test_subdomains.py bottom Calling DOLFIN just-in-time (JIT) compiler, this may take some time. [0 0 2 0 0 0 0 2 0 0 0 0 0 0 0 0] [hake@skalman] ~/tmp/simone > py test_subdomains.py top bottom [0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1] [0 0 2 0 0 0 0 2 0 0 0 0 0 0 0 0]
which looks correct.
-
- changed status to resolved
Fixed by: c6d76add31addbd21bbe0ca4efae040d6118433a
- Log in to comment