Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for complex numbers #94

Open
HelgeGehring opened this issue Aug 13, 2023 · 3 comments
Open

Support for complex numbers #94

HelgeGehring opened this issue Aug 13, 2023 · 3 comments

Comments

@HelgeGehring
Copy link

Thanks for the great library!

Would it be possible to add support for complex numbers?

@pablorubial
Copy link

pablorubial commented Jan 2, 2025

I have been working on this, and it appears that adding the following simple line of code to the build.jl file of GridapPETSc automatically provides support. With this modification, I was able to successfully solve the Helmholtz equation using complex numbers.

if scalar_type[] == PETSC_DOUBLE &&  scalar_size[] == 8
  PetscScalar = Float64
elseif scalar_type[] == PETSC_DOUBLE &&  scalar_size[] == 4
  PetscScalar = Float32
elseif scalar_type[] == PETSC_COMPLEX &&  scalar_size[] == 16
  PetscScalar = ComplexF64
else
  @error scalar_msg
end

A the same time, you have to compile PETSc locally using the flag --with-scalar-type=complex. For the local compilation something like this work for me:

# Configure PETSc
python3 ./configure \ 
--PETSC_ARCH=linux-gnu-complex-64 \
--with-cc=mpicc \
--with-cxx=mpicxx \
--with-fc=mpif90 \
--with-scalar-type=complex \
--with-pic=1 \
--with-shared-libraries=1 \
--with-debugging=no \
--download-fblaslapack=1 \
--download-metis=1 \
--download-parmetis=1 \
--download-superlu_dist=1 \
--download-mumps=1 \
--download-scalapack=1 \
--download-hypre=1 \
--download-elemental=1 \
--download-cmake
# Compile PETSc
make PETSC_DIR=/home/pablo/software/petsc PETSC_ARCH=linux-gnu-complex-64 all
# Check PETSc build
make PETSC_DIR=/home/pablo/software/petsc PETSC_ARCH=linux-gnu-complex-64 check

Could you check this @JordiManyer @fverdugo ?

@JordiManyer
Copy link
Member

Hi @pablorubial thanks for the work! That seems right to me. Would you be able to open a PR with the changes?

@pablorubial
Copy link

Done in pull request #106. Thanks to you @JordiManyer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants