projects/guix·blob ruby-team · refs

1688 lines · 75.9 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-2026 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 compiler-tools)
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 licenses) #:prefix license:)
85 #:use-module (guix packages)
86 #:use-module (guix gexp)
87 #:use-module (guix utils)
88 #:use-module (ice-9 ftw)
89 #:use-module (ice-9 match)
90 #:use-module (ice-9 regex)
91 #:use-module (srfi srfi-1))
92
93(define-public openfoam-org
94 (package
95 (name "openfoam-org")
96 (version "13")
97 (source
98 (origin
99 (method git-fetch)
100 (uri (git-reference
101 (url "https://github.com/OpenFOAM/OpenFOAM-dev")
102 (commit (string-append "version-" version))))
103 (file-name (git-file-name name version))
104 (sha256
105 (base32 "10s1x82znfnwspq5iif928j1ks4v0slmmycg6py8xw1vvhjp7arh"))))
106 (build-system gnu-build-system)
107 (native-inputs (list bison flex git))
108 (inputs (list bash-completion
109 boost
110 cgal
111 cgns
112 cli11
113 cmake-minimal
114 coreutils
115 curl
116 double-conversion
117 eigen
118 expat
119 ffmpeg
120 findutils
121 fmt
122 freetype
123 gdal
124 gl2ps
125 glew
126 gmp
127 gmsh
128 gnuplot
129 hdf5
130 jsoncpp
131 libjpeg-turbo
132 libogg
133 libpng
134 libharu
135 libtheora
136 libtiff
137 libx11
138 libxml2
139 libxslt
140 libxt
141 lz4
142 metis
143 mpfr
144 ncurses
145 netcdf
146 nlohmann-json
147 openmpi
148 paraview
149 proj
150 protobuf
151 pt-scotch32
152 pugixml
153 python
154 python-mpi4py
155 qt5compat
156 qtbase
157 qtsvg
158 qttools
159 qtwebengine
160 readline
161 trilinos-zoltan
162 utfcpp
163 vtk-9.5
164 xz
165 zlib))
166 (propagated-inputs (list python-openpmd-api)) ;needed for paraFoam
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 ,(string-append openfoam-root
585 "/platforms/linux64GccDPInt32Opt/lib/paraview-"
586 paraview-version-major+minor)))
587 `("PATH" prefix
588 (,(string-append openfoam-root "/ThirdParty-"
589 openfoam-version
590 "/platforms/linux64Gcc/gperftools-svn/bin") ,
591 (string-append #$(this-package-input
592 "paraview") "/bin")
593 ,(string-append openfoam-root "/ThirdParty-"
594 openfoam-version
595 "/platforms/linux64Gcc/cmake-*/bin")
596 ,(string-append #$(this-package-input
597 "openmpi") "/bin")
598 ,(string-append openfoam-root "/bin")
599 ,(string-append openfoam-root "/wmake")
600 ,(string-append "$HOME/OpenFOAM/$USER-"
601 openfoam-version
602 "/platforms/linux64GccDPInt32Opt/bin")
603 ,(string-append openfoam-root "/site/"
604 openfoam-version
605 "/platforms/linux64GccDPInt32Opt/bin")
606 ,(string-append openfoam-root
607 "/platforms/linux64GccDPInt32Opt/bin")))))
608 (find-files bin))))))))
609 ;; Note:
610 ;; Tutorial files are installed read-only in /gnu/store.
611 ;; To allow write permissions on files copied from the store a
612 ;; 'chmod' step is needed before running the applications. For
613 ;; example, from a user's login:
614 ;; $ source $(foamEtcFile bashrc)
615 ;; $ mkdir -p $FOAM_RUN
616 ;; $ cd $FOAM_RUN
617 ;; $ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
618 ;; $ cd pitzDaily
619 ;; $ chmod -R u+w .
620 ;; $ blockMesh
621 (home-page "https://openfoam.org")
622 (synopsis "Framework for numerical simulation of fluid flow")
623 (description
624 "OpenFOAM provides a set of solvers and methods for tackling
625problems in the field of Computational Fluid Dynamics (CFD). It is written in
626C++. Governing equations such as the Navier-Stokes equations can be solved in
627integral form. Physical processes such as phase change, droplet transport and
628chemical reaction can be modelled. Numerical methods are included to deal with
629sharp gradients, such as those encountered in flows with shock waves and flows
630with gas/liquid interfaces. Large problems may be split into smaller, connected
631problems for efficient solution on parallel systems.")
632 (license license:gpl3+)))
633
634(define-public openfoam-com
635 ;; This is a fork of 'openfoam-org', maintained separately.
636 (package
637 (inherit openfoam-org)
638 (name "openfoam-com")
639 (version "2512")
640 (source
641 (origin
642 (method git-fetch)
643 (uri (git-reference
644 (url "https://gitlab.com/openfoam/core/openfoam")
645 (commit (string-append "OpenFOAM-v" version))))
646 (file-name (git-file-name name version))
647 (sha256
648 (base32 "0v2dy7zcr1s6jc0z8gx726ljai3jnihzydiisszab8vcq79c19dr"))))
649 (arguments
650 ;; Since 'arguments' is a function of the package's version, define
651 ;; 'parent' such that the 'arguments' thunk gets to see the right
652 ;; version.
653 (let ((parent (package
654 (inherit openfoam-org)
655 (version (package-version this-package)))))
656 (substitute-keyword-arguments arguments
657 ((#:phases phases)
658 #~(modify-phases #$phases
659 (delete 'disable-failing-tests))))))
660 (synopsis
661 "Framework for numerical simulation of fluid flow (from openfoam.com)")
662 (home-page "https://www.openfoam.com")))
663
664(define-public open-simulation-interface
665 (package
666 (name "open-simulation-interface")
667 (version "3.5.0")
668 (source (origin
669 (method git-fetch)
670 (uri (git-reference
671 (url (string-append "https://github.com/"
672 "OpenSimulationInterface/"
673 "open-simulation-interface"))
674 (commit (string-append "v" version))))
675 (file-name (git-file-name name version))
676 (sha256
677 (base32
678 "09vclrvsawx608kk0vnzywr71xn11qzwxzh2j508zjfn0kvhyx7q"))))
679 (build-system cmake-build-system)
680 (arguments (list #:tests? #f ; tests are for the python package
681 #:phases
682 #~(modify-phases %standard-phases
683 (add-after 'unpack 'fix-cmake
684 (lambda _
685 (substitute* "CMakeLists.txt"
686 (("-targets\\.cmake") "_targets.cmake")))))))
687 (native-inputs (list protobuf))
688 (home-page
689 "https://github.com/OpenSimulationInterface/open-simulation-interface")
690 (synopsis "Generic interface for environmental perception")
691 (description "The Open Simulation Interface is a generic interface based on
692Google's protocol buffers for the environmental perception of automated driving
693functions in virtual scenarios.")
694 (license license:mpl2.0)))
695
696(define-public python-open-simulation-interface
697 (package/inherit open-simulation-interface
698 (name "python-open-simulation-interface")
699 (build-system pyproject-build-system)
700 (arguments '())
701 (native-inputs
702 (modify-inputs native-inputs
703 (append python-pytest python-setuptools)))
704 (propagated-inputs
705 (list python-pyyaml
706 python-protobuf))))
707
708(define-public esmini
709 (package
710 (name "esmini")
711 (version "3.5.0")
712 (source
713 (origin
714 (method git-fetch)
715 (uri (git-reference
716 (url "https://github.com/esmini/esmini")
717 (commit (string-append "v" version))))
718 (file-name (git-file-name name version))
719 (modules '((guix build utils) (ice-9 ftw)))
720 (snippet
721 #~(begin
722 (with-directory-excursion "externals"
723 (for-each
724 (lambda (dir) (unless (member dir '("." ".." "expr" "yaml"))
725 (delete-file-recursively dir)))
726 (scandir ".")))
727 (substitute* "CMakeLists.txt"
728 (("add_subdirectory\\(externals/fmt\\)") "")
729 (("set_.*_libs\\(\\)") ""))
730 (with-directory-excursion "EnvironmentSimulator"
731 (with-directory-excursion "Applications/esmini-dyn/"
732 (substitute* "CMakeLists.txt"
733 (("\\$ORIGIN") "$ORIGIN/../lib")))
734 (with-directory-excursion "Modules/RoadManager"
735 (substitute* (find-files "." "CMakeLists\\.txt$")
736 (("\\$\\{EXTERNALS_.*\\}/[^ )\n]*") "")
737 (("add_library\\(\n") "add_library("))
738 (substitute* (find-files "." "CMakeLists\\.txt$")
739 (("add_library\\(.*pugixml_lib") "find_package(pugixml")
740 (("pugixml_lib") "pugixml")))
741 (with-directory-excursion "Modules/Controllers"
742 (substitute* "ControllerSumo.cpp"
743 (("#include <utils/geom/PositionVector\\.h>") ""))))
744 (with-directory-excursion "support/cmake/external"
745 (for-each make-file-writable (scandir "."))
746 (call-with-output-file "gtest.cmake"
747 (lambda (out)
748 (display "find_package(GTest REQUIRED)" out)))
749 (call-with-output-file "osg.cmake"
750 (lambda (out)
751 (display "include_guard()\n" out)
752 (display "include(FindPkgConfig)\n" out)
753 (format out "pkg_check_modules(OSG REQUIRED~@{ ~a~})"
754 "openscenegraph"
755 "osgdb_jpeg"
756 "osgdb_png"
757 "osgdb_osg"
758 "osgdb_serializers_osg"
759 "osgdb_serializers_osgsim")))
760 (call-with-output-file "osi.cmake"
761 (lambda (out)
762 (display "\
763find_package(open_simulation_interface REQUIRED)
764set(EXTERNALS_OSI_INCLUDES \"${OPEN_SIMULATION_INTERFACE_INCLUDE_DIRS}\")
765set(OSI_LIBRARIES open_simulation_interface::open_simulation_interface)
766" out)
767 ))
768 (call-with-output-file "sumo.cmake"
769 (lambda (out)
770 (display "set(SUMO_LIBRARIES sumocpp tracicpp)"
771 out))))))
772 (sha256
773 (base32
774 "13xlkhg6z2z1j99l0j5m77lkcvsqkgmy19yjikqy32x1r0hm17df"))))
775 (build-system cmake-build-system)
776 (arguments
777 (list
778 #:configure-flags
779 #~(list "-DDYN_PROTOBUF=TRUE"
780 ;; Missing implot package
781 "-DUSE_IMPLOT=FALSE"
782 "-DDOWNLOAD_EXTERNALS=FALSE")
783 #:phases
784 #~(modify-phases %standard-phases
785 (add-after 'unpack 'fix-cmake
786 (lambda* (#:key inputs outputs #:allow-other-keys)
787 (substitute* "support/cmake/common/locations.cmake"
788 (("\\$\\{CMAKE_SOURCE_DIR\\}/bin")
789 (string-append (assoc-ref outputs "out") "/bin")))))
790 (replace 'check
791 (lambda* (#:key tests? #:allow-other-keys)
792 (with-directory-excursion "EnvironmentSimulator/Unittest/"
793 (for-each invoke (find-files "_test$")))))
794 (add-after 'install 'move-libraries
795 (lambda* (#:key outputs #:allow-other-keys)
796 (let ((out (assoc-ref outputs "out")))
797 (mkdir-p (string-append out "/lib"))
798 (with-directory-excursion (string-append out "/bin")
799 (for-each
800 (lambda (f)
801 (rename-file f (string-append out "/lib/"
802 (basename f))))
803 (find-files "." "\\.(a|so)$")))))))))
804 (inputs (list fmt
805 mesa
806 openscenegraph
807 `(,openscenegraph "pluginlib")
808 open-simulation-interface
809 protobuf
810 pugixml
811 sumo))
812 (native-inputs (list googletest pkg-config))
813 (home-page "https://github.com/esmini/esmini")
814 (synopsis "Basic OpenSCENARIO player")
815 (description "@command{esmini} is a tool to play OpenSCENARIO files.
816It is provided as both a standalone application and a shared library and has
817some support for generating and analysing traffic scenarios..")
818 (license license:mpl2.0)))
819
820(define-public python-fenics-dijitso
821 (package
822 (name "python-fenics-dijitso")
823 (version "2019.1.0")
824 (source
825 (origin
826 (method url-fetch)
827 (uri (pypi-uri "fenics-dijitso" version))
828 (sha256
829 (base32 "0lhqsq8ypdak0ahr2jnyvg07yrqp6wicjxi6k56zx24wp3qg60sc"))))
830 (build-system pyproject-build-system)
831 (arguments
832 (list
833 #:phases
834 #~(modify-phases %standard-phases
835 (add-after 'build 'mpi-setup
836 #$%openmpi-setup)
837 (replace 'check
838 (lambda* (#:key tests? #:allow-other-keys)
839 (when tests?
840 (setenv "HOME" "/tmp")
841 (with-directory-excursion "test"
842 ;; Disable parallel tests to avoid race condition. See
843 ;; https://github.com/pytest-dev/pytest-cov/issues/237.
844 (substitute* "runtests.sh"
845 (("for p in 1 4 8 16; do") "for p in 1; do"))
846 (invoke "./runtests.sh"))))))))
847 (native-inputs
848 (list python-pytest
849 ;; This package has a custom way to run tests.
850 python-pytest-cov
851 python-setuptools))
852 (inputs
853 (list openmpi python-numpy))
854 (propagated-inputs
855 (list python-mpi4py))
856 (home-page "https://bitbucket.org/fenics-project/dijitso/")
857 (synopsis "Distributed just-in-time building of shared libraries")
858 (description
859 "Dijitso provides a core component of the @code{FEniCS} framework,
860namely the just-in-time compilation of C++ code that is generated from
861Python modules. It is called from within a C++ library, using ctypes
862to import the dynamic shared library directly.
863
864As long as the compiled code can provide a simple factory function to
865a class implementing a predefined C++ interface, there is no limit to
866the complexity of that interface. Parallel support depends on the
867@code{mpi4py} interface.")
868 (license license:lgpl3+)))
869
870(define-public python-fenics-ufl
871 (package
872 (name "python-fenics-ufl")
873 (version "2025.2.0")
874 (source
875 (origin
876 (method url-fetch)
877 (uri (pypi-uri "fenics_ufl" version))
878 (sha256
879 (base32 "1k2r7s1c7dqlgkah4jr08lqy4z17h49r94yxjm7ca16vgvqvq1xg"))))
880 (build-system pyproject-build-system)
881 (inputs (list python-numpy))
882 (native-inputs (list python-pytest python-setuptools))
883 (home-page "https://bitbucket.org/fenics-project/ufl/")
884 (synopsis "Unified language for form-compilers")
885 (description
886 "The Unified Form Language (UFL) is a domain specific language for
887declaration of finite element discretizations of variational forms. More
888precisely, it defines a flexible interface for choosing finite element spaces
889and defining expressions for weak forms in a notation close to mathematical
890notation.
891
892UFL is part of the FEniCS Project.")
893 (license license:lgpl3+)))
894
895(define-public python-fenics-ufl-2019
896 (package/inherit python-fenics-ufl
897 (name "python-fenics-ufl")
898 (version "2019.1.0")
899 (source
900 (origin
901 (method url-fetch)
902 (uri (pypi-uri "fenics-ufl" version))
903 (sha256
904 (base32 "10dz8x3lm68x2w3kkqcjask38h0zkhhak26jdbkppr8g9y8wny7p"))))
905 (inputs '())
906 (propagated-inputs (list python-numpy-1))))
907
908;; XXX: This package is quite dated and upstream no longer maintains it: "This
909;; repository was archived by the owner on Feb 21, 2022. It is now read-only."
910;; <https://bitbucket.org/fenics-project/fiat> ->
911;; <https://github.com/FEniCS/fiat> while providing a new refactored fork
912;; <https://github.com/firedrakeproject/fiat>.
913(define-public python-fenics-fiat
914 (package
915 (name "python-fenics-fiat")
916 (version "2019.1.0")
917 (source
918 (origin
919 (method url-fetch)
920 (uri (pypi-uri "fenics-fiat" version))
921 (sha256
922 (base32 "13sc7lma3d2mh43an7i4kkdbbk4cmvxjk45wi43xnjd7qc38zg4b"))))
923 (build-system pyproject-build-system)
924 (arguments
925 (list
926 #:test-flags
927 #~(list
928 ;; FIXME: three FIAT test modules are known to fail with recent
929 ;; versions of pytest (>= 4). These are skipped for FIAT version
930 ;; 2019.1.0 pending an upstream pull request. For details see request
931 ;; #59 at https://bitbucket.org/fenics-project/fiat/.
932 "--ignore=test/regression/"
933 "--ignore=test/unit/test_quadrature.py"
934 "--ignore=test/unit/test_reference_element.py"
935 "-k" (string-join
936 (list "not test_nodality"
937 "test_basis_values")
938 " and not "))))
939 (native-inputs
940 (list python-pytest
941 python-setuptools
942 python-wheel))
943 (propagated-inputs
944 (list python-numpy
945 python-sympy))
946 (home-page "https://bitbucket.org/fenics-project/fiat/")
947 (synopsis "Tabulation of finite element function spaces")
948 (description
949 "The FInite element Automatic Tabulator (FIAT) supports generation of
950arbitrary order instances of the Lagrange elements on lines, triangles, and
951tetrahedra. It is also capable of generating arbitrary order instances of
952Jacobi-type quadrature rules on the same element shapes. Further, H(div) and
953H(curl) conforming finite element spaces such as the families of
954Raviart-Thomas, Brezzi-Douglas-Marini and Nedelec are supported on triangles
955and tetrahedra. Upcoming versions will also support Hermite and nonconforming
956elements.
957
958FIAT is part of the FEniCS Project.")
959 (license license:lgpl3+)))
960
961(define-public python-fenics-ffc
962 (package
963 (name "python-fenics-ffc")
964 (version "2019.1.0.post0")
965 (source
966 (origin
967 (method url-fetch)
968 (uri (pypi-uri "fenics-ffc" version))
969 (sha256
970 (base32 "1f2a44ha65fg3a1prrbrsz4dgvibsv0j5c3pi2m52zi93bhwwgg9"))))
971 (build-system pyproject-build-system)
972 (arguments
973 (list
974 #:phases
975 #~(modify-phases %standard-phases
976 (replace 'check
977 (lambda _
978 (setenv "HOME" (getcwd))
979 (with-directory-excursion "test"
980 ;; FIXME: the tests in subdirectory
981 ;; 'unit/ufc/finite_element' require the ffc_factory
982 ;; extension module. This module, located in the 'libs'
983 ;; subdirectory, needs to be built and made accessible
984 ;; prior to running the tests.
985 (invoke "pytest" "unit/" "--ignore=unit/ufc/")
986 (with-directory-excursion "uflacs"
987 (invoke "pytest" "unit/"))))))))
988 (native-inputs (list python-pytest python-setuptools))
989 (propagated-inputs (list python-fenics-dijitso python-fenics-fiat
990 python-fenics-ufl-2019
991 python-numpy-1))
992 (home-page "https://bitbucket.org/fenics-project/ffc/")
993 (synopsis "Compiler for finite element variational forms")
994 (description
995 "The FEniCS Form Compiler (FFC) is a compiler for finite element
996variational forms. From a high-level description of the form, it generates
997efficient low-level C++ code that can be used to assemble the corresponding
998discrete operator (tensor). In particular, a bilinear form may be assembled
999into a matrix and a linear form may be assembled into a vector. FFC may be
1000used either from the command line (by invoking the @code{ffc} command) or as a
1001Python module (@code{import ffc}).
1002
1003FFC is part of the FEniCS Project.")
1004 ;; There are two files released with a public domain licence;
1005 ;; ufc.h and ufc_geometry.h, in subdirectory 'ffc/backends/ufc'.
1006 (license (list license:public-domain license:lgpl3+))))
1007
1008(define-public fenics-dolfin
1009 (package
1010 (name "fenics-dolfin")
1011 (version "2019.1.0.post0")
1012 (source
1013 (origin
1014 (method url-fetch)
1015 (uri (string-append "https://bitbucket.org/fenics-project/dolfin/get/"
1016 version ".tar.gz"))
1017 (file-name (string-append name "-" version ".tar.gz"))
1018 (sha256
1019 (base32 "1m91hwcq5gfj4qqswp8l8kj58nia48f0n4kq13w0xqj4biq7rla0"))
1020 (patches (search-patches "fenics-dolfin-algorithm.patch"
1021 "fenics-dolfin-demo-init.patch"
1022 "fenics-dolfin-boost.patch"
1023 "fenics-dolfin-config-slepc.patch"
1024 "fenics-dolfin-hdf5-version-check.patch"
1025 "fenics-dolfin-integer-types.patch"))
1026 (modules '((guix build utils)))
1027 (snippet '(begin
1028 ;; Make sure we don't use the bundled test framework.
1029 (delete-file-recursively "test/unit/cpp/catch")
1030 (substitute* "test/unit/cpp/main.cpp"
1031 ;; Use standard search paths for 'catch' header file.
1032 (("#include.*")
1033 "#include <catch.hpp>\n"))
1034 (substitute* "test/unit/cpp/CMakeLists.txt"
1035 ;; Specify directory to find the header file.
1036 (("(^set\\(CATCH_INCLUDE_DIR ).*(/catch\\))" _ front back)
1037 (string-append front "$ENV{CATCH_DIR}/include" back "\n")))))))
1038 (build-system cmake-build-system)
1039 (inputs (list openblas
1040 boost-1.83
1041 eigen
1042 hdf5-parallel-openmpi
1043 libxml2
1044 python-3
1045 pt-scotch32
1046 suitesparse
1047 zlib))
1048 (native-inputs (list catch-framework pkg-config python-setuptools))
1049 (propagated-inputs (list python-fenics-ffc petsc-openmpi slepc-openmpi))
1050 (arguments
1051 (list
1052 #:configure-flags
1053 #~`("-DDOLFIN_ENABLE_DOCS:BOOL=OFF" "-DDOLFIN_ENABLE_HDF5:BOOL=ON"
1054 "-DDOLFIN_ENABLE_MPI:BOOL=ON"
1055 "-DDOLFIN_ENABLE_PARMETIS:BOOL=OFF"
1056 "-DDOLFIN_ENABLE_SCOTCH:BOOL=ON"
1057 "-DDOLFIN_ENABLE_SUNDIALS:BOOL=OFF"
1058 "-DDOLFIN_ENABLE_TRILINOS:BOOL=OFF")
1059 #:phases
1060 #~(modify-phases %standard-phases
1061 (add-after 'patch-usr-bin-file 'mpi-setup
1062 #$%openmpi-setup)
1063 (add-after 'patch-source-shebangs 'set-paths
1064 (lambda _
1065 ;; Define paths to store locations.
1066 (setenv "BLAS_DIR"
1067 #$(this-package-input "openblas"))
1068 (setenv "CATCH_DIR"
1069 #$(this-package-input "catch"))
1070 (setenv "LAPACK_DIR"
1071 #$(this-package-input "openblas"))
1072 (setenv "PETSC_DIR"
1073 #$(this-package-input "petsc"))
1074 (setenv "SLEPC_DIR"
1075 #$(this-package-input "slepc"))
1076 (setenv "SCOTCH_DIR"
1077 #$(this-package-input "scotch"))
1078 (setenv "UMFPACK_DIR"
1079 #$(this-package-input "suitesparse"))))
1080 (add-before 'check 'pre-check
1081 (lambda _
1082 ;; The Dolfin repository uses git-lfs, whereby web links are
1083 ;; substituted for large files. Only the links are downloaded.
1084 ;; The tests that require the absent meshes cannot run and are
1085 ;; skipped.
1086 ;;
1087 ;; One serial test fails and is skipped.
1088 ;; i) demo_multimesh-stokes_serial:
1089 ;; Warning: Found no facets matching domain for boundary
1090 ;; condition.
1091 ;;
1092 ;; One mpi test fails and is skipped.
1093 ;; i) demo_stokes-iterative_mpi:
1094 ;; The MPI_Comm_rank() function was called before MPI_INIT was
1095 ;; invoked.
1096 (call-with-output-file "CTestCustom.cmake"
1097 (lambda (port)
1098 (display (string-append "set(CTEST_CUSTOM_TESTS_IGNORE "
1099 "demo_bcs_serial "
1100 "demo_bcs_mpi "
1101 "demo_eigenvalue_serial "
1102 "demo_eigenvalue_mpi "
1103 "demo_navier-stokes_serial "
1104 "demo_navier-stokes_mpi "
1105 "demo_stokes-taylor-hood_serial "
1106 "demo_stokes-taylor-hood_mpi "
1107 "demo_subdomains_serial "
1108 "demo_advection-diffusion_serial "
1109 "demo_advection-diffusion_mpi "
1110 "demo_auto-adaptive-navier-stokes_serial "
1111 "demo_contact-vi-snes_serial "
1112 "demo_contact-vi-snes_mpi "
1113 "demo_contact-vi-tao_serial "
1114 "demo_contact-vi-tao_mpi "
1115 "demo_curl-curl_serial "
1116 "demo_curl-curl_mpi "
1117 "demo_dg-advection-diffusion_serial "
1118 "demo_dg-advection-diffusion_mpi "
1119 "demo_elasticity_serial "
1120 "demo_elasticity_mpi "
1121 "demo_elastodynamics_serial "
1122 "demo_elastodynamics_mpi "
1123 "demo_lift-drag_serial "
1124 "demo_lift-drag_mpi "
1125 "demo_mesh-quality_serial "
1126 "demo_mesh-quality_mpi "
1127 "demo_multimesh-stokes_serial "
1128 "demo_stokes-iterative_mpi"
1129 ")\n") port)))))
1130 (replace 'check
1131 (lambda* (#:key tests? #:allow-other-keys)
1132 (when tests?
1133 (invoke "make" "unittests")
1134 (invoke "make" "demos")
1135 (invoke "ctest" "-R" "unittests")
1136 (invoke "ctest" "-R" "demo" "-R" "serial")
1137 (invoke "ctest" "-R" "demo" "-R" "mpi")))))))
1138 (home-page "https://bitbucket.org/fenics-project/dolfin/")
1139 (synopsis "Problem solving environment for differential equations")
1140 (description
1141 "DOLFIN is a computational framework for finding numerical
1142solutions to problems described by differential equations. Numerical
1143models in DOLFIN are constructed using general families of finite
1144elements. Data structures are provided for discretizing the governing
1145system on a computational mesh. A compact syntax, similar to
1146mathematical notation, is made available for defining function spaces
1147and expressing variational forms. Interfaces to specialized matrix
1148solvers are provided for solving the resultant linear systems.
1149
1150@code{fenics-dolfin} is part of the FEniCS project. It is the C++
1151user interface to the FEniCS core components and external libraries.")
1152 ;; The source code for the DOLFIN C++ library is licensed under the
1153 ;; GNU Lesser General Public License, version 3 or later, with the
1154 ;; following exceptions:
1155 ;;
1156 ;; public-domain: dolfin/geometry/predicates.cpp
1157 ;; dolfin/geometry/predicates.h
1158 ;;
1159 ;; zlib: dolfin/io/base64.cpp
1160 ;; dolfin/io/base64.h
1161 ;;
1162 ;; expat: dolfin/io/pugiconfig.hpp
1163 ;; dolfin/io/pugixml.cpp
1164 ;; dolfin/io/pugixml.hpp
1165 (license (list license:public-domain license:zlib license:expat
1166 license:lgpl3+))))
1167
1168(define-public fenics
1169 (package/inherit fenics-dolfin
1170 (name "fenics")
1171 (build-system pyproject-build-system)
1172 (arguments
1173 (list
1174 #:test-flags
1175 #~(list
1176 "unit"
1177 ;; This test fails and is ignored.
1178 "--deselect"
1179 "unit/nls/test_PETScSNES_solver.py::test_snes_set_from_options"
1180 ;; These tests are flaky.
1181 "--deselect=unit/common/test_timer.py::test_context_manager_named"
1182 "--deselect=unit/common/test_timer.py::test_context_manager_anonymous"
1183 ;; FIXME: Tests with binary encoded hdf5 files fail with a
1184 ;; segfault. See fenics-project DOLFIN commit 6fbc9fb.
1185 "--ignore=unit/io/test_XDMF.py"
1186 ;; Assertions failed.
1187 "--deselect=unit/common/test_timer.py::test_context_manager_named"
1188 "--deselect=unit/common/test_timer.py::test_context_manager_anonymous"
1189 ;; TypeError: 'float' object cannot be interpreted as an integer.
1190 "--ignore=unit/common/test_timer.py")
1191 #:phases
1192 #~(modify-phases %standard-phases
1193 (add-after 'unpack 'relax-requirements
1194 (lambda _
1195 (substitute* "python/setup.py"
1196 (("pybind11==") "pybind11>="))))
1197 (add-after 'unpack 'set-dolfin-pc-file-name
1198 (lambda* (#:key inputs #:allow-other-keys)
1199 ;; Instead of cluttering the user's PKG_CONFIG_PATH environment
1200 ;; variable, hard-code the 'dolfin.pc' absolute file name.
1201 (let ((pc-file (search-input-file inputs
1202 "/lib/pkgconfig/dolfin.pc")))
1203 (substitute* "python/dolfin/jit/jit.py"
1204 (("pkgconfig\\.parse\\(\"dolfin\"\\)")
1205 (string-append "pkgconfig.parse(\"" pc-file "\")"))))))
1206 (add-after 'patch-source-shebangs 'set-paths
1207 (lambda _
1208 ;; Define paths to store locations.
1209 (setenv "PYBIND11_DIR" #$(this-package-input "pybind11"))
1210 ;; Move to python sub-directory.
1211 (chdir "python")))
1212 (add-after 'build 'mpi-setup #$%openmpi-setup)
1213 (add-before 'check 'pre-check
1214 (lambda _
1215 ;; Exclude three tests that generate 'NotImplementedError' in
1216 ;; matplotlib v3.1.2. See
1217 ;; <https://github.com/matplotlib/matplotlib/issues/15382>.
1218 ;; Also exclude tests that require meshes supplied by git-lfs.
1219 (substitute* "demo/test.py"
1220 (("(.*stem !.*)" line)
1221 (format #f "~a
1222excludeList = [~{ '~a',~% ~}]
1223demos = [d for d in demos if d[0].stem not in excludeList]~%"
1224 line
1225 (list "built-in-meshes"
1226 "hyperelasticity"
1227 "elasticity"
1228 "multimesh-quadrature"
1229 "multimesh-marking"
1230 "mixed-poisson-sphere"
1231 "mesh-quality"
1232 "lift-drag"
1233 "elastodynamics"
1234 "dg-advection-diffusion"
1235 "curl-curl"
1236 "contact-vi-tao"
1237 "contact-vi-snes"
1238 "collision-detection"
1239 "buckling-tao"
1240 "auto-adaptive-navier-stokes"
1241 "advection-diffusion"
1242 "subdomains"
1243 "stokes-taylor-hood"
1244 "stokes-mini"
1245 "navier-stokes"
1246 "eigenvalue"))))
1247 ;; Do not test for expired numpy aliases.
1248 (substitute* "test/unit/la/test_vector.py"
1249 ((" numpy.float\\(42.0\\),") "")
1250 (("^.*numpy.int\\(42.0\\).*$") ""))
1251 (substitute* "test/unit/la/test_la_basic.py"
1252 ((" int,") " ")
1253 (("\\[int,") "["))
1254 (setenv "HOME" (getcwd))
1255 ;; Restrict OpenBLAS to MPI-only in preference to MPI+OpenMP.
1256 (setenv "OPENBLAS_NUM_THREADS" "1")))
1257 (replace 'check
1258 (lambda* (#:key tests? test-flags #:allow-other-keys)
1259 (when tests?
1260 (with-directory-excursion "test"
1261 (apply invoke "pytest" test-flags)))))
1262 (add-after 'install 'install-demo-files
1263 (lambda _
1264 (let* ((demos (string-append #$output
1265 "/share/python-dolfin/demo")))
1266 (mkdir-p demos)
1267 (with-directory-excursion "demo"
1268 (for-each (lambda (file)
1269 (let* ((dir (dirname file))
1270 (tgt-dir (string-append demos "/" dir)))
1271 (unless (equal? "." dir)
1272 (mkdir-p tgt-dir)
1273 (install-file file tgt-dir))))
1274 (find-files "." ".*\\.(py|gz|xdmf)$")))))))))
1275 (inputs
1276 (modify-inputs inputs
1277 (delete "python")
1278 (prepend pybind11-2 python-matplotlib)))
1279 (native-inputs
1280 (modify-inputs native-inputs
1281 (prepend cmake-minimal
1282 python-decorator
1283 python-numpy-1
1284 python-ply
1285 python-pytest
1286 python-setuptools)))
1287 (propagated-inputs
1288 (list fenics-dolfin
1289 python-petsc4py
1290 python-slepc4py
1291 ;; 'dolfin/jit/jit.py' parses 'dolfin.pc' at runtime.
1292 python-pkgconfig))
1293 (home-page "https://fenicsproject.org/")
1294 (synopsis "High-level environment for solving differential equations")
1295 (description
1296 "@code{fenics} is a computing platform for solving general classes of
1297problems that involve differential equations. @code{fenics} facilitates
1298access to efficient methods for dealing with ordinary differential
1299equations (ODEs) and partial differential equations (PDEs). Systems of
1300equations such as these are commonly encountered in areas of engineering,
1301mathematics and the physical sciences. It is particularly well-suited to
1302problems that can be solved using the Finite Element Method (FEM).
1303
1304@code{fenics} is the top level of the set of packages that are developed
1305within the FEniCS project. It provides the python user interface to the
1306FEniCS core components and external libraries.")
1307 (license license:lgpl3+)))
1308
1309(define-public fullswof-2d
1310 (let ((revision 505)
1311 (release "1.09.01"))
1312 (package
1313 (name "fullswof-2d")
1314 (version release)
1315 (source (origin
1316 (method svn-fetch)
1317 (uri (svn-reference
1318 (url (string-append "https://subversion.renater.fr/"
1319 "anonscm/svn/fullswof-2d/tags/"
1320 "release-" version))
1321 (revision revision)))
1322 (file-name (string-append "fullswof-2d-" version "-checkout"))
1323 (sha256
1324 (base32
1325 "16v08dx7h7n4wyddzbwimazwyj74ynis12mpjfkay4243npy44b8"))))
1326 (build-system gnu-build-system)
1327 (native-inputs
1328 (list inetutils)) ; for 'hostname', used in the check phase
1329 (arguments
1330 `(#:phases
1331 (modify-phases %standard-phases
1332 (delete 'configure) ; no configure script
1333 (add-after 'build 'build-tools
1334 (lambda _
1335 (with-directory-excursion "Tools/ConvertFormat"
1336 (invoke "make" "../../bin/asc2xyz")
1337 (invoke "make" "../../bin/xyz2asc"))
1338 (with-directory-excursion "Tools/ExtractWindow"
1339 (invoke "make" "../../bin/cropxyz"))
1340 #t))
1341 (replace 'check ; no check target
1342 (lambda _
1343 (invoke "make" "benchref")))
1344 (replace 'install ; no install target
1345 (lambda* (#:key outputs #:allow-other-keys)
1346 (let* ((out (assoc-ref outputs "out"))
1347 (bin (string-append out "/bin"))
1348 (doc (string-append
1349 out "/share/doc/" ,name "-" ,version))
1350 (examples (string-append doc "/Examples")))
1351 (with-directory-excursion "bin"
1352 (for-each (lambda (binary) (install-file binary bin))
1353 (list "asc2xyz" "xyz2asc" "cropxyz"
1354 "FullSWOF_2D")))
1355 (with-directory-excursion "doc"
1356 (for-each (lambda (pdf) (install-file pdf doc))
1357 (list "Documentation.pdf" "refman.pdf")))
1358 (with-directory-excursion "Tools"
1359 (for-each (lambda (dir)
1360 (copy-file
1361 (string-append dir "/README.txt")
1362 (string-append doc "/README_" dir ".txt")))
1363 (list "ConvertFormat" "ExtractWindow")))
1364 (copy-recursively "Examples" examples)
1365 #t))))))
1366 (home-page "https://www.idpoisson.fr/fullswof/")
1367 (synopsis "Two dimensional flow solver for flood modelling")
1368 (description "@code{FullSWOF_2d} is a numerical tool for solving
1369the shallow water equations on structured grids. The name FullSWOF
1370refers to the Full form of the Shallow Water equations for Overland
1371Flow. The discretized system of equations is solved using the finite
1372volume method. A choice of shock-capturing methods is available to
1373locate the transition boundaries between the wet areas and the dry
1374areas in the model. A semi-implicit method is used to advance the
1375solution in time. The tool is typically applied to the modelling of
1376river flooding.")
1377 (license license:cecill))))
1378
1379(define-public python-meshio
1380 (package
1381 (name "python-meshio")
1382 (version "5.3.5")
1383 (source
1384 (origin
1385 ;; Using PyPI rather than git because some test files must be
1386 ;; downloaded through git-fls.
1387 (method url-fetch)
1388 (uri (pypi-uri "meshio" version))
1389 (sha256
1390 (base32 "0vaqhygr2d186qixvfckzqf4447674ylnc0rl5pa16zjv6mh27zj"))))
1391 (build-system pyproject-build-system)
1392 (arguments
1393 (list
1394 #:test-flags
1395 ;; XXX: See: <https://github.com/nschloe/meshio/issues/1499>.
1396 ;; ValueError: invalid literal for int() with base 10: 'np.int64(4)'
1397 #~(list "--deselect=tests/test_dolfin.py::test_dolfin[mesh3]"
1398 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh9]"
1399 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh10]"
1400 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh11]"
1401 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh12]"
1402 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh13]"
1403 "--deselect=tests/test_gmsh.py::test_gmsh22[False-mesh14]"
1404 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh8]"
1405 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh9]"
1406 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh10]"
1407 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh11]"
1408 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh12]"
1409 "--deselect=tests/test_gmsh.py::test_gmsh40[False-mesh13]"
1410 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh8]"
1411 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh9]"
1412 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh10]"
1413 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh11]"
1414 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh12]"
1415 "--deselect=tests/test_gmsh.py::test_gmsh41[False-mesh13]"
1416 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh0]"
1417 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh1]"
1418 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh2]"
1419 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh3]"
1420 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh4]"
1421 "--deselect=tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh5]"
1422 ;; XXX: <...>/h5py/defs.cpython-312-x86_64-linux-gnu.so:
1423 ;; undefined symbol: H5Pset_dxpl_mpio
1424 "--deselect=tests/test_xdmf.py"
1425 "--deselect=tests/test_hmf.py"
1426 "--deselect=tests/test_cgns.py::test[mesh0]")))
1427 (inputs (list python-h5py python-netcdf4))
1428 (native-inputs (list python-pytest python-setuptools))
1429 (propagated-inputs (list python-numpy python-rich))
1430 (home-page "https://github.com/nschloe/meshio")
1431 (synopsis "I/O for mesh files")
1432 (description
1433 "There are various file formats available for representing unstructured
1434meshes and mesh data. The @code{meshio} package is able to read and write
1435mesh files in many formats and to convert files from one format to another.
1436Formats such as cgns, h5m, gmsh, xdmf and vtk are supported. The package
1437provides command-line tools and a collection of Python modules for
1438programmatic use.")
1439 (license license:expat)))
1440
1441(define-public python-pygmsh
1442 (package
1443 (name "python-pygmsh")
1444 (version "7.1.17")
1445 (source
1446 (origin
1447 (method git-fetch)
1448 (uri (git-reference
1449 (url "https://github.com/nschloe/pygmsh")
1450 (commit (string-append "v" version))))
1451 (file-name (git-file-name name version))
1452 (sha256
1453 (base32
1454 "11flp2c4ynk1fhanf4mqyzrpd0gjbnv6afrwwc7xi3mb6ms69lr0"))))
1455 (build-system pyproject-build-system)
1456 (arguments
1457 (list
1458 #:phases
1459 #~(modify-phases %standard-phases
1460 (add-after 'unpack 'workaround-gmsh-detection-failure
1461 (lambda _
1462 ;; Due to lack of metadata, the gmsh Python package is not
1463 ;; detected although importable.
1464 (substitute* "pyproject.toml"
1465 (("\"gmsh\",") "")))))))
1466 (native-inputs (list python-flit-core python-pytest))
1467 (propagated-inputs (list gmsh python-meshio python-numpy))
1468 (home-page "https://github.com/nschloe/pygmsh")
1469 (synopsis "Python frontend for Gmsh")
1470 (description "The goal of @code{pygmsh} is to combine the power of
1471Gmsh with the versatility of Python. The package generalises many of
1472the methods and functions that comprise the Gmsh Python API. In this
1473way the meshing of complex geometries using high-level abstractions is
1474made possible. The package provides a Python library together with a
1475command-line utility for mesh optimisation.")
1476 (license license:gpl3+)))
1477
1478(define-public python-simpy
1479 (package
1480 (name "python-simpy")
1481 (version "4.1.1")
1482 (source
1483 (origin
1484 (method url-fetch)
1485 (uri (pypi-uri "simpy" version))
1486 (sha256
1487 (base32 "19h1a3wxygyi819njmnl8cbmzvflqv3hpki0iq71xcc4g057bl06"))))
1488 (build-system pyproject-build-system)
1489 (arguments
1490 (list
1491 ;; tests: 141 passed, 10 deselected, 10 warnings
1492 #:test-flags
1493 ;; Doctests require deprecated python-py.
1494 #~(list "--ignore=docs/")))
1495 (native-inputs
1496 (list python-pytest
1497 python-setuptools
1498 python-setuptools-scm))
1499 (home-page "https://gitlab.com/team-simpy/simpy")
1500 (synopsis "Process-based discrete-event simulation framework")
1501 (description
1502 "SimPy is a process-based discrete-event simulation framework based
1503on standard Python. Processes in SimPy are defined by Python generator
1504functions and can, for example, be used to model active components like
1505customers, vehicles or agents. SimPy also provides various types of shared
1506resources to model limited capacity congestion points (like servers, checkout
1507counters and tunnels).")
1508 (license license:bsd-2)))
1509
1510(define %commonroad-dont-install-license-at-root
1511 #~(substitute* "setup.py"
1512 (("data_files=\\[\\('.', \\['LICENSE.txt'\\]\\)\\],")
1513 "")))
1514
1515(define-public python-commonroad-vehicle-models
1516 (package
1517 (name "python-commonroad-vehicle-models")
1518 (version "3.0.2")
1519 (source (origin
1520 (method url-fetch)
1521 (uri (pypi-uri "commonroad-vehicle-models" version))
1522 (sha256
1523 (base32
1524 "13jg0cys7y4n7rg548w6mxk9g10gd5qxmj4ynrlriczpffqy6kc7"))))
1525 (build-system pyproject-build-system)
1526 (arguments
1527 (list
1528 #:test-flags
1529 #~(list "--ignore=scripts/test_vehicle.py" ; import error
1530 "-k" "not test_std") ; flaky
1531 #:phases
1532 #~(modify-phases %standard-phases
1533 (add-after 'unpack 'fix-setup.py
1534 (lambda _
1535 #$%commonroad-dont-install-license-at-root)))))
1536 (native-inputs
1537 (list python-matplotlib
1538 python-pytest
1539 python-scipy
1540 python-setuptools))
1541 (propagated-inputs (list python-numpy python-omegaconf))
1542 (home-page "https://commonroad.in.tum.de/")
1543 (synopsis "CommonRoad vehicle models")
1544 (description "This package provides vehicle models used in CommonRoad
1545benchmarks. Varying abstraction levels are used ranging from kinematic single
1546track models to multi-body models.")
1547 (license license:bsd-3)))
1548
1549(define-public python-commonroad-io
1550 (package
1551 (name "python-commonroad-io")
1552 (version "2022.3")
1553 (source (origin
1554 (method url-fetch)
1555 (uri (pypi-uri "commonroad-io" version))
1556 (sha256
1557 (base32
1558 "1cj9zj567mca8xb8sx9h3nnl2cccv6vh8h73imgpq61cimk9mvas"))))
1559 (build-system pyproject-build-system)
1560 (arguments
1561 (list
1562 #:tests? #f ; No tests.
1563 #:phases
1564 #~(modify-phases %standard-phases
1565 (add-after 'unpack 'fix-setup.py
1566 (lambda _
1567 (substitute* "setup.py"
1568 (("protobuf==3.20.1") "protobuf >= 3.20.1"))
1569 #$%commonroad-dont-install-license-at-root)))))
1570 (propagated-inputs (list python-commonroad-vehicle-models
1571 python-iso3166
1572 python-lxml
1573 python-matplotlib
1574 python-networkx
1575 python-numpy
1576 python-omegaconf
1577 python-pillow
1578 python-protobuf
1579 python-rtree
1580 python-scipy
1581 python-shapely
1582 python-tqdm))
1583 (native-inputs (list python-lxml python-setuptools))
1584 (home-page "https://commonroad.in.tum.de/")
1585 (synopsis "Read, write, and visualize CommonRoad scenarios")
1586 (description "This package provides methods to read, write, and visualize
1587CommonRoad scenarios and planning problems. It can be used as a framework for
1588implementing motion planning algorithms to solve CommonRoad Benchmarks
1589and is the basis for other tools of the CommonRoad Framework.")
1590 (license license:bsd-3)))
1591
1592(define-public python-commonroad-route-planner
1593 (package
1594 (name "python-commonroad-route-planner")
1595 (version "2022.3")
1596 (source (origin
1597 (method git-fetch)
1598 (uri (git-reference
1599 (url "https://gitlab.lrz.de/tum-cps/commonroad-route-planner")
1600 (commit version)))
1601 (file-name (git-file-name name version))
1602 (sha256
1603 (base32
1604 "0xn0l7bzmj56d4mlqacvbl8mdvsffkg2fn2lzfmis5jl4vp99ipf"))))
1605 (arguments
1606 (list
1607 #:tests? #f ; No tests.
1608 #:phases
1609 #~(modify-phases %standard-phases
1610 (add-after 'unpack 'fix-setup.py
1611 (lambda _
1612 #$%commonroad-dont-install-license-at-root)))))
1613 (build-system pyproject-build-system)
1614 (native-inputs (list python-setuptools))
1615 (propagated-inputs (list python-commonroad-io
1616 python-matplotlib
1617 python-networkx
1618 python-numpy
1619 python-setuptools
1620 python-shapely))
1621 (home-page "https://gitlab.lrz.de/tum-cps/commonroad-route-planner")
1622 (synopsis "Route planner for CommonRoad scenarios")
1623 (description
1624 "This package provides functions for route planning, that is finding
1625sequences that lead from a given start lanelet to some goal lanelet(s).")
1626 (license license:bsd-3)))
1627
1628(define-public sumo
1629 (package
1630 (name "sumo")
1631 (version "1.27.1")
1632 (source (origin
1633 (method git-fetch)
1634 (uri (git-reference
1635 (url "https://github.com/eclipse/sumo")
1636 (commit (string-append "v"
1637 (string-replace-substring version
1638 "." "_")))))
1639 (file-name (git-file-name name version))
1640 (sha256
1641 (base32
1642 "0l2bqxs5xjxx23aagxw5wvr1sz325ldnyx1l5gvhbvhvpxqg64xh"))))
1643 (build-system cmake-build-system)
1644 (arguments
1645 (list
1646 #:phases
1647 #~(modify-phases %standard-phases
1648 (add-after 'unpack 'disable-problematic-tests
1649 (lambda _
1650 (substitute* "CMakeLists.txt"
1651 ;; docs/example appears to be missing
1652 (("add_test\\(exampletest .*") ""))
1653 (substitute* "src/traci_testclient/CMakeLists.txt"
1654 ;; requires network connection (at least to localhost)
1655 (("add_test\\(NAME libtracitest .*") "")))))))
1656 (inputs (list eigen
1657 freetype
1658 fontconfig
1659 ffmpeg
1660 fox
1661 gdal
1662 glu
1663 gperftools ; tcmalloc
1664 libjpeg-turbo
1665 libtiff
1666 libx11
1667 libxcursor
1668 libxft
1669 libxi
1670 libxrandr
1671 libxrender
1672 openscenegraph
1673 proj
1674 python
1675 xerces-c
1676 zlib))
1677 (native-inputs (list googletest python))
1678 (home-page "https://eclipse.org/sumo")
1679 (synopsis "Traffic simulator")
1680 (description "@acronym{SUMO, Simulation of Urban MObility} is a traffic
1681simulation package designed to handle large road networks and different modes
1682of transportation -- including road vehicles, public transport and pedestrians.
1683Included with SUMO is a wealth of supporting tools which automate core tasks
1684for the creation, the execution and evaluation of traffic simulations,
1685such as network import, route calculations, visualization and emission
1686calculation. SUMO can be enhanced with custom models and provides various
1687APIs to remotely control the simulation.")
1688 (license (list license:epl2.0 license:gpl2+))))