openfoam/etc/config.sh/paraview
Mark Olesen 9e2259c19c STYLE: clean out clutter in paraview config files (issue #176)
Now reduced to 3 environment variables:
    ParaView_DIR         - paraview installation directory
    ParaView_INCLUDE_DIR - paraview include directory
    PV_PLUGIN_PATH       - paraview plugin directory for OpenFOAM modules

Previously also had (ParaView_MAJOR, ParaView_VERSION).

ThirdParty makeParaView adjusted accordingly.

ENH: improved configuration possibility for non-ThirdParty paraview
installation.

BUG: csh foamPV alias was completely incorrect.
2016-07-13 09:57:58 +02:00

163 lines
5.3 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.0.1
# export ParaView_INCLUDE_DIR=$ParaView_DIR/include/paraview-5.0
# export PV_PLUGIN_PATH=$FOAM_LIBBIN/paraview-5.0
#
# export PATH=$ParaView_DIR/bin:$PATH
# export LD_LIBRARY_PATH=$ParaView_DIR/lib/paraview-5.0:$LD_LIBRARY_PATH
# unset ParaView_VERSION # avoid using ThirdParty settings
#
#------------------------------------------------------------------------------
ParaView_VERSION=5.0.1
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"
# Environment for ThirdParty cmake
unset CMAKE_HOME
cmake=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cmake_version
if [ -r $cmake ]
then
export CMAKE_HOME=$cmake
export CMAKE_ROOT=$cmake
export PATH=$CMAKE_HOME/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
pvSrcDir=$WM_THIRD_PARTY_DIR/$pvName
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 -o -r $pvSrcDir ]
then
pvLibDir=$ParaView_DIR/lib/$pvMajor
pvPython=$ParaView_DIR/Utilities/VTKPythonWrapping
export ParaView_INCLUDE_DIR=$ParaView_DIR/include/$pvMajor
export PV_PLUGIN_PATH=$FOAM_LIBBIN/$pvMajor
export PATH=$ParaView_DIR/bin:$PATH
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
unset ParaView_DIR ParaView_INCLUDE_DIR PV_PLUGIN_PATH
fi
fi
unset -f _foamParaviewEval
unset cleaned cmake cmake_version pvName pvMajor pvSrcDir pvLibDir pvPython
unset ParaView_VERSION ParaView_MAJOR
#------------------------------------------------------------------------------