Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
f26b0d60
Commit
f26b0d60
authored
May 26, 2011
by
andy
Browse files
Merge branch 'olesenm'
parents
3754b27d
7cdee136
Changes
3
Hide whitespace changes
Inline
Side-by-side
bin/paraFoam
View file @
f26b0d60
...
...
@@ -37,7 +37,7 @@ usage() {
while
[
"$#"
-ge
1
]
;
do
echo
"
$1
"
;
shift
;
done
cat
<<
USAGE
Usage:
${
0
##*/
}
[OPTION]
Usage:
${
0
##*/
}
[OPTION]
[PARAVIEW_OPTION]
options:
-block use blockMesh reader (uses .blockMesh extension)
-builtin use VTK builtin OpenFOAM reader (uses .foam extension)
...
...
@@ -47,6 +47,9 @@ options:
-touchAll create .blockMesh, .OpenFOAM files (and for all regions)
-help print the usage
paraview options start with a double dashes
* start paraview
$ParaView_VERSION
with the OpenFOAM libraries
USAGE
...
...
@@ -57,7 +60,7 @@ USAGE
# to clean up
unset
FOAM_ABORT
unset
regionName
t
ouch
Opt
unset
regionName
optT
ouch
# reader extension
extension
=
OpenFOAM
...
...
@@ -88,12 +91,19 @@ do
shift
2
;;
-touch
)
t
ouch
Opt
=
true
optT
ouch
=
true
shift
;;
-touchAll
)
touchOpt
=
all
optTouch
=
all
shift
;;
--
)
shift
break
# stop here, treat balance as paraview options
;;
--
*
)
break
# stop here, treat this and balance as paraview options
;;
*
)
usage
"unknown option/argument: '
$*
'"
...
...
@@ -101,6 +111,28 @@ do
esac
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
caseName
=
${
PWD
##*/
}
caseFile
=
"
$caseName
.
$extension
"
...
...
@@ -112,7 +144,7 @@ then
fvControls
=
"
$fvControls
/
$regionName
"
fi
case
"
${
t
ouch
Opt
:-
false
}
"
in
case
"
${
optT
ouch
:-
false
}
"
in
all
)
extension
=
OpenFOAM
if
[
-f
constant/polyMesh/blockMeshDict
]
...
...
@@ -149,33 +181,56 @@ case "$caseName" in
esac
#
# check existence of essential files
#
case
$extension
in
blockMesh
)
for
check
in
system/controlDict constant/polyMesh/blockMeshDict
do
[
-s
"
$parentDir
/
$check
"
]
||
usage
"file does not exist: '
$parentDir
/
$check
'"
done
;;
if
[
"
${
hasData
:-
false
}
"
=
true
]
then
builtin
|
OpenFOAM
)
for
check
in
system/controlDict
$fvControls
/fvSchemes
$fvControls
/fvSolution
do
[
-s
"
$parentDir
/
$check
"
]
||
usage
"file does not exist: '
$parentDir
/
$check
'"
done
;;
esac
# has --data=.., send directly to paraview
exec
paraview
"
$@
"
else
# check existence of essential files
warn
=
"WARN file does not exist:"
case
$extension
in
blockMesh
)
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
'"
}
# 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
"
#------------------------------------------------------------------------------
src/OpenFOAM/global/argList/argList.C
View file @
f26b0d60
...
...
@@ -414,11 +414,11 @@ Foam::argList::argList
(
(
validOptions
.
found
(
optionName
)
&&
validOptions
[
optionName
]
!=
""
&&
!
validOptions
[
optionName
]
.
empty
()
)
||
(
validParOptions
.
found
(
optionName
)
&&
validParOptions
[
optionName
]
!=
""
&&
!
validParOptions
[
optionName
]
.
empty
()
)
)
{
...
...
@@ -833,6 +833,116 @@ Foam::argList::~argList()
// * * * * * * * * * * * * * * * 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
{
// output notes directly - no automatic text wrapping
...
...
src/OpenFOAM/global/argList/argList.H
View file @
f26b0d60
...
...
@@ -334,6 +334,19 @@ public:
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 notes (if any)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment