gnu: Add array-operations.
[jackhill/guix/guix.git] / gnu / packages / simulation.scm
index 6144e23..45efd5c 100644 (file)
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2017, 2018 Paul Garlick <pgarlick@tourbillion-technology.com>
+;;; Copyright © 2017, 2018, 2019, 2020 Paul Garlick <pgarlick@tourbillion-technology.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,6 +19,7 @@
 (define-module (gnu packages simulation)
   #:use-module (gnu packages)
   #:use-module (gnu packages algebra)
+  #:use-module (gnu packages admin)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages readline)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages version-control)
   #:use-module (gnu packages xml)
   #:use-module (gnu packages xorg)
   #:use-module (guix download)
-  #:use-module (guix build utils)
+  #:use-module (guix svn-download)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
        (file-name (string-append name "-" version ".tar.gz"))
        (sha256
         (base32 "0cgxh4h2hf50qbvvdg5miwc2nympb0nrv3md96vb3gbs9vk8vq9d"))
-       (patches (search-patches "openfoam-4.1-cleanup.patch"))))
+       (patches (search-patches "openfoam-4.1-cleanup.patch"))
+       (modules '((guix build utils)))
+       (snippet
+        '(begin
+           ;; Include <sys/sysmacros.h>, which is where glibc >= 2.28 provides
+           ;; 'major' and 'minor'.
+           (substitute* "src/OSspecific/POSIX/fileStat.C"
+             (("#include <unistd\\.h>")
+              "#include <unistd.h>\n#include <sys/sysmacros.h>\n"))
+           #t))))
     (build-system gnu-build-system)
     (inputs
      `(("boost" ,boost)
@@ -232,14 +243,14 @@ problems for efficient solution on parallel systems.")
 (define-public python-fenics-dijitso
   (package
     (name "python-fenics-dijitso")
-    (version "2018.1.0")
+    (version "2019.1.0")
     (source
       (origin
         (method url-fetch)
         (uri (pypi-uri "fenics-dijitso" version))
         (sha256
           (base32
-            "1qax2f52qsjbd1h5lk5i5shp448qlakxabjjybrfc1w823p0yql9"))))
+            "0lhqsq8ypdak0ahr2jnyvg07yrqp6wicjxi6k56zx24wp3qg60sc"))))
     (build-system python-build-system)
     (inputs
      `(("openmpi" ,openmpi)
@@ -259,6 +270,11 @@ problems for efficient solution on parallel systems.")
              (setenv "PYTHONPATH"
                      (string-append (getcwd) ":" (getenv "PYTHONPATH")))
              (with-directory-excursion "test"
+               ;; Disable parallel tests to avoid race condition.  See
+               ;; https://github.com/pytest-dev/pytest-cov/issues/237.
+               (substitute* "runtests.sh"
+                 (("for p in 1 4 8 16; do")
+                  "for p in 1; do"))
                (invoke "./runtests.sh"))
              #t)))))
     (home-page "https://bitbucket.org/fenics-project/dijitso/")
@@ -278,14 +294,14 @@ the complexity of that interface.  Parallel support depends on the
 (define-public python-fenics-ufl
   (package
     (name "python-fenics-ufl")
-    (version "2018.1.0")
+    (version "2019.1.0")
     (source
       (origin
         (method url-fetch)
         (uri (pypi-uri "fenics-ufl" version))
         (sha256
           (base32
-            "1fq8yc86s1s3c8c0b1rc2vf265q0hrkzg57100fg1nghcz0p4vla"))))
+            "10dz8x3lm68x2w3kkqcjask38h0zkhhak26jdbkppr8g9y8wny7p"))))
     (build-system python-build-system)
     (inputs
      `(("python-numpy" ,python-numpy)))
@@ -315,14 +331,14 @@ UFL is part of the FEniCS Project.")
 (define-public python-fenics-fiat
   (package
     (name "python-fenics-fiat")
-    (version "2018.1.0")
+    (version "2019.1.0")
     (source
       (origin
         (method url-fetch)
         (uri (pypi-uri "fenics-fiat" version))
         (sha256
           (base32
-            "0fmjd93r6bwf6xs8csw86qzphrnr66xwv7f372w59gmq8mg6rljc"))))
+            "13sc7lma3d2mh43an7i4kkdbbk4cmvxjk45wi43xnjd7qc38zg4b"))))
     (build-system python-build-system)
     (native-inputs
      `(("python-pytest" ,python-pytest)))
@@ -337,7 +353,15 @@ UFL is part of the FEniCS Project.")
              (setenv "PYTHONPATH"
                      (string-append (getcwd) ":" (getenv "PYTHONPATH")))
              (with-directory-excursion "test"
-               (invoke "py.test" "unit/"))
+               ;; FIXME: three FIAT test modules are known to fail
+               ;; with recent versions of pytest (>= 4).  These are
+               ;; skipped for FIAT version 2019.1.0 pending an
+               ;; upstream pull request. For details see request #59
+               ;; at https://bitbucket.org/fenics-project/fiat/.
+               (invoke "py.test" "unit/"
+                       "--ignore=unit/test_fiat.py"
+                       "--ignore=unit/test_quadrature.py"
+                       "--ignore=unit/test_reference_element.py"))
              #t)))))
     (home-page "https://bitbucket.org/fenics-project/fiat/")
     (synopsis "Tabulation of finite element function spaces")
@@ -357,14 +381,14 @@ FIAT is part of the FEniCS Project.")
 (define-public python-fenics-ffc
   (package
     (name "python-fenics-ffc")
-    (version "2018.1.0")
+    (version "2019.1.0.post0")
     (source
       (origin
         (method url-fetch)
         (uri (pypi-uri "fenics-ffc" version))
         (sha256
           (base32
-            "1b2ia5vlkw298x7rf0k2p3ihlpwkwgc98p3s6sbpds3hqmfrzdz9"))))
+            "1f2a44ha65fg3a1prrbrsz4dgvibsv0j5c3pi2m52zi93bhwwgg9"))))
     (build-system python-build-system)
     (native-inputs
      `(("python-pytest" ,python-pytest)))
@@ -409,7 +433,7 @@ FFC is part of the FEniCS Project.")
 (define-public fenics-dolfin
   (package
     (name "fenics-dolfin")
-    (version "2018.1.0.post1")
+    (version "2019.1.0.post0")
     (source
       (origin
         (method url-fetch)
@@ -419,7 +443,7 @@ FFC is part of the FEniCS Project.")
         (file-name (string-append name "-" version ".tar.gz"))
         (sha256
           (base32
-           "12zkk8j3xsg6l8p0ggwsl03084vlcivw4h99b7z9kndg7k89b3ya"))
+           "1m91hwcq5gfj4qqswp8l8kj58nia48f0n4kq13w0xqj4biq7rla0"))
         (modules '((guix build utils)))
         (snippet
          '(begin
@@ -430,26 +454,10 @@ FFC is part of the FEniCS Project.")
               (("#include.*")
                "#include <catch.hpp>\n"))
             (substitute* "test/unit/cpp/CMakeLists.txt"
-              ;; Add extra include directories required by the unit tests.
-              (("(^target_link_libraries.*)" line)
-               (string-append line "\n"
-                              "target_include_directories("
-                              "unittests PRIVATE "
-                              "${DOLFIN_SOURCE_DIR} "
-                              "${DOLFIN_SOURCE_DIR}/dolfin "
-                              "${DOLFIN_BINARY_DIR})\n"))
+              ;; Specify directory to find the header file.
               (("(^set\\(CATCH_INCLUDE_DIR ).*(/catch\\))" _ front back)
                (string-append front
-                              "$ENV{CATCH_DIR}"
-                              "/include" back "\n")))
-            (substitute* "demo/CMakeLists.txt"
-              ;; Add extra include directories required by the demo tests.
-              (("(^#find_package.*)" line)
-               (string-append line "\n"
-                              "include_directories("
-                              "${DOLFIN_SOURCE_DIR} "
-                              "${DOLFIN_SOURCE_DIR}/dolfin "
-                              "${DOLFIN_BINARY_DIR})\n")))
+                              "$ENV{CATCH_DIR}/include" back "\n")))
             #t))))
     (build-system cmake-build-system)
     (inputs
@@ -466,7 +474,7 @@ FFC is part of the FEniCS Project.")
        ("sundials" ,sundials-openmpi)
        ("zlib" ,zlib)))
     (native-inputs
-     `(("catch" ,catch-framework2)
+     `(("catch" ,catch-framework2-1)
        ("pkg-config" ,pkg-config)))
     (propagated-inputs
      `(("ffc" ,python-fenics-ffc)
@@ -602,7 +610,7 @@ user interface to the FEniCS core components and external libraries.")
        ("python-matplotlib" ,python-matplotlib)
        ,@(alist-delete "python" (package-inputs fenics-dolfin))))
     (native-inputs
-     `(("cmake" ,cmake)
+     `(("cmake" ,cmake-minimal)
        ("ply" ,python-ply)
        ("pytest" ,python-pytest)
        ("python-decorator" ,python-decorator)
@@ -626,12 +634,20 @@ user interface to the FEniCS core components and external libraries.")
            ,%openmpi-setup)
          (add-before 'check 'pre-check
            (lambda _
-             ;; Exclude tests that require meshes supplied by git-lfs.
+             ;; Exclude three tests that generate
+             ;; 'NotImplementedError' in matplotlib version 3.1.2.
+             ;; See
+             ;; <https://github.com/matplotlib/matplotlib/issues/15382>.
+             ;; Also exclude tests that require meshes supplied by
+             ;; git-lfs.
              (substitute* "demo/test.py"
                (("(.*stem !.*)" line)
                 (string-append
                  line "\n"
                  "excludeList = [\n"
+                 "'built-in-meshes', \n"
+                 "'hyperelasticity', \n"
+                 "'elasticity', \n"
                  "'multimesh-quadrature', \n"
                  "'multimesh-marking', \n"
                  "'mixed-poisson-sphere', \n"
@@ -639,6 +655,7 @@ user interface to the FEniCS core components and external libraries.")
                  "'lift-drag', \n"
                  "'elastodynamics', \n"
                  "'dg-advection-diffusion', \n"
+                 "'curl-curl', \n"
                  "'contact-vi-tao', \n"
                  "'contact-vi-snes', \n"
                  "'collision-detection', \n"
@@ -667,17 +684,13 @@ user interface to the FEniCS core components and external libraries.")
              (with-directory-excursion "test"
                ;; Note: The test test_snes_set_from_options() in the file
                ;; unit/nls/test_PETScSNES_solver.py fails and is ignored.
-               (and (invoke "py.test" "unit" "--ignore"
-                            "unit/nls/test_PETScSNES_solver.py")
-                    (invoke "mpirun" "-np" "3" "python" "-B" "-m"
-                            "pytest" "unit" "--ignore"
-                            "unit/nls/test_PETScSNES_solver.py")))
-             (with-directory-excursion "demo"
-               ;; Check demos.
-               (invoke "python" "generate-demo-files.py")
-               (and (invoke "python" "-m" "pytest" "-v" "test.py")
-                    (invoke "python" "-m" "pytest" "-v" "test.py"
-                            "--mpiexec=mpiexec" "--num-proc=3")))
+               ;; Limit the number of jobs to 3 as 500 MiB of memory is used
+               ;; per process.
+               (invoke "mpirun" "-np" (number->string
+                                       (min 3 (parallel-job-count)))
+                       "python" "-B" "-m"
+                       "pytest" "unit" "--ignore"
+                       "unit/nls/test_PETScSNES_solver.py"))
              #t))
          (add-after 'install 'install-demo-files
            (lambda* (#:key outputs #:allow-other-keys)
@@ -709,3 +722,73 @@ problems that can be solved using the Finite Element Method (FEM).
 within the FEniCS project.  It provides the python user interface to the
 FEniCS core components and external libraries.")
     (license license:lgpl3+)))
+
+(define-public fullswof-2d
+  (let ((revision 505)
+        (release "1.09.01"))
+    (package
+      (name "fullswof-2d")
+      (version release)
+      (source (origin
+               (method svn-fetch)
+               (uri (svn-reference
+                     (url (string-append "https://subversion.renater.fr/"
+                                         "anonscm/svn/fullswof-2d/tags/"
+                                         "release-" version))
+                     (revision revision)))
+               (file-name (string-append "fullswof-2d-" version "-checkout"))
+               (sha256
+                (base32
+                 "16v08dx7h7n4wyddzbwimazwyj74ynis12mpjfkay4243npy44b8"))))
+      (build-system gnu-build-system)
+      (native-inputs
+       `(("inetutils" ,inetutils))) ; for 'hostname', used in the check phase
+      (arguments
+       `(#:phases
+         (modify-phases %standard-phases
+           (delete 'configure)     ; no configure script
+           (add-after 'build 'build-tools
+             (lambda _
+               (with-directory-excursion "Tools/ConvertFormat"
+                 (invoke "make" "../../bin/asc2xyz")
+                 (invoke "make" "../../bin/xyz2asc"))
+               (with-directory-excursion "Tools/ExtractWindow"
+                 (invoke "make" "../../bin/cropxyz"))
+               #t))
+           (replace 'check         ; no check target
+             (lambda _
+               (invoke "make" "benchref")))
+           (replace 'install       ; no install target
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (bin (string-append out "/bin"))
+                      (doc (string-append
+                            out "/share/doc/" ,name "-" ,version))
+                      (examples (string-append doc "/Examples")))
+                 (with-directory-excursion "bin"
+                   (for-each (lambda (binary) (install-file binary bin))
+                             (list "asc2xyz" "xyz2asc" "cropxyz"
+                                   "FullSWOF_2D")))
+                 (with-directory-excursion "doc"
+                   (for-each (lambda (pdf) (install-file pdf doc))
+                             (list "Documentation.pdf" "refman.pdf")))
+                 (with-directory-excursion "Tools"
+                   (for-each (lambda (dir)
+                               (copy-file
+                                (string-append dir "/README.txt")
+                                (string-append doc "/README_" dir ".txt")))
+                             (list "ConvertFormat" "ExtractWindow")))
+                 (copy-recursively "Examples" examples)
+                 #t))))))
+      (home-page "https://www.idpoisson.fr/fullswof/")
+      (synopsis "Two dimensional flow solver for flood modelling")
+      (description "@code{FullSWOF_2d} is a numerical tool for solving
+the shallow water equations on structured grids.  The name FullSWOF
+refers to the Full form of the Shallow Water equations for Overland
+Flow.  The discretized system of equations is solved using the finite
+volume method.  A choice of shock-capturing methods is available to
+locate the transition boundaries between the wet areas and the dry
+areas in the model.  A semi-implicit method is used to advance the
+solution in time.  The tool is typically applied to the modelling of
+river flooding.")
+      (license license:cecill))))