Commit 1e6e335f authored by henry's avatar henry
Browse files
parents d217b8bd 2e77a6f9
......@@ -3,8 +3,8 @@ cd ${0%/*} || exit 1 # run from this directory
if [ "$PWD" != "$WM_PROJECT_DIR" ]
then
echo "Error: Current directory in not \$WM_PROJECT_DIR"
echo " The environment variable are not consistent with the installation."
echo "Error: Current directory is not \$WM_PROJECT_DIR"
echo " The environment variables are inconsistent with the installation."
echo " Check the OpenFOAM entries in your dot-files and source them."
exit 1
fi
......
......@@ -3,8 +3,8 @@ cd ${0%/*} || exit 1 # run from this directory
if [ "$PWD" != "$WM_PROJECT_DIR/applications" ]
then
echo "Error: Current directory in not \$WM_PROJECT_DIR/applications"
echo " The environment variable are not consistent with the installation."
echo "Error: Current directory is not \$WM_PROJECT_DIR/applications"
echo " The environment variables are inconsistent with the installation."
echo " Check the OpenFOAM entries in your dot-files and source them."
exit 1
fi
......
......@@ -82,7 +82,7 @@
(
"kappa",
wallFunctionDict,
0.4187
0.41
)
);
......@@ -92,7 +92,7 @@
(
"E",
wallFunctionDict,
9.0
9.8
)
);
......
......@@ -304,7 +304,7 @@
(
"kappa",
wallFunctionDict,
0.4187
0.41
)
);
......@@ -314,7 +314,7 @@
(
"E",
wallFunctionDict,
9.0
9.8
)
);
......
fvSolutionCombine.C
EXE = $(FOAM_USER_APPBIN)/fvSolutionCombine
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
-lfiniteVolume
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
fvSolutionCombine
Description
Simple utility for combining fvSolution solution entries.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "wordRe.H"
#include "OSspecific.H"
using namespace Foam;
// check for identical dictionary content, regardless of the order
bool checkDictionaryContent(const dictionary& dict1, const dictionary& dict2)
{
// trivial cases first
if (&dict1 == &dict2)
{
return true;
}
else if (dict1.size() != dict2.size())
{
return false;
}
forAllConstIter(dictionary, dict1, iter1)
{
const entry* entryPtr = dict2.lookupEntryPtr
(
iter1().keyword(),
false,
false
);
if (!entryPtr)
{
return false;
}
const entry& entry1 = iter1();
const entry& entry2 = *entryPtr;
bool ok = false;
if (entry1.isDict())
{
if (entry2.isDict())
{
ok = checkDictionaryContent(entry1.dict(), entry2.dict());
}
}
else
{
ok = (entry1 == entry2);
}
if (!ok)
{
return false;
}
}
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validOptions.insert("rewrite", "");
argList::validOptions.insert("show", "");
argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName());
const word dictName("fvSolution");
bool optRewrite = args.optionFound("rewrite");
bool optShow = args.optionFound("show");
IOdictionary solutionDict
(
IOobject
(
dictName,
"system",
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
if (!solutionDict.found("solvers"))
{
Info<<"no solvers entry found in : " << dictName << endl;
return 2;
}
if (optRewrite && solutionDict.instance() != "system")
{
Info<<"instance is not 'system' "
"- disabling rewrite for this file" << nl;
optRewrite = false;
}
dictionary& solverDict = solutionDict.subDict("solvers");
wordList names = solverDict.toc();
wordList oldNames = names;
bool changed = false;
for (label orig = 0; orig < names.size()-1; ++orig)
{
// skip patterns or entries that have already been done
if (names[orig].empty() || wordRe::isPattern(names[orig]))
{
continue;
}
const dictionary& dict1 = solverDict.subDict(names[orig]);
for (label check = orig+1; check < names.size(); ++check)
{
// skip patterns or entries that have already been done
if (names[check].empty() || wordRe::isPattern(names[check]))
{
continue;
}
const dictionary& dict2 = solverDict.subDict(names[check]);
// check for identical content
if (checkDictionaryContent(dict1, dict2))
{
names[orig] += "|" + names[check];
names[check].clear();
changed = true;
}
}
}
if (changed)
{
forAll(names, nameI)
{
if (names[nameI].empty())
{
solverDict.remove(oldNames[nameI]);
Info<<" #remove " << oldNames[nameI];
}
else
{
Info<< " " << oldNames[nameI];
if (names[nameI] != oldNames[nameI])
{
// make "(abc|def)" pattern
keyType renamed( "(" + names[nameI] + ")", true);
solverDict.changeKeyword(oldNames[nameI], renamed);
Info<< " -> " << renamed;
}
}
Info<< endl;
}
if (optRewrite)
{
mvBak(solutionDict.objectPath(), "orig");
Info<< "Backup to .orig" << nl
<< "Writing " << solutionDict.objectPath() << nl << endl;
solutionDict.regIOobject::write();
}
else if (optShow)
{
IOobject::writeDivider(Info);
solutionDict.dictionary::write(Info, false);
}
else
{
Info<< "\nFile not rewritten" << endl;
}
}
else
{
Info<< "no changes" << endl;
}
Info<< "Done\n" << endl;
return changed ? 0 : 1;
}
// ************************************************************************* //
......@@ -33,6 +33,7 @@ Description
#include "argList.H"
#include "IFstream.H"
#include "IOobject.H"
#include "dictionary.H"
using namespace Foam;
......@@ -42,13 +43,19 @@ using namespace Foam;
int main(int argc, char *argv[])
{
argList::noBanner();
argList::noParallel();
argList::validArgs.clear();
argList::validArgs.append("inputDict");
argList args(argc, argv);
IFstream dictStream(args.additionalArgs()[0]);
dictionary inputDict(dictStream);
Info<< inputDict << endl;
const string& dictName = args.additionalArgs()[0];
Info<<"//\n// expansion of dictionary " << dictName << "\n//\n";
dictionary(IFstream(dictName)()).write(Info, false);
IOobject::writeDivider(Info);
return 0;
}
......
......@@ -41,6 +41,11 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// turbulence constants - file-scope
static const scalar Cmu(0.09);
static const scalar kappa(0.41);
int main(int argc, char *argv[])
{
argList::validOptions.insert("ybl", "scalar");
......@@ -48,7 +53,6 @@ int main(int argc, char *argv[])
argList::validOptions.insert("writenut", "");
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
......@@ -117,10 +121,6 @@ int main(int argc, char *argv[])
phi = fvc::interpolate(U) & mesh.Sf();
phi.write();
// Set turbulence constants
dimensionedScalar kappa("kappa", dimless, 0.4187);
dimensionedScalar Cmu("Cmu", dimless, 0.09);
// Read and modify turbulence fields if present
IOobject epsilonHeader
......@@ -182,11 +182,11 @@ int main(int argc, char *argv[])
Info<< "Reading field epsilon\n" << endl;
volScalarField epsilon(epsilonHeader, mesh);
scalar ck0 = ::pow(Cmu.value(), 0.25)*kappa.value();
scalar ck0 = ::pow(Cmu, 0.25)*kappa;
k = sqr(nut/(ck0*min(y, ybl)));
k.correctBoundaryConditions();
scalar ce0 = ::pow(Cmu.value(), 0.75)/kappa.value();
scalar ce0 = ::pow(Cmu, 0.75)/kappa;
epsilon = ce0*k*sqrt(k)/min(y, ybl);
epsilon.correctBoundaryConditions();
......
......@@ -38,7 +38,7 @@
#
#------------------------------------------------------------------------------
PROGNAME=${0##*/}
Script=${0##*/}
#-------------------------------------------------------------------------------
#- User settings
......@@ -48,9 +48,9 @@ NDAYSLIMIT=7
#-------------------------------------------------------------------------------
#- work file
TMPFILE=/tmp/${PROGNAME}$$.tmp
TMPFILE=/tmp/${Script}$$.tmp
#- work dir. Needs to be accessible for all machines
MACHDIR=$HOME/.OpenFOAM/${PROGNAME}
MACHDIR=$HOME/.OpenFOAM/${Script}
DEFSTATEFILE=$HOME/.OpenFOAM/foamCheckJobs.out
......@@ -62,6 +62,29 @@ else
fi
usage() {
cat<<USAGE
Usage: $Script [stateFile]
This program checks all the locks in the FOAM_JOB_DIR directory to see if
their processes are still running. Processes will not release their
lock if they exit abnormally. This program will try to obtain process
information on the machine the process ran on and release the lock
if the program is no longer running.
Note: all machines have to be reachable using ssh.
The output from checking all running jobs is collected in an optional
file.
FILES:
\$FOAM_JOB_DIR/runningJobs locks for running processes
/finishedJobs locks for finished processes
USAGE
exit 1
}
#-------------------------------------------------------------------------------
#
# Functions
......@@ -83,7 +106,8 @@ getEntry() {
# notEmpty directory
# Returns 0 if directory contains files/directories
notEmpty() {
if [ "`ls $1`" ]; then
if [ "`ls $1`" ]
then
return 0
else
return 1
......@@ -96,7 +120,8 @@ notEmpty() {
# ==> 13
dayDiff() {
date -d "$1" > /dev/null 2>&1
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]
then
#- option '-d' on date not supported. Give up.
echo "0"
else
......@@ -119,12 +144,14 @@ dayDiff() {
# Also handles 'slaves' entries in jobInfo:
# slaves 1 ( penfold.23766 );
getAllJobs() {
if notEmpty $1; then
if notEmpty $1
then
jobs=$1/*
for f in $jobs
do
line=`grep '^[ ]*slaves' $f 2>/dev/null`
if [ $? -eq 0 ]; then
if [ $? -eq 0 ]
then
slaveJobs=`echo "$line" | sed -e 's/.*(\(.*\)).*/\1/'`
jobs="$jobs $slaveJobs"
fi
......@@ -138,34 +165,12 @@ getAllJobs() {
# releaseLock jobId lockFile
# Releases lock on jobId
releaseLock () {
if [ -f $2 ]; then
if [ -f $2 ]
then
#- move lock to finishedJobs
mv $2 $FOAM_JOB_DIR/finishedJobs/
fi
$ECHO "Lock on job $1 released."
}
printUsage() {
cat << LABEL
Usage: $PROGNAME [stateFile]
This program checks all the locks in the license directory to see if
their processes are still running. Processes will not release their
lock if they exit abnormally. This program will try to obtain process
information on the machine the process ran on and release the lock
if the program is no longer running.
Requirements: the environment variable FOAM_JOB_DIR needs to point to the
license directory and all machines have to be reachable using ssh.
The output from checking all running jobs is collected in an optional
file.
FILES:
\$FOAM_JOB_DIR/runningJobs locks for running processes
/finishedJobs ,, finished processes
LABEL
echo "Lock on job $1 released."
}
......@@ -175,39 +180,50 @@ LABEL
#
#-------------------------------------------------------------------------------
if [ $# -eq 1 ]
then
if [ "$1" = "-h" -o "$1" = "-help" ]
then
usage
fi
STATEFILE="$1"
elif [ $# -eq 0 ]
then
STATEFILE=${STATEFILE:-$DEFSTATEFILE}
else
usage
fi
#- Check a few things
if [ ! "$FOAM_JOB_DIR" ]; then
$ECHO "$PROGNAME : FOAM_JOB_DIR environment variable not set."
$ECHO "This should point to your central license directory."
if [ ! "$FOAM_JOB_DIR" ]
then
echo "$Script : FOAM_JOB_DIR environment variable not set."
echo
exit 1
fi
if [ ! -d "$FOAM_JOB_DIR" ]; then
$ECHO "$PROGNAME : The license directory accoring to FOAM_JOB_DIR is not valid."
$ECHO "FOAM_JOB_DIR: $FOAM_JOB_DIR"
if [ ! -d "$FOAM_JOB_DIR" ]
then
echo "$Script : directory does not exist."
echo " FOAM_JOB_DIR=$FOAM_JOB_DIR"
echo
exit 1
fi
if [ ! -d "$FOAM_JOB_DIR/runningJobs" -o ! -d "$FOAM_JOB_DIR/finishedJobs" ]; then
$ECHO "$PROGNAME : The license directory according to FOAM_JOB_DIR is not valid."
$ECHO "FOAM_JOB_DIR: $FOAM_JOB_DIR"
if [ ! -d "$FOAM_JOB_DIR/runningJobs" -o ! -d "$FOAM_JOB_DIR/finishedJobs" ]
then
echo "$Script : invalid directory."
echo " FOAM_JOB_DIR=$FOAM_JOB_DIR"
echo
exit 1
fi
if [ $# -eq 1 ]; then
STATEFILE=$1
elif [ $# -eq 0 ]; then
STATEFILE=${STATEFILE:-$DEFSTATEFILE}
else
printUsage
exit 1
fi
#- obtain rsh method
RSH='ssh'
echo "Using remote shell type : $RSH"
echo ""
echo "Collecting information on jobs in"
echo " $FOAM_JOB_DIR"
......@@ -226,13 +242,14 @@ do
pid=`echo $machinePid | sed -e 's/.*\.\([0-9][0-9]*\)$/\1/'`
fgrep "$machine" $TMPFILE >/dev/null 2>&1
if [ $? -ne 0 ]; then
$ECHO "$machine" >> $TMPFILE
if [ $? -ne 0 ]
then
echo "$machine" >> $TMPFILE
fi
done
$ECHO "Found machines:"
echo "Found machines:"
cat $TMPFILE
$ECHO ""
echo ""
......@@ -243,31 +260,34 @@ cnt=1
while true
do
machine=`sed -n -e "${cnt}p" $TMPFILE`
if [ ! "$machine" ]; then
if [ ! "$machine" ]
then
break
fi
machFile=$MACHDIR/$machine
rm -f $machFile
$ECHO "Contacting $machine to collect process information:"
if [ $machine = `hostname` ]; then
$ECHO " foamProcessInfo $machFile"
echo "Contacting $machine to collect process information:"
if [ $machine = `hostname` ]
then
echo " foamProcessInfo $machFile"
foamProcessInfo $machFile >/dev/null 2>&1
else
$ECHO " $RSH $machine foamProcessInfo $machFile"
echo " $RSH $machine foamProcessInfo $machFile"
$RSH $machine foamProcessInfo $machFile >/dev/null 2>&1
fi
if [ $? -ne 0 -o ! -s $machFile ]; then
$ECHO "** Failed collecting process information on $machine."
$ECHO "Check $machFile and run foamProcessInfo by hand"
if [ $? -ne 0 -o ! -s $machFile ]
then
echo "** Failed collecting process information on $machine."
echo "Check $machFile and run foamProcessInfo by hand"
rm -f $machFile
else