Subject: Re: [Viper-dev] [DOLFIN-dev] plot.py

From: Anders Logg <[email-masked]>
Date: Mon, 5 Jan 2009 09:09:55 +0100

On Sat, Jan 03, 2009 at 09:27:04PM -0300, Ola Skavhaug wrote:
> What's the purpose of dolfin_plot? It just calls viper_plot for all
> types, except when the object is unknown, in which case it tries
>  to project something, without knowing what it is. This should be put
> into viper instead of in this almost empty wrapper. What is the type
> of object if project can handle it?

The type of object is any expression like grad(u), u + u, div(u) etc.
but it can also be anything else (like an int or float) that FFC can
interpret as a Form. The easiest test is probably the one that's there
now in plot.py (try: project).

> The case viper is not available, I guess you need some logic anyway.
> Plot muting when an environment variable is set could be placed in
> viper, but that would only be a duplicate of what you need anyway, so
> I suggest you keep that (or a better version of the IgnorePlot).

It would be helpful if there were an environment variable, perhaps
NOPLOT that Viper looked at. Then we can remove that part too from the
wrapper. Maybe it's also good for Viper to have a plotless mode for
unit testing?

The release of DOLFIN 0.9.0 is planned to come out today, so it would
be good if we could wait with any changes in the interface until after
the release.

Can you make a Viper release today that matches the current DOLFIN?
There have been a few bug fixes since last time I think. There will
also be a new FFC release. Then Johannes can make a release of
fenics-2009-01. :-)

-- 
Anders

---

From: "Ola Skavhaug" <[email-masked]>
Date: Tue, 6 Jan 2009 07:28:31 -0300

> also be a new FFC release. Then Johannes can make a release of

I'm currently suffering from a highly unstable internet connection
here in Porto de Galinhas, so if it is not too much a problem I'd like
to wait with the release until Friday.

Ola

> --
> Anders
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAklhwFMACgkQTuwUCDsYZdGUFACbB3vaOadgI8OcqKFcnXdSeXCS
> Jd8AniNeO/k3JAPv0CLlOU1UmGdn6h9q
> =9+nD
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Viper-dev mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/viper-dev
>
>

-- 
Ola Skavhaug

---

From: Anders Logg <[email-masked]>
Date: Tue, 6 Jan 2009 11:59:01 +0100

> to wait with the release until Friday.

ok. Have fun. :-)

-- 
Anders

---

From: "Ola Skavhaug" <[email-masked]>
Date: Tue, 6 Jan 2009 11:45:46 -0300

> now in plot.py (try: project).

I don't understand. I don't see any tests where project is used. Can
you point me to the appropriate test?

Ola

-- 
Ola Skavhaug

---

From: Anders Logg <[email-masked]>
Date: Tue, 6 Jan 2009 20:46:33 +0100

> you point me to the appropriate test?

I mean the following tests:

    # Plot mesh
    if isinstance(object, cpp.Mesh):
        return viper_plot(object, *args, **kwargs)

    # Plot mesh function
    if isinstance(object, cpp.MeshFunctionUInt) or \
       isinstance(object, cpp.MeshFunctionInt)  or \
       isinstance(object, cpp.MeshFunctionReal):
        return viper_plot(object, *args, **kwargs)

    # Plot function
    if isinstance(object, cpp.Function):
        return viper_plot(object, *args, **kwargs)

    # Try projecting function
    from project import project
    try:
        print "Object cannot be plotted directly, projecting to
        piecewise linears."
        u = project(object)
        return plot(u, *args, **kwargs)
    except:
        raise RuntimeError, ("Don't know how to plot given object and
        projection failed: " + str(object))

This tests for any object that DOLFIN knows that Viper can handle and
otherwise tries to project the object to a Function and then calls
Viper with the Function.

So: first check for everything that Viper knows how to plot and
otherwise try to project it.

-- 
Anders

---

From: "Ola Skavhaug" <[email-masked]>
Date: Tue, 6 Jan 2009 17:13:25 -0300

> otherwise try to project it.

I know this code, but this is not a test. This is dolfin code. I'm
talking about a test of this functionality. Since object is unknown,
there is no simple way for me to test that I don't break anything when
coding.

See?

Ola

> iEYEARECAAYFAkljtRkACgkQTuwUCDsYZdFeqwCePHm3XzE5AjHySSaYfqNKk99q
> eeEAn3KjfMhENAqz04ODnZFM+ZMi3fKu
> =9rvo

-- 
Ola Skavhaug

---

From: Anders Logg <[email-masked]>
Date: Tue, 6 Jan 2009 21:18:44 +0100

> there is no simple way for me to test that I don't break anything when

No... What kind of test do you want?

-- 
Anders

---

From: "Ola Skavhaug" <[email-masked]>
Date: Tue, 6 Jan 2009 17:33:39 -0300

A demo, unit test or whatever. Something that tests this functionlity
of dolfin. I've run almost all demos, and I can't trigger the project
code. Hence, it looks dead to me.

Ola

On Tue, Jan 6, 2009 at 5:18 PM, Anders Logg <[email-masked]> wrote:
> iEYEARECAAYFAkljvKQACgkQTuwUCDsYZdGCAACfUs+Q539im2UEeNn5jucKOyXk
> mpgAni3Bu75cVq3jrhNsOBiIklYMUQu6
> =+uf1

-- 
Ola Skavhaug

---

From: Anders Logg <[email-masked]>
Date: Tue, 6 Jan 2009 21:56:51 +0100

Here's one that calls project:

  demo/function/projection-interpolation/python/demo.py

And here's one that plots and object that needs to be projected before
plotted:

  demo/pde/nonlinear-poisson/python/demo.py

-- 
Anders

---

From: "Ola Skavhaug" <[email-masked]>
Date: Tue, 6 Jan 2009 18:06:24 -0300

>  demo/function/projection-interpolation/python/demo.py

No, this doesn't trigger project in plot.py

>  demo/pde/nonlinear-poisson/python/demo.py

Ah, finally. Now I can proceed. Thanks!

Ola

> iEYEARECAAYFAkljxZMACgkQTuwUCDsYZdHp6gCgl3SqOlyLtJsNW6ZzTwlrK9yt
> 20cAnA3hJFV44J3KeDt8R1xn5Ps6rZ+6
> =aIYu

-- 
Ola Skavhaug