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