Commit e3b58a6b authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Merge branch 'JK/hypre' into 'develop'

Hypre wrappers

See merge request !136
parents caf095a8 ecb421e8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2123,6 +2123,7 @@ INCLUDE_FILE_PATTERNS =
PREDEFINED = DOXYGEN_ONLY
PREDEFINED += HAVE_MPI
PREDEFINED += HAVE_CUDA
PREDEFINED += HAVE_HYPRE

# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
+5 −0
Original line number Diff line number Diff line
@@ -178,6 +178,11 @@ computing platform, and (optionally) some libraries.
      <td> </td>
      <td> Only used for the compilation of the `tnl-decompose-mesh` tool. </td>
  </tr>
  <tr><td> [Hypre](https://github.com/hypre-space/hypre) </td>
      <td> \ref Hypre "Wrappers for Hypre solvers" </td>
      <td> `-DHAVE_HYPRE -lHYPRE` </td>
      <td> Attention should be paid to Hypre build options, e.g. `--enable-bigint`. </td>
  </tr>
  <tr><td> [libpng](http://www.libpng.org/pub/png/libpng.html) </td>
      <td> \ref TNL::Images "Image processing" classes </td>
      <td> `-DHAVE_PNG_H -lpng` </td>

cmake/FindHypre.cmake

0 → 100644
+78 −0
Original line number Diff line number Diff line
################################################################################
#
# \file      FindHypre.cmake
# \copyright 2012-2015 J. Bakosi,
#            2016-2018 Los Alamos National Security, LLC.,
#            2019-2021 Triad National Security, LLC.
#            All rights reserved. See the LICENSE file for details.
# \brief     Find the Hypre library from LLNL
#
################################################################################

# Hypre: https://github.com/LLNL/hypre
#
#  HYPRE_FOUND - System has Hypre
#  HYPRE_INCLUDE_DIRS - The Hypre include directory
#  HYPRE_LIBRARIES - The libraries needed to use Hypre
#
#  Set HYPRE_ROOT before calling find_package to a path to add an additional
#  search path, e.g.,
#
#  Usage:
#
#  set(HYPRE_ROOT "/path/to/custom/hypre") # prefer over system
#  find_package(Hypre)
#  if(HYPRE_FOUND)
#    target_link_libraries (TARGET ${HYPRE_LIBRARIES})
#  endif()

function(_HYPRE_GET_VERSION _OUT_ver _version_hdr)
  file(STRINGS ${_version_hdr} _contents REGEX "#define HYPRE_RELEASE_VERSION[ \t]+")
  if(_contents)
    string(REGEX REPLACE "\"" "" _cont "${_contents}")
    string(REGEX REPLACE ".*#define HYPRE_RELEASE_VERSION[ \t]+([0-9.]+).*" "\\1" ${_OUT_ver} "${_cont}")
    if(NOT ${${_OUT_ver}} MATCHES "[0-9]+")
        message(FATAL_ERROR "Version parsing failed for HYPRE_RELEASE_VERSION in ${_version_hdr}!")
    endif()
    set(${_OUT_ver} ${${_OUT_ver}} PARENT_SCOPE)
 elseif(EXISTS ${_version_hdr})
    message(FATAL_ERROR "No HYPRE_RELEASE_VERSION in ${_version_hdr}")
 else()
    message(FATAL_ERROR "Include file ${_version_hdr} does not exist")
  endif()
endfunction()

# If already in cache, be silent
if(HYPRE_INCLUDE_DIRS AND HYPRE_LIBRARIES)
  set (HYPRE_FIND_QUIETLY TRUE)
endif()

if (HYPRE_ROOT)
  set(HYPRE_SEARCH_OPTS NO_DEFAULT_PATH)
else()
  set(HYPRE_ROOT "/usr")
endif()

find_path(HYPRE_INCLUDE_DIR NAMES HYPRE.h
                            PATH_SUFFIXES hypre
                            HINTS ${HYPRE_ROOT}/include ${HYPRE_ROOT}/include/hypre
                            ${HYPRE_SEARCH_OPTS})

if(HYPRE_INCLUDE_DIR)
  _HYPRE_GET_VERSION(HYPRE_VERSION ${HYPRE_INCLUDE_DIR}/HYPRE_config.h)
  set(HYPRE_INCLUDE_DIRS ${HYPRE_INCLUDE_DIR})
else()
  set(HYPRE_VERSION 0.0.0)
  set(HYPRE_INCLUDE_DIRS "")
endif()

find_library(HYPRE_LIBRARY NAMES HYPRE HINTS ${HYPRE_ROOT}/lib)

set(HYPRE_LIBRARIES ${HYPRE_LIBRARY})

# Handle the QUIETLY and REQUIRED arguments and set HYPRE_FOUND to TRUE if
# all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Hypre REQUIRED_VARS HYPRE_LIBRARIES HYPRE_INCLUDE_DIRS VERSION_VAR HYPRE_VERSION)

MARK_AS_ADVANCED(HYPRE_INCLUDE_DIRS HYPRE_LIBRARIES)
+2 −0
Original line number Diff line number Diff line
add_subdirectory( Hypre )

#add_subdirectory( simple-examples )
#add_subdirectory( Hamilton-Jacobi )
#add_subdirectory( heat-equation )
+13 −0
Original line number Diff line number Diff line
if( ${BUILD_MPI} )
   find_package(Hypre)
   if( ${HYPRE_FOUND} )
      foreach( source IN ITEMS hypre-ex5.c tnl-hypre-ex5.cpp )
         string( REGEX REPLACE "\.cpp|\.c" "" target ${source} )
         add_executable( ${target} ${source} )
         target_compile_definitions( ${target} PUBLIC "-DHAVE_HYPRE" )
         target_include_directories( ${target} PUBLIC ${HYPRE_INCLUDE_DIRS} )
         target_link_libraries( ${target} ${HYPRE_LIBRARIES} -lm )
         install( TARGETS ${target} RUNTIME DESTINATION bin )
      endforeach()
   endif()
endif()
Loading