all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: reza via Guix-patches via <guix-patches@gnu.org>
To: 66262@debbugs.gnu.org <66262@debbugs.gnu.org>
Cc: reza <reza@housseini.me>
Subject: [bug#66262] [PATCH v2 1/3] gnu: Add openfoam-package.
Date: Fri, 29 Sep 2023 09:39:50 +0000	[thread overview]
Message-ID: <0102018ae04f07c5-bbef6aff-cee5-4376-a9c3-487aa062960a-000000@eu-west-1.amazonses.com> (raw)
In-Reply-To: <cover.1695980074.git.reza@housseini.me>

* gnu/packages/simulation.scm (openfoam-package): Add factory function to
generate openfoam packages. Improve build tree clean up.
---
 gnu/packages/simulation.scm | 295 ++++++++++++++++++++++++++++++++++++
 1 file changed, 295 insertions(+)

diff --git a/gnu/packages/simulation.scm b/gnu/packages/simulation.scm
index b2fb123815..ab4f7c124f 100644
--- a/gnu/packages/simulation.scm
+++ b/gnu/packages/simulation.scm
@@ -450,6 +450,301 @@ (define-public openfoam-com
     (synopsis "Framework for numerical simulation of fluid flow (from openfoam.com)")
     (home-page "https://www.openfoam.com")))
 
