example of call to superlu_dist

Satish Balay balay at mcs.anl.gov
Wed May 6 12:14:10 CDT 2009


PCFactorSetMatSolverPackage() works for me with a test example.

Satish

[petsc:ksp/examples/tutorials] petsc> hg diff ex2.c
diff -r fca389f2db83 src/ksp/ksp/examples/tutorials/ex2.c
--- a/src/ksp/ksp/examples/tutorials/ex2.c      Wed May 06 10:52:26 2009 -0500
+++ b/src/ksp/ksp/examples/tutorials/ex2.c      Wed May 06 12:13:10 2009 -0500
@@ -38,6 +38,7 @@
   PetscErrorCode ierr;
   PetscTruth     flg = PETSC_FALSE;
   PetscScalar    v,one = 1.0,neg_one = -1.0;
+  PC             pc;
 #if defined(PETSC_USE_LOG)
   PetscLogStage  stage;
 #endif
@@ -187,6 +188,9 @@
     KSPSetFromOptions() is called _after_ any other customization
     routines.
   */
+  ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr);
+  ierr = PCSetType(pc,PCLU);CHKERRQ(ierr);
+  ierr = PCFactorSetMatSolverPackage(pc,MAT_SOLVER_SUPERLU_DIST);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
 
   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
[petsc:ksp/examples/tutorials] petsc> mpiexec -n 2 ./ex2 -ksp_view
KSP Object:
  type: gmres
    GMRES: restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement
    GMRES: happy breakdown tolerance 1e-30
  maximum iterations=10000, initial guess is zero
  tolerances:  relative=0.000138889, absolute=1e-50, divergence=10000
  left preconditioning
PC Object:
  type: lu
    LU: out-of-place factorization
      matrix ordering: natural
    LU: tolerance for zero pivot 1e-12
    LU: factor fill ratio needed 0
         Factored matrix follows
        Matrix Object:
          type=mpiaij, rows=56, cols=56
          package used to perform factorization: superlu_dist
          total: nonzeros=0, allocated nonzeros=112
            SuperLU_DIST run parameters:
              Process grid nprow 2 x npcol 1 
              Equilibrate matrix TRUE 
              Matrix input mode 1 
              Replace tiny pivots TRUE 
              Use iterative refinement FALSE 
              Processors in row 2 col partition 1 
              Row permutation LargeDiag 
              Column permutation MMD_AT_PLUS_A
              Parallel symbolic factorization FALSE 
              Repeated factorization SamePattern
  linear system matrix = precond matrix:
  Matrix Object:
    type=mpiaij, rows=56, cols=56
    total: nonzeros=250, allocated nonzeros=560
      not using I-node (on process 0) routines
Norm of error < 1.e-12 iterations 1
[petsc:ksp/examples/tutorials] petsc> 



On Wed, 6 May 2009, Fredrik Bengzon wrote:

> Hi
> Is there an example of how to call superlu_dist somewhere. I'm  not looking
> for command line options, but how to call KSP in my code when using
> superlu_dist. I've set the KSPPREONLY, and PCLU options, and also made a call
> to PCFactorSetMatSolverPackage(), but this does not seem to be the right way
> to do it. Petsc aborts with error message 'mpiaij matrix does not have a
> build-in LU solver'. Do I need to specify any particular matrix format to use
> with superlu_dist? Any input is appreciated.
> Regards
> Fredrik Bengzon
> 



More information about the petsc-users mailing list