diff --git a/bin/foamSequenceVTKFiles b/bin/foamSequenceVTKFiles index fbbfc6014..86e512228 100755 --- a/bin/foamSequenceVTKFiles +++ b/bin/foamSequenceVTKFiles @@ -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..." diff --git a/bin/mpirunDebug b/bin/mpirunDebug index b9a284d61..3be74baa2 100755 --- a/bin/mpirunDebug +++ b/bin/mpirunDebug @@ -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 diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C index 44ee3c708..9188b7e24 100644 --- a/src/OSspecific/POSIX/POSIX.C +++ b/src/OSspecific/POSIX/POSIX.C @@ -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 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; } diff --git a/src/OSspecific/POSIX/POSIX.H b/src/OSspecific/POSIX/POSIX.H index 9947f3de7..0b17af732 100644 --- a/src/OSspecific/POSIX/POSIX.H +++ b/src/OSspecific/POSIX/POSIX.H @@ -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; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C index 185bfb2f5..6800360b4 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C @@ -246,7 +246,7 @@ void Foam::PairCollision::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()]; diff --git a/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allrun b/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allrun index 196a72a1d..60c6459cf 100755 --- a/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allrun +++ b/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allrun @@ -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 diff --git a/wmake/makeWmake b/wmake/makeWmake deleted file mode 100755 index 98b5b55e1..000000000 --- a/wmake/makeWmake +++ /dev/null @@ -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 . -# -# Script -# makeWmake -# -# Description -# Build platform-specific parts of wmake -# -#------------------------------------------------------------------------------ -Script=${0##*/} - -usage() { - exec 1>&2 - while [ "$#" -ge 1 ]; do echo "$1"; shift; done - cat<&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat< -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 + 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 #------------------------------------------------------------------------------ diff --git a/wmake/wrmdepold b/wmake/wrmdepold deleted file mode 100755 index 61cdc92bc..000000000 --- a/wmake/wrmdepold +++ /dev/null @@ -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 . -# -# 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</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 - - -# -----------------------------------------------------------------------------