[petsc-users] Vec, Mat and binaryfiles.

Sal Am tempohoper at gmail.com
Mon Nov 5 03:46:32 CST 2018


Hi,

I am trying to solve a Ax=b complex system. the vector b and "matrix" A are
both binary and NOT created by PETSc. So I keep getting error messages that
they are not correct format when I read the files with PetscViewBinaryOpen,
after some digging it seems that one cannot just read a binary file that
was created by another software.

How would I go on to solve this problem?

More info and trials:

"matrix" A consists of two files, one that contains row column index
numbers and one that contains the non-zero values. So what I would have to
do is multiply the last term in a+b with PETSC_i to get a real + imaginary
vector A.

vector b is in binary, so what I have done so far (not sure if it works) is:

std::ifstream input("Vector_b.bin", std::ios::binary );
while (input.read(reinterpret_cast<char*>(&v), sizeof(float)))
     ierr    = VecSetValues(u,1,&iglobal,&v,INSERT_VALUES);CHKERRQ(ierr);

where v is a PetscScalar.

Once I am able to read both matrices I think I can figure out the solvers
to solve the system.

All the best,
S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20181105/7b49789a/attachment.html>


More information about the petsc-users mailing list