[petsc-users] solving system with 2x2 block size

Manav Bhatia bhatiamanav at gmail.com
Tue Nov 15 16:37:48 CST 2016


> On Nov 15, 2016, at 3:34 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> 
>    In PETSc we call this 2x2 block Jacobi "point-block Jacobi"  you can use the option -pc_type pbjacobi.  The ILU() in PETSc can also be "point block", this is obtained with the usual -pc_type ilu (that is there is no different preconditioner name for ILU point block).  To use all these things you need to make your matrix a BAIJ matrix (not an AIJ) and set its block size to 2. 
> 

The following code is how I setup the matrix in the code, and the provide the command line options for specifics. Is there anything I need to change about this to achieve a block size of 2 and then use the point block solvers? 


    ierr = MatCreate(sys.comm().get(), &mat);                      CHKERRABORT(sys.comm().get(), ierr);
    ierr = MatSetSizes(mat, 2*m_l, 2*n_l, 2*my_m, 2*my_n);         CHKERRABORT(sys.comm().get(), ierr);
    ierr = MatSetType(mat, MATAIJ);                                CHKERRABORT(sys.comm().get(), ierr);
    ierr = MatSetBlockSize(mat, 2);                                CHKERRABORT(sys.comm().get(), ierr);
    ierr = MatSeqAIJSetPreallocation(mat,
                                     2*my_m,
                                     (PetscInt*)&complex_n_nz[0]); CHKERRABORT(sys.comm().get(), ierr);
    ierr = MatMPIAIJSetPreallocation(mat,
                                     0,
                                     (PetscInt*)&complex_n_nz[0],
                                     0,
                                     (PetscInt*)&complex_n_oz[0]); CHKERRABORT(sys.comm().get(), ierr);
    ierr = MatSeqBAIJSetPreallocation (mat, 2,
                                       0, (PetscInt*)&n_nz[0]);    CHKERRABORT(sys.comm().get(), ierr);
    ierr = MatMPIBAIJSetPreallocation (mat, 2,
                                       0, (PetscInt*)&n_nz[0],
                                       0, (PetscInt*)&n_oz[0]);    CHKERRABORT(sys.comm().get(), ierr);
    ierr = MatSetOption(mat,
                        MAT_NEW_NONZERO_ALLOCATION_ERR,
                        PETSC_TRUE);                               CHKERRABORT(sys.comm().get(), ierr);
    
    ierr = MatSetFromOptions(mat);                                 CHKERRABORT(sys.comm().get(), ierr);


>   Have you tried solving the matrices as complex? Is there a reason you wish to reformulate them as real? 

The complex matrices come from a frequency domain formulation of compressible Euler equations using SU/PG method. This is a chunk in a larger part of the code that also needs to solve some real-valued problems before the complex solution. I need to keep a single code that does all this, so I am sticking with the real formulation. 

I used to do think with separate codes built for real-valued and complex-valued codes, and never had a problem applying the iterative solvers to the complex code. But now I need that done with the equivalent real formulation. 

> 
>   The convergence of iterative methods (either with real or complex numbers) depends on the properties of the A and B (i.e. C) matrix. Where does the C matrix come from? There are many applications that result in complex matrices that are poorly conditioned for iterative methods.

Given that I have had success with applying iterative solvers to the complex system (not in equivalent real-valued form), and following the discussion in the paper, my understanding is that some form of point preconditioner (not sure if this is the right terminology) would be able equivalent to applying the same preconditioner to the complex problem. (Please correct if this is not true). 

So, if it works for complex valued, can we get it to work for the equivalent form? 

-Manav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20161115/bab58036/attachment-0001.html>


More information about the petsc-users mailing list