1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017, 2018, 2019, 2020, 2021 Paul Garlick <pgarlick@tourbillion-technology.com>
3 ;;; Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
4 ;;; Copyright © 2022 Eric Bavier <bavier@posteo.net>
6 ;;; This file is part of GNU Guix.
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 (define-module (gnu packages simulation)
22 #:use-module (gnu packages)
23 #:use-module (gnu packages algebra)
24 #:use-module (gnu packages admin)
25 #:use-module (gnu packages base)
26 #:use-module (gnu packages bash)
27 #:use-module (gnu packages bison)
28 #:use-module (gnu packages boost)
29 #:use-module (gnu packages check)
30 #:use-module (gnu packages cmake)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages flex)
33 #:use-module (gnu packages gettext)
34 #:use-module (gnu packages gcc)
35 #:use-module (gnu packages gl)
36 #:use-module (gnu packages graphics)
37 #:use-module (gnu packages gtk)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages m4)
40 #:use-module (gnu packages maths)
41 #:use-module (gnu packages mpi)
42 #:use-module (gnu packages multiprecision)
43 #:use-module (gnu packages ncurses)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages python)
46 #:use-module (gnu packages python-build)
47 #:use-module (gnu packages python-science)
48 #:use-module (gnu packages python-xyz)
49 #:use-module (gnu packages readline)
50 #:use-module (gnu packages tls)
51 #:use-module (gnu packages version-control)
52 #:use-module (gnu packages xml)
53 #:use-module (gnu packages xorg)
54 #:use-module (guix download)
55 #:use-module (guix gexp)
56 #:use-module (guix git-download)
57 #:use-module (guix svn-download)
58 #:use-module (guix build-system cmake)
59 #:use-module (guix build-system gnu)
60 #:use-module (guix build-system python)
61 #:use-module ((guix licenses) #:prefix license:)
62 #:use-module (guix packages)
63 #:use-module (guix utils)
64 #:use-module (ice-9 ftw)
65 #:use-module (ice-9 regex)
66 #:use-module (srfi srfi-1))
68 (define-public openfoam
76 "http://dl.openfoam.org/source/"
77 (string-map (lambda (x) (if (eq? x #\.) #\- x)) version)))
78 (file-name (string-append name "-" version ".tar.gz"))
80 (base32 "0cgxh4h2hf50qbvvdg5miwc2nympb0nrv3md96vb3gbs9vk8vq9d"))
81 (patches (search-patches "openfoam-4.1-cleanup.patch"))
82 (modules '((guix build utils)))
85 ;; Include <sys/sysmacros.h>, which is where glibc >= 2.28 provides
86 ;; 'major' and 'minor'.
87 (substitute* "src/OSspecific/POSIX/fileStat.C"
88 (("#include <unistd\\.h>")
89 "#include <unistd.h>\n#include <sys/sysmacros.h>\n"))
91 (build-system gnu-build-system)
102 ("readline" ,readline)
103 ("scotch" ,pt-scotch32)
108 (list gzip gnuplot openmpi))
109 (outputs '("debug" ;~60MB
112 `( ;; Executable files and shared libraries are located in the 'platforms'
114 #:strip-directories (list (string-append
115 "lib/OpenFOAM-" ,version
116 "/platforms/linux64GccDPInt32Opt/bin")
118 "lib/OpenFOAM-" ,version
119 "/platforms/linux64GccDPInt32Opt/lib"))
120 #:tests? #f ; no tests to run
122 #:modules ((ice-9 ftw)
124 (guix build gnu-build-system)
127 #:phases (modify-phases %standard-phases
128 (add-after 'unpack 'rename-build-directory
131 ;; Use 'OpenFOAM-version' convention to match the file
132 ;; name expectations in the build phase.
133 (let ((unpack-dir (string-append
135 (list-ref (scandir (getcwd) (lambda (name)
136 (string-match "^OpenFOAM" name))) 0)))
137 (build-dir (string-append
138 (getcwd) "/OpenFOAM-" ,version)))
139 (rename-file unpack-dir build-dir) ; rename build directory
140 (chdir (basename build-dir))) ; move to build directory
142 (delete 'configure) ; no configure phase
145 (let ((libraries '("boost" "cgal" "gmp" "metis" "mpfr" "scotch")))
146 ;; set variables to define store paths
147 (for-each (lambda (library)
148 (setenv (string-append
149 (string-upcase library) "_ROOT")
150 (assoc-ref %build-inputs library))) libraries))
151 ;; set variables to define package versions
152 (setenv "SCOTCHVERSION" ,(package-version scotch))
153 (setenv "METISVERSION" ,(package-version metis))
154 ;; set variable to pass extra 'rpath' arguments to linker
158 "-rpath=" %output "/lib/OpenFOAM-" ,version
159 "/platforms/linux64GccDPInt32Opt/lib,"
160 "-rpath=" %output "/lib/OpenFOAM-" ,version
161 "/platforms/linux64GccDPInt32Opt/lib/dummy"))
162 ;; compile OpenFOAM libraries and applications
163 (zero? (system (format #f
164 "source ./etc/bashrc && ./Allwmake -j~a"
165 (parallel-job-count))))))
166 (add-after 'build 'update-configuration-files
168 ;; record store paths and package versions in
169 ;; configuration files
170 (substitute* "etc/config.sh/CGAL"
171 (("$BOOST_ROOT") (getenv "BOOST_ROOT")))
172 (substitute* "etc/config.sh/CGAL"
173 (("$CGAL_ROOT") (getenv "CGAL_ROOT")))
174 (substitute* "etc/config.sh/metis"
175 (("$METIS_ROOT") (getenv "METIS_ROOT")))
176 (substitute* "etc/config.sh/metis"
177 (("$METISVERSION") (getenv "METISVERSION")))
178 (substitute* "etc/config.sh/scotch"
179 (("$SCOTCH_ROOT") (getenv "SCOTCH_ROOT")))
180 (substitute* "etc/config.sh/scotch"
181 (("$SCOTCHVERSION") (getenv "SCOTCHVERSION")))
182 (substitute* "etc/config.sh/settings"
183 (("$GMP_ROOT") (getenv "GMP_ROOT")))
184 (substitute* "etc/config.sh/settings"
185 (("$MPFR_ROOT") (getenv "MPFR_ROOT")))
186 ;; reset lockDir variable to refer to write-enabled
188 (substitute* "wmake/wmake"
190 " lockDir=$HOME/.$WM_PROJECT/.wmake\n"))
191 (substitute* "wmake/wmakeScheduler"
193 "lockDir=$HOME/.$WM_PROJECT/.wmake\n"))
194 (substitute* "wmake/wmakeSchedulerUptime"
196 "lockDir=$HOME/.$WM_PROJECT/.wmake\n"))
198 (add-after 'build 'cleanup
199 ;; Avoid unncessary, voluminous object and dep files.
201 (delete-file-recursively
202 "platforms/linux64GccDPInt32Opt/src")
203 (delete-file-recursively
204 "platforms/linux64GccDPInt32OptSYSTEMOPENMPI")
205 (for-each delete-file (find-files "." "\\.o$"))
209 ;; use 'OpenFOAM-version' convention
210 (let ((install-dir (string-append
211 %output "/lib/OpenFOAM-" ,version)))
212 (mkdir-p install-dir) ; create install directory
213 ;; move contents of build directory to install directory
214 (copy-recursively "." install-dir))))
215 (add-after 'install 'add-symbolic-link
217 ;; add symbolic link for standard 'bin' directory
219 (string-append "./lib/OpenFOAM-" ,version
220 "/platforms/linux64GccDPInt32Opt/bin")
221 (string-append %output "/bin"))
224 ;; Tutorial files are installed read-only in /gnu/store.
225 ;; To allow write permissions on files copied from the store a
226 ;; 'chmod' step is needed before running the applications. For
227 ;; example, from a user's login:
228 ;; $ source $GUIX_PROFILE/lib/OpenFOAM-4.1/etc/bashrc
229 ;; $ mkdir -p $FOAM_RUN
231 ;; $ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
235 (synopsis "Framework for numerical simulation of fluid flow")
236 (description "OpenFOAM provides a set of solvers and methods for tackling
237 problems in the field of Computational Fluid Dynamics (CFD). It is written in
238 C++. Governing equations such as the Navier-Stokes equations can be solved in
239 integral form. Physical processes such as phase change, droplet transport and
240 chemical reaction can be modelled. Numerical methods are included to deal with
241 sharp gradients, such as those encountered in flows with shock waves and flows
242 with gas/liquid interfaces. Large problems may be split into smaller, connected
243 problems for efficient solution on parallel systems.")
244 (license license:gpl3+)
245 (home-page "https://openfoam.org")))
247 (define-public python-fenics-dijitso
249 (name "python-fenics-dijitso")
254 (uri (pypi-uri "fenics-dijitso" version))
257 "0lhqsq8ypdak0ahr2jnyvg07yrqp6wicjxi6k56zx24wp3qg60sc"))))
258 (build-system python-build-system)
260 (list openmpi python-numpy))
262 (list python-pytest-cov))
264 (list python-mpi4py))
267 (modify-phases %standard-phases
268 (add-after 'build 'mpi-setup
272 (setenv "HOME" "/tmp")
273 (with-directory-excursion "test"
274 ;; Disable parallel tests to avoid race condition. See
275 ;; https://github.com/pytest-dev/pytest-cov/issues/237.
276 (substitute* "runtests.sh"
277 (("for p in 1 4 8 16; do")
279 (invoke "./runtests.sh")))))))
280 (home-page "https://bitbucket.org/fenics-project/dijitso/")
281 (synopsis "Distributed just-in-time building of shared libraries")
283 "Dijitso provides a core component of the @code{FEniCS} framework,
284 namely the just-in-time compilation of C++ code that is generated from
285 Python modules. It is called from within a C++ library, using ctypes
286 to import the dynamic shared library directly.
288 As long as the compiled code can provide a simple factory function to
289 a class implementing a predefined C++ interface, there is no limit to
290 the complexity of that interface. Parallel support depends on the
291 @code{mpi4py} interface.")
292 (license license:lgpl3+)))
294 (define-public python-fenics-ufl
296 (name "python-fenics-ufl")
301 (uri (pypi-uri "fenics-ufl" version))
304 "10dz8x3lm68x2w3kkqcjask38h0zkhhak26jdbkppr8g9y8wny7p"))))
305 (build-system python-build-system)
309 (list python-pytest))
312 (modify-phases %standard-phases
315 (invoke "py.test" "test"))))))
316 (home-page "https://bitbucket.org/fenics-project/ufl/")
317 (synopsis "Unified language for form-compilers")
318 (description "The Unified Form Language (UFL) is a domain specific
319 language for declaration of finite element discretizations of
320 variational forms. More precisely, it defines a flexible interface
321 for choosing finite element spaces and defining expressions for weak
322 forms in a notation close to mathematical notation.
324 UFL is part of the FEniCS Project.")
325 (license license:lgpl3+)))
327 (define-public python-fenics-fiat
329 (name "python-fenics-fiat")
334 (uri (pypi-uri "fenics-fiat" version))
337 "13sc7lma3d2mh43an7i4kkdbbk4cmvxjk45wi43xnjd7qc38zg4b"))))
338 (build-system python-build-system)
340 (list python-pytest))
342 (list python-numpy python-sympy))
345 (modify-phases %standard-phases
348 (with-directory-excursion "test"
349 ;; FIXME: three FIAT test modules are known to fail
350 ;; with recent versions of pytest (>= 4). These are
351 ;; skipped for FIAT version 2019.1.0 pending an
352 ;; upstream pull request. For details see request #59
353 ;; at https://bitbucket.org/fenics-project/fiat/.
354 (invoke "py.test" "unit/"
355 "--ignore=unit/test_fiat.py"
356 "--ignore=unit/test_quadrature.py"
357 "--ignore=unit/test_reference_element.py")))))))
358 (home-page "https://bitbucket.org/fenics-project/fiat/")
359 (synopsis "Tabulation of finite element function spaces")
361 "The FInite element Automatic Tabulator (FIAT) supports
362 generation of arbitrary order instances of the Lagrange elements on
363 lines, triangles, and tetrahedra. It is also capable of generating
364 arbitrary order instances of Jacobi-type quadrature rules on the same
365 element shapes. Further, H(div) and H(curl) conforming finite element
366 spaces such as the families of Raviart-Thomas, Brezzi-Douglas-Marini
367 and Nedelec are supported on triangles and tetrahedra. Upcoming
368 versions will also support Hermite and nonconforming elements.
370 FIAT is part of the FEniCS Project.")
371 (license license:lgpl3+)))
373 (define-public python-fenics-ffc
375 (name "python-fenics-ffc")
376 (version "2019.1.0.post0")
380 (uri (pypi-uri "fenics-ffc" version))
383 "1f2a44ha65fg3a1prrbrsz4dgvibsv0j5c3pi2m52zi93bhwwgg9"))))
384 (build-system python-build-system)
386 (list python-pytest))
388 (list python-fenics-dijitso python-fenics-fiat python-fenics-ufl))
391 (modify-phases %standard-phases
394 (setenv "HOME" (getcwd))
395 (with-directory-excursion "test"
396 ;; FIXME: the tests in subdirectory
397 ;; 'unit/ufc/finite_element' require the ffc_factory
398 ;; extension module. This module, located in the 'libs'
399 ;; subdirectory, needs to be built and made accessible
400 ;; prior to running the tests.
401 (invoke "py.test" "unit/" "--ignore=unit/ufc/")
402 (with-directory-excursion "uflacs"
403 (invoke "py.test" "unit/")))
405 (home-page "https://bitbucket.org/fenics-project/ffc/")
406 (synopsis "Compiler for finite element variational forms")
407 (description "The FEniCS Form Compiler (FFC) is a compiler for
408 finite element variational forms. From a high-level description of
409 the form, it generates efficient low-level C++ code that can be used
410 to assemble the corresponding discrete operator (tensor). In
411 particular, a bilinear form may be assembled into a matrix and a
412 linear form may be assembled into a vector. FFC may be used either
413 from the command line (by invoking the @code{ffc} command) or as a
414 Python module (@code{import ffc}).
416 FFC is part of the FEniCS Project.")
417 ;; There are two files released with a public domain licence;
418 ;; ufc.h and ufc_geometry.h, in subdirectory 'ffc/backends/ufc'.
419 (license (list license:public-domain license:lgpl3+))))
421 (define-public fenics-dolfin
423 (name "fenics-dolfin")
424 (version "2019.1.0.post0")
429 "https://bitbucket.org/fenics-project/dolfin/get/"
431 (file-name (string-append name "-" version ".tar.gz"))
434 "1m91hwcq5gfj4qqswp8l8kj58nia48f0n4kq13w0xqj4biq7rla0"))
435 (patches (search-patches "fenics-dolfin-algorithm.patch"
436 "fenics-dolfin-demo-init.patch"
437 "fenics-dolfin-boost.patch"
438 "fenics-dolfin-config-slepc.patch"))
439 (modules '((guix build utils)))
442 ;; Make sure we don't use the bundled test framework.
443 (delete-file-recursively "test/unit/cpp/catch")
444 (substitute* "test/unit/cpp/main.cpp"
445 ;; Use standard search paths for 'catch' header file.
447 "#include <catch.hpp>\n"))
448 (substitute* "test/unit/cpp/CMakeLists.txt"
449 ;; Specify directory to find the header file.
450 (("(^set\\(CATCH_INCLUDE_DIR ).*(/catch\\))" _ front back)
452 "$ENV{CATCH_DIR}/include" back "\n")))))))
453 (build-system cmake-build-system)
458 ("hdf5" ,hdf5-parallel-openmpi)
463 ("scotch" ,pt-scotch32)
464 ("suitesparse" ,suitesparse)
465 ("sundials" ,sundials-openmpi)
468 `(("catch" ,catch-framework2-1)
469 ("pkg-config" ,pkg-config)))
471 `(("ffc" ,python-fenics-ffc)
472 ("petsc" ,petsc-openmpi)
473 ("slepc" ,slepc-openmpi)))
476 `("-DDOLFIN_ENABLE_DOCS:BOOL=OFF"
477 "-DDOLFIN_ENABLE_HDF5:BOOL=ON"
478 "-DDOLFIN_ENABLE_MPI:BOOL=ON"
479 "-DDOLFIN_ENABLE_PARMETIS:BOOL=OFF"
480 "-DDOLFIN_ENABLE_SCOTCH:BOOL=ON"
481 "-DDOLFIN_ENABLE_SUNDIALS:BOOL=ON"
482 "-DDOLFIN_ENABLE_TRILINOS:BOOL=OFF")
484 (modify-phases %standard-phases
485 (add-after 'patch-usr-bin-file 'mpi-setup
487 (add-after 'patch-source-shebangs 'set-paths
489 ;; Define paths to store locations.
490 (setenv "BLAS_DIR" (assoc-ref %build-inputs "blas"))
491 (setenv "CATCH_DIR" (assoc-ref %build-inputs "catch"))
492 (setenv "LAPACK_DIR" (assoc-ref %build-inputs "lapack"))
493 (setenv "PETSC_DIR" (assoc-ref %build-inputs "petsc"))
494 (setenv "SLEPC_DIR" (assoc-ref %build-inputs "slepc"))
495 (setenv "SCOTCH_DIR" (assoc-ref %build-inputs "scotch"))
496 (setenv "SUNDIALS_DIR" (assoc-ref %build-inputs "sundials"))
497 (setenv "UMFPACK_DIR" (assoc-ref %build-inputs "suitesparse"))))
498 (add-before 'check 'pre-check
500 ;; The Dolfin repository uses git-lfs, whereby web links are
501 ;; substituted for large files. Guix does not currently support
502 ;; git-lfs, so only the links are downloaded. The tests that
503 ;; require the absent meshes cannot run and are skipped.
505 ;; One serial test fails and is skipped.
506 ;; i) demo_multimesh-stokes_serial:
507 ;; Warning: Found no facets matching domain for boundary
510 ;; One mpi test fails and is skipped.
511 ;; i) demo_stokes-iterative_mpi:
512 ;; The MPI_Comm_rank() function was called before MPI_INIT was
514 (call-with-output-file "CTestCustom.cmake"
518 "set(CTEST_CUSTOM_TESTS_IGNORE "
521 "demo_eigenvalue_serial "
522 "demo_eigenvalue_mpi "
523 "demo_navier-stokes_serial "
524 "demo_navier-stokes_mpi "
525 "demo_stokes-taylor-hood_serial "
526 "demo_stokes-taylor-hood_mpi "
527 "demo_subdomains_serial "
528 "demo_advection-diffusion_serial "
529 "demo_advection-diffusion_mpi "
530 "demo_auto-adaptive-navier-stokes_serial "
531 "demo_contact-vi-snes_serial "
532 "demo_contact-vi-snes_mpi "
533 "demo_contact-vi-tao_serial "
534 "demo_contact-vi-tao_mpi "
535 "demo_curl-curl_serial "
536 "demo_curl-curl_mpi "
537 "demo_dg-advection-diffusion_serial "
538 "demo_dg-advection-diffusion_mpi "
539 "demo_elasticity_serial "
540 "demo_elasticity_mpi "
541 "demo_elastodynamics_serial "
542 "demo_elastodynamics_mpi "
543 "demo_lift-drag_serial "
544 "demo_lift-drag_mpi "
545 "demo_mesh-quality_serial "
546 "demo_mesh-quality_mpi "
547 "demo_multimesh-stokes_serial "
550 (lambda* (#:key tests? #:allow-other-keys)
552 (invoke "make" "unittests")
553 (invoke "make" "demos")
554 (invoke "ctest" "-R" "unittests")
555 (invoke "ctest" "-R" "demo" "-R" "serial")
556 (invoke "ctest" "-R" "demo" "-R" "mpi")))))))
557 (home-page "https://bitbucket.org/fenics-project/dolfin/")
558 (synopsis "Problem solving environment for differential equations")
560 "DOLFIN is a computational framework for finding numerical
561 solutions to problems described by differential equations. Numerical
562 models in DOLFIN are constructed using general families of finite
563 elements. Data structures are provided for discretizing the governing
564 system on a computational mesh. A compact syntax, similar to
565 mathematical notation, is made available for defining function spaces
566 and expressing variational forms. Interfaces to specialized matrix
567 solvers are provided for solving the resultant linear systems.
569 @code{fenics-dolfin} is part of the FEniCS project. It is the C++
570 user interface to the FEniCS core components and external libraries.")
571 ;; The source code for the DOLFIN C++ library is licensed under the
572 ;; GNU Lesser General Public License, version 3 or later, with the
573 ;; following exceptions:
575 ;; public-domain: dolfin/geometry/predicates.cpp
576 ;; dolfin/geometry/predicates.h
578 ;; zlib: dolfin/io/base64.cpp
579 ;; dolfin/io/base64.h
581 ;; expat: dolfin/io/pugiconfig.hpp
582 ;; dolfin/io/pugixml.cpp
583 ;; dolfin/io/pugixml.hpp
584 (license (list license:public-domain
589 (define-public fenics
590 (package/inherit fenics-dolfin
592 (build-system python-build-system)
594 `(("pybind11" ,pybind11)
595 ("python-matplotlib" ,python-matplotlib)
596 ,@(alist-delete "python" (package-inputs fenics-dolfin))))
598 `(("cmake" ,cmake-minimal)
600 ("pytest" ,python-pytest)
601 ("python-decorator" ,python-decorator)
602 ("python-pkgconfig" ,python-pkgconfig)
603 ,@(package-native-inputs fenics-dolfin)))
605 `(("dolfin" ,fenics-dolfin)
606 ("petsc4py" ,python-petsc4py)
607 ("slepc4py" ,python-slepc4py)))
610 (modify-phases %standard-phases
611 (add-after 'unpack 'relax-requirements
613 (substitute* "python/setup.py"
614 (("pybind11==") "pybind11>="))))
615 (add-after 'patch-source-shebangs 'set-paths
617 ;; Define paths to store locations.
618 (setenv "PYBIND11_DIR" (assoc-ref %build-inputs "pybind11"))
619 ;; Move to python sub-directory.
621 (add-after 'build 'mpi-setup
623 (add-before 'check 'pre-check
625 ;; Exclude three tests that generate
626 ;; 'NotImplementedError' in matplotlib version 3.1.2.
628 ;; <https://github.com/matplotlib/matplotlib/issues/15382>.
629 ;; Also exclude tests that require meshes supplied by
631 (substitute* "demo/test.py"
632 (("(.*stem !.*)" line)
636 "'built-in-meshes', \n"
637 "'hyperelasticity', \n"
639 "'multimesh-quadrature', \n"
640 "'multimesh-marking', \n"
641 "'mixed-poisson-sphere', \n"
644 "'elastodynamics', \n"
645 "'dg-advection-diffusion', \n"
647 "'contact-vi-tao', \n"
648 "'contact-vi-snes', \n"
649 "'collision-detection', \n"
651 "'auto-adaptive-navier-stokes', \n"
652 "'advection-diffusion', \n"
654 "'stokes-taylor-hood', \n"
656 "'navier-stokes', \n"
659 "d for d in demos if d[0].stem not in "
661 (setenv "HOME" (getcwd))
662 ;; Restrict OpenBLAS to MPI-only in preference to MPI+OpenMP.
663 (setenv "OPENBLAS_NUM_THREADS" "1")))
665 (lambda* (#:key tests? #:allow-other-keys)
667 (with-directory-excursion "test"
670 ;; The test test_snes_set_from_options() in the file
671 ;; unit/nls/test_PETScSNES_solver.py fails and is ignored.
672 "--ignore" "unit/nls/test_PETScSNES_solver.py"
673 ;; Fails with a segfault.
674 "--ignore" "unit/io/test_XDMF.py")))))
675 (add-after 'install 'install-demo-files
676 (lambda* (#:key outputs #:allow-other-keys)
677 (let* ((demos (string-append
678 (assoc-ref outputs "out")
679 "/share/python-dolfin/demo")))
681 (with-directory-excursion "demo"
682 (for-each (lambda (file)
683 (let* ((dir (dirname file))
684 (tgt-dir (string-append demos "/" dir)))
685 (unless (equal? "." dir)
687 (install-file file tgt-dir))))
688 (find-files "." ".*\\.(py|gz|xdmf)$")))))))))
689 (home-page "https://fenicsproject.org/")
690 (synopsis "High-level environment for solving differential equations")
692 "@code{fenics} is a computing platform for solving general classes of
693 problems that involve differential equations. @code{fenics} facilitates
694 access to efficient methods for dealing with ordinary differential
695 equations (ODEs) and partial differential equations (PDEs). Systems of
696 equations such as these are commonly encountered in areas of engineering,
697 mathematics and the physical sciences. It is particularly well-suited to
698 problems that can be solved using the Finite Element Method (FEM).
700 @code{fenics} is the top level of the set of packages that are developed
701 within the FEniCS project. It provides the python user interface to the
702 FEniCS core components and external libraries.")
703 (license license:lgpl3+)))
705 (define-public fullswof-2d
714 (url (string-append "https://subversion.renater.fr/"
715 "anonscm/svn/fullswof-2d/tags/"
717 (revision revision)))
718 (file-name (string-append "fullswof-2d-" version "-checkout"))
721 "16v08dx7h7n4wyddzbwimazwyj74ynis12mpjfkay4243npy44b8"))))
722 (build-system gnu-build-system)
724 (list inetutils)) ; for 'hostname', used in the check phase
727 (modify-phases %standard-phases
728 (delete 'configure) ; no configure script
729 (add-after 'build 'build-tools
731 (with-directory-excursion "Tools/ConvertFormat"
732 (invoke "make" "../../bin/asc2xyz")
733 (invoke "make" "../../bin/xyz2asc"))
734 (with-directory-excursion "Tools/ExtractWindow"
735 (invoke "make" "../../bin/cropxyz"))
737 (replace 'check ; no check target
739 (invoke "make" "benchref")))
740 (replace 'install ; no install target
741 (lambda* (#:key outputs #:allow-other-keys)
742 (let* ((out (assoc-ref outputs "out"))
743 (bin (string-append out "/bin"))
745 out "/share/doc/" ,name "-" ,version))
746 (examples (string-append doc "/Examples")))
747 (with-directory-excursion "bin"
748 (for-each (lambda (binary) (install-file binary bin))
749 (list "asc2xyz" "xyz2asc" "cropxyz"
751 (with-directory-excursion "doc"
752 (for-each (lambda (pdf) (install-file pdf doc))
753 (list "Documentation.pdf" "refman.pdf")))
754 (with-directory-excursion "Tools"
755 (for-each (lambda (dir)
757 (string-append dir "/README.txt")
758 (string-append doc "/README_" dir ".txt")))
759 (list "ConvertFormat" "ExtractWindow")))
760 (copy-recursively "Examples" examples)
762 (home-page "https://www.idpoisson.fr/fullswof/")
763 (synopsis "Two dimensional flow solver for flood modelling")
764 (description "@code{FullSWOF_2d} is a numerical tool for solving
765 the shallow water equations on structured grids. The name FullSWOF
766 refers to the Full form of the Shallow Water equations for Overland
767 Flow. The discretized system of equations is solved using the finite
768 volume method. A choice of shock-capturing methods is available to
769 locate the transition boundaries between the wet areas and the dry
770 areas in the model. A semi-implicit method is used to advance the
771 solution in time. The tool is typically applied to the modelling of
773 (license license:cecill))))
775 (define-public python-meshio
777 (name "python-meshio")
782 (uri (pypi-uri "meshio" version))
785 "1w39qcg0rw5kb04j7sa45fnqd6k20fsdgrf62cmw2ygjgwnnjh72"))
787 '(let ((file (open-file "setup.py" "a")))
788 (display "from setuptools import setup\nsetup()" file)
789 (close-port file)))))
790 (build-system python-build-system)
795 (list python-pytest))
797 (list python-importlib-metadata
802 (modify-phases %standard-phases
804 (lambda* (#:key tests? #:allow-other-keys)
806 (invoke "python" "-m" "pytest" "-v" "tests")))))))
807 (home-page "https://github.com/nschloe/meshio")
808 (synopsis "I/O for mesh files")
809 (description "There are various file formats available for
810 representing unstructured meshes and mesh data. The @code{meshio}
811 package is able to read and write mesh files in many formats and to
812 convert files from one format to another. Formats such as cgns, h5m,
813 gmsh, xdmf and vtk are supported. The package provides command-line
814 tools and a collection of Python modules for programmatic use.")
815 (license license:expat)))
817 (define-public python-pygmsh
819 (name "python-pygmsh")
825 (url "https://github.com/nschloe/pygmsh")
826 (commit (string-append "v" version))))
827 (file-name (git-file-name name version))
830 "11flp2c4ynk1fhanf4mqyzrpd0gjbnv6afrwwc7xi3mb6ms69lr0"))))
831 (build-system python-build-system)
835 #~(modify-phases %standard-phases
836 (add-after 'unpack 'workaround-gmsh-detection-failure
838 ;; Due to lack of metadata, the gmsh Python package is not
839 ;; detected although importable.
840 (substitute* "pyproject.toml"
841 (("\"gmsh\",") ""))))
842 ;; XXX: PEP 517 manual build copied from python-isort.
845 (invoke "python" "-m" "build" "--wheel" "--no-isolation" ".")))
847 (lambda* (#:key tests? #:allow-other-keys)
849 (invoke "pytest" "-v" "tests"))))
852 (let ((whl (car (find-files "dist" "\\.whl$"))))
853 (invoke "pip" "--no-cache-dir" "--no-input"
854 "install" "--no-deps" "--prefix" #$output whl)))))))
855 (native-inputs (list python-pypa-build python-flit-core python-pytest))
856 (propagated-inputs (list gmsh python-meshio python-numpy))
857 (home-page "https://github.com/nschloe/pygmsh")
858 (synopsis "Python frontend for Gmsh")
859 (description "The goal of @code{pygmsh} is to combine the power of
860 Gmsh with the versatility of Python. The package generalises many of
861 the methods and functions that comprise the Gmsh Python API. In this
862 way the meshing of complex geometries using high-level abstractions is
863 made possible. The package provides a Python library together with a
864 command-line utility for mesh optimisation.")
865 (license license:gpl3+)))
867 (define-public python-dolfin-adjoint
869 (name "python-dolfin-adjoint")
875 (url "https://github.com/dolfin-adjoint/pyadjoint")
877 (file-name (git-file-name name version))
880 "0xhy76a5f33hz94wc9g2mc5qmwkxfccbbc6yxl7psm130afp8lhn"))
881 (modules '((guix build utils)))
884 ;; One of the migration tests attempts to call openmpi
885 ;; recursively and fails. See
886 ;; https://bitbucket.org/mpi4py/mpi4py/issues/95. Run the
887 ;; test sequentially instead.
888 (with-directory-excursion "tests/migration/optimal_control_mms"
889 (substitute* "test_optimal_control_mms.py"
890 (("\\\"mpirun\\\", \\\"-n\\\", \\\"2\\\", ") "")))
891 ;; Result files are regenerated in the check phase.
892 (delete-file-recursively
893 "tests/migration/viscoelasticity/test-results")
895 (build-system python-build-system)
897 (list fenics openmpi pybind11))
906 `(("scipy" ,python-scipy)))
909 (modify-phases %standard-phases
910 (add-after 'build 'mpi-setup
912 (add-after 'install 'install-doc
913 (lambda* (#:key outputs #:allow-other-keys)
914 (let* ((doc (string-append (assoc-ref outputs "out")
915 "/share/doc/" ,name "-"
917 (examples (string-append doc "/examples")))
919 (copy-recursively "examples" examples))
922 (lambda* (#:key inputs outputs tests? #:allow-other-keys)
924 (add-installed-pythonpath inputs outputs)
925 (setenv "HOME" (getcwd))
926 (and (invoke "py.test" "-v" "tests/fenics_adjoint")
927 (invoke "py.test" "-v" "tests/migration")
928 (invoke "py.test" "-v" "tests/pyadjoint")))
930 (home-page "http://www.dolfin-adjoint.org")
931 (synopsis "Automatic differentiation library")
932 (description "@code{python-dolfin-adjoint} is a solver of
933 differential equations associated with a governing system and a
934 functional of interest. Working from the forward model the solver
935 automatically derives the discrete adjoint and tangent linear models.
936 These additional models are key ingredients in many algorithms such as
937 data assimilation, optimal control, sensitivity analysis, design
938 optimisation and error estimation. The dolfin-adjoint project
939 provides the necessary tools and data structures for cases where the
940 forward model is implemented in @code{fenics} or
941 @url{https://firedrakeproject.org,firedrake}.")
942 (license license:lgpl3)))