Commit d3dde21a authored by henry's avatar henry
Browse files
parents fd7ec69c 599c1c59
namedEnumTest.C
EXE = $(FOAM_APPBIN)/NamedEnum
EXE = $(FOAM_USER_APPBIN)/NamedEnum
callbackTest.C
EXE = $(FOAM_APPBIN)/callbackTest
EXE = $(FOAM_USER_APPBIN)/callbackTest
testDataEntry.C
EXE = $(FOAM_APPBIN)/testDataEntry
EXE = $(FOAM_USER_APPBIN)/testDataEntry
......@@ -30,6 +30,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H"
#include "dictionary.H"
......@@ -40,18 +41,12 @@ using namespace Foam;
int main(int argc, char *argv[])
{
IFstream dictStream("testDict");
dictionary testDict(dictStream);
Info<< dictionary(IFstream("testDict")()) << endl;
Info<< testDict << endl;
IOobject::writeDivider(Info);
{
dictionary someDict;
someDict.add(keyType("a.*", true), "subdictValue");
dictionary dict;
dict.add("someDict", someDict);
dict.add(keyType(".*", true), "parentValue");
dictionary dict(IFstream("testDictRegex")());
Info<< "dict:" << dict << endl;
......@@ -64,6 +59,18 @@ int main(int argc, char *argv[])
Info<< "Recursive wildcard find \"def\" in sub directory : "
<< dict.subDict("someDict").lookup("def", true)
<< endl;
Info<< "Recursive wildcard find \"foo\" in sub directory : "
<< dict.subDict("someDict").lookup("foo", true)
<< endl;
Info<< "Recursive wildcard find \"fooz\" in sub directory : "
<< dict.subDict("someDict").lookup("fooz", true)
<< endl;
Info<< "Recursive wildcard find \"bar\" in sub directory : "
<< dict.subDict("someDict").lookup("bar", true)
<< endl;
Info<< "Recursive wildcard find \"xxx\" in sub directory : "
<< dict.subDict("someDict").lookup("xxx", true)
<< endl;
}
return 0;
......
/*-------------------------------*- C++ -*---------------------------------*\
| ========= |
| \\ / OpenFOAM |
| \\ / |
| \\ / The Open Source CFD Toolbox |
| \\/ http://www.OpenFOAM.org |
\*-------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDictRegex;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#inputMode merge
".*" parentValue1;
"[n-z].*" parentValue2;
"f.*" parentValue3;
someDict
{
foo subdictValue0;
bar $f.*; // should this really match 'foo'?
// result is dependent on insert order!
"a.*c" subdictValue3;
"ab.*" subdictValue2;
"a.*" subdictValue1;
abcd subdictValue4;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -28,6 +28,7 @@ Description
#include "argList.H"
#include "Time.H"
#include "timeSelector.H"
using namespace Foam;
......@@ -36,13 +37,19 @@ using namespace Foam;
int main(int argc, char *argv[])
{
argList::noParallel();
// timeSelector::addOptions();
timeSelector::addOptions(true, true);
# include "setRootCase.H"
# include "createTime.H"
Info<< runTime.times() << endl;
Info<< "Times found:" << runTime.times() << endl;
Info << "End\n" << endl;
instantList timeDirs = timeSelector::select0(runTime, args);
Info<< "Times selected:" << timeDirs << endl;
Info<< "\nEnd\n" << endl;
return 0;
}
......
regexTest.C
EXE = $(FOAM_USER_APPBIN)/regexTest
EXE_LIBS = \
$(FOAM_LIBBIN)/libOSspecific.o
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H"
#include "regExp.H"
#include "List.H"
#include "Tuple2.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
List<Tuple2<string, string> > rawList(IFstream("testRegexps")());
Info<< "input list:" << rawList << endl;
IOobject::writeDivider(Info);
Info<< endl;
List<string> groups;
// report matches:
forAll(rawList, elemI)
{
const string& pat = rawList[elemI].first();
const string& str = rawList[elemI].second();
regExp re(pat);
Info<< str << " =~ m/" << pat.c_str() << "/ == ";
if (re.match(str, groups))
{
Info<< "true";
if (re.ngroups())
{
Info<< groups;
}
}
else
{
Info<< "false";
if (re.match(str, true))
{
Info<< " partial match";
}
}
Info << endl;
}
Info<< endl;
return 0;
}
// ************************************************************************* //
/*-------------------------------*- C++ -*---------------------------------*\
| ========= |
| \\ / OpenFOAM |
| \\ / |
| \\ / The Open Source CFD Toolbox |
| \\/ http://www.OpenFOAM.org |
\*-------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// pattern, string
(
( "a.*" "abc" )
( "a.*" "bac" )
( "a.*" "abcd" )
( "a.*" "def" )
( "d(.*)f" "def" )
)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -26,7 +26,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "stringList.H"
#include "stringListOps.H"
#include "IOstreams.H"
using namespace Foam;
......
xferListTest.C
/* EXE = $(FOAM_USER_APPBIN)/xferListTest */
EXE = ./xferListTest
EXE = $(FOAM_USER_APPBIN)/xferListTest
......@@ -45,8 +45,10 @@ Description
int main(int argc, char *argv[])
{
// enable -constant ... if someone really wants it
// enable -zeroTime to prevent accidentally trashing the initial fields
timeSelector::addOptions(true, true);
argList::noParallel();
timeSelector::addOptions();
# include "addRegionOption.H"
argList::validOptions.insert("fields", "\"(list of fields)\"");
......
......@@ -74,7 +74,9 @@ using namespace Foam;
int main(int argc, char *argv[])
{
// with -constant and -zeroTime
// enable -constant
// probably don't need -zeroTime though, since the fields are vetted
// afterwards anyhow
timeSelector::addOptions(true, false);
argList::noParallel();
argList::validOptions.insert("ascii", "");
......
......@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
Info<< "\nWall heat fluxes [W]" << endl;
forAll(patchHeatFlux, patchi)
{
if (typeid(mesh.boundary()) == typeid(wallFvPatch))
if (typeid(mesh.boundary()[patchi]) == typeid(wallFvPatch))
{
Info<< mesh.boundary()[patchi].name()
<< " "
......
foamUpgradeFvSolution.C
EXE = $(FOAM_APPBIN)/foamUpgradeFvSolution
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
foamUpgradeFvSolution
Description
Simple tool to upgrade the syntax of system/fvSolution::solvers
Usage
- foamUpgradeFvSolution [OPTION]
@param -test \n
Suppress writing the updated fvSolution file
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "IOdictionary.H"
#include "solution.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validOptions.insert("test", "");
# include "setRootCase.H"
# include "createTime.H"
IOdictionary solutionDict
(
IOobject
(
"fvSolution",
runTime.system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
label nChanged = 0;
entry* e = solutionDict.lookupEntryPtr("solvers", false, false);
if (e && e->isDict())
{
nChanged = solution::upgradeSolverDict(e->dict(), true);
}
Info<< nChanged << " solver settings changed" << nl << endl;
if (nChanged)
{
if (args.options().found("test"))
{
Info<< "-test option: no changes made" << nl << endl;
}
else
{
mv
(
solutionDict.objectPath(),
solutionDict.objectPath() + ".old"
);
solutionDict.writeObject
(
IOstream::ASCII,
IOstream::currentVersion,
IOstream::UNCOMPRESSED
);
Info<< "Backup to " << (solutionDict.objectPath() + ".old") << nl
<< "Write to " << solutionDict.objectPath() << nl << endl;
}
}
return 0;
}
// ************************************************************************* //
......@@ -31,19 +31,19 @@
#
#------------------------------------------------------------------------------
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: ${0##*/} [OPTION]
options:
-case dir specify alternative case directory
-region name specify mesh region name
-touch create the .OpenFOAM file only and exit
-touch only create the .OpenFOAM file
* start paraview $ParaView_VERSION with the OpenFOAM libraries
USAGE
exit 1
exit 1
}
unset regionName touchOnly
......@@ -51,81 +51,83 @@ unset regionName touchOnly
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-case)
[ "$#" -ge 2 ] || usage "'-case' option requires an argument"
caseDir=$2
shift 2
cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'"
;;
-region)
[ "$#" -ge 2 ] || usage "'-region' option requires an argument"
regionName=$2
shift 2
;;
-touch)
touchOnly=1
shift
;;
*)
usage "unknown option/argument: '$*'"
;;
esac
case "$1" in
-h | -help)
usage
;;
-case)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
shift 2
;;
-region)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
regionName=$2
shift 2
;;
-touch)
touchOnly=true
shift
;;
*)
usage "unknown option/argument: '$*'"
;;
esac
done
# get a sensible caseName
caseName=${PWD##*/}
caseFile="$caseName.OpenFOAM"
fvControls="system"
if [ -n "$regionName" ]
then
caseFile="$caseName{$regionName}.OpenFOAM"
caseFile="$caseName{$regionName}.OpenFOAM"
fvControls="$fvControls/$regionName"
fi
if [ -n "$touchOnly" ];
if [ -n "$touchOnly" ]
then
touch "$caseFile"
echo "created '$caseFile'"
exit 0
touch "$caseFile"
echo "created '$caseFile'"
exit 0
fi
# parent directory for normal or parallel results
case "$caseName" in
processor*) parentDir=".." ;;
*) parentDir="." ;;
processor*) parentDir=".." ;;
*) parentDir="." ;;
esac
# check existence of essential files
for check in system/controlDict system/fvSchemes system/fvSolution
for check in system/controlDict $fvControls/fvSchemes $fvControls/fvSolution
do
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
done
case "$ParaView_VERSION" in
2*)
trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch $caseFile
trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch "$caseFile"
# since we are now in the cwd, %CASE% is '$PWD/$caseFile'
sed -e s@%CASE%@$PWD/$caseFile@g \
$WM_PROJECT_DIR/bin/paraFoam.pvs > paraFoam.pvs
# since we are now in the cwd, %CASE% is '$PWD/$caseFile'
sed -e s@%CASE%@$PWD/$caseFile@g \
$WM_PROJECT_DIR/bin/tools/paraFoam.pvs > paraFoam.pvs
paraview paraFoam.pvs
;;
paraview paraFoam.pvs
;;
*)
# only create/remove caseFile if it doesn't exist
[ -e $caseFile ] || {
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch "$caseFile"
echo "created temporary '$caseFile'"
}
paraview --data="$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"
;;
esac
#------------------------------------------------------------------------------
Misc. tools for building applications, etc that are useful to have
but which don't really need to be in the PATH.
Misc. tools, scripts, templates that are useful (eg, for building applications)
but don't need to be in the PATH.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment