gnu: Add openfoam-org. Deprecate openfoam.

* gnu/packages/patches/openfoam-4.1-cleanup.patch: Delete file.
* gnu/local.mk: Remove it.
* gnu/packages/simulation.scm (openfoam-org): New variable.
(openfoam): Mark as deprecated.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
reza 2023-06-24 21:38:04 +00:00 committed by Ludovic Courtès
parent 66158f535a
commit 5d77091cfc
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
3 changed files with 304 additions and 405 deletions

View file

@ -1677,7 +1677,6 @@ dist_patch_DATA = \
%D%/packages/patches/openboardview-use-system-mpc.patch \ %D%/packages/patches/openboardview-use-system-mpc.patch \
%D%/packages/patches/openbox-python3.patch \ %D%/packages/patches/openbox-python3.patch \
%D%/packages/patches/opencolorio-fix-build-with-gcc11.patch \ %D%/packages/patches/opencolorio-fix-build-with-gcc11.patch \
%D%/packages/patches/openfoam-4.1-cleanup.patch \
%D%/packages/patches/openjdk-9-pointer-comparison.patch \ %D%/packages/patches/openjdk-9-pointer-comparison.patch \
%D%/packages/patches/openjdk-9-setsignalhandler.patch \ %D%/packages/patches/openjdk-9-setsignalhandler.patch \
%D%/packages/patches/openjdk-10-idlj-reproducibility.patch \ %D%/packages/patches/openjdk-10-idlj-reproducibility.patch \

View file

