Add the OpenFOAM source tree

This commit is contained in:
Henry
2014-12-10 22:40:10 +00:00
parent ee487c860d
commit 446e5777f0
13379 changed files with 3983377 additions and 0 deletions

136
bin/tools/CleanFunctions Normal file
View File

@ -0,0 +1,136 @@
#---------------------------------*- sh -*-------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# CleanFunctions
#
# Description
# Miscellaneous cleanup functions for tutorial cases
#------------------------------------------------------------------------------
#cleanTimeDirectories()
#{
# echo "Cleaning $PWD case"
# for time in $(foamInfoExec -times)
# do
# # keep 0 and constant directories
# [ "$time" = "0" -o "$time" = constant ] || {
# echo "Deleting directory $time"
# rm -rf $time > /dev/null 2>&1
# }
# done
# rm -rf {log,log.*,log-*,logSummary.*,.fxLock,*.xml,ParaView*,paraFoam*,*.OpenFOAM} > /dev/null 2>&1
#}
cleanTimeDirectories()
{
echo "Cleaning $PWD case"
zeros=""
while [ ${#zeros} -lt 8 ]
do
timeDir="0.${zeros}[1-9]*"
rm -rf ./${timeDir} ./-${timeDir} > /dev/null 2>&1
zeros="0$zeros"
done
rm -rf ./[1-9]* ./-[1-9]* ./log ./log.* ./log-* ./logSummary.* ./.fxLock ./*.xml ./ParaView* ./paraFoam* ./*.OpenFOAM ./*.blockMesh ./.setSet > /dev/null 2>&1
}
#
# Remove dynamicCode subdirectory if it looks appropriate
#
cleanDynamicCode()
{
if [ -d system -a -d dynamicCode ]
then
rm -rf dynamicCode > /dev/null 2>&1
fi
}
cleanCase()
{
cleanTimeDirectories
cleanDynamicCode
rm -rf processor* > /dev/null 2>&1
rm -rf postProcessing > /dev/null 2>&1
rm -rf probes* > /dev/null 2>&1
rm -rf forces* > /dev/null 2>&1
rm -rf graphs* > /dev/null 2>&1
rm -rf sets > /dev/null 2>&1
rm -rf surfaceSampling > /dev/null 2>&1
rm -rf cuttingPlane > /dev/null 2>&1
rm -rf system/machines > /dev/null 2>&1
if [ -d constant/polyMesh ]
then
(cd constant/polyMesh && \
rm -rf \
allOwner* cell* face* meshModifiers* \
owner* neighbour* point* edge* \
cellLevel* pointLevel* refinementHistory* level0Edge* surfaceIndex* sets \
> /dev/null 2>&1 \
)
fi
(cd constant && \
rm -rf \
cellToRegion cellLevel* pointLevel* \
> /dev/null 2>&1 \
)
rm -rf constant/tetDualMesh > /dev/null 2>&1
rm -rf VTK > /dev/null 2>&1
rm -f 0/cellLevel 0/pointLevel 0/cellDist constant/cellDecomposition
if [ -e constant/polyMesh/blockMeshDict.m4 ]
then
rm -f constant/polyMesh/blockMeshDict > /dev/null 2>&1
fi
}
removeCase()
{
echo "Removing ${1:-unknown} case"
rm -rf $1
}
cleanSamples()
{
rm -rf ./sets ./samples ./sampleSurfaces > /dev/null 2>&1
}
cleanUcomponents()
{
rm -rf 0/Ux 0/Uy 0/Uz > /dev/null 2>&1
}
cleanApplication()
{
echo "Cleaning $PWD application"
wclean
}
#------------------------------------------------------------------------------

42
bin/tools/MakefileDirs Normal file
View File

@ -0,0 +1,42 @@
#-------------------------------*- makefile -*---------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# File
# MakefileDirs
#
# Description
# Makefile used by
# foamRunTutorials
# to call some script in subdirectories.
#
#------------------------------------------------------------------------------
.PHONY: application $(FOAM_TARGETS)
application: $(FOAM_TARGETS)
$(FOAM_TARGETS):
+@(cd $@ && $(FOAM_APP) $(FOAM_ARGS))
#------------------------------------------------------------------------------

2
bin/tools/README Normal file
View File

@ -0,0 +1,2 @@
Misc. tools, scripts, templates that are useful (eg, for building applications)
but don't need to be in the PATH.

102
bin/tools/RunFunctions Normal file
View File

@ -0,0 +1,102 @@
#---------------------------------*- sh -*-------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# RunFunctions
#
# Description
# Miscellaneous functions for running tutorial cases
#------------------------------------------------------------------------------
getNumberOfProcessors()
{
sed -ne 's/^numberOfSubdomains *\(.*\);/\1/p' system/decomposeParDict
}
getApplication()
{
sed -ne 's/^ *application *\([a-zA-Z]*\) *;.*$/\1/p' system/controlDict
}
runApplication()
{
APP_RUN=$1
APP_NAME=${1##*/}
shift
if [ -f log.$APP_NAME ]
then
echo "$APP_NAME already run on $PWD: remove log file to re-run"
else
echo "Running $APP_RUN on $PWD"
$APP_RUN "$@" > log.$APP_NAME 2>&1
fi
}
runParallel()
{
APP_RUN=$1
APP_NAME=${1##*/}
shift
if [ -f log.$APP_NAME ]
then
echo "$APP_NAME already run on $PWD: remove log file to re-run"
else
nProcs=$1
shift
echo "Running $APP_RUN in parallel on $PWD using $nProcs processes"
#if [ "$WM_SCHEDULER" ]
#then
# echo "$PWD: $WM_SCHEDULER -np $nProcs" 1>&2
# $WM_SCHEDULER -np $nProcs "( mpirun -np $nProcs $APP_RUN -parallel "$@" < /dev/null > log.$APP_NAME 2>&1 )"
#else
( mpirun -np $nProcs $APP_RUN -parallel "$@" < /dev/null > log.$APP_NAME 2>&1 )
#fi
fi
}
compileApplication()
{
echo "Compiling $1 application"
wmake $1
}
cloneCase()
{
if [ -d $2 ]
then
echo "Case already cloned: remove case directory $2 to clone"
else
echo "Cloning $2 case from $1"
mkdir $2
cpfiles="0 system constant"
for f in $cpfiles
do
cp -r $1/$f $2
done
fi
}
#------------------------------------------------------------------------------

64
bin/tools/doxyFilter Executable file
View File

@ -0,0 +1,64 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# doxyFilter
#
# Description
# pass-through filter for doxygen
#
# Special treatment for applications/{solvers,utilities}/*.C
# - only keep the first comment block of the C source file
# use @cond / @endcond to suppress documenting all classes/variables
#
# Special treatment for applications/{solvers,utilities}/*.H
# - use @cond / @endcond to suppress documenting all classes/variables
#------------------------------------------------------------------------------
if [ "$#" -gt 0 ]
then
filePath=$(echo $1 | sed -e s@^$WM_PROJECT_DIR@../../..@ )
# dirName=$(echo "$filePath" | sed -e 's@/[^/]*$@@' )
dirName=${filePath%/[^/]*}
fileName=${filePath##*/}
awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilter.awk
case "$1" in
*/applications/solvers/*.C | */applications/utilities/*.C )
awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilter-top.awk
;;
# */applications/solvers/*.H | */applications/utilities/*.H )
# awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilter-ignore.awk
# ;;
esac
awk -f $WM_PROJECT_DIR/bin/tools/doxyFilter-table.awk $1 | \
awk -f $awkScript | \
sed -f $WM_PROJECT_DIR/bin/tools/doxyFilter.sed \
-e s@%filePath%@$filePath@g \
-e s@%fileName%@$fileName@g \
-e s@%dirName%@$dirName@g
fi
#------------------------------------------------------------------------------

View File

@ -0,0 +1,44 @@
# -----------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# doxyFilter-ignore.awk
#
# Description
# - Prefix file contents with doxygen @file tag and %filePath% tag
# that will be changed in a subsequent sed script
# - Surround the contents of an entire file with @cond / @endcond
# to skip documenting all classes/variables
#
# -----------------------------------------------------------------------------
BEGIN {
print "//! @file %filePath%"
print "//! @cond OpenFOAMIgnoreAppDoxygen"
}
{ print }
END {
print "//! @endcond"
}
# -----------------------------------------------------------------------------

View File

@ -0,0 +1,135 @@
BEGIN {
FS = "|";
data = "";
flag = 0;
firstRow = 0;
}
/\\table/ {
flag = 1;
firstRow = 1;
next;
}
/\\endtable/ {
if (data != "")
{
printf "<table class=\"OFTable\">\n";
printf data;
printf "</table>\n";
}
data = "";
flag = 0;
next;
}
/\\vartable/ {
flag = 2;
firstRow = 1;
next;
}
/\\endvartable/ {
if (data != "")
{
printf "<table border="0">\n";
printf data;
printf "</table>\n";
}
data = "";
flag = 0;
next;
}
/\\plaintable/ {
flag = 3;
firstRow = 1;
next;
}
/\\endplaintable/ {
if (data != "")
{
printf "<table border="0">\n";
printf data;
printf "</table>\n";
}
data = "";
flag = 0;
next;
}
{
if (flag > 0)
{
data = (data "<tr>\n");
if (flag == 1)
{
for (i = 0; i <= NF; i++)
{
if ((i != 0) && (firstRow == 1))
{
data = (data " <th align=\"center\"><b>"$i"</b></th>\n");
}
else
{
if (i == 1)
{
data = (data " <td>\\c "$i"</td>\n");
}
else if (i > 1)
{
data = (data " <td>"$i"</td>\n");
}
}
}
}
else if (flag == 2)
{
for (i = 0; i <= NF; i++)
{
if (i == 1)
{
data = (data " <td style=\"padding-left: 10px\">\\f$"$i"\\f$</td>\n");
data = (data " <td style=\"padding-left: 10px; padding-right: 10px;\">=</td>\n");
}
else if (i > 1)
{
data = (data " <td>"$i"</td>\n");
}
}
}
else if (flag == 3)
{
for (i = 0; i <= NF; i++)
{
if (i == 1)
{
data = (data " <td style=\"padding-left: 10px\">"$i"</td>\n");
data = (data " <td style=\"padding-left: 10px; padding-right: 10px;\">:</td>\n");
}
else if (i > 1)
{
data = (data " <td>"$i"</td>\n");
}
}
}
data = (data "</tr>\n");
firstRow = 0;
}
else
{
print $0
}
}

View File

@ -0,0 +1,81 @@
# -----------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# doxyFilter-top.awk
#
# Description
# Only output the first /* ... */ comment section found in the file
# Use @cond / @endcond to suppress documenting all classes/variables
# - This is useful for application files in which only the first
# block documents the application itself.
#
# -----------------------------------------------------------------------------
BEGIN {
state = 0
}
# a '/*' at the beginning of a line starts a comment block
/^ *\/\*/ {
state++
}
# check first line
# either started with a comment or skip documentation for the whole file
FNR == 1 {
if (!state)
{
print "//! @cond OpenFOAMIgnoreAppDoxygen"
state = 2
}
}
# a '*/' ends the comment block
# skip documentation for rest of the file
/\*\// {
if (state == 1)
{
print
print "//! @cond OpenFOAMIgnoreAppDoxygen"
}
state = 2
next
}
# print everything within the first comment block
{
if (state)
{
print
}
next
}
END {
if (state == 2)
{
print "//! @endcond"
}
}
# -----------------------------------------------------------------------------

89
bin/tools/doxyFilter.awk Normal file
View File

@ -0,0 +1,89 @@
# -----------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# doxyFilter.awk
#
# Description
# Converts cocoon style sentinel strings into doxygen style strings
#
# Assumes comment strings are formatted as follows
# //- general description
# // more information
# // and even more information
# This should be re-formatted as the following
# //! general description
# /*!
# more information
# and even more information
# */
# The intermediate "/*! ... */" block is left-justified to handle
# possible verbatim text
# -----------------------------------------------------------------------------
BEGIN {
state = 0
}
/^ *\/\/-/ {
state = 1
sub(/\/\/-/, "//!")
print
next
}
/^ *\/\// {
# start comment block
if (state == 1)
{
printf "/*! "
state = 2
}
# inside comment block
if (state == 2)
{
if (!sub(/^ *\/\/ /, ""))
{
sub(/^ *\/\//, "")
}
}
print
next
}
{
# end comment block
if (state == 2)
{
printf "*/ "
}
state = 0
print
next
}
# -----------------------------------------------------------------------------

173
bin/tools/doxyFilter.sed Normal file
View File

@ -0,0 +1,173 @@
# -----------------------------------------------------------------------------
# Script
# doxyFilter.sed
#
# Description
# Transform human-readable tags such as 'Description' into the Doxygen
# equivalent
# -----------------------------------------------------------------------------
# new FSF address
/^License/,/\*\//{
/^License/,\%http://www.gnu.org/licenses%{
s?^License.*?\*\/\
\/\*! \\file %filePath%\
<b>Original source file</b> <a href="%filePath%">%fileName%</a>\
\
\
\
\
\
\
\
\
?
/^ /d
}
# remove entry
/^Application *$/{
N
N
d
}
# remove entry
/^Global *$/{
N
N
d
}
# Primitive
# typename
# =>
# \\relates typename
#
/^Primitive *$/,/^[^ ]/{
s/^Primitive *$//
s/^ /\\relates /
}
# Class
# Foam::className
# =>
# \\class Foam::className
#
/^Class *$/,/^[^ ]/{
s/^Class *$//
s/^ /\\class /
}
# Group
# groupName
# =>
# \ingroup namespaceName
#
/^Group *$/,/^[^ ]/{
s/^Group//
s/^ /\\ingroup /
}
# Namespace
# namespaceName
# =>
# \namespace namespaceName
#
/^Namespace *$/,/^[^ ]/{
s/^Namespace//
s/^ /\\namespace /
}
# Typedef
# Foam::def
# =>
# \typedef Foam::def
/^Typedef *$/,/^[^ ]/{
s/^Typedef//
s/^ /\\typedef /
}
# add anchor and use \brief
# the first paragraph will be 'brief' and the others 'detail'
/^Description *$/,/^[^ ]/{
/^Description/c\
<a class="anchor" name="Description"></a> \\brief
s/^ //
}
/^Usage *$/,/^[^ ]/{
/^Usage/c\
\\par Usage
s/^ //
}
/^See *Also *$/,/^[^ ]/{
/^See *Also/c\
\\see
s/^ //
}
/^Note *$/,/^[^ ]/{
/^Note/c\
\\note
s/^ //
}
# remove ToDo paragraph to avoid them showing on related pages
/^To[Dd]o *$/,/^[^ ]/{
s/^To[Dd]o *$//
s/^ .*//
}
/^Warning *$/,/^[^ ]/{
/^Warning/c\
\\warning
s/^ //
}
/^Deprecated *$/,/^[^ ]/{
/^Deprecated/c\
\\deprecated
s/^ //
}
/^SourceFiles *$/,/^$/{
s?SourceFiles?\\par Source files\
<ul><li><a href="%filePath%">%fileName%</a></li>?
s? *\([a-zA-Z0-9]*\.[a-zA-Z]*\)? <li><a href="%dirName%/\1">\1</a></li>?
s?^$?</ul>?
}
/fileName%<\/a><\/li>$/{
N
s?\n$?</ul>?g
s/<\/li>\n/<\/li> /
s? *\([a-zA-Z0-9]*\.[a-zA-Z]*\)? <li><a href="%dirName%/\1">\1</a></li>?
}
s/.*\*\//\*\//
# convert /heading in source files to bold font and add some space
s#\\heading \(.*\)#<br><b>\1</b>#g
# add a linebreak
s#\\linebreak#<br>#g
}
# -----------------------------------------------------------------------------

