[petsc-users] Output portability, binary, HDF5, ascii

Arturo Fountain art.fountain at gmail.com
Thu Feb 18 16:03:08 CST 2010


I'll certainly look into this. Numpy does seem to be a very portable
format and may solve many of my problems. Thanks for the script and
the heads up!

Arturo

On Thu, Feb 18, 2010 at 2:36 PM, Lisandro Dalcin <dalcinl at gmail.com> wrote:
> On 18 February 2010 18:10, Barry Smith <bsmith at mcs.anl.gov> wrote:
>>
>> On Feb 18, 2010, at 2:35 PM, Arturo Fountain wrote:
>>
>>> Greetings:
>>>
>>> I've been using the PETSc libraries for a few weeks now and am very
>>> impressed with the software. Great work folks!
>>>
>>> I'm writing with an issue I've been unable to work around. I'd like to
>>> save output and import it into an external program (hdfview or matlab,
>>> for example). Vectors are no problem to output but as mentioned at
>>>
>>> https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2010-January/005796.html,
>>> this is not possible in PETSc for matrices.
>>
>>
>>    This is an indirect way of doing but since PETSc can dump vectors and
>> sparse matrices in PETSc format rapidly and they can be read into Matlab
>> rapidly, could you then use Matlab's HDF5 capability to write then into any
>> HDF5 format you like? I realize this is not ideal, but it is just a single
>> extra postprocessing step.
>>
>>    You could also write your own PETSc object viewers that wrote to HDF5,
>> for sparse matrices, but I think it is easy just to dump to Matlab and have
>> it save it in the format you want.
>>
>>    ASCII is just SO slow for large data sets I think it is impractical.
>>
>>   Barry
>>
>>
>>
>>> Furthermore: "It won't buy
>>> you any speed, disk space, or portability."
>>>
>>> Certainly the PETSc binary format works fine for PETSc I/O but I am
>>> unable to find anything to convert between this format and any other.
>>> I'm most concerned with portability; I would like to utilize external
>>> visualization packages. Is it standard practice to simply use ASCII
>>> output? I can certainly do that but for larger problems size will
>>> certainly become an impending issue....
>>>
>>> Thanks in advance for any help you can offer,
>>>
>>> Arturo
>>
>>
>
> OTOH, PETSc binary format is extremely easy to read... for example,
> feed the attached Python script with a PETSc binary file, and you will
> see the sparse matrix line by line in your console:
>
> $ python matio.py matrix.dat
>
> try this with a small matrix, as printing a big matrix can take
> forever. However, the readmat() function should perform extremely
> well, all the actual IO is done in C, thanks to numpy,
>
>
> Of course, you can do anything you want with the I, J, V numpy arrays,
> like using any HDF5 Python wrapper to generate an hdf5 file...
>
> --
> Lisandro Dalcin
> ---------------
> Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
> Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
> Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
> PTLC - Güemes 3450, (3000) Santa Fe, Argentina
> Tel/Fax: +54-(0)342-451.1594
>


More information about the petsc-users mailing list