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