On Thu, Apr 30, 2009 at 3:18 PM, david wende <[email protected]> wrote:

>> Mayavi 2 works, it's just we don't have an interface to it right now.
>> However, you can extract the required data arrays and pass them to
>> mayavi2 like any other numpy arrays, which is the main reason we have
>> wrapper classes to take care of this. If you want to make a
>> publication quality figure or customize your figure, you would
>> probably have to hack our viewers or interface with Mayavi2 directly
>> anyway.
>
> OK - I'll try and extract array and view with mayavi2 How would I dump data
> into format suitable for mayavi2? I tried TSVViewer but mayavi2 does not
> like it.

I haven't used mayavi 2 yet, but I expect that you can access it
straight from a python script. You need to save the data from fipy as
numpy arrays, which can be extracted from CellVariables at each time
step or whatever frequency you see fit. There are many ways to save
the data from fipy, you can use tsv, pickle the data, pytables or
others that I don't know about. Onve you save the data you need to
write a script that reads the data back in and asks mayavi 2 to
display it. mayavi 2 does not have to read your data.

>> > 5. mayavi 1.5 not working on my system
>>
>> What happens? Does it freeze on the screen? Are you using Windows?
>
> Mayavi 1.5 on Linux.  Error messages on startup, such as:
> " _tkinter.Tcl_Obj has no len() "

What happens when you do import "import mayavi" at the python command line?

>>
>>
>> > 6. So - could I do a 3D simulation and then slice a cross section and
>> > send
>> > that to a 2D viewer?
>>
>> Yes, extract the data, create a 2D mesh and a new CellVariable based
>> on the 2D mesh and initialized with the sliced data.
>
> This sounds hard - I will try first suggestion first (data dump -> mayavi2).
> Do you mean something like:
>
> solution2D = solution3D(where x  = 3)
> where solution3D is the solution variable in the eqn.solve step ?

This should do it,

In [1]: from fipy import *

In [6]: m3D = Grid3D(nx=10, ny=10, nz=10)

In [6]: m2D = Grid2D(nx=5, ny=5)

In [7]: x, y, z = m3D.getCellCenters()

In [8]: v3D = CellVariable(mesh=m3D, value=x * y * x)

In [9]: x, y = m2D.getCellCenters()

In [15]: v2D = CellVariable(mesh=m2D, value=v3D((x,y,y * 0. + 5.), order=1))

In [16]: v = Viewer(v2D)

In [17]: v.plot()

In line 15, the __call__ method of v3D accepts an array that acts as
the interpolation points. The z value is just the slice (z=5), " y *
0. + 5." is just a clumsy way to construct an array of 5s. The order
argument is the order of interpolation. order 0 just finds nearest
neighbor.

Hope this helps.

-- 
Daniel Wheeler

Reply via email to