STYLE: adjust shell syntax and usage output for paraFoam

- have -help-full as the last entry in the list of options.
  This permits some optimizations when generating shell completions.
This commit is contained in:
Mark Olesen 2018-11-21 09:44:00 +01:00
parent 253dd183f9
commit 481e83f007
2 changed files with 30 additions and 26 deletions

View File

@ -4,7 +4,7 @@
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. # \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, licensed under GNU General Public License # This file is part of OpenFOAM, licensed under GNU General Public License
@ -26,21 +26,25 @@ printHelp() {
Usage: ${0##*/} [OPTION] [--] [PARAVIEW_OPTION] Usage: ${0##*/} [OPTION] [--] [PARAVIEW_OPTION]
options: options:
-block use blockMesh reader (uses .blockMesh extension) -block Use blockMesh reader (.blockMesh extension)
-case <dir> specify alternative case directory, default is the cwd -case <dir> Specify alternative case directory, default is the cwd
-region <name> specify alternative mesh region -region <name> Specify alternative mesh region
-touch create the file (eg, .blockMesh, .OpenFOAM, .foam, ...) -touch Create the file (eg, .blockMesh, .OpenFOAM, .foam, ...)
-touch-all | -touchAll -touch-all Create .blockMesh, .foam, .OpenFOAM files (for all regions)
create .blockMesh, .foam, .OpenFOAM files (for all regions) -touch-proc Same as '-touch' but for each processor
-touch-proc same as '-touch' but for each processor -vtk Use VTK builtin OpenFOAM reader (.foam extension)
-vtk | -builtin use VTK builtin OpenFOAM reader (uses .foam extension) --help Display ParaView help
-help |-help-full print the usage -help Display short help and exit
--help paraview help -help-full Display full help and exit
Start paraview with the OpenFOAM libraries and reader modules. Start paraview with the OpenFOAM libraries and reader modules.
Note that paraview options begin with double dashes. Note that paraview options begin with double dashes.
paraview=$(command -v paraview) Uses paraview=$(command -v paraview)
Equivalent options:
-touch-all -touchAll
-vtk -builtin
USAGE USAGE
exit 0 # A clean exit exit 0 # A clean exit
@ -135,7 +139,7 @@ do
done done
# If a reader module is needed, check that it exists # If a reader module is needed, check that it exists
[ -z "$plugin" -o -f $PV_PLUGIN_PATH/lib${plugin}_SM.so ] || { [ -z "$plugin" ] || [ -f "$PV_PLUGIN_PATH/lib${plugin}_SM.so" ] || {
cat<< BUILDREADER 1>&2 cat<< BUILDREADER 1>&2
ERROR: ParaView reader module library ($plugin) does not exist ERROR: ParaView reader module library ($plugin) does not exist
@ -174,7 +178,7 @@ hasDataArg()
done done
} }
hasDataArg $@ hasDataArg "$@"
# Get a sensible caseName from the directory name # Get a sensible caseName from the directory name
@ -184,7 +188,7 @@ fvControls="system"
if [ -n "$regionName" ] if [ -n "$regionName" ]
then then
[ -d constant/$regionName ] || { [ -d "constant/$regionName" ] || {
echo "FATAL ERROR: Region $regionName does not exist" 1>&2 echo "FATAL ERROR: Region $regionName does not exist" 1>&2
exit 1 exit 1
} }
@ -195,7 +199,7 @@ fi
case "${optTouch:-false}" in case "${optTouch:-false}" in
all) all)
extension=OpenFOAM extension=OpenFOAM
if [ -f system/blockMeshDict -o -f constant/polyMesh/blockMeshDict ] if [ -f system/blockMeshDict ] || [ -f constant/polyMesh/blockMeshDict ]
then then
touch "$caseName.blockMesh" touch "$caseName.blockMesh"
echo "Created '$caseName.blockMesh'" 1>&2 echo "Created '$caseName.blockMesh'" 1>&2
@ -205,7 +209,7 @@ all)
# Discover probable regions # Discover probable regions
for region in constant/* for region in constant/*
do do
if [ -d $region -a -d $region/polyMesh ] if [ -d "$region" ] && [ -d "$region/polyMesh" ]
then then
regionName=${region##*/} regionName=${region##*/}
touch "$caseName{$regionName}.$extension" touch "$caseName{$regionName}.$extension"
@ -218,7 +222,7 @@ processor)
for i in processor* for i in processor*
do do
( (
cd $i 2> /dev/null && touch "${caseFile%.*}#${i#processor}.$extension" cd "$i" 2> /dev/null && touch "${caseFile%.*}#${i#processor}.$extension"
) )
done done
echo "Created '$caseFile' for processor directories" 1>&2 echo "Created '$caseFile' for processor directories" 1>&2
@ -244,7 +248,7 @@ hasFiles() {
if [ -s "$file" ] if [ -s "$file" ]
then then
continue continue
elif [ -n "$parent" -a -s "$parent$file" ] elif [ -n "$parent" ] && [ -s "$parent$file" ]
then then
continue continue
else else
@ -282,7 +286,7 @@ else
# Check existence of essential files # Check existence of essential files
warn=false warn=false
case $extension in case "$extension" in
blockMesh) blockMesh)
blockMeshDict=system/blockMeshDict blockMeshDict=system/blockMeshDict
if [ -f constant/polyMesh/blockMeshDict ] if [ -f constant/polyMesh/blockMeshDict ]
@ -290,14 +294,14 @@ else
blockMeshDict=constant/polyMesh/blockMeshDict blockMeshDict=constant/polyMesh/blockMeshDict
fi fi
hasFiles system/controlDict $blockMeshDict || warn=true hasFiles system/controlDict "$blockMeshDict" || warn=true
;; ;;
OpenFOAM) OpenFOAM)
hasFiles \ hasFiles \
system/controlDict \ system/controlDict \
$fvControls/fvSchemes \ "$fvControls/fvSchemes" \
$fvControls/fvSolution || warn=true "$fvControls/fvSolution" || warn=true
;; ;;
esac esac
@ -309,7 +313,7 @@ else
} }
# Only create/remove caseFile if it didn't already exist # Only create/remove caseFile if it didn't already exist
[ -e $caseFile ] || { [ -e "$caseFile" ] || {
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch "$caseFile" touch "$caseFile"
echo "Created temporary '$caseFile'" 1>&2 echo "Created temporary '$caseFile'" 1>&2
@ -317,7 +321,7 @@ else
# For now filter out any ld.so errors. Caused by non-system compiler? # For now filter out any ld.so errors. Caused by non-system compiler?
paraview --data="$caseFile" "$@" 2>&1 \ paraview --data="$caseFile" "$@" 2>&1 \
| fgrep -v 'Inconsistency detected by ld.so' | grep -F -v 'Inconsistency detected'
fi fi

View File

@ -289,6 +289,6 @@ _of_complete_cache_[XiDyMFoam]="-case -decomposeParDict -fileHandler -hostRoots
_of_complete_cache_[XiEngineFoam]="-case -decomposeParDict -fileHandler -hostRoots -listScalarBCs -listVectorBCs -roots | -listFunctionObjects -listFvOptions -listRegisteredSwitches -listSwitches -listTurbulenceModels -listUnsetSwitches -noFunctionObjects -parallel -postProcess -doc -doc-source -help" _of_complete_cache_[XiEngineFoam]="-case -decomposeParDict -fileHandler -hostRoots -listScalarBCs -listVectorBCs -roots | -listFunctionObjects -listFvOptions -listRegisteredSwitches -listSwitches -listTurbulenceModels -listUnsetSwitches -noFunctionObjects -parallel -postProcess -doc -doc-source -help"
_of_complete_cache_[XiFoam]="-case -decomposeParDict -fileHandler -hostRoots -listScalarBCs -listVectorBCs -roots | -dry-run -dry-run-write -listFunctionObjects -listFvOptions -listRegisteredSwitches -listSwitches -listTurbulenceModels -listUnsetSwitches -noFunctionObjects -parallel -postProcess -doc -doc-source -help" _of_complete_cache_[XiFoam]="-case -decomposeParDict -fileHandler -hostRoots -listScalarBCs -listVectorBCs -roots | -dry-run -dry-run-write -listFunctionObjects -listFvOptions -listRegisteredSwitches -listSwitches -listTurbulenceModels -listUnsetSwitches -noFunctionObjects -parallel -postProcess -doc -doc-source -help"
_of_complete_cache_[zipUpMesh]="-case -decomposeParDict -fileHandler -hostRoots -region -roots | -listFunctionObjects -listRegisteredSwitches -listSwitches -listUnsetSwitches -noFunctionObjects -parallel -doc -doc-source -help" _of_complete_cache_[zipUpMesh]="-case -decomposeParDict -fileHandler -hostRoots -region -roots | -listFunctionObjects -listRegisteredSwitches -listSwitches -listUnsetSwitches -noFunctionObjects -parallel -doc -doc-source -help"
_of_complete_cache_[paraFoam]="-case -region | -block -touch -touch-all -touch-proc -vtk" _of_complete_cache_[paraFoam]="-case -region | -block -touch -touch-all -touch-proc -vtk -help"
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------