gnu: python-meshio: Remove trailing booleans.
[jackhill/guix/guix.git] / gnu / packages / simulation.scm
CommitLineData
8f21aa22 1;;; GNU Guix --- Functional package management for GNU
1f519e8b 2;;; Copyright © 2017, 2018, 2019, 2020, 2021 Paul Garlick <pgarlick@tourbillion-technology.com>
85b42f04 3;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
41b11c45 4;;; Copyright © 2022 Eric Bavier <bavier@posteo.net>
8f21aa22
PG
5;;;
6;;; This file is part of GNU Guix.
7;;;
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.
12;;;
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.
17;;;
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/>.
20
21(define-module (gnu packages simulation)
22 #:use-module (gnu packages)
0ace6c0b 23 #:use-module (gnu packages algebra)
40fc8992 24 #:use-module (gnu packages admin)
8f21aa22
PG
25 #:use-module (gnu packages base)
26 #:use-module (gnu packages bash)
27 #:use-module (gnu packages bison)
28 #:use-module (gnu packages boost)
f7a4757a 29 #:use-module (gnu packages check)
0ace6c0b 30 #:use-module (gnu packages cmake)
8f21aa22
PG
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)
0ace6c0b 44 #:use-module (gnu packages pkg-config)
f7a4757a 45 #:use-module (gnu packages python)
3af31bc2 46 #:use-module (gnu packages python-build)
b05a1eb5 47 #:use-module (gnu packages python-science)
44d10b1f 48 #:use-module (gnu packages python-xyz)
8f21aa22
PG
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)
b05a1eb5 55 #:use-module (guix git-download)
40fc8992 56 #:use-module (guix svn-download)
0ace6c0b 57 #:use-module (guix build-system cmake)
8f21aa22 58 #:use-module (guix build-system gnu)
f7a4757a 59 #:use-module (guix build-system python)
8f21aa22
PG
60 #:use-module ((guix licenses) #:prefix license:)
61 #:use-module (guix packages)
62 #:use-module (guix utils)
63 #:use-module (ice-9 ftw)
64 #:use-module (ice-9 regex)
65 #:use-module (srfi srfi-1))
66
67(define-public openfoam
68 (package
69 (name "openfoam")
70 (version "4.1")
71 (source
72 (origin
73 (method url-fetch)
74 (uri (string-append
75 "http://dl.openfoam.org/source/"
76 (string-map (lambda (x) (if (eq? x #\.) #\- x)) version)))
77 (file-name (string-append name "-" version ".tar.gz"))
78 (sha256
79 (base32 "0cgxh4h2hf50qbvvdg5miwc2nympb0nrv3md96vb3gbs9vk8vq9d"))
886d833e
LC
80 (patches (search-patches "openfoam-4.1-cleanup.patch"))
81 (modules '((guix build utils)))
82 (snippet
83 '(begin
84 ;; Include <sys/sysmacros.h>, which is where glibc >= 2.28 provides
85 ;; 'major' and 'minor'.
86 (substitute* "src/OSspecific/POSIX/fileStat.C"
87 (("#include <unistd\\.h>")
88 "#include <unistd.h>\n#include <sys/sysmacros.h>\n"))
89 #t))))
8f21aa22
PG
90 (build-system gnu-build-system)
91 (inputs
92 `(("boost" ,boost)
93 ("cgal" ,cgal)
94 ("flex" ,flex)
95 ("git" ,git)
96 ("gmp" ,gmp)
97 ("libxt" ,libxt)
98 ("metis" ,metis)
99 ("mpfr" ,mpfr)
100 ("ncurses" ,ncurses)
101 ("readline" ,readline)
102 ("scotch" ,pt-scotch32)
103 ("zlib" ,zlib)))
104 (native-inputs
8394619b 105 (list bison))
8f21aa22 106 (propagated-inputs
8394619b 107 (list gzip gnuplot openmpi))
f1de0e37
DL
108 (outputs '("debug" ;~60MB
109 "out"))
8f21aa22
PG
110 (arguments
111 `( ;; Executable files and shared libraries are located in the 'platforms'
112 ;; subdirectory.
113 #:strip-directories (list (string-append
114 "lib/OpenFOAM-" ,version
115 "/platforms/linux64GccDPInt32Opt/bin")
116 (string-append
117 "lib/OpenFOAM-" ,version
118 "/platforms/linux64GccDPInt32Opt/lib"))
119 #:tests? #f ; no tests to run
120
121 #:modules ((ice-9 ftw)
122 (ice-9 regex)
123 (guix build gnu-build-system)
124 (guix build utils))
125
126 #:phases (modify-phases %standard-phases
127 (add-after 'unpack 'rename-build-directory
128 (lambda _
129 (chdir "..")
130 ;; Use 'OpenFOAM-version' convention to match the file
131 ;; name expectations in the build phase.
132 (let ((unpack-dir (string-append
133 (getcwd) "/"
134 (list-ref (scandir (getcwd) (lambda (name)
135 (string-match "^OpenFOAM" name))) 0)))
136 (build-dir (string-append
137 (getcwd) "/OpenFOAM-" ,version)))
138 (rename-file unpack-dir build-dir) ; rename build directory
139 (chdir (basename build-dir))) ; move to build directory
140 #t))
141 (delete 'configure) ; no configure phase
142 (replace 'build
143 (lambda _
144 (let ((libraries '("boost" "cgal" "gmp" "metis" "mpfr" "scotch")))
145 ;; set variables to define store paths
146 (for-each (lambda (library)
147 (setenv (string-append
148 (string-upcase library) "_ROOT")
149 (assoc-ref %build-inputs library))) libraries))
150 ;; set variables to define package versions
151 (setenv "SCOTCHVERSION" ,(package-version scotch))
152 (setenv "METISVERSION" ,(package-version metis))
153 ;; set variable to pass extra 'rpath' arguments to linker
154 (setenv "LDFLAGS"
155 (string-append
156 "-Wl,"
157 "-rpath=" %output "/lib/OpenFOAM-" ,version
158 "/platforms/linux64GccDPInt32Opt/lib,"
159 "-rpath=" %output "/lib/OpenFOAM-" ,version
160 "/platforms/linux64GccDPInt32Opt/lib/dummy"))
161 ;; compile OpenFOAM libraries and applications
162 (zero? (system (format #f
163 "source ./etc/bashrc && ./Allwmake -j~a"
164 (parallel-job-count))))))
165 (add-after 'build 'update-configuration-files
166 (lambda _
167 ;; record store paths and package versions in
168 ;; configuration files
169 (substitute* "etc/config.sh/CGAL"
170 (("$BOOST_ROOT") (getenv "BOOST_ROOT")))
171 (substitute* "etc/config.sh/CGAL"
172 (("$CGAL_ROOT") (getenv "CGAL_ROOT")))
173 (substitute* "etc/config.sh/metis"
174 (("$METIS_ROOT") (getenv "METIS_ROOT")))
175 (substitute* "etc/config.sh/metis"
176 (("$METISVERSION") (getenv "METISVERSION")))
177 (substitute* "etc/config.sh/scotch"
178 (("$SCOTCH_ROOT") (getenv "SCOTCH_ROOT")))
179 (substitute* "etc/config.sh/scotch"
180 (("$SCOTCHVERSION") (getenv "SCOTCHVERSION")))
181 (substitute* "etc/config.sh/settings"
182 (("$GMP_ROOT") (getenv "GMP_ROOT")))
183 (substitute* "etc/config.sh/settings"
184 (("$MPFR_ROOT") (getenv "MPFR_ROOT")))
185 ;; reset lockDir variable to refer to write-enabled
186 ;; directory
187 (substitute* "wmake/wmake"
188 ((" lockDir=.*$")
189 " lockDir=$HOME/.$WM_PROJECT/.wmake\n"))
190 (substitute* "wmake/wmakeScheduler"
191 (("lockDir=.*$")
192 "lockDir=$HOME/.$WM_PROJECT/.wmake\n"))
193 (substitute* "wmake/wmakeSchedulerUptime"
194 (("lockDir=.*$")
195 "lockDir=$HOME/.$WM_PROJECT/.wmake\n"))
196 #t))
f1de0e37
DL
197 (add-after 'build 'cleanup
198 ;; Avoid unncessary, voluminous object and dep files.
199 (lambda _
200 (delete-file-recursively
201 "platforms/linux64GccDPInt32Opt/src")
202 (delete-file-recursively
203 "platforms/linux64GccDPInt32OptSYSTEMOPENMPI")
204 (for-each delete-file (find-files "." "\\.o$"))
205 #t))
8f21aa22
PG
206 (replace 'install
207 (lambda _
208 ;; use 'OpenFOAM-version' convention
209 (let ((install-dir (string-append
210 %output "/lib/OpenFOAM-" ,version)))
211 (mkdir-p install-dir) ; create install directory
212 ;; move contents of build directory to install directory
213 (copy-recursively "." install-dir))))
214 (add-after 'install 'add-symbolic-link
215 (lambda _
216 ;; add symbolic link for standard 'bin' directory
217 (symlink
218 (string-append "./lib/OpenFOAM-" ,version
219 "/platforms/linux64GccDPInt32Opt/bin")
220 (string-append %output "/bin"))
221 #t)))))
222 ;; Note:
223 ;; Tutorial files are installed read-only in /gnu/store.
224 ;; To allow write permissions on files copied from the store a
225 ;; 'chmod' step is needed before running the applications. For
226 ;; example, from a user's login:
227 ;; $ source $GUIX_PROFILE/lib/OpenFOAM-4.1/etc/bashrc
228 ;; $ mkdir -p $FOAM_RUN
229 ;; $ cd $FOAM_RUN
a836e9f5
PG
230 ;; $ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
231 ;; $ cd pitzDaily
8f21aa22
PG
232 ;; $ chmod -R u+w .
233 ;; $ blockMesh
234 (synopsis "Framework for numerical simulation of fluid flow")
235 (description "OpenFOAM provides a set of solvers and methods for tackling
236problems in the field of Computational Fluid Dynamics (CFD). It is written in
237C++. Governing equations such as the Navier-Stokes equations can be solved in
238integral form. Physical processes such as phase change, droplet transport and
239chemical reaction can be modelled. Numerical methods are included to deal with
240sharp gradients, such as those encountered in flows with shock waves and flows
241with gas/liquid interfaces. Large problems may be split into smaller, connected
b6598237 242problems for efficient solution on parallel systems.")
8f21aa22
PG
243 (license license:gpl3+)
244 (home-page "https://openfoam.org")))
f7a4757a
PG
245
246(define-public python-fenics-dijitso
247 (package
248 (name "python-fenics-dijitso")
23686184 249 (version "2019.1.0")
f7a4757a
PG
250 (source
251 (origin
252 (method url-fetch)
253 (uri (pypi-uri "fenics-dijitso" version))
254 (sha256
255 (base32
23686184 256 "0lhqsq8ypdak0ahr2jnyvg07yrqp6wicjxi6k56zx24wp3qg60sc"))))
f7a4757a
PG
257 (build-system python-build-system)
258 (inputs
8394619b 259 (list openmpi python-numpy))
f7a4757a 260 (native-inputs
8394619b 261 (list python-pytest-cov))
f7a4757a 262 (propagated-inputs
8394619b 263 (list python-mpi4py))
f7a4757a
PG
264 (arguments
265 `(#:phases
266 (modify-phases %standard-phases
267 (add-after 'build 'mpi-setup
268 ,%openmpi-setup)
269 (replace 'check
270 (lambda _
271 (setenv "HOME" "/tmp")
f7a4757a 272 (with-directory-excursion "test"
7a82074c
PG
273 ;; Disable parallel tests to avoid race condition. See
274 ;; https://github.com/pytest-dev/pytest-cov/issues/237.
275 (substitute* "runtests.sh"
276 (("for p in 1 4 8 16; do")
277 "for p in 1; do"))
85b42f04 278 (invoke "./runtests.sh")))))))
f7a4757a
PG
279 (home-page "https://bitbucket.org/fenics-project/dijitso/")
280 (synopsis "Distributed just-in-time building of shared libraries")
281 (description
282 "Dijitso provides a core component of the @code{FEniCS} framework,
283namely the just-in-time compilation of C++ code that is generated from
284Python modules. It is called from within a C++ library, using ctypes
285to import the dynamic shared library directly.
286
287As long as the compiled code can provide a simple factory function to
288a class implementing a predefined C++ interface, there is no limit to
289the complexity of that interface. Parallel support depends on the
290@code{mpi4py} interface.")
291 (license license:lgpl3+)))
3941cf5a
PG
292
293(define-public python-fenics-ufl
294 (package
295 (name "python-fenics-ufl")
def588d2 296 (version "2019.1.0")
3941cf5a
PG
297 (source
298 (origin
299 (method url-fetch)
300 (uri (pypi-uri "fenics-ufl" version))
301 (sha256
302 (base32
def588d2 303 "10dz8x3lm68x2w3kkqcjask38h0zkhhak26jdbkppr8g9y8wny7p"))))
3941cf5a
PG
304 (build-system python-build-system)
305 (inputs
8394619b 306 (list python-numpy))
3941cf5a 307 (native-inputs
8394619b 308 (list python-pytest))
3941cf5a
PG
309 (arguments
310 '(#:phases
311 (modify-phases %standard-phases
312 (replace 'check
313 (lambda _
10bee15c 314 (invoke "py.test" "test"))))))
3941cf5a
PG
315 (home-page "https://bitbucket.org/fenics-project/ufl/")
316 (synopsis "Unified language for form-compilers")
317 (description "The Unified Form Language (UFL) is a domain specific
318language for declaration of finite element discretizations of
319variational forms. More precisely, it defines a flexible interface
320for choosing finite element spaces and defining expressions for weak
321forms in a notation close to mathematical notation.
322
323UFL is part of the FEniCS Project.")
324 (license license:lgpl3+)))
0fc49983
PG
325
326(define-public python-fenics-fiat
327 (package
328 (name "python-fenics-fiat")
4dfb22c1 329 (version "2019.1.0")
0fc49983
PG
330 (source
331 (origin
332 (method url-fetch)
333 (uri (pypi-uri "fenics-fiat" version))
334 (sha256
335 (base32
4dfb22c1 336 "13sc7lma3d2mh43an7i4kkdbbk4cmvxjk45wi43xnjd7qc38zg4b"))))
0fc49983
PG
337 (build-system python-build-system)
338 (native-inputs
8394619b 339 (list python-pytest))
0fc49983 340 (propagated-inputs
8394619b 341 (list python-numpy python-sympy))
0fc49983
PG
342 (arguments
343 '(#:phases
344 (modify-phases %standard-phases
345 (replace 'check
346 (lambda _
0fc49983 347 (with-directory-excursion "test"
4dfb22c1
PG
348 ;; FIXME: three FIAT test modules are known to fail
349 ;; with recent versions of pytest (>= 4). These are
350 ;; skipped for FIAT version 2019.1.0 pending an
351 ;; upstream pull request. For details see request #59
352 ;; at https://bitbucket.org/fenics-project/fiat/.
353 (invoke "py.test" "unit/"
354 "--ignore=unit/test_fiat.py"
355 "--ignore=unit/test_quadrature.py"
0c9844e1 356 "--ignore=unit/test_reference_element.py")))))))
0fc49983
PG
357 (home-page "https://bitbucket.org/fenics-project/fiat/")
358 (synopsis "Tabulation of finite element function spaces")
359 (description
360 "The FInite element Automatic Tabulator (FIAT) supports
361generation of arbitrary order instances of the Lagrange elements on
362lines, triangles, and tetrahedra. It is also capable of generating
363arbitrary order instances of Jacobi-type quadrature rules on the same
364element shapes. Further, H(div) and H(curl) conforming finite element
365spaces such as the families of Raviart-Thomas, Brezzi-Douglas-Marini
366and Nedelec are supported on triangles and tetrahedra. Upcoming
367versions will also support Hermite and nonconforming elements.
368
369FIAT is part of the FEniCS Project.")
370 (license license:lgpl3+)))
6b7f1f8a
PG
371
372(define-public python-fenics-ffc
373 (package
374 (name "python-fenics-ffc")
ec8dff89 375 (version "2019.1.0.post0")
6b7f1f8a
PG
376 (source
377 (origin
378 (method url-fetch)
379 (uri (pypi-uri "fenics-ffc" version))
380 (sha256
381 (base32
ec8dff89 382 "1f2a44ha65fg3a1prrbrsz4dgvibsv0j5c3pi2m52zi93bhwwgg9"))))
6b7f1f8a
PG
383 (build-system python-build-system)
384 (native-inputs
8394619b 385 (list python-pytest))
6b7f1f8a 386 (propagated-inputs
8394619b 387 (list python-fenics-dijitso python-fenics-fiat python-fenics-ufl))
6b7f1f8a
PG
388 (arguments
389 '(#:phases
390 (modify-phases %standard-phases
391 (replace 'check
392 (lambda _
393 (setenv "HOME" (getcwd))
6b7f1f8a
PG
394 (with-directory-excursion "test"
395 ;; FIXME: the tests in subdirectory
396 ;; 'unit/ufc/finite_element' require the ffc_factory
397 ;; extension module. This module, located in the 'libs'
398 ;; subdirectory, needs to be built and made accessible
399 ;; prior to running the tests.
400 (invoke "py.test" "unit/" "--ignore=unit/ufc/")
401 (with-directory-excursion "uflacs"
1ebb629c
MC
402 (invoke "py.test" "unit/")))
403 #t)))))
6b7f1f8a
PG
404 (home-page "https://bitbucket.org/fenics-project/ffc/")
405 (synopsis "Compiler for finite element variational forms")
406 (description "The FEniCS Form Compiler (FFC) is a compiler for
407finite element variational forms. From a high-level description of
408the form, it generates efficient low-level C++ code that can be used
409to assemble the corresponding discrete operator (tensor). In
410particular, a bilinear form may be assembled into a matrix and a
411linear form may be assembled into a vector. FFC may be used either
412from the command line (by invoking the @code{ffc} command) or as a
413Python module (@code{import ffc}).
414
415FFC is part of the FEniCS Project.")
416 ;; There are two files released with a public domain licence;
417 ;; ufc.h and ufc_geometry.h, in subdirectory 'ffc/backends/ufc'.
418 (license (list license:public-domain license:lgpl3+))))
0ace6c0b
PG
419
420(define-public fenics-dolfin
421 (package
422 (name "fenics-dolfin")
09ecd9a7 423 (version "2019.1.0.post0")
0ace6c0b
PG
424 (source
425 (origin
426 (method url-fetch)
427 (uri (string-append
428 "https://bitbucket.org/fenics-project/dolfin/get/"
429 version ".tar.gz"))
430 (file-name (string-append name "-" version ".tar.gz"))
431 (sha256
432 (base32
09ecd9a7 433 "1m91hwcq5gfj4qqswp8l8kj58nia48f0n4kq13w0xqj4biq7rla0"))
41b11c45
EB
434 (patches (search-patches "fenics-dolfin-algorithm.patch"
435 "fenics-dolfin-demo-init.patch"
436 "fenics-dolfin-boost.patch"
437 "fenics-dolfin-config-slepc.patch"))
0ace6c0b
PG
438 (modules '((guix build utils)))
439 (snippet
440 '(begin
441 ;; Make sure we don't use the bundled test framework.
442 (delete-file-recursively "test/unit/cpp/catch")
443 (substitute* "test/unit/cpp/main.cpp"
444 ;; Use standard search paths for 'catch' header file.
445 (("#include.*")
446 "#include <catch.hpp>\n"))
447 (substitute* "test/unit/cpp/CMakeLists.txt"
09ecd9a7 448 ;; Specify directory to find the header file.
0ace6c0b
PG
449 (("(^set\\(CATCH_INCLUDE_DIR ).*(/catch\\))" _ front back)
450 (string-append front
69505bec 451 "$ENV{CATCH_DIR}/include" back "\n")))))))
0ace6c0b
PG
452 (build-system cmake-build-system)
453 (inputs
454 `(("blas" ,openblas)
455 ("boost" ,boost)
456 ("eigen" ,eigen)
457 ("hdf5" ,hdf5-parallel-openmpi)
458 ("lapack" ,lapack)
459 ("libxml2" ,libxml2)
460 ("openmpi" ,openmpi)
461 ("python" ,python-3)
462 ("scotch" ,pt-scotch32)
463 ("suitesparse" ,suitesparse)
464 ("sundials" ,sundials-openmpi)
465 ("zlib" ,zlib)))
466 (native-inputs
09ecd9a7 467 `(("catch" ,catch-framework2-1)
0ace6c0b
PG
468 ("pkg-config" ,pkg-config)))
469 (propagated-inputs
470 `(("ffc" ,python-fenics-ffc)
471 ("petsc" ,petsc-openmpi)
472 ("slepc" ,slepc-openmpi)))
473 (arguments
474 `(#:configure-flags
475 `("-DDOLFIN_ENABLE_DOCS:BOOL=OFF"
476 "-DDOLFIN_ENABLE_HDF5:BOOL=ON"
477 "-DDOLFIN_ENABLE_MPI:BOOL=ON"
478 "-DDOLFIN_ENABLE_PARMETIS:BOOL=OFF"
479 "-DDOLFIN_ENABLE_SCOTCH:BOOL=ON"
480 "-DDOLFIN_ENABLE_SUNDIALS:BOOL=ON"
481 "-DDOLFIN_ENABLE_TRILINOS:BOOL=OFF")
482 #:phases
483 (modify-phases %standard-phases
484 (add-after 'patch-usr-bin-file 'mpi-setup
485 ,%openmpi-setup)
486 (add-after 'patch-source-shebangs 'set-paths
487 (lambda _
488 ;; Define paths to store locations.
489 (setenv "BLAS_DIR" (assoc-ref %build-inputs "blas"))
490 (setenv "CATCH_DIR" (assoc-ref %build-inputs "catch"))
491 (setenv "LAPACK_DIR" (assoc-ref %build-inputs "lapack"))
492 (setenv "PETSC_DIR" (assoc-ref %build-inputs "petsc"))
493 (setenv "SLEPC_DIR" (assoc-ref %build-inputs "slepc"))
494 (setenv "SCOTCH_DIR" (assoc-ref %build-inputs "scotch"))
495 (setenv "SUNDIALS_DIR" (assoc-ref %build-inputs "sundials"))
69505bec 496 (setenv "UMFPACK_DIR" (assoc-ref %build-inputs "suitesparse"))))
0ace6c0b
PG
497 (add-before 'check 'pre-check
498 (lambda _
499 ;; The Dolfin repository uses git-lfs, whereby web links are
500 ;; substituted for large files. Guix does not currently support
501 ;; git-lfs, so only the links are downloaded. The tests that
502 ;; require the absent meshes cannot run and are skipped.
503 ;;
41b11c45
EB
504 ;; One serial test fails and is skipped.
505 ;; i) demo_multimesh-stokes_serial:
0ace6c0b
PG
506 ;; Warning: Found no facets matching domain for boundary
507 ;; condition.
508 ;;
509 ;; One mpi test fails and is skipped.
510 ;; i) demo_stokes-iterative_mpi:
511 ;; The MPI_Comm_rank() function was called before MPI_INIT was
512 ;; invoked
513 (call-with-output-file "CTestCustom.cmake"
514 (lambda (port)
515 (display
516 (string-append
517 "set(CTEST_CUSTOM_TESTS_IGNORE "
518 "demo_bcs_serial "
519 "demo_bcs_mpi "
520 "demo_eigenvalue_serial "
521 "demo_eigenvalue_mpi "
522 "demo_navier-stokes_serial "
523 "demo_navier-stokes_mpi "
524 "demo_stokes-taylor-hood_serial "
525 "demo_stokes-taylor-hood_mpi "
526 "demo_subdomains_serial "
527 "demo_advection-diffusion_serial "
528 "demo_advection-diffusion_mpi "
529 "demo_auto-adaptive-navier-stokes_serial "
530 "demo_contact-vi-snes_serial "
531 "demo_contact-vi-snes_mpi "
532 "demo_contact-vi-tao_serial "
533 "demo_contact-vi-tao_mpi "
534 "demo_curl-curl_serial "
535 "demo_curl-curl_mpi "
536 "demo_dg-advection-diffusion_serial "
537 "demo_dg-advection-diffusion_mpi "
538 "demo_elasticity_serial "
539 "demo_elasticity_mpi "
540 "demo_elastodynamics_serial "
541 "demo_elastodynamics_mpi "
542 "demo_lift-drag_serial "
543 "demo_lift-drag_mpi "
544 "demo_mesh-quality_serial "
545 "demo_mesh-quality_mpi "
546 "demo_multimesh-stokes_serial "
69505bec 547 ")\n") port)))))
0ace6c0b 548 (replace 'check
69505bec
PP
549 (lambda* (#:key tests? #:allow-other-keys)
550 (when tests?
551 (invoke "make" "unittests")
552 (invoke "make" "demos")
553 (invoke "ctest" "-R" "unittests")
554 (invoke "ctest" "-R" "demo" "-R" "serial")
555 (invoke "ctest" "-R" "demo" "-R" "mpi")))))))
0ace6c0b
PG
556 (home-page "https://bitbucket.org/fenics-project/dolfin/")
557 (synopsis "Problem solving environment for differential equations")
558 (description
559 "DOLFIN is a computational framework for finding numerical
560solutions to problems described by differential equations. Numerical
561models in DOLFIN are constructed using general families of finite
562elements. Data structures are provided for discretizing the governing
563system on a computational mesh. A compact syntax, similar to
564mathematical notation, is made available for defining function spaces
565and expressing variational forms. Interfaces to specialized matrix
566solvers are provided for solving the resultant linear systems.
567
568@code{fenics-dolfin} is part of the FEniCS project. It is the C++
569user interface to the FEniCS core components and external libraries.")
570 ;; The source code for the DOLFIN C++ library is licensed under the
571 ;; GNU Lesser General Public License, version 3 or later, with the
572 ;; following exceptions:
573 ;;
574 ;; public-domain: dolfin/geometry/predicates.cpp
575 ;; dolfin/geometry/predicates.h
576 ;;
577 ;; zlib: dolfin/io/base64.cpp
578 ;; dolfin/io/base64.h
579 ;;
580 ;; expat: dolfin/io/pugiconfig.hpp
581 ;; dolfin/io/pugixml.cpp
582 ;; dolfin/io/pugixml.hpp
583 (license (list license:public-domain
584 license:zlib
585 license:expat
586 license:lgpl3+))))
ae0f1dd1
PG
587
588(define-public fenics
1a265842 589 (package/inherit fenics-dolfin
ae0f1dd1
PG
590 (name "fenics")
591 (build-system python-build-system)
592 (inputs
593 `(("pybind11" ,pybind11)
594 ("python-matplotlib" ,python-matplotlib)
595 ,@(alist-delete "python" (package-inputs fenics-dolfin))))
596 (native-inputs
c69959f0 597 `(("cmake" ,cmake-minimal)
ae0f1dd1
PG
598 ("ply" ,python-ply)
599 ("pytest" ,python-pytest)
600 ("python-decorator" ,python-decorator)
601 ("python-pkgconfig" ,python-pkgconfig)
602 ,@(package-native-inputs fenics-dolfin)))
603 (propagated-inputs
604 `(("dolfin" ,fenics-dolfin)
605 ("petsc4py" ,python-petsc4py)
606 ("slepc4py" ,python-slepc4py)))
607 (arguments
608 `(#:phases
609 (modify-phases %standard-phases
b7d2644c
PP
610 (add-after 'unpack 'relax-requirements
611 (lambda _
612 (substitute* "python/setup.py"
613 (("pybind11==") "pybind11>="))))
ae0f1dd1
PG
614 (add-after 'patch-source-shebangs 'set-paths
615 (lambda _
616 ;; Define paths to store locations.
617 (setenv "PYBIND11_DIR" (assoc-ref %build-inputs "pybind11"))
618 ;; Move to python sub-directory.
1ebb629c 619 (chdir "python")))
ae0f1dd1
PG
620 (add-after 'build 'mpi-setup
621 ,%openmpi-setup)
622 (add-before 'check 'pre-check
623 (lambda _
37bb0d1e
PG
624 ;; Exclude three tests that generate
625 ;; 'NotImplementedError' in matplotlib version 3.1.2.
626 ;; See
627 ;; <https://github.com/matplotlib/matplotlib/issues/15382>.
628 ;; Also exclude tests that require meshes supplied by
629 ;; git-lfs.
ae0f1dd1
PG
630 (substitute* "demo/test.py"
631 (("(.*stem !.*)" line)
632 (string-append
633 line "\n"
634 "excludeList = [\n"
37bb0d1e
PG
635 "'built-in-meshes', \n"
636 "'hyperelasticity', \n"
637 "'elasticity', \n"
ae0f1dd1
PG
638 "'multimesh-quadrature', \n"
639 "'multimesh-marking', \n"
640 "'mixed-poisson-sphere', \n"
641 "'mesh-quality', \n"
642 "'lift-drag', \n"
643 "'elastodynamics', \n"
644 "'dg-advection-diffusion', \n"
dd6cb4a0 645 "'curl-curl', \n"
ae0f1dd1
PG
646 "'contact-vi-tao', \n"
647 "'contact-vi-snes', \n"
648 "'collision-detection', \n"
649 "'buckling-tao', \n"
650 "'auto-adaptive-navier-stokes', \n"
651 "'advection-diffusion', \n"
652 "'subdomains', \n"
653 "'stokes-taylor-hood', \n"
654 "'stokes-mini', \n"
655 "'navier-stokes', \n"
656 "'eigenvalue']\n"
657 "demos = ["
658 "d for d in demos if d[0].stem not in "
659 "excludeList]\n")))
660 (setenv "HOME" (getcwd))
ae0f1dd1 661 ;; Restrict OpenBLAS to MPI-only in preference to MPI+OpenMP.
1ebb629c 662 (setenv "OPENBLAS_NUM_THREADS" "1")))
ae0f1dd1 663 (replace 'check
9d5160bc
PP
664 (lambda* (#:key tests? #:allow-other-keys)
665 (when tests?
666 (with-directory-excursion "test"
667 ;; Note: The test test_snes_set_from_options() in the file
668 ;; unit/nls/test_PETScSNES_solver.py fails and is ignored.
669 ;; Limit the number of jobs to 3 as 500 MiB of memory is used
670 ;; per process.
671 (invoke "mpirun" "-np" (number->string
672 (min 3 (parallel-job-count)))
673 "python" "-B" "-m"
674 "pytest" "unit" "--ignore"
675 "unit/nls/test_PETScSNES_solver.py")))))
ae0f1dd1
PG
676 (add-after 'install 'install-demo-files
677 (lambda* (#:key outputs #:allow-other-keys)
678 (let* ((demos (string-append
679 (assoc-ref outputs "out")
680 "/share/python-dolfin/demo")))
681 (mkdir-p demos)
682 (with-directory-excursion "demo"
683 (for-each (lambda (file)
684 (let* ((dir (dirname file))
685 (tgt-dir (string-append demos "/" dir)))
686 (unless (equal? "." dir)
687 (mkdir-p tgt-dir)
688 (install-file file tgt-dir))))
1ebb629c 689 (find-files "." ".*\\.(py|gz|xdmf)$")))))))))
ae0f1dd1
PG
690 (home-page "https://fenicsproject.org/")
691 (synopsis "High-level environment for solving differential equations")
692 (description
693 "@code{fenics} is a computing platform for solving general classes of
694problems that involve differential equations. @code{fenics} facilitates
695access to efficient methods for dealing with ordinary differential
696equations (ODEs) and partial differential equations (PDEs). Systems of
697equations such as these are commonly encountered in areas of engineering,
698mathematics and the physical sciences. It is particularly well-suited to
699problems that can be solved using the Finite Element Method (FEM).
700
701@code{fenics} is the top level of the set of packages that are developed
702within the FEniCS project. It provides the python user interface to the
703FEniCS core components and external libraries.")
704 (license license:lgpl3+)))
40fc8992
PG
705
706(define-public fullswof-2d
707 (let ((revision 505)
708 (release "1.09.01"))
709 (package
710 (name "fullswof-2d")
711 (version release)
712 (source (origin
713 (method svn-fetch)
714 (uri (svn-reference
715 (url (string-append "https://subversion.renater.fr/"
716 "anonscm/svn/fullswof-2d/tags/"
717 "release-" version))
718 (revision revision)))
719 (file-name (string-append "fullswof-2d-" version "-checkout"))
720 (sha256
721 (base32
722 "16v08dx7h7n4wyddzbwimazwyj74ynis12mpjfkay4243npy44b8"))))
723 (build-system gnu-build-system)
724 (native-inputs
8394619b 725 (list inetutils)) ; for 'hostname', used in the check phase
40fc8992
PG
726 (arguments
727 `(#:phases
728 (modify-phases %standard-phases
729 (delete 'configure) ; no configure script
730 (add-after 'build 'build-tools
731 (lambda _
732 (with-directory-excursion "Tools/ConvertFormat"
733 (invoke "make" "../../bin/asc2xyz")
734 (invoke "make" "../../bin/xyz2asc"))
735 (with-directory-excursion "Tools/ExtractWindow"
736 (invoke "make" "../../bin/cropxyz"))
737 #t))
738 (replace 'check ; no check target
739 (lambda _
740 (invoke "make" "benchref")))
741 (replace 'install ; no install target
742 (lambda* (#:key outputs #:allow-other-keys)
743 (let* ((out (assoc-ref outputs "out"))
744 (bin (string-append out "/bin"))
745 (doc (string-append
746 out "/share/doc/" ,name "-" ,version))
747 (examples (string-append doc "/Examples")))
748 (with-directory-excursion "bin"
749 (for-each (lambda (binary) (install-file binary bin))
750 (list "asc2xyz" "xyz2asc" "cropxyz"
751 "FullSWOF_2D")))
752 (with-directory-excursion "doc"
753 (for-each (lambda (pdf) (install-file pdf doc))
754 (list "Documentation.pdf" "refman.pdf")))
755 (with-directory-excursion "Tools"
756 (for-each (lambda (dir)
757 (copy-file
758 (string-append dir "/README.txt")
759 (string-append doc "/README_" dir ".txt")))
760 (list "ConvertFormat" "ExtractWindow")))
761 (copy-recursively "Examples" examples)
762 #t))))))
763 (home-page "https://www.idpoisson.fr/fullswof/")
764 (synopsis "Two dimensional flow solver for flood modelling")
765 (description "@code{FullSWOF_2d} is a numerical tool for solving
766the shallow water equations on structured grids. The name FullSWOF
767refers to the Full form of the Shallow Water equations for Overland
768Flow. The discretized system of equations is solved using the finite
769volume method. A choice of shock-capturing methods is available to
770locate the transition boundaries between the wet areas and the dry
771areas in the model. A semi-implicit method is used to advance the
772solution in time. The tool is typically applied to the modelling of
773river flooding.")
774 (license license:cecill))))
1f519e8b
PG
775
776(define-public python-meshio
777 (package
778 (name "python-meshio")
779 (version "4.4.6")
780 (source
781 (origin
782 (method url-fetch)
783 (uri (pypi-uri "meshio" version))
784 (sha256
785 (base32
786 "0kv832s2vyff30zz8yqypw5jifwdanvh5x56d2bzkvy94h4jlddy"))
787 (snippet
c76ba276
PP
788 '(let ((file (open-file "setup.py" "a")))
789 (display "from setuptools import setup\nsetup()" file)
790 (close-port file)))))
1f519e8b
PG
791 (build-system python-build-system)
792 (inputs
4a6acd04
PP
793 (list python-h5py
794 python-netcdf4))
1f519e8b 795 (native-inputs
4a6acd04 796 (list python-pytest))
1f519e8b 797 (propagated-inputs
4a6acd04
PP
798 (list python-importlib-metadata
799 python-numpy))
1f519e8b
PG
800 (arguments
801 `(#:phases
802 (modify-phases %standard-phases
803 (replace 'check
804 (lambda* (#:key outputs inputs #:allow-other-keys)
805 (add-installed-pythonpath inputs outputs)
c76ba276 806 (invoke "python" "-m" "pytest" "-v" "tests"))))))
1f519e8b
PG
807 (home-page "https://github.com/nschloe/meshio")
808 (synopsis "I/O for mesh files")
809 (description "There are various file formats available for
810representing unstructured meshes and mesh data. The @code{meshio}
811package is able to read and write mesh files in many formats and to
812convert files from one format to another. Formats such as cgns, h5m,
813gmsh, xdmf and vtk are supported. The package provides command-line
814tools and a collection of Python modules for programmatic use.")
815 (license license:expat)))
3af31bc2
PG
816
817(define-public python-pygmsh
818 (package
819 (name "python-pygmsh")
d6c2fc37 820 (version "7.1.11")
3af31bc2
PG
821 (source
822 (origin
74b82ecd
PG
823 (method git-fetch)
824 (uri (git-reference
825 (url "https://github.com/nschloe/pygmsh")
d6c2fc37 826 (commit version)))
74b82ecd 827 (file-name (git-file-name name version))
3af31bc2
PG
828 (sha256
829 (base32
d6c2fc37 830 "0g4yllmxks7yb50vild5xi1cma0yl16vsq6rfvdwmqaj4hwxcabk"))
3af31bc2
PG
831 (modules '((guix build utils)))
832 (snippet
833 '(begin
834 (let ((file (open-file "setup.py" "a")))
835 (display "from setuptools import setup\nsetup()" file)
836 (close-port file))
d6c2fc37
PG
837 ;; A reference to setuptools in the configuration file
838 ;; triggers an attempt to download the package from pypi.
839 ;; The reference is not needed since the package is
840 ;; provided by the build system.
3af31bc2
PG
841 (substitute* "setup.cfg"
842 (("^[[:blank:]]+setuptools>=42\n") ""))
3af31bc2
PG
843 #t))))
844 (build-system python-build-system)
845 (native-inputs
846 `(("pytest" ,python-pytest)
847 ("wheel" ,python-wheel)))
848 (propagated-inputs
849 `(("importlib-metadata" ,python-importlib-metadata)
850 ("gmsh" ,gmsh)
851 ("meshio" ,python-meshio)
852 ("numpy" ,python-numpy)))
853 (arguments
854 `(#:phases
855 (modify-phases %standard-phases
856 (replace 'check
857 (lambda* (#:key inputs outputs tests? #:allow-other-keys)
858 (when tests?
859 (add-installed-pythonpath inputs outputs)
2caf9eaf 860 (invoke "python" "-m" "pytest" "-v" "tests"))
3af31bc2
PG
861 #t)))))
862 (home-page "https://github.com/nschloe/pygmsh")
863 (synopsis "Python frontend for Gmsh")
864 (description "The goal of @code{pygmsh} is to combine the power of
865Gmsh with the versatility of Python. The package generalises many of
866the methods and functions that comprise the Gmsh Python API. In this
867way the meshing of complex geometries using high-level abstractions is
868made possible. The package provides a Python library together with a
869command-line utility for mesh optimisation.")
870 (license license:lgpl3)))
b05a1eb5
PG
871
872(define-public python-dolfin-adjoint
873 (package
874 (name "python-dolfin-adjoint")
875 (version "2019.1.0")
876 (source
877 (origin
878 (method git-fetch)
879 (uri (git-reference
880 (url "https://github.com/dolfin-adjoint/pyadjoint")
881 (commit version)))
882 (file-name (git-file-name name version))
883 (sha256
884 (base32
885 "0xhy76a5f33hz94wc9g2mc5qmwkxfccbbc6yxl7psm130afp8lhn"))
886 (modules '((guix build utils)))
887 (snippet
888 '(begin
889 ;; One of the migration tests attempts to call openmpi
890 ;; recursively and fails. See
891 ;; https://bitbucket.org/mpi4py/mpi4py/issues/95. Run the
892 ;; test sequentially instead.
893 (with-directory-excursion "tests/migration/optimal_control_mms"
894 (substitute* "test_optimal_control_mms.py"
895 (("\\\"mpirun\\\", \\\"-n\\\", \\\"2\\\", ") "")))
896 ;; Result files are regenerated in the check phase.
897 (delete-file-recursively
898 "tests/migration/viscoelasticity/test-results")
899 #t))))
900 (build-system python-build-system)
901 (inputs
8394619b 902 (list fenics openmpi pybind11))
b05a1eb5 903 (native-inputs
8394619b
LC
904 (list pkg-config
905 python-coverage
906 python-decorator
907 python-flake8
908 python-pkgconfig
909 python-pytest))
b05a1eb5
PG
910 (propagated-inputs
911 `(("scipy" ,python-scipy)))
912 (arguments
913 `(#:phases
914 (modify-phases %standard-phases
915 (add-after 'build 'mpi-setup
916 ,%openmpi-setup)
917 (add-after 'install 'install-doc
918 (lambda* (#:key outputs #:allow-other-keys)
919 (let* ((doc (string-append (assoc-ref outputs "out")
920 "/share/doc/" ,name "-"
921 ,version))
922 (examples (string-append doc "/examples")))
923 (mkdir-p examples)
924 (copy-recursively "examples" examples))
925 #t))
926 (replace 'check
927 (lambda* (#:key inputs outputs tests? #:allow-other-keys)
928 (when tests?
929 (add-installed-pythonpath inputs outputs)
930 (setenv "HOME" (getcwd))
931 (and (invoke "py.test" "-v" "tests/fenics_adjoint")
932 (invoke "py.test" "-v" "tests/migration")
933 (invoke "py.test" "-v" "tests/pyadjoint")))
934 #t)))))
935 (home-page "http://www.dolfin-adjoint.org")
936 (synopsis "Automatic differentiation library")
937 (description "@code{python-dolfin-adjoint} is a solver of
938differential equations associated with a governing system and a
939functional of interest. Working from the forward model the solver
940automatically derives the discrete adjoint and tangent linear models.
941These additional models are key ingredients in many algorithms such as
942data assimilation, optimal control, sensitivity analysis, design
943optimisation and error estimation. The dolfin-adjoint project
944provides the necessary tools and data structures for cases where the
945forward model is implemented in @code{fenics} or
946@url{https://firedrakeproject.org,firedrake}.")
947 (license license:lgpl3)))