DolfinX_mpc and complex mode of petsc

Hi,

Can anyone help me with this issue? I want to import the dolfinx_mpc library in the complex mode of petsc, But I run into the following error message as attached below:

File "/root/Piezobeam/harmonic_piezobeam.py", line 30, in <module>
    import dolfinx_mpc
  File "/usr/local/lib/python3.9/dist-packages/dolfinx_mpc/__init__.py", line 10, in <module>
    import dolfinx_mpc.cpp
ImportError: /usr/local/lib/libdolfinx_mpc.so.0.3: undefined symbol: _ZN7dolfinx2la5petsc18create_vector_wrapERKNS_6common8IndexMapEiRKN3tcb4spanIKdLln1EEE

How did you install the dolfinx_mpc C++ layer, and how did you try to install the python layer. The error message

translates to
dolfinx::la::petsc::create_vector_wrap(dolfinx::common::IndexMap const&, int, tcb::span<double const, -1l> const&) which indicates that your C++ layer of dolfinx_mpc was built with PETSc in real mode

Dear Sir,

I have used the following commands to install the dolfinx_mpc:

git clone https://github.com/jorgensd/dolfinx_mpc.git  
    cd dolfinx_mpc 
    git checkout V0.3.0
    cmake -G Ninja -DCMAKE_BUILD_TYPE=Developer -B build-dir cpp/ 
    ninja install -j12  -C build-dir
    pip3 install python/. --upgrade

Could you:

  1. print the output of:

and

  1. print the output of the command
    echo $PETSC_ARCH

Dear Sir,

I have the following out, and am not able to install dolfinx_mpc within dolfinx docker image,

root@2750005ee6cc:/mnt/dolfinx_mpc# cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -B build-dir cpp/
-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Asking Python module FFCX for location of UFC...
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.9.7", minimum required is "3") 
-- Found UFC: /usr/local/lib/python3.9/dist-packages/ffcx/codegeneration  
-- Found MPI_C: /usr/local/lib/libmpi.so (found version "4.0") 
-- Found MPI_CXX: /usr/local/lib/libmpicxx.so (found version "4.0") 
-- Found MPI: TRUE (found version "4.0")  
-- Found Boost 1.74.0 at /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0
--   Requested configuration: QUIET REQUIRED COMPONENTS timer;filesystem
-- Found boost_headers 1.74.0 at /usr/lib/x86_64-linux-gnu/cmake/boost_headers-1.74.0
-- Found boost_timer 1.74.0 at /usr/lib/x86_64-linux-gnu/cmake/boost_timer-1.74.0
--   [x] libboost_timer.so.1.74.0
--   [ ] libboost_timer.a
-- Adding boost_timer dependencies: chrono;headers
-- Found boost_chrono 1.74.0 at /usr/lib/x86_64-linux-gnu/cmake/boost_chrono-1.74.0
--   [x] libboost_chrono.so.1.74.0
--   [ ] libboost_chrono.a
-- Adding boost_chrono dependencies: headers
-- Found boost_filesystem 1.74.0 at /usr/lib/x86_64-linux-gnu/cmake/boost_filesystem-1.74.0
--   [x] libboost_filesystem.so.1.74.0
--   [ ] libboost_filesystem.a
-- Adding boost_filesystem dependencies: headers
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found suitable version "1.74.0", minimum required is "1.70") found components: timer filesystem 
-- Performing Test arch_native_supported
-- Performing Test arch_native_supported - Success
-- Found Python3: /usr/bin/python3.9 (found version "3.9.7") found components: Interpreter 
-- Adding /usr/local/lib/python3.9/dist-packages/basix to Basix search hints
-- HDF5: Using hdf5 compiler wrapper to determine C configuration
-- Found HDF5: /usr/local/lib/libhdf5.so;/usr/lib/x86_64-linux-gnu/libz.so;/usr/lib/x86_64-linux-gnu/libdl.a;/usr/lib/x86_64-linux-gnu/libm.so (found version "1.12.1") found components: C 
-- HDF5_DIR: HDF5_DIR-NOTFOUND
-- HDF5_DEFINITIONS: 
-- HDF5_INCLUDE_DIRS: /usr/local/include
-- HDF5_LIBRARIES: /usr/local/lib/libhdf5.so;/usr/lib/x86_64-linux-gnu/libz.so;/usr/lib/x86_64-linux-gnu/libdl.a;/usr/lib/x86_64-linux-gnu/libm.so
-- HDF5_HL_LIBRARIES: 
-- HDF5_C_DEFINITIONS: 
-- HDF5_C_INCLUDE_DIR: 
-- HDF5_C_INCLUDE_DIRS: /usr/local/include
-- HDF5_C_LIBRARY: 
-- HDF5_C_LIBRARIES: /usr/local/lib/libhdf5.so;/usr/lib/x86_64-linux-gnu/libz.so;/usr/lib/x86_64-linux-gnu/libdl.a;/usr/lib/x86_64-linux-gnu/libm.so
-- HDF5_C_HL_LIBRARY: 
-- HDF5_C_HL_LIBRARIES: 
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") 
-- Checking for one of the modules 'PETSc;petsc'
-- Checking for one of the modules 'SLEPc;slepc'
-- Found MPI_C: /usr/local/lib/libmpi.so (found suitable version "4.0", minimum required is "3") 
-- Found MPI_CXX: /usr/local/lib/libmpicxx.so (found suitable version "4.0", minimum required is "3") 
-- Found MPI: TRUE (found suitable version "4.0", minimum required is "3")  
-- Looking for PETSC_USE_COMPLEX
-- Looking for PETSC_USE_COMPLEX - not found
-- The following features have been enabled:

 * BUILD_SHARED_LIBS, Build DOLFINX_MPC with shared libraries.
 * CMAKE_INSTALL_RPATH_USE_LINK_PATH, Add paths to linker search and installed rpath.

