[petsc-users] reuse a real matrix for a second linear system with complex numbers
feng wang
snailsoar at hotmail.com
Fri May 14 09:36:47 CDT 2021
Thanks for your comments. It is very helpful!
I might try the 1st approach first. For the 2nd approach which uses an equivalent real-number system, I see potential issues when running in parallel. I have re-ordered my cells to allow each rank hold continuous rows in the first real system Ax=B. For the equivalent real-number system, each rank now holds (or can assign values to) two patches of continuous rows, which are separated by N rows, N is the size of square matrix A. I can't see a straightforward way to allow each rank hold continuous rows in this case. or petsc can handle these two patches of continuous rows with fixed row index difference in this case?
By the way, could I still re-use my KSP object in my second system by simply changing the operators and setting new parameters?
Thanks,
Feng
________________________________
From: Matthew Knepley <knepley at gmail.com>
Sent: 14 May 2021 10:00
To: feng wang <snailsoar at hotmail.com>
Cc: petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] reuse a real matrix for a second linear system with complex numbers
On Fri, May 14, 2021 at 4:23 AM feng wang <snailsoar at hotmail.com<mailto:snailsoar at hotmail.com>> wrote:
Dear All,
I am solving a coupled system. One system is AX=B. A, X and B are all real numbers and it is solved with GMRES in petsc. Now I need to solve a second linear system, it can be represented as (A+i*w)*Z=C. i is the imaginary unit. Z and C are also complex numbers.
So the Jacobian matrix of the second system is just A plus a diagonal contribution i*w. I would like solve the second system with GMRES, could petsc handle this? any comments are welcome.
Mixing real and complex numbers in the same code is somewhat difficult now. You have two obvious choices:
1) Configure for complex numbers and solve your first system as complex but with 0 imaginary part. This will work fine, but uses more memory for that system. However, since you will already
use that much memory for the second system, it does not seem like a big deal to me.
2) You could solve the second system in its equivalent real form
/ A w \ /Zr\ = /Cr\
\ -w A / \Zi/ \Ci/
This uses more memory for the second system, but does not require reconfiguring.
THanks,
Matt
Thanks,
Feng
--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20210514/3f9165d5/attachment.html>
More information about the petsc-users
mailing list