214
bin/tools/foamConfigurePaths Executable file
View File

@ -0,0 +1,214 @@
#!/bin/sh
#---------------------------------*- sh -*-------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# foamConfigurePaths
#
# Description
# hardcode installation directory
#
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: ${0##*/}
--foamInstall dir specify installation directory (e.g. /opt)
--projectName name specify project name (e.g. openfoam220)
--projectVersion ver specify project version (e.g. 2.2.0)
--archOption arch specify architecture option (only 32 or 64 applicable)
--paraviewInstall dir specify ParaView_DIR (e.g. /opt/paraviewopenfoam3120)
--paraviewVersion ver specify ParaView_VERSION (e.g. 3.12.0)
--scotchArchPath dir specify SCOTCH_ARCH_PATH (e.g. /opt/OpenFOAM-scotch-6.0.0/)
--scotchVersion ver specify SCOTCH_VERSION (e.g. 6.0.0)
* hardcode paths to installation
USAGE
exit 1
}
# Function to do replacement on file. Checks if any replacement has been done.
# _inlineSed <file> <regexp> <replacement> <msg>
_inlineSed()
{
file="$1"
[ -f "$file" ] || {
echo "Missing file: $file"
exit 1
}
regexp="$2"
replacement="$3"
msg="$4"
cmd='/^[^#]/s@'"$regexp"'@'"$replacement"'@'
grep -q "$regexp" "$file" && sed -i -e "$cmd" "$file" || \
(echo "Failed: $msg in $file" && exit 1)
echo "Okay: $msg in $file"
return 0
}
[ -f etc/bashrc ] || usage "Please run from top-level directory of installation"
unset foamInstall projectName projectVersion archOption
unset paraviewInstall scotchArchPath
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help | --help)
usage
;;
-foamInstall | --foamInstall)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
foamInstall="$2"
# replace foamInstall=...
_inlineSed \
etc/bashrc \
'foamInstall=.*' \
'foamInstall='"$foamInstall" \
"Replacing foamInstall setting by '$foamInstall'"
shift 2
;;
-projectName | --projectName)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
projectName="$2"
# replace WM_PROJECT_DIR=...
_inlineSed \
etc/bashrc \
'WM_PROJECT_DIR=.*' \
'WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/'"$projectName" \
"Replacing WM_PROJECT_DIR setting by $projectName"
shift 2
;;
--projectVersion)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
projectVersion="$2"
# replace WM_PROJECT_VERSION=...
echo "Replacing WM_PROJECT_VERSION setting by $projectVersion"
_inlineSed \
etc/bashrc \
'WM_PROJECT_VERSION=.*' \
'WM_PROJECT_VERSION='"$projectVersion" \
"Replacing WM_PROJECT_VERSION setting by $projectVersion"
shift 2
;;
-archOption | --archOption)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
archOption="$2"
current_archOption=`grep WM_ARCH_OPTION= etc/bashrc | sed "s/export WM_ARCH_OPTION=//"`
if [ "$archOption" != "$current_archOption" ]
then
# replace WM_ARCH_OPTION=...
_inlineSed \
etc/bashrc \
'WM_ARCH_OPTION=.*' \
'WM_ARCH_OPTION='"$archOption" \
"Replacing WM_ARCH_OPTION setting by '$archOption'"
else
echo "WM_ARCH_OPTION already set to $archOption"
fi
shift 2
;;
-paraviewInstall | --paraviewInstall)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
paraviewInstall="$2"
# replace ParaView_DIR=...
_inlineSed \
etc/config/paraview.sh \
'ParaView_DIR=.*' \
'ParaView_DIR='"$paraviewInstall" \
"Replacing ParaView_DIR setting by '$paraviewInstall'"
shift 2
;;
-paraviewVersion | --paraviewVersion)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
paraviewVersion="$2"
# replace ParaView_VERSION=...
_inlineSed \
etc/config/paraview.sh \
'ParaView_VERSION=.*' \
'ParaView_VERSION='"$paraviewVersion" \
"Replacing ParaView_VERSION setting by '$paraviewVersion'"
shift 2
;;
-scotchVersion | --scotchVersion)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
scotchVersion="$2"
_inlineSed \
etc/config/scotch.sh \
'SCOTCH_VERSION=.*' \
'SCOTCH_VERSION='"$scotchVersion" \
"Replacing SCOTCH_VERSION setting by '$scotchVersion'"
shift 2
;;
-scotchArchPath | --scotchArchPath)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
scotchArchPath="$2"
_inlineSed \
etc/config/scotch.sh \
'SCOTCH_ARCH_PATH=.*' \
'SCOTCH_ARCH_PATH='"$scotchArchPath" \
"Replacing SCOTCH_ARCH_PATH setting by '$scotchArchPath'"
shift 2
;;
*)
usage "unknown option/argument: '$*'"
;;
esac
done
[ -n "$foamInstall" -o -n "$projectName" -o -n "$projectVersion" -o -n "$archOption" \
-o -n "$paraviewInstall" -o -n "$paraviewVersion" \
-o -n "$scotchVersion" -o -n "$scotchArchPath" \
] || usage "Please specify at least one configure option"
#echo "Replacing WM_PROJECT setting by '$projectName'"
#sed -i -e 's@WM_PROJECT=.*@WM_PROJECT='"$projectName@" etc/bashrc
# Set WM_MPLIB=SYSTEMOPENMPI always
_inlineSed \
etc/bashrc \
'export WM_MPLIB=.*' \
'export WM_MPLIB=SYSTEMOPENMPI' \
"Replacing WM_MPLIB setting by 'SYSTEMOPENMPI'"
## set foamCompiler=system always
#_inlineSed \
# etc/bashrc \
# 'foamCompiler=.*' \
# 'foamCompiler=system' \
# "Replacing foamCompiler setting by 'system'"
#------------------------------------------------------------------------------

