[petsc-users] Loading external array data into PETSc

Smit Thijs thijs.smit at hest.ethz.ch
Thu Mar 4 00:10:09 CST 2021


Hi Matt, Roland and others,

@ Roland, I can create the Vec in Petsc, but want to load it with external data. I can arrange that data in what ever way with Python. It is about two vectors, each of length 4.6 x10^6 entries.

I have created a hdf5 file with Python and try to load it into PETSc which gives me some errors. I added the small test script I am using. The error I am getting is:

error: ‘PetscViewerHDF5Open’ was not declared in this scope; did you mean ‘PetscViewerVTKOpen’?

Am I using the wrong header?

Best,

Thijs

From: Matthew Knepley <knepley at gmail.com>
Sent: 03 March 2021 23:02
To: Smit Thijs <thijs.smit at hest.ethz.ch>
Cc: petsc-users at mcs.anl.gov
Subject: Re: [petsc-users] Loading external array data into PETSc

On Wed, Mar 3, 2021 at 4:23 PM Smit Thijs <thijs.smit at hest.ethz.ch<mailto:thijs.smit at hest.ethz.ch>> wrote:
Hi All,

I would like to readin a fairly large external vector into PETSc to be used further. My idea was to write a hdf5 file using Python with the vector data. Then read that hdf5 file into PETSc using PetscViewerHDF5Open and VecLoad. Is this the advised way or is there a better alternative to achieve the same (getting this external array data into PETSc)?

I think there are at least two nice ways to do this:

1) Use HDF5. Here you have to name your vector to match the HDF5 object

2) Use raw binary. This is a specific PETSc format, but it is fast and simple.

  Thanks,

    Matt

Best regards,

Thijs Smit

PhD Candidate
ETH Zurich
Institute for Biomechanics



--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20210304/0f19f108/attachment-0001.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hdf5.cpp
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20210304/0f19f108/attachment-0001.ksh>


More information about the petsc-users mailing list