[petsc-users] Using matrix-free with KSP
Tu, Jiannan
Jiannan_Tu at uml.edu
Mon May 30 19:29:11 CDT 2022
Barry, thanks for the clarification.
Jiannan
From: Barry Smith <bsmith at petsc.dev>
Sent: Monday, May 30, 2022 7:49 PM
To: Tu, Jiannan <Jiannan_Tu at uml.edu>
Cc: petsc-users at mcs.anl.gov
Subject: Re: [petsc-users] Using matrix-free with KSP
This e-mail originated from outside the UMass Lowell network.
________________________________
50,000 * 50,000 > 2^31 (roughly 2 billion) hence we cannot represent even the length of a vector using 32 bit integers; just to do "book keeping" of dimensions requires using 64 bit integers. Using 64 bit integers should not slow PETSc significantly, especially in matrix-free mode.
On May 30, 2022, at 7:33 PM, Tu, Jiannan <Jiannan_Tu at uml.edu<mailto:Jiannan_Tu at uml.edu>> wrote:
I tried the matrix-free method. Since the number of the unknown is large, say 50000, then the number of matrix elements is 50000^2, which is greater than the max number represented by the 32-bit int. PETSC gives an error message: “Mesh of 50,000 by 50,000 by 1 (dof) is too large for 32 bit indices.”
I know using the 64-bit int option when compiling PETSC can avoid this error. However, it seems that 64-bit int makes the PETSC relatively slow. I wonder why the matrix-free method still counts the total number of matrix elements even though they are not stored. Any other ways around it?
Thank you,
Jiannan
From: Barry Smith <bsmith at petsc.dev<mailto:bsmith at petsc.dev>>
Sent: Tuesday, May 24, 2022 2:13 PM
To: Tu, Jiannan <Jiannan_Tu at uml.edu<mailto:Jiannan_Tu at uml.edu>>
Cc: petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] Using matrix-free with KSP
This e-mail originated from outside the UMass Lowell network.
________________________________
You can use MatCreateMFFD https://petsc.org/main/docs/manualpages/Mat/MatCreateMFFD/<https://urldefense.com/v3/__https:/petsc.org/main/docs/manualpages/Mat/MatCreateMFFD/__;!!PVKG_VDCxu5g!stxq2NWGVjUihvHBQC9Rlk0aHVoowcy0PTQYMcQxQ4DqOEC05KSw6TmstSXKckiUgelHzy4ue-d10-zlXkw$> MatMFFDSetFunction MatSetFromOptions MatMFFDSetBase and provide the matrix to KSP. Note you will need to use -pc_type none or provide your own custom preconditioner with https://petsc.org/main/docs/manualpages/PC/PCSHELL/<https://urldefense.com/v3/__https:/petsc.org/main/docs/manualpages/PC/PCSHELL/__;!!PVKG_VDCxu5g!stxq2NWGVjUihvHBQC9Rlk0aHVoowcy0PTQYMcQxQ4DqOEC05KSw6TmstSXKckiUgelHzy4ue-d1cA4fKGw$>
On May 24, 2022, at 1:21 PM, Tu, Jiannan <Jiannan_Tu at uml.edu<mailto:Jiannan_Tu at uml.edu>> wrote:
I want to use a matrix-free matrix to solve a large linear equation system because the matrix is too large to be stored. Petsc user manual describes matrix-free method for SNES with examples. The matrix-free matrices section explains how to set up such a matrix, but I can't find any example of matrix-free method with KSP. I am wondering how to apply the method to KSP iterative solver in parallel.
I greatly appreciate your help for me to understand this topic.
Jiannan Tu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220531/f0901abc/attachment.html>
More information about the petsc-users
mailing list