Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

This commit is contained in:
Andrew Heather
2016-12-20 11:17:59 +00:00
24 changed files with 792 additions and 330 deletions

View File

@ -1,10 +1,9 @@
Info<< "Reading thermophysical properties\n" << endl; Info<< "Reading thermophysical properties\n" << endl;
autoPtr<rhoThermo> pThermo
autoPtr<psiThermo> pThermo
( (
psiThermo::New(mesh) rhoThermo::New(mesh)
); );
psiThermo& thermo = pThermo(); rhoThermo& thermo = pThermo();
thermo.validate(args.executable(), "h", "e"); thermo.validate(args.executable(), "h", "e");
volScalarField rho volScalarField rho

View File

@ -1,4 +1,6 @@
{ {
//const volScalarField& psi = thermo.psi();
volScalarField rAU(1.0/UEqn.A()); volScalarField rAU(1.0/UEqn.A());
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU)); surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p)); volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
@ -93,6 +95,9 @@
rho = max(rho, rhoMin); rho = max(rho, rhoMin);
rho = min(rho, rhoMax); rho = min(rho, rhoMax);
thermo.rho() = max(thermo.rho(), rhoMin);
thermo.rho() = min(thermo.rho(), rhoMax);
if (!simple.transonic()) if (!simple.transonic())
{ {
rho.relax(); rho.relax();

View File

@ -109,6 +109,8 @@ if (closedVolume)
rho = thermo.rho(); rho = thermo.rho();
rho = max(rho, rhoMin); rho = max(rho, rhoMin);
rho = min(rho, rhoMax); rho = min(rho, rhoMax);
thermo.rho() = max(thermo.rho(), rhoMin);
thermo.rho() = min(thermo.rho(), rhoMax);
if (!simple.transonic()) if (!simple.transonic())
{ {

View File

@ -86,6 +86,10 @@
rho = thermo.rho(); rho = thermo.rho();
rho = max(rho, rhoMin); rho = max(rho, rhoMin);
rho = min(rho, rhoMax); rho = min(rho, rhoMax);
thermo.rho() = max(thermo.rho(), rhoMin);
thermo.rho() = min(thermo.rho(), rhoMax);
rho.relax(); rho.relax();
Info<< "rho max/min : " Info<< "rho max/min : "
<< max(rho).value() << " " << max(rho).value() << " "

View File

@ -33,7 +33,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvCFD.H" #include "fvCFD.H"
#include "psiThermo.H" #include "rhoThermo.H"
#include "turbulentFluidThermoModel.H" #include "turbulentFluidThermoModel.H"
#include "simpleControl.H" #include "simpleControl.H"
#include "fvOptions.H" #include "fvOptions.H"

View File

@ -29,26 +29,225 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "argList.H"
#include "fileName.H" #include "fileName.H"
#include "SubList.H" #include "SubList.H"
#include "DynamicList.H"
#include "IOobject.H" #include "IOobject.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "OSspecific.H" #include "OSspecific.H"
#include "POSIX.H" #include "POSIX.H"
#include "Switch.H"
#include "etcFiles.H"
using namespace Foam; using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program: // Main program:
int main() int main(int argc, char *argv[])
{ {
wordList wrdList(5); argList::noParallel();
wrdList[0] = "hello"; argList::addBoolOption("ext", "test handing of file extensions");
wrdList[1] = "hello1"; argList::addBoolOption("construct", "test constructors");
wrdList[2] = "hello2"; argList::addBoolOption("default", "reinstate default tests");
wrdList[3] = "hello3"; argList::addNote("runs default tests or specified ones only");
wrdList[4] = "hello4.hmm";
#include "setRootCase.H"
// Run default tests, unless only specific tests are requested
const bool defaultTests =
args.optionFound("default") || args.options().empty();
if (args.optionFound("construct"))
{
Info<< "From initializer_list<word> = ";
fileName file1
{
"hello",
"hello1",
"hello2",
"hello3",
"hello4.hmm"
};
Info<< file1 << nl;
Info<< "From initializer_list<fileName> = ";
fileName file2
{
file1,
"some",
"more/things.hmm"
};
Info<< file2 << nl;
Info<< "From initializer_list<fileName> with nesting = ";
fileName file3
{
std::string("ffO"),
"some",
"more/things.hmm"
};
Info<< file3 << nl;
DynamicList<word> base
{
"hello",
"hello1"
};
fileName file4
{
"some",
file3,
"more/things.hmm",
file1
};
Info<< "All ==> " << file4 << nl;
}
// Test various ext() methods
if (args.optionFound("ext"))
{
Info<<nl << nl << "handling of fileName extension" << nl;
fileName empty;
fileName endWithDot("some.path/name.");
fileName endWithSlash("some.path/");
fileName input0("some.file/with.out/extension");
fileName input1("path.to/media/image.png");
Info<<"File : " << input0 << " ext: "
<< Switch(input0.hasExt())
<< " = " << input0.ext() << nl;
Info<<"File : " << input1 << " ext: "
<< Switch(input1.hasExt())
<< " = " << input1.ext() << nl;
Info<<"File : " << endWithDot << " ext: "
<< Switch(endWithDot.hasExt())
<< " = " << endWithDot.ext() << " <-- perhaps return false?" << nl;
Info<<"File : " << endWithSlash << " ext: "
<< Switch(endWithSlash.hasExt())
<< " = " << endWithSlash.ext() << nl;
Info<<"Remove extension " << (input0.removeExt());
Info<< " now: " << input0 << nl;
Info<<"Remove extension " << (input1.removeExt());
Info<< " now: " << input1 << nl;
Info<<"Remove extension " << (endWithSlash.removeExt());
Info<< " now: " << endWithSlash << nl;
wordList exts{ "jpg", "png", "txt", word::null };
Info<<"Add extension(s): " << input1 << nl;
for (const word& e : exts)
{
Info<<"<" << e << "> -> " << input1.ext(e) << nl;
}
Info<< nl;
Info<<"Test hasExt(word)" << nl
<<"~~~~~~~~~~~~~~~~~" << nl;
Info<<"Has extension(s):" << nl
<< "input: " << input1 << nl;
for (const word& e : exts)
{
Info<<" '" << e << "' -> "
<< Switch(input1.hasExt(e)) << nl;
}
Info<< nl;
Info<<"Has extension(s):" << nl
<< "input: " << endWithDot << nl;
for (const word& e : exts)
{
Info<<" '" << e << "' -> "
<< Switch(endWithDot.hasExt(e)) << nl;
}
Info<< nl;
Info<<"Test hasExt(wordRe)" << nl
<<"~~~~~~~~~~~~~~~~~~~" << nl;
// A regex with a zero length matcher doesn't work at all:
// eg "(png|jpg|txt|)" regex matcher itself
wordRe matcher0("()", wordRe::REGEXP);
wordRe matcher1("(png|jpg|txt)", wordRe::REGEXP);
wordRe matcher2("(png|txt)", wordRe::REGEXP);
Info<<"Has extension(s):" << nl
<< "input: " << endWithDot << nl;
Info<<" " << matcher0 << " -> "
<< Switch(endWithDot.hasExt(matcher0)) << nl;
Info<<" " << matcher1 << " -> "
<< Switch(endWithDot.hasExt(matcher1)) << nl;
Info<<" " << matcher2 << " -> "
<< Switch(endWithDot.hasExt(matcher2)) << nl;
Info<< "input: " << input1 << nl;
Info<<" " << matcher0 << " -> "
<< Switch(input1.hasExt(matcher0)) << nl;
Info<<" " << matcher1 << " -> "
<< Switch(input1.hasExt(matcher1)) << nl;
Info<<" " << matcher2 << " -> "
<< Switch(input1.hasExt(matcher2)) << nl;
Info<< nl;
Info<<"Remove extension(s):" << nl << "input: " << input1 << nl;
while (!input1.empty())
{
if (input1.removeExt())
{
Info<< " -> " << input1 << nl;
}
else
{
Info<< "stop> " << input1 << nl;
break;
}
}
Info<< nl;
input0.clear();
Info<<"test with zero-sized: " << input0 << nl;
Info<<"add extension: " << input0.ext("abc") << nl;
Info<< nl;
input0 = "this/";
Info<<"test add after slash: " << input0 << nl;
Info<<"add extension: " << input0.ext("abc")
<< " <-- avoids accidentally creating hidden files" << nl;
Info<< nl;
input0 = "this.file.";
Info<<"test after dot: " << input0 << nl;
Info<<"add extension: " << input0.ext("abc")
<< " <-- No check for repeated dots (user error!)" << nl;
Info<< nl;
}
if (!defaultTests)
{
return 0;
}
DynamicList<word> wrdList
{
"hello",
"hello1",
"hello2",
"hello3",
"hello4.hmm"
};
fileName pathName(wrdList); fileName pathName(wrdList);
@ -191,7 +390,6 @@ int main()
} }
// test findEtcFile // test findEtcFile
Info<< "\n\nfindEtcFile tests:" << nl Info<< "\n\nfindEtcFile tests:" << nl
<< " controlDict => " << findEtcFile("controlDict") << nl << " controlDict => " << findEtcFile("controlDict") << nl

View File

@ -34,6 +34,8 @@ Description
#include "int.H" #include "int.H"
#include "uint.H" #include "uint.H"
#include "scalar.H" #include "scalar.H"
#include "Switch.H"
#include "stringList.H"
using namespace Foam; using namespace Foam;
@ -166,6 +168,76 @@ int main(int argc, char *argv[])
<< Foam::name("formatted >%08d<", val) << "\n"; << Foam::name("formatted >%08d<", val) << "\n";
} }
// test startsWith, endsWith methods
{
string empty; //;
string input1 = "shorter input";
string input2 = "longer input text";
stringList checks{"match", "long", "", "short", "text", "s", "l", "t"};
Info<< nl;
Info<< "check startsWith:" << nl
<< "~~~~~~~~~~~~~~~~~" << nl;
Info<<"input: " << empty << nl;
for (const string& test : checks)
{
Info<< " startsWith(" << test << ") = "
<< Switch(empty.startsWith(test)) << nl;
}
Info<<"input: " << input1 << nl;
for (const string& test : checks)
{
Info<< " startsWith(" << test << ") = "
<< Switch(input1.startsWith(test)) << nl;
}
Info<<"input: " << input2 << nl;
for (const string& test : checks)
{
Info<< " startsWith(" << test << ") = "
<< Switch(input2.startsWith(test)) << nl;
}
Info<< nl;
Info<< "check endsWith:" << nl
<< "~~~~~~~~~~~~~~~~~" << nl;
Info<<"input: " << empty << nl;
for (const string& test : checks)
{
Info<< " endsWith(" << test << ") = "
<< Switch(empty.endsWith(test)) << nl;
}
Info<<"input: " << input1 << nl;
for (const string& test : checks)
{
Info<< " endsWith(" << test << ") = "
<< Switch(input1.endsWith(test)) << nl;
}
Info<<"input: " << input2 << nl;
for (const string& test : checks)
{
Info<< " endsWith(" << test << ") = "
<< Switch(input2.endsWith(test)) << nl;
}
Info<< nl;
Info<< "check endsWith as applied to field names:" << nl
<< "~~~~~~~~~~~~~~~~~" << nl;
string input3 = "field_0";
string input4 = "_0";
Info<<input3 << " endsWith(\"_0\") = "
<< Switch(input3.endsWith("_0")) << nl;
Info<<input4 << " endsWith(\"_0\") = "
<< Switch(input4.endsWith("_0")) << nl;
}
Info<< "\nEnd\n" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -11,9 +11,8 @@ if (!fieldsToUse.found(fieldName))
{ {
variableGood = variableGood =
( (
fieldName.size() > 2 && fieldName(fieldName.size()-2, 2) == "_0" !fieldName.endsWith("_0")
? false && IOobject
: IOobject
( (
fieldName, fieldName,
timeDirs[n1].name(), timeDirs[n1].name(),

View File

@ -19,13 +19,9 @@ if (timeDirs.size())
const word& fieldName = obj.name(); const word& fieldName = obj.name();
const word& fieldType = obj.headerClassName(); const word& fieldType = obj.headerClassName();
if (fieldName.size() > 2 && fieldName(fieldName.size()-2, 2) == "_0") if (volFieldTypes.found(fieldType) && !fieldName.endsWith("_0"))
{ {
// ignore _0 fields // ignore types that we don't handle, and ignore _0 fields
}
else if (volFieldTypes.found(fieldType))
{
// simply ignore types that we don't handle
volumeFields.insert(fieldName, fieldType); volumeFields.insert(fieldName, fieldType);
} }
} }

View File

@ -169,7 +169,7 @@ void Foam::boundaryInfo::setType(const label patchI, const word& condition)
return; return;
} }
if (wordRe(".*[mM]apped.*", wordRe::DETECT).match(types_[patchI])) if (wordRe(".*[Mm]apped.*", wordRe::REGEXP).match(types_[patchI]))
{ {
// ugly hack to avoid overriding mapped types // ugly hack to avoid overriding mapped types
return; return;

View File

@ -26,30 +26,27 @@
# foamInstallationTest # foamInstallationTest
# #
# Description # Description
# Checks the machine system, the installation of OpenFOAM, and the user's # Check the machine system, the installation of OpenFOAM, and the user's
# personal configuration for running OpenFOAM. # personal configuration for running OpenFOAM.
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Base settings # Base settings
MIN_VERSION_GCC=4.5.0 MIN_VERSION_GCC=4.8.0
# General # General
WIDTH=20 WIDTH=20
# Global variables
fatalError=0
criticalError=0
# System variables # System variables
HOST=`uname -n` HOST=$(uname -n)
OSTYPE=`uname -s` OSTYPE=$(uname -s)
USER_NAME=$LOGNAME
: ${USER_NAME:=$USER}
# which OpenFOAM application to test for the Version # OpenFOAM application to test for the Version
foamTestApp=icoFoam foamTestApp=icoFoam
# Global variables
unset fatalError criticalError
#============================================================================== #==============================================================================
# HELPER FUNCTIONS # HELPER FUNCTIONS
#============================================================================== #==============================================================================
@ -68,43 +65,22 @@ heading()
} }
lenBase()
{
echo $1 | tr -d " " | wc -m | tr -d " "
}
length()
{
NOCHAR=`lenBase $1`
NOCHAR=`expr $NOCHAR - 1`
[ $NOCHAR -ge 0 ] || NOCHAR=0
echo $NOCHAR
}
stringLength()
{
echo $1 | wc -m | tr -d " "
}
fixlen() fixlen()
{ {
WORD=$1 WORD=$1
ONELEN=`stringLength $1` LDIFF=$(expr ${#WORD} - ${2:-4})
LDIFF=`expr $ONELEN - $2`
if [ $LDIFF -le 1 ] if [ $LDIFF -le 1 ]
then then
while [ $LDIFF -lt 0 ] while [ $LDIFF -lt 0 ]
do do
WORD="$WORD " WORD="$WORD "
LDIFF=`expr $LDIFF + 1` LDIFF=$(expr $LDIFF + 1)
done done
echo "$WORD" echo "$WORD"
else else
LDIFF=`expr $LDIFF + 4` LDIFF=$(expr $LDIFF + 4)
WORD=`echo "$WORD" | cut -c${LDIFF}-` WORD=$(echo "$WORD" | cut -c${LDIFF}-)
echo "...${WORD}" echo "...${WORD}"
fi fi
} }
@ -112,83 +88,54 @@ fixlen()
reportEnv() reportEnv()
{ {
EXP_ENV=`eval "echo $1"` eval EXP_ENV="$1"
EXP_PATH=`eval "echo $2"` eval EXP_PATH="$2"
CRIT="$3" CRIT="$3"
EXISTS=" no " EXISTS=" no "
ON_PATH="" ON_PATH=""
if [ `length $EXP_ENV` -gt 0 ]
if [ -n "$EXP_ENV" ]
then then
case "$OSTYPE" in if test -e "$EXP_ENV"
SunOS) then
if /usr/bin/test -e $EXP_ENV EXISTS=" yes "
if [ "$2" != noPath ]
then then
EXISTS=" yes " ON_PATH=" no "
if [ "$2" != noPath ] oldIFS=$IFS
then IFS=':'
ON_PATH=" no " for e in $EXP_PATH
oldIFS=$IFS do
IFS=':' case "$e" in
for e in $EXP_PATH "$EXP_ENV" | "$EXP_ENV/bin" | "$EXP_ENV/lib")
do ON_PATH="yes "
case "$e" in break
"$EXP_ENV" | "$EXP_ENV/bin" | "$EXP_ENV/lib") ;;
ON_PATH="yes " esac
;; done
esac IFS=$oldIFS
done else
IFS=$oldIFS CRIT=" $3"
else fi
CRIT=" $3" else
fi ON_PATH=" "
else fi
ON_PATH=" " echo "$(fixlen "$1" 21) $(fixlen "$EXP_ENV" 40) $EXISTS $ON_PATH $CRIT"
fi
echo "`fixlen "$1" 21` `fixlen "$EXP_ENV" 40` $EXISTS $ON_PATH $CRIT"
;;
*)
if [ -e "$EXP_ENV" ]
then
EXISTS=" yes "
if [ "$2" != noPath ]
then
ON_PATH=" no "
oldIFS=$IFS
IFS=':'
for e in $EXP_PATH
do
case "$e" in
"$EXP_ENV" | "$EXP_ENV/bin" | "$EXP_ENV/lib")
ON_PATH="yes "
;;
esac
done
IFS=$oldIFS
else
CRIT=" $3"
fi
else
ON_PATH=" "
fi
echo "`fixlen "$1" 21` `fixlen "$EXP_ENV" 40` $EXISTS $ON_PATH $CRIT"
;;
esac
else else
echo "`fixlen "$1" 21` --------- env variable not set --------- $3" echo "$(fixlen "$1" 21) --------- env variable not set --------- $3"
fi fi
ERROR="false" ERROR=false
if [ "$EXISTS" = no ] || [ "$ON_PATH" = no ] if [ "$EXISTS" = no ] || [ "$ON_PATH" = no ]
then then
ERROR="true" ERROR=true
fi fi
if [ "$3" = yes ] && [ "$ERROR" = true ] if [ "$3" = yes ] && [ "$ERROR" = true ]
then then
criticalError=`expr $criticalError + 1` criticalError="x${criticalError}"
echo "WARNING: CRITICAL ERROR" echo "WARNING: CRITICAL ERROR"
echo echo
fi fi
} }
@ -198,139 +145,149 @@ findExec()
IFS=':' IFS=':'
for d in $1 for d in $1
do do
case "$OSTYPE" in if test ! -d "$d/$2" -a -x "$d/$2"
SunOS) then
if /usr/bin/test ! -d "$d/$2" -a -x "$d/$2" IFS=$oldIFS
then echo "$d/$2"
IFS=$oldIFS return 0
echo "$d/$2" fi
return 0
fi
;;
*)
if [ ! -d "$d/$2" -a -x "$d/$2" ]
then
IFS=$oldIFS
echo "$d/$2"
return 0
fi
;;
esac
done done
IFS=$oldIFS IFS=$oldIFS
return 1 return 1
} }
# compare (required-version, version)
# Major.minor.patch <= Major.minor.patch
#
vercmp_3()
{
local arg1="$1"
local arg2="$2"
oldIFS=$IFS
IFS='.'
set -- $arg1
local arg1Major=$1 arg1Minor=$2 arg1Patch="${3:-0}"
set -- $arg2
local arg2Major=$1 arg2Minor=$2 arg2Patch="${3:-0}"
IFS=$oldIFS
#debug> echo "check $arg1 vs $arg2"
#debug> echo "arg1maj=$arg1Major arg1min=$arg1Minor arg1patch=$arg1Patch"
#debug> echo "arg2maj=$arg2Major arg2min=$arg2Minor arg2patch=$arg2Patch"
# Major version
if [ $arg1Major -lt $arg2Major ]
then
return 0
elif [ $arg1Major -gt $arg2Major ]
then
return 1
fi
# Minor version
if [ $arg1Minor -lt $arg2Minor ]
then
return 0
elif [ $arg1Minor -gt $arg2Minor ]
then
return 2
fi
# Patch
if [ -n "$arg1Patch" -a -n "$arg2Patch" ]
then
if [ "$arg1Patch" -gt "$arg2Patch" ]
then
return 3
fi
fi
return 0
}
reportExecutable() reportExecutable()
{ {
APP_PATH="" APP_NAME="$1"
APP_PATH=`findExec $PATH $1`
APP_SPEC="$2" APP_SPEC="$2"
if [ ! -n $APP_PATH ] APP_PATH="$(findExec $PATH $1)"
if [ -z "$APP_PATH" ]
then then
echo "`fixlen "$1" 9`" "*** not installed ***" echo "$(fixlen "$1" 9)" "*** not installed ***"
VERSION="" VERSION=""
case "$1" in case "$1" in
gcc* | $foamTestApp) gcc* | $foamTestApp)
echo " CRITICAL ERROR" echo " CRITICAL ERROR"
criticalError=`expr $criticalError + 1` criticalError="x${criticalError}"
;; ;;
esac esac
echo echo
return 1 return 1
fi fi
case "$1" in case "$APP_NAME" in
$foamTestApp) $foamTestApp)
VERSION=`$1 -case /dev/null 2>&1 \ VERSION=$($APP_NAME -case /dev/null 2>&1 \
| sed -ne 's/^.*Version: *\([^ ][^ ]*\).*/\1/p'` | sed -ne 's/^.*Version: *\([^ ][^ ]*\).*/\1/p')
;; ;;
flex) flex)
VERSION=`$1 --version /dev/null 2>&1 \ VERSION=$($APP_NAME --version /dev/null 2>&1 \
| sed -ne 's/flex \([0-9][0-9.]*\).*/\1/p' ` | sed -ne 's/flex \([0-9][0-9.]*\).*/\1/p')
;; ;;
gcc* | g++*) gcc* | g++*)
VERSION=`$1 -v 2>&1 \ VERSION=$($APP_NAME -v 2>&1 \
| sed -ne 's/^gcc version \([0-9][0-9.]*\).*/\1/p' ` | sed -ne 's/^gcc version \([0-9][0-9.]*\).*/\1/p')
case "$1" in if ! vercmp_3 "$MIN_VERSION_GCC" "$VERSION"
gcc*) then
BINARYCODENAME=gcc case "$APP_NAME" in
;; gcc*)
g++*) SHORT_NAME=gcc
BINARYCODENAME=g++ ;;
;; g++*)
esac SHORT_NAME=g++
;;
esac
MINV1=`echo $MIN_VERSION_GCC | cut -d. -f1` echo "ERROR: $SHORT_NAME version is too old for this release of OpenFOAM"
MINV2=`echo $MIN_VERSION_GCC | cut -d. -f2`
MINV3=`echo $MIN_VERSION_GCC | cut -d. -f3`
V1=`echo $VERSION | cut -d. -f1`
V2=`echo $VERSION | cut -d. -f2`
V3=`echo $VERSION | cut -d. -f3`
gccOK=""
pass=""
if [ $V1 -lt $MINV1 ]; then
gccOk="ERROR"
elif [ $V1 -gt $MINV1 ]; then
pass="yes"
fi
if [ "$pass" = "" ] && [ "$gccOk" = "" ]; then
if [ $V2 -lt $MINV2 ]; then
gccOk="ERROR"
elif [ $V2 -gt $MINV2 ]; then
pass="yes"
fi
fi
if [ "$pass" = "" ] && [ "$gccOk" = "" ] && [ $V3 != "" ] && [ $MINV3 != "" ]; then
if [ $V3 -lt $MINV3 ]; then
gccOk="ERROR"
fi
fi
if [ "$gccOk" != "" ]; then
echo "ERROR: $BINARYCODENAME version is too old for this release of OpenFOAM"
echo " User version : $VERSION" echo " User version : $VERSION"
echo " Minimum required: $MIN_VERSION_GCC" echo " Minimum required: $MIN_VERSION_GCC"
echo "" echo ""
fatalError=`expr $fatalError + 1` fatalError="x${fatalError}"
fi fi
;; ;;
gtar) gtar)
VERSION=`$APP_PATH --version | head -1` VERSION=$($APP_PATH --version | head -1)
;; ;;
tar) tar)
VERSION=`$APP_PATH --version | head -1 | cut -d" " -f4` VERSION=$($APP_PATH --version | head -1 | cut -d" " -f4)
;; ;;
gzip) gzip)
case "$OSTYPE" in case "$OSTYPE" in
SunOS) SunOS)
VERSION=`$1 --version 2>&1 | grep gzip | cut -d" " -f2` VERSION=$($APP_NAME --version 2>&1 | grep gzip | cut -d" " -f2)
;; ;;
*) *)
VERSION=`$1 --version | head -1 | cut -d" " -f2` VERSION=$($APP_NAME --version | head -1 | cut -d" " -f2)
;; ;;
esac esac
;; ;;
esac esac
if [ "$APP_PATH" = "$APP_SPEC" ] || [ ! "$2" ] if [ "$APP_PATH" = "$APP_SPEC" ] || [ -z "$APP_SPEC" ]
then then
echo "`fixlen "$1" 9` `fixlen "$VERSION" 10` `fixlen "$APP_PATH" 58`" echo "$(fixlen "$APP_NAME" 9) $(fixlen "$VERSION" 10) $(fixlen "$APP_PATH" 58)"
else else
echo "`fixlen "$1" 9` `fixlen "$VERSION" 10`" echo "$(fixlen "$APP_NAME" 9) $(fixlen "$VERSION" 10)"
echo "WARNING: Conflicting installations:" echo "WARNING: Conflicting installations:"
echo " OpenFOAM settings : $APP_SPEC" echo " OpenFOAM settings : $APP_SPEC"
echo " current path : $APP_PATH" echo " current path : $APP_PATH"
case "$1" in case "$APP_NAME" in
gcc | $foamTestApp) gcc | $foamTestApp)
echo " CRITICAL ERROR" echo " CRITICAL ERROR"
criticalError=`expr $criticalError + 1` criticalError="x${criticalError}"
;; ;;
esac esac
echo "" echo ""
@ -340,7 +297,9 @@ reportExecutable()
checkOpenFOAMEnvironment() checkOpenFOAMEnvironment()
{ {
[ -d "$WM_PROJECT_INST_DIR" ] && [ -d "$WM_THIRD_PARTY_DIR" ] || { [ -d "$WM_PROJECT_INST_DIR" ] && \
[ -d "$WM_PROJECT_DIR" ] && \
[ -d "$WM_THIRD_PARTY_DIR" ] || {
echo "" echo ""
echo "FATAL ERROR: OpenFOAM environment not configured." echo "FATAL ERROR: OpenFOAM environment not configured."
echo "" echo ""
@ -350,12 +309,15 @@ checkOpenFOAMEnvironment()
echo "" echo ""
exit 1 exit 1
} }
echo "$(fixlen OpenFOAM: $WIDTH) ${WM_PROJECT_DIR##*/}"
echo "$(fixlen ThirdParty: $WIDTH) ${WM_THIRD_PARTY_DIR##*/}"
} }
checkUserShell() checkUserShell()
{ {
echo "`fixlen Shell: $WIDTH` ${SHELL##*/}" echo "$(fixlen Shell: $WIDTH) ${SHELL##*/}"
case $SHELL in case $SHELL in
*/csh | */tcsh | */bash | */ksh) */csh | */tcsh | */bash | */ksh)
;; ;;
@ -364,7 +326,7 @@ checkUserShell()
echo " OpenFOAM ${WM_PROJECT_VERSION} is compatible with " echo " OpenFOAM ${WM_PROJECT_VERSION} is compatible with "
echo " csh, tcsh, ksh and bash." echo " csh, tcsh, ksh and bash."
echo echo
fatalError=`expr $fatalError + 1` fatalError="x${fatalError}"
;; ;;
esac esac
} }
@ -372,15 +334,15 @@ checkUserShell()
checkHostName() checkHostName()
{ {
echo "`fixlen Host: $WIDTH` $HOST" echo "$(fixlen Host: $WIDTH) $HOST"
if [ ! "$HOST" ] if [ -z "$HOST" ]
then then
echo "FATAL ERROR: Cannot stat hostname." echo "FATAL ERROR: Cannot stat hostname."
echo " Contact your system administrator, " echo " Contact your system administrator, "
echo " OpenFOAM ${WM_PROJECT_VERSION} needs a valid " echo " OpenFOAM ${WM_PROJECT_VERSION} needs a valid "
echo " hostname to function." echo " hostname to function."
echo echo
fatalError=`expr $fatalError + 1` fatalError="x${fatalError}"
fi fi
} }
@ -389,14 +351,14 @@ checkOS()
{ {
case "$OSTYPE" in case "$OSTYPE" in
Linux | LinuxAMD64 | SunOS ) Linux | LinuxAMD64 | SunOS )
echo "`fixlen OS: $WIDTH` $OSTYPE version $(uname -r)" echo "$(fixlen OS: $WIDTH) $OSTYPE version $(uname -r)"
;; ;;
*) *)
echo "FATAL ERROR: Incompatible operating system \"$OSTYPE\"." echo "FATAL ERROR: Incompatible operating system \"$OSTYPE\"."
echo " OpenFOAM ${FWM_PROJECT_VERSION} is currently " echo " OpenFOAM ${FWM_PROJECT_VERSION} is currently "
echo " available for Linux and SunOS only." echo " available for Linux and SunOS only."
echo echo
fatalError=`expr $fatalError + 1` fatalError="x${fatalError}"
;; ;;
esac esac
} }
@ -409,7 +371,7 @@ checkOS()
echo "Executing $0:" echo "Executing $0:"
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
heading "Checking basic setup..." heading "Basic setup :"
hline hline
checkOpenFOAMEnvironment checkOpenFOAMEnvironment
checkUserShell checkUserShell
@ -418,51 +380,48 @@ checkOS
hline hline
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
heading "Checking main OpenFOAM env variables..." heading "Main OpenFOAM env variables :"
COL1=`fixlen Environment_variable 21` COL1=$(fixlen EnvironmentVariable 21)
COL2=`fixlen Set_to_file_or_directory 40` COL2=$(fixlen FileOrDirectory 40)
COL3="Valid" COL3="Valid"
COL4="Path" COL4="Path"
COL5="Crit" COL5="Crit"
hline hline
echo "$COL1 $COL2 $COL3 $COL5" echo "$COL1 $COL2 $COL3 $COL5"
hline hline
reportEnv '$WM_PROJECT_INST_DIR' 'noPath' "yes" reportEnv '$WM_PROJECT_INST_DIR' noPath yes
reportEnv '$WM_PROJECT_USER_DIR' 'noPath' "no" reportEnv '$WM_PROJECT_USER_DIR' noPath no
reportEnv '$WM_THIRD_PARTY_DIR' 'noPath' "yes" reportEnv '$WM_THIRD_PARTY_DIR' noPath yes
hline hline
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
heading "Checking the OpenFOAM env variables set on the PATH..." heading "OpenFOAM env variables in PATH :"
hline hline
echo "$COL1 $COL2 $COL3 $COL4 $COL5" echo "$COL1 $COL2 $COL3 $COL4 $COL5"
hline hline
reportEnv '$WM_PROJECT_DIR' '$PATH' "yes" reportEnv '$WM_PROJECT_DIR' '$PATH' yes
echo "" echo ""
reportEnv '$FOAM_APPBIN' '$PATH' "yes" reportEnv '$FOAM_APPBIN' '$PATH' yes
reportEnv '$FOAM_SITE_APPBIN' '$PATH' "no" reportEnv '$FOAM_SITE_APPBIN' '$PATH' no
reportEnv '$FOAM_USER_APPBIN' '$PATH' "no" reportEnv '$FOAM_USER_APPBIN' '$PATH' no
reportEnv '$WM_DIR' '$PATH' "yes" reportEnv '$WM_DIR' '$PATH' yes
hline hline
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
heading "Checking the OpenFOAM env variables set on the LD_LIBRARY_PATH..." heading "OpenFOAM env variables in LD_LIBRARY_PATH :"
hline hline
echo "$COL1 $COL2 $COL3 $COL4 $COL5" echo "$COL1 $COL2 $COL3 $COL4 $COL5"
hline hline
reportEnv '$FOAM_LIBBIN' '$LD_LIBRARY_PATH' "yes" reportEnv '$FOAM_LIBBIN' '$LD_LIBRARY_PATH' yes
reportEnv '$FOAM_SITE_LIBBIN' '$LD_LIBRARY_PATH' "no" reportEnv '$FOAM_SITE_LIBBIN' '$LD_LIBRARY_PATH' no
reportEnv '$FOAM_USER_LIBBIN' '$LD_LIBRARY_PATH' "no" reportEnv '$FOAM_USER_LIBBIN' '$LD_LIBRARY_PATH' no
reportEnv '$MPI_ARCH_PATH' '$LD_LIBRARY_PATH' "yes" reportEnv '$MPI_ARCH_PATH' '$LD_LIBRARY_PATH' yes
hline hline
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
heading "Third party software" heading "Third-party software"
COL1=`fixlen Software 9`
COL2=`fixlen Version 10`
COL3=`fixlen Location 10`
hline hline
echo "$COL1 $COL2 $COL3" echo "$(fixlen Software 9) $(fixlen Version 10) $(fixlen Location 10)"
hline hline
reportExecutable flex reportExecutable flex
reportExecutable "$WM_CC" reportExecutable "$WM_CC"
@ -482,19 +441,19 @@ hline
heading "Summary" heading "Summary"
hline hline
if [ $fatalError -gt 0 ] if [ "${#fatalError}" -gt 0 ]
then then
echo "The system test has evoked $fatalError fatal error(s)." echo "The system test evoked ${#fatalError} fatal error(s)."
else else
echo "Base configuration ok." echo "Base configuration ok."
fi fi
if [ $criticalError -gt 0 ] if [ "${#criticalError}" -gt 0 ]
then then
echo "The foam installation contains $criticalError critical error(s)." echo "The foam installation contains ${#criticalError} critical error(s)."
else else
echo "Critical systems ok." echo "Critical systems ok."
fi fi
if [ $criticalError -gt 0 ] || [ $fatalError -gt 0 ] if [ "${#criticalError}" -gt 0 ] || [ "${#fatalError}" -gt 0 ]
then then
echo echo
echo "Review the output for warning messages and consult" echo "Review the output for warning messages and consult"

