summaryrefslogtreecommitdiff
path: root/gnu/packages/maths.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/maths.scm')
-rw-r--r--gnu/packages/maths.scm170
1 files changed, 169 insertions, 1 deletions
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index cc42ce7902..e64fc40929 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -45,7 +45,7 @@
;;; Copyright © 2021 Gerd Heber <gerd.heber@gmail.com>
;;; Copyright © 2021 Franck Pérignon <franck.perignon@univ-grenoble-alpes.fr>
;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com>
-;;; Copyright © 2021, 2022 Paul A. Patience <paul@apatience.com>
+;;; Copyright © 2021-2024 Paul A. Patience <paul@apatience.com>
;;; Copyright © 2021 Ivan Gankevich <i.gankevich@spbu.ru>
;;; Copyright © 2021 Jean-Baptiste Volatier <jbv@pm.me>
;;; Copyright © 2021, 2023 Guillaume Le Vaillant <glv@posteo.net>
@@ -152,6 +152,7 @@
#:use-module (gnu packages xorg)
#:use-module (gnu packages gl)
#:use-module (gnu packages imagemagick)
+ #:use-module (gnu packages libunwind)
#:use-module (gnu packages m4)
#:use-module (gnu packages mpi)
#:use-module (gnu packages multiprecision)
@@ -6896,6 +6897,173 @@ in finite element programs.")
(delete 'unset-cpath)))))
(synopsis "Finite element library (with MPI support)")))
+(define-public mfem
+ (package
+ (name "mfem")
+ (version "4.6")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/mfem/mfem")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0vr3s110bc42r81s1hi9brwwaz01d60l6mbdlsrfxxinpnzxq7ax"))
+ (patches (search-patches "mfem-remove-source-dir-refs.patch"
+ "mfem-fix-mk-file-export.patch"))))
+ (outputs '("out" "doc")) ; 338 MiB of documentation
+ (build-system cmake-build-system)
+ (arguments
+ (list #:configure-flags
+ ;; Follow order of config/defaults.mk, which has a more exhaustive
+ ;; list than config/defaults.cmake.
+ #~(list "-DBUILD_SHARED_LIBS=ON"
+ "-DMFEM_USE_MPI=OFF"
+ "-DMFEM_USE_METIS=OFF" ; MPI only
+ "-DMFEM_USE_METIS_5=OFF"
+ "-DMFEM_PRECISION=double" ; For versions beyond 4.6
+ "-DMFEM_DEBUG=OFF"
+ "-DMFEM_USE_EXCEPTIONS=ON"
+ "-DMFEM_USE_ZLIB=ON"
+ "-DMFEM_USE_LIBUNWIND=ON"
+ "-DMFEM_USE_LAPACK=ON"
+ "-DMFEM_THREAD_SAFE=OFF"
+ "-DMFEM_USE_OPENMP=ON"
+ "-DMFEM_USE_LEGACY_OPENMP=OFF"
+ "-DMFEM_USE_MEMALLOC=ON"
+ "-DMFEM_TIMER_TYPE=2"
+ "-DMFEM_USE_SUNDIALS=ON"
+ "-DMFEM_USE_SUITESPARSE=ON"
+ "-DMFEM_USE_SUPERLU=OFF" ; MPI only
+ "-DMFEM_USE_SUPERLU5=OFF"
+ "-DMFEM_USE_MUMPS=OFF" ; MPI only
+ "-DMFEM_USE_STRUMPACK=OFF" ; Missing dep, MPI only
+ "-DMFEM_USE_GINKGO=OFF" ; Missing dep
+ "-DMFEM_USE_AMGX=OFF" ; CUDA library
+ "-DMFEM_USE_GNUTLS=ON"
+ "-DMFEM_USE_NETCDF=ON"
+ "-DMFEM_USE_PETSC=OFF" ; MPI only
+ "-DMFEM_USE_SLEPC=OFF" ; MPI only
+ "-DMFEM_USE_MPFR=ON"
+ "-DMFEM_USE_SIDRE=OFF" ; Missing dep
+ "-DMFEM_USE_FMS=OFF" ; Missing dep
+ "-DMFEM_USE_CONDUIT=OFF" ; Missing dep
+ "-DMFEM_USE_PUMI=OFF" ; Missing dep, MPI only
+ "-DMFEM_USE_HIOP=OFF" ; Missing dep
+ "-DMFEM_USE_GSLIB=OFF" ; Missing dep
+ "-DMFEM_USE_CUDA=OFF"
+ "-DMFEM_USE_HIP=OFF" ; GPU library
+ "-DMFEM_USE_RAJA=OFF" ; Missing dep
+ "-DMFEM_USE_OCCA=OFF" ; Missing dep
+ "-DMFEM_USE_CEED=OFF" ; Missing dep
+ "-DMFEM_USE_CALIPER=OFF" ; Missing dep
+ "-DMFEM_USE_ALGOIM=OFF" ; Missing dep
+ "-DMFEM_USE_UMPIRE=OFF" ; Missing dep
+ "-DMFEM_USE_SIMD=ON"
+ "-DMFEM_USE_ADIOS2=OFF" ; Missing dep
+ "-DMFEM_USE_MKL_CPARDISO=OFF" ; Intel MKL
+ "-DMFEM_USE_MKL_PARDISO=OFF"
+ "-DMFEM_USE_MOONOLITH=OFF" ; Missing dep
+ "-DMFEM_USE_ADFORWARD=OFF"
+ "-DMFEM_USE_CODIPACK=OFF" ; Missing dep
+ "-DMFEM_USE_BENCHMARK=OFF" ; Only for benchmarks
+ "-DMFEM_USE_PARELAG=OFF" ; Missing dep, only for miniapps
+ "-DMFEM_USE_ENZYME=OFF" ; Missing dep, requires Clang
+ "-DMFEM_ENABLE_TESTING=ON"
+ "-DMFEM_ENABLE_EXAMPLES=ON"
+ "-DMFEM_ENABLE_MINIAPPS=ON" ; Used in some tests
+ "-DMFEM_ENABLE_GOOGLE_BENCHMARKS=OFF"
+ (string-append "-DHDF5_DIR=" #$(this-package-input "hdf5")))
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'clean-mpi-references
+ (lambda _
+ (substitute* "config/config.mk.in"
+ (("(MFEM_MPIEXEC += ).*" _ prefix)
+ ;; Set to non-empty value, to avoid running unexpected
+ ;; commands.
+ (string-append prefix (which "false") "\n"))
+ (("(MFEM_MPIEXEC_NP +=).*" _ prefix)
+ (string-append prefix "\n"))
+ (("(MFEM_MPI_NP +=).*" _ prefix)
+ (string-append prefix "\n")))))
+ (add-after 'unpack 'clean-local-references
+ (lambda _
+ (substitute* "config/config.mk.in"
+ (("(MFEM_BUILD_TAG += ).*" _ prefix)
+ (string-append prefix "(none)\n")))))
+ (add-before 'check 'build-tests
+ (lambda _
+ (invoke "cmake" "--build" "." "--target" "tests")))
+ (add-after 'check 'build-doc
+ (lambda _
+ (setenv "HOME" "/tmp") ; Writable cache for fontconfig
+ (invoke "cmake" "--build" "." "--target" "doc")))
+ (add-after 'install 'remove-examples
+ (lambda _
+ (delete-file-recursively
+ (string-append #$output "/examples"))))
+ (add-after 'install 'install-doc
+ (lambda _
+ (let ((docdir (string-append #$output:doc "/share/doc/"
+ #$name "-" #$version)))
+ (install-file "doc/CodeDocumentation.html" docdir)
+ (copy-recursively
+ "doc/CodeDocumentation"
+ (string-append docdir "/CodeDocumentation")))))
+ (add-after 'install 'fix-library-paths
+ (let ((mpfr #$(this-package-input "mpfr"))
+ (libunwind #$(this-package-input "libunwind")))
+ (lambda _
+ (substitute* (string-append
+ #$output "/lib/cmake/mfem/MFEMTargets.cmake")
+ ((";mpfr;")
+ (string-append ";" mpfr "/lib/libmpfr.so;"))
+ ((";unwind;")
+ (string-append ";" libunwind "/lib/libunwind.so;")))
+ (substitute* (string-append #$output "/share/mfem/config.mk")
+ ((" mpfr ")
+ (string-append " -Wl,-rpath," mpfr "/lib"
+ " -L" mpfr "/lib"
+ " -lmpfr "))
+ ((" unwind ")
+ (string-append " -Wl,-rpath," libunwind "/lib"
+ " -L" libunwind "/lib"
+ " -lunwind ")))))))))
+ (native-inputs
+ (list doxygen graphviz perl)) ; For documentation
+ ;; No propagated inputs necessary because the installed CMake files and
+ ;; share/mfem/config.mk provide the full list of include directories.
+ (inputs
+ (list gnutls
+ hdf5 ; For NetCDF
+ lapack
+ libunwind
+ metis-suitesparse ; For SuiteSparse
+ mpfr
+ netcdf
+ suitesparse-amd
+ suitesparse-btf
+ suitesparse-camd
+ suitesparse-ccolamd
+ suitesparse-cholmod
+ suitesparse-colamd
+ suitesparse-config
+ suitesparse-klu
+ suitesparse-umfpack
+ sundials
+ zlib))
+ ;; TODO: Enable MFEM_USE_SIMD only if tuned?
+ (properties '((tunable? . #t)))
+ (home-page "https://mfem.org/")
+ (synopsis "Finite element library")
+ (description "MFEM is a modular parallel C++ library for finite element
+methods. Its goal is to enable high-performance scalable finite element
+discretization research and application development on a wide variety of
+platforms, ranging from laptops to supercomputers.")
+ (license license:bsd-3)))
+
(define-public flann
(package
(name "flann")