Commit 1ec1d335 authored by Mark Olesen's avatar Mark Olesen
Browse files

Merge remote branch 'bundle/olesenm' into home

parents fd2f0a13 7cb9c39b
......@@ -27,7 +27,11 @@ int main()
Info<< magSqr(d) << endl;
vector d2(0.5, 0.51, -0.5);
Info<< cmptMax(d2) << " " << cmptSum(d2) << " " << cmptMag(d2) << endl;
Info<< cmptMax(d2) << " "
<< cmptSum(d2) << " "
<< cmptProduct(d2) << " "
<< cmptMag(d2)
<< endl;
Info<< min(d, d2) << endl;
return 0;
}
......@@ -27,6 +27,7 @@ setFormat raw;
// Surface output format. Choice of
// null : suppress output
// ensight : Ensight Gold format, one field per case file
// foamFile : separate points, faces and values file
// dx : DX scalar or vector format
// vtk : VTK ascii format
......
......@@ -49,9 +49,10 @@
# test the specified files/directories for standards conformance.
#
#------------------------------------------------------------------------------
hookName="pre-commit"
die()
{
echo 'pre-commit hook failure' 1>&2
echo '$hookName hook failure' 1>&2
echo '-----------------------' 1>&2
echo '' 1>&2
echo "$@" 1>&2
......@@ -104,7 +105,7 @@ dieOnBadFiles()
{
if [ -n "$badFiles" ]
then
echo 'pre-commit hook failure' 1>&2
echo '$hookName hook failure' 1>&2
echo '-----------------------' 1>&2
echo "$@" 1>&2
echo '' 1>&2
......@@ -116,22 +117,38 @@ dieOnBadFiles()
}
#
# 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 "pre-commit: check bad strings/characters etc ..." 1>&2
echo "$hookName: check bad strings/characters etc ..." 1>&2
reBad="(N""abla|"$'\t'")"
msgBad="N""abla or <TAB>"
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
do
# parse line numbers from grep output:
# <lineNr>: contents
lines=$(git grep --cached -E -hn -e "$reBad" -- "$f" |
lines=$(git grep -E -hn -e "$reBad" $scope"$f" |
sed -e 's@:.*@@' |
tr '\n' ' '
)
......@@ -149,7 +166,9 @@ checkIllegalCode()
checkCopyright()
{
year=$(date +%Y)
echo "pre-commit: check copyright ..." 1>&2
echo "$hookName: check copyright ..." 1>&2
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
......@@ -160,10 +179,10 @@ checkCopyright()
# parse line numbers from grep output:
# <lineNr>: contents
#
lines=$(git grep --cached -F -hn -e Copyright \
lines=$(git grep -F -hn -e Copyright \
--and -e OpenCFD \
--and --not -e "$year" \
-- "$f" |
$scope"$f" |
sed -e 's@:.*@@' |
tr '\n' ' '
)
......@@ -180,7 +199,9 @@ checkCopyright()
#
checkLineLength()
{
echo "pre-commit: check line lengths ..." 1>&2
echo "$hookName: check line lengths ..." 1>&2
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
......@@ -190,7 +211,7 @@ checkLineLength()
(*.[CH])
# parse line numbers from grep output:
# <lineNr>: contents
lines=$(git grep --cached -hn -e '^.\{81,\}' -- "$f" |
lines=$(git grep -hn -e '^.\{81,\}' $scope"$f" |
sed -e 's@:.*@@' |
tr '\n' ' '
)
......@@ -209,7 +230,9 @@ checkLineLength()
#
checkLineLengthNonComments()
{
echo "pre-commit: check line lengths ..." 1>&2
echo "$hookName: check line lengths ..." 1>&2
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
......@@ -219,9 +242,9 @@ checkLineLengthNonComments()
(*.[CH])
# parse line numbers from grep output:
# <lineNr>: contents
lines=$(git grep --cached -hn -e '^.\{81,\}' \
lines=$(git grep -hn -e '^.\{81,\}' \
--and --not -e "^ *//" \
-- "$f" |
$scope"$f" |
sed -e 's@:.*@@' |
tr '\n' ' '
)
......@@ -234,12 +257,15 @@ checkLineLengthNonComments()
dieOnBadFiles "Limit code to 80 columns before pushing"
}
#
# limit line length to 80-columns, except #directive lines
#
checkLineLengthNonDirective()
{
echo "pre-commit: check line lengths ..." 1>&2
echo "$hookName: check line lengths ..." 1>&2
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
......@@ -249,9 +275,9 @@ checkLineLengthNonDirective()
(*.[CH])
# parse line numbers from grep output:
# <lineNr>: contents
lines=$(git grep --cached -hn -e '^.\{81,\}' \
lines=$(git grep -hn -e '^.\{81,\}' \
--and --not -e "^ *#" \
-- "$f" |
$scope"$f" |
sed -e 's@:.*@@' |
tr '\n' ' '
)
......@@ -265,9 +291,9 @@ checkLineLengthNonDirective()
}
# do all checks
# ~~~~~~~~~~~~~
#------------------------------------------------------------------------------
# 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"
......
#!/bin/bash
#---------------------------------*- sh -*-------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2010-2010 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 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>
# - copyright is current, e.g. if present, contains XXX-<current-year>
# - 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="(N""abla|"$'\t'"|"$'\r\n'")"
msgBad="N""abla, <TAB> or DOS-line-endings"
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
do
# 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"
done
)
dieOnBadFiles "Remove/correct bad '$msgBad' references"
}
#
# check that OpenCFD copyright is current
#
checkCopyright()
{
year=$(date +%Y)
echo "$hookName: check copyright ..." 1>&2
scope=$(gitScope $@)
badFiles=$(
for f in $fileList
do
# NB: need to have OpenCFD on a separate line to prevent
# this check being caught by itself!
#
# parse line numbers from grep output:
# <lineNr>: contents
#
lines=$(git grep -F -hn -e Copyright \
--and -e OpenCFD \
--and --not -e "$year" \
$scope"$f" |
sed -e 's@:.*@@' |
tr '\n' ' '
)
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
done
)
dieOnBadFiles "Update copyright year, e.g. XXXX-$year"
}
#
# 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 OpenCFD copyright contains correct year
checkCopyright $newSHA1
# ensure code conforms to 80 columns max
checkLineLengthNonDirective $newSHA1
done
exit 0
#------------------------------------------------------------------------------
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2010-2010 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 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
# scotch/bashrc
#
# Description
# Setup file for scotch include/libraries.
# Sourced during wmake process only.
#
# Note
# A csh version is not needed, since the values here are only sourced
# during the wmake process
#------------------------------------------------------------------------------
export SCOTCH_VERSION=scotch_5.1.10b
export SCOTCH_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$SCOTCH_VERSION
# -----------------------------------------------------------------------------
......@@ -69,14 +69,10 @@ setenv WM_THIRD_PARTY_DIR $WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION
# Source files, possibly with some verbosity
alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; source \!*'
alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; if (\!* != "") source \!*'
# Add in preset user or site preferences:
set foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh`
if ( $status == 0 ) then
_foamSource $foamPrefs
endif
unset foamPrefs
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh`
# Evaluate command-line parameters
while ( $#argv > 0 )
......@@ -255,17 +251,8 @@ _foamSource $WM_PROJECT_DIR/etc/aliases.csh
# Source user setup files for optional packages
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set paraview3=`$WM_PROJECT_DIR/bin/foamEtcFile apps/paraview3/cshrc`
if ( $status == 0 ) then
_foamSource $paraview3
endif
unset paraview3
set ensight=`$WM_PROJECT_DIR/bin/foamEtcFile apps/ensight/cshrc`
if ( $status == 0 ) then
_foamSource $ensight
endif
unset ensight
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile apps/paraview3/cshrc`
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile apps/ensight/cshrc`
# Clean environment paths again. Only remove duplicates
......
......@@ -145,6 +145,13 @@ void Foam::stableSort(UList<T>& a, const Cmp& cmp)
}
template<class T>
void Foam::shuffle(UList<T>& a)
{
std::random_shuffle(a.begin(), a.end());
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T>
......
......@@ -344,6 +344,9 @@ void stableSort(UList<T>&);
template<class T, class Cmp>
void stableSort(UList<T>&, const Cmp&);
template<class T>
void shuffle(UList<T>&);
// Reverse the first n elements of the list
template<class T>
inline void reverse(UList<T>&, const label n);
......
......@@ -152,6 +152,12 @@ public:
return ::Foam::mag(max_ - min_);
}
//- The volume of the bound box
scalar volume() const
{
return cmptProduct(span());
}
//- Smallest length/height/width dimension
scalar minDim() const
{
......
......@@ -406,6 +406,17 @@ inline Cmpt cmptAv
return cmptSum(vs)/nCmpt;
}
template<class Form, class Cmpt, int nCmpt>
inline Cmpt cmptProduct
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
)
{
Cmpt product = vs.v_[0];
VectorSpaceOps<nCmpt,1>::SeqOp(product, vs, multiplyEqOp<Cmpt>());
return product;
}
template<class Form, class Cmpt, int nCmpt>
inline Form cmptMag
......
.\" $NetBSD: random.3,v 1.4 1995/12/28 08:52:42 thorpej Exp $
.\"
.\" Copyright (c) 1983, 1991 The Regents of the University of California.
.\" All rights reserved.
.\"