-- The following OPTIONAL packages have been found:

 * Python3

-- The following REQUIRED packages have been found:

 * PythonInterp (required version >= 3)
 * boost_chrono (required version == 1.74.0)
 * boost_timer (required version == 1.74.0)
 * boost_headers (required version == 1.74.0)
 * boost_filesystem (required version == 1.74.0)
 * DOLFINX (required version >= 0.3.1.0), New generation Dynamic Object-oriented Library for - FINite element computation, <https://github.com/FEniCS/dolfinx>
   Main dependency of library
 * Basix (required version >= 0.3.1.0)
 * MPI (required version >= 3)
 * PkgConfig
 * PETSc, Portable, Extensible Toolkit for Scientific Computation (PETSc), <https://www.mcs.anl.gov/petsc/>
   PETSc linear algebra backend

-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/dolfinx_mpc/build-dir
root@2750005ee6cc:/mnt/dolfinx_mpc# ninja -j3 install -C build-dir
ninja: Entering directory `build-dir'
[1/11] Building CXX object CMakeFiles/dolfinx_mpc.dir/ContactConstraint.cpp.o
FAILED: CMakeFiles/dolfinx_mpc.dir/ContactConstraint.cpp.o 
/usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_CHRONO_DYN_LINK -DBOOST_TIMER_DYN_LINK -DDOLFINX_MPC_VERSION=\"0.3.1.0\" -DDOLFINX_VERSION=\"0.3.1.0\" -DHAS_ADIOS2 -DHAS_PTSCOTCH -DHAS_SLEPC -Ddolfinx_mpc_EXPORTS -I/mnt/dolfinx_mpc/cpp -I/mnt/dolfinx_mpc/cpp/dolfinx_mpc -isystem /usr/local/lib/python3.9/dist-packages/ffcx/codegeneration -isystem /usr/local/petsc/linux-gnu-real-32/include -isystem /usr/local/petsc/include -isystem /usr/local/dolfinx-real/include -isystem /usr/local/slepc/linux-gnu-real-32/include -isystem /usr/local/slepc/include -O3 -DNDEBUG -fPIC -std=c++17 -MD -MT CMakeFiles/dolfinx_mpc.dir/ContactConstraint.cpp.o -MF CMakeFiles/dolfinx_mpc.dir/ContactConstraint.cpp.o.d -o CMakeFiles/dolfinx_mpc.dir/ContactConstraint.cpp.o -c /mnt/dolfinx_mpc/cpp/ContactConstraint.cpp
/mnt/dolfinx_mpc/cpp/ContactConstraint.cpp: In function 'dolfinx_mpc::mpc_data dolfinx_mpc::create_contact_slip_condition(std::shared_ptr<dolfinx::fem::FunctionSpace>, dolfinx::mesh::MeshTags<int>, int32_t, int32_t, std::shared_ptr<dolfinx::fem::Function<double> >, double)':
/mnt/dolfinx_mpc/cpp/ContactConstraint.cpp:832:25: error: 'compute_graph_edges_nbx' is not a member of 'dolfinx::MPI'; did you mean 'compute_graph_edges'?
  832 |         = dolfinx::MPI::compute_graph_edges_nbx(MPI_COMM_WORLD, src_ranks);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~
      |                         compute_graph_edges
/mnt/dolfinx_mpc/cpp/ContactConstraint.cpp: In function 'dolfinx_mpc::mpc_data dolfinx_mpc::create_contact_inelastic_condition(std::shared_ptr<dolfinx::fem::FunctionSpace>, dolfinx::mesh::MeshTags<int>, int32_t, int32_t, double)':
/mnt/dolfinx_mpc/cpp/ContactConstraint.cpp:1179:25: error: 'compute_graph_edges_nbx' is not a member of 'dolfinx::MPI'; did you mean 'compute_graph_edges'?
 1179 |         = dolfinx::MPI::compute_graph_edges_nbx(MPI_COMM_WORLD, src_ranks);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~
      |                         compute_graph_edges
[3/11] Building CXX object CMakeFiles/dolfinx_mpc.dir/SlipConstraint.cpp.o
ninja: build stopped: subcommand failed.
root@2750005ee6cc:/mnt/dolfinx_mpc# 

Firstly, have you pulled the latest docker image by calling docker pull dolfinx/dolfinx before create your docker container?
Secondly,

Indicates that PETSC_ARCH is not set to linux-gnu-complex-32

Dear Sir,

Am able to successfully install the dolfinx_mpc library.
Thanks