El 16/02/2012, a las 16:41, Verena Kuhlemann escribi?: > Hi, > > I am trying to use LOBPCG via Slepc and I am a little confused on how to set > the preconditioner and operator matrices. I have a shell matrix A and a > matrix P that should be used for the preconditioning. Here is the relevant > part of my code: > > EPSCreate(PETSC_COMM_WORLD,&eps); > EPSSetOperators(eps, A, PETSC_NULL); > EPSSetProblemType(eps, EPS_HEP); > EPSSetType(eps, EPSBLOPEX); > EPSGetST(eps, &st); > STPrecondSetMatForPC(st, P); > STGetKSP(st,&ksp); > KSPGetPC(ksp, &pc); > KSPSetOperators(ksp,A, P, DIFFERENT_NONZERO_PATTERN); //do I have to set > this?? If I don't the program complains that a matrix is not set > PCSetType(pc, PCJACOBI); > EPSSetUp(eps); > > > Is that correct or do I need to do something else? > > Thanks, > Verena
It works for me like this: ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr); ierr = EPSSetOperators(eps,A,PETSC_NULL);CHKERRQ(ierr); ierr = EPSSetProblemType(eps,EPS_HEP);CHKERRQ(ierr); ierr = EPSSetType(eps,EPSBLOPEX);CHKERRQ(ierr); ierr = EPSGetST(eps,&st);CHKERRQ(ierr); ierr = STPrecondSetMatForPC(st,P);CHKERRQ(ierr); ierr = EPSSetFromOptions(eps);CHKERRQ(ierr); You don't need to manipulate the KSP or PC objects. If you want to check whether your matrix P is being used in Blopex, you can do ierr = PetscObjectSetName((PetscObject)P,"My precond");CHKERRQ(ierr); then run with -eps_view and you will see "Matrix Object: My precond 1 MPI processes" in the PC section. Jose
