Skip to content
Snippets Groups Projects
Commit b0756c39 authored by Lars Bilke's avatar Lars Bilke
Browse files

Merge branch 'fix-install-petsc-vtk' into 'master'

Fix install petsc vtk, fix vtkXMLPUnstructuredGridWriter usage & more

Closes #3354

See merge request ogs/ogs!4427
parents f57959ea 9a17b519
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,7 @@ target_link_libraries(
VTK::IOLegacy
range-v3
$<$<TARGET_EXISTS:VTK::IOParallelXML>:VTK::IOParallelXML>
$<$<TARGET_EXISTS:VTK::ParallelMPI>:VTK::ParallelMPI>
$<$<TARGET_EXISTS:MPI::MPI_CXX>:MPI::MPI_CXX>
$<$<TARGET_EXISTS:petsc>:petsc>
PRIVATE nlohmann_json::nlohmann_json
......@@ -55,5 +56,12 @@ target_compile_definitions(
$<$<AND:$<BOOL:$ENV{VTK_USE_64BIT_IDS}>,$<NOT:$<BOOL:VTK_ADDED>>>:VTK_USE_64BIT_IDS>
)
target_precompile_headers(MeshLib PRIVATE [["BaseLib/Error.h"]]
[["BaseLib/ConfigTree.h"]] [["BaseLib/Logging.h"]] Elements/Element.h <Eigen/Core>)
target_precompile_headers(
MeshLib
PRIVATE
[["BaseLib/Error.h"]]
[["BaseLib/ConfigTree.h"]]
[["BaseLib/Logging.h"]]
Elements/Element.h
<Eigen/Core>
)
......@@ -26,6 +26,9 @@
#ifdef USE_PETSC
#include <mpi.h>
#include <vtkMPI.h>
#include <vtkMPICommunicator.h>
#include <vtkMPIController.h>
#endif
class vtkXMLPUnstructuredGridWriter;
......@@ -79,14 +82,29 @@ bool VtuInterface::writeVTU(std::string const& file_name,
vtuWriter->SetFileName(file_name.c_str());
#ifdef USE_PETSC
if constexpr (std::is_same_v<UnstructuredGridWriter,
vtkXMLPUnstructuredGridWriter>)
{
// Set the writer controller to same communicator as OGS
vtkSmartPointer<vtkMPICommunicator> vtk_comm =
vtkSmartPointer<vtkMPICommunicator>::New();
MPI_Comm mpi_comm = MPI_COMM_WORLD;
vtkMPICommunicatorOpaqueComm vtk_opaque_comm(&mpi_comm);
vtk_comm->InitializeExternal(&vtk_opaque_comm);
vtkSmartPointer<vtkMPIController> vtk_mpi_ctrl =
vtkSmartPointer<vtkMPIController>::New();
vtk_mpi_ctrl->SetCommunicator(vtk_comm);
vtuWriter->SetController(vtk_mpi_ctrl);
vtuWriter->SetGhostLevel(1);
vtuWriter->SetNumberOfPieces(num_partitions);
vtuWriter->SetStartPiece(rank);
vtuWriter->SetEndPiece(rank);
}
#endif
#ifdef VTK_USE_64BIT_IDS
vtuWriter->SetHeaderTypeToUInt64();
......
......@@ -10,6 +10,12 @@ set(OGS_EXTERNAL_DEPENDENCIES_CACHE ""
CACHE PATH "Directory containing source archives of external dependencies."
)
if(CCACHE_EXECUTABLE)
set(_defaultCMakeArgs "-DCMAKE_C_COMPILER_LAUNCHER=${CCACHE_EXECUTABLE}"
"-DCMAKE_CXX_COMPILER_LAUNCHER=${CCACHE_EXECUTABLE}"
)
endif()
if(OGS_USE_MFRONT)
option(OGS_BUILD_TFEL
"Build TFEL locally. Needs to be set with a clean cache!" OFF
......@@ -44,13 +50,13 @@ if(OGS_USE_MFRONT)
"-DBUILD_SHARED_LIBS=OFF"
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
"-Denable-testing=OFF"
${_defaultCMakeArgs}
)
message(
STATUS
"ExternalProject_Add(): added package TFEL@rliv-${ogs.minimum_version.tfel-rliv}"
)
set(TFELHOME ${PROJECT_BINARY_DIR}/_ext/TFEL CACHE PATH "" FORCE)
set(_EXT_LIBS ${_EXT_LIBS} TFEL CACHE INTERNAL "")
endif()
endif()
......@@ -174,8 +180,8 @@ elseif(NOT OGS_BUILD_ZLIB)
endif()
if(NOT ZLIB_FOUND)
BuildExternalProject(
ZLIB ${_zlib_source}
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
ZLIB ${_zlib_source} CMAKE_ARGS "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
${_defaultCMakeArgs}
)
message(
STATUS
......@@ -235,12 +241,13 @@ elseif(NOT OGS_BUILD_HDF5)
find_package(HDF5 ${ogs.minimum_version.hdf5})
endif()
if(NOT HDF5_FOUND)
BuildExternalProject(HDF5 ${_hdf5_source} CMAKE_ARGS ${_hdf5_options})
BuildExternalProject(
HDF5 ${_hdf5_source} CMAKE_ARGS ${_hdf5_options} ${_defaultCMakeArgs}
)
message(
STATUS
"ExternalProject_Add(): added package HDF5@${ogs.tested_version.hdf5}"
)
set(_EXT_LIBS ${_EXT_LIBS} HDF5 CACHE INTERNAL "")
BuildExternalProject_find_package(HDF5)
endif()
......@@ -269,9 +276,8 @@ foreach(option_index ${ogs.libraries.vtk.options})
endforeach()
list(REMOVE_DUPLICATES VTK_OPTIONS)
# Setting shared libs on PETSc, otherwise pvtu files only contain one
# <Piece>-element (one subdomain).
list(APPEND VTK_OPTIONS "-DBUILD_SHARED_LIBS=${OGS_USE_PETSC}"
# Setting static libs for easier packaging.
list(APPEND VTK_OPTIONS "-DBUILD_SHARED_LIBS=OFF"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
)
message(STATUS "VTK_OPTIONS: ${VTK_OPTIONS}")
......@@ -313,13 +319,13 @@ if(NOT VTK_FOUND)
)
endif()
BuildExternalProject(
VTK ${_vtk_source} CMAKE_ARGS ${VTK_OPTIONS} ${_loguru_patch}
VTK ${_vtk_source} CMAKE_ARGS ${VTK_OPTIONS} ${_defaultCMakeArgs}
${_loguru_patch}
)
message(
STATUS
"ExternalProject_Add(): added package VTK@${ogs.minimum_version.vtk}"
)
set(_EXT_LIBS ${_EXT_LIBS} VTK CACHE INTERNAL "")
BuildExternalProject_find_package(VTK)
endif()
......
......@@ -17,7 +17,15 @@ if(OGS_USE_PIP)
${PROJECT_SOURCE_DIR}/scripts/cmake/PythonCreateVirtualEnv.cmake
WORKING_DIRECTORY ${PROJECT_BINARY_DIR} COMMAND_ECHO STDOUT
ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE
RESULT_VARIABLE _return_code
)
if(NOT ${_return_code} EQUAL 0)
message(
FATAL_ERROR
"Creation of Python virtual environment failed!\n"
"To disable virtual environments set OGS_USE_PIP=OFF."
)
endif()
unset(_OGS_PYTHON_PACKAGES_SHA1 CACHE)
endif()
set(_venv_bin_dir "bin")
......
......@@ -8,6 +8,7 @@ else()
set(INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
endif()
list(JOIN CMAKE_INSTALL_RPATH ":" _rpath)
install(CODE "set(CMAKE_BUILD_RPATH \"${CMAKE_BUILD_RPATH}\")")
install(CODE "set(INSTALL_DIR \"${INSTALL_DIR}\")")
install(CODE "set(CMAKE_INSTALL_LIBDIR \"${CMAKE_INSTALL_LIBDIR}\")")
......@@ -27,7 +28,10 @@ install(
$<$<TARGET_EXISTS:DataExplorer>:$<TARGET_FILE:DataExplorer>>
$<$<TARGET_EXISTS:testrunner>:$<TARGET_FILE:testrunner>>
$<$<TARGET_EXISTS:RemoveGhostData>:$<TARGET_FILE:RemoveGhostData>>
DIRECTORIES ${MKL_ROOT_DIR}/redist/intel64 ${MKL_ROOT_DIR}/../../tbb/latest/redist/intel64/vc_mt
DIRECTORIES
${MKL_ROOT_DIR}/redist/intel64
${MKL_ROOT_DIR}/../../tbb/latest/redist/intel64/vc_mt
${CMAKE_BUILD_RPATH}
RESOLVED_DEPENDENCIES_VAR _r_deps
UNRESOLVED_DEPENDENCIES_VAR _u_deps
PRE_EXCLUDE_REGEXES "api-ms-" "ext-ms-" ${OGS_INSTALL_DEPENDENCIES_PRE_EXCLUDES}
......@@ -36,10 +40,10 @@ install(
find_program(PATCHELF_TOOL patchelf)
foreach(_lib ${_r_deps})
string(REGEX MATCH "libpetsc.*" _petsc_lib ${_lib})
if(_petsc_lib AND EXISTS _ext/PETSc/lib/${_petsc_lib})
if(_petsc_lib AND EXISTS _ext/PETSc/lib/${_petsc_lib} AND NOT APPLE)
if(PATCHELF_TOOL)
execute_process(COMMAND patchelf --set-rpath ${_rpath} _ext/PETSc/lib/${_petsc_lib} COMMAND_ERROR_IS_FATAL ANY)
message(STATUS "Patching RPATH of ${_petsc_lib} -> ${_rpath}")
execute_process(COMMAND patchelf --set-rpath ${_rpath} _ext/PETSc/lib/${_petsc_lib} COMMAND_ERROR_IS_FATAL ANY)
else()
message(WARNING "patchelf tool not found: installed ogs binaries may not work (error: shared libraries not found)! "
"Install the patchelf tool for proper runtime library search paths!")
......
......@@ -52,7 +52,7 @@ Please note that the PETSc package is preferred to build in release model regard
PESTSc is recommended to use on Linux. On Windows, it only runs on
UNIX emulator Cygwin. A detailed description about how to use PETSc on Windows
is available on this PETSc site: <https://petsc.org/main/install/windows/>.
is available on this PETSc site: <https://petsc.org/release/install/windows/>.
One the frontends of EVE cluster of UFZ, your can load specified MPI, PETSc and
other modules by command:
......
......@@ -93,7 +93,7 @@ The above example shows that once a prefix is given for PETSc linear solver
above example, `-`, is replaced with `-T_` and `-H_`, respectively.
A introduction and a list of PETSc KSP solvers and preconditioners can be found by
[this link](https://petsc.org/main/docs/manual/ksp/).
[this link](https://petsc.org/release/docs/manual/ksp/).
### 2. Launch MPI OGS
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment