From a4ca2bb889fb65f9fdd2cbeca7d64fe8d5b27577 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 2 Jul 2018 17:02:48 +0200 Subject: ENH: Building OpenFOAM sub-packages (issue #8579) (#8592) * ENH: Building OpenFOAM sub-packages (issue #8579) * Some support for packages building with OpenFOAM - Adjust the wrappers calling the OpenFOAM Allwmake script. Have them look for a Allwmake-spack file first, which is assumed to contain special adjustments for compiling with spack. This file could be delivered as part of a tarball (which is unlikely) or generated on the fly by the spack sub-package as part of its patch or configure stage. CONFIG: change the default paraview variant for openfoam to be False - the different combinations of paraview backends, off-screen etc make it difficult to suggest that building with paraview as a standard dependency makes much sense. Additionally, building paraview with qt can become quite an issue. So it makes much more sense to only enable that upon request. ENH: add a +vtk variant. - for VTK with off-screen rendering to be used by the runTimePostProcessing function object, which is a fairly simple framework for generating images of some OpenFOAM derived objects (eg, sampling planes). SPACK spec problem: - reflect the flex restriction impose by the scotch dependency within the openfoam spec as well, as partial workaround for buggy or annoying spec resolution. OTHER: - updated the backstop foamEtcFile file to include args handling as per the OpenFOAM-v1806 updates. * new version: OpenFOAM-v1806 - https://www.openfoam.com/releases/openfoam-v1806/ --- .../packages/openfoam-com/common/spack-Allwmake | 10 +- .../openfoam-com/common/spack-derived-Allwmake | 12 +- .../repos/builtin/packages/openfoam-com/package.py | 19 ++- .../packages/openfoam-org/assets/bin/foamEtcFile | 170 +++++++++++++++------ 4 files changed, 156 insertions(+), 55 deletions(-) diff --git a/var/spack/repos/builtin/packages/openfoam-com/common/spack-Allwmake b/var/spack/repos/builtin/packages/openfoam-com/common/spack-Allwmake index cff22daf10..6c53c2fd70 100755 --- a/var/spack/repos/builtin/packages/openfoam-com/common/spack-Allwmake +++ b/var/spack/repos/builtin/packages/openfoam-com/common/spack-Allwmake @@ -5,7 +5,15 @@ export FOAM_INST_DIR=$(cd .. && pwd -L) mkdir -p $FOAM_APPBIN $FOAM_LIBBIN 2>/dev/null # Allow interrupt echo "Build openfoam with SPACK ($@)" echo WM_PROJECT_DIR = $WM_PROJECT_DIR -./Allwmake $@ # Pass arguments + +# Prefer spack-specific Allwmake if it exists +if [ -f Allwmake-spack ] +then + ./Allwmake-spack $@ # Pass arguments +else + ./Allwmake $@ # Pass arguments +fi + # Link non-dummy MPI_FOAM type to parent-dir, where rpath can find it if [ "${FOAM_MPI:=dummy}" != dummy -a -d "$FOAM_LIBBIN/$FOAM_MPI" ] diff --git a/var/spack/repos/builtin/packages/openfoam-com/common/spack-derived-Allwmake b/var/spack/repos/builtin/packages/openfoam-com/common/spack-derived-Allwmake index 407ad734e8..02741f1d13 100755 --- a/var/spack/repos/builtin/packages/openfoam-com/common/spack-derived-Allwmake +++ b/var/spack/repos/builtin/packages/openfoam-com/common/spack-derived-Allwmake @@ -1,6 +1,7 @@ #!/bin/bash # The openfoam providers must export 'FOAM_PROJECT_DIR' -# The package is expected to supply an appropriate Allwmake file. +# The derived package is expected to supply an appropriate +# or file. [ -d "$FOAM_PROJECT_DIR" -a -f "$FOAM_PROJECT_DIR/etc/bashrc" ] || { echo "Error: no PROJECT=$FOAM_PROJECT_DIR" 1>&2 @@ -22,5 +23,12 @@ echo " $WM_COMPILER $WM_COMPILER_TYPE compiler" echo " $WM_OPTIONS - with $WM_MPLIB $FOAM_MPI" echo -./Allwmake $@ # Pass arguments +# Prefer spack-specific Allwmake if it exists +if [ -f Allwmake-spack ] +then + ./Allwmake-spack $@ # Pass arguments +else + ./Allwmake $@ # Pass arguments +fi + # ----------------------------------------------------------------------------- diff --git a/var/spack/repos/builtin/packages/openfoam-com/package.py b/var/spack/repos/builtin/packages/openfoam-com/package.py index a8d7598e0e..1a05a40380 100644 --- a/var/spack/repos/builtin/packages/openfoam-com/package.py +++ b/var/spack/repos/builtin/packages/openfoam-com/package.py @@ -281,6 +281,7 @@ class OpenfoamCom(Package): list_url = "https://sourceforge.net/projects/openfoamplus/files/" list_depth = 2 + version('1806', 'bb244a3bde7048a03edfccffc46c763f') version('1712', '6ad92df051f4d52c7d0ec34f4b8eb3bc') version('1706', '630d30770f7b54d6809efbf94b7d7c8f') version('1612', 'ca02c491369150ab127cbb88ec60fbdf') @@ -303,8 +304,10 @@ class OpenfoamCom(Package): # TODO?# variant('scalasca', default=False, # TODO?# description='With scalasca profiling') variant('mgridgen', default=False, description='With mgridgen support') - variant('paraview', default=True, + variant('paraview', default=False, description='Build paraview plugins and runtime post-processing') + variant('vtk', default=False, + description='With VTK runTimePostProcessing') variant('source', default=True, description='Install library/application sources and tutorials') @@ -319,7 +322,9 @@ class OpenfoamCom(Package): depends_on('fftw') depends_on('boost') depends_on('cgal') - depends_on('flex', type='build') + # The flex restriction is ONLY to deal with a spec resolution clash + # introduced by the restriction within scotch! + depends_on('flex@:2.6.1,2.6.4:', type='build') depends_on('cmake', type='build') # Require scotch with ptscotch - corresponds to standard OpenFOAM setup @@ -331,6 +336,8 @@ class OpenfoamCom(Package): # mgridgen is statically linked depends_on('parmgridgen', when='+mgridgen', type='build') depends_on('zoltan', when='+zoltan') + depends_on('vtk', when='+vtk') + # TODO?# depends_on('scalasca', when='+scalasca') # For OpenFOAM plugins and run-time post-processing this should just be @@ -568,6 +575,7 @@ class OpenfoamCom(Package): 'ensight': {}, # Disable settings 'paraview': [], 'gperftools': [], # Currently unused + 'vtk': [], } if '+scotch' in spec: @@ -596,6 +604,13 @@ class OpenfoamCom(Package): ('PATH', foamAddPath('${ParaView_DIR}/bin')), ] + if '+vtk' in spec: + self.etc_config['vtk'] = [ + ('VTK_DIR', spec['vtk'].prefix), + ('LD_LIBRARY_PATH', + foamAddLib(pkglib(spec['vtk'], '${VTK_DIR}'))), + ] + # Optional if '+mgridgen' in spec: self.etc_config['mgridgen'] = { diff --git a/var/spack/repos/builtin/packages/openfoam-org/assets/bin/foamEtcFile b/var/spack/repos/builtin/packages/openfoam-org/assets/bin/foamEtcFile index e61279b591..195b91bdbe 100755 --- a/var/spack/repos/builtin/packages/openfoam-org/assets/bin/foamEtcFile +++ b/var/spack/repos/builtin/packages/openfoam-org/assets/bin/foamEtcFile @@ -4,7 +4,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation -# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. +# \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. #------------------------------------------------------------------------------- # License # This file is part of OpenFOAM, licensed under GNU General Public License @@ -46,7 +46,7 @@ printHelp() { cat<&2 # done - -# Save the essential bits of information -# silently remove leading ~OpenFOAM/ (used in Foam::findEtcFile) -nArgs=$# -fileName="${1#~OpenFOAM/}" - # Define the various places to be searched: unset dirList case "$optMode" in (*u*) # (U)ser @@ -309,27 +335,61 @@ case "$optMode" in (*o*) # (O)ther == shipped esac set -- $dirList +[ "$#" -ge 1 ] || die "No directories to scan. Programming error?" +exitCode=2 # Fallback is a FileNotFound error + + +# +# Preliminaries +# + +# Special handling of config.sh/ , config.csh/ directories +if [ -n "$optConfig" -a -n "$shellOutput" -a -n "$fileName" ] +then + case "$shellOutput" in + csh*) + optConfig="config.csh/" + ;; + sh*) + optConfig="config.sh/" + ;; + *) + unset optConfig + ;; + esac + + if [ -n "$optConfig" ] + then + case "$fileName" in + /* | config.csh* | config.sh*) + # Does not need or cannot add a prefix + unset optConfig + ;; + *) + fileName="$optConfig$fileName" + ;; + esac + fi +fi + # # The main routine # -exitCode=0 if [ -n "$optList" ] then # List directories, or potential file locations [ "$nArgs" -le 1 ] || \ - die "-list expects 0 or 1 filename, but $nArgs provided" + die "-list options expect 0 or 1 filename, but $nArgs provided" - # A silly combination, but -quiet does have precedence + # A silly combination, but -quiet has absolute precedence [ -n "$optQuiet" ] && exit 0 # Test for directory or file too? if [ "$optList" = "test" ] then - exitCode=2 # Fallback to a general error (file not found) - if [ "$nArgs" -eq 1 ] then for dir @@ -352,6 +412,7 @@ then done fi else + exitCode=0 # OK, already verified that $# != 0 for dir do echo "$dir${fileName:+/}$fileName" @@ -362,35 +423,44 @@ else [ "$nArgs" -eq 1 ] || die "One filename expected - $nArgs provided" - exitCode=2 # Fallback to a general error (file not found) + # Output for sourcing files ("source" for csh, "." for POSIX shell) + # Only allow sourcing a single file (disallow combination with -all) + case "$shellOutput" in + csh*) + shellOutput="source " # eg, "source FILE" + ;; + sh*) + shellOutput=". " # eg, ". FILE" + ;; + esac + + # Anti-pattern: -all disables shell commands + if [ -n "$optAll" ] + then + unset shellOutput verboseOutput + fi for dir do - if [ -f "$dir/$fileName" ] + resolved="$dir/$fileName" + if [ -f "$resolved" ] then - exitCode=0 - [ -n "$optQuiet" ] && break - - case "$optShell" in - (*verbose) - echo "Using: $dir/$fileName" 1>&2 - ;; - esac - - case "$optShell" in - csh*) - echo "source $dir/$fileName" - break - ;; - sh*) - echo ". $dir/$fileName" + exitCode=0 # OK + if [ -n "$optQuiet" ] + then break - ;; - *) - echo "$dir/$fileName" - [ -n "$optAll" ] || break - ;; - esac + elif [ -n "$verboseOutput" ] + then + echo "$verboseOutput$resolved" 1>&2 + fi + + if [ -n "$shellOutput" ] + then + echo "$shellOutput$resolved $evalArgs" + else + echo "$resolved" + fi + [ -n "$optAll" ] || break fi done -- cgit v1.2.3-70-g09d2