Torbjørn Bækø Ness
unread,May 27, 2011, 3:58:01 AM5/27/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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?