unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] gnu: Add openfoam
@ 2017-07-23 20:11 Paul Garlick
  2017-07-25  9:02 ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Garlick @ 2017-07-23 20:11 UTC (permalink / raw)
  To: guix-devel; +Cc: Paul Garlick

* gnu/packages/maths.scm(openfoam): Add it
* gnu/packages/patches/openfoam-cleanup.patch: New file
* gnu/local.mk(dist_patch_DATA): Add patch
---
 gnu/local.mk                                |   1 +
 gnu/packages/maths.scm                      | 195 ++++++++++++++++++++
 gnu/packages/patches/openfoam-cleanup.patch | 267 ++++++++++++++++++++++++++++
 3 files changed, 463 insertions(+)
 create mode 100644 gnu/packages/patches/openfoam-cleanup.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 4b2bdfe37..a7c456c1d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -866,6 +866,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-cleanup.patch			\
   %D%/packages/patches/openjpeg-CVE-2016-9850-CVE-2016-9851.patch		\
   %D%/packages/patches/openjpeg-CVE-2016-9572-CVE-2016-9573.patch		\
   %D%/packages/patches/openldap-CVE-2017-9287.patch		\
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 88a46f8e9..9eaa606a3 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -47,7 +47,9 @@
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system ocaml)
   #:use-module (guix build-system r)
+  #:use-module (guix build-system trivial)
   #:use-module (gnu packages algebra)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages check)
@@ -64,10 +66,12 @@
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages gd)
   #:use-module (gnu packages ghostscript)
+  #:use-module (gnu packages graphics)
   #:use-module (gnu packages graphviz)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages image)
   #:use-module (gnu packages less)
+  #:use-module (gnu packages linux)
   #:use-module (gnu packages lisp)
   #:use-module (gnu packages logging)
   #:use-module (gnu packages lua)
@@ -79,6 +83,7 @@
   #:use-module (gnu packages m4)
   #:use-module (gnu packages mpi)
   #:use-module (gnu packages multiprecision)
+  #:use-module (gnu packages ncurses)
   #:use-module (gnu packages netpbm)
   #:use-module (gnu packages ocaml)
   #:use-module (gnu packages pcre)
@@ -94,9 +99,11 @@
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages tex)
   #:use-module (gnu packages tls)
+  #:use-module (gnu packages version-control)
   #:use-module (gnu packages wxwidgets)
   #:use-module (gnu packages xml)
   #:use-module (gnu packages zip)
+  #:use-module (ice-9 ftw)
   #:use-module (srfi srfi-1))
 
 (define-public aris
@@ -1174,6 +1181,194 @@ modules is done either interactively using the graphical user interface or in
 ASCII text files using Gmsh's own scripting language.")
     (license license:gpl2+)))
 
