hypre-space / hypre

Parallel solvers for sparse linear systems featuring multigrid methods.
https://www.llnl.gov/casc/hypre/
Other
674 stars 185 forks source link

Complex numbers support #152

Open djanekovic opened 4 years ago

djanekovic commented 4 years ago

Hi all, I installed hypre with complex numbers support and encountered numerous warnings about incompatible pointer type. On the other hand, real numbers support works fine. I started to fix warnings and at this point I am wondering if there is some development in this area? Should I be doing this or this is not a concern to the hypre developers?

Kind regards, Darko

rfalgout commented 4 years ago

Hi @djanekovic . Complex numbers support has not been a high priority for us (hence the many warnings), but it is something we are interested in. Out of curiosity, what were you doing to fix the warnings? Explicit casting? Thanks!

djanekovic commented 4 years ago

Hi @rfalgout, thanks for the quick answer! I forked the repo and started pushing changes like this: https://github.com/djanekovic/hypre/commit/cc35da3667c62e27e7b5c81770ba2dddba5a5d34 Basically I am going over the code and changing HYPRE_Real -> HYPRE_Complex and sqrt -> hypre_sqrt -> csqrt and such. I am trying to be as precise as I can with the changes but there are a lot of these...

rfalgout commented 4 years ago

Thanks for the info @djanekovic . Eliminating the warnings would be nice, but I'd like to have a clear plan on how to go about that, because the only solvers that currently work with Complex turned on are PCG and GMRES (if memory serves me correctly), and I don't expect that all solvers will support Complex (hence, they should use the Real type).

I wouldn't want you to go too far down this path unless you will get something out of it, so can you tell me what you were hoping hypre would do for you in the Complex case? Thanks again!

djanekovic commented 4 years ago

We would like to try hypre AMS for time-harmonic maxwell equations

rfalgout commented 4 years ago

Okay. Note that we currently don't support a complex version of AMS. The following article discusses an approach based on the equivalent real system: https://www.research-collection.ethz.ch/bitstream/handle/20.500.11850/103394/geo2015-0013.1.pdf?sequence=2 . We have plans to support this directly in hypre, but I don't have a definitive time-frame to give you. Tzanio Kolev ( @tzanio ) may have more to add or suggest on this front.

rkcroc commented 3 years ago

@rfalgout I am working on a complex wave equation solver similar to @djanekovic. You mention plans to implement an approach similar to Grayver & Kolev. Any new news on when this might reach active development and release? It could be very useful in our application.

tzanio commented 3 years ago

Hi @djanekovic and @rkcroc,

This doesn't address your question directly, but MFEM has an AMS-based implementation for something very similar in one of its examples. See https://mfem.org/examples/?ams and https://github.com/mfem/mfem/blob/master/examples/ex22p.cpp.

Tzanio

lucasbanting commented 2 years ago

Okay. Note that we currently don't support a complex version of AMS. The following article discusses an approach based on the equivalent real system: https://www.research-collection.ethz.ch/bitstream/handle/20.500.11850/103394/geo2015-0013.1.pdf?sequence=2 . We have plans to support this directly in hypre, but I don't have a definitive time-frame to give you. Tzanio Kolev ( @tzanio ) may have more to add or suggest on this front.

Has there been any progress on this issue? I would like to use AMS with a complex matrix A and complex rhs b. Based off the shared paper, as well as MFEM's implementation, the real block wise preconditioner to use with AMS should be Re{A} + Im{A} I think.

I am mostly a PETSc user, and am not too familiar with HYPRE. Does HYPRE support mixing complex matrices and real valued matrices in the same code? If it does, it should be not too involved to support complex systems for AMS. Additionally if AMS supported multivec, the preconditioner could be applied to the real and imaginary parts at the same time.

rfalgout commented 2 years ago

Hi @lucasbanting . No progress on this, and no real plans in place either. HYPRE does allow both complex and real types at the same time. The original idea here was to implement a complex AMS solver that automatically creates the equivalent real system and builds on the real AMS algorithm as described in the article mentioned above.