Direct LU solver

Satish Balay balay at mcs.anl.gov
Fri Feb 29 13:06:06 CST 2008


On Fri, 29 Feb 2008, Amit.Itagi at seagate.com wrote:

> 
> My woes continue.  Based on the earlier discussions, I implemented the
> matrix as
> 
> //=========================================================================
> 
>  //   Option 1
>   ierr=MatCreate(PETSC_COMM_WORLD,&A); CHKERRQ(ierr);
>   ierr=MatSetSizes(A,1,1,2,2); CHKERRQ(ierr);
> 
> 
>   /*    Option 2
>   PetscInt d_nnz=1, o_nnz=1;
>   ierr=MatCreateMPIAIJ(PETSC_COMM_WORLD,1,1,2,2,0,&d_nnz,0,&o_nnz,&A);
> CHKERRQ(ierr);
>   */
> 
>   /*   Option 3
> 
> ierr=MatCreateMPIAIJ(PETSC_COMM_WORLD,1,1,2,2,0,PETSC_NULL,0,PETSC_NULL,&A);
>  CHKERRQ(ierr);
>   */
> 
>   ierr=MatSetType(A,MATSUPERLU_DIST); CHKERRQ(ierr);
>   ierr=MatSetFromOptions(A); CHKERRQ(ierr);
> 
>   // (After this, I set the values and do the assembly). I then use the
> direct LU solver.
> 
> //============================================================================
> 
> Note: I have a simple 2 by 2 matrix (with non-zero values in all 4 places).
> If I use "option 1" (based on Satish's email), the program executes
> successfully. If instead of "option 1", I use "option 2" or "option 3", I
> get a crash.
> If I am not mistaken, options 1 and 3 are the same. Option 2, additionally,
> does a pre-allocation. Am I correct ?

Nope - Option 3 is same as:

MatCreate()
MatSetType(MPIAIJ)
MatMPIAIJSetPreallocation()
MatSetType(MATSUPERLU_DIST)

[i.e first you are setting type as MPIAIJ, and then changing to
MATSUPERLU_DIST]

What you want is:

MatCreate()
MatSetType(MATSUPERLU_DIST)
MatMPIAIJSetPreallocation()

[Ideally you need MatSuerLU_DistSetPreallocation() - but that would be
same as MatMPIAIJSetPreallocation()]

Satish




More information about the petsc-users mailing list