Subject: [Viper-dev] Plotting vector field

From: Anders Logg <[email-masked]>
Date: Sat, 28 Apr 2007 00:42:33 +0200

There seems (or might be) something wrong with plotting of vector
fields in viper.

Try the DOLFIN demo in src/pde/stokes/taylor-hood. I get the following
error message:

Reading function from velocity.xml.
Reading vector from file velocity.xml.
Reading mesh from file velocity.xml.
Traceback (most recent call last):
  File "plot.py", line 5, in ?
    plot(u)
  File "/usr/lib/python2.4/site-packages/viper/viper_dolfin.py", line
  83, in plot
    viper = Viper(data, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/viper/viper_dolfin.py", line
  13, in __init__
    self.plot(data, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/viper/viper_dolfin.py", line
  20, in plot
    self.plot_function(data, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/viper/viper_dolfin.py", line
  60, in plot_function
    (self.iren, self.renWin, self.ren) =
    self.vector_plotter(self.vtkgrid, self.mesh.coordinates(), self.x,
    self.x.min(), self.x.max(), wireframe=False)
  File "/usr/lib/python2.4/site-packages/viper/viper.py", line 392, in
  vector_plotter
    vectors = self._vectors_from_numpy(coords, x)
  File "/usr/lib/python2.4/site-packages/viper/viper.py", line 348, in
  _vectors_from_numpy
    directions_3d[:,:m] = directions
ValueError: shape mismatch: objects cannot be broadcast to a single
shape

/Anders

---

From: Ola Skavhaug <[email-masked]>
Date: Sat, 28 Apr 2007 11:56:32 +0200

> There seems (or might be) something wrong with plotting of vector

I'm not able to compile dofin after my last pull, so it's difficult to track
this error. 

My dolfin errors are:
SubSystem.cpp:113: error: 'const class ufc::dof_map' has no member named
'num_sub_dof_maps'

../../../src/kernel/function/dolfin/Function.h:15:32: error:
dolfin/SubFunction.h: No such file or directory

For the record, also ufc is fresh from the repos.

Ola
 
> _______________________________________________
> Viper-dev mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/viper-dev

---

From: "Garth N. Wells" <[email-masked]>
Date: Sat, 28 Apr 2007 12:00:46 +0200

> SubSystem.cpp:113: error: 'const class ufc::dof_map' has no member named

I had this error yesterday and thought that I had the latest UFC, but I 
had two versions (under /usr/local/include and /usr/include).

Garth

> DOLFIN-dev mailing list
> [email-masked]
> http://www.fenics.org/mailman/listinfo/dolfin-dev
>

---

From: Ola Skavhaug <[email-masked]>
Date: Sat, 28 Apr 2007 12:14:44 +0200

> had two versions (under /usr/local/include and /usr/include).

Thanks, that fixed the first error. The second seems to be a missing file.

Ola

---

From: Anders Logg <[email-masked]>
Date: Sat, 28 Apr 2007 20:55:47 +0200

> Thanks, that fixed the first error. The second seems to be a missing file.

Fixed. Sorry about this.

/Anders

---

From: Anders Logg <[email-masked]>
Date: Sun, 29 Apr 2007 10:14:11 +0200

On Sat, Apr 28, 2007 at 11:46:16PM +0200, Ola Skavhaug wrote:
> [snip]
> Thanks, now, pydolfin does not compile:
> 
> dolfin_wrap.cpp: In function 'PyObject* _wrap_new_Function__SWIG_5(PyObject*,
> PyObject*)':
> dolfin_wrap.cpp:16769: error: no matching function for call to
> 'dolfin::SubFunction::SubFunction()'
> ../../src/kernel/function/dolfin/SubFunction.h:33: note: candidates are:
> dolfin::SubFunction::SubFunction(dolfin::DiscreteFunction*, dolfin::uint)
> ../../src/kernel/function/dolfin/SubFunction.h:29: note:
> dolfin::SubFunction::SubFunction(const dolfin::SubFunction&)
> make[1]: *** [_dolfin_la-dolfin_wrap.lo] Error 1
> 
> Ola

It's the old touch dolfin.i problem as usual... This should be fixed
now.

I tested two different ways of calling plot. Just calling plot(u)
gives

  File "plot.py", line 7, in ?
    plot(u)

Adding mode="vectorfield" gives

  File "plot.py", line 8, in ?
    plot(u, mode="vectorfield")
  File "/usr/lib/python2.4/site-packages/viper/viper_dolfin.py", line
  83, in plot
    viper = Viper(data, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/viper/viper_dolfin.py", line
  13, in __init__
    self.plot(data, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/viper/viper_dolfin.py", line
  20, in plot
    self.plot_function(data, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/viper/viper_dolfin.py", line
  69, in plot_function
    self.iren.Initialize()
AttributeError: 'Viper' object has no attribute 'iren'

Perhaps mode="vectorfield" should be the default option for
vector-valued functions?

By the way, mode="displacement" seems to give something reasonable for
the Stokes demo. (It's not reasonable to plot the velocity field as a
displacement but the output looks to be what you would expect.)

/Anders

---

From: Ola Skavhaug <[email-masked]>
Date: Sun, 29 Apr 2007 13:36:05 +0200

> It's the old touch dolfin.i problem as usual... This should be fixed

Great, both dolfin and pydolfin compile and install now.

I'll have a look at viper for vectorfields. A question; if you prefer
mode="vectorfield", the displacement switch should be called
"displacementfield"? Or should be stick to displacement and vector as viper uses
today?

Ola

---

From: Ola Skavhaug <[email-masked]>
Date: Sun, 29 Apr 2007 14:02:19 +0200

> It's the old touch dolfin.i problem as usual... This should be fixed

When running dolfin-stokes in taylor-hood, no file named velocity.xml is
created. Shouldn't the solutions be saved to file in xml-format?

Ola

---

From: Anders Logg <[email-masked]>
Date: Sun, 29 Apr 2007 14:58:08 +0200

> "displacementfield"? Or should be stick to displacement and vector as viper uses

I just thought it was called "vectorfield", but "displacement" and
"vector" sounds good to me, with "vector" as default.

/Anders

---

From: Anders Logg <[email-masked]>
Date: Sun, 29 Apr 2007 15:00:47 +0200

> created. Shouldn't the solutions be saved to file in xml-format?

We've been debugging the VTK (.pvd) output for paraview so we've been
changing back and forth. If you pull again, you should get something
that works.

Note: The Poisson, elasticity and Stokes demo (one of them) works now, so
we just need to continue digging through the demos to get closer to a
release.

/Anders