Commit 628b2445 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: improve setup for paraview

- removed reliance on ParaView_INCLUDE_DIR variable for conveying the
  major.minor version information when compiling. This can be somewhat
  fragile and also adds variable that is an unnecessary when running
  (only used when compiling).

  Instead use `have_pvplugin_support` function in paraviewFunctions
  wmake script to determine the maj.min from the PV_PLUGIN_PATH
  since we have already defined the output path there with paraview
  maj.min numbering.

  Can now build with paraview from the operating system,
  provided that it has develop headers available.

      ParaView_VERSION=system

  In the etc/config.sh/paraview setup, the maj.min is taken from
  the corresponding `paraview --version` output and used when
  defining the PV_PLUGIN_PATH.

  During the build, the include path taken from `paraview-config`
  for a system installation, from the guess installation root
  of the paraview binary, or ParaView_DIR otherwise.

NB: using a system ParaView for building runTimePostProcessing is unsupported.

- these types of builds appear to have various library resolution issues
  (eg, libexpat not being loaded). Additionally, the build logic does
  not yet cover this type of use case.
parent e4b8fede
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions # Source wmake functions
# Source the wmake functions
. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions
# Cleanup OpenFOAM libraries
# Cleanup libraries
wclean libso foamPv
wclean libso vtkPVblockMesh
wclean libso vtkPVFoam
......
......@@ -2,7 +2,7 @@
cd ${0%/*} || exit 1 # Run from this directory
export WM_CONTINUE_ON_ERROR=true # Optional unit
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions # The CMake functions
. $WM_PROJECT_DIR/wmake/scripts/paraviewFunctions # CMake and PV functions
# -----------------------------------------------------------------------------
......@@ -13,31 +13,19 @@ warnIncomplete()
echo
}
# major version as per paraview include directory:
# Eg, "PREFIX/include/paraview-5.0" -> "5.0"
major="${ParaView_INCLUDE_DIR##*-}"
if have_pvplugin_support
then
(
wmakeLibPv foamPv
wmakeLibPv vtkPVblockMesh
wmakeLibPv vtkPVFoam
case "$major" in
[45].[0-9]*)
if canBuildPlugin
if [ "$targetType" != objects ]
then
(
wmakeLibPv foamPv
wmakeLibPv vtkPVblockMesh
wmakeLibPv vtkPVFoam
if [ "$targetType" != objects ]
then
cmakePv $PWD/PVblockMeshReader || warnIncomplete "BlockMesh"
cmakePv $PWD/PVFoamReader || warnIncomplete "OpenFOAM"
fi
)
cmakePv $PWD/PVblockMeshReader || warnIncomplete "BlockMesh"
cmakePv $PWD/PVFoamReader || warnIncomplete "OpenFOAM"
fi
;;
*)
echo "==> skip build of ParaView plugins"
echo " include directory was for paraview major version '${major:-none}'"
;;
esac
)
fi
#------------------------------------------------------------------------------
......@@ -26,7 +26,7 @@ set(OPENFOAM_LIBRARIES
# Set output library destination to plugin directory
set(
LIBRARY_OUTPUT_PATH $ENV{PV_PLUGIN_PATH}
LIBRARY_OUTPUT_PATH $ENV{FOAM_PV_PLUGIN_LIBBIN}
CACHE INTERNAL
"Single output directory for building all libraries."
)
......
......@@ -20,7 +20,7 @@ set(OPENFOAM_LIBRARIES
# Set output library destination to plugin directory
set(
LIBRARY_OUTPUT_PATH $ENV{PV_PLUGIN_PATH}
LIBRARY_OUTPUT_PATH $ENV{FOAM_PV_PLUGIN_LIBBIN}
CACHE INTERNAL
"Single output directory for building all libraries."
)
......
sinclude $(GENERAL_RULES)/paraview
EXE_INC = \
${c++LESSWARN} \
-I$(LIB_SRC)/conversion/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(ParaView_INCLUDE_DIR) \
-I$(ParaView_INCLUDE_DIR)/vtkkwiml
-I$(PARAVIEW_INC_DIR) \
-I$(PARAVIEW_INC_DIR)/vtkkwiml
LIB_LIBS = \
$(GLIBS)
sinclude $(GENERAL_RULES)/paraview
EXE_INC = \
${c++LESSWARN} \
-I$(LIB_SRC)/meshTools/lnInclude \
......@@ -9,8 +7,8 @@ EXE_INC = \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude \
-I$(ParaView_INCLUDE_DIR) \
-I$(ParaView_INCLUDE_DIR)/vtkkwiml \
-I$(PARAVIEW_INC_DIR) \
-I$(PARAVIEW_INC_DIR)/vtkkwiml \
-I../foamPv \
-I../PVFoamReader
......@@ -20,5 +18,5 @@ LIB_LIBS = \
-lconversion \
-lgenericPatchFields \
-llagrangian \
-L$(FOAM_LIBBIN) -lfoamPv-pv${ParaView_MAJOR} \
-L$(FOAM_LIBBIN) -lfoamPv-pv$(PARAVIEW_MAJMIN) \
$(GLIBS)
sinclude $(GENERAL_RULES)/paraview
EXE_INC = \
${c++LESSWARN} \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/mesh/blockMesh/lnInclude \
-I$(ParaView_INCLUDE_DIR) \
-I$(ParaView_INCLUDE_DIR)/vtkkwiml \
-I$(PARAVIEW_INC_DIR) \
-I$(PARAVIEW_INC_DIR)/vtkkwiml \
-I../foamPv \
-I../PVblockMeshReader
LIB_LIBS = \
-lmeshTools \
-lblockMesh \
-L$(FOAM_LIBBIN) -lfoamPv-pv${ParaView_MAJOR} \
-L$(FOAM_LIBBIN) -lfoamPv-pv$(PARAVIEW_MAJMIN) \
$(GLIBS)
......@@ -88,37 +88,32 @@ do
-block*)
extension=blockMesh
plugin=PVblockMeshReader
shift
;;
-vtk | -built*)
extension=foam
unset plugin
shift
;;
-case)
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
cd "$2" 2>/dev/null || die "directory does not exist: '$2'"
shift 2
shift
;;
-region)
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
regionName=$2
shift 2
shift
;;
-touch)
optTouch=true
unset plugin
shift
;;
-touch-all | -touchAll)
optTouch=all
unset plugin
shift
;;
-touch-proc*)
optTouch=processor
unset plugin
shift
;;
--)
shift
......@@ -130,59 +125,65 @@ do
exit 1 # This should not have happened
;;
--*)
break # Stop here, treat this and balance as paraview options
break # Stop here, treat _this_ and balance as paraview options
;;
*)
die "unknown option/argument: '$1'"
die "Unknown option/argument: '$1'"
;;
esac
shift
done
# If a reader module is needed, check that it exists
[ -z "$plugin" ] || [ -f "$PV_PLUGIN_PATH/lib${plugin}_SM.so" ] || {
cat<< BUILDREADER 1>&2
ERROR: ParaView reader module library ($plugin) does not exist
Please build the reader module before continuing:
if [ -n "$plugin" ]
then
pluginError="Cannot use ParaView reader module library ($plugin)"
# Check if requested reader module exists
if [ -z "$PV_PLUGIN_PATH" ]
then
echo "$pluginError" 1>&2
echo "The PV_PLUGIN_PATH environment value is not set" 1>&2
elif [ -f "$PV_PLUGIN_PATH/lib${plugin}_SM.so" ]
then
unset pluginError
else
echo "$pluginError - not built?" 1>&2
cat<< NO_PLUGIN 1>&2
Consider building the reader module
cd \$WM_PROJECT_DIR/applications/utilities/postProcessing/graphics/PVReaders
./Allwclean
./Allwmake
NO_PLUGIN
fi
BUILDREADER
# Fallback to native reader, if possible
if [ "$extension" = OpenFOAM ]
if [ -n "$pluginError" ]
then
extension=foam
echo "Using the native VTK/OpenFOAM reader instead" 1>&2
else
exit 1
# Fallback to native reader, if possible
if [ "$plugin" = PVFoamReader ]
then
echo 1>&2
echo "Continuing with builtin reader: paraFoam -vtk" 1>&2
echo 1>&2
extension=foam
else
echo 1>&2
exit 1
fi
unset plugin
fi
}
fi
# Check for --data=... argument
hasDataArg()
{
hasData=false
while [ "$#" -gt 0 ]
do
case "$1" in
(--data=*)
hasData=true
break
;;
esac
shift
done
}
hasDataArg "$@"
unset hasData
for i
do
case "$i" in (--data=*) hasData=true; break;; esac
done
# Get a sensible caseName from the directory name
caseName=${PWD##*/}
caseName="${PWD##*/}"
caseFile="$caseName.$extension"
fvControls="system"
......@@ -211,14 +212,14 @@ all)
do
if [ -d "$region" ] && [ -d "$region/polyMesh" ]
then
regionName=${region##*/}
regionName="${region##*/}"
touch "$caseName{$regionName}.$extension"
echo "Created '$caseName{$regionName}.$extension'" 1>&2
fi
done
exit 0
;;
processor)
proc*)
for i in processor*
do
(
......@@ -286,8 +287,8 @@ else
# Check existence of essential files
warn=false
case "$extension" in
blockMesh)
case "$plugin" in
PVblockMeshReader)
blockMeshDict=system/blockMeshDict
if [ -f constant/polyMesh/blockMeshDict ]
then
......@@ -297,7 +298,7 @@ else
hasFiles system/controlDict "$blockMeshDict" || warn=true
;;
OpenFOAM)
PVFoamReader)
hasFiles \
system/controlDict \
"$fvControls/fvSchemes" \
......@@ -312,7 +313,7 @@ else
exit
}
# Only create/remove caseFile if it didn't already exist
# Only create/remove caseFile if it did not previously exist
[ -e "$caseFile" ] || {
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch "$caseFile"
......
......@@ -16,25 +16,30 @@
# Description
# Setup for PARAVIEW (partially cmake, qt too)
#
# For system-wide cmake: cmake_version=cmake-system
# For system-wide qt: ParaView_QT=qt-system
# To disable use of the PV_PLUGIN_PATH:
# ParaView_VERSION=none
#
# For system-wide installations:
# cmake_version=cmake-system
# ParaView_QT=qt-system
# ParaView_VERSION=system [EXPERIMENTAL]
#
# Note
# The following env. variables are required for building plugins:
# ParaView_DIR
# ParaView_INCLUDE_DIR
# PV_PLUGIN_PATH
# The OpenFOAM plugin must be the first in PV_PLUGIN_PATH and have
# paraview-major.minor version encoded in its name.
#
# For central installations not located under ThirdParty, the environment
# values must be set manually. For example,
#
# setenv ParaView_DIR /opt/paraview/paraview-5.5.0
# setenv ParaView_INCLUDE_DIR $ParaView_DIR/include/paraview-5.5
# setenv PV_PLUGIN_PATH $FOAM_LIBBIN/paraview-5.5
# setenv ParaView_DIR /opt/paraview/paraview-5.6.0
# setenv PV_PLUGIN_PATH $FOAM_LIBBIN/paraview-5.6
#
# setenv PATH $ParaView_DIR/bin:${PATH}
# setenv LD_LIBRARY_PATH $ParaView_DIR/lib:$LD_LIBRARY_PATH
# unsetenv ParaView_VERSION # avoid using ThirdParty settings
# unsetenv ParaView_VERSION # skip ThirdParty settings
#
# In paraview-5.4 and earlier, the libraries were in the sub-directory:
#
......@@ -43,8 +48,8 @@
#------------------------------------------------------------------------------
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
setenv ParaView_VERSION 5.6.0
set ParaView_QT=qt-system
set ParaView_VERSION=5.6.0
set ParaView_QT=qt-system
set cmake_version=cmake-system
# END OF (NORMAL) USER EDITABLE PART
......@@ -62,10 +67,10 @@ eval `$WM_PROJECT_DIR/bin/foamCleanPath -csh-env=PATH "$ParaView_DIR $archDir/Pa
eval `$WM_PROJECT_DIR/bin/foamCleanPath -csh-env=LD_LIBRARY_PATH "$ParaView_DIR $archDir/ParaView- $archDir/qt-"`
# ThirdParty cmake
set cmake=$archDir/$cmake_version
if ( -r $cmake/bin/cmake ) then
set cmake="$archDir/$cmake_version"
if ( -r "$cmake/bin/cmake" ) then
# _foamAddPath not available when foamPV alias is used
setenv PATH $cmake/bin:${PATH}
setenv PATH "$cmake/bin:${PATH}"
endif
# Evaluate command-line parameters for ParaView
......@@ -79,10 +84,47 @@ while ( $#argv > 0 )
shift
end
if (! $?ParaView_VERSION ) set ParaView_VERSION=''
switch ("$ParaView_VERSION")
case "":
# empty - do nothing
setenv ParaView_DIR # Defined but empty (used by foamPV alias)
breaksw
case "none":
unsetenv PV_PLUGIN_PATH
setenv ParaView_DIR # Defined but empty (used by foamPV alias)
if ($?FOAM_VERBOSE && $?prompt) then
echo "Using paraview (disabled)"
endif
breaksw
case "system":
# Obtain major.minor from `paraview --version`
set pv_api=`paraview --version | \
sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
if ( "${%pv_api}" ) then
setenv PV_PLUGIN_PATH "$FOAM_LIBBIN/paraview-$pv_api"
else
unsetenv ParaView_DIR PV_PLUGIN_PATH
endif
# Require that ParaView_VERSION has not been unset.
# Avoids conflict with an alternative (non-ThirdParty) installation.
if ( $?ParaView_VERSION ) then
if ($?FOAM_VERBOSE && $?prompt) then
echo "Using paraview (disabled)"
if ( $?PV_PLUGIN_PATH ) then
echo "Using paraview (system)"
echo " PV_PLUGIN_PATH : $PV_PLUGIN_PATH"
else
echo "system paraview (not found)"
endif
endif
breaksw
default:
# ParaView_VERSION set and non-empty
# Set API to correspond to VERSION
# pv_api is <digits>.<digits> from ParaView_VERSION
......@@ -94,20 +136,21 @@ if ( $?ParaView_VERSION ) then
case [0-9]*:
# Extract API from VERSION
set pv_api=`echo ${ParaView_VERSION} | \
sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
set pv_api=`echo "$ParaView_VERSION" | \
sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
breaksw
endsw
setenv ParaView_DIR $archDir/ParaView-$ParaView_VERSION
setenv ParaView_DIR "$archDir/ParaView-$ParaView_VERSION"
# Set paths if binaries are present
if ( -r $ParaView_DIR ) then
setenv PATH ${ParaView_DIR}/bin:${PATH}
setenv ParaView_INCLUDE_DIR $ParaView_DIR/include/paraview-$pv_api
setenv PV_PLUGIN_PATH $FOAM_LIBBIN/paraview-$pv_api
if ( -r "$ParaView_DIR" ) then
# The OpenFOAM plugin directory must be the first in PV_PLUGIN_PATH
# and have paraview-major.minor encoded in its name
setenv PV_PLUGIN_PATH "$FOAM_LIBBIN/paraview-$pv_api"
set pvLibDir=${ParaView_DIR}/lib/paraview-$pv_api
setenv PATH "${ParaView_DIR}/bin:${PATH}"
set pvLibDir="${ParaView_DIR}/lib/paraview-$pv_api"
#OBSOLETE? set pvPython=$ParaView_DIR/Utilities/VTKPythonWrapping
#OBSOLETE? # Python libraries as required
......@@ -115,7 +158,7 @@ if ( $?ParaView_VERSION ) then
#OBSOLETE? if ($?PYTHONPATH) then
#OBSOLETE? setenv PYTHONPATH ${PYTHONPATH}:${pvPython}:$pvLibDir
#OBSOLETE? else
#OBSOLETE? setenv PYTHONPATH ${pvPython}:$pvLibDir
#OBSOLETE? setenv PYTHONPATH ${pvPython}:${pvLibDir}
#OBSOLETE? endif
#OBSOLETE? endif
......@@ -125,9 +168,9 @@ if ( $?ParaView_VERSION ) then
set qtDir="$archDir/$ParaView_QT"
if ( -d "$qtDir" ) then
switch ($ParaView_QT)
switch ("$ParaView_QT")
case *-5*:
setenv Qt5_DIR $qtDir
setenv Qt5_DIR "$qtDir"
breaksw
endsw
foreach qtLibDir ("$qtDir/lib$WM_COMPILER_LIB_ARCH" "$qtDir/lib")
......@@ -143,17 +186,16 @@ if ( $?ParaView_VERSION ) then
# - 5.5 and later: lib/
switch ("$pv_api")
case 5.[0-4]*:
setenv LD_LIBRARY_PATH $pvLibDir:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH "${pvLibDir}:${LD_LIBRARY_PATH}"
breaksw
default:
setenv LD_LIBRARY_PATH ${ParaView_DIR}/lib:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH "${ParaView_DIR}/lib:${LD_LIBRARY_PATH}"
breaksw
endsw
if ($?FOAM_VERBOSE && $?prompt) then
echo "Using paraview"
echo " ParaView_DIR : $ParaView_DIR"
echo " ParaView_INCLUDE_DIR : $ParaView_INCLUDE_DIR"
echo " library dir : $pvLibDir"
echo " PV_PLUGIN_PATH : $PV_PLUGIN_PATH"
endif
......@@ -163,11 +205,12 @@ if ( $?ParaView_VERSION ) then
echo " ParaView_DIR : $ParaView_DIR"
endif
unsetenv ParaView_INCLUDE_DIR PV_PLUGIN_PATH
unsetenv PV_PLUGIN_PATH
setenv ParaView_DIR # Defined but empty (used by foamPV alias)
endif
breaksw
endif
endsw
unset cleaned archDir
unset cmake cmake_version
......
......@@ -16,25 +16,30 @@
# Description
# Setup for PARAVIEW (partially cmake, qt too)
#
# For system-wide cmake: cmake_version=cmake-system
# For system-wide qt: ParaView_QT=qt-system
# To disable use of the PV_PLUGIN_PATH:
# ParaView_VERSION=none
#
# For system-wide installations:
# cmake_version=cmake-system
# ParaView_QT=qt-system
# ParaView_VERSION=system [EXPERIMENTAL]
#
# Note
# The following env. variables are required for building plugins:
# ParaView_DIR
# ParaView_INCLUDE_DIR
# PV_PLUGIN_PATH
# The OpenFOAM plugin must be the first in PV_PLUGIN_PATH and have
# paraview-major.minor encoded in its name.
#
# For central installations not located under ThirdParty, the environment
# values must be set manually. For example,
#
# export ParaView_DIR=/opt/paraview/paraview-5.5.0
# export ParaView_INCLUDE_DIR=$ParaView_DIR/include/paraview-5.5
# export PV_PLUGIN_PATH=$FOAM_LIBBIN/paraview-5.5
# export ParaView_DIR=/opt/paraview/paraview-5.6.0
# export PV_PLUGIN_PATH=$FOAM_LIBBIN/paraview-5.6
#
# export PATH=$ParaView_DIR/bin:$PATH
# export LD_LIBRARY_PATH=$ParaView_DIR/lib:$LD_LIBRARY_PATH
# unset ParaView_VERSION # avoid using ThirdParty settings
# unset ParaView_VERSION # skip ThirdParty settings
#
# In paraview-5.4 and earlier, the libraries were in the sub-directory:
#
......@@ -75,52 +80,82 @@ then
fi
# Evaluate command-line parameters for ParaView
_foamParaviewEval()
{
while [ $# -gt 0 ]
do
case "$1" in
ParaView*=*)
# name=value -> export name=value
eval "export $1"
;;
esac
shift
done
}
for i
do
case "$i" in
(ParaView*=*)
# name=value -> export name=value
eval "export $i"
;;
esac
done
# Evaluate command-line parameters
_foamParaviewEval $@
case "$ParaView_VERSION" in
('')
# empty - do nothing
;;
# Require that ParaView_VERSION has not been unset.
# Avoids conflict with an alternative (non-ThirdParty) installation.
if [ -n "$ParaView_VERSION" ]
then
(none)
unset ParaView_DIR PV_PLUGIN_PATH
if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then
echo "Using paraview (disabled)" 1>&2
fi
;;
(system)
# Obtain major.minor from `paraview --version`
pv_api="$(paraview --version 2>/dev/null | \
sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p')"
if [ -n "$pv_api" ]
then
export PV_PLUGIN_PATH="$FOAM_LIBBIN/paraview-$pv_api"
else
unset ParaView_DIR PV_PLUGIN_PATH
fi
if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then
if [ -n "$PV_PLUGIN_PATH" ]
then
echo "Using paraview (system)" 1>&2
echo " PV_PLUGIN_PATH : $PV_PLUGIN_PATH" 1>&2
else
echo "system paraview (not found)" 1>&2
fi
fi
;;