hypre icon indicating copy to clipboard operation
hypre copied to clipboard

Complex numbers support

Open djanekovic opened this issue 4 years ago • 9 comments

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

djanekovic avatar Jul 14 '20 17:07 djanekovic

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!

rfalgout avatar Jul 14 '20 17:07 rfalgout

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...

djanekovic avatar Jul 14 '20 18:07 djanekovic

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!

rfalgout avatar Jul 14 '20 18:07 rfalgout

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

djanekovic avatar Jul 14 '20 19:07 djanekovic

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.

rfalgout avatar Jul 14 '20 19:07 rfalgout

@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.

rkcroc avatar Mar 30 '21 17:03 rkcroc

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

tzanio avatar May 27 '21 02:05 tzanio

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.

lucasbanting avatar Sep 27 '22 15:09 lucasbanting

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.

rfalgout avatar Oct 03 '22 21:10 rfalgout