117
bin/tools/foamListBinDirs Executable file
View File

@ -0,0 +1,117 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# foamListBinDirs <directory> [archOptions]
#
# Description
# Lists directories containing binary files of OpenFOAM
#
# Note
# Not normally called directly by the user.
#------------------------------------------------------------------------------
toolsDir="${0%/*}" # this script is already located in the tools/ directory
[ $# -eq 1 -o $# -eq 2 ] || {
cat <<USAGE 1>&2
Usage : ${0##*/} <packDir> [archOptions]
* Lists directories containing binary files for OpenFOAM
The value of 'archOptions' normally corresponds to \$WM_OPTIONS
The current value of \$WM_OPTIONS = $WM_OPTIONS
USAGE
exit 1
}
#------------------------------------------------------------------------------
packDir="$1"
# default to same as $WM_OPTIONS - eg, 'linux64GccDPOpt'
archOptions="${2:-$WM_OPTIONS}"
[ -n "$archOptions" ] || {
echo "Error: no archOptions specified" 1>&2
exit 1
}
# base arch (w/o precision, optimization, etc)
# same as "$WM_ARCH$WM_COMPILER"
archCompiler=$(echo "$archOptions" | sed -e 's@[DS]P.*$@@')
# same as $WM_ARCH - eg, 'linux64'
# TODO: only works for Gcc, Icc, Clang
archOS=$(echo "$archOptions" | sed -e 's@[GI]cc.*$@@' -e 's@Clang.*$@@')
# links for 32-bit version, eg convert linux64 -> linux-64
arch3264=$(echo "$archOS" | sed -e 's@64@-64@')
#------------------------------------------------------------------------------
# check for essential directories
for dir in \
$packDir \
$packDir/platforms/$archOptions/bin \
$packDir/platforms/$archOptions/lib \
;
do
[ -d $dir ] || {
echo "Error: directory $dir does not exist" 1>&2
exit 1
}
done
#------------------------------------------------------------------------------
# list of directories
dirList=$(
for dir in \
$packDir/platforms/$archOptions/bin \
$packDir/platforms/$archOptions/lib \
$packDir/wmake/platforms/$archCompiler \
$packDir/wmake/platforms/$archOS \
$packDir/wmake/rules/General \
$packDir/wmake/rules/$archCompiler \
$packDir/wmake/rules/$archOS \
;
do
[ -d $dir ] && echo $dir
done
)
cat <<INFO 1>&2
-------------------------------------------------------------------------------
Packing $archOptions ($archCompiler) port of $packDir
archOS = $archOS
32bit archOS = $arch3264
dirs:
$(echo ${dirList:-NONE})
INFO
echo "$dirList"
#------------------------------------------------------------------------------

91
bin/tools/foamListSourceFiles Executable file
View File

@ -0,0 +1,91 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# foamListSourceFiles <directory>
#
# Description
# Lists source files and Make/{files,options} in given directory
#
# Note
# Not normally called directly by the user.
#------------------------------------------------------------------------------
[ $# -eq 1 ] || {
cat <<USAGE 1>&2
Usage : ${0##*/} directory
* Lists source files and Make/{files,options} in given directory
USAGE
exit 1
}
# canonical form (no double and no trailing dashes)
packDir=$(echo "$1" | sed -e 's@//*@/@g' -e 's@/$@@')
# check for essential directories
[ -d "$packDir" ] || {
echo "Error: directory $packDir does not exist" 1>&2
exit 1
}
#
# list of files but excluding
# - dependent files (dep, obj, lib), archives
# - exclude Doxygen documentation etc
#
find -H $packDir \
! -type d \
\( -type f -o -type l \) \
! -name "*~" \
-a ! -name ".*~" \
-a ! -name "*.orig" \
-a ! -name "*.dep" \
-a ! -name "*.o" \
-a ! -name "*.so" \
-a ! -name "*.a" \
-a ! -name "*.tar" \
-a ! -name "*.tar.gz" \
-a ! -name "*.tgz" \
-a ! -name "*.tar.bz2" \
-a ! -name "*.tbz" \
-a ! -name "core" \
-a ! -name "core.[1-9]*" \
-a ! -name "libccmio*" \
| sed \
-e '\@/\.git/@d' \
-e '\@/\.tags/@d' \
-e '\@/platforms/@d' \
-e '\@/t/@d' \
-e '\@/Make[.A-Za-z]*/[^/]*/@d' \
-e '\@/[Dd]oxygen/html/@d' \
-e '\@/download/@d' \
-e '\@/libccmio-.*/@d' \
-e '\@/debian/@d'
#------------------------------------------------------------------------------

View File

@ -0,0 +1,123 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# foamListThirdPartyBinDirs <directory> [archOptions]
#
# Description
# Lists directories containing binary files for OpenFOAM ThirdParty
#
# Note
# Not normally called directly by the user.
#------------------------------------------------------------------------------
toolsDir="${0%/*}" # this script is already located in the tools/ directory
[ $# -eq 1 -o $# -eq 2 ] || {
cat <<USAGE 1>&2
Usage : ${0##*/} <packDir> [archOptions]
* List directories containing binary files for OpenFOAM ThirdParty
The value of 'archOptions' normally corresponds to \$WM_OPTIONS
The current value of \$WM_OPTIONS = $WM_OPTIONS
USAGE
exit 1
}
#------------------------------------------------------------------------------
packDir="$1"
# default to same as $WM_OPTIONS - eg, 'linux64GccDPOpt'
archOptions="${2:-$WM_OPTIONS}"
[ -n "$archOptions" ] || {
echo "Error: no archOptions specified" 1>&2
exit 1
}
# base arch (w/o precision, optimization, etc)
# same as "$WM_ARCH$WM_COMPILER"
archCompiler=$(echo "$archOptions" | sed -e 's@[DS]P.*$@@')
# same as $WM_ARCH - eg, 'linux64'
# TODO: only works for Gcc, Icc, Clang
archOS=$(echo "$archOptions" | sed -e 's@[GI]cc.*$@@' -e 's@Clang.*$@@')
# links for 32-bit version, eg convert linux64 -> linux-64
arch3264=$(echo "$archOS" | sed -e 's@64@-64@')
#------------------------------------------------------------------------------
# check for essential directories
for dir in \
$packDir \
$packDir/platforms/$archOptions/lib \
;
do
[ -d $dir ] || {
echo "Error: directory $dir does not exist" 1>&2
exit 1
}
done
#------------------------------------------------------------------------------
# list of directories
dirList=$(
for dir in \
$packDir/platforms/$archOptions \
$packDir/platforms/$archCompiler \
$packDir/platforms/$archOS \
;
do
[ -d $dir ] && echo $dir
done
# add in links for 32-bit version
if [ "$archOS" != "$arch3264" ]
then
for dir in \
$packDir/platforms/$arch3264 \
;
do
[ -d $dir -a -L $dir ] && echo $dir
done
fi
)
cat <<INFO 1>&2
-------------------------------------------------------------------------------
Packing $archOptions ($archCompiler) port of $packDir
archOS = $archOS
32bit archOS = $arch3264
dirs:
$(echo ${dirList:-NONE})
INFO
echo "$dirList"
#------------------------------------------------------------------------------

55
bin/tools/foamLog.db Normal file
View File

@ -0,0 +1,55 @@
#------------------------------------------------------------------------------
# Query database for Foam Log extraction.
# Each line stands for one query:
#
# name '/' line selector '/' column selector
#
# e.g.
# kMin/bounding k,/min:
#
# The extraction will select a line using 'bounding k,' and in the line
# takes the word following 'min:' as the value.
#
# A special entry is the 'Separator' entry which delimits one iteration
# from the other.
#
#------------------------------------------------------------------------------
#- String to recognize new iteration by (usually same as 'Time')
Separator/^[ \t]*Time = /Time =
#- Time value:
Time/^[ \t]*Time = /Time =
#- Continuity errors:
contLocal/time step continuity errors :/sum local =
contGlobal/time step continuity errors :/ global =
contCumulative/time step continuity errors :/cumulative =
#- Special for combustion code:
minFu/min\(fu\) = /min(fu) =
minFt/min\(ft\) = /min(ft) =
#- Execution time:
executionTime/ExecutionTime = /ExecutionTime =
#- Courant no:
CourantMax/Courant Number /max:
CourantMean/Courant Number /mean:
#- K bounding
kMin/bounding k,/min:
kMax/bounding k,/max:
kAvg/bounding k,/average:
#- epsilon bounding
epsMin/bounding epsilon,/min:
epsMax/bounding epsilon,/max:
epsAvg/bounding epsilon,/average:
#- gamma bounding
alpha1Min/Min\(alpha1\) =/Min(alpha1) =
alpha1Max/Max\(alpha1\) =/Max(alpha1) =
# AMI
AMIMin/AMI: Patch source sum/average =

62
bin/tools/gtagsrc Normal file
View File

@ -0,0 +1,62 @@
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Canfiguration file
# gtagsrc
#
# Description
# Configuration file for gtags(1).
#
#------------------------------------------------------------------------------
default:\
:tc=gtags:tc=htags:
#------------------------------------------------------------------------------
# Configuration for gtags(1)
# See gtags(1).
#------------------------------------------------------------------------------
common:\
:skip=GPATH,GTAGS,GRTAGS,GSYMS,HTML/,HTML.pub/,html/,tags,TAGS,ID,.ebrowse,.etags,.etagsDef,.etagsDec,y.tab.c,y.tab.h,.notfunction,cscope.out,cscope.po.out,cscope.in.out,.gdbinit,SCCS/,RCS/,CVS/,CVSROOT/,{arch}/,.svn/,.git/,.cvsrc,.cvsignore,.gitignore,.cvspass,.cvswrappers,.deps/,autom4te.cache/,.snprj/:\
:langmap=c\:.c.h,yacc\:.y,asm\:.s.S,java\:.java,cpp\:.c++.cc.cpp.cxx.hxx.hpp.C.H,php\:.php.php3.phtml:
gtags:\
:tc=common:\
:GTAGS=gtags-parser %s:\
:GRTAGS=gtags-parser -r %s:\
:GSYMS=gtags-parser -s %s:\
:skip=lnInclude/,tutorials/,wmake/,doc/,lib/,etc/:
#
#------------------------------------------------------------------------------
# Configuration for htags(1)
#------------------------------------------------------------------------------
htags:\
:body_begin=<body text='#191970' bgcolor='#f5f5dc' vlink='gray'>:body_end=</body>:\
:table_begin=<table>:table_end=</table>:\
:title_begin=<h1><font color='#cc0000'>:title_end=</font></h1>:\
:comment_begin=<i><font color='green'>:comment_end=</font></i>:\
:sharp_begin=<font color='darkred'>:sharp_end=</font>:\
:brace_begin=<font color='red'>:brace_end=</font>:\
:warned_line_begin=<span style='background-color\:yellow'>:warned_line_end=</span>:\
:reserved_begin=<b>:reserved_end=</b>:script_alias=/cgi-bin/:\
:ncol#4:tabs#8:normal_suffix=html:gzipped_suffix=ghtml:\
:definition_header=no:
#------------------------------------------------------------------------------

30
bin/tools/inlineReplace Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
# $0 oldString newString file1 .. fileN
#
if [ $# -lt 3 ]
then
echo "Usage: ${0##*/} <oldString> <newString> <file1> [.. fileN]"
echo ""
echo "Replaces all occurrences of oldString by newString in files."
echo "(replacement for sed -i on systems that don't support it)"
exit 1
fi
oldString="$1"
newString="$2"
shift 2
for f
do
if grep "$oldString" "$f" >/dev/null
then
cp "$f" "${f}_bak"
sed -e "s@$oldString@$newString@g" "${f}_bak" > "$f"
rm -f "${f}_bak"
#else
# echo "String $oldString not present in $f"
fi
done
# ----------------------------------------------------------------- end-of-file

134
bin/tools/org-batch Executable file
View File

@ -0,0 +1,134 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# org-batch
#
# Description
# Batch process emacs org-mode files to create html/LaTeX etc.
#
#------------------------------------------------------------------------------
Script=${0##*/}
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script [OPTIONS] file1 [.. fileN]
options:
-html create html (default)
-latex create LaTeX
-pdflatex create pdf via pdflatex
* Batch process emacs org-mode files to create html/LaTeX etc.
USAGE
exit 1
}
# default is html export:
mode=html
unset makePDF
echo "have $Script"
case $Script in
*pdflatex)
mode=latex
makePDF=pdflatex
;;
*latex)
mode=latex
;;
*html)
mode=html
;;
esac
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-html)
mode=html
shift
;;
-latex)
mode=latex
shift
;;
-pdflatex)
mode=latex
makePDF=pdflatex
shift
;;
-*)
usage "unknown option: '$*'"
;;
*)
break
;;
esac
done
# default is the current directory
[ "$#" -gt 0 ] || usage "No files specified"
type emacs >/dev/null 2>&1 || usage "No emacs found in PATH"
for org
do
echo "Processing: $org"
echo "----------"
if [ -f "$org" ]
then
emacs --batch -l org --visit=$org \
--funcall org-export-as-$mode-batch
# post-processing step to create pdf
case "$makePDF" in
pdflatex)
input="${org%.org}.tex"
if [ -f "$input" ]
then
pdflatex "$input"
else
echo "No $input to convert to pdf"
fi
;;
esac
else
echo "File not found"
fi
echo "----------"
done
#------------------------------------------------------------------------------

