guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#28045] [PATCH] gnu: Add openfoam


From: Paul Garlick
Subject: [bug#28045] [PATCH] gnu: Add openfoam
Date: Wed, 6 Sep 2017 22:28:01 +0100

*gnu/packages/patches/openfoam-4.1-cleanup.patch: New file
*gnu/packages/simulation.scm: New file
*gnu/local.mk (GNU_SYSTEM_MODULES): Add module
(dist_patch_DATA): Add patch
---
 gnu/local.mk                                    |   2 +
 gnu/packages/patches/openfoam-4.1-cleanup.patch | 239 ++++++++++++++++++++++++
 gnu/packages/simulation.scm                     | 198 ++++++++++++++++++++
 3 files changed, 439 insertions(+)
 create mode 100644 gnu/packages/patches/openfoam-4.1-cleanup.patch
 create mode 100644 gnu/packages/simulation.scm

Hello Guix,

Please find the updated patch for OpenFOAM below.

Thank you for the reviews.  I have implemented the suggestions made by Ludo,
Eric and Marius, barring a couple of exceptions noted below.

I have also changed the filename for the patch, in order to include the version.
This will allow new versions to have their own patches.

Lastly, I have added a section in the patch to rename the 'lockDir' variable
temporarily for the build phase. It is reset in the 'update-configuration-files'
phase.

In answer to the specific comments:

>> +-    Field<scalar> processorWeights;
>> ++    Field<floatScalar> processorWeights;
>
>This seems unrelated to unbundling :) Is this a known issue?

Yes, this is OpenFOAM bug#0002085.   I believe a fix has been implemented so
that this part of the patch will not be needed in future versions.

>> +       #:validate-runpath? #f
>
>I don't suppose it's easy to move everything up to the top store level,
>which is already in a versioned directory and would allow these phases
>to proceed normally?

I think it would be difficult to make a change here, without risking disruption
to internal paths and external (user) scripts.

