mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop
This commit is contained in:
@ -1,10 +1,9 @@
|
||||
Info<< "Reading thermophysical properties\n" << endl;
|
||||
|
||||
autoPtr<psiThermo> pThermo
|
||||
autoPtr<rhoThermo> pThermo
|
||||
(
|
||||
psiThermo::New(mesh)
|
||||
rhoThermo::New(mesh)
|
||||
);
|
||||
psiThermo& thermo = pThermo();
|
||||
rhoThermo& thermo = pThermo();
|
||||
thermo.validate(args.executable(), "h", "e");
|
||||
|
||||
volScalarField rho
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
{
|
||||
//const volScalarField& psi = thermo.psi();
|
||||
|
||||
volScalarField rAU(1.0/UEqn.A());
|
||||
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU));
|
||||
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
|
||||
@ -93,6 +95,9 @@
|
||||
rho = max(rho, rhoMin);
|
||||
rho = min(rho, rhoMax);
|
||||
|
||||
thermo.rho() = max(thermo.rho(), rhoMin);
|
||||
thermo.rho() = min(thermo.rho(), rhoMax);
|
||||
|
||||
if (!simple.transonic())
|
||||
{
|
||||
rho.relax();
|
||||
|
||||
@ -109,6 +109,8 @@ if (closedVolume)
|
||||
rho = thermo.rho();
|
||||
rho = max(rho, rhoMin);
|
||||
rho = min(rho, rhoMax);
|
||||
thermo.rho() = max(thermo.rho(), rhoMin);
|
||||
thermo.rho() = min(thermo.rho(), rhoMax);
|
||||
|
||||
if (!simple.transonic())
|
||||
{
|
||||
|
||||
@ -86,6 +86,10 @@
|
||||
rho = thermo.rho();
|
||||
rho = max(rho, rhoMin);
|
||||
rho = min(rho, rhoMax);
|
||||
|
||||
thermo.rho() = max(thermo.rho(), rhoMin);
|
||||
thermo.rho() = min(thermo.rho(), rhoMax);
|
||||
|
||||
rho.relax();
|
||||
Info<< "rho max/min : "
|
||||
<< max(rho).value() << " "
|
||||
|
||||
@ -33,7 +33,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "psiThermo.H"
|
||||
#include "rhoThermo.H"
|
||||
#include "turbulentFluidThermoModel.H"
|
||||
#include "simpleControl.H"
|
||||
#include "fvOptions.H"
|
||||
|
||||
@ -29,26 +29,225 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "fileName.H"
|
||||
#include "SubList.H"
|
||||
#include "DynamicList.H"
|
||||
#include "IOobject.H"
|
||||
#include "IOstreams.H"
|
||||
#include "OSspecific.H"
|
||||
#include "POSIX.H"
|
||||
#include "Switch.H"
|
||||
#include "etcFiles.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main()
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
wordList wrdList(5);
|
||||
wrdList[0] = "hello";
|
||||
wrdList[1] = "hello1";
|
||||
wrdList[2] = "hello2";
|
||||
wrdList[3] = "hello3";
|
||||
wrdList[4] = "hello4.hmm";
|
||||
argList::noParallel();
|
||||
argList::addBoolOption("ext", "test handing of file extensions");
|
||||
argList::addBoolOption("construct", "test constructors");
|
||||
argList::addBoolOption("default", "reinstate default tests");
|
||||
argList::addNote("runs default tests or specified ones only");
|
||||
|
||||
#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);
|
||||
|
||||
@ -191,7 +390,6 @@ int main()
|
||||
}
|
||||
|
||||
|
||||
|
||||
// test findEtcFile
|
||||
Info<< "\n\nfindEtcFile tests:" << nl
|
||||
<< " controlDict => " << findEtcFile("controlDict") << nl
|
||||
|
||||
@ -34,6 +34,8 @@ Description
|
||||
#include "int.H"
|
||||
#include "uint.H"
|
||||
#include "scalar.H"
|
||||
#include "Switch.H"
|
||||
#include "stringList.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -166,6 +168,76 @@ int main(int argc, char *argv[])
|
||||
<< 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;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -11,9 +11,8 @@ if (!fieldsToUse.found(fieldName))
|
||||
{
|
||||
variableGood =
|
||||
(
|
||||
fieldName.size() > 2 && fieldName(fieldName.size()-2, 2) == "_0"
|
||||
? false
|
||||
: IOobject
|
||||
!fieldName.endsWith("_0")
|
||||
&& IOobject
|
||||
(
|
||||
fieldName,
|
||||
timeDirs[n1].name(),
|
||||
|
||||
@ -19,13 +19,9 @@ if (timeDirs.size())
|
||||
const word& fieldName = obj.name();
|
||||
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
|
||||
}
|
||||
else if (volFieldTypes.found(fieldType))
|
||||
{
|
||||
// simply ignore types that we don't handle
|
||||
// ignore types that we don't handle, and ignore _0 fields
|
||||
volumeFields.insert(fieldName, fieldType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ void Foam::boundaryInfo::setType(const label patchI, const word& condition)
|
||||
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
|
||||
return;
|
||||
|
||||
@ -26,30 +26,27 @@
|
||||
# foamInstallationTest
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Base settings
|
||||
MIN_VERSION_GCC=4.5.0
|
||||
MIN_VERSION_GCC=4.8.0
|
||||
|
||||
# General
|
||||
WIDTH=20
|
||||
|
||||
# Global variables
|
||||
fatalError=0
|
||||
criticalError=0
|
||||
|
||||
# System variables
|
||||
HOST=`uname -n`
|
||||
OSTYPE=`uname -s`
|
||||
USER_NAME=$LOGNAME
|
||||
: ${USER_NAME:=$USER}
|
||||
HOST=$(uname -n)
|
||||
OSTYPE=$(uname -s)
|
||||
|
||||
# which OpenFOAM application to test for the Version
|
||||
# OpenFOAM application to test for the Version
|
||||
foamTestApp=icoFoam
|
||||
|
||||
# Global variables
|
||||
unset fatalError criticalError
|
||||
|
||||
#==============================================================================
|
||||
# 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()
|
||||
{
|
||||
WORD=$1
|
||||
ONELEN=`stringLength $1`
|
||||
LDIFF=`expr $ONELEN - $2`
|
||||
LDIFF=$(expr ${#WORD} - ${2:-4})
|
||||
|
||||
if [ $LDIFF -le 1 ]
|
||||
then
|
||||
while [ $LDIFF -lt 0 ]
|
||||
do
|
||||
WORD="$WORD "
|
||||
LDIFF=`expr $LDIFF + 1`
|
||||
LDIFF=$(expr $LDIFF + 1)
|
||||
done
|
||||
echo "$WORD"
|
||||
else
|
||||
LDIFF=`expr $LDIFF + 4`
|
||||
WORD=`echo "$WORD" | cut -c${LDIFF}-`
|
||||
LDIFF=$(expr $LDIFF + 4)
|
||||
WORD=$(echo "$WORD" | cut -c${LDIFF}-)
|
||||
echo "...${WORD}"
|
||||
fi
|
||||
}
|
||||
@ -112,83 +88,54 @@ fixlen()
|
||||
|
||||
reportEnv()
|
||||
{
|
||||
EXP_ENV=`eval "echo $1"`
|
||||
EXP_PATH=`eval "echo $2"`
|
||||
eval EXP_ENV="$1"
|
||||
eval EXP_PATH="$2"
|
||||
CRIT="$3"
|
||||
EXISTS=" no "
|
||||
ON_PATH=""
|
||||
if [ `length $EXP_ENV` -gt 0 ]
|
||||
|
||||
if [ -n "$EXP_ENV" ]
|
||||
then
|
||||
case "$OSTYPE" in
|
||||
SunOS)
|
||||
if /usr/bin/test -e $EXP_ENV
|
||||
if test -e "$EXP_ENV"
|
||||
then
|
||||
EXISTS=" yes "
|
||||
if [ "$2" != noPath ]
|
||||
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"
|
||||
;;
|
||||
*)
|
||||
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
|
||||
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 "
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
IFS=$oldIFS
|
||||
else
|
||||
CRIT=" $3"
|
||||
fi
|
||||
else
|
||||
ON_PATH=" "
|
||||
fi
|
||||
echo "$(fixlen "$1" 21) $(fixlen "$EXP_ENV" 40) $EXISTS $ON_PATH $CRIT"
|
||||
else
|
||||
echo "`fixlen "$1" 21` --------- env variable not set --------- $3"
|
||||
echo "$(fixlen "$1" 21) --------- env variable not set --------- $3"
|
||||
fi
|
||||
|
||||
ERROR="false"
|
||||
ERROR=false
|
||||
if [ "$EXISTS" = no ] || [ "$ON_PATH" = no ]
|
||||
then
|
||||
ERROR="true"
|
||||
ERROR=true
|
||||
fi
|
||||
if [ "$3" = yes ] && [ "$ERROR" = true ]
|
||||
then
|
||||
criticalError=`expr $criticalError + 1`
|
||||
criticalError="x${criticalError}"
|
||||
echo "WARNING: CRITICAL ERROR"
|
||||
echo
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -198,139 +145,149 @@ findExec()
|
||||
IFS=':'
|
||||
for d in $1
|
||||
do
|
||||
case "$OSTYPE" in
|
||||
SunOS)
|
||||
if /usr/bin/test ! -d "$d/$2" -a -x "$d/$2"
|
||||
then
|
||||
IFS=$oldIFS
|
||||
echo "$d/$2"
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [ ! -d "$d/$2" -a -x "$d/$2" ]
|
||||
then
|
||||
IFS=$oldIFS
|
||||
echo "$d/$2"
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if test ! -d "$d/$2" -a -x "$d/$2"
|
||||
then
|
||||
IFS=$oldIFS
|
||||
echo "$d/$2"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
IFS=$oldIFS
|
||||
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()
|
||||
{
|
||||
APP_PATH=""
|
||||
APP_PATH=`findExec $PATH $1`
|
||||
APP_NAME="$1"
|
||||
APP_SPEC="$2"
|
||||
if [ ! -n $APP_PATH ]
|
||||
APP_PATH="$(findExec $PATH $1)"
|
||||
if [ -z "$APP_PATH" ]
|
||||
then
|
||||
echo "`fixlen "$1" 9`" "*** not installed ***"
|
||||
echo "$(fixlen "$1" 9)" "*** not installed ***"
|
||||
VERSION=""
|
||||
case "$1" in
|
||||
gcc* | $foamTestApp)
|
||||
echo " CRITICAL ERROR"
|
||||
criticalError=`expr $criticalError + 1`
|
||||
criticalError="x${criticalError}"
|
||||
;;
|
||||
esac
|
||||
echo
|
||||
return 1
|
||||
fi
|
||||
case "$1" in
|
||||
case "$APP_NAME" in
|
||||
$foamTestApp)
|
||||
VERSION=`$1 -case /dev/null 2>&1 \
|
||||
| sed -ne 's/^.*Version: *\([^ ][^ ]*\).*/\1/p'`
|
||||
VERSION=$($APP_NAME -case /dev/null 2>&1 \
|
||||
| sed -ne 's/^.*Version: *\([^ ][^ ]*\).*/\1/p')
|
||||
;;
|
||||
flex)
|
||||
VERSION=`$1 --version /dev/null 2>&1 \
|
||||
| sed -ne 's/flex \([0-9][0-9.]*\).*/\1/p' `
|
||||
VERSION=$($APP_NAME --version /dev/null 2>&1 \
|
||||
| sed -ne 's/flex \([0-9][0-9.]*\).*/\1/p')
|
||||
;;
|
||||
gcc* | g++*)
|
||||
VERSION=`$1 -v 2>&1 \
|
||||
| sed -ne 's/^gcc version \([0-9][0-9.]*\).*/\1/p' `
|
||||
VERSION=$($APP_NAME -v 2>&1 \
|
||||
| sed -ne 's/^gcc version \([0-9][0-9.]*\).*/\1/p')
|
||||
|
||||
case "$1" in
|
||||
gcc*)
|
||||
BINARYCODENAME=gcc
|
||||
;;
|
||||
g++*)
|
||||
BINARYCODENAME=g++
|
||||
;;
|
||||
esac
|
||||
if ! vercmp_3 "$MIN_VERSION_GCC" "$VERSION"
|
||||
then
|
||||
case "$APP_NAME" in
|
||||
gcc*)
|
||||
SHORT_NAME=gcc
|
||||
;;
|
||||
g++*)
|
||||
SHORT_NAME=g++
|
||||
;;
|
||||
esac
|
||||
|
||||
MINV1=`echo $MIN_VERSION_GCC | cut -d. -f1`
|
||||
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 "ERROR: $SHORT_NAME version is too old for this release of OpenFOAM"
|
||||
echo " User version : $VERSION"
|
||||
echo " Minimum required: $MIN_VERSION_GCC"
|
||||
echo ""
|
||||
fatalError=`expr $fatalError + 1`
|
||||
fatalError="x${fatalError}"
|
||||
fi
|
||||
|
||||
;;
|
||||
gtar)
|
||||
VERSION=`$APP_PATH --version | head -1`
|
||||
VERSION=$($APP_PATH --version | head -1)
|
||||
;;
|
||||
tar)
|
||||
VERSION=`$APP_PATH --version | head -1 | cut -d" " -f4`
|
||||
VERSION=$($APP_PATH --version | head -1 | cut -d" " -f4)
|
||||
;;
|
||||
gzip)
|
||||
case "$OSTYPE" in
|
||||
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
|
||||
if [ "$APP_PATH" = "$APP_SPEC" ] || [ ! "$2" ]
|
||||
if [ "$APP_PATH" = "$APP_SPEC" ] || [ -z "$APP_SPEC" ]
|
||||
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
|
||||
echo "`fixlen "$1" 9` `fixlen "$VERSION" 10`"
|
||||
echo "$(fixlen "$APP_NAME" 9) $(fixlen "$VERSION" 10)"
|
||||
echo "WARNING: Conflicting installations:"
|
||||
echo " OpenFOAM settings : $APP_SPEC"
|
||||
echo " current path : $APP_PATH"
|
||||
case "$1" in
|
||||
case "$APP_NAME" in
|
||||
gcc | $foamTestApp)
|
||||
echo " CRITICAL ERROR"
|
||||
criticalError=`expr $criticalError + 1`
|
||||
criticalError="x${criticalError}"
|
||||
;;
|
||||
esac
|
||||
echo ""
|
||||
@ -340,7 +297,9 @@ reportExecutable()
|
||||
|
||||
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 "FATAL ERROR: OpenFOAM environment not configured."
|
||||
echo ""
|
||||
@ -350,12 +309,15 @@ checkOpenFOAMEnvironment()
|
||||
echo ""
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "$(fixlen OpenFOAM: $WIDTH) ${WM_PROJECT_DIR##*/}"
|
||||
echo "$(fixlen ThirdParty: $WIDTH) ${WM_THIRD_PARTY_DIR##*/}"
|
||||
}
|
||||
|
||||
|
||||
checkUserShell()
|
||||
{
|
||||
echo "`fixlen Shell: $WIDTH` ${SHELL##*/}"
|
||||
echo "$(fixlen Shell: $WIDTH) ${SHELL##*/}"
|
||||
case $SHELL in
|
||||
*/csh | */tcsh | */bash | */ksh)
|
||||
;;
|
||||
@ -364,7 +326,7 @@ checkUserShell()
|
||||
echo " OpenFOAM ${WM_PROJECT_VERSION} is compatible with "
|
||||
echo " csh, tcsh, ksh and bash."
|
||||
echo
|
||||
fatalError=`expr $fatalError + 1`
|
||||
fatalError="x${fatalError}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
@ -372,15 +334,15 @@ checkUserShell()
|
||||
|
||||
checkHostName()
|
||||
{
|
||||
echo "`fixlen Host: $WIDTH` $HOST"
|
||||
if [ ! "$HOST" ]
|
||||
echo "$(fixlen Host: $WIDTH) $HOST"
|
||||
if [ -z "$HOST" ]
|
||||
then
|
||||
echo "FATAL ERROR: Cannot stat hostname."
|
||||
echo " Contact your system administrator, "
|
||||
echo " OpenFOAM ${WM_PROJECT_VERSION} needs a valid "
|
||||
echo " hostname to function."
|
||||
echo
|
||||
fatalError=`expr $fatalError + 1`
|
||||
fatalError="x${fatalError}"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -389,14 +351,14 @@ checkOS()
|
||||
{
|
||||
case "$OSTYPE" in
|
||||
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 " OpenFOAM ${FWM_PROJECT_VERSION} is currently "
|
||||
echo " available for Linux and SunOS only."
|
||||
echo
|
||||
fatalError=`expr $fatalError + 1`
|
||||
fatalError="x${fatalError}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
@ -409,7 +371,7 @@ checkOS()
|
||||
echo "Executing $0:"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
heading "Checking basic setup..."
|
||||
heading "Basic setup :"
|
||||
hline
|
||||
checkOpenFOAMEnvironment
|
||||
checkUserShell
|
||||
@ -418,51 +380,48 @@ checkOS
|
||||
hline
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
heading "Checking main OpenFOAM env variables..."
|
||||
COL1=`fixlen Environment_variable 21`
|
||||
COL2=`fixlen Set_to_file_or_directory 40`
|
||||
heading "Main OpenFOAM env variables :"
|
||||
COL1=$(fixlen EnvironmentVariable 21)
|
||||
COL2=$(fixlen FileOrDirectory 40)
|
||||
COL3="Valid"
|
||||
COL4="Path"
|
||||
COL5="Crit"
|
||||
hline
|
||||
echo "$COL1 $COL2 $COL3 $COL5"
|
||||
hline
|
||||
reportEnv '$WM_PROJECT_INST_DIR' 'noPath' "yes"
|
||||
reportEnv '$WM_PROJECT_USER_DIR' 'noPath' "no"
|
||||
reportEnv '$WM_THIRD_PARTY_DIR' 'noPath' "yes"
|
||||
reportEnv '$WM_PROJECT_INST_DIR' noPath yes
|
||||
reportEnv '$WM_PROJECT_USER_DIR' noPath no
|
||||
reportEnv '$WM_THIRD_PARTY_DIR' noPath yes
|
||||
hline
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
heading "Checking the OpenFOAM env variables set on the PATH..."
|
||||
heading "OpenFOAM env variables in PATH :"
|
||||
hline
|
||||
echo "$COL1 $COL2 $COL3 $COL4 $COL5"
|
||||
hline
|
||||
reportEnv '$WM_PROJECT_DIR' '$PATH' "yes"
|
||||
reportEnv '$WM_PROJECT_DIR' '$PATH' yes
|
||||
echo ""
|
||||
reportEnv '$FOAM_APPBIN' '$PATH' "yes"
|
||||
reportEnv '$FOAM_SITE_APPBIN' '$PATH' "no"
|
||||
reportEnv '$FOAM_USER_APPBIN' '$PATH' "no"
|
||||
reportEnv '$WM_DIR' '$PATH' "yes"
|
||||
reportEnv '$FOAM_APPBIN' '$PATH' yes
|
||||
reportEnv '$FOAM_SITE_APPBIN' '$PATH' no
|
||||
reportEnv '$FOAM_USER_APPBIN' '$PATH' no
|
||||
reportEnv '$WM_DIR' '$PATH' yes
|
||||
hline
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
heading "Checking the OpenFOAM env variables set on the LD_LIBRARY_PATH..."
|
||||
heading "OpenFOAM env variables in LD_LIBRARY_PATH :"
|
||||
hline
|
||||
echo "$COL1 $COL2 $COL3 $COL4 $COL5"
|
||||
hline
|
||||
reportEnv '$FOAM_LIBBIN' '$LD_LIBRARY_PATH' "yes"
|
||||
reportEnv '$FOAM_SITE_LIBBIN' '$LD_LIBRARY_PATH' "no"
|
||||
reportEnv '$FOAM_USER_LIBBIN' '$LD_LIBRARY_PATH' "no"
|
||||
reportEnv '$MPI_ARCH_PATH' '$LD_LIBRARY_PATH' "yes"
|
||||
reportEnv '$FOAM_LIBBIN' '$LD_LIBRARY_PATH' yes
|
||||
reportEnv '$FOAM_SITE_LIBBIN' '$LD_LIBRARY_PATH' no
|
||||
reportEnv '$FOAM_USER_LIBBIN' '$LD_LIBRARY_PATH' no
|
||||
reportEnv '$MPI_ARCH_PATH' '$LD_LIBRARY_PATH' yes
|
||||
hline
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
heading "Third party software"
|
||||
COL1=`fixlen Software 9`
|
||||
COL2=`fixlen Version 10`
|
||||
COL3=`fixlen Location 10`
|
||||
heading "Third-party software"
|
||||
hline
|
||||
echo "$COL1 $COL2 $COL3"
|
||||
echo "$(fixlen Software 9) $(fixlen Version 10) $(fixlen Location 10)"
|
||||
hline
|
||||
reportExecutable flex
|
||||
reportExecutable "$WM_CC"
|
||||
@ -482,19 +441,19 @@ hline
|
||||
heading "Summary"
|
||||
hline
|
||||
|
||||
if [ $fatalError -gt 0 ]
|
||||
if [ "${#fatalError}" -gt 0 ]
|
||||
then
|
||||
echo "The system test has evoked $fatalError fatal error(s)."
|
||||
echo "The system test evoked ${#fatalError} fatal error(s)."
|
||||
else
|
||||
echo "Base configuration ok."
|
||||
fi
|
||||
if [ $criticalError -gt 0 ]
|
||||
if [ "${#criticalError}" -gt 0 ]
|
||||
then
|
||||
echo "The foam installation contains $criticalError critical error(s)."
|
||||
echo "The foam installation contains ${#criticalError} critical error(s)."
|
||||
else
|
||||
echo "Critical systems ok."
|
||||
fi
|
||||
if [ $criticalError -gt 0 ] || [ $fatalError -gt 0 ]
|
||||
if [ "${#criticalError}" -gt 0 ] || [ "${#fatalError}" -gt 0 ]
|
||||
then
|
||||
echo
|
||||
echo "Review the output for warning messages and consult"
|
||||
|
||||
@ -33,26 +33,28 @@ Description
|
||||
#include "label.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
|
||||
{
|
||||
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())
|
||||
{
|
||||
InfoInFunction
|
||||
@ -66,10 +68,14 @@ bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const
|
||||
<< "FoamFile\n{\n"
|
||||
<< " version " << os.version() << ";\n"
|
||||
<< " format " << os.format() << ";\n"
|
||||
<< " arch " << archHint << ";\n"
|
||||
<< " class " << type << ";\n";
|
||||
|
||||
if (note().size())
|
||||
if (os.format() == IOstream::BINARY)
|
||||
{
|
||||
os << " arch " << archHint << ";\n";
|
||||
}
|
||||
|
||||
if (!note().empty())
|
||||
{
|
||||
os << " note " << note() << ";\n";
|
||||
}
|
||||
|
||||
@ -766,10 +766,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::storeOldTimes() const
|
||||
(
|
||||
field0Ptr_
|
||||
&& timeIndex_ != this->time().timeIndex()
|
||||
&& !(
|
||||
this->name().size() > 2
|
||||
&& this->name()(this->name().size()-2, 2) == "_0"
|
||||
)
|
||||
&& !this->name().endsWith("_0")
|
||||
)
|
||||
{
|
||||
storeOldTime();
|
||||
|
||||
@ -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()
|
||||
{
|
||||
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;
|
||||
if (argI >= args_.size())
|
||||
{
|
||||
@ -475,6 +493,9 @@ Foam::argList::argList
|
||||
}
|
||||
else
|
||||
{
|
||||
// All other options (including unknown ones) are simply
|
||||
// registered as existing.
|
||||
|
||||
options_.insert(optionName, "");
|
||||
}
|
||||
}
|
||||
@ -527,29 +548,31 @@ void Foam::argList::parse
|
||||
// -help print the usage
|
||||
// -doc display application documentation 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"))
|
||||
{
|
||||
printUsage();
|
||||
quickExit = true;
|
||||
}
|
||||
|
||||
// Only display one or the other
|
||||
if (options_.found("srcDoc"))
|
||||
{
|
||||
displayDoc(true);
|
||||
quickExit = true;
|
||||
}
|
||||
else if (options_.found("doc"))
|
||||
{
|
||||
displayDoc(false);
|
||||
quickExit = true;
|
||||
}
|
||||
|
||||
::exit(0);
|
||||
if (quickExit)
|
||||
{
|
||||
::exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Print the usage message and exit if the number of arguments is incorrect
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -348,6 +348,10 @@ public:
|
||||
//- Disable emitting the banner information
|
||||
static void noBanner();
|
||||
|
||||
//- Remove the 'noFunctionObjects' option,
|
||||
// optionally adding a 'withFunctionObjects' option instead
|
||||
static void noFunctionObjects(bool addWithOption = false);
|
||||
|
||||
//- Remove the parallel options
|
||||
static void noParallel();
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ License
|
||||
#include "wordList.H"
|
||||
#include "DynamicList.H"
|
||||
#include "OSspecific.H"
|
||||
#include "wordRe.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -37,11 +38,46 @@ const Foam::fileName Foam::fileName::null;
|
||||
|
||||
// * * * * * * * * * * * * * * * * 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
|
||||
{
|
||||
size_type i = find_last_of("./");
|
||||
size_type i = find_ext();
|
||||
|
||||
if (i == npos || i == 0 || operator[](i) == '/')
|
||||
if (i == npos)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
@ -283,9 +319,9 @@ Foam::fileName Foam::fileName::lessExt() 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;
|
||||
}
|
||||
@ -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
|
||||
{
|
||||
DynamicList<word> wrdList(20);
|
||||
|
||||
@ -53,10 +53,11 @@ namespace Foam
|
||||
{
|
||||
|
||||
template<class T> class List;
|
||||
template<class T> class UList;
|
||||
typedef List<word> wordList;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class wordRe;
|
||||
class fileName;
|
||||
|
||||
Istream& operator>>(Istream&, fileName&);
|
||||
@ -73,6 +74,10 @@ class fileName
|
||||
{
|
||||
// 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
|
||||
inline void stripInvalid();
|
||||
|
||||
@ -104,31 +109,35 @@ public:
|
||||
inline fileName();
|
||||
|
||||
//- Construct as copy
|
||||
inline fileName(const fileName&);
|
||||
inline fileName(const fileName& fn);
|
||||
|
||||
//- Construct as copy of word
|
||||
inline fileName(const word&);
|
||||
inline fileName(const word& s);
|
||||
|
||||
//- 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
|
||||
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
|
||||
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 '/'
|
||||
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
|
||||
fileName(Istream&);
|
||||
fileName(Istream& is);
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Is this character valid for a fileName?
|
||||
inline static bool valid(char);
|
||||
inline static bool valid(char c);
|
||||
|
||||
//- Cleanup file name
|
||||
//
|
||||
@ -205,6 +214,24 @@ public:
|
||||
//- Return file name extension (part after last .)
|
||||
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
|
||||
//
|
||||
// Behaviour:
|
||||
@ -215,32 +242,46 @@ public:
|
||||
// "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
|
||||
word component(const size_type, const char delimiter='/') const;
|
||||
word component
|
||||
(
|
||||
const size_type cmpt,
|
||||
const char delimiter = '/'
|
||||
) const;
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
// Assignment
|
||||
// Assignment
|
||||
|
||||
void operator=(const fileName&);
|
||||
void operator=(const word&);
|
||||
void operator=(const string&);
|
||||
void operator=(const std::string&);
|
||||
void operator=(const char*);
|
||||
//- Copy, no character validation required
|
||||
void operator=(const fileName& str);
|
||||
|
||||
//- Copy, no character validation required
|
||||
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
|
||||
|
||||
friend Istream& operator>>(Istream&, fileName&);
|
||||
friend Ostream& operator<<(Ostream&, const fileName&);
|
||||
friend Istream& operator>>(Istream& is, fileName& fn);
|
||||
friend Ostream& operator<<(Ostream& os, const fileName& fn);
|
||||
};
|
||||
|
||||
|
||||
//- Assemble words and fileNames as pathnames by adding a '/' separator
|
||||
fileName operator/(const string&, const string&);
|
||||
//- Assemble words and fileNames as pathnames by adding a '/' separator.
|
||||
// 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
|
||||
|
||||
@ -25,6 +25,21 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * 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()
|
||||
{
|
||||
// skip stripping unless debug is active to avoid
|
||||
|
||||
@ -78,5 +78,3 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const fileName& fn)
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,7 +26,6 @@ License
|
||||
#include "string.H"
|
||||
#include "stringOps.H"
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
||||
|
||||
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))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -104,49 +104,53 @@ public:
|
||||
inline string();
|
||||
|
||||
//- Construct from std::string
|
||||
inline string(const std::string&);
|
||||
inline string(const std::string& str);
|
||||
|
||||
//- Construct as copy of character array
|
||||
inline string(const char*);
|
||||
inline string(const char* str);
|
||||
|
||||
//- 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
|
||||
inline string(const char);
|
||||
inline string(const char c);
|
||||
|
||||
//- Construct from Istream
|
||||
string(Istream&);
|
||||
string(Istream& is);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- 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?
|
||||
template<class String>
|
||||
static inline bool valid(const string&);
|
||||
static inline bool valid(const string& str);
|
||||
|
||||
//- Does this string have particular meta-characters?
|
||||
// The meta characters can be optionally quoted.
|
||||
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
|
||||
template<class String>
|
||||
static inline bool stripInvalid(string&);
|
||||
static inline bool stripInvalid(string& str);
|
||||
|
||||
//- Return a valid String from the given 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
|
||||
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
|
||||
inline bool match(const std::string&) const;
|
||||
inline bool match(const std::string& str) const;
|
||||
|
||||
//- Avoid masking the normal std::string replace
|
||||
using std::string::replace;
|
||||
@ -186,16 +190,26 @@ public:
|
||||
string& expand(const bool allowEmpty = false);
|
||||
|
||||
//- Remove repeated characters returning true if string changed
|
||||
bool removeRepeated(const char);
|
||||
bool removeRepeated(const char character);
|
||||
|
||||
//- 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
|
||||
bool removeTrailing(const char);
|
||||
bool removeTrailing(const char character);
|
||||
|
||||
//- 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
|
||||
@ -216,8 +230,8 @@ public:
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Istream& operator>>(Istream&, string&);
|
||||
friend Ostream& operator<<(Ostream&, const string&);
|
||||
friend Istream& operator>>(Istream& is, string& s);
|
||||
friend Ostream& operator<<(Ostream& os, const string& s);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -95,12 +95,12 @@ public:
|
||||
// Note that 'REGEXP' is implicit if 'NOCASE' is specified alone.
|
||||
enum compOption
|
||||
{
|
||||
LITERAL = 0, //!< treat as a string literal
|
||||
DETECT = 1, //!< treat as regular expression
|
||||
REGEXP = 2, //!< detect if the string contains meta-characters
|
||||
NOCASE = 4, //!< ignore case in regular expression
|
||||
DETECT_NOCASE = DETECT | NOCASE,
|
||||
REGEXP_NOCASE = REGEXP | NOCASE
|
||||
LITERAL = 0, //!< Treat as a string literal
|
||||
DETECT = 1, //!< Detect if the string contains meta-characters
|
||||
REGEXP = 2, //!< Treat as regular expression
|
||||
NOCASE = 4, //!< Ignore case in regular expression
|
||||
DETECT_NOCASE = DETECT | NOCASE, //!< Combined DETECT and NOCASE
|
||||
REGEXP_NOCASE = REGEXP | NOCASE //!< Combined REGEXP and NOCASE
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ stopAt endTime;
|
||||
|
||||
endTime 18000;
|
||||
|
||||
deltaT 10;
|
||||
deltaT 1;
|
||||
|
||||
writeControl adjustableRunTime;
|
||||
|
||||
@ -49,4 +49,8 @@ adjustTimeStep yes;
|
||||
|
||||
maxCo 15;
|
||||
|
||||
maxDeltaT 10;
|
||||
|
||||
maxDi 0.25;
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -43,7 +43,7 @@ options
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
momentumSource1
|
||||
{
|
||||
type vectorSemiImplicitSource;
|
||||
@ -55,11 +55,11 @@ options
|
||||
volumeMode absolute;
|
||||
injectionRateSuSp
|
||||
{
|
||||
U.steam ((0 1e-1 0) 0); // kg*m/s^2
|
||||
U.steam ((0 1e-2 0) 0); // kg*m/s^2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
energySource1
|
||||
{
|
||||
type scalarSemiImplicitSource;
|
||||
|
||||
Reference in New Issue
Block a user