This repository has been archived on 2023-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
foam-extend4.1-coherent-io/bin/paraFoam

150 lines
3.9 KiB
Text
Raw Normal View History

#!/bin/bash
#------------------------------------------------------------------------------
# ========= |
2013-12-11 16:09:41 +00:00
# \\ / F ield | foam-extend: Open Source CFD
# \\ / 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
#------------------------------------------------------------------------------
# License
2013-12-11 16:09:41 +00:00
# This file is part of foam-extend.
#
2013-12-11 16:09:41 +00:00
# foam-extend is free software: you can redistribute it and/or modify it
# 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
# 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.
#
# 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/>.
#
# 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-27 10:48:11 +00:00
usage: ${0##*/} [OPTION]
options:
-case dir specify alternative case directory
-region name specify mesh region name
-touch only create the .OpenFOAM or .foam file
-nativeReader use the paraview native reader for OpenFOAM
* start paraview $ParaView_VERSION with the OpenFOAM libraries
USAGE
2010-05-27 10:48:11 +00:00
exit 1
}
unset regionName touchOnly useNativeReader
2010-05-27 10:48:11 +00:00
# This is needed for systems that are using comma as the decimal separator
export LC_NUMERIC=C
# 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
;;
-nativeReader)
useNativeReader=true
shift
;;
2010-05-27 10:48:11 +00:00
*)
usage "unknown option/argument: '$*'"
;;
esac
done
# get a sensible caseName
caseName=${PWD##*/}
if [ -n "$useNativeReader" ]
then
caseFileExt=".foam"
else
caseFileExt=".OpenFOAM"
fi
caseFile="$caseName$caseFileExt"
2010-05-27 10:48:11 +00:00
fvControls="system"
if [ -n "$regionName" ]
then
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
# parent directory for normal or parallel results
case "$caseName" in
2010-05-27 10:48:11 +00:00
processor*) parentDir=".." ;;
*) parentDir="." ;;
esac
# check existence of essential files
2010-05-27 10:48:11 +00:00
for check in system/controlDict $fvControls/fvSchemes $fvControls/fvSolution
do
2010-05-27 10:48:11 +00:00
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
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-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-27 10:48:11 +00:00
paraview paraFoam.pvs
;;
*)
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"
;;
esac
#------------------------------------------------------------------------------