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