[petsc-users] Error when Using KSP with Matrix -free
s1humahd
s1humahd at stmail.uni-bayreuth.de
Mon Mar 21 09:51:34 CDT 2016
Hello All,
I'm trying to run a very simple program to get familiar with solving
linear system using matrix free structure before I use it in my
implementation.
I already created a sparse matrix A and a vector b and set values to
them. then I created a free-matrix matrix using MatCreateShell() and I
set the function which provide the operation which currently it is
merely multiply matrix A to the vector b, ( it is just an attemp to get
familiar,similar to the example ex14f.F in KSP ).
However I'm getting the flowing error when I call the KSPSolve()
routine. I will be grateful if you could help me to recognize the
reason for this error. also the related parts of my code is here.
MatCreate(PETSC_COMM_WORLD,&A);
MatSetSizes(A,nlocal,nlocal,8,8);
.
.
.
VecCreate(PETSC_COMM_WORLD,&b);
VecSetSizes(x,PETSC_DECIDE,8);
.
.
MatCreateShell(PETSC_COMM_WORLD,nlocal,nlocal,8,8, (void *)&A,&j_free);
MatShellSetOperation(j_free,MATOP_MULT, (void(*) (void))
(my_mult)(j_free,b,x) );
.
.
.
KSPCreate(PETSC_COMM_WORLD,&ksp);
KSPSetOperators(ksp,j_free,A);
KSPSetFromOptions(ksp);
KSPSolve(ksp,x,sol);
.
.
.
PetscErrorCode my_mult(Mat j_free, Vec b, Vec x)
{
void *ptr;
Mat *ptr2;
MatShellGetContext(j_free, &ptr); // the context is matrix A
ptr2 = (Mat*) ptr;
MatMult(*ptr2,b,x);
return 0;
}
The error as follow:
[0]PETSC ERROR: No support for this operation for this object type
[0]PETSC ERROR: This matrix type does not have a multiply defined
[0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html
for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.6.3, unknown
[0]PETSC ERROR: ./jac_free on a arch-linux2-c-debug named
humam-VirtualBox by humam Mon Mar 21 23:37:14 2016
[0]PETSC ERROR: Configure options --download-hdf5=1
--with-blas-lapack-dir=/usr/lib --with-mpi-dir=/usr
[0]PETSC ERROR: #1 MatMult() line 2223 in
/home/humam/petsc/src/mat/interface/matrix.c
[0]PETSC ERROR: #2 PCApplyBAorAB() line 727 in
/home/humam/petsc/src/ksp/pc/interface/precon.c
[0]PETSC ERROR: #3 KSP_PCApplyBAorAB() line 272 in
/home/humam/petsc/include/petsc/private/kspimpl.h
[0]PETSC ERROR: #4 KSPGMRESCycle() line 155 in
/home/humam/petsc/src/ksp/ksp/impls/gmres/gmres.c
[0]PETSC ERROR: #5 KSPSolve_GMRES() line 236 in
/home/humam/petsc/src/ksp/ksp/impls/gmres/gmres.c
[0]PETSC ERROR: #6 KSPSolve() line 604 in
/home/humam/petsc/src/ksp/ksp/interface/itfunc.c
[0]PETSC ERROR: #7 main() line 293 in /home/humam/jac_free.c
[0]PETSC ERROR: No PETSc Option Table entries
[0]PETSC ERROR: ----------------End of Error Message -------send entire
error message to petsc-maint at mcs.anl.gov----------
application called MPI_Abort(MPI_COMM_WORLD, 56) - process 0
Thanks,
Humam
More information about the petsc-users
mailing list