[petsc-users] Loading external array data into PETSc

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


Hi Matt,

Thank you, I needed to reconfigure with hdf5.

The import works well now.

Best, Thijs

From: Matthew Knepley <knepley at gmail.com>
Sent: 04 March 2021 14:53
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 Thu, Mar 4, 2021 at 1:10 AM Smit Thijs <thijs.smit at hest.ethz.ch<mailto:thijs.smit at hest.ethz.ch>> wrote:
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

Did you configure PETSc with HDF5? If so, the configure.log will have an entry for it at the bottom. If not, reconfigure with it:

  ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py --download-hdf5

or you can use

  --with-hdf5-dir=/path/to/hdf5

if it is already installed.

  Thanks,

    Matt

Best,

Thijs

From: Matthew Knepley <knepley at gmail.com<mailto:knepley at gmail.com>>
Sent: 03 March 2021 23:02
To: Smit Thijs <thijs.smit at hest.ethz.ch<mailto:thijs.smit at hest.ethz.ch>>
Cc: petsc-users at mcs.anl.gov<mailto: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/>


--
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/505343f9/attachment-0001.html>


More information about the petsc-users mailing list