[petsc-users] Reading Vectors from a PETSc Vec

Mohammad Ali Yaqteen mhyaqteen at sju.ac.kr
Mon Nov 14 18:39:04 CST 2022


I am using the following procedure to read from Vec, but it keeps giving me the same values! I was told that using VecGetValues gives wrog output. If not this, then what function should be used to read the contents of a vector?

for (int i = 0; i < nconv; i++)
        {
            PetscCall(EPSGetEigenpair(eps,i,&kr,&ki,xr,xi));
            PetscCall(EPSComputeError(eps,i,EPS_ERROR_RELATIVE,&error1));

            #if defined(PETSC_USE_COMPLEX)
                re = PetscRealPart(kr);
                im = PetscImaginaryPart(kr);
            #else
                re = kr;
                im = ki;
            #endif
            if (im!=0.0) PetscCall(PetscPrintf(PETSC_COMM_WORLD," %9f%+9fi %12g\n",(double)re,(double)im,(double)error1));
            else PetscCall(PetscPrintf(PETSC_COMM_WORLD,"   %12f       %12g\n",(double)re,(double)error1));
            eval(i) = re;
            VecGetValues(xr, tdof, ei, eveci);
            for (int j = 0; j < tdof; j++)
            {
                evec(j, i) = eveci[j];
            }
        }
        PetscCall(PetscPrintf(PETSC_COMM_WORLD,"\n"));

Thank you
Ali
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20221115/29dd7bc1/attachment.html>


More information about the petsc-users mailing list