dolfin_function2BoxField gives error: "NameError: global name 'u' is not defined"

35 views
Skip to first unread message

Torbjørn Bækø Ness

unread,
May 27, 2011, 3:58:01 AM5/27/11
to scitools
Hi.

I'm trying to use dolfin_function2BoxField(), to make the solution
of a 3 dimensional problem easier to work with. The problem is solved
using FEniCS.
I get the error message "NameError: global name 'u' is not defined"

torbjone@imt-iw23014324:~/inf5620/keyThree/simplest$ python
poiLayer.py
Solving linear variational problem.
Applying boundary conditions to linear system.
Solving linear system of size 4939 x 4939 (PETSc LU solver,
umfpack).
Traceback (most recent call last):
File "poiLayer.py", line 73, in <module>
u_box = dolfin_function2BoxField(u2, mesh,(10,10))
File "/usr/local/lib/python2.7/dist-packages/scitools/
BoxField.py", line 277, in dolfin_function2BoxField
if u.ufl_element().degree() != 1:
NameError: global name 'u' is not defined

Here are some relevant lines from my code:

from dolfin import *

mesh = Mesh("mesh.xml")
boundaries = MeshFunction('uint', mesh, 'boundaries.xml')

V = FunctionSpace(mesh, "CG", 1)

v = TestFunction(V)
u = TrialFunction(V)

a = inner(grad(v), C*grad(u))*dx
L = J_soma*v*ds(7)-J_soma*v*ds(8)

problem = VariationalProblem(a, L, bc,
exterior_facet_domains=boundaries)
u = problem.solve()

from scitools.BoxField import *

u2 = u if u.ufl_element().degree() == 1 else \
interpolate(u, FunctionSpace(mesh, 'CG', 1))
u_box = dolfin_function2BoxField(u2, mesh, (40,40,10))


Does anybody know what's wrong?

Johannes Ring

unread,
May 27, 2011, 5:13:52 AM5/27/11
to scit...@googlegroups.com
Hi Torbjørn,

This bug has now been fixed in the SciTools development repository.
Please update your installation.

Thanks for your report,

Johannes

Reply all
Reply to author
Forward
0 new messages