1D plot issue persists in OSX10.6 build

Bug #914880 reported by Ernesto Ismail
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
DOLFIN
Fix Released
Undecided
Unassigned
Viper
Fix Released
Undecided
Unassigned

Bug Description

I'm new to FEniCS and have successfully worked through most of the Demos. When I started trying to write my own simple code I noticed that an attempt to recreate the Poisson Equation tutorial in 1D throws an error from the plot command. Based on a cursory search I found bug #180690 where another user documented a similar problem.

The text of the bug report suggested that the bug had been fixed. While this may be the case in general it appears that modifying the line UnitCube(32,32) in the Poisson Equation demo to UnitInterval(32) still causes the error under my (recently downloaded and installed) fenics-1.0.0-osx10.6dmg.

Regards,

Ernesto

Revision history for this message
Ernesto Ismail (ernesto-ismail) wrote :
Revision history for this message
Johan Hake (johan-hake) wrote : Re: [Bug 914880] [NEW] 1D plot issue persists in OSX10.6 build

Provide a minimal example which reproduce the bug.

Johan
On Jan 11, 2012 6:05 PM, "Ernesto Ismail" <email address hidden> wrote:

> Public bug reported:
>
> I'm new to FEniCS and have successfully worked through most of the
> Demos. When I started trying to write my own simple code I noticed that
> an attempt to recreate the Poisson Equation tutorial in 1D throws an
> error from the plot command. Based on a cursory search I found bug
> #180690 where another user documented a similar problem.
>
> The text of the bug report suggested that the bug had been fixed. While
> this may be the case in general it appears that modifying the line
> UnitCube(32,32) in the Poisson Equation demo to UnitInterval(32) still
> causes the error under my (recently downloaded and installed)
> fenics-1.0.0-osx10.6dmg.
>
> Regards,
>
> Ernesto
>
> ** Affects: dolfin
> Importance: Undecided
> Status: New
>
> --
> You received this bug notification because you are a member of DOLFIN
> Core Team, which is subscribed to DOLFIN.
> https://bugs.launchpad.net/bugs/914880
>
> Title:
> 1D plot issue persists in OSX10.6 build
>
> Status in DOLFIN:
> New
>
> Bug description:
> I'm new to FEniCS and have successfully worked through most of the
> Demos. When I started trying to write my own simple code I noticed
> that an attempt to recreate the Poisson Equation tutorial in 1D throws
> an error from the plot command. Based on a cursory search I found bug
> #180690 where another user documented a similar problem.
>
> The text of the bug report suggested that the bug had been fixed.
> While this may be the case in general it appears that modifying the
> line UnitCube(32,32) in the Poisson Equation demo to UnitInterval(32)
> still causes the error under my (recently downloaded and installed)
> fenics-1.0.0-osx10.6dmg.
>
> Regards,
>
> Ernesto
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/dolfin/+bug/914880/+subscriptions
>

Revision history for this message
Ernesto Ismail (ernesto-ismail) wrote :

Thanks for the prompt reply Johan.

If I run the following, the solution process completes and I can open the .pvd in ParaView. The plot command throws an error.

from dolfin import *

# Create mesh and define function space
mesh = UnitInterval(32)
V = FunctionSpace(mesh, "Lagrange", 1)

# Define Dirichlet boundary (x = 0 or x = 1)
def boundary(x):
    return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS

# Define boundary condition
u0 = Constant(0.0)
bc = DirichletBC(V, u0, boundary)

# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)")
g = Expression("sin(5*x[0])")
a = inner(grad(u), grad(v))*dx
L = f*v*dx + g*v*ds

# Compute solution
u = Function(V)
solve(a == L, u, bc)

# Save solution in VTK format
file = File("poisson.pvd")
file << u

# Plot solution
plot(u, interactive=True)

Revision history for this message
Johan Hake (johan-hake) wrote : Re: [Bug 914880] Re: 1D plot issue persists in OSX10.6 build

This modified script works fine for me. Using DOLFIN 1.0.

Johan

####################################################33

from dolfin import *

# Create mesh and define function space
mesh = UnitInterval(32)
V = FunctionSpace(mesh, "Lagrange", 1)

# Define Dirichlet boundary (x = 0 or x = 1)
def boundary(x):
    return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS

# Define boundary condition
u0 = Constant(0.0)
bc = DirichletBC(V, u0, boundary)

# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Expression("10*exp(-pow(x[0] - 0.5, 2) / 0.02)")
a = inner(grad(u), grad(v))*dx
L = f*v*dx

# Compute solution
u = Function(V)
solve(a == L, u, bc)

# Save solution in VTK format
file = File("poisson.pvd")
file << u

# Plot solution
plot(u, interactive=True)

