]> SALOME platform Git repositories - tools/solverlab.git/commitdiff
Salome HOME
Improved mpi4py petsc4py and slepc4py variables
authormichael <michael@localhost.localdomain>
Thu, 13 Jan 2022 17:36:29 +0000 (18:36 +0100)
committermichael <michael@localhost.localdomain>
Thu, 13 Jan 2022 17:36:29 +0000 (18:36 +0100)
CMakeLists.txt
CoreFlows/swig/CMakeLists.txt
CoreFlows/swig/CoreFlows.i

index 613630709e383364d58fa52cbb1e07f62b121de9..5d4db933632df6a244f260e57bae6af0c181c37a 100644 (file)
@@ -57,16 +57,12 @@ include(ExternalProject)#For PETSc, MED and MEDCoupling
 list (APPEND CMAKE_MODULE_PATH "${SOLVERLAB_SOURCE_DIR}/cmake_files")
 
 
-#####################
-# Detection of MPI  #
-#####################
-if   ( DEFINED ENV{MPI_ROOT_DIR} OR DEFINED MPI_ROOT_DIR )
-  if   ( DEFINED  ENV{MPI_ROOT_DIR} )
-    set(MPI_HOME $ENV{MPI_ROOT_DIR})
-  else ( DEFINED  ENV{MPI_ROOT_DIR} )
-    set(MPI_HOME    ${MPI_ROOT_DIR})
-  endif( DEFINED  ENV{MPI_ROOT_DIR} )
-endif( DEFINED ENV{MPI_ROOT_DIR} OR DEFINED MPI_ROOT_DIR )
+#############################
+# Detection of MPI + MPI4PY #
+#############################
+if   ( DEFINED MPI_ROOT_DIR )
+  set(MPI_HOME    ${MPI_ROOT_DIR})
+endif( DEFINED MPI_ROOT_DIR )
 
 # Definition of SOLVERLAB_WITH_MPI
 if(    DEFINED ENV{MPI_HOME} OR MPI_HOME )
@@ -80,7 +76,7 @@ else(  DEFINED ENV{MPI_HOME} OR MPI_HOME )
   set(SOLVERLAB_WITH_MPI OFF)
 endif( DEFINED ENV{MPI_HOME} OR MPI_HOME )
 
-# Definition of MPI4PY_ROOT_DIR
+# Definition of MPI4PY_ROOT_DIR from either the environment or petsc
 if(   ${SOLVERLAB_WITH_PYTHON} AND ${SOLVERLAB_WITH_MPI} AND NOT ${MPI4PY_ROOT_DIR})
   message(STATUS "Defining MPI4PY directory" )
   if(    DEFINED ENV{MPI4PY_ROOT_DIR})
