gnu: shadow: Return #t from all phases.
[jackhill/guix/guix.git] / gnu / packages / simulation.scm
CommitLineData
8f21aa22
PG
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2017 Paul Garlick <pgarlick@tourbillion-technology.com>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (gnu packages simulation)
20 #:use-module (gnu packages)
21 #:use-module (gnu packages base)
22 #:use-module (gnu packages bash)
23 #:use-module (gnu packages bison)
24 #:use-module (gnu packages boost)
25 #:use-module (gnu packages compression)
26 #:use-module (gnu packages flex)
27 #:use-module (gnu packages gettext)
28 #:use-module (gnu packages gcc)
29 #:use-module (gnu packages gl)
30 #:use-module (gnu packages graphics)
31 #:use-module (gnu packages gtk)
32 #:use-module (gnu packages linux)
33 #:use-module (gnu packages m4)
34 #:use-module (gnu packages maths)
35 #:use-module (gnu packages mpi)
36 #:use-module (gnu packages multiprecision)
37 #:use-module (gnu packages ncurses)
38 #:use-module (gnu packages readline)
39 #:use-module (gnu packages tls)
40 #:use-module (gnu packages version-control)
41 #:use-module (gnu packages xml)
42 #:use-module (gnu packages xorg)
43 #:use-module (guix download)
44 #:use-module (guix build utils)
45 #:use-module (guix build-system gnu)
46 #:use-module ((guix licenses) #:prefix license:)
47 #:use-module (guix packages)
48 #:use-module (guix utils)
49 #:use-module (ice-9 ftw)
50 #:use-module (ice-9 regex)
51 #:use-module (srfi srfi-1))
52
53(define-public openfoam
54 (package
55 (name "openfoam")
56 (version "4.1")
57 (source
58 (origin
59 (method url-fetch)
60 (uri (string-append
61 "http://dl.openfoam.org/source/"
62 (string-map (lambda (x) (if (eq? x #\.) #\- x)) version)))
63 (file-name (string-append name "-" version ".tar.gz"))
64 (sha256
65 (base32 "0cgxh4h2hf50qbvvdg5miwc2nympb0nrv3md96vb3gbs9vk8vq9d"))
66 (patches (search-patches "openfoam-4.1-cleanup.patch"))))
67 (build-system gnu-build-system)
68 (inputs
69 `(("boost" ,boost)
70 ("cgal" ,cgal)
71 ("flex" ,flex)
72 ("git" ,git)
73 ("gmp" ,gmp)
74 ("libxt" ,libxt)
75 ("metis" ,metis)
76 ("mpfr" ,mpfr)
77 ("ncurses" ,ncurses)
78 ("readline" ,readline)
79 ("scotch" ,pt-scotch32)
80 ("zlib" ,zlib)))
81 (native-inputs
82 `(("bison" ,bison)))
83 (propagated-inputs
84 `(("gzip" ,gzip)
85 ("gnuplot" ,gnuplot)
86 ("openmpi" ,openmpi)))
f1de0e37
DL
87 (outputs '("debug" ;~60MB
88 "out"))
8f21aa22
PG
89 (arguments
90 `( ;; Executable files and shared libraries are located in the 'platforms'
91 ;; subdirectory.
92 #:strip-directories (list (string-append
93 "lib/OpenFOAM-" ,version
94 "/platforms/linux64GccDPInt32Opt/bin")
95 (string-append
96 "lib/OpenFOAM-" ,version
97 "/platforms/linux64GccDPInt32Opt/lib"))
98 #:tests? #f ; no tests to run
99
100 #:modules ((ice-9 ftw)
101 (ice-9 regex)
102 (guix build gnu-build-system)
103 (guix build utils))
104
105 #:phases (modify-phases %standard-phases
106 (add-after 'unpack 'rename-build-directory
107 (lambda _
108 (chdir "..")
109 ;; Use 'OpenFOAM-version' convention to match the file
110 ;; name expectations in the build phase.
111 (let ((unpack-dir (string-append
112 (getcwd) "/"
113 (list-ref (scandir (getcwd) (lambda (name)
114 (string-match "^OpenFOAM" name))) 0)))
115 (build-dir (string-append
116 (getcwd) "/OpenFOAM-" ,version)))
117 (rename-file unpack-dir build-dir) ; rename build directory
118 (chdir (basename build-dir))) ; move to build directory
119 #t))
120 (delete 'configure) ; no configure phase
121 (replace 'build
122 (lambda _
123 (let ((libraries '("boost" "cgal" "gmp" "metis" "mpfr" "scotch")))
124 ;; set variables to define store paths
125 (for-each (lambda (library)
126 (setenv (string-append
127 (string-upcase library) "_ROOT")
128 (assoc-ref %build-inputs library))) libraries))
129 ;; set variables to define package versions
130 (setenv "SCOTCHVERSION" ,(package-version scotch))
131 (setenv "METISVERSION" ,(package-version metis))
132 ;; set variable to pass extra 'rpath' arguments to linker
133 (setenv "LDFLAGS"
134 (string-append
135 "-Wl,"
136 "-rpath=" %output "/lib/OpenFOAM-" ,version
137 "/platforms/linux64GccDPInt32Opt/lib,"
138 "-rpath=" %output "/lib/OpenFOAM-" ,version
139 "/platforms/linux64GccDPInt32Opt/lib/dummy"))
140 ;; compile OpenFOAM libraries and applications
141 (zero? (system (format #f
142 "source ./etc/bashrc && ./Allwmake -j~a"
143 (parallel-job-count))))))
144 (add-after 'build 'update-configuration-files
145 (lambda _
146 ;; record store paths and package versions in
147 ;; configuration files
148 (substitute* "etc/config.sh/CGAL"
149 (("$BOOST_ROOT") (getenv "BOOST_ROOT")))
150 (substitute* "etc/config.sh/CGAL"
151 (("$CGAL_ROOT") (getenv "CGAL_ROOT")))
152 (substitute* "etc/config.sh/metis"
153 (("$METIS_ROOT") (getenv "METIS_ROOT")))
154 (substitute* "etc/config.sh/metis"
155 (("$METISVERSION") (getenv "METISVERSION")))
156 (substitute* "etc/config.sh/scotch"
157 (("$SCOTCH_ROOT") (getenv "SCOTCH_ROOT")))
158 (substitute* "etc/config.sh/scotch"
159 (("$SCOTCHVERSION") (getenv "SCOTCHVERSION")))
160 (substitute* "etc/config.sh/settings"
161 (("$GMP_ROOT") (getenv "GMP_ROOT")))
162 (substitute* "etc/config.sh/settings"
163 (("$MPFR_ROOT") (getenv "MPFR_ROOT")))
164 ;; reset lockDir variable to refer to write-enabled
165 ;; directory
166 (substitute* "wmake/wmake"
167 ((" lockDir=.*$")
168 " lockDir=$HOME/.$WM_PROJECT/.wmake\n"))
169 (substitute* "wmake/wmakeScheduler"
170 (("lockDir=.*$")
171 "lockDir=$HOME/.$WM_PROJECT/.wmake\n"))
172 (substitute* "wmake/wmakeSchedulerUptime"
173 (("lockDir=.*$")
174 "lockDir=$HOME/.$WM_PROJECT/.wmake\n"))
175 #t))
f1de0e37
DL
176 (add-after 'build 'cleanup
177 ;; Avoid unncessary, voluminous object and dep files.
178 (lambda _
179 (delete-file-recursively
180 "platforms/linux64GccDPInt32Opt/src")
181 (delete-file-recursively
182 "platforms/linux64GccDPInt32OptSYSTEMOPENMPI")
183 (for-each delete-file (find-files "." "\\.o$"))
184 #t))
8f21aa22
PG
185 (replace 'install
186 (lambda _
187 ;; use 'OpenFOAM-version' convention
188 (let ((install-dir (string-append
189 %output "/lib/OpenFOAM-" ,version)))
190 (mkdir-p install-dir) ; create install directory
191 ;; move contents of build directory to install directory
192 (copy-recursively "." install-dir))))
193 (add-after 'install 'add-symbolic-link
194 (lambda _
195 ;; add symbolic link for standard 'bin' directory
196 (symlink
197 (string-append "./lib/OpenFOAM-" ,version
198 "/platforms/linux64GccDPInt32Opt/bin")
199 (string-append %output "/bin"))
200 #t)))))
201 ;; Note:
202 ;; Tutorial files are installed read-only in /gnu/store.
203 ;; To allow write permissions on files copied from the store a
204 ;; 'chmod' step is needed before running the applications. For
205 ;; example, from a user's login:
206 ;; $ source $GUIX_PROFILE/lib/OpenFOAM-4.1/etc/bashrc
207 ;; $ mkdir -p $FOAM_RUN
208 ;; $ cd $FOAM_RUN
a836e9f5
PG
209 ;; $ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
210 ;; $ cd pitzDaily
8f21aa22
PG
211 ;; $ chmod -R u+w .
212 ;; $ blockMesh
213 (synopsis "Framework for numerical simulation of fluid flow")
214 (description "OpenFOAM provides a set of solvers and methods for tackling
215problems in the field of Computational Fluid Dynamics (CFD). It is written in
216C++. Governing equations such as the Navier-Stokes equations can be solved in
217integral form. Physical processes such as phase change, droplet transport and
218chemical reaction can be modelled. Numerical methods are included to deal with
219sharp gradients, such as those encountered in flows with shock waves and flows
220with gas/liquid interfaces. Large problems may be split into smaller, connected
b6598237 221problems for efficient solution on parallel systems.")
8f21aa22
PG
222 (license license:gpl3+)
223 (home-page "https://openfoam.org")))