On Wednesday January 11 2012 19:13:38 Ernesto Ismail wrote:
> Thanks for the prompt reply Johan.
>
> If I run the following, the solution process completes and I can open
> the .pvd in ParaView. The plot command throws an error.
>
> from dolfin import *
>
> # Create mesh and define function space
> mesh = UnitInterval(32)
> V = FunctionSpace(mesh, "Lagrange", 1)
>
> # Define Dirichlet boundary (x = 0 or x = 1)
> def boundary(x):
> return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS
>
> # Define boundary condition
> u0 = Constant(0.0)
> bc = DirichletBC(V, u0, boundary)
>
> # Define variational problem
> u = TrialFunction(V)
> v = TestFunction(V)
> f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)")
> g = Expression("sin(5*x[0])")
> a = inner(grad(u), grad(v))*dx
> L = f*v*dx + g*v*ds
>
> # Compute solution
> u = Function(V)
> solve(a == L, u, bc)
>
> # Save solution in VTK format
> file = File("poisson.pvd")
> file << u
>
> # Plot solution
> plot(u, interactive=True)

Revision history for this message
Ernesto Ismail (ernesto-ismail) wrote :

The problem still persists and when running the provided code I get the error stream:

#######
ernesto@Woodchuck:fenics_code$ python poisson_modified.py
Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Solving linear variational problem.
Traceback (most recent call last):
  File "poisson_modified.py", line 31, in <module>
    plot(u, interactive=True)
  File "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/dolfin/common/plotting.py", line 121, in dolfin_plot
    return viper_dolfin.plot(make_viper_object(object, mesh=mesh), *args, **kwargs)
  File "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/viper/viper_dolfin.py", line 452, in plot
    fig = _plotter.plot(data, **kwargs)
  File "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/viper/viper_dolfin.py", line 401, in plot
    return self.autoplot(plot_object, *args, **kwargs)
  File "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/viper/viper_dolfin.py", line 415, in autoplot
    plotter = Viper(plot_object, *args, **kwargs)
  File "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/viper/viper_dolfin.py", line 60, in __init__
    self.plot(data, *args, **kwargs)
  File "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/viper/viper_dolfin.py", line 85, in plot
    plot_method(data, *args, **kwargs)
  File "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/viper/viper_dolfin.py", line 165, in plot_genericfunction
    vmax=kwargs.get("vmax", None))
  File "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/viper/viper.py", line 1299, in plot_xy
    renWin.SetSize(self.window_size)
TypeError: function takes exactly 2 arguments (1 given)

According to the Question linked above the error was solved in the current release of FEniCS. Despite this, I am running the most current release for OSX and the error persists. Is it possible that the .dmg file does not have the most up to date build of the plot function?

Thanks for your efforts thus far,

Ernesto

Revision history for this message
Johan Hake (johan-hake) wrote :

I do not have a mac build to test against and it looks like it is a VTK
problem.

Johan

On Wednesday January 11 2012 20:49:15 Ernesto Ismail wrote:
> The problem still persists and when running the provided code I get the
> error stream:
>
> #######
> ernesto@Woodchuck:fenics_code$ python poisson_modified.py
> Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
> Calling FFC just-in-time (JIT) compiler, this may take some time.
> Solving linear variational problem.
> Traceback (most recent call last):
> File "poisson_modified.py", line 31, in <module>
> plot(u, interactive=True)
> File
> "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/d
> olfin/common/plotting.py", line 121, in dolfin_plot return
> viper_dolfin.plot(make_viper_object(object, mesh=mesh), *args, **kwargs)
> File
> "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/v
> iper/viper_dolfin.py", line 452, in plot fig = _plotter.plot(data,
> **kwargs)
> File
> "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/v
> iper/viper_dolfin.py", line 401, in plot return self.autoplot(plot_object,
> *args, **kwargs)
> File
> "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/v
> iper/viper_dolfin.py", line 415, in autoplot plotter = Viper(plot_object,
> *args, **kwargs)
> File
> "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/v
> iper/viper_dolfin.py", line 60, in __init__ self.plot(data, *args,
> **kwargs)
> File
> "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/v
> iper/viper_dolfin.py", line 85, in plot plot_method(data, *args, **kwargs)
> File
> "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/v
> iper/viper_dolfin.py", line 165, in plot_genericfunction
> vmax=kwargs.get("vmax", None))
> File
> "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/v
> iper/viper.py", line 1299, in plot_xy renWin.SetSize(self.window_size)
> TypeError: function takes exactly 2 arguments (1 given)
>
> According to the Question linked above the error was solved in the
> current release of FEniCS. Despite this, I am running the most current
> release for OSX and the error persists. Is it possible that the .dmg
> file does not have the most up to date build of the plot function?
>
> Thanks for your efforts thus far,
>
> Ernesto

Revision history for this message
Anders Logg (logg) wrote :

Yes, looks like you have an old version of VTK. The SetSize function
in VTK should take one argument and it seems to want two arguments
with your version of VTK.

--
Anders

