Files
openfoam/etc/config.sh/aliases
Mark Olesen 831a47b81e CONFIG: eliminate most occurances of outdated FOAM_INST_DIR (issue #444)
- since 1612, FOAM_INST_DIR and foamInstDir longer have any
  special meanings when sourcing the bashrc or cshrc files.
  Thus no need for special treatment in any of the dispatch wrappers.

  Retained FOAM_INST_DIR as (unexported) variable in etc/bashrc,
  just in case people are using patched versions of etc/bashrc
  as part of their installation.

ENH: relax prefix restrictions on foamCreateVideo (issue #904)

- shift the implicit '.' to be part of the default prefix. This allows
  things like "-image myimages_00" to work as might be expected.
2018-06-25 09:56:34 +02:00

132 lines
3.7 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-2018 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
#
# File
# etc/config.sh/aliases
# - sourced by OpenFOAM-*/etc/bashrc (or from the user's ~/.bashrc)
#
# Description
# Aliases for working with OpenFOAM.
#
#------------------------------------------------------------------------------
# Change compiled version aliases
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias wmSet='. $WM_PROJECT_DIR/etc/bashrc'
alias wmInt32='wmSet WM_LABEL_SIZE=32'
alias wmInt64='wmSet WM_LABEL_SIZE=64'
alias wmSP='wmSet WM_PRECISION_OPTION=SP'
alias wmDP='wmSet WM_PRECISION_OPTION=DP'
# Clear env
alias wmUnset='. $WM_PROJECT_DIR/etc/config.sh/unset'
# Toggle wmakeScheduler on/off
# - also need to set WM_HOSTS
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias wmSchedOn='export WM_SCHEDULER=$WM_PROJECT_DIR/wmake/wmakeScheduler'
alias wmSchedOff='unset WM_SCHEDULER'
# Change directory aliases
# ~~~~~~~~~~~~~~~~~~~~~~~~
alias foam='cd $WM_PROJECT_DIR'
alias src='cd $FOAM_SRC'
alias lib='cd $FOAM_LIBBIN'
alias app='cd $FOAM_APP'
alias sol='cd $FOAM_SOLVERS'
alias util='cd $FOAM_UTILITIES'
alias tut='cd $FOAM_TUTORIALS'
alias run='cd $FOAM_RUN'
alias ufoam='cd $WM_PROJECT_USER_DIR'
alias uapp='cd $WM_PROJECT_USER_DIR/applications'
alias usol='cd $WM_PROJECT_USER_DIR/applications/solvers'
alias uutil='cd $WM_PROJECT_USER_DIR/applications/utilities'
# Refresh the environment
# ~~~~~~~~~~~~~~~~~~~~~~~
unset -f wmRefresh 2>/dev/null
wmRefresh()
{
local projectDir=$WM_PROJECT_DIR
local foamSettings=$FOAM_SETTINGS
wmUnset
. $projectDir/etc/bashrc $foamSettings
}
# Query the current OpenFOAM version
# or change to another version (if installed in a parallel directory)
unset -f foamVersion 2>/dev/null
foamVersion()
{
if [ "$#" -gt 0 ]
then
local dir="${WM_PROJECT_DIR%/*}" # Parent directory
local ver=$1
shift
if [ -f "$dir/OpenFOAM-$ver/etc/bashrc" ]
then
wmUnset
. $dir/OpenFOAM-$ver/etc/bashrc
foam
echo "Changed to OpenFOAM-$WM_PROJECT_VERSION" 1>&2
else
echo "No OpenFOAM-$ver available in $dir" 1>&2
echo "Using OpenFOAM-$WM_PROJECT_VERSION" 1>&2
return 1
fi
else
# Treat as query. Report current version
echo "OpenFOAM-$WM_PROJECT_VERSION" 1>&2
fi
}
# Change ParaView version
# ~~~~~~~~~~~~~~~~~~~~~~~
# pass in first value directly (eg, 5.4.1) and transform to
# ParaView_VERSION=...
# Any additional arguments must be fully specified and start with "ParaView".
# Eg,
# ParaView_QT=...
unset -f foamPV 2>/dev/null
foamPV()
{
. $WM_PROJECT_DIR/etc/config.sh/paraview "${@+ParaView_VERSION=$@}"
local pvdir="${ParaView_DIR##*/}"
echo "${pvdir:-ParaView_DIR not set}" 1>&2
}
# OpenFOAM working directory with basic env replacements
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
unset -f foamPwd 2>/dev/null
foamPwd()
{
if [ -d "$WM_PROJECT_DIR" ]
then
echo $PWD | sed \
-e "s#^${FOAM_RUN}#\$FOAM_RUN#;" \
-e "s#^${WM_PROJECT_DIR}#\$WM_PROJECT_DIR#;" \
-e "s#^${WM_PROJECT_USER_DIR}#\$WM_PROJECT_USER_DIR#;" \
-e "s#^${HOME}#\$HOME#";
else
echo $PWD | sed -e "s#^${HOME}#\$HOME#;"
fi
}
#------------------------------------------------------------------------------