@@ -92,7 +88,7 @@ endif(${SOLVERLAB_WITH_PYTHON} AND ${SOLVERLAB_WITH_MPI} AND NOT ${MPI4PY_ROOT_D
 
 if(    MPI4PY_ROOT_DIR)
   message(STATUS "MPI4PY directory is ${MPI4PY_ROOT_DIR}" )
-  SET(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -DMPI4PY_ROOT_DIR=${MPI4PY_ROOT_DIR})
+  SET(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -DMPI4PY_ROOT_DIR=${MPI4PY_ROOT_DIR})#Necessary for swig generation of mpi structures
 endif( MPI4PY_ROOT_DIR)
 
 ############################
@@ -347,13 +343,6 @@ endif( DEFINED ENV{HDF5_ROOT_DIR} OR DEFINED HDF5_ROOT_DIR )
       set(HDF5_LIBRARY_DIR ${HDF5_ROOT}/lib)
       set(HDF5_INCLUDE_DIRS ${HDF5_ROOT}/include)
 
-      #define MPI variables
-      #set(SOLVERLAB_WITH_MPI ON)
-      #set(MPI_HOME    ${PETSC_INSTALL} )
-      #set(MPI_LIBRARY ${PETSC_INSTALL}/lib/libmpi.so)
-      #set(MPIEXEC     ${PETSC_INSTALL}/bin/mpiexec)
-      #set(MPI4PY_ROOT_DIR    ${PETSC_INSTALL}/lib/mpi4py )
-
     endif ( IS_DIRECTORY "/usr/include/petsc/" AND EXISTS "/usr/lib64/libpetsc.so" )
   endif ( DEFINED ENV{PETSC_DIR} OR PETSC_DIR )
 
@@ -361,6 +350,11 @@ if   ( ${PETSC_VERSION} VERSION_GREATER 3.5 )
   add_definitions(-DPETSC_VERSION_GREATER_3_5)
 endif( ${PETSC_VERSION} VERSION_GREATER 3.5 )
 
+if   ( ${SOLVERLAB_WITH_PYTHON} )
+  set(SLEPC4PY_ROOT_DIR ${PETSC_DIR}/${PETSC_ARCH}/lib/slepc4py)# or use FindSLEPC4PY
+  set(PETSC4PY_ROOT_DIR ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc4py)# or use FindPETSC4PY
+endif( ${SOLVERLAB_WITH_PYTHON} )
+
 string(REPLACE ";" ":"  PETSC_INCLUDES_INSTALL "${PETSC_INCLUDES}")# use colon instead of semicolon in environment file env_SOLVERLAB.sh
 
 add_library(petsc   SHARED IMPORTED)
index e78beb490114a26d45416a8b1a0da263d8509115..ad245967fe40f47272e0c2213b9073410ce8b01b 100755 (executable)
@@ -18,14 +18,30 @@ IF(    ${SOLVERLAB_WITH_MPI} )
     ${PETSC_INCLUDES}
     ${SLEPC_INCLUDES}
   ) 
+
+  if(EXISTS ${MPI4PY_ROOT_DIR}/mpi4py/include/mpi4py/mpi4py.i)
+    INCLUDE_DIRECTORIES( ${MPI4PY_ROOT_DIR}/mpi4py/include
+                         ${MPI4PY_ROOT_DIR}/mpi4py/include/mpi4py )
+  elseif (EXISTS ${MPI4PY_ROOT_DIR}/include/mpi4py/mpi4py.i )
+    INCLUDE_DIRECTORIES( ${MPI4PY_ROOT_DIR}/include
+                         ${MPI4PY_ROOT_DIR}/include/mpi4py )
+  endif()
 ENDIF( ${SOLVERLAB_WITH_MPI} )
 
-if(EXISTS ${MPI4PY_ROOT_DIR}/mpi4py/include/mpi4py/mpi4py.i)
-  INCLUDE_DIRECTORIES( ${MPI4PY_ROOT_DIR}/mpi4py/include
-                       ${MPI4PY_ROOT_DIR}/mpi4py/include/mpi4py )
-elseif (EXISTS ${MPI4PY_ROOT_DIR}/include/mpi4py/mpi4py.i )
-  INCLUDE_DIRECTORIES( ${MPI4PY_ROOT_DIR}/include
-                       ${MPI4PY_ROOT_DIR}/include/mpi4py )
+if(EXISTS ${PETSC4PY_ROOT_DIR}/petsc4py/include/petsc4py/petsc4py.i)
+  INCLUDE_DIRECTORIES( ${PETSC4PY_ROOT_DIR}/petsc4py/include
+                       ${PETSC4PY_ROOT_DIR}/petsc4py/include/petsc4py )
+elseif (EXISTS ${PETSC4PY_ROOT_DIR}/include/petsc4py/petsc4py.i )
+  INCLUDE_DIRECTORIES( ${PETSC4PY_ROOT_DIR}/include
+                       ${PETSC4PY_ROOT_DIR}/include/petsc4py )
+endif()
+
+if(EXISTS ${SLEPC4PY_ROOT_DIR}/slepc4py/include/slepc4py/slepc4py.i)
+  INCLUDE_DIRECTORIES( ${SLEPC4PY_ROOT_DIR}/slepc4py/include
+                       ${SLEPC4PY_ROOT_DIR}/slepc4py/include/slepc4py )
+elseif (EXISTS ${SLEPC4PY_ROOT_DIR}/include/slepc4py/slepc4py.i )
+  INCLUDE_DIRECTORIES( ${SLEPC4PY_ROOT_DIR}/include
+                       ${SLEPC4PY_ROOT_DIR}/include/slepc4py )
 endif()
 
 IF   (${CMAKE_VERSION} VERSION_LESS "3.8.0") 
index e426b486631b7eacc7658861f1e43b2cff9ef170..4216f8ad000a8656dde60c5202892cda5ef4d8ad 100755 (executable)
@@ -4,6 +4,8 @@
 %include std_vector.i
 %include std_map.i
 
+%include slepc4py.i
+
 #ifdef MPI4PY_ROOT_DIR
 %include mpi4py.i
 %mpi4py_typemap(Comm, MPI_Comm);