Merge branch 'master' of github.com:OpenFOAM/OpenFOAM-dev

This commit is contained in:
Chris Greenshields
2015-12-15 11:17:00 +00:00
12 changed files with 234 additions and 272 deletions

View File

@ -72,7 +72,7 @@ do
shift 2
;;
-h | -help)
printUsage
usage
;;
-o | -out)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
@ -94,7 +94,7 @@ if [ ! -d $DIR ]; then
fi
FILES=$(find $DIR -type f -name *vtk)
NAMES=$(basename -s .vtk -a $FILES | sort -u)
NAMES=$(for f in $FILES; do basename $f .vtk; done | sort -u)
if [ -d $OUT ]; then
echo "$OUT directory already exists. Deleting links within it..."

View File

@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
# \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
@ -250,7 +250,7 @@ MPICH)
*)
echo
echo "Unsupported WM_MPLIB setting : $WM_MPLIB"
printUsage
usage
exit 1
esac

View File

@ -246,19 +246,44 @@ Foam::fileName Foam::home(const string& userName)
Foam::fileName Foam::cwd()
{
char buf[256];
if (::getcwd(buf, sizeof(buf)))
{
return buf;
}
else
{
FatalErrorInFunction
<< "Couldn't get the current working directory"
<< exit(FatalError);
label pathLengthLimit = POSIX::pathLengthChunk;
List<char> path(pathLengthLimit);
return fileName::null;
// Resize path if getcwd fails with an ERANGE error
while(pathLengthLimit == path.size())
{
if (::getcwd(path.data(), path.size()))
{
return path.data();
}
else if(errno == ERANGE)
{
// Increment path length upto the pathLengthMax limit
if
(
(pathLengthLimit += POSIX::pathLengthChunk)
>= POSIX::pathLengthMax
)
{
FatalErrorInFunction
<< "Attempt to increase path length beyond limit of "
<< POSIX::pathLengthMax
<< exit(FatalError);
}
path.setSize(pathLengthLimit);
}
else
{
break;
}
}
FatalErrorInFunction
<< "Couldn't get the current working directory"
<< exit(FatalError);
return fileName::null;
}
@ -670,8 +695,8 @@ Foam::fileNameList Foam::readDir
if (POSIX::debug)
{
Info<< "readDir(const fileName&, const fileType, const bool filtergz)"
<< " : reading directory " << directory << endl;
InfoInFunction
<< "reading directory " << directory << endl;
}
// Setup empty string list MAXTVALUES long
@ -691,9 +716,8 @@ Foam::fileNameList Foam::readDir
if (POSIX::debug)
{
Info<< "readDir(const fileName&, const fileType, "
"const bool filtergz) : cannot open directory "
<< directory << endl;
InfoInFunction
<< "cannot open directory " << directory << endl;
}
}
else
@ -824,7 +848,8 @@ bool Foam::cp(const fileName& src, const fileName& dest)
{
if (POSIX::debug)
{
Info<< "Copying : " << src/contents[i]
InfoInFunction
<< "Copying : " << src/contents[i]
<< " to " << destFile/contents[i] << endl;
}
@ -838,7 +863,8 @@ bool Foam::cp(const fileName& src, const fileName& dest)
{
if (POSIX::debug)
{
Info<< "Copying : " << src/subdirs[i]
InfoInFunction
<< "Copying : " << src/subdirs[i]
<< " to " << destFile << endl;
}
@ -856,7 +882,8 @@ bool Foam::ln(const fileName& src, const fileName& dst)
{
if (POSIX::debug)
{
Info<< "Create softlink from : " << src << " to " << dst
InfoInFunction
<< "Create softlink from : " << src << " to " << dst
<< endl;
}
@ -893,7 +920,8 @@ bool Foam::mv(const fileName& src, const fileName& dst)
{
if (POSIX::debug)
{
Info<< "Move : " << src << " to " << dst << endl;
InfoInFunction
<< "Move : " << src << " to " << dst << endl;
}
if
@ -919,7 +947,8 @@ bool Foam::mvBak(const fileName& src, const std::string& ext)
{
if (POSIX::debug)
{
Info<< "mvBak : " << src << " to extension " << ext << endl;
InfoInFunction
<< "mvBak : " << src << " to extension " << ext << endl;
}
if (exists(src, false))
@ -956,7 +985,8 @@ bool Foam::rm(const fileName& file)
{
if (POSIX::debug)
{
Info<< "Removing : " << file << endl;
InfoInFunction
<< "Removing : " << file << endl;
}
// Try returning plain file name; if not there, try with .gz
@ -976,7 +1006,7 @@ bool Foam::rmDir(const fileName& directory)
{
if (POSIX::debug)
{
Info<< "rmDir(const fileName&) : "
InfoInFunction
<< "removing directory " << directory << endl;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,6 +48,9 @@ namespace POSIX
{
//- Declare name of the class and its debug switch
NamespaceName("POSIX");
const label pathLengthChunk = 256;
const label pathLengthMax = 4096;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -246,7 +246,7 @@ void Foam::PairCollision<CloudType>::wallInteraction()
vector pW = nearPt - pos;
scalar normalAlignment = normal & pW/mag(pW);
scalar normalAlignment = normal & pW/(mag(pW) + SMALL);
// Find the patchIndex and wallData for WallSiteData object
label patchI = patchID[realFaceI - mesh.nInternalFaces()];

View File

@ -19,7 +19,7 @@ runApplication simpleFoam
# Copy the mesh from the steady state case and map the results to a
# mesh motion case, then solve transient.
cd ../wingMotion2D_pimpleDyMFoam
cp -r ../wingMotion2D_simpleFoam/constant/polyMesh/* constant/polyMesh/
cp -r ../wingMotion2D_simpleFoam/constant/polyMesh constant
cp -r 0.org 0
runApplication mapFields ../wingMotion2D_simpleFoam -sourceTime latestTime -consistent
mv 0/pointDisplacement.unmapped 0/pointDisplacement

View File

@ -1,73 +0,0 @@
#!/bin/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
# makeWmake
#
# Description
# Build platform-specific parts of wmake
#
#------------------------------------------------------------------------------
Script=${0##*/}
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script
Build platform-specific parts of wmake
USAGE
exit 1
}
case "$1" in
-h | -help)
usage
;;
esac
echo ========================================
echo Build platform-specific parts of wmake
echo
(
set -x
make -C ${0%/*}/src $@
)
echo
echo ========================================
echo Done building wmake
echo ========================================
echo
#------------------------------------------------------------------------------
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset Script usage
#------------------------------------------------------------------------------

View File

@ -55,6 +55,7 @@ options:
-j Compile using all local cores/hyperthreads
-jN or -j N Compile using N cores/hyperthreads
-no-scheduler Compile without wmakeScheduler
-update Update lnInclude directories and dep files
USAGE
# Print options for building code documentation
@ -122,6 +123,11 @@ do
-no-scheduler)
unset WM_SCHEDULER
;;
# Update lnInclude directories and dep files following a pull
-update)
wrmdep -update
wmakeLnIncludeAll
;;
# Generate documentation
doc)
test -n "$genDoc" || usage "invalid option '$1'"

View File

@ -3,7 +3,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
# \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
@ -40,17 +40,18 @@ Usage: $Script [OPTION] [dir]
$Script [OPTION] target [dir [MakeDir]]
options:
-s | -silent ignored - for compatibility with wmake
-help print the usage
-s | -silent Ignored - for compatibility with wmake
-help Print the usage
Clean up the wmake control directory Make/\$WM_OPTIONS and remove the
lnInclude directories generated for libraries.
The targets correspond to a subset of the 'wmake' special targets:
all all subdirectories, uses any Allwclean or Allclean
all All subdirectories, uses any Allwclean or Allclean
files if they exist
exe | lib | libo | libso
clean Make, any *.dep files and lnInclude directories
Clean Make, any *.dep files and lnInclude directories
empty Remove empty sub-directories for the requested dir
USAGE
exit 1
@ -67,7 +68,7 @@ do
-h | -help)
usage
;;
-s | -silent) # ignored - for compatibility with wmake
-s | -silent) # Ignored - for compatibility with wmake
shift
;;
-*)
@ -81,7 +82,7 @@ done
#------------------------------------------------------------------------------
# check arguments and change to the directory in which to run wclean
# Check arguments and change to the directory in which to run wclean
#------------------------------------------------------------------------------
unset dir targetType
@ -97,10 +98,10 @@ then
targetType=$1
fi
# specified directory name:
# Specified directory name:
[ $# -ge 2 ] && dir=$2
# specified alternative name for the Make sub-directory:
# Specified alternative name for the Make sub-directory:
[ $# -ge 3 ] && MakeDir=$3
if [ "$dir" ]
@ -111,22 +112,40 @@ then
}
fi
# provide some feedback
# Provide some feedback
echo "$Script ${dir:-./}"
fi
#------------------------------------------------------------------------------
# Remove empty sub-directories and exit
#------------------------------------------------------------------------------
if [ "$targetType" = empty ]
then
# Get sub-directories avoiding particular directories
for dir in $(find . -mindepth 1 -maxdepth 1 \
-type d \( -name .git -prune -o -print \) )
do
echo "check dir: $dir"
find $dir -depth -type d -empty -exec rmdir {} \; -print
done
exit 0
fi
#------------------------------------------------------------------------------
# Recurse the directories tree
#------------------------------------------------------------------------------
if [ "$targetType" = all ]
then
if [ -e Allwclean ] # consistent with Allwmake
if [ -e Allwclean ] # Consistent with Allwmake
then
./Allwclean
exit $?
elif [ -e Allclean ] # often used for tutorial cases
elif [ -e Allclean ] # Often used for tutorial cases
then
./Allclean
exit $?
@ -135,7 +154,7 @@ then
for dir in `find . \( -type d -a -name Make \)`
do
echo $dir
$0 ${dir%/Make} # parent directory - trim /Make from the end
$0 ${dir%/Make} # Parent directory - trim /Make from the end
done
fi
fi

View File

@ -61,7 +61,8 @@ do
esac
done
[ -d bin -a -d src ] || usage "not in the project top level directory"
[ "$PWD" = "$WM_PROJECT_DIR" ] \
|| usage "Not in the project top-level directory"
echo "Removing platforms/sub-directories"

View File

@ -24,13 +24,30 @@
#
# Script
# wrmdep [-a | -all | all] [file]
# wrmdep [-o | -old] [dir1 .. dirN]
# wrmdep -update
#
# Description
# This is a catch-all script for pruning .dep files, depending on the
# provided arguments.
#
# [-a | -all | all] [file]:
# Remove all .dep files from the object directory tree corresponding to the
# current source derectory or remove only the .dep files referring to the
# optionally specified [file]. With the -a/-all/all option the .dep files
# are removed for all platforms rather than just the current platform.
#
# [-o | -old] [dir1 .. dirN]:
# Remove *.dep files that are without a corresponding .C or .L source file.
# This occurs when a directory has been moved.
# - prints the questionable directory and *.dep file
#
# -update:
# Search all the "src" and "application" directories of the project for
# broken symbolic links for source code files and then remove all .dep
# files that relate to files that no longer exist.
# Must be executed in the project top-level directory: $WM_PROJECT_DIR.
#
#------------------------------------------------------------------------------
Script=${0##*/}
@ -41,11 +58,28 @@ usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script [-a | -all | all] [file]
Usage:
Remove all .dep files or remove .dep files referring to <file>
With the -a/-all/all option the .dep files are removed for all platform
rather than just the current platform.
$Script [-a | -all | all] [file]
Remove all .dep files or remove .dep files referring to <file>
With the -a/-all/all option the .dep files are removed for all
platform rather than just the current platform.
$Script [-o | -old] [dir1 .. dirN]
Remove *.dep files that are without a corresponding .C or .L file.
This occurs when a directory has been moved.
- prints the questionable directory and *.dep file
Note: to remove empty directories, run: wclean empty
$Script -update
Search all the "src" and "application" directories of the project for
broken symbolic links for source code files and then remove all .dep
files that relate to files that no longer exist.
Must be executed in the project top-level directory: $WM_PROJECT_DIR
USAGE
exit 1
@ -56,6 +90,9 @@ USAGE
# Parse arguments and options
#------------------------------------------------------------------------------
# Default is for removing all .dep files in the current directory
rmdepMode="files"
# Default to processing only the current platform
all=
@ -71,6 +108,14 @@ do
all="all"
shift
;;
-o | -old)
rmdepMode="oldFolders"
shift
;;
-update)
rmdepMode="updateMode"
shift
;;
-*)
usage "unknown option: '$*'"
;;
@ -84,33 +129,97 @@ done
checkEnv
#------------------------------------------------------------------------------
# Remove the selected .dep files from the object tree
#------------------------------------------------------------------------------
case "$rmdepMode" in
files)
findObjectDir .
#-------------------------------------------------------------------------
# Remove the selected .dep files from the object tree
#-------------------------------------------------------------------------
# With the -a/-all option replace the current platform with a wildcard
if [ "$all" = "all" ]
then
objectsDir=$(echo $objectsDir | sed s%$WM_OPTIONS%*% )
fi
findObjectDir .
if [ "$#" -eq 0 ]
then
echo "removing all .dep files ..."
find $objectsDir -name '*.dep' -print | xargs -t rm 2>/dev/null
else
echo "removing .dep files referring to $1 ..."
find $objectsDir -name '*.dep' -exec grep "$1" '{}' \; -exec rm '{}' \;
fi
# With the -a/-all option replace the current platform with a wildcard
if [ "$all" = "all" ]
then
objectsDir=$(echo $objectsDir | sed s%$WM_OPTIONS%*% )
fi
if [ "$#" -eq 0 ]
then
echo "removing all .dep files ..."
find $objectsDir -name '*.dep' -print | xargs -t rm 2>/dev/null
else
echo "removing .dep files referring to $1 ..."
find $objectsDir -name '*.dep' -exec grep "$1" '{}' \; \
-exec rm '{}' \;
fi
;;
oldFolders)
# Default is the current directory
[ "$#" -gt 0 ] || set -- .
for checkDir
do
findObjectDir $checkDir
if [ -d $objectsDir ]
then
echo "Searching: $objectsDir"
else
echo "Skipping non-dir: $objectsDir"
continue
fi
find $objectsDir -name '*.dep' -print | while read depFile
do
depToSource $depFile
# Check C++ or Flex source file exists
if [ ! -r "$sourceFile" ];
then
echo "rm $depFile"
rm -f $depFile 2>/dev/null
fi
done
done
;;
updateMode)
[ "$PWD" = "$WM_PROJECT_DIR" ] \
|| usage "Not in the project top-level directory"
echo "Purging all dep files that relate to files that no longer exist..."
fileNameList=$(find -L src applications -name '*.[CHL]' -type l \
-exec basename {} \;)
for fileName in $fileNameList
do
echo "Purging from 'src': $fileName"
cd src
$Script -a $fileName
echo "Purging from 'applications': $fileName"
cd ../applications
$Script -a $fileName
cd ..
done
;;
esac
#------------------------------------------------------------------------------
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset Script usage
unset Script usage rmdepMode all
#------------------------------------------------------------------------------

View File

@ -1,133 +0,0 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2015 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
# wrmdepold
#
# Description
# Usage: wrmdepold [dir1 .. dirN]
#
# Remove *.dep files that are without a corresponding .C or .L source file.
# This often occurs when a directory has been moved.
# - print questionable directory and the *.dep file
# - optionally remove empty directories
#------------------------------------------------------------------------------
Script=${0##*/}
# Source the wmake functions
. ${0%/*}/scripts/wmakeFunctions
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: $Script [OPTION] [dir1 .. dirN]
options:
-rmdir find and remove empty directories (recursively)
Remove *.dep files that are without a corresponding .C or .L file.
This often occurs when a directory has been moved.
- print questionable directory and file
- optionally remove empty directories
USAGE
exit 1
}
#------------------------------------------------------------------------------
# Parse arguments and options
#------------------------------------------------------------------------------
unset optRmdir
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-rmdir)
optRmdir=true
shift
;;
-*)
usage "unknown option: '$*'"
;;
*)
break
;;
esac
done
# Check environment variables
checkEnv
#------------------------------------------------------------------------------
#
#------------------------------------------------------------------------------
# Default is the current directory
[ "$#" -gt 0 ] || set -- .
for checkDir
do
findObjectDir $checkDir
if [ -d $objectsDir ]
then
echo "Searching: $objectsDir"
else
echo "Skipping non-dir: $objectsDir"
continue
fi
find $objectsDir -name '*.dep' -print | while read depFile
do
depToSource $depFile
# Check C++ or Flex source file exists
if [ ! -r "$sourceFile" ];
then
echo "rm $depFile"
rm -f $depFile 2>/dev/null
fi
done
# Remove empty dirs
if [ "$optRmdir" ]
then
# get subdirs ourselves so we can avoid particular directories
for dir in $(find $objectsDir -mindepth 1 -maxdepth 1 -type d \( -name .git -prune -o -print \) )
do
echo "check dir: $dir"
find $dir -depth -type d -empty -exec rmdir {} \; -print
done
fi
done
# -----------------------------------------------------------------------------