<div dir="ltr"><div dir="ltr">On Thu, May 7, 2020 at 1:38 PM Satish Balay via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Its best to keep the discussion on the list [or petsc-maint] - as others would have answers to some of these qestions.<br>
<br>
Wrt -info - yeah this is the correct option [my mistake in suggesting -log_info]<br>
<br>
Wrt understanding performance -log_view should help<br></blockquote><div><br></div><div>Block preconditioners tend to come down to having a good preconditioner for the Schur complement. There is a voluminous</div><div>literature here. For example, <a href="https://www.sciencedirect.com/science/article/pii/S0021999107004330">https://www.sciencedirect.com/science/article/pii/S0021999107004330</a></div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Satish<br>
<br>
<br>
On Thu, 7 May 2020, Thomas S. Chyczewski wrote:<br>
<br>
> Satish,<br>
> <br>
> Thanks for your help. Sorry for not being able to figure it out on my own. I had a little trouble following the discussion in the manual. I got the block version working now and the linear solver time is cut in half compared to the monolithic version for a given set of parameters. I have experimented with a number of solver and preconditioner options as well as solver convergence criteria. But I'm wondering if there are any other parameters I should be playing with. I ask because I also had some trouble following the PCFIELDSPLIT discussion in the manual and I'm wondering if the default is the best option for me.<br>
> <br>
> The -log_info option isn't available in the Fortran version, so I couldn't check the inode information as you suggested. However, below is the output when I run with the -info option. I know that having no mallocs during MatSetValues is good, but that's about it.<br>
> <br>
> Thanks,<br>
> Tom<br>
> <br>
> [0] PetscGetHostName(): Rejecting domainname, likely is NIS arl19814.(none)<br>
> [0] petscinitialize_internal(): (Fortran):PETSc successfully started: procs 1<br>
> [0] PetscGetHostName(): Rejecting domainname, likely is NIS arl19814.(none)<br>
> [0] petscinitialize_internal(): Running on machine: arl19814<br>
> [0] PetscCommDuplicate(): Duplicating a communicator 2 2 max tags = 100000000<br>
> [0] MatAssemblyEnd_SeqBAIJ(): Matrix size: 374400 X 374400, block size 3; storage space: 11199240 unneeded, 5606640 used<br>
> [0] MatAssemblyEnd_SeqBAIJ(): Number of mallocs during MatSetValues is 0<br>
> [0] MatAssemblyEnd_SeqBAIJ(): Most nonzeros blocks in any row is 5<br>
> [0] MatCheckCompressedRow(): Found the ratio (num_zerorows 0)/(num_localrows 124800) < 0.6. Do not use CompressedRow routines.<br>
> [0] PCSetUp(): Setting up PC for first time<br>
> [0] PetscCommDuplicate(): Duplicating a communicator 1 3 max tags = 100000000<br>
> [0] PetscCommDuplicate(): Using internal PETSc communicator 1 3<br>
> [0] PCSetUp(): Leaving PC with identical preconditioner since operator is unchanged<br>
> [0] PCSetUp(): Leaving PC with identical preconditioner since operator is unchanged<br>
> [0] PCSetUp(): Leaving PC with identical preconditioner since operator is unchanged<br>
> [0] PCSetUp(): Leaving PC with identical preconditioner since operator is unchanged<br>
> [0] PCSetUp(): Leaving PC with identical preconditioner since operator is unchanged<br>
> [0] PCSetUp(): Leaving PC with identical preconditioner since operator is unchanged<br>
> [0] PCSetUp(): Leaving PC with identical preconditioner since operator is unchanged<br>
> [0] PCSetUp(): Leaving PC with identical preconditioner since operator is unchanged<br>
> [0] PCSetUp(): Leaving PC with identical preconditioner since operator is unchanged<br>
> <br>
> <br>
> <br>
> -----Original Message-----<br>
> From: Satish Balay <<a href="mailto:balay@mcs.anl.gov" target="_blank">balay@mcs.anl.gov</a>> <br>
> Sent: Wednesday, May 6, 2020 4:05 PM<br>
> To: Thomas S. Chyczewski <<a href="mailto:tsc109@arl.psu.edu" target="_blank">tsc109@arl.psu.edu</a>><br>
> Cc: petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>><br>
> Subject: Re: [petsc-users] [EXTERNAL] Re: Example code of linear solve of a block matrix system in Fortran<br>
> <br>
> You can use <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetValuesBlocked.html" rel="noreferrer" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetValuesBlocked.html</a><br>
> <br>
> MatSetValues() will also work - but MatSetValuesBlocked() is more efficient wrt BAIJ<br>
> <br>
> Satish<br>
> <br>
> On Wed, 6 May 2020, Thomas S. Chyczewski wrote:<br>
> <br>
> > Thanks Satish. I have seen that page and can create a block matrix. It's not clear to me how to fill it and use it in a Fortran code.<br>
> > <br>
> > -----Original Message-----<br>
> > From: Satish Balay <<a href="mailto:balay@mcs.anl.gov" target="_blank">balay@mcs.anl.gov</a>> <br>
> > Sent: Wednesday, May 6, 2020 3:43 PM<br>
> > To: Thomas S. Chyczewski <<a href="mailto:tsc109@arl.psu.edu" target="_blank">tsc109@arl.psu.edu</a>><br>
> > Cc: <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>
> > Subject: [EXTERNAL] Re: [petsc-users] Example code of linear solve of a block matrix system in Fortran<br>
> > <br>
> > What you are looking for is:<br>
> > <br>
> > <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateBAIJ.html" rel="noreferrer" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateBAIJ.html</a><br>
> > <br>
> > indoe is optimization for AIJ type - where you might not have a simple block size like 3 that you have.<br>
> > <br>
> > BAIJ will perform better than AIJ/with-inode<br>
> > <br>
> > To verify indoe usage - you can run the code with '-log_info' option - and do a 'grep inode'<br>
> > <br>
> > Satish<br>
> > <br>
> > On Wed, 6 May 2020, Thomas S. Chyczewski wrote:<br>
> > <br>
> > > <br>
> > > All,<br>
> > > <br>
> > > I'm relatively new to PETSc and have relied pretty heavily on the example codes included in the distribution to figure out the finer points of using the PETSc library that I couldn't deduce from the manual. One thing I can't figure out is how to solve block matrix systems and I couldn't find an example in Fortran. I'm writing a 2D incompressible CFD solver so I have a 3x3 block Imax*Jmax system. The closest I've come to finding an example is ex19.c in the snes directory, but that is in c and for the nonlinear solver.<br>
> > > <br>
> > > I have been able to run PETSc but unwrapping the block matrix into a monolithic system. But the manual says "Block matrices represent an important class of problems in numerical linear algebra and offer the possibility of far more efficient iterative solvers than just treating the entire matrix as black box." However, in the FAQs I saw a comment that PETSc scans the AIJ matrices for rows that have the same column layout and can deduce if it's a block system and use the more efficient solvers. I also saw in the archives for this email list a thread where it seems workaround for building fields in a Fortran code is discussed ("Back to struct in Fortran to represent field with dof > 1"), so I'm beginning to suspect building a block system in Fortran might not be straight forward.<br>
> > > <br>
> > > All that being said, my questions:<br>
> > > <br>
> > > Is there a significant advantage to building the block system as opposed to the analogous monolithic system if PETSc can figure out that it's a block system? Can you confirm that PETSc does figure this out?<br>
> > > If there is an advantage to loading the matrix as a block matrix, is there an example Fortran code that builds and solves a linear block system?<br>
> > > <br>
> > > Thanks,<br>
> > > Tom C<br>
> > > <br>
> > > <br>
> > <br>
> <br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>