[petsc-users] Load dense matrices from hdf5

Sajid Ali sajidsyed2021 at u.northwestern.edu
Fri Nov 30 16:59:11 CST 2018


Thanks for the advice! I'll look into using the binary format then.

On Fri, Nov 30, 2018 at 4:47 PM Smith, Barry F. <bsmith at mcs.anl.gov> wrote:

>
>     I would start by simply using the PETSc binary dense format for the
> matrices; it will work find for 1d (and 2d) development work with dozens of
> processes. Latter, if need be, you can switch to the HDF5, the only
> difference in your code would be the viewer you MatLoad() from will be an
> HDF5 file instead of a PETSc binary file.
>
>     The format of a PETSc binary dense file is
>
>     4 integer values (the header) followed by the matrix as one contiguous
> array of doubles (stored by row). The header is of the form
>
>     MAT_FILE_CLASSID, M, N, -1    (where M and N are number of rows and
> columns in the matrix.)
>
>     You can easily create this file from Python (which I assume is where
> you are getting your h(t) values from).
>
>     Barry
>
>
> > On Nov 30, 2018, at 4:27 PM, Sajid Ali via petsc-users <
> petsc-users at mcs.anl.gov> wrote:
> >
> > Hi,
> >
> > I'm trying to solve the Helmholtz equation in 1D for x-rays which
> roughly like :
> >
> > u_dot = a*u_xx + h(t)*u
> >
> > I've already implemented the case where h(t) is always zero (free-space)
> in PETSc as per the last box on page 156 of the manual.
> >
> > For the time dependent version of the same the next step is to modify
> the RHSMatrix by adding h(t) via MatDiagonalSet&Insert. (With h(t)=0, the
> RHS matrix is just a (scaled) Laplacian matrix)
> >
> > The h(t) is related to x-ray refractive index at that time. These x-ray
> indices need to be (preferably) stored in matrix beforehand. Each column of
> the matrix would be the refractive index to be used in one iteration. Using
> hdf5 is something I'd like to do because I can make/view the grid using
> numpy in python and solve the PDE using PETSc in C.
> >
> > PS: I've seen past questions on this thread strongly discouraging users
> from storing dense matrices in hdf5 format.
> >
> > PPS : This 1D x-ray scattering problem is just a stepping stone to doing
> the same in 2D so if there's a better approach to adopt, I'm be open to new
> ideas.
> >
> > Thank You,
> > Sajid Ali
> > Applied Physics
> > Northwestern University
>
>

-- 
Sajid Ali
Applied Physics
Northwestern University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20181130/515239e7/attachment-0001.html>


More information about the petsc-users mailing list