mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add paraFoam -plugin-path=DIR option
- convenient way to use alternative plugin installations - provide separate -help-build information and reduce the noisy output when a reader module cannot be located.
This commit is contained in:
105
bin/paraFoam
105
bin/paraFoam
@ -21,21 +21,43 @@
|
|||||||
# Note
|
# Note
|
||||||
# Combining -block, -vtk, -builtin options with -region option yields
|
# Combining -block, -vtk, -builtin options with -region option yields
|
||||||
# undefined behaviour
|
# undefined behaviour
|
||||||
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
printBuildHelp() {
|
||||||
|
cat<<HELP_BUILD
|
||||||
|
Possible way to build supplementary ParaView/OpenFOAM reader modules
|
||||||
|
|
||||||
|
cd \$WM_PROJECT_DIR/modules/visualization/src/paraview-plugins
|
||||||
|
./Allwclean
|
||||||
|
./Allwmake
|
||||||
|
|
||||||
|
HELP_BUILD
|
||||||
|
}
|
||||||
|
|
||||||
printHelp() {
|
printHelp() {
|
||||||
# Print usage to stdout so that it can be captured for bash completion
|
cat<<HELP_HEAD
|
||||||
cat<<USAGE
|
|
||||||
|
|
||||||
Usage: ${0##*/} [OPTION] [--] [PARAVIEW_OPTION]
|
Usage: ${0##*/} [OPTION] [--] [PARAVIEW_OPTION]
|
||||||
options:
|
options:
|
||||||
-block Use blockMesh reader (.blockMesh extension)
|
-block Use blockMesh reader (.blockMesh extension)
|
||||||
|
-vtk Use VTK builtin OpenFOAM reader (.foam 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 Create .blockMesh, .foam, .OpenFOAM files (for all regions)
|
-touch-all Create .blockMesh, .foam, .OpenFOAM files (for all regions)
|
||||||
|
HELP_HEAD
|
||||||
|
|
||||||
|
if [ -n "$1" ]
|
||||||
|
then
|
||||||
|
cat<<HELP_FULL
|
||||||
-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)
|
-plugin-path=DIR Define plugin directory (default: \$PV_PLUGIN_PATH)
|
||||||
--help Display ParaView help
|
--help Display ParaView help
|
||||||
|
-help-build Display help for building reader module and exit
|
||||||
|
HELP_FULL
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat<<HELP_TAIL_COMMON
|
||||||
-help Display short help and exit
|
-help Display short help and exit
|
||||||
-help-full Display full help and exit
|
-help-full Display full help and exit
|
||||||
|
|
||||||
@ -44,11 +66,18 @@ Note that paraview options begin with double dashes.
|
|||||||
|
|
||||||
Uses paraview=$(command -v paraview)
|
Uses paraview=$(command -v paraview)
|
||||||
|
|
||||||
|
HELP_TAIL_COMMON
|
||||||
|
|
||||||
|
if [ -n "$1" ]
|
||||||
|
then
|
||||||
|
cat<<HELP_TAIL_FULL
|
||||||
Equivalent options:
|
Equivalent options:
|
||||||
-touch-all -touchAll
|
-touch-all -touchAll
|
||||||
-vtk -builtin
|
-vtk -builtin
|
||||||
|
|
||||||
USAGE
|
HELP_TAIL_FULL
|
||||||
|
fi
|
||||||
|
|
||||||
exit 0 # A clean exit
|
exit 0 # A clean exit
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,10 +113,38 @@ unset regionName optTouch
|
|||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h | -help*)
|
-help-b*) # Build help
|
||||||
|
printBuildHelp
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-help-f*) # Full help
|
||||||
|
printHelp -full
|
||||||
|
;;
|
||||||
|
-h | -help*) # Short help
|
||||||
printHelp
|
printHelp
|
||||||
;;
|
;;
|
||||||
-block*)
|
|
||||||
|
-plugin-path=*)
|
||||||
|
# Define alternative plugin directory
|
||||||
|
pluginPath="${1#*=}"
|
||||||
|
if [ -d "$pluginPath" ]
|
||||||
|
then
|
||||||
|
export PV_PLUGIN_PATH="$pluginPath"
|
||||||
|
pluginPath="${pluginPath%/*}"
|
||||||
|
|
||||||
|
# If located in lib/ subdir, include parent in lib-path
|
||||||
|
case "$(basename "$pluginPath")" in
|
||||||
|
(lib*)
|
||||||
|
LD_LIBRARY_PATH="${pluginPath}:$LD_LIBRARY_PATH"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
echo "Ignore bad/invalid plugin-path: $pluginPath" 1>&2
|
||||||
|
unset pluginPath
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
-block*) # Silently accepts -blockMesh
|
||||||
extension=blockMesh
|
extension=blockMesh
|
||||||
plugin=blockReader
|
plugin=blockReader
|
||||||
;;
|
;;
|
||||||
@ -136,16 +193,14 @@ do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
pluginError="No supplementary ParaView/OpenFOAM reader modules"
|
||||||
|
|
||||||
if [ -n "$plugin" ]
|
if [ -n "$plugin" ]
|
||||||
then
|
then
|
||||||
pluginError="Cannot use ParaView/OpenFOAM reader modules"
|
if [ -d "$PV_PLUGIN_PATH" ]
|
||||||
|
|
||||||
# Check if requested reader module exists
|
|
||||||
if [ -z "$PV_PLUGIN_PATH" ]
|
|
||||||
then
|
then
|
||||||
echo "The PV_PLUGIN_PATH environment variable is unset" 1>&2
|
# Check if requested reader module exists
|
||||||
echo "$pluginError" 1>&2
|
|
||||||
else
|
|
||||||
|
|
||||||
# Check for different names. For example,
|
# Check for different names. For example,
|
||||||
# - ParaFoamReader = (paraview >= 5.7)
|
# - ParaFoamReader = (paraview >= 5.7)
|
||||||
@ -186,30 +241,30 @@ then
|
|||||||
if [ -n "$pluginError" ]
|
if [ -n "$pluginError" ]
|
||||||
then
|
then
|
||||||
cat<< NO_PLUGIN 1>&2
|
cat<< NO_PLUGIN 1>&2
|
||||||
=========================
|
$pluginError
|
||||||
$pluginError - need to build?
|
See '${0##*/} -help-build' for more information
|
||||||
|
|
||||||
cd \$WM_PROJECT_DIR/modules/visualization/src/paraview-plugins
|
|
||||||
OR cd \$WM_PROJECT_DIR/applications/utilities/postProcessing/graphics/PVReaders
|
|
||||||
|
|
||||||
./Allwclean && ./Allwmake
|
|
||||||
=========================
|
|
||||||
NO_PLUGIN
|
NO_PLUGIN
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "Invalid \$PV_PLUGIN_PATH and -plugin-path= not defined" 1>&2
|
||||||
|
echo "$pluginError" 1>&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$pluginError" ]
|
if [ -n "$pluginError" ]
|
||||||
then
|
then
|
||||||
# Fallback to native reader, if possible
|
# Fallback to native reader, if possible
|
||||||
if [ "$plugin" = foamReader ]
|
case "$plugin" in
|
||||||
then
|
(foamReader)
|
||||||
echo "Continuing with builtin reader: paraFoam -vtk" 1>&2
|
echo "Using builtin reader: ${0##*/} -vtk" 1>&2
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
extension=foam
|
extension=foam
|
||||||
else
|
;;
|
||||||
|
(*)
|
||||||
echo 1>&2
|
echo 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
unset plugin
|
unset plugin
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user