gnu: ruby-pandoc-ruby: Use pandoc instead of ghc-pandoc.
[jackhill/guix/guix.git] / gnu / packages / simulation.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017, 2018, 2019, 2020 Paul Garlick <pgarlick@tourbillion-technology.com>
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)
21 #:use-module (gnu packages algebra)
22 #:use-module (gnu packages admin)
23 #:use-module (gnu packages base)
24 #:use-module (gnu packages bash)
25 #:use-module (gnu packages bison)
26 #:use-module (gnu packages boost)
27 #:use-module (gnu packages check)
28 #:use-module (gnu packages cmake)
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)
42 #:use-module (gnu packages pkg-config)
43 #:use-module (gnu packages python)
44 #:use-module (gnu packages python-xyz)
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)
51 #:use-module (guix svn-download)
52 #:use-module (guix build-system cmake)
53 #:use-module (guix build-system gnu)
54 #:use-module (guix build-system python)
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"))
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))))
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)))
105 (outputs '("debug" ;~60MB
106 "out"))
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))
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))
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
227 ;; $ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
228 ;; $ cd pitzDaily
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
233 problems in the field of Computational Fluid Dynamics (CFD). It is written in
234 C++. Governing equations such as the Navier-Stokes equations can be solved in
235 integral form. Physical processes such as phase change, droplet transport and
236 chemical reaction can be modelled. Numerical methods are included to deal with
237 sharp gradients, such as those encountered in flows with shock waves and flows
238 with gas/liquid interfaces. Large problems may be split into smaller, connected
239 problems for efficient solution on parallel systems.")
240 (license license:gpl3+)
241 (home-page "https://openfoam.org")))
242
243 (define-public python-fenics-dijitso
244 (package
245 (name "python-fenics-dijitso")
246 (version "2019.1.0")
247 (source
248 (origin
249 (method url-fetch)
250 (uri (pypi-uri "fenics-dijitso" version))
251 (sha256
252 (base32
253 "0lhqsq8ypdak0ahr2jnyvg07yrqp6wicjxi6k56zx24wp3qg60sc"))))
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"
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"))
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,
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.
287
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+)))
293
294 (define-public python-fenics-ufl
295 (package
296 (name "python-fenics-ufl")
297 (version "2019.1.0")
298 (source
299 (origin
300 (method url-fetch)
301 (uri (pypi-uri "fenics-ufl" version))
302 (sha256
303 (base32
304 "10dz8x3lm68x2w3kkqcjask38h0zkhhak26jdbkppr8g9y8wny7p"))))
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
323 language for declaration of finite element discretizations of
324 variational forms. More precisely, it defines a flexible interface
325 for choosing finite element spaces and defining expressions for weak
326 forms in a notation close to mathematical notation.
327
328 UFL is part of the FEniCS Project.")
329 (license license:lgpl3+)))
330
331 (define-public python-fenics-fiat
332 (package
333 (name "python-fenics-fiat")
334 (version "2019.1.0")
335 (source
336 (origin
337 (method url-fetch)
338 (uri (pypi-uri "fenics-fiat" version))
339 (sha256
340 (base32
341 "13sc7lma3d2mh43an7i4kkdbbk4cmvxjk45wi43xnjd7qc38zg4b"))))
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"
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"))
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
370 generation of arbitrary order instances of the Lagrange elements on
371 lines, triangles, and tetrahedra. It is also capable of generating
372 arbitrary order instances of Jacobi-type quadrature rules on the same
373 element shapes. Further, H(div) and H(curl) conforming finite element
374 spaces such as the families of Raviart-Thomas, Brezzi-Douglas-Marini
375 and Nedelec are supported on triangles and tetrahedra. Upcoming
376 versions will also support Hermite and nonconforming elements.
377
378 FIAT is part of the FEniCS Project.")
379 (license license:lgpl3+)))
380
381 (define-public python-fenics-ffc
382 (package
383 (name "python-fenics-ffc")
384 (version "2019.1.0.post0")
385 (source
386 (origin
387 (method url-fetch)
388 (uri (pypi-uri "fenics-ffc" version))
389 (sha256
390 (base32
391 "1f2a44ha65fg3a1prrbrsz4dgvibsv0j5c3pi2m52zi93bhwwgg9"))))
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
420 finite element variational forms. From a high-level description of
421 the form, it generates efficient low-level C++ code that can be used
422 to assemble the corresponding discrete operator (tensor). In
423 particular, a bilinear form may be assembled into a matrix and a
424 linear form may be assembled into a vector. FFC may be used either
425 from the command line (by invoking the @code{ffc} command) or as a
426 Python module (@code{import ffc}).
427
428 FFC 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+))))
432
433 (define-public fenics-dolfin
434 (package
435 (name "fenics-dolfin")
436 (version "2019.1.0.post0")
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
446 "1m91hwcq5gfj4qqswp8l8kj58nia48f0n4kq13w0xqj4biq7rla0"))
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"
457 ;; Specify directory to find the header file.
458 (("(^set\\(CATCH_INCLUDE_DIR ).*(/catch\\))" _ front back)
459 (string-append front
460 "$ENV{CATCH_DIR}/include" back "\n")))
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
477 `(("catch" ,catch-framework2-1)
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
576 solutions to problems described by differential equations. Numerical
577 models in DOLFIN are constructed using general families of finite
578 elements. Data structures are provided for discretizing the governing
579 system on a computational mesh. A compact syntax, similar to
580 mathematical notation, is made available for defining function spaces
581 and expressing variational forms. Interfaces to specialized matrix
582 solvers are provided for solving the resultant linear systems.
583
584 @code{fenics-dolfin} is part of the FEniCS project. It is the C++
585 user 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+))))
603
604 (define-public fenics
605 (package (inherit fenics-dolfin)
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
613 `(("cmake" ,cmake-minimal)
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 _
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.
643 (substitute* "demo/test.py"
644 (("(.*stem !.*)" line)
645 (string-append
646 line "\n"
647 "excludeList = [\n"
648 "'built-in-meshes', \n"
649 "'hyperelasticity', \n"
650 "'elasticity', \n"
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"
658 "'curl-curl', \n"
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.
687 (and (invoke "py.test" "unit" "--ignore"
688 "unit/nls/test_PETScSNES_solver.py")
689 (invoke "mpirun" "-np" "3" "python" "-B" "-m"
690 "pytest" "unit" "--ignore"
691 "unit/nls/test_PETScSNES_solver.py")))
692 (with-directory-excursion "demo"
693 ;; Check demos.
694 (invoke "python" "generate-demo-files.py")
695 (and (invoke "python" "-m" "pytest" "-v" "test.py")
696 (invoke "python" "-m" "pytest" "-v" "test.py"
697 "--mpiexec=mpiexec" "--num-proc=3")))
698 #t))
699 (add-after 'install 'install-demo-files
700 (lambda* (#:key outputs #:allow-other-keys)
701 (let* ((demos (string-append
702 (assoc-ref outputs "out")
703 "/share/python-dolfin/demo")))
704 (mkdir-p demos)
705 (with-directory-excursion "demo"
706 (for-each (lambda (file)
707 (let* ((dir (dirname file))
708 (tgt-dir (string-append demos "/" dir)))
709 (unless (equal? "." dir)
710 (mkdir-p tgt-dir)
711 (install-file file tgt-dir))))
712 (find-files "." ".*\\.(py|gz|xdmf)$"))))
713 #t)))))
714 (home-page "https://fenicsproject.org/")
715 (synopsis "High-level environment for solving differential equations")
716 (description
717 "@code{fenics} is a computing platform for solving general classes of
718 problems that involve differential equations. @code{fenics} facilitates
719 access to efficient methods for dealing with ordinary differential
720 equations (ODEs) and partial differential equations (PDEs). Systems of
721 equations such as these are commonly encountered in areas of engineering,
722 mathematics and the physical sciences. It is particularly well-suited to
723 problems that can be solved using the Finite Element Method (FEM).
724
725 @code{fenics} is the top level of the set of packages that are developed
726 within the FEniCS project. It provides the python user interface to the
727 FEniCS core components and external libraries.")
728 (license license:lgpl3+)))
729
730 (define-public fullswof-2d
731 (let ((revision 505)
732 (release "1.09.01"))
733 (package
734 (name "fullswof-2d")
735 (version release)
736 (source (origin
737 (method svn-fetch)
738 (uri (svn-reference
739 (url (string-append "https://subversion.renater.fr/"
740 "anonscm/svn/fullswof-2d/tags/"
741 "release-" version))
742 (revision revision)))
743 (file-name (string-append "fullswof-2d-" version "-checkout"))
744 (sha256
745 (base32
746 "16v08dx7h7n4wyddzbwimazwyj74ynis12mpjfkay4243npy44b8"))))
747 (build-system gnu-build-system)
748 (native-inputs
749 `(("inetutils" ,inetutils))) ; for 'hostname', used in the check phase
750 (arguments
751 `(#:phases
752 (modify-phases %standard-phases
753 (delete 'configure) ; no configure script
754 (add-after 'build 'build-tools
755 (lambda _
756 (with-directory-excursion "Tools/ConvertFormat"
757 (invoke "make" "../../bin/asc2xyz")
758 (invoke "make" "../../bin/xyz2asc"))
759 (with-directory-excursion "Tools/ExtractWindow"
760 (invoke "make" "../../bin/cropxyz"))
761 #t))
762 (replace 'check ; no check target
763 (lambda _
764 (invoke "make" "benchref")))
765 (replace 'install ; no install target
766 (lambda* (#:key outputs #:allow-other-keys)
767 (let* ((out (assoc-ref outputs "out"))
768 (bin (string-append out "/bin"))
769 (doc (string-append
770 out "/share/doc/" ,name "-" ,version))
771 (examples (string-append doc "/Examples")))
772 (with-directory-excursion "bin"
773 (for-each (lambda (binary) (install-file binary bin))
774 (list "asc2xyz" "xyz2asc" "cropxyz"
775 "FullSWOF_2D")))
776 (with-directory-excursion "doc"
777 (for-each (lambda (pdf) (install-file pdf doc))
778 (list "Documentation.pdf" "refman.pdf")))
779 (with-directory-excursion "Tools"
780 (for-each (lambda (dir)
781 (copy-file
782 (string-append dir "/README.txt")
783 (string-append doc "/README_" dir ".txt")))
784 (list "ConvertFormat" "ExtractWindow")))
785 (copy-recursively "Examples" examples)
786 #t))))))
787 (home-page "https://www.idpoisson.fr/fullswof/")
788 (synopsis "Two dimensional flow solver for flood modelling")
789 (description "@code{FullSWOF_2d} is a numerical tool for solving
790 the shallow water equations on structured grids. The name FullSWOF
791 refers to the Full form of the Shallow Water equations for Overland
792 Flow. The discretized system of equations is solved using the finite
793 volume method. A choice of shock-capturing methods is available to
794 locate the transition boundaries between the wet areas and the dry
795 areas in the model. A semi-implicit method is used to advance the
796 solution in time. The tool is typically applied to the modelling of
797 river flooding.")
798 (license license:cecill))))