mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'olesenm'
This commit is contained in:
113
bin/paraFoam
113
bin/paraFoam
@ -37,7 +37,7 @@ usage() {
|
|||||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||||
cat<<USAGE
|
cat<<USAGE
|
||||||
|
|
||||||
Usage: ${0##*/} [OPTION]
|
Usage: ${0##*/} [OPTION] [PARAVIEW_OPTION]
|
||||||
options:
|
options:
|
||||||
-block use blockMesh reader (uses .blockMesh extension)
|
-block use blockMesh reader (uses .blockMesh extension)
|
||||||
-builtin use VTK builtin OpenFOAM reader (uses .foam extension)
|
-builtin use VTK builtin OpenFOAM reader (uses .foam extension)
|
||||||
@ -47,6 +47,9 @@ options:
|
|||||||
-touchAll create .blockMesh, .OpenFOAM files (and for all regions)
|
-touchAll create .blockMesh, .OpenFOAM files (and for all regions)
|
||||||
-help print the usage
|
-help print the usage
|
||||||
|
|
||||||
|
|
||||||
|
paraview options start with a double dashes
|
||||||
|
|
||||||
* start paraview $ParaView_VERSION with the OpenFOAM libraries
|
* start paraview $ParaView_VERSION with the OpenFOAM libraries
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
@ -57,7 +60,7 @@ USAGE
|
|||||||
# to clean up
|
# to clean up
|
||||||
unset FOAM_ABORT
|
unset FOAM_ABORT
|
||||||
|
|
||||||
unset regionName touchOpt
|
unset regionName optTouch
|
||||||
|
|
||||||
# reader extension
|
# reader extension
|
||||||
extension=OpenFOAM
|
extension=OpenFOAM
|
||||||
@ -88,19 +91,48 @@ do
|
|||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
-touch)
|
-touch)
|
||||||
touchOpt=true
|
optTouch=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-touchAll)
|
-touchAll)
|
||||||
touchOpt=all
|
optTouch=all
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break # stop here, treat balance as paraview options
|
||||||
|
;;
|
||||||
|
--*)
|
||||||
|
break # stop here, treat this and balance as paraview options
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
usage "unknown option/argument: '$*'"
|
usage "unknown option/argument: '$*'"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# check for --data=... argument
|
||||||
|
#
|
||||||
|
hasDataArg()
|
||||||
|
{
|
||||||
|
hasData=false
|
||||||
|
while [ "$#" -gt 0 ]
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
(--data=*)
|
||||||
|
hasData=true
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
hasDataArg $@
|
||||||
|
|
||||||
|
|
||||||
# get a sensible caseName from the directory name
|
# get a sensible caseName from the directory name
|
||||||
caseName=${PWD##*/}
|
caseName=${PWD##*/}
|
||||||
caseFile="$caseName.$extension"
|
caseFile="$caseName.$extension"
|
||||||
@ -112,7 +144,7 @@ then
|
|||||||
fvControls="$fvControls/$regionName"
|
fvControls="$fvControls/$regionName"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "${touchOpt:-false}" in
|
case "${optTouch:-false}" in
|
||||||
all)
|
all)
|
||||||
extension=OpenFOAM
|
extension=OpenFOAM
|
||||||
if [ -f constant/polyMesh/blockMeshDict ]
|
if [ -f constant/polyMesh/blockMeshDict ]
|
||||||
@ -149,33 +181,56 @@ case "$caseName" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
#
|
if [ "${hasData:-false}" = true ]
|
||||||
# check existence of essential files
|
then
|
||||||
#
|
|
||||||
case $extension in
|
|
||||||
blockMesh)
|
|
||||||
for check in system/controlDict constant/polyMesh/blockMeshDict
|
|
||||||
do
|
|
||||||
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
|
|
||||||
builtin | OpenFOAM)
|
# has --data=.., send directly to paraview
|
||||||
for check in system/controlDict $fvControls/fvSchemes $fvControls/fvSolution
|
exec paraview "$@"
|
||||||
do
|
|
||||||
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
# only create/remove caseFile if it didn't already exist
|
# check existence of essential files
|
||||||
[ -e $caseFile ] || {
|
warn="WARN file does not exist:"
|
||||||
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
|
case $extension in
|
||||||
touch "$caseFile"
|
blockMesh)
|
||||||
echo "created temporary '$caseFile'"
|
for check in \
|
||||||
}
|
system/controlDict \
|
||||||
|
constant/polyMesh/blockMeshDict \
|
||||||
|
;
|
||||||
|
do
|
||||||
|
[ -s "$parentDir/$check" ] || {
|
||||||
|
[ -n "$warn" ] && echo "$warn" 1>&2
|
||||||
|
echo " $parentDir/$check" 1>&2
|
||||||
|
unset warn
|
||||||
|
}
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
|
||||||
|
builtin | OpenFOAM)
|
||||||
|
for check in \
|
||||||
|
system/controlDict \
|
||||||
|
$fvControls/fvSchemes \
|
||||||
|
$fvControls/fvSolution \
|
||||||
|
;
|
||||||
|
do
|
||||||
|
[ -s "$parentDir/$check" ] || {
|
||||||
|
[ -n "$warn" ] && echo "$warn" 1>&2
|
||||||
|
echo " $parentDir/$check" 1>&2
|
||||||
|
unset warn
|
||||||
|
}
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# 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" "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
paraview --data="$caseFile"
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -414,11 +414,11 @@ Foam::argList::argList
|
|||||||
(
|
(
|
||||||
(
|
(
|
||||||
validOptions.found(optionName)
|
validOptions.found(optionName)
|
||||||
&& validOptions[optionName] != ""
|
&& !validOptions[optionName].empty()
|
||||||
)
|
)
|
||||||
|| (
|
|| (
|
||||||
validParOptions.found(optionName)
|
validParOptions.found(optionName)
|
||||||
&& validParOptions[optionName] != ""
|
&& !validParOptions[optionName].empty()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -833,6 +833,116 @@ Foam::argList::~argList()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::argList::setOption(const word& opt, const string& param)
|
||||||
|
{
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
|
// only allow valid options
|
||||||
|
if (validOptions.found(opt))
|
||||||
|
{
|
||||||
|
// some options are to be protected
|
||||||
|
if
|
||||||
|
(
|
||||||
|
opt == "case"
|
||||||
|
|| opt == "parallel"
|
||||||
|
|| opt == "roots"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
FatalError
|
||||||
|
<<"used argList::setOption on a protected option: '"
|
||||||
|
<< opt << "'" << endl;
|
||||||
|
FatalError.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validOptions[opt].empty())
|
||||||
|
{
|
||||||
|
// bool option
|
||||||
|
if (!param.empty())
|
||||||
|
{
|
||||||
|
// disallow change of type
|
||||||
|
FatalError
|
||||||
|
<<"used argList::setOption to change bool to non-bool: '"
|
||||||
|
<< opt << "'" << endl;
|
||||||
|
FatalError.exit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// did not previously exist
|
||||||
|
changed = !options_.found(opt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// non-bool option
|
||||||
|
if (param.empty())
|
||||||
|
{
|
||||||
|
// disallow change of type
|
||||||
|
FatalError
|
||||||
|
<<"used argList::setOption to change non-bool to bool: '"
|
||||||
|
<< opt << "'" << endl;
|
||||||
|
FatalError.exit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// existing value needs changing, or did not previously exist
|
||||||
|
changed = options_.found(opt) ? options_[opt] != param : true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalError
|
||||||
|
<<"used argList::setOption on an invalid option: '"
|
||||||
|
<< opt << "'" << nl << "allowed are the following:"
|
||||||
|
<< validOptions << endl;
|
||||||
|
FatalError.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// set/change the option as required
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
options_.set(opt, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::argList::unsetOption(const word& opt)
|
||||||
|
{
|
||||||
|
// only allow valid options
|
||||||
|
if (validOptions.found(opt))
|
||||||
|
{
|
||||||
|
// some options are to be protected
|
||||||
|
if
|
||||||
|
(
|
||||||
|
opt == "case"
|
||||||
|
|| opt == "parallel"
|
||||||
|
|| opt == "roots"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
FatalError
|
||||||
|
<<"used argList::unsetOption on a protected option: '"
|
||||||
|
<< opt << "'" << endl;
|
||||||
|
FatalError.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove the option, return true if state changed
|
||||||
|
return options_.erase(opt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalError
|
||||||
|
<<"used argList::unsetOption on an invalid option: '"
|
||||||
|
<< opt << "'" << nl << "allowed are the following:"
|
||||||
|
<< validOptions << endl;
|
||||||
|
FatalError.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::argList::printNotes() const
|
void Foam::argList::printNotes() const
|
||||||
{
|
{
|
||||||
// output notes directly - no automatic text wrapping
|
// output notes directly - no automatic text wrapping
|
||||||
|
|||||||
@ -334,6 +334,19 @@ public:
|
|||||||
static void noParallel();
|
static void noParallel();
|
||||||
|
|
||||||
|
|
||||||
|
//- Set option directly (use with caution)
|
||||||
|
// An option with an empty param is a bool option.
|
||||||
|
// Not all valid options can also be set: eg, -case, -roots, ...
|
||||||
|
// Return true if the existing option value needed changing,
|
||||||
|
// or if the option did not previously exist.
|
||||||
|
bool setOption(const word& opt, const string& param = "");
|
||||||
|
|
||||||
|
//- Unset option directly (use with caution)
|
||||||
|
// Not all valid options can also be unset: eg, -case, -roots ...
|
||||||
|
// Return true if the option existed before being unset.
|
||||||
|
bool unsetOption(const word& opt);
|
||||||
|
|
||||||
|
|
||||||
// Print
|
// Print
|
||||||
|
|
||||||
//- Print notes (if any)
|
//- Print notes (if any)
|
||||||
|
|||||||
Reference in New Issue
Block a user