Re: [petsc-users] Using matrix-free with KSP

2022-08-16 Thread Tu, Jiannan
Barry, Thank you so much. I'll try these options and see how they work. Jiannan From: Barry Smith Sent: Tuesday, August 16, 2022 1:59 PM To: Tu, Jiannan Cc: petsc-users@mcs.anl.gov Subject: Re: [petsc-users] Using matrix-free with KSP CAUTION: This email was

Re: [petsc-users] Parallel assembly of a matrix problem

2022-08-16 Thread Barry Smith
MatMPIAIJSetPreallocation(A, 3, NULL, 0, NULL); The 0 indicates you expect that there will be no matrix entries in the columns of the matrix that represent degrees of freedom that are not stored on the given rank. In your case this means you expect the matrix to be block diagonal with one

Re: [petsc-users] Using matrix-free with KSP

2022-08-16 Thread Barry Smith
Create another matrix B that contains "Selected parts of the matrix can be pre-calculated and stored to serve as the preconditioner." When you call KSPSetOperators() pass in B as the second matrix argument. Now if literally application of B is the preconditioner you want to use, then

Re: [petsc-users] Parallel assembly of a matrix problem

2022-08-16 Thread Patrick Alken
I have managed to simplify my example program, and removed the dependencies on slepc and gsl (attached). The program defines a 800x800 matrix with 3 non-zero entries per row, which are all set to 1.0. When I run the program on 1 processor, everything works correctly. When I run it on 2+

Re: [petsc-users] Scaling of PETSc example ex2f.F90

2022-08-16 Thread Jed Brown
Your observed performance is explained by the number of iterations, which varies based on a number of factors, plus imperfect memory bandwidth scaling (https://petsc.org/release/faq/#what-kind-of-parallel-computers-or-clusters-are-needed-to-use-petsc-or-why-do-i-get-little-speedup). Problems

Re: [petsc-users] Using matrix-free with KSP

2022-08-16 Thread Tu, Jiannan
Barry, Thank you very much for your instructions. I am sorry I may not ask clearer questions. I don't use SNES. What I am trying to solve is a very large linear equation system with dense and ill-conditioned matrix. Selected parts of the matrix can be pre-calculated and stored to serve as the

[petsc-users] Scaling of PETSc example ex2f.F90

2022-08-16 Thread Sidarth Narayanan
Hello PETSc team, I am currently using PETSc to improve the performance of a CFD solver by using it's parallel linear solver. While doing so I ran across some scaling issues where performance increase ( measured as KSPSolve time using MPI_Wtime() function ) in the linear algebra operation was

Re: [petsc-users] Using matrix-free with KSP

2022-08-16 Thread Barry Smith
I don't fully understand your question so I will answer questions that I do know the answer to :-) The function you provide to PCShellSetApply() applies the preconditioner to the input vector and puts the result in the output vector. This input vector changes at every application of the

Re: [petsc-users] Using matrix-free with KSP

2022-08-16 Thread Tu, Jiannan
I am trying to apply a user-defined preconditioner to speed up the convergency of matrix-free KSP solver. The user's manual provides an example of how to call the user-defined preconditioner routine. The routine has PC, input Vec and output Vec as arguments. I want to use part of the Jacobian