ngs-petsc with complex numbers

Dear NGSolve / ngs-petsc developers,

I managed to compile ngs-petsc using petsc with real numbers. However, I would like to also use complex numbers. When I tried to compile ngs-petsc with petsc using complex numbers, the compilation failed.
Am I right that this interface is currently not implemented? Are there any plans to implement this or is there anything speaking against this?

Thank you for your reply!

Best,
Julius

You are right, I have not touched the complex case at all yet.

In principle, I do not think it would be hard to handle the complex case. I have not done it yet mostly because I do not know how to make the complex and the real interface work at the same time.

I will try it out sometime this week or next, if I do not run into troubles it should be available in the GitHub at some point.

Best,
Lukas

That’s great to hear! Thank you very much!
Please let me know if I can somehow contribute to this (with an example or even to the code basis).

Best,
Julius

I have push a new branch, “complex”, to the github repo.

You must set -DPETSC_COMPLEX=ON, and the complex version of the interface will be built.
(Compiling will throw an error when it tries to compile against a real PETSc installation when this is turned on, or if it finds a complex one when it is turned off)

You can have the real and complex interfaces installed at the same time, one will be called “ngs_petsc” and the other “ngs_petsc_complex”.

Unfortunately:

  1. You cannot load both at the same time
  2. When you a complex and a real PETSc installation at the same time, you have to be careful with your LD_LIBRARY_PATH/PETSC_ARCH/PETSC_DIR environment variables! For me, loading ngs_petsc when the complex libraries take priority will not produce an error but garbage output!

Best, Lukas

That’s awesome! I could compile and run the example. I will now try to implement my own examples. Thank you very much!

Best,
Julius

Hi Lukas
I think i am missing something when you say the complex petsc interface should get built automatically. I have the option DPETSC_COMPLEX=ON but cmake warns it’s not being used. Do i have to specify where the ngsolve-petsc is located?

Have you checked out the complex branch? I have not merged the changes into the master yet!

Yes, this is what i have in the build script:

export BASEDIR=/home/diwang/Documents/extsofts/
mkdir -p $BASEDIR
cd $BASEDIR && git clone https://github.com/NGSolve/ngsolve.git ngsolve-src
cd $BASEDIR && git clone https://github.com/NGSolve/ngs-petsc.git ngsolve-petsc
cd $BASEDIR/ngsolve-petsc && git checkout complex && git pull
cd $BASEDIR/ngsolve-src && git submodule update --init --recursive
mkdir $BASEDIR/ngsolve-build
mkdir $BASEDIR/ngsolve-install
cd $BASEDIR/ngsolve-build
cmake -DINSTALL_DIR=${BASEDIR}/ngsolve-install ${BASEDIR}/ngsolve-src \
-DUSE_OCC=ON \
-DUSE_GUI=OFF \
-DUSE_PYTHON=ON \
-DUSE_MPI=ON \
-DUSE_MUMPS=ON \
-DUSE_UMFPACK=ON \
-DCMAKE_CXX_COMPILER=/usr/bin/g++ \
-DCMAKE_C_COMPILER=/usr/bin/gcc \
-DPETSC_COMPLEX=ON \
-DLIB_MPIF90=/usr/lib/libmpifort.so
make -j4
make install
echo "export NETGENDIR=${BASEDIR}/ngsolve-install/bin" >> ~/.bashrc
echo "export PATH=\$NETGENDIR:\$PATH" >> ~/.bashrc
export PYTHONPATH_TMP=`python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1,0,''))"`
echo "export PYTHONPATH=\$NETGENDIR/../${PYTHONPATH_TMP}:\$PATH" >> ~/.bashrc
source ~/.bashrc
cd ${BASEDIR}/ngsolve-install/share/ngsolve/py_tutorials/intro

I am not sure if ngsolve-petsc has to be inside {BASEDIR}/ngsolve-src/external_dependencies or in the {BASEDIR} itself.

You have to run cmake/make seperately for ngs-petsc. It is not integrated into the NGSolve SuperBuild right now.

So first install Netgen/NGSolve and PETSc, then install ngs-petsc.