This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Fenics tutorial program "poisson_extended.py" not running for P2

0 votes

Hi.

I just cloned the repository with the fenics-tutorial.

When I in the function "demo_structured_mesh()" in the program "poisson_extended.py"
change the line

u = solver(kappa, f, u_D, nx, ny, 1, linear_solver='direct')

to

u = solver(kappa, f, u_D, nx, ny, 2, linear_solver='direct')

and run the program with option 3, I get the following error-message:

   Pick a demo: 3
C code for u: exp(-16*pow(x[0] - 0.5, 2))*exp(-16*pow(x[1] - 0.5, 2))*sin(3*pi*x[0])*sin(3*pi*x[1])
C code for f: (-pow(32*x[0] - 16.0, 2)*sin(3*pi*x[0])*sin(3*pi*x[1]) + 6*pi*(32*x[0] - 16.0)*sin(3*pi*x[1])*cos(3*pi*x[0]) - pow(32*x[1] - 16.0, 2)*sin(3*pi*x[0])*sin(3*pi*x[1]) + 6*pi*(32*x[1] - 16.0)*sin(3*pi*x[0])*cos(3*pi*x[1]) + 64*sin(3*pi*x[0])*sin(3*pi*x[1]) + 18*pow(pi, 2)*sin(3*pi*x[0])*sin(3*pi*x[1]))*exp(-16*pow(x[0] - 0.5, 2) - 16*pow(x[1] - 0.5, 2))
Calling FFC just-in-time (JIT) compiler, this may take some time.
Solving linear variational problem.
Traceback (most recent call last):
  File "poisson_extended.py", line 759, in <module>
    demos[nr]()
  File "poisson_extended.py", line 564, in demo_structured_mesh
    u_box = FEniCSBoxField(u, (nx, ny))
  File "/home/.../fenics_tutorial/fenics-tutorial/src/vol1/python/boxfield.py", line 1026, in FEniCSBoxField
    = interpolate(u, FunctionSpace(fenics_mesh, 'P', 1))
NameError: global name 'interpolate' is not defined

Aborted (core dumped)

Does anybody have an idea on how to fix this?

asked Mar 3, 2017 by aaka FEniCS Novice (170 points)

1 Answer

0 votes

Hi,
I met the same error. The module boxfield can't be imported in python. Moreover, the corresponding page https://fenicsproject.org/pub/tutorial/python/vol1/boxfield.py can't be found.

answered Mar 4, 2017 by xuanyuan9288 FEniCS Novice (290 points)
reshown Mar 6, 2017 by xuanyuan9288

I don't think that is the problem in my case.
My folder includes all files from this repository, which includes "boxfield.py". It works for P1, not for P2.

...