mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
CONFIG: inline _foamEval within <etc/config.sh/setup>
- previously a function (unlike the csh version) but since bashrc and setup have been split -> replace with inline definition STYLE: formatting/wording for openfoam starters TUT: simplify controlDict modification, add default substitution ENH: accept '/' for end-of-options terminator (etc/openfoam) - makes the application or service more apparent. * eg. /usr/bin/openfoam / blockMesh * vs. /usr/bin/openfoam -- blockMesh Accept lone '-' as the end-of-options terminator, as per bash - Adjust handling of openfoam '-c' option to flag that a command-string will appear, but continue with option parsing. Consistent with bash definition.
This commit is contained in:
@ -151,10 +151,10 @@ modifyCaseControlDict()
|
|||||||
do
|
do
|
||||||
cp -f "${dict}" "${dict}.orig"
|
cp -f "${dict}" "${dict}.orig"
|
||||||
sed \
|
sed \
|
||||||
-e 's/\(startFrom[ \t]*\)\([A-Za-z]*\);/\1 latestTime;/' \
|
-e 's/\(startFrom[ \t]*\)[^ \t;]*;/\1 latestTime;/' \
|
||||||
-e 's/\(stopAt[ \t]*\)\([A-Za-z]*\);/\1 nextWrite;/' \
|
-e 's/\(stopAt[ \t]*\)[^ \t;]*;/\1 nextWrite;/' \
|
||||||
-e 's/\(writeControl[ \t]*\)\([A-Za-z]*\);/\1 timeStep;/' \
|
-e 's/\(writeControl[ \t]*\)[^ \t;]*;/\1 timeStep;/' \
|
||||||
-e 's/\(writeInterval[ \t]*\)\([-.0-9A-Za-z]*\);/\1 '"$optRunLimit"';/' \
|
-e 's/\(writeInterval[ \t]*\)[^ \t;]*;/\1 '"${optRunLimit:-1}"';/' \
|
||||||
"${dict}.orig" > "${dict}"
|
"${dict}.orig" > "${dict}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,19 +1,13 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
exec "@PROJECT_DIR@"/etc/openfoam "$@"
|
exec "@PROJECT_DIR@"/etc/openfoam "$@"
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# ========= |
|
# OpenFOAM file (www.openfoam.com)
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
#
|
||||||
# \\ / O peration |
|
# Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||||
# \\ / A nd | www.openfoam.com
|
# SPDX-License-Identifier: (GPL-3.0+)
|
||||||
# \\/ M anipulation |
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# Copyright (C) 2020 OpenCFD Ltd.
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# License
|
|
||||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
|
||||||
#
|
#
|
||||||
# Description
|
# Description
|
||||||
# Forwarding to OpenFOAM etc/openfoam bash session script.
|
# Forward to OpenFOAM etc/openfoam bash session script.
|
||||||
# Uses a hard-code directory path (eg, generated with autoconfig).
|
# Uses hard-coded directory path.
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
# \\ / A nd | www.openfoam.com
|
# \\ / A nd | www.openfoam.com
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Copyright (C) 2018-2020 OpenCFD Ltd.
|
# Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -105,7 +105,10 @@ while ( $#argv > 0 )
|
|||||||
switch ($argv[1])
|
switch ($argv[1])
|
||||||
case -*:
|
case -*:
|
||||||
# Stray option (not meant for us here) -> get out
|
# Stray option (not meant for us here) -> get out
|
||||||
break
|
break # Break while
|
||||||
|
breaksw
|
||||||
|
case =*:
|
||||||
|
# Junk
|
||||||
breaksw
|
breaksw
|
||||||
case *=:
|
case *=:
|
||||||
# name= -> unsetenv name
|
# name= -> unsetenv name
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
# Copyright (C) 2017-2020 OpenCFD Ltd.
|
# Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -159,45 +159,6 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Evaluate command-line parameters
|
|
||||||
unset -f _foamEval 2>/dev/null
|
|
||||||
_foamEval()
|
|
||||||
{
|
|
||||||
for i
|
|
||||||
do
|
|
||||||
case "$i" in
|
|
||||||
-*)
|
|
||||||
# Stray option (not meant for us here) -> get out
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
*=)
|
|
||||||
# name= -> unset name
|
|
||||||
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
|
|
||||||
&& echo "unset ${1%=}" 1>&2
|
|
||||||
eval "unset ${1%=}"
|
|
||||||
;;
|
|
||||||
*=*)
|
|
||||||
# name=value -> export name=value
|
|
||||||
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
|
|
||||||
&& echo "export $i" 1>&2
|
|
||||||
eval "export $i"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# Filename: source it
|
|
||||||
if [ -f "$i" ]
|
|
||||||
then
|
|
||||||
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
|
|
||||||
&& echo "Using: $i" 1>&2
|
|
||||||
. "$i"
|
|
||||||
else
|
|
||||||
_foamEtc -silent "$i"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------
|
#--------------------------------------------------------------------------
|
||||||
# Avoid any ThirdParty settings that may have 'leaked' into the environment
|
# Avoid any ThirdParty settings that may have 'leaked' into the environment
|
||||||
|
|
||||||
@ -221,7 +182,7 @@ else
|
|||||||
# Was previously loaded/defined - now unset
|
# Was previously loaded/defined - now unset
|
||||||
|
|
||||||
unset -f _foamAddPath _foamAddMan _foamAddLib _foamAddLibAuto 2>/dev/null
|
unset -f _foamAddPath _foamAddMan _foamAddLib _foamAddLibAuto 2>/dev/null
|
||||||
unset -f _foamClean _foamEcho _foamEtc _foamEval 2>/dev/null
|
unset -f _foamClean _foamEcho _foamEtc 2>/dev/null
|
||||||
unset foamClean
|
unset foamClean
|
||||||
unset WM_SHELL_FUNCTIONS
|
unset WM_SHELL_FUNCTIONS
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
# \\ / A nd | www.openfoam.com
|
# \\ / A nd | www.openfoam.com
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Copyright (C) 2018-2020 OpenCFD Ltd.
|
# Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -106,19 +106,64 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Capture and evaluate any command-line parameters
|
#----------------------------------------------------------------------------
|
||||||
# These can be used to set/unset values, specify additional files etc.
|
|
||||||
FOAM_SETTINGS="$@"
|
|
||||||
|
|
||||||
# Evaluate the command-line parameters, which were saved as FOAM_SETTINGS.
|
# Capture and evaluate command-line parameters
|
||||||
# These can be used to set/unset values, specify additional files etc.
|
# - set/unset values, specify additional files etc.
|
||||||
if [ -z "$FOAM_SETTINGS" ]
|
# - parameters never start with '-'
|
||||||
|
if [ "$#" -gt 0 ] && [ "${1#-}" = "${1}" ]
|
||||||
then
|
then
|
||||||
unset FOAM_SETTINGS
|
FOAM_SETTINGS="$@"
|
||||||
else
|
if [ -n "$FOAM_SETTINGS" ]
|
||||||
|
then
|
||||||
export FOAM_SETTINGS
|
export FOAM_SETTINGS
|
||||||
_foamEval "$@"
|
|
||||||
|
for foamVar_eval
|
||||||
|
do
|
||||||
|
case "$foamVar_eval" in
|
||||||
|
(-*)
|
||||||
|
# Stray option (not meant for us here) -> get out
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
(=*)
|
||||||
|
# Junk
|
||||||
|
;;
|
||||||
|
(*=)
|
||||||
|
# name= -> unset name
|
||||||
|
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
|
||||||
|
&& echo "unset ${foamVar_eval%=}" 1>&2
|
||||||
|
eval "unset ${foamVar_eval%=}"
|
||||||
|
;;
|
||||||
|
(*=*)
|
||||||
|
# name=value -> export name=value
|
||||||
|
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
|
||||||
|
&& echo "export $foamVar_eval" 1>&2
|
||||||
|
eval "export $foamVar_eval"
|
||||||
|
;;
|
||||||
|
(*)
|
||||||
|
# Filename: source it
|
||||||
|
if [ -f "$foamVar_eval" ]
|
||||||
|
then
|
||||||
|
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
|
||||||
|
&& echo "Using: $foamVar_eval" 1>&2
|
||||||
|
. "$foamVar_eval"
|
||||||
|
elif [ -n "$foamVar_eval" ]
|
||||||
|
then
|
||||||
|
_foamEtc -silent "$foamVar_eval"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
else
|
||||||
|
unset FOAM_SETTINGS
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
unset FOAM_SETTINGS
|
||||||
fi
|
fi
|
||||||
|
unset foamVar_eval
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
# Verify FOAM_CONFIG_ETC (from calling environment or from prefs)
|
# Verify FOAM_CONFIG_ETC (from calling environment or from prefs)
|
||||||
if [ -n "$FOAM_CONFIG_ETC" ]
|
if [ -n "$FOAM_CONFIG_ETC" ]
|
||||||
|
|||||||
55
etc/openfoam
55
etc/openfoam
@ -31,7 +31,7 @@
|
|||||||
# -int32 | -DWM_LABEL_SIZE=32
|
# -int32 | -DWM_LABEL_SIZE=32
|
||||||
# -int64 | -DWM_LABEL_SIZE=64
|
# -int64 | -DWM_LABEL_SIZE=64
|
||||||
#
|
#
|
||||||
# However, the '-D' options grant more flexibility. For example,
|
# The '-D' options grant even more flexibility. For example,
|
||||||
# etc/openfoam -DWM_COMPILER=Clang
|
# etc/openfoam -DWM_COMPILER=Clang
|
||||||
#
|
#
|
||||||
# SeeAlso
|
# SeeAlso
|
||||||
@ -43,25 +43,29 @@ projectDir="$(\cd "$(dirname "${0%/*}")" && \pwd -L)"
|
|||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
printHelp() {
|
printHelp() {
|
||||||
cat<<USAGE
|
cat<<HELP_USAGE
|
||||||
|
|
||||||
Usage: ${0##*/} [OPTION] [application ...]
|
Usage: ${0##*/} [OPTION] [[--] application ...]
|
||||||
|
|
||||||
options:
|
options:
|
||||||
-c command Execute shell commands with OpenFOAM environment
|
-c Shell commands read from the first non-option argument
|
||||||
-Dkey[=value] Define key/value to pass as a preference
|
-Dkey[=value] Define key/value to pass as a preference
|
||||||
-sp Single precision
|
-sp Single precision
|
||||||
-dp Double precision
|
-dp Double precision
|
||||||
-spdp Mixed single/double precision
|
-spdp Mixed single/double precision
|
||||||
-int32 | -int64 The label-size
|
-int32 Label-size 32
|
||||||
|
-int64 Label-size 64
|
||||||
-etc=DIR Additional project etc/ directory
|
-etc=DIR Additional project etc/ directory
|
||||||
-prefix=DIR Alternative OpenFOAM project directory
|
-prefix=DIR Alternative OpenFOAM project directory
|
||||||
-show-api | -version Print META-INFO api value and exit
|
-show-api Print META-INFO api value and exit
|
||||||
-show-patch Print META-INFO patch value and exit
|
-show-patch Print META-INFO patch value and exit
|
||||||
-show-prefix Print project directory and exit
|
-show-prefix Print project directory and exit
|
||||||
-test-tutorial Forward arguments to bin/foamTestTutorial
|
-test-tutorial Forward arguments to bin/foamTestTutorial
|
||||||
-init=FILE Alternative initialization file (expert option)
|
-init=FILE Alternative initialization file (expert option)
|
||||||
|
-version Same as -show-api
|
||||||
-verbose Set FOAM_VERBOSE=true (interactive only)
|
-verbose Set FOAM_VERBOSE=true (interactive only)
|
||||||
|
-- The end of option processing.
|
||||||
|
An argument of - or / is equivalent to --.
|
||||||
-help Print the usage
|
-help Print the usage
|
||||||
|
|
||||||
Open an interactive bash session with an OpenFOAM environment,
|
Open an interactive bash session with an OpenFOAM environment,
|
||||||
@ -76,7 +80,7 @@ For a persistent OpenFOAM environment, the following can be added to your
|
|||||||
|
|
||||||
For more information: www.openfoam.com
|
For more information: www.openfoam.com
|
||||||
|
|
||||||
USAGE
|
HELP_USAGE
|
||||||
exit 0 # A clean exit
|
exit 0 # A clean exit
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +114,12 @@ unset optTestTut
|
|||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h | -help* | --help*)
|
('') ;;
|
||||||
|
(- | -- | /)
|
||||||
|
shift
|
||||||
|
break # Stop option parsing
|
||||||
|
;;
|
||||||
|
(-h | -help* | --help*)
|
||||||
printHelp
|
printHelp
|
||||||
;;
|
;;
|
||||||
-show-api | -version | --version) # Show API and exit
|
-show-api | -version | --version) # Show API and exit
|
||||||
@ -130,14 +139,8 @@ do
|
|||||||
optTestTut=true
|
optTestTut=true
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-c) # Shell command
|
(-c) # Shell command
|
||||||
_foamScriptCommand="$2"
|
_foamScriptCommand="-c"
|
||||||
[ -n "$_foamScriptCommand" ] || {
|
|
||||||
echo "$0: missing or bad command argument: $2" 1>&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
shift 2
|
|
||||||
break
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-D*) # Define key/value to pass as preference
|
-D*) # Define key/value to pass as preference
|
||||||
@ -175,11 +178,6 @@ do
|
|||||||
-verbose)
|
-verbose)
|
||||||
export FOAM_VERBOSE=true
|
export FOAM_VERBOSE=true
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--)
|
|
||||||
shift
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
-*)
|
-*)
|
||||||
echo "$0: unknown option: '$1'" 1>&2
|
echo "$0: unknown option: '$1'" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -217,7 +215,14 @@ fi
|
|||||||
|
|
||||||
unset interactive
|
unset interactive
|
||||||
|
|
||||||
if [ "$#" -eq 0 ] && [ -z "$_foamScriptCommand" ] && [ -z "$optTestTut" ]
|
if [ -n "$_foamScriptCommand" ]
|
||||||
|
then
|
||||||
|
if [ "$#" -eq 0 ]
|
||||||
|
then
|
||||||
|
echo "$0: -c: option requires an argument" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
elif [ "$#" -eq 0 ] && [ -z "$optTestTut" ]
|
||||||
then
|
then
|
||||||
interactive=true
|
interactive=true
|
||||||
fi
|
fi
|
||||||
@ -283,16 +288,14 @@ sourceBashrc()
|
|||||||
if [ -n "$_foamScriptCommand" ]
|
if [ -n "$_foamScriptCommand" ]
|
||||||
then
|
then
|
||||||
# A shell command
|
# A shell command
|
||||||
|
|
||||||
sourceBashrc
|
sourceBashrc
|
||||||
exec bash -c "$_foamScriptCommand" "$@"
|
exec bash -c "$@"
|
||||||
exit $? # Safety
|
exit $? # Safety
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ -n "$optTestTut" ]
|
if [ -n "$optTestTut" ]
|
||||||
then
|
then
|
||||||
|
# Test tutorial(s)
|
||||||
sourceBashrc
|
sourceBashrc
|
||||||
exec "$WM_PROJECT_DIR"/bin/foamTestTutorial "$@"
|
exec "$WM_PROJECT_DIR"/bin/foamTestTutorial "$@"
|
||||||
exit $? # Safety
|
exit $? # Safety
|
||||||
|
|||||||
@ -148,10 +148,10 @@ modifyCaseControlDict()
|
|||||||
do
|
do
|
||||||
cp -f "${dict}" "${dict}.orig"
|
cp -f "${dict}" "${dict}.orig"
|
||||||
sed \
|
sed \
|
||||||
-e 's/\(startFrom[ \t]*\)\([A-Za-z]*\);/\1 latestTime;/' \
|
-e 's/\(startFrom[ \t]*\)[^ \t;]*;/\1 latestTime;/' \
|
||||||
-e 's/\(stopAt[ \t]*\)\([A-Za-z]*\);/\1 nextWrite;/' \
|
-e 's/\(stopAt[ \t]*\)[^ \t;]*;/\1 nextWrite;/' \
|
||||||
-e 's/\(writeControl[ \t]*\)\([A-Za-z]*\);/\1 timeStep;/' \
|
-e 's/\(writeControl[ \t]*\)[^ \t;]*;/\1 timeStep;/' \
|
||||||
-e 's/\(writeInterval[ \t]*\)\([-.0-9A-Za-z]*\);/\1 '"$optRunLimit"';/' \
|
-e 's/\(writeInterval[ \t]*\)[^ \t;]*;/\1 '"${optRunLimit:-1}"';/' \
|
||||||
"${dict}.orig" > "${dict}"
|
"${dict}.orig" > "${dict}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user