← Back to team overview

dolfin team mailing list archive

[Bug 747289] Re: Python: DirichletBC arguments are deleted early

 

** Branch linked: lp:~dolfin-core/dolfin/wells

-- 
You received this bug notification because you are a member of DOLFIN
Team, which is subscribed to DOLFIN.
https://bugs.launchpad.net/bugs/747289

Title:
  Python: DirichletBC arguments are deleted early

Status in DOLFIN:
  Fix Committed

Bug description:
  The following code fails with a strange error:
  -----
  from dolfin import *
  class Boundary(SubDomain):
      def inside(self, x, on_boundary):
          return on_boundary
  class BoundaryFunction(Expression):
      def eval(self, values, x):
          values[0] = 1 if near(x[1],1) else 0
  mesh = UnitSquare(2,2)
  V = FunctionSpace(mesh, "CG", 1)
  v,u = TestFunction(V), TrialFunction(V)
  A = assemble(v*u*dx)

  bc = DirichletBC(V, BoundaryFunction(), Boundary())
  bc.apply(A)
  -----
  Replacing the bc = line as follows also fails, with a different strange error:
  -----
  bf = BoundaryFunction()
  bc = DirichletBC(V, BoundaryFunction(), Boundary())
  ----
  Only this works:
  -----
  bf = BoundaryFunction()
  bc = DirichletBC(V, bf, Boundary())
  -----

  I have attached a patch that works around this by saving a reference
  to the arguments in DirichletBC. It's not the proper fix of course,
  but I have no time to find the root cause.



References