TAO solver for the complex mode

I am using dolfinx Docker image in the complex mode, but there is no PETSc TAO method that I can use. Everything works fine when I use the real mode of Docker image. Based on my search, there are TAO solvers that exist for complex numbers. Is there any dOLFINX Docker image equipped with TAO for complex numbers?

Hi @alireza_sharif,

could you clarify a bit further what your setup looks like and what is not working? You are using the dolfinx/dolfinx - Docker Image image for both the real and complex setup? Which method calls do not work? There are some differences in available functionality in the Python complex TAO version, ref src/binding/petsc4py/src/lib-petsc/compat/tao.h · main · PETSc / petsc · GitLab.

Hi @schnellerhase,
Thank you for your reply.
I have installed the docker image of dolfinx/dolfinx:stable and use source /usr/local/bin/dolfinx-complex-mode and source /usr/local/bin/dolfinx-real-mode to switch between real and complex numbers.
All the Tao solvers that I can think of do not exist with the complex mode, while according to the link that you kindly shared, they should. Please find the attached code to reproduce my issue:

from petsc4py import PETSc

tao = PETSc.TAO().create(PETSc.COMM_WORLD)

all_types = [
'nls', 'ntr', 'ntl', 'cg', 'tron', 'nm', 'lmvm',
    'blmvm', 'bncg', 'bnls', 'bntr', 'bqnls', 'bqnkls',
    'bqnktr', 'bqnktl', 'pounders', 'brgn', 'lcl',
    'ssils', 'ssfls', 'asils', 'asfls', 'ipm', 'dsils']

print("=== Available TAO types in this build ===")
for t in all_types:
    try:
        tao.setType(t)
        print(f"  ✓ {t}")
    except Exception:
        print(f"  ✗ {t}")

tao.destroy()

Thanks for the code snippet. Can reproduce the behaviour you are seeing.

This seems to be a limitation on the PETSc end, see this thread. Technically all makefiles in the PETSc/src/tao tree ship with the marker #requiresscalar real, so they require a real scalar type to be build.

As stated in the thread this seems to be for historic reasons, and no one has yet altered this behaviour (in particular inequalities are problematic for complex types). Anyways this seems to be a PETSc issue. Best to raise it again at Work items · PETSc / petsc · GitLab.