Hi Zhiwen,

Try pickling the mesh (see below), but performance won't be any better
than recreating the mesh from scratch.

In [1]: from fipy import *

In [2]: m = Grid2D(nx=4, ny=4)

In [3]: dump.write(m, 'm.gz')

In [4]: m0 = dump.read('m.gz')

In [5]: m0.getCellCenters()
Out[5]:
array([[ 0.5,  1.5,  2.5,  3.5,  0.5,  1.5,  2.5,  3.5,  0.5,  1.5,  2.5,
         3.5,  0.5,  1.5,  2.5,  3.5],
       [ 0.5,  0.5,  0.5,  0.5,  1.5,  1.5,  1.5,  1.5,  2.5,  2.5,  2.5,
         2.5,  3.5,  3.5,  3.5,  3.5]])

If performance is an issue then __getstate__ and __setstate__ (see
<https://www.matforge.org/fipy/browser/trunk/fipy/meshes/numMesh/mesh.py#L664>)
would need to be rewritten so that less is done when the object is
unpickled.

I don't think we have ever used GmshExport for anything useful so I
wouldn't trust it, especially if it is not part of the test suite. I
can't think why it is even in there.

On Fri, Apr 4, 2008 at 3:46 PM, Zhiwen Liang <[EMAIL PROTECTED]> wrote:
> Dear Dan and Jon,
>
>  I have a problem regarding the GmshExport module in fipy.
>
>  What I am trying to do is to save the mesh every time I create it so that I
> can import it the next time I need it without having to create it from
> scratch. So what I did is to export the mesh using gmshExport as the way of
> saving the mesh. Then next time I need the mesh, I just have to use
> gmshImport to import it.
>
>  I noticed that there is a test inside the script of gmshExport.py which
> export a Grid3D mesh. I run it and could not go through. I also attached a
> script that I tried to export the unstructured mesh created by GMSH. It
> stops with different errors.
>
>  Or maybe you can suggest some other ways of saving the mesh.
>
>  We thank you in advance for any advice you are giving.
>
>  Regards,
>  Zhiwen
>
>



-- 
Daniel Wheeler

Reply via email to