On Wed, Jan 11, 2012 at 08:13:49PM -0000, Johan Hake wrote:
> I do not have a mac build to test against and it looks like it is a VTK
> problem.
>
> Johan
>
> On Wednesday January 11 2012 20:49:15 Ernesto Ismail wrote:
> > The problem still persists and when running the provided code I get the
> > error stream:
> >
> > #######
> > ernesto@Woodchuck:fenics_code$ python poisson_modified.py
> > Calling DOLFIN just-in-time (JIT) compiler, this may take some time.
> > Calling FFC just-in-time (JIT) compiler, this may take some time.
> > Solving linear variational problem.
> > Traceback (most recent call last):
> > File "poisson_modified.py", line 31, in <module>
> > plot(u, interactive=True)
> > File
> > "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/d
> > olfin/common/plotting.py", line 121, in dolfin_plot return
> > viper_dolfin.plot(make_viper_object(object, mesh=mesh), *args, **kwargs)
> > File
> > "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/v
> > iper/viper_dolfin.py", line 452, in plot fig = _plotter.plot(data,
> > **kwargs)
> > File
> > "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/v
> > iper/viper_dolfin.py", line 401, in plot return self.autoplot(plot_object,
> > *args, **kwargs)
> > File
> > "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/v
> > iper/viper_dolfin.py", line 415, in autoplot plotter = Viper(plot_object,
> > *args, **kwargs)
> > File
> > "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/v
> > iper/viper_dolfin.py", line 60, in __init__ self.plot(data, *args,
> > **kwargs)
> > File
> > "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/v
> > iper/viper_dolfin.py", line 85, in plot plot_method(data, *args, **kwargs)
> > File
> > "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/v
> > iper/viper_dolfin.py", line 165, in plot_genericfunction
> > vmax=kwargs.get("vmax", None))
> > File
> > "/Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/v
> > iper/viper.py", line 1299, in plot_xy renWin.SetSize(self.window_size)
> > TypeError: function takes exactly 2 arguments (1 given)
> >
> > According to the Question linked above the error was solved in the
> > current release of FEniCS. Despite this, I am running the most current
> > release for OSX and the error persists. Is it possible that the .dmg
> > file does not have the most up to date build of the plot function?
> >
> > Thanks for your efforts thus far,
> >
> > Ernesto
>

Revision history for this message
Ernesto Ismail (ernesto-ismail) wrote :

I guess it was too easy to install FEniCS via a single download. I am using the XCode libraries that came with my OSX10.6 CD. Making new VTK work with python wrappers seems to be a bit of a chore in OSX. Hopefully someone with an OSX build can confirm that this is indeed the problem.

Thanks so much for your input everyone.

Revision history for this message
Johannes Ring (johannr) wrote :

The VTK version included in the OS X binary is not that old, but there might be a bug in VTK on OS X because both SetSize(int, int) and SetSize(int a[2]) are supposed to work. This can easily be fixed by modifying the file

  /Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-packages/viper/viper.py

on OS X 10.6 or

  /Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/viper/viper.py

on OS X 10.7. Simply replace line 1299, that is

    renWin.SetSize(self.window_size)

with this line

    renWin.SetSize(*self.window_size)

This should work on all platforms so we might as well apply this fix in Viper.

Changed in dolfin:
status: New → Confirmed
Changed in fenics-viper:
status: New → Confirmed
Revision history for this message
Ernesto Ismail (ernesto-ismail) wrote :

The suggested fix works perfectly.

Thank you for the fix Johannes Ring (johannr). Additional thanks to Johan Hake (johan-hake) for helping isolate the problem to VTK and to Anders Logg (logg) for confirming that the issue was in the version of VTK.

Cheers,

Ernesto

Revision history for this message
Anders Logg (logg) wrote :

On Thu, Jan 12, 2012 at 07:06:48AM -0000, Johannes Ring wrote:
> The VTK version included in the OS X binary is not that old, but there
> might be a bug in VTK on OS X because both SetSize(int, int) and
> SetSize(int a[2]) are supposed to work. This can easily be fixed by
> modifying the file
>
> /Applications/FEniCS.app/Contents/Resources/lib/python2.6/site-
> packages/viper/viper.py
>
> on OS X 10.6 or
>
> /Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-
> packages/viper/viper.py
>
> on OS X 10.7. Simply replace line 1299, that is
>
> renWin.SetSize(self.window_size)
>
> with this line
>
> renWin.SetSize(*self.window_size)
>
> This should work on all platforms so we might as well apply this fix
> in Viper.

I've applied Johannes' fix in Viper.

Should we make a release of Viper 1.0.1?

--
Anders

Changed in dolfin:
status: Confirmed → Fix Committed
Changed in fenics-viper:
status: Confirmed → Fix Committed
Changed in dolfin:
status: Fix Committed → Fix Released
Changed in fenics-viper:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.