328
bin/tools/pre-commit-hook Executable file
View File

@ -0,0 +1,328 @@
#!/bin/bash
#---------------------------------*- sh -*-------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# pre-commit-hook
#
# Description
# pre-commit hook for git.
# Copy or link this file as ".git/hooks/pre-commit"
#
# Eg,
# (
# cd $WM_PROJECT_DIR/.git/hooks &&
# ln -sf ../../bin/tools/pre-commit-hook pre-commit
# )
#
# Hook receives: empty
#
# Checks for
# - illegal code, e.g. <TAB>
# - columns greater than 80 for *.[CH] files
#
# Note
# Using "git commit --no-verify" it is possible to override the hook.
#
# By supplying arguments to the hook, it can also be used to manually
# test the specified files/directories for standards conformance.
#
#------------------------------------------------------------------------------
hookName="pre-commit"
die()
{
echo "$hookName hook failure" 1>&2
echo '-----------------------------------' 1>&2
echo '' 1>&2
echo "$@" 1>&2
echo '' 1>&2
exit 1
}
#-----------------------------------------------------------------------------
# Check content that will be added by this commit.
if git rev-parse --verify HEAD > /dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# called manually with arguments for the files/directories to be tested?
if [ "$#" -gt 0 ]
then
case "$1" in
-h | -help)
die "interactive usage: supply list of files/directories to check"
;;
esac
# obtain list of all specified files/directories
fileList=$(git ls-files -- $@ 2>/dev/null)
else
# list of all files to be committed
fileList=$(git diff-index --cached --name-only $against --)
fi
#
# no files changed: can skip all the checks
# this usage can correspond to a 'git commit --amend'
#
[ -n "$fileList" ] || exit 0
unset badFiles
# join list of files with this amount of space
Indent=" "
#
# report bad files and die if there are any
#
dieOnBadFiles()
{
if [ -n "$badFiles" ]
then
echo "$hookName hook failure" 1>&2
echo '-----------------------------------' 1>&2
echo "$@" 1>&2
echo '' 1>&2
echo "File(s):" 1>&2
echo "$badFiles" 1>&2
echo '' 1>&2
exit 1
fi
}
#
# qualify 'git grep' to check cached value or from a specific commit
#
gitScope()
{
if [ "$#" -gt 0 ]
then
echo "$1:"
else
echo "--cached -- "
fi
}
#
# check for bad strings, characters, etc
#
checkIllegalCode()
{
echo "$hookName: check bad strings/characters etc ..." 1>&2
reBad="("$'\t'")"
msgBad="<TAB>"
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
do
case "$f" in
# exclude potential makefiles
(*[Mm]akefile* | wmake/rules/* | *.f* | *.v[cf]proj | *.pdf | *.png | *.html | *.gif | *.css | *.gz)
;;
(*)
fileType=`file -b $f`
if [ "$fileType" != "data" ]
then
# parse line numbers from grep output:
# <lineNr>: contents
lines=$(git grep -E -hn -e "$reBad" $scope"$f" |
sed -e 's@:.*@@' |
tr '\n' ' '
)
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
fi
;;
esac
done
)
dieOnBadFiles "Remove/correct bad '$msgBad' references"
}
#
# limit line length to 80-columns
#
checkLineLength()
{
echo "$hookName: check line lengths ..." 1>&2
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
do
# limit to *.[CH] files
case "$f" in
(*.[CH])
# parse line numbers from grep output:
# <lineNr>: contents
lines=$(git grep -hn -e '^.\{81,\}' $scope"$f" |
sed -e 's@:.*@@' |
tr '\n' ' '
)
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
;;
esac
done
)
dieOnBadFiles "Limit code to 80 columns before pushing"
}
#
# limit line length to 80-columns, except C++ comment lines
#
checkLineLengthNonComments()
{
echo "$hookName: check line lengths ..." 1>&2
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
do
# limit to *.[CH] files
case "$f" in
(*.[CH])
# parse line numbers from grep output:
# <lineNr>: contents
lines=$(git grep -hn -e '^.\{81,\}' \
--and --not -e '^ *//' \
$scope"$f" |
sed -e 's@:.*@@' |
tr '\n' ' '
)
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
;;
esac
done
)
dieOnBadFiles "Limit code to 80 columns before pushing"
}
#
# limit line length to 80-columns, except #directive lines
#
checkLineLengthNonDirective()
{
echo "$hookName: check line lengths ..." 1>&2
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
do
# limit to *.[CH] files
case "$f" in
(*.[CH])
# parse line numbers from grep output:
# <lineNr>: contents
lines=$(git grep -hn -e '^.\{81,\}' \
--and --not -e '^ *#' \
$scope"$f" |
sed -e 's@:.*@@' |
tr '\n' ' '
)
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
;;
esac
done
)
dieOnBadFiles "Limit code to 80 columns before pushing"
}
#
# check that OpenFOAM Foundation copyright is current
#
checkCopyright()
{
year=$(date +%Y)
echo "$hookName: check copyright ..." 1>&2
badFiles=$(
for f in $fileList
do
startYear=`grep "Copyright.*OpenFOAM" $f | sed 's/[^0-9]*\([0-9]*\).*/\1/g'`
endYear=`grep "Copyright.*-.*OpenFOAM" $f | sed 's/[^-]*-\([0-9]*\).*/\1/g'`
#echo "startYear=$startYear endYear=$endYear"
if [ "$startYear" != "" ]
then
if [ "$endYear" != "" ]
then
# Date is of type 2011-2012 OpenFOAM Foundation
if [ "$year" != "$endYear" ]
then
echo "Updated copyright for: $f" 1>&2
echo "$f"
sed -i "s/$startYear-$endYear OpenFOAM/$startYear-$year OpenFOAM/g" $f
fi
else
# Date is of type 2011 OpenFOAM Foundation
if [ "$year" != "$startYear" ]
then
echo "$f"
echo "Updated copyright for: $f" 1>&2
sed -i "s/$startYear OpenFOAM/$startYear-$year OpenFOAM/g" $f
fi
fi
fi
done
)
dieOnBadFiles "Some copyright dates were automatically updated; Please check these before pushing"
}
#------------------------------------------------------------------------------
# Main code : do all checks
#
# builtin whitespace check to avoid trailing space, including CR-LF endings
bad=$(git diff-index --cached --check $against --) || die "$bad"
# check for illegal code, e.g. <TAB>, etc
checkIllegalCode
# ensure code conforms to 80 columns max
checkLineLengthNonDirective
checkCopyright
exit 0
#------------------------------------------------------------------------------