@ -1,243 +0,0 @@
# This patch removes all need for the ThirdParty files of OpenFOAM.
# Derived from EasyBuild patch by Ward Poelmans <wpoely86@gmail.com>.
# Modified for GNU Guix by Paul Garlick <pgarlick@tourbillion-technology.com>.
diff -ur OpenFOAM-4.x-version-4.1.org/applications/utilities/mesh/manipulation/setSet/Allwmake OpenFOAM-4.x-version-4.1/applications/utilities/mesh/manipulation/setSet/Allwmake
--- OpenFOAM-4.x-version-4.1.org/applications/utilities/mesh/manipulation/setSet/Allwmake
+++ OpenFOAM-4.x-version-4.1/applications/utilities/mesh/manipulation/setSet/Allwmake
@@ -9,7 +9,7 @@
#
# use readline if available
#
-if [ -f /usr/include/readline/readline.h ]
+if true
then
echo "Found <readline/readline.h> -- enabling readline support."
export COMP_FLAGS="-DHAS_READLINE"
diff -ur OpenFOAM-4.x-version-4.1.org/etc/bashrc OpenFOAM-4.x-version-4.1/etc/bashrc
--- OpenFOAM-4.x-version-4.1.org/etc/bashrc
+++ OpenFOAM-4.x-version-4.1/etc/bashrc
@@ -43,8 +43,10 @@
# Please set to the appropriate path if the default is not correct.
#
[ $BASH_SOURCE ] && \
-export FOAM_INST_DIR=$(cd ${BASH_SOURCE%/*/*/*} && pwd -P) || \
+export FOAM_INST_DIR=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P) || \
export FOAM_INST_DIR=$HOME/$WM_PROJECT
+# For GNU Guix: set initially for build then re-set at runtime
+#
# export FOAM_INST_DIR=~$WM_PROJECT
# export FOAM_INST_DIR=/opt/$WM_PROJECT
# export FOAM_INST_DIR=/usr/local/$WM_PROJECT
diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/CGAL OpenFOAM-4.x-version-4.1/etc/config.sh/CGAL
--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/CGAL
+++ OpenFOAM-4.x-version-4.1/etc/config.sh/CGAL
@@ -36,37 +36,7 @@
#
#------------------------------------------------------------------------------
-boost_version=boost-system
-cgal_version=cgal-system
-#cgal_version=CGAL-4.8
-
-if [ -z "$SOURCE_CGAL_VERSIONS_ONLY" ]
-then
-
- common_path=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
-
- export BOOST_ARCH_PATH=$common_path/$boost_version
- export CGAL_ARCH_PATH=$common_path/$cgal_version
-
- if [ "$FOAM_VERBOSE" -a "$PS1" ]
- then
- echo "Using CGAL and boost" 1>&2
- echo " $cgal_version at $CGAL_ARCH_PATH" 1>&2
- echo " $boost_version at $BOOST_ARCH_PATH" 1>&2
- fi
-
- if [ -d "$CGAL_ARCH_PATH" -a "$cgal_version" != "cgal-system" ]
- then
- _foamAddLib $CGAL_ARCH_PATH/lib
- fi
-
- if [ -d "$BOOST_ARCH_PATH" -a "$boost_version" != "boost-system" ]
- then
- _foamAddLib $BOOST_ARCH_PATH/lib
- fi
-
- unset boost_version cgal_version common_path
-
-fi
+export CGAL_ARCH_PATH=$CGAL_ROOT
+export BOOST_ARCH_PATH=$BOOST_ROOT
#------------------------------------------------------------------------------
diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/gperftools OpenFOAM-4.x-version-4.1/etc/config.sh/gperftools
--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/gperftools
+++ OpenFOAM-4.x-version-4.1/etc/config.sh/gperftools
@@ -29,13 +29,5 @@
#
#------------------------------------------------------------------------------
-version=svn
-gperftools_install=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
-
-GPERFTOOLS_VERSION=gperftools-$version
-GPERFTOOLS_ARCH_PATH=$gperftools_install/$GPERFTOOLS_VERSION
-
-export PATH=$GPERFTOOLS_ARCH_PATH/bin:$PATH
-export LD_LIBRARY_PATH=$GPERFTOOLS_ARCH_PATH/lib:$LD_LIBRARY_PATH
#------------------------------------------------------------------------------
diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/metis OpenFOAM-4.x-version-4.1/etc/config.sh/metis
--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/metis
+++ OpenFOAM-4.x-version-4.1/etc/config.sh/metis
@@ -34,7 +34,7 @@
#
#------------------------------------------------------------------------------
-export METIS_VERSION=metis-5.1.0
-export METIS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/$METIS_VERSION
+export METIS_VERSION=metis-$METISVERSION
+export METIS_ARCH_PATH=$METIS_ROOT
#------------------------------------------------------------------------------
diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/scotch OpenFOAM-4.x-version-4.1/etc/config.sh/scotch
--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/scotch
+++ OpenFOAM-4.x-version-4.1/etc/config.sh/scotch
@@ -37,7 +37,7 @@
#
#------------------------------------------------------------------------------
-export SCOTCH_VERSION=scotch_6.0.3
-export SCOTCH_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/$SCOTCH_VERSION
+export SCOTCH_VERSION=scotch_$SCOTCHVERSION
+export SCOTCH_ARCH_PATH=$SCOTCH_ROOT
#------------------------------------------------------------------------------
diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/settings OpenFOAM-4.x-version-4.1/etc/config.sh/settings
--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/settings
+++ OpenFOAM-4.x-version-4.1/etc/config.sh/settings
@@ -279,6 +279,9 @@
;;
system)
# Use system compiler
+ # Use system GMP and MPFR packages
+ export GMP_ARCH_PATH=$GMP_ROOT
+ export MPFR_ARCH_PATH=$MPFR_ROOT
;;
*)
echo "Warn: WM_COMPILER_TYPE='$WM_COMPILER_TYPE' is unsupported" 1>&2
diff -ur OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/ptscotchDecomp/Make/options OpenFOAM-4.x-version-4.1/src/parallel/decompose/ptscotchDecomp/Make/options
--- OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/ptscotchDecomp/Make/options
+++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/ptscotchDecomp/Make/options
@@ -5,8 +5,7 @@
$(PFLAGS) $(PINC) \
-I$(SCOTCH_ROOT)/include \
-I$(SCOTCH_ARCH_PATH)/include/$(FOAM_MPI) \
- -I/usr/include/scotch \
-I../decompositionMethods/lnInclude
LIB_LIBS = \
- -L$(SCOTCH_ROOT)/lib -L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) -lptscotch -lptscotcherrexit -lscotch ${LINK_FLAGS} -lrt
+ -L$(SCOTCH_ROOT)/lib -L$(MPI_ARCH_PATH)/lib -lptscotch -lptscotcherrexit -lscotch ${LINK_FLAGS} -lrt
diff -ur OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/scotchDecomp/Make/options OpenFOAM-4.x-version-4.1/src/parallel/decompose/scotchDecomp/Make/options
--- OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/scotchDecomp/Make/options
+++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/scotchDecomp/Make/options
@@ -9,8 +9,7 @@
$(PFLAGS) $(PINC) \
-I$(SCOTCH_ROOT)/include \
-I$(SCOTCH_ARCH_PATH)/include \
- -I/usr/include/scotch \
-I../decompositionMethods/lnInclude
LIB_LIBS = \
- -L$(SCOTCH_ROOT)/lib -L$(FOAM_EXT_LIBBIN) -lscotch -lscotcherrexit -lrt
+ -L$(SCOTCH_ROOT)/lib -lscotch -lscotcherrexit -lrt
diff -ur OpenFOAM-4.x-version-4.1.org/wmake/makefiles/general OpenFOAM-4.x-version-4.1/wmake/makefiles/general
--- OpenFOAM-4.x-version-4.1.org/wmake/makefiles/general
+++ OpenFOAM-4.x-version-4.1/wmake/makefiles/general
@@ -33,7 +33,6 @@
# The Makefile uses a POSIX shell
#------------------------------------------------------------------------------
-SHELL = /bin/sh
#------------------------------------------------------------------------------
diff -ur OpenFOAM-4.x-version-4.1.org/wmake/wmake OpenFOAM-4.x-version-4.1/wmake/wmake
--- OpenFOAM-4.x-version-4.1.org/wmake/wmake
+++ OpenFOAM-4.x-version-4.1/wmake/wmake
@@ -163,7 +163,7 @@
then
if [ "$WM_NCOMPPROCS" -gt 1 -a ! "$MAKEFLAGS" ]
then
- lockDir=$HOME/.$WM_PROJECT/.wmake
+ lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
if [ -d $lockDir ]
then
diff -ur OpenFOAM-4.x-version-4.1.org/wmake/wmakeScheduler OpenFOAM-4.x-version-4.1/wmake/wmakeScheduler
--- OpenFOAM-4.x-version-4.1.org/wmake/wmakeScheduler
+++ OpenFOAM-4.x-version-4.1/wmake/wmakeScheduler
@@ -53,7 +53,7 @@
# csh sets HOST, bash sets HOSTNAME
: ${HOST:=$HOSTNAME}
-lockDir=$HOME/.$WM_PROJECT/.wmake
+lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
# Fallback - 1 core on current host
: ${WM_HOSTS:=$HOST:1}
diff -ur OpenFOAM-4.x-version-4.1.org/wmake/wmakeSchedulerUptime OpenFOAM-4.x-version-4.1/wmake/wmakeSchedulerUptime
--- OpenFOAM-4.x-version-4.1.org/wmake/wmakeSchedulerUptime
+++ OpenFOAM-4.x-version-4.1/wmake/wmakeSchedulerUptime
@@ -53,7 +53,7 @@
# csh sets HOST, bash sets HOSTNAME
: ${HOST:=$HOSTNAME}
-lockDir=$HOME/.$WM_PROJECT/.wmake
+lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
# Fallback - 1 core on current host
: ${WM_HOSTS:=$HOST:1}
diff -ur OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/metisDecomp/metisDecomp.C OpenFOAM-4.x-version-4.1/src/parallel/decompose/metisDecomp/metisDecomp.C
--- OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/metisDecomp/metisDecomp.C
+++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/metisDecomp/metisDecomp.C
@@ -67,7 +67,7 @@
// Processor weights initialised with no size, only used if specified in
// a file
- Field<scalar> processorWeights;
+ Field<floatScalar> processorWeights;
// Cell weights (so on the vertices of the dual)
List<label> cellWeights;
diff -ur OpenFOAM-4.x-version-4.1.org/wmake/rules/General/CGAL OpenFOAM-4.x-version-4.1/wmake/rules/General/CGAL
--- OpenFOAM-4.x-version-4.1.org/wmake/rules/General/CGAL
+++ OpenFOAM-4.x-version-4.1/wmake/rules/General/CGAL
@@ -6,9 +6,10 @@
-I/usr/include
CGAL_LIBS = \
- -L$(MPFR_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
- -L$(GMP_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
+ -L$(MPFR_ARCH_PATH)/lib \
+ -L$(GMP_ARCH_PATH)/lib \
-L$(BOOST_ARCH_PATH)/lib \
-L$(CGAL_ARCH_PATH)/lib \
-lCGAL \
+ -lgmp \
-lmpfr
diff -ur OpenFOAM-4.x-version-4.1.org/wmake/rules/linux64Gcc/c++ OpenFOAM-4.x-version-4.1/wmake/rules/linux64Gcc/c++
--- OpenFOAM-4.x-version-4.1.org/wmake/rules/linux64Gcc/c++
+++ OpenFOAM-4.x-version-4.1/wmake/rules/linux64Gcc/c++
@@ -20,5 +20,5 @@
LINK_LIBS = $(c++DBUG)
-LINKLIBSO = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed
-LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed
+LINKLIBSO = $(CC) $(c++FLAGS) $(LDFLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed
+LINKEXE = $(CC) $(c++FLAGS) $(LDFLAGS) -Xlinker --add-needed -Xlinker --no-as-needed

View file

@ -3,6 +3,7 @@
;;; Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com> ;;; Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2022 Eric Bavier <bavier@posteo.net> ;;; Copyright © 2022 Eric Bavier <bavier@posteo.net>
;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler@gmail.com> ;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler@gmail.com>
;;; Copyright © 2023 Reza Housseini <reza@housseini.me>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -31,6 +32,8 @@ (define-module (gnu packages simulation)
#:use-module (gnu packages cmake) #:use-module (gnu packages cmake)
#:use-module (gnu packages compression) #:use-module (gnu packages compression)
#:use-module (gnu packages cpp) #:use-module (gnu packages cpp)
#:use-module (gnu packages curl)
#:use-module (gnu packages engineering)
#:use-module (gnu packages flex) #:use-module (gnu packages flex)
#:use-module (gnu packages fontutils) #:use-module (gnu packages fontutils)
#:use-module (gnu packages gettext) #:use-module (gnu packages gettext)
@ -41,22 +44,31 @@ (define-module (gnu packages simulation)
#:use-module (gnu packages gtk) #:use-module (gnu packages gtk)
#:use-module (gnu packages image) #:use-module (gnu packages image)
#:use-module (gnu packages iso-codes) #:use-module (gnu packages iso-codes)
#:use-module (gnu packages image-processing)
#:use-module (gnu packages linux) #:use-module (gnu packages linux)
#:use-module (gnu packages m4) #:use-module (gnu packages m4)
#:use-module (gnu packages maths) #:use-module (gnu packages maths)
#:use-module (gnu packages mpi) #:use-module (gnu packages mpi)
#:use-module (gnu packages multiprecision) #:use-module (gnu packages multiprecision)
#:use-module (gnu packages ncurses) #:use-module (gnu packages ncurses)
#:use-module (gnu packages pdf)
#:use-module (gnu packages pkg-config) #:use-module (gnu packages pkg-config)
#:use-module (gnu packages pretty-print)
#:use-module (gnu packages protobuf) #:use-module (gnu packages protobuf)
#:use-module (gnu packages python) #:use-module (gnu packages python)
#:use-module (gnu packages python-build) #:use-module (gnu packages python-build)
#:use-module (gnu packages python-science) #:use-module (gnu packages python-science)
#:use-module (gnu packages python-xyz) #:use-module (gnu packages python-xyz)
#:use-module (gnu packages qt)
#:use-module (gnu packages readline) #:use-module (gnu packages readline)
#:use-module (gnu packages serialization)
#:use-module (gnu packages sqlite)
#:use-module (gnu packages ssh)
#:use-module (gnu packages textutils)
#:use-module (gnu packages tls) #:use-module (gnu packages tls)
#:use-module (gnu packages version-control) #:use-module (gnu packages version-control)
#:use-module (gnu packages video) #:use-module (gnu packages video)
#:use-module (gnu packages xiph)
#:use-module (gnu packages xml) #:use-module (gnu packages xml)
#:use-module (gnu packages xorg) #:use-module (gnu packages xorg)
#:use-module (guix download) #:use-module (guix download)
@ -75,175 +87,303 @@ (define-module (gnu packages simulation)
#:use-module (ice-9 regex) #:use-module (ice-9 regex)
#:use-module (srfi srfi-1)) #:use-module (srfi srfi-1))
(define-public openfoam (define-public openfoam-org
(package (package
(name "openfoam") (name "openfoam-org")
(version "4.1") (version "10.20230119")
(source (source (origin
(origin (method url-fetch)
(method url-fetch) (uri (string-append "https://github.com/OpenFOAM/OpenFOAM-"
(uri (string-append (version-major version) "/archive/"
"http://dl.openfoam.org/source/" (second (string-split version #\.))
(string-map (lambda (x) (if (eq? x #\.) #\- x)) version))) ".tar.gz"))
(file-name (string-append name "-" version ".tar.gz")) (sha256
(sha256 (base32
(base32 "0cgxh4h2hf50qbvvdg5miwc2nympb0nrv3md96vb3gbs9vk8vq9d")) "1aw2vb5s7frg942ngd5x5x2dm67liyg6czff56qi567mshccpy46"))
(patches (search-patches "openfoam-4.1-cleanup.patch")) (modules '((guix build utils)))
(modules '((guix build utils))) (snippet `(begin
(snippet ;; patch shell paths
'(begin (substitute* (list "wmake/src/Makefile"
;; Include <sys/sysmacros.h>, which is where glibc >= 2.28 provides "wmake/makefiles/general")
;; 'major' and 'minor'. (("/bin/sh")
(substitute* "src/OSspecific/POSIX/fileStat.C" "sh"))
(("#include <unistd\\.h>") (substitute* "etc/bashrc"
"#include <unistd.h>\n#include <sys/sysmacros.h>\n")) ;; only go back one folder level
#t)))) (("\\$\\(dirname \\$\\{BASH_SOURCE:-\\$0\\}\\)/../..")
"$(dirname ${BASH_SOURCE:-$0})/..")
;; do not use openfoam folder convention
(("^export WM_PROJECT_DIR=.*$")
(string-append
"export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR\n"))
;; do not source bash_completion (gives error)
(("^.*bash_completion.*$" all)
(string-append "#" all))
;; set same version as guix package
(("^export WM_PROJECT_VERSION=.*$")
(string-append "export WM_PROJECT_VERSION="
,version "\n")))
;; add expand flag to RunFunctions
(substitute* "bin/tools/RunFunctions"
(("foamDictionary (.*)" all args)
(string-append "foamDictionary -expand " args)))
;; disable failing test
(substitute* "test/postProcessing/channel/Allrun"
(("^.*getApplication.*$" all)
(string-append "#" all "\n")))))))
(build-system gnu-build-system) (build-system gnu-build-system)
(inputs (inputs (list boost
`(("boost" ,boost) cgal
("cgal" ,cgal) git
("flex" ,flex) gmp
("git" ,git) libxt
("gmp" ,gmp) metis
("libxt" ,libxt) mpfr
("metis" ,metis) ncurses
("mpfr" ,mpfr) openmpi
("ncurses" ,ncurses) openssh
("readline" ,readline) paraview
("scotch" ,pt-scotch32) pt-scotch32
("zlib" ,zlib))) readline
(native-inputs zlib))
(list bison)) (native-inputs (list bison
(propagated-inputs flex
(list gzip gnuplot openmpi)) ;; paraview plugin dependencies
(outputs '("debug" ;~60MB cli11
cmake-minimal
cgns
curl
double-conversion
eigen
expat
ffmpeg
fmt
freetype
gdal
gl2ps
glew
gmsh
hdf5
jsoncpp
libjpeg-turbo
libogg
libpng
libharu
libtheora
libtiff
libx11
libxml2
lz4
netcdf
nlohmann-json
proj
protobuf
pugixml
python
python-mpi4py
qtbase-5
qtsvg-5
qttools-5
qtwebengine-5
qtxmlpatterns
utfcpp
vtk
xz))
(propagated-inputs (list gnuplot))
(outputs '("debug" ;~60MB
"out")) "out"))
(arguments (arguments
`( ;; Executable files and shared libraries are located in the 'platforms' (list
;; subdirectory. ;; Executable files and shared libraries are located in the 'platforms'
#:strip-directories (list (string-append ;; subdirectory.
"lib/OpenFOAM-" ,version #:strip-directories
"/platforms/linux64GccDPInt32Opt/bin") #~(list "share/OpenFOAM/platforms/linux64GccDPInt32Opt/bin"
(string-append "share/OpenFOAM/platforms/linux64GccDPInt32Opt/lib")
"lib/OpenFOAM-" ,version
"/platforms/linux64GccDPInt32Opt/lib"))
#:tests? #f ; no tests to run
#:modules ((ice-9 ftw) #:modules
(ice-9 regex) '((ice-9 ftw)
(guix build gnu-build-system) (ice-9 regex)
(guix build utils)) (ice-9 string-fun)
(srfi srfi-1)
(guix build gnu-build-system)
(guix build utils))
#:phases (modify-phases %standard-phases #:phases
(add-after 'unpack 'rename-build-directory #~(modify-phases %standard-phases
(lambda _ (add-before 'build 'patch-HOME-path
(chdir "..") (lambda _
;; Use 'OpenFOAM-version' convention to match the file (setenv "HOME" "/tmp") #t))
;; name expectations in the build phase. (add-before 'build 'patch-scotch
(let ((unpack-dir (string-append (lambda _
(getcwd) "/" (substitute* "etc/config.sh/scotch"
(list-ref (scandir (getcwd) (lambda (name) (("^export SCOTCH_VERSION=scotch_.*$")
(string-match "^OpenFOAM" name))) 0))) (string-append "export SCOTCH_VERSION=scotch_"
(build-dir (string-append #$(package-version pt-scotch32) "\n"))
(getcwd) "/OpenFOAM-" ,version))) (("^export SCOTCH_ARCH_PATH=.*$")
(rename-file unpack-dir build-dir) ; rename build directory (string-append "export SCOTCH_ARCH_PATH="
(chdir (basename build-dir))) ; move to build directory (assoc-ref %build-inputs "pt-scotch32")
#t)) "\n"))) #t))
(delete 'configure) ; no configure phase (add-before 'build 'patch-mpi
(replace 'build (lambda _
(lambda _ (let* ((mpi-path (assoc-ref %build-inputs "openmpi"))
(let ((libraries '("boost" "cgal" "gmp" "metis" "mpfr" "scotch"))) (mpi-version #$(package-version openmpi)))
;; set variables to define store paths ;; specify openmpi type
(for-each (lambda (library) (substitute* "etc/bashrc"
(setenv (string-append (("WM_MPLIB=SYSTEMOPENMPI")
(string-upcase library) "_ROOT") "WM_MPLIB=OPENMPI"))
(assoc-ref %build-inputs library))) libraries)) (substitute* "etc/config.sh/mpi"
;; set variables to define package versions (("export FOAM_MPI=openmpi-.*$")
(setenv "SCOTCHVERSION" ,(package-version scotch)) (string-append "export FOAM_MPI=openmpi-"
(setenv "METISVERSION" ,(package-version metis)) mpi-version "\n"))
;; set variable to pass extra 'rpath' arguments to linker (("export MPI_ARCH_PATH=.*\\$FOAM_MPI.*$")
(setenv "LDFLAGS" (string-append "export MPI_ARCH_PATH=" mpi-path
(string-append "\n")))) #t))
"-Wl," (add-before 'build 'patch-paraview
"-rpath=" %output "/lib/OpenFOAM-" ,version (lambda _
"/platforms/linux64GccDPInt32Opt/lib," (substitute* "etc/config.sh/paraview"
"-rpath=" %output "/lib/OpenFOAM-" ,version (("^export ParaView_VERSION=.*$")
"/platforms/linux64GccDPInt32Opt/lib/dummy")) (string-append "export ParaView_VERSION="
;; compile OpenFOAM libraries and applications #$(package-version paraview) "\n"))
(zero? (system (format #f (("^export ParaView_DIR=.*$")
"source ./etc/bashrc && ./Allwmake -j~a" (string-append "export ParaView_DIR="
(parallel-job-count)))))) (assoc-ref %build-inputs "paraview")
(add-after 'build 'update-configuration-files "\n"))) #t))
(lambda _ (add-before 'build 'add-rpaths
;; record store paths and package versions in (lambda _
;; configuration files (letrec* ((libraries '("boost" "cgal"
(substitute* "etc/config.sh/CGAL" "gmp"
(("$BOOST_ROOT") (getenv "BOOST_ROOT"))) "metis"
(substitute* "etc/config.sh/CGAL" "mpfr"
(("$CGAL_ROOT") (getenv "CGAL_ROOT"))) "pt-scotch32"
(substitute* "etc/config.sh/metis" "openmpi"
(("$METIS_ROOT") (getenv "METIS_ROOT"))) "zlib"
(substitute* "etc/config.sh/metis" "paraview"))
(("$METISVERSION") (getenv "METISVERSION"))) (rpaths
(substitute* "etc/config.sh/scotch" (fold-right (lambda (library rpaths)
(("$SCOTCH_ROOT") (getenv "SCOTCH_ROOT"))) (string-append rpaths
(substitute* "etc/config.sh/scotch" "-rpath="
(("$SCOTCHVERSION") (getenv "SCOTCHVERSION"))) (assoc-ref
(substitute* "etc/config.sh/settings" %build-inputs library)
(("$GMP_ROOT") (getenv "GMP_ROOT"))) "/lib,")) "" libraries))
(substitute* "etc/config.sh/settings" (openfoam-lib
(("$MPFR_ROOT") (getenv "MPFR_ROOT"))) (string-append #$output
;; reset lockDir variable to refer to write-enabled "/share/OpenFOAM/platforms/linux64GccDPInt32Opt/lib"))
;; directory (ldflags
(substitute* "wmake/wmake" (string-append "-Wl,"
((" lockDir=.*$") rpaths
" lockDir=$HOME/.$WM_PROJECT/.wmake\n")) "-rpath="
(substitute* "wmake/wmakeScheduler" openfoam-lib
(("lockDir=.*$") ","
"lockDir=$HOME/.$WM_PROJECT/.wmake\n")) "-rpath="
(substitute* "wmake/wmakeSchedulerUptime" openfoam-lib
(("lockDir=.*$") "/dummy,"
"lockDir=$HOME/.$WM_PROJECT/.wmake\n")) "-rpath="
#t)) openfoam-lib
(add-after 'build 'cleanup "/paraview-"
;; Avoid unncessary, voluminous object and dep files. #$(version-major+minor (package-version
(lambda _ paraview)))))
(delete-file-recursively (substitute* "wmake/rules/linux64Gcc/c++"
"platforms/linux64GccDPInt32Opt/src") (("\\$\\(LIB_HEADER_DIRS\\) -fPIC" all)
(delete-file-recursively (string-append all " " ldflags)))) #t))
"platforms/linux64GccDPInt32OptSYSTEMOPENMPI") (add-before 'build 'add-vtk-include-path
(for-each delete-file (find-files "." "\\.o$")) (lambda _
#t)) (let* ((vtk-version #$(version-major+minor
(replace 'install (package-version vtk)))
(lambda _ (vtk-root (assoc-ref %build-inputs "vtk"))
;; use 'OpenFOAM-version' convention (vtk-inc (string-append vtk-root "/include/vtk-" vtk-version))
(let ((install-dir (string-append (vtk-inc-flag (string-append "-I" vtk-inc)))
%output "/lib/OpenFOAM-" ,version))) (substitute* "wmake/rules/linux64Gcc/c++"
(mkdir-p install-dir) ; create install directory (("\\$\\(LIB_HEADER_DIRS\\)" all)
;; move contents of build directory to install directory (string-append all " " vtk-inc-flag " "))))
(copy-recursively "." install-dir)))) #t))
(add-after 'install 'add-symbolic-link (delete 'configure) ;no configure phase
(lambda _ (replace 'build
;; add symbolic link for standard 'bin' directory (lambda _
(symlink ;; compile OpenFOAM libraries and applications
(string-append "./lib/OpenFOAM-" ,version (invoke "bash" "-c"
"/platforms/linux64GccDPInt32Opt/bin") (format #f
(string-append %output "/bin")) "source ./etc/bashrc && ./Allwmake -j~a"
#t))))) (parallel-job-count)))))
(add-after 'build 'cleanup
;; Avoid unnecessary, voluminous object and dep files.
(lambda _
(when (file-exists? "platforms/linux64GccDPInt32Opt/src")
(delete-file-recursively
"platforms/linux64GccDPInt32Opt/src"))
(when (file-exists?
"platforms/linux64GccDPInt32OptOPENMPI")
(delete-file-recursively
"platforms/linux64GccDPInt32OptOPENMPI"))
(for-each delete-file
(find-files "." "\\.o$")) #t))
(replace 'check
(lambda* (#:key tests? #:allow-other-keys)
(when tests?
(when (file-exists? "test")
(with-directory-excursion "test"
(invoke "bash" "-c"
(format #f
"source ../etc/bashrc && ./Allrun -j~a"
(parallel-job-count)))))
;; too many tutorials are failing
;; (with-directory-excursion "tutorials"
;; (invoke "bash" "-c" "source ../etc/bashrc && ./Alltest"))
) #t))
(replace 'install
(lambda _
(let ((install-dir (string-append #$output
"/share/OpenFOAM")))
(mkdir-p install-dir) ;create install directory
;; move contents of build directory to install directory
(copy-recursively "." install-dir))))
(add-after 'install 'add-symbolic-link
(lambda _
(let* ((bin (string-append #$output "/bin"))
(lib (string-append #$output "/lib"))
(openfoam (string-append #$output
"/share/OpenFOAM"))
(build-bin (string-append openfoam
"/platforms/linux64GccDPInt32Opt/bin"))
(build-lib (string-append openfoam
"/platforms/linux64GccDPInt32Opt/lib"))
(foam-bin (string-append openfoam "/bin")))
;; add symbolic links in standard 'bin' directory
(mkdir-p bin)
(for-each (lambda (file)
(unless (member file
'("." ".."))
(symlink (string-append build-bin "/"
file)
(string-append bin "/" file))))
(scandir build-bin))
(for-each (lambda (file)
(unless (member file
'("." ".."))
(symlink (string-append foam-bin "/"
file)
(string-append bin "/" file))))
(scandir foam-bin))
;; add symbolic link for standard 'lib' directory
(symlink build-lib lib)) #t)))))
(native-search-paths
(list (search-path-specification
(variable "WM_PROJECT_DIR")
(separator #f)
(files '("share/OpenFOAM")))))
;; Note: ;; Note:
;; Tutorial files are installed read-only in /gnu/store. ;; Tutorial files are installed read-only in /gnu/store.
;; To allow write permissions on files copied from the store a ;; To allow write permissions on files copied from the store a
;; 'chmod' step is needed before running the applications. For ;; 'chmod' step is needed before running the applications. For
;; example, from a user's login: ;; example, from a user's login:
;; $ source $GUIX_PROFILE/lib/OpenFOAM-4.1/etc/bashrc ;; $ source $(dirname $(which blockMesh))/../../../etc/bashrc
;; $ mkdir -p $FOAM_RUN ;; $ mkdir -p $FOAM_RUN
;; $ cd $FOAM_RUN ;; $ cd $FOAM_RUN
;; $ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily . ;; $ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
;; $ cd pitzDaily ;; $ cd pitzDaily
;; $ chmod -R u+w . ;; $ chmod -R u+w .
;; $ blockMesh ;; $ blockMesh
(synopsis "Framework for numerical simulation of fluid flow") (synopsis "Framework for numerical simulation of fluid flow")
(description "OpenFOAM provides a set of solvers and methods for tackling (description
"OpenFOAM provides a set of solvers and methods for tackling
problems in the field of Computational Fluid Dynamics (CFD). It is written in problems in the field of Computational Fluid Dynamics (CFD). It is written in
C++. Governing equations such as the Navier-Stokes equations can be solved in C++. Governing equations such as the Navier-Stokes equations can be solved in
integral form. Physical processes such as phase change, droplet transport and integral form. Physical processes such as phase change, droplet transport and
@ -254,6 +394,9 @@ (define-public openfoam
(license license:gpl3+) (license license:gpl3+)
(home-page "https://openfoam.org"))) (home-page "https://openfoam.org")))
(define-public openfoam
(deprecated-package "openfoam" openfoam-org))
(define-public open-simulation-interface (define-public open-simulation-interface
(package (package
(name "open-simulation-interface") (name "open-simulation-interface")