>> +     ;; define the FOAM_INST_DIR variable
>> +     (list (search-path-specification
>> +            (variable "FOAM_INST_DIR")
>> +            (files '(".")))))
>
>...maybe by utilizing this variable?  It would also be better to wrap
>the binaries with it, instead of depending on it being in a profile.

This variable is often used in user aliases and scripts.  It is used as the
starting point for navigating the OpenFOAM directory structure.  Other
installation methods make the variable immediately available.  If it were
missing in the Guix package it would be necessary to add an explanation
of how it should be set.

>> * gnu/packages/simulation.scm: New file
>
>Would this package not fit nicely in gnu/packages/engineering.scm?

In fact, there was some discussion on this question when I submitted the
original patch:

http://lists.gnu.org/archive/html/guix-devel/2017-07/msg00354.html

I think the 'simulation' module is the best idea since there are also many
non-engineering applications such as biomedical and geophysical modelling.

Best regards,

Paul.


diff --git a/gnu/local.mk b/gnu/local.mk
index 643a88db8..048f7aa1c 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -363,6 +363,7 @@ GNU_SYSTEM_MODULES =                                \
   %D%/packages/shells.scm                      \
   %D%/packages/shellutils.scm                  \
   %D%/packages/simh.scm                                \
+  %D%/packages/simulation.scm                  \
   %D%/packages/skarnet.scm                     \
   %D%/packages/skribilo.scm                    \
   %D%/packages/slang.scm                       \
@@ -886,6 +887,7 @@ dist_patch_DATA =                                           
\
   %D%/packages/patches/ola-readdir-r.patch                     \
   %D%/packages/patches/openscenegraph-ffmpeg3.patch             \
   %D%/packages/patches/openexr-missing-samples.patch           \
+  %D%/packages/patches/openfoam-4.1-cleanup.patch                      \
   %D%/packages/patches/openjpeg-CVE-2017-12982.patch           \
   %D%/packages/patches/openjpeg-CVE-2017-14040.patch           \
   %D%/packages/patches/openjpeg-CVE-2017-14041.patch           \
diff --git a/gnu/packages/patches/openfoam-4.1-cleanup.patch 
b/gnu/packages/patches/openfoam-4.1-cleanup.patch
new file mode 100644
index 000000000..590db5982
--- /dev/null
+++ b/gnu/packages/patches/openfoam-4.1-cleanup.patch
@@ -0,0 +1,239 @@
+# This patch removes all need for the ThirdParty files of OpenFOAM
+
+# Derived from easybuild patch:  Ward Poelmans <address@hidden>
+# Modified for GNU Guix:  Paul Garlick <address@hidden>
+
+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      2016-10-16 
16:11:45.000000000 +0200
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/gperftools  2017-04-10 
14:51:01.473221230 +0200
+@@ -29,13 +29,13 @@
+ #
+ 
#------------------------------------------------------------------------------
+
+-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
++# 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,7 @@
+ # The Makefile uses a POSIX shell
+ 
#------------------------------------------------------------------------------
+ 
+-SHELL           = /bin/sh
++# 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,8 +6,8 @@
+     -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 \
diff --git a/gnu/packages/simulation.scm b/gnu/packages/simulation.scm
new file mode 100644
index 000000000..3446d72c6
--- /dev/null
+++ b/gnu/packages/simulation.scm
@@ -0,0 +1,198 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Paul Garlick <address@hidden>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages simulation)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
+  #:use-module (gnu packages bison)
+  #:use-module (gnu packages boost)
+  #:use-module (gnu packages compression)
+  #:use-module (gnu packages flex)
+  #:use-module (gnu packages gettext)
+  #:use-module (gnu packages gcc)
+  #:use-module (gnu packages gl)
+  #:use-module (gnu packages graphics)
+  #:use-module (gnu packages gtk)
+  #:use-module (gnu packages linux)
+  #:use-module (gnu packages m4)
+  #:use-module (gnu packages maths)
+  #:use-module (gnu packages mpi)
+  #:use-module (gnu packages multiprecision)
+  #:use-module (gnu packages ncurses)
+  #:use-module (gnu packages readline)
+  #:use-module (gnu packages tls)
+  #:use-module (gnu packages version-control)
+  #:use-module (gnu packages xml)
+  #:use-module (gnu packages xorg)
+  #:use-module (guix download)
+  #:use-module (guix build utils)
+  #:use-module (guix build-system gnu)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix packages)
+  #:use-module (guix utils)
+  #:use-module (ice-9 ftw)
+  #:use-module (ice-9 regex)
+  #:use-module (srfi srfi-1))
+
+(define-public openfoam
+  (package
+    (name "openfoam")
+    (version "4.1")
+    (source
+     (origin
+      (method url-fetch)
+      (uri (string-append
+             "http://dl.openfoam.org/source/";
+             (string-map (lambda (x) (if (eq? x #\.) #\- x)) version)))
+      (file-name (string-append name "-" version ".tar.gz"))
+      (sha256
+       (base32 "1hgh2kw7fqv4bfachhbjhw16v8j35jbv6s576fmz4ka2q4ks4wg3"))
+      (patches (search-patches "openfoam-4.1-cleanup.patch"))))
+    (build-system gnu-build-system)
+    (inputs
+     `(("boost" ,boost)
+       ("cgal" ,cgal)
+       ("flex" ,flex)
+       ("git" ,git)
+       ("gmp" ,gmp)
+       ("libxt" ,libxt)
+       ("metis" ,metis)
+       ("mpfr" ,mpfr)
+       ("ncurses" ,ncurses)
+       ("readline" ,readline)
+       ("scotch" ,pt-scotch32)
+       ("zlib" ,zlib)))
+    (native-inputs
+     `(("bison" ,bison)))
+    (propagated-inputs
+     `(("gzip" ,gzip)
+       ("gnuplot" ,gnuplot)
+       ("openmpi" ,openmpi)))
+    (arguments
+     `(#:strip-directories (list (string-append
+                                  "OpenFOAM-" ,version
+                                  "/platforms/linux64GccDPInt32Opt/bin")
+                                 (string-append
+                                  "OpenFOAM-" ,version
+                                  "/platforms/linux64GccDPInt32Opt/lib"))
+                              ; executable files and shared libraries are
+                              ; located in the 'platforms' subdirectory
+       #:validate-runpath? #f ; '#:elf-directories' is not recognised here
+       #:tests? #f            ; no tests to run
+       #:phases (modify-phases %standard-phases
+        (add-after 'unpack 'rename-build-directory
+          (lambda _
+            (use-modules (ice-9 ftw))
+            (use-modules (ice-9 regex))
+            (chdir "..")
+            ;; use 'OpenFOAM-version' convention to match pathname expectations
+            ;; in the build phase
+            (let ((unpack-dir (string-append
+                               (getcwd) "/"
+                               (list-ref (scandir (getcwd) (lambda (name)
+                                 (string-match "^OpenFOAM" name))) 0)))
+                  (build-dir (string-append
+                              (getcwd) "/OpenFOAM-" ,version)))
+             (rename-file unpack-dir build-dir) ; re-name build directory
+             (chdir (basename build-dir)))      ; move to build directory
+            #t))
+        (add-after 'patch-source-shebangs 'set-environment-variables
+          (lambda _
+            (let ((libraries '("boost" "cgal" "gmp" "metis" "mpfr" "scotch")))
+             ;; set variables to define store paths
+             (for-each (lambda (library)
+                        (setenv (string-append
+                                 (string-upcase library) "_ROOT")
+                                (assoc-ref %build-inputs library))) libraries))
+            ;; set variables to define package versions
+            (setenv "SCOTCHVERSION" ,(package-version scotch))
+            (setenv "METISVERSION" ,(package-version metis))
+            #t))
+        (delete 'configure) ; no configure phase
+        (replace 'build
+          (lambda _
+            ;; compile OpenFOAM libraries and applications
+            (zero? (system (format #f
+                             "source ./etc/bashrc && ./Allwmake -j~a"
+                                (parallel-job-count))))))
+        (add-after 'build 'update-configuration-files
+          (lambda _
+            ;; record store paths and package versions in configuration files
+            (substitute* "etc/config.sh/CGAL"
+                       (("$BOOST_ROOT") (getenv "BOOST_ROOT")))
+            (substitute* "etc/config.sh/CGAL"
+                       (("$CGAL_ROOT") (getenv "CGAL_ROOT")))
+            (substitute* "etc/config.sh/metis"
+                       (("$METIS_ROOT") (getenv "METIS_ROOT")))
+            (substitute* "etc/config.sh/metis"
+                       (("$METISVERSION") (getenv "METISVERSION")))
+            (substitute* "etc/config.sh/scotch"
+                       (("$SCOTCH_ROOT") (getenv "SCOTCH_ROOT")))
+            (substitute* "etc/config.sh/scotch"
+                       (("$SCOTCHVERSION") (getenv "SCOTCHVERSION")))
+            (substitute* "etc/config.sh/settings"
+                       (("$GMP_ROOT") (getenv "GMP_ROOT")))
+            (substitute* "etc/config.sh/settings"
+                       (("$MPFR_ROOT") (getenv "MPFR_ROOT")))
+            ;; reset lockDir variable to refer to write-enabled directory
+            (substitute* "wmake/wmake"
+                       (("        lockDir=.*$")
+                         "        lockDir=$HOME/.$WM_PROJECT/.wmake\n"))
+            (substitute* "wmake/wmakeScheduler"
+                       (("lockDir=.*$")
+                         "lockDir=$HOME/.$WM_PROJECT/.wmake\n"))
+            (substitute* "wmake/wmakeSchedulerUptime"
+                       (("lockDir=.*$")
+                         "lockDir=$HOME/.$WM_PROJECT/.wmake\n"))
+            #t))
+        (replace 'install
+          (lambda _
+            ;; use 'OpenFOAM-version' convention
+            (let ((install-dir (string-append
+                                %output "/OpenFOAM-" ,version)))
+              (mkdir-p install-dir) ; create install directory
+              ;; move contents of build directory to install directory
+              (copy-recursively "." install-dir)))))))
+        ;; Note: tutorial files are installed read-only in /gnu/store.
+        ;; To allow write permissions on files copied from the store a
+        ;; 'chmod' step is needed before running the applications.  For
+        ;; example, from a user's login:
+        ;; $ source $GUIX_PROFILE/OpenFOAM-4.1/etc/bashrc
+        ;; $ mkdir -p $FOAM_RUN
+        ;; $ cd $FOAM_RUN
+        ;; $ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzdaily .
+        ;; $ cd pitzdaily
+        ;; $ chmod -R u+w .
+        ;; $ blockMesh
+    (native-search-paths
+     ;; define the FOAM_INST_DIR variable
+     (list (search-path-specification
+            (variable "FOAM_INST_DIR")
+            (files '(".")))))
+    (synopsis "Framework for numerical simulation of fluid flow")
+    (description "OpenFOAM provides a set of solvers and methods for tackling
+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
+integral form.  Physical processes such as phase change, droplet transport and
+chemical reaction can be modelled.  Numerical methods are included to deal with
+sharp gradients, such as those encountered in flows with shock waves and flows
+with gas/liquid interfaces.  Large problems may be split into smaller, 
connected
+problems for efficient solution on parallel systems")
+    (license license:gpl3+)
+    (home-page "https://openfoam.org";)))
-- 
2.13.0






reply via email to

[Prev in Thread] Current Thread [Next in Thread]