dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #22408
[Bug 747289] [NEW] Python: DirichletBC arguments are deleted early
Public bug reported:
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.
** Affects: dolfin
Importance: Undecided
Status: New
--
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:
New
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.
Follow ups
-
[Bug 747289] Re: Python: DirichletBC arguments are deleted early
From: Garth Wells, 2011-05-16
-
[Bug 747289] Re: Python: DirichletBC arguments are deleted early
From: Garth Wells, 2011-04-25
-
[Bug 747289] Re: Python: DirichletBC arguments are deleted early
From: Garth Wells, 2011-04-24
-
[Bug 747289] Re: Python: DirichletBC arguments are deleted early
From: Garth Wells, 2011-04-22
-
[Bug 747289] Re: Python: DirichletBC arguments are deleted early
From: Garth Wells, 2011-04-22
-
[Bug 747289] Re: Python: DirichletBC arguments are deleted early
From: Launchpad Bug Tracker, 2011-04-22
-
[Bug 747289] Re: Python: DirichletBC arguments are deleted early
From: Johan Hake, 2011-04-22
-
[Bug 747289] Re: Python: DirichletBC arguments are deleted early
From: Garth Wells, 2011-04-22
-
[Bug 747289] Re: Python: DirichletBC arguments are deleted early
From: Joachim Haga, 2011-04-01
-
[Bug 747289] [NEW] Python: DirichletBC arguments are deleted early
From: Joachim Haga, 2011-04-01
References