+(define-public openfoam
+  (package
+    (name "openfoam")
+    (version "4.1")
+    (source
+     (origin
+      (method url-fetch)
+      (uri (string-append
+             "http://dl.openfoam.org/source/"
+             (string-replace-substring version "." "-")))
+      (file-name (string-append name "-" version ".tar.gz"))
+      (sha256
+       (base32 "1hgh2kw7fqv4bfachhbjhw16v8j35jbv6s576fmz4ka2q4ks4wg3"))
+      (patches (search-patches "openfoam-cleanup.patch"))
+      (modules '((guix build utils)))))
+    (build-system trivial-build-system)
+    (inputs
+     `(("coreutils" ,(@ (gnu packages base) coreutils))
+       ("diffutils" ,(@ (gnu packages base) diffutils))
+       ("findutils" ,(@ (gnu packages base) findutils))
+       ("git" ,git)
+       ("grep" ,(@ (gnu packages base) grep))
+       ("ld-wrapper" ,((@ (gnu packages base) make-ld-wrapper)
+                                "ld-wrapper"
+                                #:binutils (@ (gnu packages base) binutils)))
+       ("linux-libre-headers" ,linux-libre-headers)
+       ("locales" ,(@ (gnu packages base) glibc-utf8-locales))
+       ("patch" ,(@ (gnu packages base) patch))
+       ("sed" ,(@ (gnu packages base) sed))
+       ("tar" ,(@ (gnu packages base) tar))
+       ("xz" ,xz)))
+    (native-inputs
+     `(("bash" ,bash)
+       ("bison" ,bison)))
+    (propagated-inputs
+     `(("binutils" ,(@ (gnu packages base) binutils))
+       ("boost" ,boost)
+       ("cgal" ,cgal)
+       ("flex" ,flex)
+       ("gcc" ,gcc)
+       ("glibc" ,(@ (gnu packages base) glibc))
+       ("gmp" ,gmp)
+       ("gzip" ,gzip)
+       ("gnuplot" ,gnuplot)
+       ("libxt" ,libxt)
+       ("make" ,(@ (gnu packages base) gnu-make))
+       ("metis" ,metis)
+       ("mpfr" ,mpfr)
+       ("ncurses" ,ncurses)
+       ("openmpi" ,openmpi)
+       ("readline" ,readline)
+       ("pt-scotch" ,pt-scotch)
+       ("scotch" ,scotch)
+       ("zlib" ,zlib)))
+    (arguments
+     `(#:modules ((guix build utils)
+                  (ice-9 ftw)
+                  (ice-9 regex))
+       #:builder (begin
+                   (use-modules (guix build utils))
+                   (use-modules (ice-9 ftw))
+                   (use-modules (ice-9 regex))
+                   (let* ((input-path (lambda (binary path)
+                                       (string-append
+                                        (assoc-ref %build-inputs binary)
+                                         path ":")))
+                          (binaries '("bash" "ld-wrapper" "binutils"
+                                       "coreutils" "findutils" "flex" "git"
+                                       "gcc" "grep" "make" "openmpi" "sed"
+                                       "tar" "xz"))
+                          (binary-directories (string-concatenate
+                           (map-in-order (lambda (binary)
+                                          (input-path binary "/bin"))
+                                           binaries))))
+                    ;; set PATH environment variable for unpacking and building
+                    (setenv "PATH" (string-drop-right binary-directories 1))
+                    ;; unpack source code
+                    (system* "tar" "xvf" (assoc-ref %build-inputs "source"))
+                   )
+                   (let ((unpack-dir (string-append
+                                      (getcwd) "/"
+                                      (list-ref (scandir (getcwd) (lambda (name)
+                                        (string-match "^OpenFOAM" name))) 0)))
+                         (build-dir (string-append
+                                     (getcwd) "/OpenFOAM-" ,version)))
+                    ;; re-name top level directory
+                    (rename-file unpack-dir build-dir)
+                    ;; move to top level directory
+                    (chdir (basename build-dir))
+                    ;; replace interpreter paths in scripts
+                    (patch-shebang "Allwmake")
+                    (for-each patch-shebang
+                              (find-files "applications"
+                               (format #f "(~a|~a|~a|~a)$"
+                                 "Allwmake" "Allwclean" "Allrun"
+                                 "ensightFoamReaderTest")))
+                    (for-each patch-shebang
+                              (find-files "bin"))
+                    (for-each patch-shebang
+                              (find-files "doc"
+                                 "(Allwmake|find-its)$"))
+                    (for-each patch-shebang
+                              (find-files "etc"))
+                    (for-each patch-shebang
+                              (find-files "src"
+                                 "(Allwmake|Allwclean|AllwmakeLnInclude)$"))
+                    (for-each patch-shebang
+                              (find-files "tutorials"
+                               (format #f "(~a|~a|~a|~a|~a|~a|~a|~a|~a|~a|~a)$"
+                                "Allclean" "Allmesh" "Allrun.*" "Alltest"
+                                "makeMesh" "createGraph.*" "extractHeightData"
+                                "patchifyObstacles" "sampleCone"
+                                "externalSolver" "surfaceProcess.sh")))
+                    (for-each patch-shebang
+                              (find-files "wmake"))
+                   )
+                   (let ((install-dir (string-append
+                                       %output "/OpenFOAM-" ,version))
+                         (libraries '("boost" "cgal" "flex" "glibc" "gmp"
+                                      "linux-libre-headers" "metis" "mpfr"
+                                      "pt-scotch" "readline" "scotch" "zlib")))
+                    ;; set environment variables to define library versions
+                    (setenv "SCOTCHVERSION" ,(package-version scotch))
+                    (setenv "METISVERSION" ,(package-version metis))
+                    ;; set environment variables to define library paths
+                    (map (lambda (library)
+                          (setenv (string-append
+                                   (string-upcase library) "_ROOT")
+                           (assoc-ref %build-inputs library))) libraries)
+                    (setenv "LIBRARY_PATH" (string-append
+                                     (getenv "GLIBC_ROOT") "/lib" ":"
+                                     (getenv "ZLIB_ROOT") "/lib"))
+                    ;; set environment variables to define header paths
+                    (setenv "CPATH" (string-append
+                                     (getenv "LINUX-LIBRE-HEADERS_ROOT")
+                                     "/include"))
+                    (setenv "CPLUS_INCLUDE_PATH" (string-append
+                                     (getenv "METIS_ROOT") "/include" ":"
+                                     (getenv "FLEX_ROOT") "/include" ":"
+                                     (getenv "ZLIB_ROOT") "/include"))
+                    ;; compile OpenFOAM libraries and applications
+                    (system (format #f "source ./etc/bashrc && ./Allwmake -j~a"
+                               (parallel-job-count)))
+                    ;; update configuration files
+                    (system (format #f "sed -i 's|~a|'~:*~s'|' ~a"
+                               "$CGAL_ROOT" "etc/config.sh/CGAL"))
+                    (system (format #f "sed -i 's|~a|'~:*~s'|' ~a"
+                               "$BOOST_ROOT" "etc/config.sh/CGAL"))
+                    (system (format #f "sed -i 's|~a|'~:*~s'|' ~a"
+                               "$METIS_ROOT" "etc/config.sh/metis"))
+                    (system (format #f "sed -i 's|~a|'~:*~s'|' ~a"
+                               "$METISVERSION" "etc/config.sh/metis"))
+                    (system (format #f "sed -i 's|~a|'~:*~s'|' ~a"
+                               "$SCOTCH_ROOT" "etc/config.sh/scotch"))
+                    (system (format #f "sed -i 's|~a|'~:*~s'|' ~a"
+                               "$SCOTCHVERSION" "etc/config.sh/scotch"))
+                    (system (format #f "sed -i 's|~a|'~:*~s'|' ~a"
+                               "$GMP_ROOT" "etc/config.sh/settings"))
+                    (system (format #f "sed -i 's|~a|'~:*~s'|' ~a"
+                               "$MPFR_ROOT" "etc/config.sh/settings"))
+                    ;; set write permission on tutorial files
+                    (system (format #f "chmod -R u+w ~a" "tutorials"))
+                    ;; create install directory
+                    (mkdir-p install-dir)
+                    ;; move contents of build directory to install directory
+                    (copy-recursively "." install-dir)
+		   )
+		 )
+       )
+     )
+    (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++.  Discrete versions of governing equations such as the Navier-Stokes
+equations can be solved in integral form.  OpenFOAM implements the Finite
+Volume Method for discretizing the spacial dimensions.  Grids are accepted that
+define complex geometries in two- and three-dimensional domains.  Grids may be
+unstructured in layout and may contain any combination of polyhedral cells.
+Large problems can be split into connected smaller problems for efficient
+solution on parallel systems")
+    (license license:gpl3+)
+    (home-page "https://openfoam.org")))
+
 (define-public maxflow
   (package
     (name "maxflow")
diff --git a/gnu/packages/patches/openfoam-cleanup.patch b/gnu/packages/patches/openfoam-cleanup.patch
new file mode 100644
index 000000000..e7760b7a5
--- /dev/null
+++ b/gnu/packages/patches/openfoam-cleanup.patch
@@ -0,0 +1,267 @@
+# This patch removes all need for the ThirdParty files of OpenFOAM
+
+# Derived from easybuild patch:  Ward Poelmans <wpoely86@gmail.com>
+# Modified for GNU Guix:  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 [ -f $READLINE_ROOT/include/readline/readline.h ]
+ then
+     echo "Found <readline/readline.h>  --  enabling readline support."
+     export COMP_FLAGS="-DHAS_READLINE"
+diff -ur OpenFOAM-4.x-version-4.1.org/applications/utilities/mesh/manipulation/setSet/Make/options OpenFOAM-4.x-version-4.1/applications/utilities/mesh/manipulation/setSet/Make/options
+--- OpenFOAM-4.x-version-4.1.org/applications/utilities/mesh/manipulation/setSet/Make/options
++++ OpenFOAM-4.x-version-4.1/applications/utilities/mesh/manipulation/setSet/Make/options
+@@ -1,7 +1,9 @@
+ EXE_INC = \
+     -I$(LIB_SRC)/meshTools/lnInclude \
++    -I$(READLINE_ROOT)/include \
+     $(COMP_FLAGS)
+ 
+ EXE_LIBS = \
++    -L$(READLINE_ROOT)/lib \
+     -lmeshTools \
+     $(LINK_FLAGS)
+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
+@@ -3,10 +3,9 @@
+
+ EXE_INC = \
+     $(PFLAGS) $(PINC) \
+-    -I$(SCOTCH_ROOT)/include \
++    -I$(PT-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$(PT-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/src/Makefile OpenFOAM-4.x-version-4.1/wmake/src/Makefile
+--- OpenFOAM-4.x-version-4.1.org/wmake/src/Makefile
++++ OpenFOAM-4.x-version-4.1/wmake/src/Makefile
+@@ -33,7 +33,7 @@
+ # The Makefile use a POSIX shell
+ #------------------------------------------------------------------------------
+ 
+-SHELL      = /bin/sh
++# SHELL      = /bin/sh
+ 
+ #------------------------------------------------------------------------------
+ # Unset suffices list (suffix rules are not used)
+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 \
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] gnu: Add openfoam
  2017-07-23 20:11 [PATCH] gnu: Add openfoam Paul Garlick
@ 2017-07-25  9:02 ` Ludovic Courtès
  2017-07-28 16:01   ` Paul Garlick
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2017-07-25  9:02 UTC (permalink / raw)
  To: Paul Garlick; +Cc: guix-devel

Hello Paul,

Thanks for this patch!

Paul Garlick <pgarlick@tourbillion-technology.com> skribis:

> * gnu/packages/maths.scm(openfoam): Add it
> * gnu/packages/patches/openfoam-cleanup.patch: New file
> * gnu/local.mk(dist_patch_DATA): Add patch

I think it might make sense to create a new “simulation” module, and
eventually move OpenCascade there as well, WDYT?

Some comments:

> +    (build-system trivial-build-system)

Did you consider using ‘gnu-build-system’?  I think this would save
quite a few lines corresponding to the initial setup (set-paths, unpack,
patch-shebang, etc.), and also ensure that the final phases (strip,
compress-documentation, etc.) are run.  In addition you wouldn’t need to
list all the usual build inputs (GCC, Coreutils, Make, etc.).  WDYT?

> +		   )
> +		 )
> +       )
> +     )

Please listen to what ‘guix lint’ has to say about these.  :-)

