DirichletBC does not support changes in meshfunction
Consider the following test case:
from dolfin import *
mesh = UnitSquareMesh(4,4)
V = FunctionSpace(mesh, "CG", 1)
mf = FacetFunction("size_t", mesh)
mf.set_all(0)
CompiledSubDomain("x[0]<1e-12").mark(mf,1)
bc = DirichletBC(V, Constant(1), mf, 1)
u = Function(V)
bc.apply(u.vector())
print assemble(u*dx)
mf.set_all(1)
bc.apply(u.vector())
print assemble(u*dx) # Should be 1
bc = DirichletBC(V, Constant(1), mf, 1)
bc.apply(u.vector())
print assemble(u*dx)
DirichletBC does not capture the changes in the meshfunction (or any other mode of setting subdomains), because DirichletBC::init_facets are only computed once. Re-computing facets is of course costly, so I suggest perhaps exposing a parameter allowing for dynamic domains (e.g. recompute_facets)?
Comments (6)
-
-
If the bc objec thas been passed to a LinearVariationalProblem?
-
reporter I'm not sure of the benefits, but I found the behaviour counter-intuitive. You can change the subdomain data until you call apply, but not after. Perhaps the facets should be computed in the constructor?
-
Note that the behaviour has been only recently documented 3b98e5d4cfd7f4ae97e07343b70bca5a3a7ccfc6
-
- removed milestone
Removing milestone: 1.7 (automated comment)
-
- changed status to wontfix
The current behaviour is now documented. Feel free to implement a method for clearing DOF index cache. Closing this due to inactivity,
- Log in to comment
Is there a benefit to allowing the facets to be re-computed over creating a new
DirichletBC
object if the bc facets change?