Complex assembly

Hello, I’m new in dolfinx and i would like to implement a complex bilinearform (sesquilinear) that looks like:

c=2+3j
a = fem.form(c*inner(grad(u),grad(v))*dx)

this is only an example. Is it possible?

DOLFINx version: 0.3.1.0

Yes, this is possible. You need to use dolfinx that is compiled with the complex build of PETSc, which can be obtained by for instance using docker and the image dolfinx/dolfinx, and then call source dolfinx-complex-mode.

Hello dokken, thank you for the help. I’have installed dolfinx from source on a Unix PC. How can I activate the complex build of PETSc in this case??

Did you build petsc from source as well?

You need to set the PETS_ARCH to point to the complex build of PETSC, as done in: dolfinx/Dockerfile at main · FEniCS/dolfinx · GitHub

I did not install PETSC from source, I installed with Homebrew. But I’ve already found the complex build of PETSC in Homebrew and i’m installing it now. after that i guess i just have to reinstall dolfinx, right?
Thank you Dokken for your help.

Yes, you would have to reinstall dolfinx. When calling cmake on the C++ interface you should see something like:

-- Checking for one of the modules 'PETSc>=3.15;petsc>=3.15'
-- Looking for PETSC_USE_COMPLEX
-- Looking for PETSC_USE_COMPLEX - found
1 Like