> +    (native-search-paths
> +     ;; define the FOAM_INST_DIR variable
> +     (list (search-path-specification
> +            (variable "FOAM_INST_DIR")
> +            (files '(".")))))

My guess is that ‘FOAM_INST_DIR’ is not a search path (in the sense of a
colon-separated list of directories like ‘PATH’.)

What about wrapping the resulting binaries so that they have
‘FOAM_INST_DIR’ set to %output?

> diff --git a/gnu/packages/patches/openfoam-cleanup.patch b/gnu/packages/patches/openfoam-cleanup.patch
> new file mode 100644
> index 000000000..e7760b7a5
> --- /dev/null
> +++ b/gnu/packages/patches/openfoam-cleanup.patch
> @@ -0,0 +1,267 @@
> +# This patch removes all need for the ThirdParty files of OpenFOAM

Nice!

> +# Derived from easybuild patch:  Ward Poelmans <wpoely86@gmail.com>
> +# Modified for GNU Guix:  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 [ -f $READLINE_ROOT/include/readline/readline.h ]

You could make it “if true”, thereby avoiding the need to define
$READLINE_ROOT.

> +--- OpenFOAM-4.x-version-4.1.org/applications/utilities/mesh/manipulation/setSet/Make/options
> ++++ OpenFOAM-4.x-version-4.1/applications/utilities/mesh/manipulation/setSet/Make/options
> +@@ -1,7 +1,9 @@
> + EXE_INC = \
> +     -I$(LIB_SRC)/meshTools/lnInclude \
> ++    -I$(READLINE_ROOT)/include \

Likewise, ‘gnu-build-system’ will set C_INCLUDE_PATH appropriately so
this -I flag won’t be needed.

Could you send an updated patch to guix-patches@gnu.org, where it will
be visible in the patch tracker?

Thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gnu: Add openfoam
  2017-07-25  9:02 ` Ludovic Courtès
@ 2017-07-28 16:01   ` Paul Garlick
  2017-08-01 12:18     ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Garlick @ 2017-07-28 16:01 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 2711 bytes --]

Hello Ludo,
> I think it might make sense to create a new “simulation” module, and
> eventually move OpenCascade there as well, WDYT?
> 
Sure.  I will create a new module and put the OpenFOAM package
definition in there as the first one.
> Some comments:
> 
> 
> > 
> > +    (build-system trivial-build-system)
> > 

> 
> 
> Did you consider using ‘gnu-build-system’?  I think this would save
> quite a few lines corresponding to the initial setup (set-paths, unpack,
> patch-shebang, etc.), and also ensure that the final phases (strip,
> compress-documentation, etc.) are run.  In addition you wouldn’t need to
> list all the usual build inputs (GCC, Coreutils, Make, etc.).  WDYT?
> 

I did consider both options, removing and modifying stages in the gnu-
build-system or starting from scratch with the trivial-build-system.  I
can give the gnu-build-system option a go, reverting to the trivial-
build-system if the new attempt proves too troublesome.  
One aspect I will need to investigate in the gnu-build-system is using
the "./Allwmake" command to trigger the build process.  In OpenFOAM,
wmake is short for "wrapped-make" and the package has its own
configuration step.  In brief, it has its own sequence and does not
follow the standard "./configure && make && make install" steps.
Using the trivial-build-system the patch-shebang section is indeed a
little extended.  I found this was necessary to avoid a failure of the
patch-shebang command using a simple 'find-files "."' from top-level
directory.  There is a scenario where sub-directories named '0', in the
'tutorials' directory, identified by the find-files command, being
passed to 'patch-shebang', which should only receive files, not
directories.  This causes 'patch-shebang' to stop and the build fails.
> > 
> > +		   )
> > +		 )
> > +       )
> > +     )
> > 

