openfoam/etc/config.sh/paraview
Mark Olesen dec8bd46c3 BUG: _foamAddPath not available when foamPV alias/function is used
STYLE: only use paraview settings when actually available

- this means executing makeParaView prior to building OpenFOAM itself,
  but is consistent with the instructions given by makeParaView,
  and elminates anticipating the source location from the paraview
  config file, which increases the build flexibilty for ThirdParty
2016-11-28 15:35:27 +01:00

174 lines
5.6 KiB
Bash

#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM 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.
#
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# File
# etc/config.sh/paraview
#
# Description
# Setup file for paraview (& cmake)
# Sourced from OpenFOAM-<VERSION>/etc/bashrc or from foamPV alias
#
# If using system-wide installation for cmake, use the following settings:
#
# cmake_version=cmake-system
#
# Note
# The following env. variables are required for building plugins:
# ParaView_DIR
# ParaView_INCLUDE_DIR
# PV_PLUGIN_PATH
#
# If using a central installation not located under ThirdParty, you will
# need to set some environment values directly. For example,
#
# export ParaView_DIR=/opt/paraview/paraview-5.2.0
# export ParaView_INCLUDE_DIR=$ParaView_DIR/include/paraview-5.2
# export PV_PLUGIN_PATH=$FOAM_LIBBIN/paraview-5.2
#
# export PATH=$ParaView_DIR/bin:$PATH
# export LD_LIBRARY_PATH=$ParaView_DIR/lib/paraview-5.2:$LD_LIBRARY_PATH
# unset ParaView_VERSION # avoid using ThirdParty settings
#
# Note
# When _foamAddLib is unset (eg, called from makeParaView or from foamPV):
# - the ParaView_VERSION variable is retained.
#------------------------------------------------------------------------------
ParaView_VERSION=5.2.0
ParaView_MAJOR=detect # Automatically determine major version
cmake_version=cmake-system
#------------------------------------------------------------------------------
# Clean the PATH
cleaned=$($WM_PROJECT_DIR/bin/foamCleanPath "$PATH" \
"$ParaView_DIR \
$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/cmake- \
$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-" \
) \
&& PATH="$cleaned"
# ThirdParty cmake
cmake=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cmake_version
if [ -r $cmake/bin/cmake ]
then
# _foamAddPath not available when foamPV function is used
PATH=$cmake/bin:$PATH
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
}
# Evaluate command-line parameters
_foamParaviewEval $@
# Require that ParaView_VERSION has not been unset.
# Avoids conflict with an alternative (non-ThirdParty) installation.
if [ -n "$ParaView_VERSION" ]
then
# Set MAJOR version to correspond to VERSION
# ParaView_MAJOR is "<digits>.<digits>" from ParaView_VERSION
case "$ParaView_VERSION" in
"$ParaView_MAJOR".* )
# Version and major appear to correspond
;;
[0-9]*)
# Extract major from the version
ParaView_MAJOR=$(echo $ParaView_VERSION | \
sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/')
;;
esac
pvName=ParaView-$ParaView_VERSION
pvMajor=paraview-$ParaView_MAJOR
export ParaView_DIR=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$pvName
# Set paths if binaries or source are present
if [ -r $ParaView_DIR ]
then
pvLibDir=$ParaView_DIR/lib/$pvMajor
pvPython=$ParaView_DIR/Utilities/VTKPythonWrapping
export PATH=$ParaView_DIR/bin:$PATH
export ParaView_INCLUDE_DIR=$ParaView_DIR/include/$pvMajor
export PV_PLUGIN_PATH=$FOAM_LIBBIN/$pvMajor
export LD_LIBRARY_PATH=$pvLibDir:$LD_LIBRARY_PATH
# Add in python libraries if required
if [ -r $pvPython ]
then
if [ "$PYTHONPATH" ]
then
export PYTHONPATH=$PYTHONPATH:$pvPython:$pvLibDir
else
export PYTHONPATH=$pvPython:$pvLibDir
fi
fi
if [ "$FOAM_VERBOSE" -a "$PS1" ]
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"
fi
else
if [ "$FOAM_VERBOSE" -a "$PS1" ]
then
echo "No paraview found"
echo " ParaView_DIR : $ParaView_DIR"
fi
unset ParaView_DIR ParaView_INCLUDE_DIR PV_PLUGIN_PATH
fi
fi
unset -f _foamParaviewEval
unset cleaned cmake cmake_version pvName pvMajor pvLibDir pvPython
unset ParaView_MAJOR
if type _foamAddLib > /dev/null 2>&1 # normal sourcing
then
unset ParaView_VERSION
fi
#------------------------------------------------------------------------------