+(define* (openfoam-package source version name home-page synopsis)
+  (let* ((install-path (string-append "share/OpenFOAM-" version))
+         (paraview-version (version-major+minor (package-version paraview)))
+         (pv-plugin-path
+          (string-append install-path
+                         "/platforms/linux64GccDPInt32Opt/lib/paraview-"
+                         paraview-version)))
+    (package
+      (name name)
+      (version version)
+      (source source)
+      (build-system gnu-build-system)
+      (native-search-paths
+       (list (search-path-specification
+	      (variable "WM_PROJECT_DIR")
+	      (files `(,install-path)))
+             ;; add PV_PLUGIN_PATH to LD_LIBRARY_PATH so paraview
+             ;; finds the OpenFOAM PV plugins
+             (search-path-specification
+	      (variable "LD_LIBRARY_PATH")
+	      (files `(,pv-plugin-path)))))
+      (inputs (list boost
+		    cgal
+		    git
+		    gmp
+		    libxt
+		    metis
+		    mpfr
+		    ncurses
+		    openmpi
+		    openssh
+		    paraview
+		    pt-scotch32
+		    readline
+		    scotch
+		    zlib))
+      (native-inputs (list bison
+		           flex
+		           ;; paraview plugin dependencies
+		           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"))
+      (arguments
+       (list
+        ;; Executable files and shared libraries are located in the 'platforms'
+        ;; subdirectory.
+        #:strip-directories
+        #~(list (string-append "OpenFOAM-" #$version "/platforms/linux64GccDPInt32Opt/bin")
+	        (string-append "OpenFOAM-" #$version "/platforms/linux64GccDPInt32Opt/lib"))
+
+        #:modules
+        '((ice-9 ftw)
+          (ice-9 regex)
+          (ice-9 string-fun)
+          (srfi srfi-1)
+          (guix build gnu-build-system)
+          (guix build utils))
+
+        #:phases
+        #~(modify-phases %standard-phases
+	    (add-before 'build 'patch-HOME-path
+	      (lambda _
+	        (setenv "HOME" "/tmp") #t))
+	    (add-before 'build 'patch-scotch
+	      (lambda _
+	        (substitute* "etc/config.sh/scotch"
+	          (("^export SCOTCH_VERSION=scotch_.*$")
+	           (string-append "export SCOTCH_VERSION=scotch_"
+			          #$(package-version pt-scotch32) "\n"))
+	          (("^export SCOTCH_ARCH_PATH=.*$")
+	           (string-append "export SCOTCH_ARCH_PATH=" #$pt-scotch32 "\n")))
+	        #t))
+	    (add-before 'build 'patch-mpi
+	      (lambda _
+	        (let* ((mpi-version #$(package-version openmpi)))
+	          ;; specify openmpi type
+	          (substitute* "etc/bashrc"
+		    (("WM_MPLIB=SYSTEMOPENMPI")
+		     "WM_MPLIB=OPENMPI"))
+	          (substitute* "etc/config.sh/mpi"
+		    (("export FOAM_MPI=openmpi-.*$")
+		     (string-append "export FOAM_MPI=openmpi-"
+				    mpi-version "\n"))
+		    (("export MPI_ARCH_PATH=.*\\$FOAM_MPI.*$")
+		     (string-append "export MPI_ARCH_PATH=" #$openmpi "\n"))))
+	        #t))
+	    (add-before 'build 'patch-paraview
+	      (lambda _
+	        (substitute* "etc/config.sh/paraview"
+	          (("^export ParaView_VERSION=.*$")
+	           (string-append "export ParaView_VERSION="
+			          #$(package-version paraview) "\n"))
+	          (("^export ParaView_DIR=.*$")
+	           (string-append "export ParaView_DIR=" #$paraview "\n"))
+                  (("export ParaView_GL=mesa") "export ParaView_GL=system"))
+	        #t))
+	    (add-before 'build 'add-rpaths
+	      (lambda _
+	        (letrec* ((libraries '("boost"
+				       "cgal"
+				       "gmp"
+				       "metis"
+				       "mpfr"
+				       "scotch"
+				       "pt-scotch32"
+ 				       "openmpi"
+				       "zlib"
+				       "paraview"))
+		          (rpaths
+		           (fold-right (lambda (lib rpaths)
+				         (string-append rpaths
+						        "-rpath="
+						        (assoc-ref %build-inputs lib)
+						        "/lib,")) "" libraries))
+		          (openfoam-lib
+		           (string-append #$output
+				          "/share/OpenFOAM-" #$version
+				          "/platforms/linux64GccDPInt32Opt/lib"))
+		          (ldflags
+		           (string-append "-Wl,"
+				          rpaths
+				          "-rpath="
+				          openfoam-lib
+				          ","
+				          "-rpath="
+				          openfoam-lib
+				          "/dummy,"
+				          "-rpath="
+				          openfoam-lib
+				          "/paraview-"
+				          #$(version-major+minor (package-version
+							          paraview)))))
+	          (substitute* "wmake/rules/linux64Gcc/c++"
+		    (("\\$\\(LIB_HEADER_DIRS\\) -fPIC" all)
+		     (string-append all " " ldflags)))) #t))
+	    (add-before 'build 'add-vtk-include-path
+	      (lambda _
+	        (let* ((vtk-version #$(version-major+minor
+				       (package-version vtk)))
+		       (vtk-inc (string-append #$vtk "/include/vtk-" vtk-version))
+		       (vtk-inc-flag (string-append "-I" vtk-inc)))
+	          (substitute* "wmake/rules/linux64Gcc/c++"
+		    (("\\$\\(LIB_HEADER_DIRS\\)" all)
+		     (string-append all " " vtk-inc-flag " "))))
+	        #t))
+	    (delete 'configure) ;no configure phase
+	    (replace 'build
+	      (lambda _
+	        ;; compile OpenFOAM libraries and applications
+	        (invoke "bash" "-c"
+		        (format #f
+			        "source ./etc/bashrc && ./Allwmake -j~a"
+			        (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$"))
+                ;; Remove spurious files in src tree
+                (invoke "bash" "-c" "source ./etc/bashrc && wclean all")
+                #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)))
+                      ;; cleanup
+                      (invoke "bash" "-c"
+			      "source ../etc/bashrc && ./Allclean")))
+	          ;; too many tutorials are failing
+	          ;; (with-directory-excursion "tutorials"
+	          ;; (invoke "bash" "-c" "source ../etc/bashrc && ./Alltest"))
+	          ) #t))
+	    (add-before 'install 'set-paths
+	      (lambda _
+	        (let ((install-path (string-append #$output
+					           "/share/OpenFOAM-" #$version)))
+	          (substitute* "etc/bashrc"
+		    (("^\\[ \"\\$BASH\".*$") "")
+		    (("^export FOAM_INST_DIR=\\$\\(cd.*$")
+		     (string-append "export FOAM_INST_DIR=" install-path "\n"))
+		    (("^export FOAM_INST_DIR=\\$HOME.*$") "")))
+	        #t))
+	    (replace 'install
+	      (lambda* (#:key outputs inputs #:allow-other-keys)
+	        (let ((install-path (string-append #$output
+					           "/share/OpenFOAM-" #$version)))
+	          (mkdir-p install-path) ;create install directory
+	          ;; move contents of build directory to install directory
+	          (copy-recursively "." install-path))))
+	    (add-after 'install 'add-symbolic-link
+	      (lambda _
+	        (let* ((bin (string-append #$output "/bin"))
+		       (lib (string-append #$output "/lib"))
+		       (openfoam (string-append #$output
+					        "/share/OpenFOAM-" #$version))
+		       (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)))))
+      ;; 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 $WM_PROJECT_DIR/etc/bashrc
+      ;; $ mkdir -p $FOAM_RUN
+      ;; $ cd $FOAM_RUN
+      ;; $ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
+      ;; $ cd pitzDaily
+      ;; $ chmod -R u+w .
+      ;; $ blockMesh
+      (synopsis synopsis)
+      (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 home-page))))
+
 (define-public open-simulation-interface
   (package
     (name "open-simulation-interface")
-- 
2.41.0






       reply	other threads:[~2023-09-29  9:41 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1695980074.git.reza@housseini.me>
     [not found] ` <8f684396d68f2748f0b5e9ea832e483438cf195d.1695980074.git.reza@housseini.me>
2023-09-29  9:39   ` reza via Guix-patches via [this message]
     [not found] ` <aa633991702c2752a9692a695792e972172b2faf.1695980074.git.reza@housseini.me>
2023-09-29  9:39   ` [bug#66262] [PATCH v2 2/3] gnu: openfoam-org: Update to 11 reza via Guix-patches via
     [not found] ` <9141e57d9db9be29442325736da07e61ff3c5420.1695980074.git.reza@housseini.me>
2023-09-29  9:40   ` [bug#66262] [PATCH v2 3/3] gnu: openfoam-com: Update to 2306 reza via Guix-patches via
     [not found] <5a90ca452eac7f8947a241bf0900ca928acc311f.1701462064.git.reza@housseini.me>
     [not found] ` <e0b24fe5429f273c7e3fc07579efbb8c0cb8c560.1701462064.git.reza@housseini.me>
2023-12-01 20:21   ` [bug#66262] [PATCH v7 2/7] gnu: openfoam-org: Refactor dependency reza via Guix-patches via
     [not found] ` <b90c77d497a24b3b790237d1cd4c64f9ecf7ea9a.1701462064.git.reza@housseini.me>
2023-12-01 20:21   ` [bug#66262] [PATCH v7 3/7] gnu: openfoam-org: Improve internal path handling reza via Guix-patches via
     [not found] ` <54b1a2d73885ed2f5fef4f74fde212f9c811ce66.1701462064.git.reza@housseini.me>
2023-12-01 20:21   ` [bug#66262] [PATCH v7 4/7] gnu: openfoam-org: Improve build clean up reza via Guix-patches via
     [not found] ` <f4fb02c20f3836c2e1a3c9abddd558c2addb0451.1701462064.git.reza@housseini.me>
2023-12-01 20:21   ` [bug#66262] [PATCH v7 5/7] gnu: openfoam-org: Update to 11 reza via Guix-patches via
     [not found] ` <1e5198861de5777cb1ad76b7919bc80870b54585.1701462064.git.reza@housseini.me>
2023-12-01 20:21   ` [bug#66262] [PATCH v7 6/7] gnu: openfoam-com: Update to 2306 reza via Guix-patches via
     [not found] ` <e215dd308ca23fcdac93a10f03ae11185fa9a9f0.1701462064.git.reza@housseini.me>
2023-12-01 20:21   ` [bug#66262] [PATCH v7 7/7] gnu: openfoam-org: Improve wrapping of binaries reza via Guix-patches via
     [not found] <5a90ca452eac7f8947a241bf0900ca928acc311f.1701290362.git.reza@housseini.me>
     [not found] ` <b90c77d497a24b3b790237d1cd4c64f9ecf7ea9a.1701290362.git.reza@housseini.me>
2023-11-29 20:39   ` [bug#66262] [PATCH v5 3/6] gnu: openfoam-org: Improve internal path handling reza via Guix-patches via
     [not found] ` <f4fb02c20f3836c2e1a3c9abddd558c2addb0451.1701290362.git.reza@housseini.me>
2023-11-29 20:39   ` [bug#66262] [PATCH v5 5/6] gnu: openfoam-org: Update to 11 reza via Guix-patches via
     [not found] ` <54b1a2d73885ed2f5fef4f74fde212f9c811ce66.1701290362.git.reza@housseini.me>
2023-11-29 20:39   ` [bug#66262] [PATCH v5 4/6] gnu: openfoam-org: Improve build clean up reza via Guix-patches via
     [not found] ` <1e5198861de5777cb1ad76b7919bc80870b54585.1701290362.git.reza@housseini.me>
2023-11-29 20:39   ` [bug#66262] [PATCH v5 6/6] gnu: openfoam-com: Update to 2306 reza via Guix-patches via
     [not found] ` <e0b24fe5429f273c7e3fc07579efbb8c0cb8c560.1701290362.git.reza@housseini.me>
2023-11-29 20:39   ` [bug#66262] [PATCH v5 2/6] gnu: openfoam-org: Refactor dependency reza via Guix-patches via
     [not found] <fe263426cf5f402a7a251e120af65d4a15f955ab.1701268112.git.reza@housseini.me>
     [not found] ` <c9ba1409a268744673caf17ec529b415ad1fa29f.1701268112.git.reza@housseini.me>
2023-11-29 14:29   ` [bug#66262] [PATCH v4 " reza via Guix-patches via
     [not found] ` <0acf762696be31d70a2c40523c0054e52f9606ef.1701268112.git.reza@housseini.me>
2023-11-29 14:29   ` [bug#66262] [PATCH v4 3/6] gnu: openfoam-org: Improve internal path handling reza via Guix-patches via
     [not found] ` <97b7044beb51357a1b2f50bc59ab840fa5f97808.1701268112.git.reza@housseini.me>
2023-11-29 14:29   ` [bug#66262] [PATCH v4 4/6] gnu: openfoam-org: Improve build clean up reza via Guix-patches via
     [not found] ` <5380542281402a0572fbb4270658f354611448d9.1701268112.git.reza@housseini.me>
2023-11-29 14:29   ` [bug#66262] [PATCH v4 5/6] gnu: openfoam-org: Update to 11 reza via Guix-patches via
     [not found] ` <3aca16d2ccc66d8f39f08ddcb9a4bbda30c9caa3.1701268112.git.reza@housseini.me>
2023-11-29 14:29   ` [bug#66262] [PATCH v4 6/6] gnu: openfoam-com: Update to 2306 reza via Guix-patches via
     [not found] <cover.1696919009.git.reza@housseini.me>
     [not found] ` <ccac0a551e301ab86d5c77ba928fac1cf69cf138.1696919009.git.reza@housseini.me>
2023-10-10  6:25   ` [bug#66262] [PATCH v3 1/3] gnu: Add openfoam-package reza via Guix-patches via
     [not found] ` <bce423db0172bc6d5e2c7cc21f0df96e1b1a34e6.1696919009.git.reza@housseini.me>
2023-10-10  6:25   ` [bug#66262] [PATCH v3 2/3] gnu: openfoam-org: Update to 11 reza via Guix-patches via
     [not found] ` <f4cd9332ffd1c23dbf9fac5b1821676ae6c2aa2d.1696919009.git.reza@housseini.me>
2023-10-10  6:25   ` [bug#66262] [PATCH v3 3/3] gnu: openfoam-com: Update to 2306 reza via Guix-patches via
     [not found] <cover.1695977095.git.reza@housseini.me>
2023-09-29  9:00 ` [bug#66262] [PATCH 0/3] Update openfoam and fix bugs reza via Guix-patches via
2023-09-29  9:39   ` [bug#66262] [PATCH v2 0/3] Update openfoam reza via Guix-patches via
2023-10-10  6:25   ` [bug#66262] [PATCH v3 0/3] Remove paraview plugin search path reza via Guix-patches via
2023-11-29 14:28   ` [bug#66262] [PATCH v4 1/6] gnu: openfoam-org: Use gexps reza via Guix-patches via
2023-11-29 20:39   ` [bug#66262] [PATCH v5 " reza via Guix-patches via
2023-11-30  8:30   ` [bug#66262] [PATCH v6 " reza via Guix-patches via
2023-11-30  8:38   ` [bug#66262] [PATCH v6 2/6] gnu: openfoam-org: Refactor dependency reza via Guix-patches via
2023-11-30  8:41   ` [bug#66262] [PATCH v6 3/6] gnu: openfoam-org: Improve internal path handling reza via Guix-patches via
2023-11-30  8:57   ` [bug#66262] [PATCH v6 4/6] gnu: openfoam-org: Improve build clean up reza via Guix-patches via
2023-11-30  9:01   ` [bug#66262] [PATCH v6 5/6] gnu: openfoam-org: Update to 11 reza via Guix-patches via
2023-11-30  9:03   ` [bug#66262] [PATCH v6 6/6] gnu: openfoam-com: Update to 2306 reza via Guix-patches via
2023-12-01 20:21   ` [bug#66262] [PATCH v7 1/7] gnu: openfoam-org: Use gexps reza via Guix-patches via
     [not found] ` <08d37437f0611551d403bb7da15d78c94fe3791f.1695977095.git.reza@housseini.me>
2023-09-29  9:03   ` [bug#66262] [PATCH 1/3] gnu: Add openfoam-package reza via Guix-patches via
     [not found] ` <3c9e2eabdc2f10db9d2a51d82203fcefd5e5e218.1695977095.git.reza@housseini.me>
2023-09-29  9:03   ` [bug#66262] [PATCH 2/3] gnu: openfoam-org: Update to 11 reza via Guix-patches via
     [not found] ` <c648aabf51e10ae1063dec75068dc71d54d36ba9.1695977095.git.reza@housseini.me>
2023-09-29  9:03   ` [bug#66262] [PATCH 3/3] gnu: openfoam-com: Update to 2306 reza via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0102018ae04f07c5-bbef6aff-cee5-4376-a9c3-487aa062960a-000000@eu-west-1.amazonses.com \
    --to=guix-patches@gnu.org \
    --cc=66262@debbugs.gnu.org \
    --cc=reza@housseini.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.