> 
> 
> Please listen to what ‘guix lint’ has to say about these.  :-)
> 

Interestingly, 'guix lint' let me get away with this without making
comment.  However, I shall condense things accordingly in the new
patch.
> What about wrapping the resulting binaries so that they have
> ‘FOAM_INST_DIR’ set to %output?
> 
> 

In fact, FOAM_INST_DIR is used in multiple places to navigate around
the installed files (not just the binaries), so I think this variable
may need to remain available as is.
> 
> You could make it “if true”, thereby avoiding the need to define
> $READLINE_ROOT.
> 
> 

Could you elaborate on this idea a little?  At the moment the test is
"if file exists".
> Could you send an updated patch to guix-patches@gnu.org, where it will
> , where it will
> be visible in the patch tracker?
> 
> 
> 

Aha, a new system!
Best,
Paul.

[-- Attachment #2: Type: text/html, Size: 3542 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gnu: Add openfoam
  2017-07-28 16:01   ` Paul Garlick
@ 2017-08-01 12:18     ` Ludovic Courtès
  0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2017-08-01 12:18 UTC (permalink / raw)
  To: Paul Garlick; +Cc: guix-devel

Hi Paul,

Paul Garlick <pgarlick@tourbillion-technology.com> skribis:

>> I think it might make sense to create a new “simulation” module, and
>> eventually move OpenCascade there as well, WDYT?
>> 
> Sure.  I will create a new module and put the OpenFOAM package
> definition in there as the first one.

Sounds good.

>> Some comments:
>> 
>> 
>> > 
>> > +    (build-system trivial-build-system)
>> > 
>
>> 
>> 
>> Did you consider using ‘gnu-build-system’?  I think this would save
>> quite a few lines corresponding to the initial setup (set-paths, unpack,
>> patch-shebang, etc.), and also ensure that the final phases (strip,
>> compress-documentation, etc.) are run.  In addition you wouldn’t need to
>> list all the usual build inputs (GCC, Coreutils, Make, etc.).  WDYT?
>> 
>
> I did consider both options, removing and modifying stages in the gnu-
> build-system or starting from scratch with the trivial-build-system.  I
> can give the gnu-build-system option a go, reverting to the trivial-
> build-system if the new attempt proves too troublesome.  

With ‘gnu-build-system’ you’ll have to replace/remove some of the
phases, but hopefully it’ll be less troublesome nonetheless.

> One aspect I will need to investigate in the gnu-build-system is using
> the "./Allwmake" command to trigger the build process.  In OpenFOAM,
> wmake is short for "wrapped-make" and the package has its own
> configuration step.  In brief, it has its own sequence and does not
> follow the standard "./configure && make && make install" steps.
> Using the trivial-build-system the patch-shebang section is indeed a
> little extended.  I found this was necessary to avoid a failure of the
> patch-shebang command using a simple 'find-files "."' from top-level
> directory.  There is a scenario where sub-directories named '0', in the
> 'tutorials' directory, identified by the find-files command, being
> passed to 'patch-shebang', which should only receive files, not
> directories.  This causes 'patch-shebang' to stop and the build fails.

‘find-files’ excludes directories by default, so it’s a little
surprising.  Anyway, we can surely find a way to work around the
problem.

>> > 
>> > +		   )
>> > +		 )
>> > +       )
>> > +     )
>> > 
>
>> 
>> 
>> Please listen to what ‘guix lint’ has to say about these.  :-)
>> 
>
> Interestingly, 'guix lint' let me get away with this without making
> comment.  However, I shall condense things accordingly in the new
> patch.

Oh indeed, until now it would only scan 60 lines from the start of the
definition.  Fixed!

>> What about wrapping the resulting binaries so that they have
>> ‘FOAM_INST_DIR’ set to %output?
>> 
>> 
>
> In fact, FOAM_INST_DIR is used in multiple places to navigate around
> the installed files (not just the binaries), so I think this variable
> may need to remain available as is.

OK, though it would be good to make it work out-of-the-box when
FOAM_INST_DIR is undefined.

>> You could make it “if true”, thereby avoiding the need to define
>> $READLINE_ROOT.
>> 
>> 
>
> Could you elaborate on this idea a little?  At the moment the test is
> "if file exists".

I was thinking about doing something like this:

-if [ -f /usr/include/readline/readline.h ]
+if true

and thus we wouldn’t need to define READLINE_ROOT, IIUC.

HTH,
Ludo’.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-01 12:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-23 20:11 [PATCH] gnu: Add openfoam Paul Garlick
2017-07-25  9:02 ` Ludovic Courtès
2017-07-28 16:01   ` Paul Garlick
2017-08-01 12:18     ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).