projects/guix·blob bootstrap-team · refs

1708 lines · 76.5 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2017, 2018, 2019, 2020, 2021 Paul Garlick <[email protected]>
3;;; Copyright © 2021, 2022 Maxim Cournoyer <[email protected]>
4;;; Copyright © 2022 Eric Bavier <[email protected]>
5;;; Copyright © 2022 Liliana Marie Prikler <[email protected]>
6;;; Copyright © 2023 Reza Housseini <[email protected]>
7;;; Copyright © 2024 Ricardo Wurmus <[email protected]>
8;;; Copyright © 2024-2025 Sharlatan Hellseher <[email protected]>
9;;; Copyright © 2025 Francisco-Galindo <[email protected]>
10;;;
11;;; This file is part of GNU Guix.
12;;;
13;;; GNU Guix is free software; you can redistribute it and/or modify it
14;;; under the terms of the GNU General Public License as published by
15;;; the Free Software Foundation; either version 3 of the License, or (at
16;;; your option) any later version.
17;;;
18;;; GNU Guix is distributed in the hope that it will be useful, but
19;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21;;; GNU General Public License for more details.
22;;;
23;;; You should have received a copy of the GNU General Public License
24;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26(define-module (gnu packages simulation)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages algebra)
29 #:use-module (gnu packages admin)
30 #:use-module (gnu packages base)
31 #:use-module (gnu packages bash)
32 #:use-module (gnu packages bison)
33 #:use-module (gnu packages boost)
34 #:use-module (gnu packages check)
35 #:use-module (gnu packages cmake)
36 #:use-module (gnu packages compression)
37 #:use-module (gnu packages cpp)
38 #:use-module (gnu packages curl)
39 #:use-module (gnu packages engineering)
40 #:use-module (gnu packages flex)
41 #:use-module (gnu packages fontutils)
42 #:use-module (gnu packages gettext)
43 #:use-module (gnu packages gcc)
44 #:use-module (gnu packages geo)
45 #:use-module (gnu packages gl)
46 #:use-module (gnu packages graphics)
47 #:use-module (gnu packages gtk)
48 #:use-module (gnu packages image)
49 #:use-module (gnu packages iso-codes)
50 #:use-module (gnu packages image-processing)
51 #:use-module (gnu packages linux)
52 #:use-module (gnu packages m4)
53 #:use-module (gnu packages maths)
54 #:use-module (gnu packages mpi)
55 #:use-module (gnu packages multiprecision)
56 #:use-module (gnu packages ncurses)
57 #:use-module (gnu packages pdf)
58 #:use-module (gnu packages pkg-config)
59 #:use-module (gnu packages pretty-print)
60 #:use-module (gnu packages protobuf)
61 #:use-module (gnu packages python)
62 #:use-module (gnu packages python-build)
63 #:use-module (gnu packages python-science)
64 #:use-module (gnu packages python-xyz)
65 #:use-module (gnu packages qt)
66 #:use-module (gnu packages readline)
67 #:use-module (gnu packages serialization)
68 #:use-module (gnu packages sqlite)
69 #:use-module (gnu packages ssh)
70 #:use-module (gnu packages textutils)
71 #:use-module (gnu packages tls)
72 #:use-module (gnu packages version-control)
73 #:use-module (gnu packages video)
74 #:use-module (gnu packages xiph)
75 #:use-module (gnu packages xml)
76 #:use-module (gnu packages xorg)
77 #:use-module (guix download)
78 #:use-module (guix gexp)
79 #:use-module (guix git-download)
80 #:use-module (guix svn-download)
81 #:use-module (guix build-system cmake)
82 #:use-module (guix build-system gnu)
83 #:use-module (guix build-system pyproject)
84 #:use-module (guix build-system python)
85 #:use-module ((guix licenses) #:prefix license:)
86 #:use-module (guix packages)
87 #:use-module (guix gexp)
88 #:use-module (guix utils)
89 #:use-module (ice-9 ftw)
90 #:use-module (ice-9 match)
91 #:use-module (ice-9 regex)
92 #:use-module (srfi srfi-1))
93
94(define-public openfoam-org
95 (package
96 (name "openfoam-org")
97 (version "13")
98 (source
99 (origin
100 (method git-fetch)
101 (uri (git-reference
102 (url "https://github.com/OpenFOAM/OpenFOAM-dev")
103 (commit (string-append "version-" version))))
104 (file-name (git-file-name name version))
105 (sha256
106 (base32 "10s1x82znfnwspq5iif928j1ks4v0slmmycg6py8xw1vvhjp7arh"))))
107 (build-system gnu-build-system)
108 (native-inputs (list bison flex git))
109 (inputs (list bash-completion
110 boost
111 cgal
112 cgns
113 cli11
114 cmake-minimal
115 coreutils
116 curl
117 double-conversion
118 eigen
119 expat
120 ffmpeg
121 findutils
122 fmt-11
123 freetype
124 gdal
125 gl2ps
126 glew
127 gmp
128 gmsh
129 gnuplot
130 hdf5
131 jsoncpp
132 libjpeg-turbo
133 libogg
134 libpng
135 libharu
136 libtheora
137 libtiff
138 libx11
139 libxml2
140 libxslt
141 libxt
142 lz4
143 metis
144 mpfr
145 ncurses
146 netcdf
147 nlohmann-json
148 openmpi
149 paraview
150 proj
151 protobuf
152 pt-scotch32
153 pugixml
154 python
155 python-mpi4py
156 qt5compat
157 qtbase
158 qtsvg
159 qttools
160 qtwebengine
161 readline
162 trilinos-zoltan
163 utfcpp
164 vtk
165 xz
166 zlib))
167 (outputs '("debug" ;~60MB
168 "out"))
169 (arguments
170 (list
171 ;; Executable files and shared libraries are located in the 'platforms'
172 ;; subdirectory.
173 #:strip-directories
174 #~(list (string-append "OpenFOAM-"
175 #$(package-version this-package)
176 "/platforms/linux64GccDPInt32Opt/bin")
177 (string-append "OpenFOAM-"
178 #$(package-version this-package)
179 "/platforms/linux64GccDPInt32Opt/lib"))
180
181 #:modules '((ice-9 ftw)
182 (ice-9 regex)
183 (ice-9 string-fun)
184 (srfi srfi-1)
185 (guix build gnu-build-system)
186 (guix build utils))
187
188 #:phases
189 #~(modify-phases %standard-phases
190 (add-after 'unpack 'rename-self
191 (lambda _
192 (let* ((old-build-path (getcwd))
193 (root-path (canonicalize-path (string-append
194 old-build-path "/..")))
195 (new-build-path (string-append root-path "/OpenFOAM-"
196 #$(package-version
197 this-package))))
198 (chdir root-path)
199 (rename-file old-build-path new-build-path)
200 (chdir new-build-path))))
201 (add-before 'configure 'patch-version
202 (lambda _
203 (substitute* "etc/bashrc"
204 (("export WM_PROJECT_VERSION=.*$")
205 (string-append "export WM_PROJECT_VERSION="
206 #$(package-version this-package) "\n")))))
207 (add-before 'configure 'patch-foamcleanpath
208 (lambda _
209 (substitute* "bin/foamCleanPath"
210 (("getconf")
211 (which "getconf")))))
212 (add-before 'configure 'patch-shell-path
213 (lambda _
214 (substitute* "wmake/makefiles/general"
215 (("/bin/sh")
216 (which "sh")))))
217 ;; needed for tests
218 (add-before 'configure 'patch-HOME-path
219 (lambda _
220 (setenv "HOME" "/tmp")))
221 (add-before 'configure 'patch-bash-completion
222 (lambda _
223 (substitute* "etc/bashrc"
224 ;; do not source bash_completion (gives error)
225 (("^.*bash_completion.*$" all)
226 (string-append "#" all)))))
227 (add-before 'configure 'patch-rpaths
228 (lambda _
229 (letrec* ((libraries '(#$(this-package-input "boost")
230 #$(this-package-input "cgal")
231 #$(this-package-input "gmp")
232 #$(this-package-input "metis")
233 #$(this-package-input "mpfr")
234 #$(this-package-input "pt-scotch32")
235 #$(this-package-input "openmpi")
236 #$(this-package-input "zlib")
237 #$(this-package-input "paraview")))
238 (rpaths (fold-right (lambda (lib rpaths)
239 (string-append rpaths "-rpath="
240 lib "/lib,")) ""
241 libraries))
242 (openfoam-lib (string-append #$output
243 "/share/OpenFOAM-"
244 #$(package-version this-package)
245 "/platforms/linux64GccDPInt32Opt/lib"))
246 (ldflags (string-append "-Wl,"
247 rpaths
248 "-rpath="
249 openfoam-lib
250 ","
251 "-rpath="
252 openfoam-lib
253 "/dummy,"
254 "-rpath="
255 openfoam-lib
256 "/paraview-"
257 #$(version-major+minor (package-version
258 (this-package-input
259 "paraview"))))))
260 (substitute* "wmake/rules/linux64Gcc/c++"
261 (("-fPIC" all)
262 (string-append all " " ldflags))))))
263 (add-before 'configure 'patch-paraview
264 (lambda _
265 (substitute* "etc/config.sh/paraview"
266 (("ldd")
267 (which "ldd")))
268 (substitute* "bin/paraFoam"
269 (("paraview \"\\$@\"")
270 (string-append #$paraview "/bin/paraview \"$@\"")))))
271 (add-before 'configure 'patch-mpi
272 (lambda _
273 (substitute* "etc/config.sh/mpi"
274 (("mpicc")
275 (string-append #$(this-package-input "openmpi") "/bin/mpicc")))))
276 (add-before 'configure 'patch-paraview
277 (lambda _
278 (substitute* "etc/config.sh/paraview"
279 (("\\$paraviewBinDir/paraview")
280 "$paraviewBinDir/.paraview-real")
281 (("libpqCore-pv")
282 "libpqCore"))))
283 (add-before 'configure 'patch-vtk-include-path
284 (lambda _
285 (let* ((vtk-version #$(version-major+minor (package-version (this-package-input
286 "vtk"))))
287 (vtk-inc (string-append #$(this-package-input "vtk")
288 "/include/vtk-" vtk-version))
289 (vtk-inc-flag (string-append "-I" vtk-inc)))
290 (substitute* "wmake/makefiles/general"
291 (("SYS_INC =" all)
292 (string-append all " " vtk-inc-flag))))))
293 (replace 'configure
294 (lambda _
295 (substitute* "etc/bashrc"
296 (("export ParaView_TYPE=.*$")
297 "export ParaView_TYPE=system\n")
298 (("export SCOTCH_TYPE=.*$")
299 "export SCOTCH_TYPE=system\n")
300 (("export METIS_TYPE=.*$")
301 "export METIS_TYPE=system\n")
302 (("export ZOLTAN_TYPE=.*$")
303 "export ZOLTAN_TYPE=system\n"))
304 (substitute* "etc/config.sh/scotch"
305 (("export SCOTCH_ARCH_PATH=.*$")
306 (string-append "export SCOTCH_ARCH_PATH="
307 #$(this-package-input "pt-scotch32") "\n")))
308 (substitute* "etc/config.sh/metis"
309 (("export METIS_ARCH_PATH=.*$")
310 (string-append "export METIS_ARCH_PATH="
311 #$(this-package-input "metis") "\n")))
312 (substitute* "etc/config.sh/zoltan"
313 (("export ZOLTAN_ARCH_PATH=.*$")
314 (string-append "export ZOLTAN_ARCH_PATH="
315 #$(this-package-input "trilinos-zoltan") "\n")))))
316 (replace 'build
317 (lambda _
318 ;; compile OpenFOAM libraries and applications
319 (invoke "bash" "-c"
320 (format #f "source ./etc/bashrc && ./Allwmake -j~a"
321 (parallel-job-count)))))
322 (add-after 'build 'cleanup
323 ;; Avoid unnecessary, voluminous object and dep files.
324 (lambda _
325 (when (file-exists? "platforms/linux64GccDPInt32Opt/src")
326 (delete-file-recursively "platforms/linux64GccDPInt32Opt/src"))
327 (when (file-exists?
328 "platforms/linux64GccDPInt32OptSYSTEMOPENMPI")
329 (delete-file-recursively
330 "platforms/linux64GccDPInt32OptSYSTEMOPENMPI"))
331 (for-each delete-file
332 (find-files "." "\\.o$"))
333 (for-each delete-file
334 (find-files "." "\\.dep$"))
335 ;; Remove spurious files in src tree
336 ;; (invoke "bash" "-c" "source ./etc/bashrc && wclean all")
337 ))
338 (add-before 'check 'disable-failing-tests
339 (lambda _
340 ;; disable failing test
341 (substitute* "test/postProcessing/channel/Allrun"
342 (("^.*foam.*$" all)
343 (string-append "#" all "\n")))
344 (substitute* "test/Lagrangian/boundaries/system/decomposeParDict"
345 (("numberOfSubdomains 6")
346 "numberOfSubdomains 4")
347 (("n \\(3 2 1\\)")
348 "n (2 2 1)"))
349 (substitute* "test/Lagrangian/parabolic/system/decomposeParDict"
350 (("numberOfSubdomains 6")
351 "numberOfSubdomains 4")
352 (("n \\(3 2 1\\)")
353 "n (2 2 1)"))))
354 (replace 'check
355 (lambda* (#:key tests? #:allow-other-keys)
356 (when tests?
357 (when (file-exists? "test")
358 (with-directory-excursion "test"
359 (invoke "bash" "-c"
360 (format #f "source ../etc/bashrc && ./Allrun -j~a"
361 (parallel-job-count)))))
362 ;; too many tutorials are failing
363 ;; (with-directory-excursion "tutorials"
364 ;; (invoke "bash" "-c" "source ../etc/bashrc && ./Alltest"))
365 )))
366 (replace 'install
367 (lambda _
368 (let ((install-path (string-append #$output "/share/OpenFOAM-"
369 #$(package-version
370 this-package))))
371 (mkdir-p install-path) ;create install directory
372 ;; move contents of build directory to install directory
373 (copy-recursively "." install-path))))
374 (add-after 'install 'add-symbolic-link
375 (lambda _
376 (let* ((bin (string-append #$output "/bin"))
377 (lib (string-append #$output "/lib"))
378 (etc (string-append #$output "/etc"))
379 (openfoam (string-append #$output "/share/OpenFOAM-"
380 #$(package-version this-package)))
381 (build-bin (string-append openfoam
382 "/platforms/linux64GccDPInt32Opt/bin"))
383 (build-lib (string-append openfoam
384 "/platforms/linux64GccDPInt32Opt/lib"))
385 (foam-bin (string-append openfoam "/bin")))
386 ;; add symbolic links in standard 'bin' directory
387 (mkdir-p bin)
388 (for-each (lambda (file)
389 (symlink file
390 (string-append bin "/"
391 (basename file))))
392 (find-files build-bin))
393 (for-each (lambda (file)
394 (symlink file
395 (string-append bin "/"
396 (basename file))))
397 (find-files foam-bin))
398 ;; add symbolic link for standard 'lib' directory
399 (symlink build-lib lib)
400 ;; add symbolic link for bashrc file
401 (mkdir-p etc)
402 (symlink (string-append openfoam "/etc/bashrc")
403 (string-append etc "/bashrc"))) #t))
404 (add-after 'add-symbolic-link 'wrap
405 (lambda* (#:key python inputs outputs #:allow-other-keys)
406 (let* ((bin (string-append #$output "/bin"))
407 (openfoam-version #$(package-version this-package))
408 (openfoam-root (string-append #$output "/share/OpenFOAM-"
409 openfoam-version))
410 (openmpi-version #$(package-version (this-package-input
411 "openmpi")))
412 (paraview-version #$(package-version (this-package-input
413 "paraview")))
414 (paraview-version-major+minor #$(version-major+minor (package-version
415 (this-package-input
416 "paraview")))))
417 (for-each (lambda (program)
418 ;; wrap the programs with all the variables created by sourcing
419 ;; etc/bashrc
420 (wrap-program program
421 `("WM_PROJECT_INST_DIR" =
422 (,openfoam-root))
423 `("WM_PROJECT_DIR" =
424 (,openfoam-root))
425 '("WM_PROJECT" =
426 ("OpenFOAM"))
427 `("WM_PROJECT_VERSION" =
428 (,openfoam-version))
429 '("WM_COMPILER_TYPE" =
430 ("system"))
431 '("WM_COMPILER" =
432 ("Gcc"))
433 '("WM_ARCH_OPTION" =
434 ("64"))
435 '("WM_PRECISION_OPTION" =
436 ("DP"))
437 '("WM_LABEL_SIZE" =
438 ("32"))
439 '("WM_COMPILE_OPTION" =
440 ("Opt"))
441 '("WM_MPLIB" =
442 ("SYSTEMOPENMPI"))
443 '("WM_OSTYPE" =
444 ("POSIX"))
445 '("WM_OPTIONS" =
446 ("linux64GccDPInt32Opt"))
447 `("WM_PROJECT_USER_DIR" =
448 (,(string-append "$HOME/OpenFOAM/$USER-"
449 openfoam-version)))
450 `("WM_THIRD_PARTY_DIR" =
451 (,(string-append openfoam-root "/ThirdParty-"
452 openfoam-version)))
453 '("WM_LABEL_OPTION" =
454 ("Int32"))
455 '("WM_LINK_LANGUAGE" =
456 ("c++"))
457 '("WM_COMPILER_LIB_ARCH" =
458 ("64"))
459 `("WM_DIR" =
460 (,(string-append openfoam-root "/wmake")))
461 '("WM_LDFLAGS" =
462 ("-m64"))
463 '("WM_CC" =
464 ("gcc"))
465 '("WM_CFLAGS" =
466 ("-m64 -fPIC"))
467 '("WM_CXX" =
468 ("g++"))
469 '("WM_CXXFLAGS" =
470 ("-m64 -fPIC -std=c++0x"))
471
472 `("FOAM_INST_DIR" =
473 (,openfoam-root))
474 `("FOAM_APP" =
475 (,(string-append openfoam-root "/applications")))
476 `("FOAM_SRC" =
477 (,(string-append openfoam-root "/src")))
478 `("FOAM_ETC" =
479 (,(string-append openfoam-root "/etc")))
480 `("FOAM_TUTORIALS" =
481 (,(string-append openfoam-root "/tutorials")))
482 `("FOAM_UTILITIES" =
483 (,(string-append openfoam-root
484 "/applications/utilities")))
485 `("FOAM_SOLVERS" =
486 (,(string-append openfoam-root
487 "/applications/solvers")))
488 `("FOAM_MPI" =
489 (,(string-append "openmpi-" openmpi-version)))
490 `("FOAM_RUN" =
491 (,(string-append "$HOME/OpenFOAM/$USER-"
492 openfoam-version "/run")))
493 `("FOAM_EXT_LIBBIN" =
494 (,(string-append openfoam-root "/ThirdParty-"
495 openfoam-version
496 "/platforms/linux64GccDPInt32/lib")))
497 `("FOAM_APPBIN" =
498 (,(string-append openfoam-root
499 "/platforms/linux64GccDPInt32Opt/bin")))
500 `("FOAM_JOB_DIR" =
501 (,(string-append openfoam-root "/jobControl")))
502 `("FOAM_LIBBIN" =
503 (,(string-append openfoam-root
504 "/platforms/linux64GccDPInt32Opt/lib")))
505 `("FOAM_SITE_LIBBIN" =
506 (,(string-append openfoam-root "/site/"
507 openfoam-version
508 "/platforms/linux64GccDPInt32Opt/lib")))
509 `("FOAM_SITE_APPBIN" =
510 (,(string-append openfoam-root "/site/"
511 openfoam-version
512 "/platforms/linux64GccDPInt32Opt/bin")))
513 `("FOAM_USER_LIBBIN" =
514 (,(string-append "$HOME/OpenFOAM/$USER-"
515 openfoam-version
516 "/platforms/linux64GccDPInt32Opt/lib")))
517 `("FOAM_USER_APPBIN" =
518 (,(string-append "$HOME/OpenFOAM/$USER-"
519 openfoam-version
520 "/platforms/linux64GccDPInt32Opt/bin")))
521 `("FOAM_MODULES" =
522 (,(string-append openfoam-root
523 "/applications/modules")))
524 '("FOAM_SIGFPE" =
525 (""))
526 '("FOAM_SETTINGS" =
527 (""))
528
529 `("ParaView_INCLUDE_DIR" =
530 (,(string-append #$(this-package-input
531 "paraview")
532 "/include/paraview-"
533 paraview-version-major+minor)))
534 '("ParaView_GL" =
535 ("mesa"))
536 `("ParaView_VERSION" =
537 (,paraview-version))
538 `("ParaView_MAJOR" =
539 (,paraview-version-major+minor))
540 `("ParaView_DIR" =
541 (,#$(this-package-input "paraview")))
542 `("PV_PLUGIN_PATH" =
543 (,(string-append openfoam-root
544 "/platforms/linux64GccDPInt32Opt/lib/paraview-"
545 paraview-version-major+minor)))
546
547 `("MPI_ARCH_PATH" =
548 (,#$(this-package-input "openmpi")))
549 `("OPAL_PREFIX" =
550 (,#$(this-package-input "openmpi")))
551 '("MPI_BUFFER_SIZE" =
552 ("20000000"))
553
554 `("LD_LIBRARY_PATH" prefix
555 (,(string-append openfoam-root "/ThirdParty-"
556 openfoam-version
557 "/platforms/linux64Gcc/gperftools-svn/lib") ,
558 (string-append #$(this-package-input
559 "paraview") "/lib")
560 ,(string-append openfoam-root
561 "/platforms/linux64GccDPInt32Opt/lib/openmpi-"
562 openmpi-version)
563 ,(string-append openfoam-root "/ThirdParty-"
564 openfoam-version
565 "/platforms/linux64GccDPInt32/lib/openmpi-"
566 openmpi-version)
567 ,(string-append #$(this-package-input
568 "openmpi") "/lib")
569 ,(string-append #$(this-package-input
570 "openmpi") "/lib64")
571 ,(string-append "$HOME/OpenFOAM/$USER-"
572 openfoam-version
573 "/platforms/linux64GccDPInt32Opt/lib")
574 ,(string-append openfoam-root "/site/"
575 openfoam-version
576 "/platforms/linux64GccDPInt32Opt/lib")
577 ,(string-append openfoam-root
578 "/platforms/linux64GccDPInt32Opt/lib")
579 ,(string-append openfoam-root "/ThirdParty-"
580 openfoam-version
581 "/platforms/linux64GccDPInt32/lib")
582 ,(string-append openfoam-root
583 "/platforms/linux64GccDPInt32Opt/lib/openmpi-system")))
584 `("PATH" prefix
585 (,(string-append openfoam-root "/ThirdParty-"
586 openfoam-version
587 "/platforms/linux64Gcc/gperftools-svn/bin") ,
588 (string-append #$(this-package-input
589 "paraview") "/bin")
590 ,(string-append openfoam-root "/ThirdParty-"
591 openfoam-version
592 "/platforms/linux64Gcc/cmake-*/bin")
593 ,(string-append #$(this-package-input
594 "openmpi") "/bin")
595 ,(string-append openfoam-root "/bin")
596 ,(string-append openfoam-root "/wmake")
597 ,(string-append "$HOME/OpenFOAM/$USER-"
598 openfoam-version
599 "/platforms/linux64GccDPInt32Opt/bin")
600 ,(string-append openfoam-root "/site/"
601 openfoam-version
602 "/platforms/linux64GccDPInt32Opt/bin")
603 ,(string-append openfoam-root
604 "/platforms/linux64GccDPInt32Opt/bin")))))
605 (find-files bin))))))))
606 ;; Note:
607 ;; Tutorial files are installed read-only in /gnu/store.
608 ;; To allow write permissions on files copied from the store a
609 ;; 'chmod' step is needed before running the applications. For
610 ;; example, from a user's login:
611 ;; $ source $(foamEtcFile bashrc)
612 ;; $ mkdir -p $FOAM_RUN
613 ;; $ cd $FOAM_RUN
614 ;; $ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
615 ;; $ cd pitzDaily
616 ;; $ chmod -R u+w .
617 ;; $ blockMesh
618 (home-page "https://openfoam.org")
619 (synopsis "Framework for numerical simulation of fluid flow")
620 (description
621 "OpenFOAM provides a set of solvers and methods for tackling
622problems in the field of Computational Fluid Dynamics (CFD). It is written in
623C++. Governing equations such as the Navier-Stokes equations can be solved in
624integral form. Physical processes such as phase change, droplet transport and
625chemical reaction can be modelled. Numerical methods are included to deal with
626sharp gradients, such as those encountered in flows with shock waves and flows
627with gas/liquid interfaces. Large problems may be split into smaller, connected
628problems for efficient solution on parallel systems.")
629 (license license:gpl3+)))
630
631(define-public openfoam-com
632 ;; This is a fork of 'openfoam-org', maintained separately.
633 (package
634 (inherit openfoam-org)
635 (name "openfoam-com")
636 (version "2506")
637 (source
638 (origin
639 (method git-fetch)
640 (uri (git-reference
641 (url "https://gitlab.com/openfoam/core/openfoam")
642 (commit (string-append "OpenFOAM-v" version))))
643 (file-name (git-file-name name version))
644 (sha256
645 (base32 "1g8cjiqkk4yp5kmxyv8z43aaalr5459i54yaqmkn6qr38cjrhnd2"))))
646 (arguments
647 ;; Since 'arguments' is a function of the package's version, define
648 ;; 'parent' such that the 'arguments' thunk gets to see the right
649 ;; version.
650 (let ((parent (package
651 (inherit openfoam-org)
652 (version (package-version this-package)))))
653 (substitute-keyword-arguments (package-arguments parent)
654 ((#:phases phases)
655 #~(modify-phases #$phases
656 (delete 'disable-failing-tests))))))
657 (synopsis
658 "Framework for numerical simulation of fluid flow (from openfoam.com)")
659 (home-page "https://www.openfoam.com")))
660
661(define-public open-simulation-interface
662 (package
663 (name "open-simulation-interface")
664 (version "3.5.0")
665 (source (origin
666 (method git-fetch)
667 (uri (git-reference
668 (url (string-append "https://github.com/"
669 "OpenSimulationInterface/"
670 "open-simulation-interface"))
671 (commit (string-append "v" version))))
672 (file-name (git-file-name name version))
673 (sha256
674 (base32
675 "09vclrvsawx608kk0vnzywr71xn11qzwxzh2j508zjfn0kvhyx7q"))))
676 (build-system cmake-build-system)
677 (arguments (list #:tests? #f ; tests are for the python package
678 #:phases
679 #~(modify-phases %standard-phases
680 (add-after 'unpack 'fix-cmake
681 (lambda _
682 (substitute* "CMakeLists.txt"
683 (("-targets\\.cmake") "_targets.cmake")))))))
684 (native-inputs (list protobuf))
685 (home-page
686 "https://github.com/OpenSimulationInterface/open-simulation-interface")
687 (synopsis "Generic interface for environmental perception")
688 (description "The Open Simulation Interface is a generic interface based on
689Google's protocol buffers for the environmental perception of automated driving
690functions in virtual scenarios.")
691 (license license:mpl2.0)))
692
693(define-public python-open-simulation-interface
694 (package/inherit open-simulation-interface
695 (name "python-open-simulation-interface")
696 (build-system pyproject-build-system)
697 (arguments '())
698 (native-inputs
699 (modify-inputs (package-native-inputs open-simulation-interface)
700 (append python-pytest python-setuptools)))
701 (propagated-inputs
702 (list python-pyyaml
703 python-protobuf))))
704
705(define-public esmini
706 (package
707 (name "esmini")
708 (version "2.37.11")
709 (source (origin
710 (method git-fetch)
711 (uri (git-reference
712 (url "https://github.com/esmini/esmini")
713 (commit (string-append "v" version))))
714 (file-name (git-file-name name version))
715 (patches (search-patches "esmini-use-pkgconfig.patch"))
716 (modules '((guix build utils) (ice-9 ftw)))
717 (snippet
718 #~(with-directory-excursion "externals"
719 (for-each
720 (lambda (dir) (unless (member dir '("." ".." "expr"))
721 (delete-file-recursively dir)))
722 (scandir "."))))
723 (sha256
724 (base32
725 "07pwa34nf0b4ihb9fn1pvfi0b39hd8r630nfa6v3a17dsy66a730"))))
726 (build-system cmake-build-system)
727 (arguments
728 (list
729 #:configure-flags
730 #~(list "-DDYN_PROTOBUF=TRUE"
731 ;; Missing implot package
732 "-DUSE_IMPLOT=FALSE")
733 #:phases
734 #~(modify-phases %standard-phases
735 (add-after 'unpack 'fix-cmake
736 (lambda* (#:key inputs outputs #:allow-other-keys)
737 (substitute* "support/cmake/common/locations.cmake"
738 (("\\$\\{CMAKE_SOURCE_DIR\\}/bin")
739 (string-append (assoc-ref outputs "out") "/bin")))))
740 (replace 'check
741 (lambda* (#:key tests? #:allow-other-keys)
742 (with-directory-excursion "EnvironmentSimulator/Unittest/"
743 (for-each invoke (find-files "_test$")))))
744 (add-after 'install 'move-libraries
745 (lambda* (#:key outputs #:allow-other-keys)
746 (let ((out (assoc-ref outputs "out")))
747 (mkdir-p (string-append out "/lib"))
748 (with-directory-excursion (string-append out "/bin")
749 (for-each
750 (lambda (f)
751 (rename-file f (string-append out "/lib/"
752 (basename f))))
753 (find-files "." "\\.(a|so)$")))))))))
754 (inputs (list mesa
755 openscenegraph `(,openscenegraph "pluginlib")
756 open-simulation-interface
757 protobuf pugixml sumo))
758 (native-inputs (list googletest pkg-config))
759 (home-page "https://github.com/esmini/esmini")
760 (synopsis "Basic OpenSCENARIO player")
761 (description "@command{esmini} is a tool to play OpenSCENARIO files.
762It is provided as both a standalone application and a shared library and has
763some support for generating and analysing traffic scenarios..")
764 (license license:mpl2.0)))
765
766(define-public python-fenics-dijitso
767 (package
768 (name "python-fenics-dijitso")
769 (version "2019.1.0")
770 (source
771 (origin
772 (method url-fetch)
773 (uri (pypi-uri "fenics-dijitso" version))
774 (sha256
775 (base32 "0lhqsq8ypdak0ahr2jnyvg07yrqp6wicjxi6k56zx24wp3qg60sc"))))
776 (build-system pyproject-build-system)
777 (arguments
778 (list
779 #:phases
780 #~(modify-phases %standard-phases
781 (add-after 'build 'mpi-setup
782 #$%openmpi-setup)
783 (replace 'check
784 (lambda* (#:key tests? #:allow-other-keys)
785 (when tests?
786 (setenv "HOME" "/tmp")
787 (with-directory-excursion "test"
788 ;; Disable parallel tests to avoid race condition. See
789 ;; https://github.com/pytest-dev/pytest-cov/issues/237.
790 (substitute* "runtests.sh"
791 (("for p in 1 4 8 16; do") "for p in 1; do"))
792 (invoke "./runtests.sh"))))))))
793 (native-inputs
794 (list python-pytest
795 python-pytest-cov
796 python-setuptools
797 python-wheel))
798 (inputs
799 (list openmpi python-numpy))
800 (propagated-inputs
801 (list python-mpi4py))
802 (home-page "https://bitbucket.org/fenics-project/dijitso/")
803 (synopsis "Distributed just-in-time building of shared libraries")
804 (description
805 "Dijitso provides a core component of the @code{FEniCS} framework,
806namely the just-in-time compilation of C++ code that is generated from
807Python modules. It is called from within a C++ library, using ctypes
808to import the dynamic shared library directly.
809
810As long as the compiled code can provide a simple factory function to
811a class implementing a predefined C++ interface, there is no limit to
812the complexity of that interface. Parallel support depends on the
813@code{mpi4py} interface.")
814 (license license:lgpl3+)))
815
816(define-public python-fenics-ufl
817 (package
818 (name "python-fenics-ufl")
819 (version "2025.2.0")
820 (source
821 (origin
822 (method url-fetch)
823 (uri (pypi-uri "fenics_ufl" version))
824 (sha256
825 (base32 "1k2r7s1c7dqlgkah4jr08lqy4z17h49r94yxjm7ca16vgvqvq1xg"))))
826 (build-system pyproject-build-system)
827 (inputs (list python-numpy))
828 (native-inputs (list python-pytest python-setuptools))
829 (home-page "https://bitbucket.org/fenics-project/ufl/")
830 (synopsis "Unified language for form-compilers")
831 (description
832 "The Unified Form Language (UFL) is a domain specific language for
833declaration of finite element discretizations of variational forms. More
834precisely, it defines a flexible interface for choosing finite element spaces
835and defining expressions for weak forms in a notation close to mathematical
836notation.
837
838UFL is part of the FEniCS Project.")
839 (license license:lgpl3+)))
840
841(define-public python-fenics-ufl-2019
842 (package/inherit python-fenics-ufl
843 (name "python-fenics-ufl")
844 (version "2019.1.0")
845 (source
846 (origin
847 (method url-fetch)
848 (uri (pypi-uri "fenics-ufl" version))
849 (sha256
850 (base32 "10dz8x3lm68x2w3kkqcjask38h0zkhhak26jdbkppr8g9y8wny7p"))))
851 (inputs '())
852 (propagated-inputs (list python-numpy-1))))
853
854;; XXX: This package is quite dated and upstream no longer maintains it: "This
855;; repository was archived by the owner on Feb 21, 2022. It is now read-only."
856;; <https://bitbucket.org/fenics-project/fiat> ->
857;; <https://github.com/FEniCS/fiat> while providing a new refactored fork
858;; <https://github.com/firedrakeproject/fiat>.
859(define-public python-fenics-fiat
860 (package
861 (name "python-fenics-fiat")
862 (version "2019.1.0")
863 (source
864 (origin
865 (method url-fetch)
866 (uri (pypi-uri "fenics-fiat" version))
867 (sha256
868 (base32 "13sc7lma3d2mh43an7i4kkdbbk4cmvxjk45wi43xnjd7qc38zg4b"))))
869 (build-system pyproject-build-system)
870 (arguments
871 (list
872 #:test-flags
873 #~(list
874 ;; FIXME: three FIAT test modules are known to fail with recent
875 ;; versions of pytest (>= 4). These are skipped for FIAT version
876 ;; 2019.1.0 pending an upstream pull request. For details see request
877 ;; #59 at https://bitbucket.org/fenics-project/fiat/.
878 "--ignore=test/regression/"
879 "--ignore=test/unit/test_quadrature.py"
880 "--ignore=test/unit/test_reference_element.py"
881 "-k" (string-join
882 (list "not test_nodality"
883 "test_basis_values")
884 " and not "))))
885 (native-inputs
886 (list python-pytest
887 python-setuptools
888 python-wheel))
889 (propagated-inputs
890 (list python-numpy
891 python-sympy))
892 (home-page "https://bitbucket.org/fenics-project/fiat/")
893 (synopsis "Tabulation of finite element function spaces")
894 (description
895 "The FInite element Automatic Tabulator (FIAT) supports generation of
896arbitrary order instances of the Lagrange elements on lines, triangles, and
897tetrahedra. It is also capable of generating arbitrary order instances of
898Jacobi-type quadrature rules on the same element shapes. Further, H(div) and
899H(curl) conforming finite element spaces such as the families of
900Raviart-Thomas, Brezzi-Douglas-Marini and Nedelec are supported on triangles
901and tetrahedra. Upcoming versions will also support Hermite and nonconforming
902elements.
903
904FIAT is part of the FEniCS Project.")
905 (license license:lgpl3+)))
906
907(define-public python-fenics-ffc
908 (package
909 (name "python-fenics-ffc")
910 (version "2019.1.0.post0")
911 (source
912 (origin
913 (method url-fetch)
914 (uri (pypi-uri "fenics-ffc" version))
915 (sha256
916 (base32 "1f2a44ha65fg3a1prrbrsz4dgvibsv0j5c3pi2m52zi93bhwwgg9"))))
917 (build-system pyproject-build-system)
918 (arguments
919 (list
920 #:phases
921 #~(modify-phases %standard-phases
922 (replace 'check
923 (lambda _
924 (setenv "HOME" (getcwd))
925 (with-directory-excursion "test"
926 ;; FIXME: the tests in subdirectory
927 ;; 'unit/ufc/finite_element' require the ffc_factory
928 ;; extension module. This module, located in the 'libs'
929 ;; subdirectory, needs to be built and made accessible
930 ;; prior to running the tests.
931 (invoke "pytest" "unit/" "--ignore=unit/ufc/")
932 (with-directory-excursion "uflacs"
933 (invoke "pytest" "unit/"))))))))
934 (native-inputs (list python-pytest python-setuptools))
935 (propagated-inputs (list python-fenics-dijitso python-fenics-fiat
936 python-fenics-ufl-2019
937 python-numpy-1))
938 (home-page "https://bitbucket.org/fenics-project/ffc/")
939 (synopsis "Compiler for finite element variational forms")
940 (description
941 "The FEniCS Form Compiler (FFC) is a compiler for finite element
942variational forms. From a high-level description of the form, it generates
943efficient low-level C++ code that can be used to assemble the corresponding
944discrete operator (tensor). In particular, a bilinear form may be assembled
945into a matrix and a linear form may be assembled into a vector. FFC may be
946used either from the command line (by invoking the @code{ffc} command) or as a
947Python module (@code{import ffc}).
948
949FFC is part of the FEniCS Project.")
950 ;; There are two files released with a public domain licence;
951 ;; ufc.h and ufc_geometry.h, in subdirectory 'ffc/backends/ufc'.
952 (license (list license:public-domain license:lgpl3+))))
953
954(define-public fenics-dolfin
955 (package
956 (name "fenics-dolfin")
957 (version "2019.1.0.post0")
958 (source
959 (origin
960 (method url-fetch)
961 (uri (string-append "https://bitbucket.org/fenics-project/dolfin/get/"
962 version ".tar.gz"))
963 (file-name (string-append name "-" version ".tar.gz"))
964 (sha256
965 (base32 "1m91hwcq5gfj4qqswp8l8kj58nia48f0n4kq13w0xqj4biq7rla0"))
966 (patches (search-patches "fenics-dolfin-algorithm.patch"
967 "fenics-dolfin-demo-init.patch"
968 "fenics-dolfin-boost.patch"
969 "fenics-dolfin-config-slepc.patch"
970 "fenics-dolfin-hdf5-version-check.patch"
971 "fenics-dolfin-integer-types.patch"))
972 (modules '((guix build utils)))
973 (snippet '(begin
974 ;; Make sure we don't use the bundled test framework.
975 (delete-file-recursively "test/unit/cpp/catch")
976 (substitute* "test/unit/cpp/main.cpp"
977 ;; Use standard search paths for 'catch' header file.
978 (("#include.*")
979 "#include <catch.hpp>\n"))
980 (substitute* "test/unit/cpp/CMakeLists.txt"
981 ;; Specify directory to find the header file.
982 (("(^set\\(CATCH_INCLUDE_DIR ).*(/catch\\))" _ front back)
983 (string-append front "$ENV{CATCH_DIR}/include" back "\n")))))))
984 (build-system cmake-build-system)
985 (inputs (list openblas
986 boost-1.83
987 eigen
988 hdf5-parallel-openmpi
989 libxml2
990 openmpi
991 python-3
992 pt-scotch32
993 suitesparse
994 zlib))
995 (native-inputs (list catch-framework pkg-config))
996 (propagated-inputs (list python-fenics-ffc petsc-openmpi slepc-openmpi))
997 (arguments
998 (list
999 #:configure-flags
1000 #~`("-DDOLFIN_ENABLE_DOCS:BOOL=OFF" "-DDOLFIN_ENABLE_HDF5:BOOL=ON"
1001 "-DDOLFIN_ENABLE_MPI:BOOL=ON"
1002 "-DDOLFIN_ENABLE_PARMETIS:BOOL=OFF"
1003 "-DDOLFIN_ENABLE_SCOTCH:BOOL=ON"
1004 "-DDOLFIN_ENABLE_SUNDIALS:BOOL=OFF"
1005 "-DDOLFIN_ENABLE_TRILINOS:BOOL=OFF")
1006 #:phases
1007 #~(modify-phases %standard-phases
1008 (add-after 'patch-usr-bin-file 'mpi-setup
1009 #$%openmpi-setup)
1010 (add-after 'patch-source-shebangs 'set-paths
1011 (lambda _
1012 ;; Define paths to store locations.
1013 (setenv "BLAS_DIR"
1014 #$(this-package-input "openblas"))
1015 (setenv "CATCH_DIR"
1016 #$(this-package-input "catch"))
1017 (setenv "LAPACK_DIR"
1018 #$(this-package-input "openblas"))
1019 (setenv "PETSC_DIR"
1020 #$(this-package-input "petsc"))
1021 (setenv "SLEPC_DIR"
1022 #$(this-package-input "slepc"))
1023 (setenv "SCOTCH_DIR"
1024 #$(this-package-input "scotch"))
1025 (setenv "UMFPACK_DIR"
1026 #$(this-package-input "suitesparse"))))
1027 (add-before 'check 'pre-check
1028 (lambda _
1029 ;; The Dolfin repository uses git-lfs, whereby web links are
1030 ;; substituted for large files. Only the links are downloaded.
1031 ;; The tests that require the absent meshes cannot run and are
1032 ;; skipped.
1033 ;;
1034 ;; One serial test fails and is skipped.
1035 ;; i) demo_multimesh-stokes_serial:
1036 ;; Warning: Found no facets matching domain for boundary
1037 ;; condition.
1038 ;;
1039 ;; One mpi test fails and is skipped.
1040 ;; i) demo_stokes-iterative_mpi:
1041 ;; The MPI_Comm_rank() function was called before MPI_INIT was
1042 ;; invoked.
1043 (call-with-output-file "CTestCustom.cmake"
1044 (lambda (port)
1045 (display (string-append "set(CTEST_CUSTOM_TESTS_IGNORE "
1046 "demo_bcs_serial "
1047 "demo_bcs_mpi "
1048 "demo_eigenvalue_serial "
1049 "demo_eigenvalue_mpi "
1050 "demo_navier-stokes_serial "
1051 "demo_navier-stokes_mpi "
1052 "demo_stokes-taylor-hood_serial "
1053 "demo_stokes-taylor-hood_mpi "
1054 "demo_subdomains_serial "
1055 "demo_advection-diffusion_serial "
1056 "demo_advection-diffusion_mpi "
1057 "demo_auto-adaptive-navier-stokes_serial "
1058 "demo_contact-vi-snes_serial "
1059 "demo_contact-vi-snes_mpi "
1060 "demo_contact-vi-tao_serial "
1061 "demo_contact-vi-tao_mpi "
1062 "demo_curl-curl_serial "
1063 "demo_curl-curl_mpi "
1064 "demo_dg-advection-diffusion_serial "
1065 "demo_dg-advection-diffusion_mpi "
1066 "demo_elasticity_serial "
1067 "demo_elasticity_mpi "
1068 "demo_elastodynamics_serial "
1069 "demo_elastodynamics_mpi "
1070 "demo_lift-drag_serial "
1071 "demo_lift-drag_mpi "
1072 "demo_mesh-quality_serial "
1073 "demo_mesh-quality_mpi "
1074 "demo_multimesh-stokes_serial "
1075 "demo_stokes-iterative_mpi"
1076 ")\n") port)))))
1077 (replace 'check
1078 (lambda* (#:key tests? #:allow-other-keys)
1079 (when tests?
1080 (invoke "make" "unittests")
1081 (invoke "make" "demos")
1082 (invoke "ctest" "-R" "unittests")
1083 (invoke "ctest" "-R" "demo" "-R" "serial")
1084 (invoke "ctest" "-R" "demo" "-R" "mpi")))))))
1085 (home-page "https://bitbucket.org/fenics-project/dolfin/")
1086 (synopsis "Problem solving environment for differential equations")
1087 (description
1088 "DOLFIN is a computational framework for finding numerical
1089solutions to problems described by differential equations. Numerical
1090models in DOLFIN are constructed using general families of finite
1091elements. Data structures are provided for discretizing the governing
1092system on a computational mesh. A compact syntax, similar to
1093mathematical notation, is made available for defining function spaces
1094and expressing variational forms. Interfaces to specialized matrix
1095solvers are provided for solving the resultant linear systems.
1096
1097@code{fenics-dolfin} is part of the FEniCS project. It is the C++
1098user interface to the FEniCS core components and external libraries.")
1099 ;; The source code for the DOLFIN C++ library is licensed under the
1100 ;; GNU Lesser General Public License, version 3 or later, with the
1101 ;; following exceptions:
1102 ;;
1103 ;; public-domain: dolfin/geometry/predicates.cpp
1104 ;; dolfin/geometry/predicates.h
1105 ;;
1106 ;; zlib: dolfin/io/base64.cpp
1107 ;; dolfin/io/base64.h
1108 ;;
1109 ;; expat: dolfin/io/pugiconfig.hpp
1110 ;; dolfin/io/pugixml.cpp
1111 ;; dolfin/io/pugixml.hpp
1112 (license (list license:public-domain license:zlib license:expat
1113 license:lgpl3+))))
1114
1115(define-public fenics
1116 (package/inherit fenics-dolfin
1117 (name "fenics")
1118 (build-system pyproject-build-system)
1119 (arguments
1120 (list
1121 #:test-flags
1122 #~(list
1123 "unit"
1124 ;; This test fails and is ignored.
1125 "--deselect"
1126 "unit/nls/test_PETScSNES_solver.py::test_snes_set_from_options"
1127 ;; These tests are flaky.
1128 "--deselect=unit/common/test_timer.py::test_context_manager_named"
1129 "--deselect=unit/common/test_timer.py::test_context_manager_anonymous"
1130 ;; FIXME: Tests with binary encoded hdf5 files fail with a
1131 ;; segfault. See fenics-project DOLFIN commit 6fbc9fb.
1132 "--ignore=unit/io/test_XDMF.py")
1133 #:phases
1134 #~(modify-phases %standard-phases
1135 (add-after 'unpack 'relax-requirements
1136 (lambda _
1137 (substitute* "python/setup.py"
1138 (("pybind11==") "pybind11>="))))
1139 (add-after 'unpack 'set-dolfin-pc-file-name
1140 (lambda* (#:key inputs #:allow-other-keys)
1141 ;; Instead of cluttering the user's PKG_CONFIG_PATH environment
1142 ;; variable, hard-code the 'dolfin.pc' absolute file name.
1143 (let ((pc-file (search-input-file inputs
1144 "/lib/pkgconfig/dolfin.pc")))
1145 (substitute* "python/dolfin/jit/jit.py"
1146 (("pkgconfig\\.parse\\(\"dolfin\"\\)")
1147 (string-append "pkgconfig.parse(\"" pc-file "\")"))))))
1148 (add-after 'patch-source-shebangs 'set-paths
1149 (lambda _
1150 ;; Define paths to store locations.
1151 (setenv "PYBIND11_DIR" #$(this-package-input "pybind11"))
1152 ;; Move to python sub-directory.
1153 (chdir "python")))
1154 (add-after 'build 'mpi-setup #$%openmpi-setup)
1155 (add-before 'check 'pre-check
1156 (lambda _
1157 ;; Exclude three tests that generate 'NotImplementedError' in
1158 ;; matplotlib v3.1.2. See
1159 ;; <https://github.com/matplotlib/matplotlib/issues/15382>.
1160 ;; Also exclude tests that require meshes supplied by git-lfs.
1161 (substitute* "demo/test.py"
1162 (("(.*stem !.*)" line)
1163 (format #f "~a
1164excludeList = [~{ '~a',~% ~}]
1165demos = [d for d in demos if d[0].stem not in excludeList]~%"
1166 line
1167 (list "built-in-meshes"
1168 "hyperelasticity"
1169 "elasticity"
1170 "multimesh-quadrature"
1171 "multimesh-marking"
1172 "mixed-poisson-sphere"
1173 "mesh-quality"
1174 "lift-drag"
1175 "elastodynamics"
1176 "dg-advection-diffusion"
1177 "curl-curl"
1178 "contact-vi-tao"
1179 "contact-vi-snes"
1180 "collision-detection"
1181 "buckling-tao"
1182 "auto-adaptive-navier-stokes"
1183 "advection-diffusion"
1184 "subdomains"
1185 "stokes-taylor-hood"
1186 "stokes-mini"
1187 "navier-stokes"
1188 "eigenvalue"))))
1189 ;; Do not test for expired numpy aliases.
1190 (substitute* "test/unit/la/test_vector.py"
1191 ((" numpy.float\\(42.0\\),") "")
1192 (("^.*numpy.int\\(42.0\\).*$") ""))
1193 (substitute* "test/unit/la/test_la_basic.py"
1194 ((" int,") " ")
1195 (("\\[int,") "["))
1196 (setenv "HOME" (getcwd))
1197 ;; Restrict OpenBLAS to MPI-only in preference to MPI+OpenMP.
1198 (setenv "OPENBLAS_NUM_THREADS" "1")))
1199 (replace 'check
1200 (lambda* (#:key tests? test-flags #:allow-other-keys)
1201 (when tests?
1202 (with-directory-excursion "test"
1203 (apply invoke "pytest" test-flags)))))
1204 (add-after 'install 'install-demo-files
1205 (lambda _
1206 (let* ((demos (string-append #$output
1207 "/share/python-dolfin/demo")))
1208 (mkdir-p demos)
1209 (with-directory-excursion "demo"
1210 (for-each (lambda (file)
1211 (let* ((dir (dirname file))
1212 (tgt-dir (string-append demos "/" dir)))
1213 (unless (equal? "." dir)
1214 (mkdir-p tgt-dir)
1215 (install-file file tgt-dir))))
1216 (find-files "." ".*\\.(py|gz|xdmf)$")))))))))
1217 (inputs
1218 (modify-inputs (package-inputs fenics-dolfin)
1219 (delete "python")
1220 (prepend pybind11 python-matplotlib)))
1221 (native-inputs
1222 (modify-inputs (package-native-inputs fenics-dolfin)
1223 (prepend cmake-minimal python-ply python-pytest python-decorator
1224 python-setuptools)))
1225 (propagated-inputs
1226 (list fenics-dolfin
1227 python-petsc4py
1228 python-slepc4py
1229 ;; 'dolfin/jit/jit.py' parses 'dolfin.pc' at runtime.
1230 python-pkgconfig))
1231 (home-page "https://fenicsproject.org/")
1232 (synopsis "High-level environment for solving differential equations")
1233 (description
1234 "@code{fenics} is a computing platform for solving general classes of
1235problems that involve differential equations. @code{fenics} facilitates
1236access to efficient methods for dealing with ordinary differential
1237equations (ODEs) and partial differential equations (PDEs). Systems of
1238equations such as these are commonly encountered in areas of engineering,
1239mathematics and the physical sciences. It is particularly well-suited to
1240problems that can be solved using the Finite Element Method (FEM).
1241
1242@code{fenics} is the top level of the set of packages that are developed
1243within the FEniCS project. It provides the python user interface to the
1244FEniCS core components and external libraries.")
1245 (license license:lgpl3+)))
1246
1247(define-public fullswof-2d
1248 (let ((revision 505)
1249 (release "1.09.01"))
1250 (package
1251 (name "fullswof-2d")
1252 (version release)
1253 (source (origin
1254 (method svn-fetch)
1255 (uri (svn-reference
1256 (url (string-append "https://subversion.renater.fr/"
1257 "anonscm/svn/fullswof-2d/tags/"
1258 "release-" version))
1259 (revision revision)))
1260 (file-name (string-append "fullswof-2d-" version "-checkout"))
1261 (sha256
1262 (base32
1263 "16v08dx7h7n4wyddzbwimazwyj74ynis12mpjfkay4243npy44b8"))))
1264 (build-system gnu-build-system)
1265 (native-inputs
1266 (list inetutils)) ; for 'hostname', used in the check phase
1267 (arguments
1268 `(#:phases
1269 (modify-phases %standard-phases
1270 (delete 'configure) ; no configure script
1271 (add-after 'build 'build-tools
1272 (lambda _
1273 (with-directory-excursion "Tools/ConvertFormat"
1274 (invoke "make" "../../bin/asc2xyz")
1275 (invoke "make" "../../bin/xyz2asc"))
1276 (with-directory-excursion "Tools/ExtractWindow"
1277 (invoke "make" "../../bin/cropxyz"))
1278 #t))
1279 (replace 'check ; no check target
1280 (lambda _
1281 (invoke "make" "benchref")))
1282 (replace 'install ; no install target
1283 (lambda* (#:key outputs #:allow-other-keys)
1284 (let* ((out (assoc-ref outputs "out"))
1285 (bin (string-append out "/bin"))
1286 (doc (string-append
1287 out "/share/doc/" ,name "-" ,version))
1288 (examples (string-append doc "/Examples")))
1289 (with-directory-excursion "bin"
1290 (for-each (lambda (binary) (install-file binary bin))
1291 (list "asc2xyz" "xyz2asc" "cropxyz"
1292 "FullSWOF_2D")))
1293 (with-directory-excursion "doc"
1294 (for-each (lambda (pdf) (install-file pdf doc))
1295 (list "Documentation.pdf" "refman.pdf")))
1296 (with-directory-excursion "Tools"
1297 (for-each (lambda (dir)
1298 (copy-file
1299 (string-append dir "/README.txt")
1300 (string-append doc "/README_" dir ".txt")))
1301 (list "ConvertFormat" "ExtractWindow")))
1302 (copy-recursively "Examples" examples)
1303 #t))))))
1304 (home-page "https://www.idpoisson.fr/fullswof/")
1305 (synopsis "Two dimensional flow solver for flood modelling")
1306 (description "@code{FullSWOF_2d} is a numerical tool for solving
1307the shallow water equations on structured grids. The name FullSWOF
1308refers to the Full form of the Shallow Water equations for Overland
1309Flow. The discretized system of equations is solved using the finite
1310volume method. A choice of shock-capturing methods is available to
1311locate the transition boundaries between the wet areas and the dry
1312areas in the model. A semi-implicit method is used to advance the
1313solution in time. The tool is typically applied to the modelling of
1314river flooding.")
1315 (license license:cecill))))
1316
1317(define-public python-meshio
1318 (package
1319 (name "python-meshio")
1320 (version "5.3.5")
1321 (source
1322 (origin
1323 ;; Using PyPI rather than git because some test files must be
1324 ;; downloaded through git-fls.
1325 (method url-fetch)
1326 (uri (pypi-uri "meshio" version))
1327 (sha256
1328 (base32 "0vaqhygr2d186qixvfckzqf4447674ylnc0rl5pa16zjv6mh27zj"))))
1329 (build-system pyproject-build-system)
1330 (arguments
1331 (list
1332 #:test-flags
1333 ;; XXX: See: <https://github.com/nschloe/meshio/issues/1499>.
1334 ;; ValueError: invalid literal for int() with base 10: 'np.int64(4)'
1335 #~(list "--deselect=tests/test_dolfin.py::test_dolfin[mesh3]"
1336 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh9]"
1337 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh10]"
1338 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh11]"
1339 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh12]"
1340 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh13]"
1341 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh14]"
1342 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh8]"
1343 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh9]"
1344 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh10]"
1345 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh11]"
1346 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh12]"
1347 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh13]"
1348 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh8]"
1349 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh9]"
1350 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh10]"
1351 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh11]"
1352 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh12]"
1353 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh13]"
1354 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh0]"
1355 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh1]"
1356 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh2]"
1357 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh3]"
1358 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh4]"
1359 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh5]")))
1360 (inputs (list python-h5py python-netcdf4))
1361 (native-inputs (list python-pytest python-setuptools))
1362 (propagated-inputs (list python-numpy python-rich))
1363 (home-page "https://github.com/nschloe/meshio")
1364 (synopsis "I/O for mesh files")
1365 (description
1366 "There are various file formats available for representing unstructured
1367meshes and mesh data. The @code{meshio} package is able to read and write
1368mesh files in many formats and to convert files from one format to another.
1369Formats such as cgns, h5m, gmsh, xdmf and vtk are supported. The package
1370provides command-line tools and a collection of Python modules for
1371programmatic use.")
1372 (license license:expat)))
1373
1374(define-public python-pygmsh
1375 (package
1376 (name "python-pygmsh")
1377 (version "7.1.17")
1378 (source
1379 (origin
1380 (method git-fetch)
1381 (uri (git-reference
1382 (url "https://github.com/nschloe/pygmsh")
1383 (commit (string-append "v" version))))
1384 (file-name (git-file-name name version))
1385 (sha256
1386 (base32
1387 "11flp2c4ynk1fhanf4mqyzrpd0gjbnv6afrwwc7xi3mb6ms69lr0"))))
1388 (build-system pyproject-build-system)
1389 (arguments
1390 (list
1391 #:phases
1392 #~(modify-phases %standard-phases
1393 (add-after 'unpack 'workaround-gmsh-detection-failure
1394 (lambda _
1395 ;; Due to lack of metadata, the gmsh Python package is not
1396 ;; detected although importable.
1397 (substitute* "pyproject.toml"
1398 (("\"gmsh\",") "")))))))
1399 (native-inputs (list python-flit-core python-pytest))
1400 (propagated-inputs (list gmsh python-meshio python-numpy))
1401 (home-page "https://github.com/nschloe/pygmsh")
1402 (synopsis "Python frontend for Gmsh")
1403 (description "The goal of @code{pygmsh} is to combine the power of
1404Gmsh with the versatility of Python. The package generalises many of
1405the methods and functions that comprise the Gmsh Python API. In this
1406way the meshing of complex geometries using high-level abstractions is
1407made possible. The package provides a Python library together with a
1408command-line utility for mesh optimisation.")
1409 (license license:gpl3+)))
1410
1411(define-public python-simpy
1412 (package
1413 (name "python-simpy")
1414 (version "4.1.1")
1415 (source
1416 (origin
1417 (method url-fetch)
1418 (uri (pypi-uri "simpy" version))
1419 (sha256
1420 (base32 "19h1a3wxygyi819njmnl8cbmzvflqv3hpki0iq71xcc4g057bl06"))))
1421 (build-system pyproject-build-system)
1422 (arguments
1423 (list
1424 ;; tests: 141 passed, 10 deselected, 10 warnings
1425 #:test-flags
1426 ;; Doctests require deprecated python-py.
1427 #~(list "--ignore=docs/")))
1428 (native-inputs
1429 (list python-pytest
1430 python-setuptools
1431 python-setuptools-scm))
1432 (home-page "https://gitlab.com/team-simpy/simpy")
1433 (synopsis "Process-based discrete-event simulation framework")
1434 (description
1435 "SimPy is a process-based discrete-event simulation framework based
1436on standard Python. Processes in SimPy are defined by Python generator
1437functions and can, for example, be used to model active components like
1438customers, vehicles or agents. SimPy also provides various types of shared
1439resources to model limited capacity congestion points (like servers, checkout
1440counters and tunnels).")
1441 (license license:bsd-2)))
1442
1443(define-public python-dolfin-adjoint
1444 (package
1445 (name "python-dolfin-adjoint")
1446 (version "2019.1.0")
1447 (source
1448 (origin
1449 (method git-fetch)
1450 (uri (git-reference
1451 (url "https://github.com/dolfin-adjoint/pyadjoint")
1452 (commit version)))
1453 (file-name (git-file-name name version))
1454 (sha256
1455 (base32 "0xhy76a5f33hz94wc9g2mc5qmwkxfccbbc6yxl7psm130afp8lhn"))
1456 (modules '((guix build utils)))
1457 (snippet
1458 '(begin
1459 ;; One of the migration tests attempts to call openmpi
1460 ;; recursively and fails. See
1461 ;; https://bitbucket.org/mpi4py/mpi4py/issues/95. Run the
1462 ;; test sequentially instead.
1463 (with-directory-excursion "tests/migration/optimal_control_mms"
1464 (substitute* "test_optimal_control_mms.py"
1465 (("\\\"mpirun\\\", \\\"-n\\\", \\\"2\\\", ") "")))
1466 ;; Result files are regenerated in the check phase.
1467 (delete-file-recursively
1468 "tests/migration/viscoelasticity/test-results")))))
1469 (build-system pyproject-build-system)
1470 (arguments
1471 (list
1472 #:test-flags
1473 #~(list
1474 ;; Ignore tests which require missing packages and/or failed during
1475 ;; tests collection.
1476 "--import-mode=importlib"
1477 "--ignore=tests/firedrake_adjoint"
1478 "--ignore=tests/fenics_adjoint/test_dynamic_meshes.py"
1479 "-k" (string-append "not test_sin_weak_spatial and "
1480 "not test_shape_hessian and "
1481 "not test_read_checkpoint and "
1482 "not test_lu_solver and "
1483 "not test_lu_solver_function_ctrl and "
1484 "not test_dirichletbc_subspace"))
1485 #:phases
1486 #~(modify-phases %standard-phases
1487 (add-after 'build 'mpi-setup #$%openmpi-setup)
1488 (add-before 'check 'set-environment-variables
1489 (lambda _
1490 (setenv "HOME" (getcwd))))
1491 (add-after 'install 'install-doc
1492 (lambda _
1493 (let* ((doc (string-append #$output "/share/doc/" #$name "-" #$version))
1494 (examples (string-append doc "/examples")))
1495 (mkdir-p examples)
1496 (copy-recursively "examples" examples))))
1497 ;; Remove 'sanity-check, because it tries to import
1498 ;; firedrake_adjoint after importing fenics_adjoint.
1499 ;; Both load a module named 'backend' and firedrake_adjoint
1500 ;; fails with an ImportError if it sees that the backend module
1501 ;; has already been loaded.
1502 (delete 'sanity-check))))
1503 (inputs
1504 (list fenics openmpi pybind11))
1505 (native-inputs
1506 (list pkg-config
1507 python-coverage
1508 python-decorator
1509 python-flake8
1510 python-pkgconfig
1511 python-pytest
1512 python-setuptools
1513 python-wheel))
1514 (propagated-inputs
1515 (list python-scipy))
1516 (home-page "https://www.dolfin-adjoint.org")
1517 (synopsis "Automatic differentiation library")
1518 (description
1519 "@code{python-dolfin-adjoint} is a solver of differential equations
1520associated with a governing system and a functional of interest. Working from
1521the forward model the solver automatically derives the discrete adjoint and
1522tangent linear models. These additional models are key ingredients in many
1523algorithms such as data assimilation, optimal control, sensitivity analysis,
1524design optimisation and error estimation. The dolfin-adjoint project provides
1525the necessary tools and data structures for cases where the forward model is
1526implemented in @code{fenics} or
1527@url{https://firedrakeproject.org,firedrake}.")
1528 (license license:lgpl3)))
1529
1530(define %commonroad-dont-install-license-at-root
1531 #~(substitute* "setup.py"
1532 (("data_files=\\[\\('.', \\['LICENSE.txt'\\]\\)\\],")
1533 "")))
1534
1535(define-public python-commonroad-vehicle-models
1536 (package
1537 (name "python-commonroad-vehicle-models")
1538 (version "3.0.2")
1539 (source (origin
1540 (method url-fetch)
1541 (uri (pypi-uri "commonroad-vehicle-models" version))
1542 (sha256
1543 (base32
1544 "13jg0cys7y4n7rg548w6mxk9g10gd5qxmj4ynrlriczpffqy6kc7"))))
1545 (build-system pyproject-build-system)
1546 (arguments
1547 (list
1548 #:test-flags
1549 #~(list "--ignore=scripts/test_vehicle.py" ; import error
1550 "-k" "not test_std") ; flaky
1551 #:phases
1552 #~(modify-phases %standard-phases
1553 (add-after 'unpack 'fix-setup.py
1554 (lambda _
1555 #$%commonroad-dont-install-license-at-root)))))
1556 (native-inputs
1557 (list python-matplotlib
1558 python-pytest
1559 python-scipy
1560 python-setuptools))
1561 (propagated-inputs (list python-numpy python-omegaconf))
1562 (home-page "https://commonroad.in.tum.de/")
1563 (synopsis "CommonRoad vehicle models")
1564 (description "This package provides vehicle models used in CommonRoad
1565benchmarks. Varying abstraction levels are used ranging from kinematic single
1566track models to multi-body models.")
1567 (license license:bsd-3)))
1568
1569(define-public python-commonroad-io
1570 (package
1571 (name "python-commonroad-io")
1572 (version "2022.3")
1573 (source (origin
1574 (method url-fetch)
1575 (uri (pypi-uri "commonroad-io" version))
1576 (sha256
1577 (base32
1578 "1cj9zj567mca8xb8sx9h3nnl2cccv6vh8h73imgpq61cimk9mvas"))))
1579 (build-system pyproject-build-system)
1580 (arguments
1581 (list
1582 #:tests? #f ; No tests.
1583 #:phases
1584 #~(modify-phases %standard-phases
1585 (add-after 'unpack 'fix-setup.py
1586 (lambda _
1587 (substitute* "setup.py"
1588 (("protobuf==3.20.1") "protobuf >= 3.20.1"))
1589 #$%commonroad-dont-install-license-at-root)))))
1590 (propagated-inputs (list python-commonroad-vehicle-models
1591 python-iso3166
1592 python-lxml
1593 python-matplotlib
1594 python-networkx
1595 python-numpy
1596 python-omegaconf
1597 python-pillow
1598 python-protobuf
1599 python-rtree
1600 python-scipy
1601 python-shapely
1602 python-tqdm))
1603 (native-inputs (list python-lxml python-setuptools))
1604 (home-page "https://commonroad.in.tum.de/")
1605 (synopsis "Read, write, and visualize CommonRoad scenarios")
1606 (description "This package provides methods to read, write, and visualize
1607CommonRoad scenarios and planning problems. It can be used as a framework for
1608implementing motion planning algorithms to solve CommonRoad Benchmarks
1609and is the basis for other tools of the CommonRoad Framework.")
1610 (license license:bsd-3)))
1611
1612(define-public python-commonroad-route-planner
1613 (package
1614 (name "python-commonroad-route-planner")
1615 (version "2022.3")
1616 (source (origin
1617 (method git-fetch)
1618 (uri (git-reference
1619 (url "https://gitlab.lrz.de/tum-cps/commonroad-route-planner")
1620 (commit version)))
1621 (file-name (git-file-name name version))
1622 (sha256
1623 (base32
1624 "0xn0l7bzmj56d4mlqacvbl8mdvsffkg2fn2lzfmis5jl4vp99ipf"))))
1625 (arguments
1626 (list
1627 #:tests? #f ; No tests.
1628 #:phases
1629 #~(modify-phases %standard-phases
1630 (add-after 'unpack 'fix-setup.py
1631 (lambda _
1632 #$%commonroad-dont-install-license-at-root)))))
1633 (build-system pyproject-build-system)
1634 (native-inputs (list python-setuptools))
1635 (propagated-inputs (list python-commonroad-io
1636 python-matplotlib
1637 python-networkx
1638 python-numpy
1639 python-setuptools
1640 python-shapely))
1641 (home-page "https://gitlab.lrz.de/tum-cps/commonroad-route-planner")
1642 (synopsis "Route planner for CommonRoad scenarios")
1643 (description
1644 "This package provides functions for route planning, that is finding
1645sequences that lead from a given start lanelet to some goal lanelet(s).")
1646 (license license:bsd-3)))
1647
1648(define-public sumo
1649 (package
1650 (name "sumo")
1651 (version "1.25.0")
1652 (source (origin
1653 (method git-fetch)
1654 (uri (git-reference
1655 (url "https://github.com/eclipse/sumo")
1656 (commit (string-append "v"
1657 (string-replace-substring version
1658 "." "_")))))
1659 (file-name (git-file-name name version))
1660 (sha256
1661 (base32
1662 "0nqz4izbwgbpz3xwx0mczagilhf06jxxpr3pmr7axjk80yk1r4ri"))))
1663 (build-system cmake-build-system)
1664 (arguments
1665 (list
1666 #:phases
1667 #~(modify-phases %standard-phases
1668 (add-after 'unpack 'disable-problematic-tests
1669 (lambda _
1670 (substitute* "CMakeLists.txt"
1671 ;; docs/example appears to be missing
1672 (("add_test\\(exampletest .*") ""))
1673 (substitute* "src/traci_testclient/CMakeLists.txt"
1674 ;; requires network connection (at least to localhost)
1675 (("add_test\\(NAME libtracitest .*") "")))))))
1676 (inputs (list eigen
1677 freetype
1678 fontconfig
1679 ffmpeg
1680 fox
1681 gdal
1682 glu
1683 gperftools ; tcmalloc
1684 libjpeg-turbo
1685 libtiff
1686 libx11
1687 libxcursor
1688 libxft
1689 libxi
1690 libxrandr
1691 libxrender
1692 openscenegraph
1693 proj
1694 python
1695 xerces-c
1696 zlib))
1697 (native-inputs (list googletest-1.8 python))
1698 (home-page "https://eclipse.org/sumo")
1699 (synopsis "Traffic simulator")
1700 (description "@acronym{SUMO, Simulation of Urban MObility} is a traffic
1701simulation package designed to handle large road networks and different modes
1702of transportation -- including road vehicles, public transport and pedestrians.
1703Included with SUMO is a wealth of supporting tools which automate core tasks
1704for the creation, the execution and evaluation of traffic simulations,
1705such as network import, route calculations, visualization and emission
1706calculation. SUMO can be enhanced with custom models and provides various
1707APIs to remotely control the simulation.")
1708 (license (list license:epl2.0 license:gpl2+))))