[petsc-users] [PETSc] How to read a Vector and Matrix from an ASCII file into PETSc?
Ryan Morley
ryantmorley7298 at gmail.com
Mon Sep 11 11:21:30 CDT 2017
Dear all,
I am working on a program in Petsc that will read a vector and matrix from
an ASCII file and store it into a vector and matrix object in Petsc so I
can eventually solve. It needs to be an ASCII file because I will be
outputting the vector and matrix to an ASCII file from code in Delphi.
I am starting out trying to accomplish printing a vector to an ASCII file
and then reading the vector back into Petsc by reading from the ASCII file.
I was able to successfully print a vector to an ASCII file using the
following code:
PetscViewerASCIIOpen(PETSC_COMM_WORLD, "RyansVector.output", &viewer);
VecView(u, viewer);
Where "PETSC_COMM_WORLD" is the MPI communicator, "RyansVector.output" is
the name of the ASCII file, and "viewer" is the name of the PetscViewer to
use with the specified file.
Also "u" is a vector object in Petsc.
However, now when I want to read from an ASCII file and store the values
into a vector I cannot seem to accomplish this. Looking around online I
cannot find any evidence that it is possible to read from an ASCII file to
produce a vector object in Petsc.
Is it only possible to read into Petsc objects with Binary and HDF5 file
types?
Is it possible to use VecLoad when reading? If so, how? I was not able to
get VecLoad to work.
Thank you so much!
Ryan Morley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170911/2d1a5008/attachment.html>
More information about the petsc-users
mailing list