2013-07-05 15:50:12 +00:00
|
|
|
#!/bin/bash
|
2010-05-12 13:27:55 +00:00
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
# ========= |
|
2013-12-11 16:09:41 +00:00
|
|
|
# \\ / F ield | foam-extend: Open Source CFD
|
2018-05-29 07:35:20 +00:00
|
|
|
# \\ / O peration | Version: 4.1
|
2016-06-20 15:00:40 +00:00
|
|
|
# \\ / A nd | Web: http://www.foam-extend.org
|
|
|
|
# \\/ M anipulation | For copyright notice see file Copyright
|
2011-01-13 17:21:49 +00:00
|
|
|
#------------------------------------------------------------------------------
|
2010-05-12 13:27:55 +00:00
|
|
|
# License
|
2013-12-11 16:09:41 +00:00
|
|
|
# This file is part of foam-extend.
|
2010-05-12 13:27:55 +00:00
|
|
|
#
|
2013-12-11 16:09:41 +00:00
|
|
|
# foam-extend is free software: you can redistribute it and/or modify it
|
2010-05-12 13:27:55 +00:00
|
|
|
# under the terms of the GNU General Public License as published by the
|
2013-12-11 16:09:41 +00:00
|
|
|
# Free Software Foundation, either version 3 of the License, or (at your
|
2010-05-12 13:27:55 +00:00
|
|
|
# option) any later version.
|
|
|
|
#
|
2013-12-11 16:09:41 +00:00
|
|
|
# foam-extend 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.
|
2010-05-12 13:27:55 +00:00
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2013-12-11 16:09:41 +00:00
|
|
|
# along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
2010-05-12 13:27:55 +00:00
|
|
|
#
|
|
|
|
# Script
|
|
|
|
# paraFoam
|
|
|
|
#
|
|
|
|
# Description
|
|
|
|
# start paraview with the OpenFOAM libraries
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
usage() {
|
2010-05-27 10:48:11 +00:00
|
|
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
|
|
|
cat<<USAGE
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-05-27 10:48:11 +00:00
|
|
|
usage: ${0##*/} [OPTION]
|
|
|
|
options:
|
|
|
|
-case dir specify alternative case directory
|
|
|
|
-region name specify mesh region name
|
2013-07-05 15:50:12 +00:00
|
|
|
-touch only create the .OpenFOAM or .foam file
|
|
|
|
-nativeReader use the paraview native reader for OpenFOAM
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
* start paraview $ParaView_VERSION with the OpenFOAM libraries
|
|
|
|
|
|
|
|
USAGE
|
2010-05-27 10:48:11 +00:00
|
|
|
exit 1
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
|
2013-07-05 15:50:12 +00:00
|
|
|
unset regionName touchOnly useNativeReader
|
2010-05-27 10:48:11 +00:00
|
|
|
|
2015-09-05 11:07:11 +00:00
|
|
|
# This is needed for systems that are using comma as the decimal separator
|
|
|
|
export LC_NUMERIC=C
|
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
# parse options
|
2010-05-27 10:48:11 +00:00
|
|
|
while [ "$#" -gt 0 ]
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
-h | -help)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
-case)
|
|
|
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
|
|
|
cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
-region)
|
|
|
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
|
|
|
regionName=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
-touch)
|
|
|
|
touchOnly=true
|
|
|
|
shift
|
|
|
|
;;
|
2013-07-05 15:50:12 +00:00
|
|
|
-nativeReader)
|
|
|
|
useNativeReader=true
|
|
|
|
shift
|
|
|
|
;;
|
2010-05-27 10:48:11 +00:00
|
|
|
*)
|
|
|
|
usage "unknown option/argument: '$*'"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
# get a sensible caseName
|
|
|
|
caseName=${PWD##*/}
|
2013-07-05 15:50:12 +00:00
|
|
|
|
|
|
|
if [ -n "$useNativeReader" ]
|
|
|
|
then
|
2013-07-05 17:01:32 +00:00
|
|
|
caseFileExt=".foam"
|
2013-07-05 15:50:12 +00:00
|
|
|
else
|
2013-07-05 17:01:32 +00:00
|
|
|
caseFileExt=".OpenFOAM"
|
2013-07-05 15:50:12 +00:00
|
|
|
fi
|
|
|
|
|
2013-07-05 17:01:32 +00:00
|
|
|
caseFile="$caseName$caseFileExt"
|
|
|
|
|
2010-05-27 10:48:11 +00:00
|
|
|
fvControls="system"
|
|
|
|
|
|
|
|
if [ -n "$regionName" ]
|
|
|
|
then
|
2013-07-05 17:01:32 +00:00
|
|
|
caseFile="$caseName{$regionName}$caseFileExt"
|
2010-05-27 10:48:11 +00:00
|
|
|
fvControls="$fvControls/$regionName"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$touchOnly" ]
|
|
|
|
then
|
|
|
|
touch "$caseFile"
|
|
|
|
echo "created '$caseFile'"
|
|
|
|
exit 0
|
|
|
|
fi
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
# parent directory for normal or parallel results
|
|
|
|
case "$caseName" in
|
2010-05-27 10:48:11 +00:00
|
|
|
processor*) parentDir=".." ;;
|
|
|
|
*) parentDir="." ;;
|
2010-05-12 13:27:55 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
# check existence of essential files
|
2010-05-27 10:48:11 +00:00
|
|
|
for check in system/controlDict $fvControls/fvSchemes $fvControls/fvSolution
|
2010-05-12 13:27:55 +00:00
|
|
|
do
|
2010-05-27 10:48:11 +00:00
|
|
|
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
|
2010-05-12 13:27:55 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
case "$ParaView_VERSION" in
|
|
|
|
2*)
|
2010-05-27 10:48:11 +00:00
|
|
|
trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT
|
|
|
|
touch "$caseFile"
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-05-27 10:48:11 +00:00
|
|
|
# since we are now in the cwd, %CASE% is '$PWD/$caseFile'
|
|
|
|
sed -e s@%CASE%@$PWD/$caseFile@g \
|
|
|
|
$WM_PROJECT_DIR/bin/tools/paraFoam.pvs > paraFoam.pvs
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-05-27 10:48:11 +00:00
|
|
|
paraview paraFoam.pvs
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
*)
|
2010-05-27 10:48:11 +00:00
|
|
|
# only create/remove caseFile if it didn't already exist
|
|
|
|
[ -e $caseFile ] || {
|
|
|
|
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
|
|
|
|
touch "$caseFile"
|
|
|
|
echo "created temporary '$caseFile'"
|
|
|
|
}
|
|
|
|
|
|
|
|
paraview --data="$caseFile"
|
|
|
|
;;
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
esac
|
|
|
|
#------------------------------------------------------------------------------
|