View File

@ -33,26 +33,28 @@ Description
#include "label.H" #include "label.H"
#include "scalar.H" #include "scalar.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// file-scope
// Hint about machine endian, OpenFOAM label and scalar sizes
static const std::string archHint =
(
#ifdef WM_LITTLE_ENDIAN
"LSB"
#elif defined (WM_BIG_ENDIAN)
"MSB"
#else
"???"
#endif
";label=" + std::to_string(8*sizeof(Foam::label))
+ ";scalar=" + std::to_string(8*sizeof(Foam::scalar))
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const
{ {
static std::string archHint;
// Hint about machine endian, OpenFOAM label and scalar sizes
if (archHint.empty())
{
#ifdef WM_LITTLE_ENDIAN
archHint.append("LSB;");
#elif defined (WM_BIG_ENDIAN)
archHint.append("MSB;");
#endif
archHint.append("label=");
archHint.append(std::to_string(8*sizeof(label)));
archHint.append(";scalar=");
archHint.append(std::to_string(8*sizeof(scalar)));
}
if (!os.good()) if (!os.good())
{ {
InfoInFunction InfoInFunction
@ -66,10 +68,14 @@ bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const
<< "FoamFile\n{\n" << "FoamFile\n{\n"
<< " version " << os.version() << ";\n" << " version " << os.version() << ";\n"
<< " format " << os.format() << ";\n" << " format " << os.format() << ";\n"
<< " arch " << archHint << ";\n"
<< " class " << type << ";\n"; << " class " << type << ";\n";
if (note().size()) if (os.format() == IOstream::BINARY)
{
os << " arch " << archHint << ";\n";
}
if (!note().empty())
{ {
os << " note " << note() << ";\n"; os << " note " << note() << ";\n";
} }

View File

@ -766,10 +766,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::storeOldTimes() const
( (
field0Ptr_ field0Ptr_
&& timeIndex_ != this->time().timeIndex() && timeIndex_ != this->time().timeIndex()
&& !( && !this->name().endsWith("_0")
this->name().size() > 2
&& this->name()(this->name().size()-2, 2) == "_0"
)
) )
{ {
storeOldTime(); storeOldTime();

View File

@ -158,6 +158,21 @@ void Foam::argList::noBanner()
} }
void Foam::argList::noFunctionObjects(bool addWithOption)
{
removeOption("noFunctionObjects");
if (addWithOption)
{
addBoolOption
(
"withFunctionObjects",
"execute functionObjects"
);
}
}
void Foam::argList::noParallel() void Foam::argList::noParallel()
{ {
removeOption("parallel"); removeOption("parallel");
@ -459,6 +474,9 @@ Foam::argList::argList
) )
) )
{ {
// If the option is known to require an argument,
// get it or emit a FatalError.
++argI; ++argI;
if (argI >= args_.size()) if (argI >= args_.size())
{ {
@ -475,6 +493,9 @@ Foam::argList::argList
} }
else else
{ {
// All other options (including unknown ones) are simply
// registered as existing.
options_.insert(optionName, ""); options_.insert(optionName, "");
} }
} }
@ -527,29 +548,31 @@ void Foam::argList::parse
// -help print the usage // -help print the usage
// -doc display application documentation in browser // -doc display application documentation in browser
// -srcDoc display source code in browser // -srcDoc display source code in browser
if
(
options_.found("help")
|| options_.found("doc")
|| options_.found("srcDoc")
)
{ {
bool quickExit = false;
if (options_.found("help")) if (options_.found("help"))
{ {
printUsage(); printUsage();
quickExit = true;
} }
// Only display one or the other // Only display one or the other
if (options_.found("srcDoc")) if (options_.found("srcDoc"))
{ {
displayDoc(true); displayDoc(true);
quickExit = true;
} }
else if (options_.found("doc")) else if (options_.found("doc"))
{ {
displayDoc(false); displayDoc(false);
quickExit = true;
} }
::exit(0); if (quickExit)
{
::exit(0);
}
} }
// Print the usage message and exit if the number of arguments is incorrect // Print the usage message and exit if the number of arguments is incorrect

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -348,6 +348,10 @@ public:
//- Disable emitting the banner information //- Disable emitting the banner information
static void noBanner(); static void noBanner();
//- Remove the 'noFunctionObjects' option,
// optionally adding a 'withFunctionObjects' option instead
static void noFunctionObjects(bool addWithOption = false);
//- Remove the parallel options //- Remove the parallel options
static void noParallel(); static void noParallel();

View File

@ -27,6 +27,7 @@ License
#include "wordList.H" #include "wordList.H"
#include "DynamicList.H" #include "DynamicList.H"
#include "OSspecific.H" #include "OSspecific.H"
#include "wordRe.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -37,11 +38,46 @@ const Foam::fileName Foam::fileName::null;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fileName::fileName(const wordList& lst) Foam::fileName::fileName(const UList<word>& lst)
{ {
forAll(lst, elemI) // Estimate overall size
size_type sz = lst.size();
for (const word& item : lst)
{ {
operator=((*this)/lst[elemI]); sz += item.size();
}
reserve(sz);
sz = 0;
for (const word& item : lst)
{
if (item.size())
{
if (sz++) operator+=('/');
operator+=(item);
}
}
}
Foam::fileName::fileName(std::initializer_list<word> lst)
{
// Estimate overall size
size_type sz = lst.size();
for (const word& item : lst)
{
sz += item.size();
}
reserve(sz);
sz = 0;
for (const word& item : lst)
{
if (item.size())
{
if (sz++) operator+=('/');
operator+=(item);
}
} }
} }
@ -268,9 +304,9 @@ Foam::fileName Foam::fileName::path() const
Foam::fileName Foam::fileName::lessExt() const Foam::fileName Foam::fileName::lessExt() const
{ {
size_type i = find_last_of("./"); size_type i = find_ext();
if (i == npos || i == 0 || operator[](i) == '/') if (i == npos)
{ {
return *this; return *this;
} }
@ -283,9 +319,9 @@ Foam::fileName Foam::fileName::lessExt() const
Foam::word Foam::fileName::ext() const Foam::word Foam::fileName::ext() const
{ {
size_type i = find_last_of("./"); size_type i = find_ext();
if (i == npos || i == 0 || operator[](i) == '/') if (i == npos)
{ {
return word::null; return word::null;
} }
@ -296,6 +332,71 @@ Foam::word Foam::fileName::ext() const
} }
Foam::fileName& Foam::fileName::ext(const word& ending)
{
if (!ending.empty() && !empty() && operator[](size()-1) != '/')
{
append(".");
append(ending);
}
return *this;
}
bool Foam::fileName::hasExt() const
{
return (find_ext() != npos);
}
bool Foam::fileName::hasExt(const word& ending) const
{
size_type i = find_ext();
if (i == npos)
{
return false;
}
++i; // Do next comparison *after* the dot
return
(
// Lengths must match
((size() - i) == ending.size())
&& !compare(i, npos, ending)
);
}
bool Foam::fileName::hasExt(const wordRe& ending) const
{
size_type i = find_ext();
if (i == npos)
{
return false;
}
std::string end = substr(i+1, npos);
return ending.match(end);
}
bool Foam::fileName::removeExt()
{
const size_type i = find_ext();
if (i == npos)
{
return false;
}
else
{
this->resize(i);
return true;
}
}
Foam::wordList Foam::fileName::components(const char delimiter) const Foam::wordList Foam::fileName::components(const char delimiter) const
{ {
DynamicList<word> wrdList(20); DynamicList<word> wrdList(20);

View File

@ -53,10 +53,11 @@ namespace Foam
{ {
template<class T> class List; template<class T> class List;
template<class T> class UList;
typedef List<word> wordList; typedef List<word> wordList;
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
class wordRe;
class fileName; class fileName;
Istream& operator>>(Istream&, fileName&); Istream& operator>>(Istream&, fileName&);
@ -73,6 +74,10 @@ class fileName
{ {
// Private Member Functions // Private Member Functions
//- Find position of the file extension dot, return npos on failure.
// A wrapped version of find_last_of("./") with additional logic.
inline size_type find_ext() const;
//- Strip invalid characters //- Strip invalid characters
inline void stripInvalid(); inline void stripInvalid();
@ -104,31 +109,35 @@ public:
inline fileName(); inline fileName();
//- Construct as copy //- Construct as copy
inline fileName(const fileName&); inline fileName(const fileName& fn);
//- Construct as copy of word //- Construct as copy of word
inline fileName(const word&); inline fileName(const word& s);
//- Construct as copy of string //- Construct as copy of string
inline fileName(const string&, const bool doStripInvalid=true); inline fileName(const string& s, const bool doStripInvalid=true);
//- Construct as copy of std::string //- Construct as copy of std::string
inline fileName(const std::string&, const bool doStripInvalid=true); inline fileName(const std::string& s, const bool doStripInvalid=true);
//- Construct as copy of character array //- Construct as copy of character array
inline fileName(const char*, const bool doStripInvalid=true); inline fileName(const char* s, const bool doStripInvalid=true);
//- Construct by concatenating elements of wordList separated by '/' //- Construct by concatenating elements of wordList separated by '/'
explicit fileName(const wordList&); explicit fileName(const UList<word>& lst);
//- Construct by concatenating words separated by '/'
explicit fileName(std::initializer_list<word> lst);
//- Construct from Istream //- Construct from Istream
fileName(Istream&); fileName(Istream& is);
// Member functions // Member functions
//- Is this character valid for a fileName? //- Is this character valid for a fileName?
inline static bool valid(char); inline static bool valid(char c);
//- Cleanup file name //- Cleanup file name
// //
@ -205,6 +214,24 @@ public:
//- Return file name extension (part after last .) //- Return file name extension (part after last .)
word ext() const; word ext() const;
//- Append a '.' and the ending, and return the object.
// The '.' and ending will not be added when the ending is empty,
// or when the file name is empty or ended with a '/'.
fileName& ext(const word& ending);
//- Return true if it has an extension or simply ends with a '.'
bool hasExt() const;
//- Return true if the extension is the same as the given ending.
bool hasExt(const word& ending) const;
//- Return true if the extension matches the given ending.
bool hasExt(const wordRe& ending) const;
//- Remove extension, returning true if string changed.
bool removeExt();
//- Return path components as wordList //- Return path components as wordList
// //
// Behaviour: // Behaviour:
@ -215,32 +242,46 @@ public:
// "foo/bar" 2("foo", "bar") // "foo/bar" 2("foo", "bar")
// "/foo/bar" 2("foo", "bar") // "/foo/bar" 2("foo", "bar")
// "/foo/bar/" 2("foo", "bar") // "/foo/bar/" 2("foo", "bar")
wordList components(const char delimiter='/') const; wordList components(const char delimiter = '/') const;
//- Return a single component of the path //- Return a single component of the path
word component(const size_type, const char delimiter='/') const; word component
(
const size_type cmpt,
const char delimiter = '/'
) const;
// Member operators // Member operators
// Assignment // Assignment
void operator=(const fileName&); //- Copy, no character validation required
void operator=(const word&); void operator=(const fileName& str);
void operator=(const string&);
void operator=(const std::string&); //- Copy, no character validation required
void operator=(const char*); void operator=(const word& str);
//- Copy, stripping invalid characters
void operator=(const string& str);
//- Copy, stripping invalid characters
void operator=(const std::string& str);
//- Copy, stripping invalid characters
void operator=(const char* str);
// IOstream operators // IOstream operators
friend Istream& operator>>(Istream&, fileName&); friend Istream& operator>>(Istream& is, fileName& fn);
friend Ostream& operator<<(Ostream&, const fileName&); friend Ostream& operator<<(Ostream& os, const fileName& fn);
}; };
//- Assemble words and fileNames as pathnames by adding a '/' separator //- Assemble words and fileNames as pathnames by adding a '/' separator.
fileName operator/(const string&, const string&); // No '/' separator is added if either argument is an empty string.
fileName operator/(const string& a, const string& b);
//- Recursively search the given directory for the file //- Recursively search the given directory for the file

View File

@ -25,6 +25,21 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline std::string::size_type Foam::fileName::find_ext() const
{
const size_type i = find_last_of("./");
if (i == npos || i == 0 || operator[](i) == '/')
{
return npos;
}
else
{
return i;
}
}
inline void Foam::fileName::stripInvalid() inline void Foam::fileName::stripInvalid()
{ {
// skip stripping unless debug is active to avoid // skip stripping unless debug is active to avoid

View File

@ -78,5 +78,3 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const fileName& fn)
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,7 +26,6 @@ License
#include "string.H" #include "string.H"
#include "stringOps.H" #include "stringOps.H"
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
const char* const Foam::string::typeName = "string"; const char* const Foam::string::typeName = "string";
@ -168,4 +167,30 @@ Foam::string Foam::string::removeTrailing(const char character) const
} }
bool Foam::string::startsWith(const std::string& text) const
{
const size_type strLen = this->size();
const size_type txtLen = text.size();
return
(
!txtLen
|| (strLen >= txtLen && !compare(0, txtLen, text))
);
}
bool Foam::string::endsWith(const std::string& text) const
{
const size_type strLen = this->size();
const size_type txtLen = text.size();
return
(
!txtLen
|| (strLen >= txtLen && !compare(strLen - txtLen, npos, text))
);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -104,49 +104,53 @@ public:
inline string(); inline string();
//- Construct from std::string //- Construct from std::string
inline string(const std::string&); inline string(const std::string& str);
//- Construct as copy of character array //- Construct as copy of character array
inline string(const char*); inline string(const char* str);
//- Construct as copy of specified number of characters //- Construct as copy of specified number of characters
inline string(const char*, const size_type); inline string(const char* str, const size_type len);
//- Construct from a single character //- Construct from a single character
inline string(const char); inline string(const char c);
//- Construct from Istream //- Construct from Istream
string(Istream&); string(Istream& is);
// Member Functions // Member Functions
//- Count and return the number of a given character in the string //- Count and return the number of a given character in the string
size_type count(const char) const; size_type count(const char c) const;
//- Is this string type valid? //- Is this string type valid?
template<class String> template<class String>
static inline bool valid(const string&); static inline bool valid(const string& str);
//- Does this string have particular meta-characters? //- Does this string have particular meta-characters?
// The meta characters can be optionally quoted. // The meta characters can be optionally quoted.
template<class String> template<class String>
static inline bool meta(const string&, const char quote='\\'); static inline bool meta(const string& str, const char quote = '\\');
//- Strip invalid characters from the given string //- Strip invalid characters from the given string
template<class String> template<class String>
static inline bool stripInvalid(string&); static inline bool stripInvalid(string& str);
//- Return a valid String from the given string //- Return a valid String from the given string
template<class String> template<class String>
static inline String validate(const string&); static inline String validate(const string& str);
//- Return a String with quoted meta-characters from the given string //- Return a String with quoted meta-characters from the given string
template<class String> template<class String>
static inline string quotemeta(const string&, const char quote='\\'); static inline string quotemeta
(
const string& str,
const char quote = '\\'
);
//- True when strings match literally //- True when strings match literally
inline bool match(const std::string&) const; inline bool match(const std::string& str) const;
//- Avoid masking the normal std::string replace //- Avoid masking the normal std::string replace
using std::string::replace; using std::string::replace;
@ -186,16 +190,26 @@ public:
string& expand(const bool allowEmpty = false); string& expand(const bool allowEmpty = false);
//- Remove repeated characters returning true if string changed //- Remove repeated characters returning true if string changed
bool removeRepeated(const char); bool removeRepeated(const char character);
//- Return string with repeated characters removed //- Return string with repeated characters removed
string removeRepeated(const char) const; string removeRepeated(const char character) const;
//- Remove trailing character returning true if string changed //- Remove trailing character returning true if string changed
bool removeTrailing(const char); bool removeTrailing(const char character);
//- Return string with trailing character removed //- Return string with trailing character removed
string removeTrailing(const char) const; string removeTrailing(const char character) const;
//- True if the string starts with the given text.
// Always true if the given text is empty or if the string
// is identical to the given text.
bool startsWith(const std::string& text) const;
//- True if the string ends with the given text.
// Always true if the given text is empty or if the string
// is identical to the given text.
bool endsWith(const std::string& text) const;
// Member Operators // Member Operators
@ -216,8 +230,8 @@ public:
// IOstream Operators // IOstream Operators
friend Istream& operator>>(Istream&, string&); friend Istream& operator>>(Istream& is, string& s);
friend Ostream& operator<<(Ostream&, const string&); friend Ostream& operator<<(Ostream& os, const string& s);
}; };

View File

@ -95,12 +95,12 @@ public:
// Note that 'REGEXP' is implicit if 'NOCASE' is specified alone. // Note that 'REGEXP' is implicit if 'NOCASE' is specified alone.
enum compOption enum compOption
{ {
LITERAL = 0, //!< treat as a string literal LITERAL = 0, //!< Treat as a string literal
DETECT = 1, //!< treat as regular expression DETECT = 1, //!< Detect if the string contains meta-characters
REGEXP = 2, //!< detect if the string contains meta-characters REGEXP = 2, //!< Treat as regular expression
NOCASE = 4, //!< ignore case in regular expression NOCASE = 4, //!< Ignore case in regular expression
DETECT_NOCASE = DETECT | NOCASE, DETECT_NOCASE = DETECT | NOCASE, //!< Combined DETECT and NOCASE
REGEXP_NOCASE = REGEXP | NOCASE REGEXP_NOCASE = REGEXP | NOCASE //!< Combined REGEXP and NOCASE
}; };

View File

@ -25,7 +25,7 @@ stopAt endTime;
endTime 18000; endTime 18000;
deltaT 10; deltaT 1;
writeControl adjustableRunTime; writeControl adjustableRunTime;
@ -49,4 +49,8 @@ adjustTimeStep yes;
maxCo 15; maxCo 15;
maxDeltaT 10;
maxDi 0.25;
// ************************************************************************* // // ************************************************************************* //

View File

@ -43,7 +43,7 @@ options
} }
} }
} }
/*
momentumSource1 momentumSource1
{ {
type vectorSemiImplicitSource; type vectorSemiImplicitSource;
@ -55,11 +55,11 @@ options
volumeMode absolute; volumeMode absolute;
injectionRateSuSp injectionRateSuSp
{ {
U.steam ((0 1e-1 0) 0); // kg*m/s^2 U.steam ((0 1e-2 0) 0); // kg*m/s^2
} }
} }
} }
*/
energySource1 energySource1
{ {
type scalarSemiImplicitSource; type scalarSemiImplicitSource;