272
bin/tools/pre-receive-hook Executable file
View File

@ -0,0 +1,272 @@
#!/bin/bash
#---------------------------------*- sh -*-------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# pre-receive-hook
#
# Description
# pre-receive hook for git.
# Copy or link this file as ".git/hooks/pre-receive"
#
# Eg,
# (
# cd $WM_PROJECT_DIR/.git/hooks &&
# ln -sf ../../bin/tools/pre-receive-hook pre-receive
# )
#
# Hook receives: <old-sha1> <new-sha1> <ref-name>
#
# Checks for
# - illegal code, e.g. <TAB>
# - columns greater than 80 for *.[CH] files
#
#------------------------------------------------------------------------------
hookName="pre-receive"
die()
{
echo "$hookName hook failure" 1>&2
echo '-----------------------------------' 1>&2
echo '' 1>&2
echo "$@" 1>&2
echo '' 1>&2
exit 1
}
#-----------------------------------------------------------------------------
unset fileList
unset badFiles
# join list of files with this amount of space
Indent=" "
#
# report bad files and die if there are any
#
dieOnBadFiles()
{
if [ -n "$badFiles" ]
then
echo "$hookName hook failure" 1>&2
echo '-----------------------------------' 1>&2
echo "$@" 1>&2
echo '' 1>&2
echo "File(s):" 1>&2
echo "$badFiles" 1>&2
echo '' 1>&2
exit 1
fi
}
#
# qualify 'git grep' to check cached value or from a specific commit
#
gitScope()
{
if [ "$#" -gt 0 ]
then
echo "$1:"
else
echo "--cached -- "
fi
}
#
# check for bad strings, characters, etc
#
checkIllegalCode()
{
echo "$hookName: check bad strings/characters etc ..." 1>&2
reBad="("$'\t'"|"$'\r\n'")"
msgBad="<TAB> or DOS-line-endings"
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
do
case "$f" in
# exclude potential makefiles
(*[Mm]akefile* | wmake/rules/*)
;;
(*)
# parse line numbers from grep output:
# <lineNr>: contents
lines=$(git grep -E -hn -e "$reBad" $scope"$f" |
sed -e 's@:.*@@' |
tr '\n' ' '
)
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
;;
esac
done
)
dieOnBadFiles "Remove/correct bad '$msgBad' references"
}
#
# limit line length to 80-columns
#
checkLineLength()
{
echo "$hookName: check line lengths ..." 1>&2
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
do
# limit to *.[CH] files
case "$f" in
(*.[CH])
# parse line numbers from grep output:
# <lineNr>: contents
lines=$(git grep -hn -e '^.\{81,\}' $scope"$f" |
sed -e 's@:.*@@' |
tr '\n' ' '
)
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
;;
esac
done
)
dieOnBadFiles "Limit code to 80 columns before pushing"
}
#
# limit line length to 80-columns, except C++ comment lines
#
checkLineLengthNonComments()
{
echo "$hookName: check line lengths ..." 1>&2
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
do
# limit to *.[CH] files
case "$f" in
(*.[CH])
# parse line numbers from grep output:
# <lineNr>: contents
lines=$(git grep -hn -e '^.\{81,\}' \
--and --not -e '^ *//' \
$scope"$f" |
sed -e 's@:.*@@' |
tr '\n' ' '
)
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
;;
esac
done
)
dieOnBadFiles "Limit code to 80 columns before pushing"
}
#
# limit line length to 80-columns, except #directive lines
#
checkLineLengthNonDirective()
{
echo "$hookName: check line lengths ..." 1>&2
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
do
# limit to *.[CH] files
case "$f" in
(*.[CH])
# parse line numbers from grep output:
# <lineNr>: contents
lines=$(git grep -hn -e '^.\{81,\}' \
--and --not -e '^ *#' \
$scope"$f" |
sed -e 's@:.*@@' |
tr '\n' ' '
)
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
;;
esac
done
)
dieOnBadFiles "Limit code to 80 columns before pushing"
}
#------------------------------------------------------------------------------
# Main code : do all checks
#
while read oldSHA1 newSHA1 refName
do
unset fileList rawFileList
if [ "$newSHA1" = 0 ]
then
# ref to be deleted
continue
elif [ "$oldSHA1" = 0 ]
then
# ref to be created
rawFileList=$(git diff-tree --root $newSHA1)
else
# normal changes
rawFileList=$(git diff --name-only $oldSHA1..$newSHA1)
fi
#
# no files changed: can skip all the checks
#
[ -n "$rawFileList" ] || continue
fileList=$(
for f in $rawFileList
do
git cat-file -e $newSHA1:$f > /dev/null 2>&1 && echo "$f"
done
)
# check for illegal code, e.g. <TAB>, etc
checkIllegalCode $newSHA1
# ensure code conforms to 80 columns max
checkLineLengthNonDirective $newSHA1
done
exit 0
#------------------------------------------------------------------------------

17
bin/tools/replaceAllShellSun Executable file
View File

@ -0,0 +1,17 @@
#!/usr/xpg4/bin/sh
# Replace all shell script headers with
if [ $# -ne 1 -o ! -d "$1" ]
then
echo "Usage: ${0##*/} <dir>"
echo ""
echo "Replaces all occurrences of #!/bin/sh with #!/usr/xpg4/bin/sh inside a directory tree."
exit 1
fi
#- note that below does not work since {} does not get replaced
#find $1 -type f -exec /usr/xpg4/bin/sh -c "grep '^#\!/bin/sh' {} >/dev/null && echo {} && mv {} {}_bak && sed -e 's@^#\!/bin/sh@#\!/usr/xpg4/bin/sh@' {}_bak > {}" ';'
find $1 -exec $WM_PROJECT_DIR/bin/tools/inlineReplace '^#\!/bin/sh' '#\!/usr/xpg4/bin/sh' {} \; -print
# ----------------------------------------------------------------- end-of-file

8
bin/tools/scanpackages Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
#
# Generate Packages file on debian repositories.
for D in `find . -mindepth 4 -type d`
do
dpkg-scanpackages $D | gzip -9c > ${D}/Packages.gz
done