From 931c30e61ebeaa224f9eb51cd42ad373d3cab05c Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 17 Jul 2008 10:03:16 +0200 Subject: [PATCH 01/30] foamClearPolyMesh minor cleanup --- bin/foamClearPolyMesh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/foamClearPolyMesh b/bin/foamClearPolyMesh index 07531f68bf..535be942b8 100755 --- a/bin/foamClearPolyMesh +++ b/bin/foamClearPolyMesh @@ -45,9 +45,8 @@ USAGE } unset caseDir -unset meshDir -# parse options +# parse a single option if [ "$#" -gt 0 ]; then case "$1" in -h | -help) @@ -58,7 +57,6 @@ if [ "$#" -gt 0 ]; then caseDir=$1 [ "$#" -ge 1 ] || usage "'-case' option requires an argument" cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'" - meshDir="constant/polyMesh" ;; *) usage "unknown option/argument: '$*'" @@ -67,8 +65,11 @@ if [ "$#" -gt 0 ]; then fi # meshDir is only set if -case was specified: insist upon 'constant/polyMesh' -if [ -n "$meshDir" ] +if [ -n "$caseDir" ] then + # require constant/polyMesh + meshDir=constant/polyMesh + if [ ! -d "$meshDir" ] then echo "Error: no '$meshDir' in $caseDir" 1>&2 From a34c8d635b475cb11cb4e3c0e2a782889627a870 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 17 Jul 2008 10:04:30 +0200 Subject: [PATCH 02/30] foamUpgradeTurbulenceProperties : do not use dirname with missing arguments --- bin/foamUpgradeTurbulenceProperties | 70 ++++++++++++++++------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/bin/foamUpgradeTurbulenceProperties b/bin/foamUpgradeTurbulenceProperties index 1f10d8551a..b5ba0a9b0b 100755 --- a/bin/foamUpgradeTurbulenceProperties +++ b/bin/foamUpgradeTurbulenceProperties @@ -30,51 +30,62 @@ # Upgrade the turbulenceProperties dictionary to the new format employed # in OpenFOAM version 1.5 # - RAS turbulence models now defined by the RASProperties dictionary, -# and RASModel keyword, and +# and RASModel keyword. # - LES turbulence models now defined by the LESProperties dictionary, # and LESModel keyword. # #------------------------------------------------------------------------------ -printUsage() -{ - echo "Usage: `basename $0` " - echo " Where is the full path to the" - echo " turbulenceProperties dictionary" +usage() { + cat< + + Where is the full path to the + turbulenceProperties dictionary + +USAGE + exit 1 } +[ $# = 1 ] || usage + +turbDict=$1 +if [ ! -f $turbDict ] +then + echo " Error: file $turbDict does not exist" + echo "" + usage +fi + + +# +# $1: turbulence model +# $2: new properties type +# $3: original dictionary +# convertDict() { - echo " Identified $1 turbulence model" + echo " Identified $1 turbulence model in $3" + outputPath=`dirname $3` sed -e "s/turbulenceProperties/$1Properties/" \ -e "s/$2/$1Model/" \ -e "s/[a-zA-Z0-9]* [ ]*\[[0-9 ]*\]//" \ $3 > "$outputPath/$1Properties" - echo " written $1Properties to $outputPath/" + echo " wrote $outputPath/$1Properties" } -outputPath=`dirname $1` - -if [ $# -ne 1 ]; then - printUsage - exit 1 -elif [ ! -e $1 ]; then - echo " Error: file $1 does not exist" - echo "" - printUsage - exit 1 -fi - -# Identify type of turbulence model -RAS=`grep turbulenceModel $1` -LES=`grep LESmodel $1` - -if [ -n "$RAS" ]; then - convertDict "RAS" "turbulenceModel" $1 -elif [ -n "$LES" ]; then - convertDict "LES" "LESmodel" $1 +# +# Identify type of turbulence model and convert +# +if grep turbulenceModel $turbDict >/dev/null 2>&1 +then + convertDict RAS turbulenceModel $turbDict +elif grep LESmodel $turbDict >/dev/null 2>&1 +then + convertDict LES LESmodel $turbDict else echo "Unable to determine turbulence model type - nothing changed" exit 1 @@ -82,7 +93,4 @@ fi echo "done." -exit 0 - - #------------------------------------------------------------------------------ From 1884b91c8c098d90f0f6af41a1d1fbc5f9866e91 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 17 Jul 2008 23:26:54 +0200 Subject: [PATCH 03/30] bin/script changes foamUpdateCaseFileHeader: - handle multiple files - use fixed version width - replace grep/tr/cut -> sed foamUpgradeTurbulenceProperties: - handle multiple files --- bin/foamUpdateCaseFileHeader | 121 +++++++++++++++++----------- bin/foamUpgradeTurbulenceProperties | 53 ++++++------ 2 files changed, 97 insertions(+), 77 deletions(-) diff --git a/bin/foamUpdateCaseFileHeader b/bin/foamUpdateCaseFileHeader index dad6dfc355..6b7aa8439f 100755 --- a/bin/foamUpdateCaseFileHeader +++ b/bin/foamUpdateCaseFileHeader @@ -33,85 +33,108 @@ # Also removes consecutive blank lines from file. # #------------------------------------------------------------------------------ +foamVersion=$WM_PROJECT_VERSION -# -# FUNCTIONS -# -printUsage () { -cat < - Updates the header of application files - By default, writes current version in the header - Alternatively version can be specified with -v option - Also removes consecutive blank lines from file +usage() { + cat<" specifies the version to be written in the header --h help -EOF +usage: ${0##*/} [OPTION] ... + +options: + -v "" specifies the version to be written in the header + -h help + + Updates the header of application files. + By default, writes current version in the header. + Alternatively version can be specified with -v option. + Also removes consecutive blank lines from file. + +USAGE + exit 1 } -printOpenFOAMheader () { -cat< FoamFile - CLASS=`FoamFileAttribute class FoamFile` - OBJECT=`FoamFileAttribute object FoamFile` - FORMAT=`FoamFileAttribute format FoamFile` - printOpenFOAMheader $VERSION $FORMAT $CLASS $OBJECT > temp - sed '1,/}/d' $CASE_FILE | sed '/./,/^$/!d' >> temp - mv temp $1 - rm FoamFile -else - echo "The following file does not appear to be a case file:" - echo " " $CASE_FILE -fi +for caseFile +do + if grep FoamFile $caseFile >/dev/null 2>&1 + then + echo "Updating case file: $caseFile" + sed -n '/FoamFile/,/}/p' $caseFile > FoamFile + CLASS=`FoamFileAttribute class FoamFile` + OBJECT=`FoamFileAttribute object FoamFile` + FORMAT=`FoamFileAttribute format FoamFile` + + printHeader $FORMAT $CLASS $OBJECT $NOTE > FoamFile.tmp + sed '1,/}/d' $caseFile | sed '/./,/^$/!d' >> FoamFile.tmp + + mv FoamFile.tmp $caseFile + rm FoamFile + else + echo " Invalid case file: $caseFile" + fi +done #------------------------------------------------------------------------------ diff --git a/bin/foamUpgradeTurbulenceProperties b/bin/foamUpgradeTurbulenceProperties index b5ba0a9b0b..8c1437aca6 100755 --- a/bin/foamUpgradeTurbulenceProperties +++ b/bin/foamUpgradeTurbulenceProperties @@ -41,24 +41,15 @@ usage() { usage: ${0##*/} - Where is the full path to the - turbulenceProperties dictionary + Where is the full path to the + turbulenceProperties dictionary + + Note: can upgrade several files at once USAGE exit 1 } -[ $# = 1 ] || usage - -turbDict=$1 -if [ ! -f $turbDict ] -then - echo " Error: file $turbDict does not exist" - echo "" - usage -fi - - # # $1: turbulence model # $2: new properties type @@ -66,7 +57,7 @@ fi # convertDict() { - echo " Identified $1 turbulence model in $3" + echo "Identified $1 turbulence model in '$3'" outputPath=`dirname $3` sed -e "s/turbulenceProperties/$1Properties/" \ @@ -77,20 +68,26 @@ convertDict() echo " wrote $outputPath/$1Properties" } -# -# Identify type of turbulence model and convert -# -if grep turbulenceModel $turbDict >/dev/null 2>&1 -then - convertDict RAS turbulenceModel $turbDict -elif grep LESmodel $turbDict >/dev/null 2>&1 -then - convertDict LES LESmodel $turbDict -else - echo "Unable to determine turbulence model type - nothing changed" - exit 1 -fi +[ $# -ge 1 ] || usage -echo "done." +for turbDict +do + # Identify type of turbulence model and convert + if [ -f $turbDict ] + then + if grep turbulenceModel $turbDict >/dev/null 2>&1 + then + convertDict RAS turbulenceModel $turbDict + elif grep LESmodel $turbDict >/dev/null 2>&1 + then + convertDict LES LESmodel $turbDict + else + echo "Unable to determine turbulence model type in '$turbDict'" + echo " - nothing changed" + fi + else + echo "Error: file '$turbDict' does not exist" + fi +done #------------------------------------------------------------------------------ From b341c45864d34df4eac259d964a712cd564b4c98 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 18 Jul 2008 08:52:33 +0200 Subject: [PATCH 04/30] update docs for timeVarying bcs --- .../timeVaryingFlowRateInletVelocityFvPatchVectorField.H | 4 ++-- .../timeVaryingUniformFixedValueFvPatchField.H | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingFlowRateInletVelocity/timeVaryingFlowRateInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingFlowRateInletVelocity/timeVaryingFlowRateInletVelocityFvPatchVectorField.H index 21198d936e..aab658efed 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingFlowRateInletVelocity/timeVaryingFlowRateInletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingFlowRateInletVelocity/timeVaryingFlowRateInletVelocityFvPatchVectorField.H @@ -35,8 +35,8 @@ Description type timeVaryingFlowRateInletVelocity; flowRate 0.2; // Volumetric/mass flow rate [m3/s or kg/s] value uniform (0 0 0); // placeholder - fileName "time-series"; - boundAction repeat; // (error|warn|clamp|repeat) + fileName "$FOAM_CASE/time-series"; + outOfBounds repeat; // (error|warn|clamp|repeat) } @endverbatim diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchField.H index b6ce246cc6..2dfeb31d7c 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchField.H @@ -33,8 +33,8 @@ Description inlet { type timeVaryingUniformFixedValue; - fileName "time-series"; - boundAction clamp; // (error|warn|clamp|repeat) + fileName "$FOAM_CASE/time-series"; + outOfBounds clamp; // (error|warn|clamp|repeat) } @endverbatim From 3ae1a49119a0633d3f3b1fe4501503dab5e8cf00 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 18 Jul 2008 10:23:09 +0200 Subject: [PATCH 05/30] blockMesh: renamed genBlockMesh.C -> blockMeshApp.C for the -doc option Followed Eugene's suggestions and moved blockMeshDict out of polyMesh/. Rationale: blockMeshDict is not a polyMesh or part of a polyMesh, thus it doesn't really belong in the polyMesh/ dir anyhow. Moving it to constant/ or constant// improves the overview and eases cleanup of polyMesh/ as well. For compatibility, constant/polyMesh/ or constant//polyMesh/ will be searched if the new locations fail. --- .../mesh/generation/blockMesh/Make/files | 2 +- .../{genBlockMesh.C => blockMeshApp.C} | 104 ++++++++++++++---- 2 files changed, 84 insertions(+), 22 deletions(-) rename applications/utilities/mesh/generation/blockMesh/{genBlockMesh.C => blockMeshApp.C} (77%) diff --git a/applications/utilities/mesh/generation/blockMesh/Make/files b/applications/utilities/mesh/generation/blockMesh/Make/files index af92bf759c..81f5f36749 100644 --- a/applications/utilities/mesh/generation/blockMesh/Make/files +++ b/applications/utilities/mesh/generation/blockMesh/Make/files @@ -26,6 +26,6 @@ blockPoints.C blockCells.C blockBoundary.C -genBlockMesh.C +blockMeshApp.C EXE = $(FOAM_APPBIN)/blockMesh diff --git a/applications/utilities/mesh/generation/blockMesh/genBlockMesh.C b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C similarity index 77% rename from applications/utilities/mesh/generation/blockMesh/genBlockMesh.C rename to applications/utilities/mesh/generation/blockMesh/blockMeshApp.C index c13d906392..fbfbaa289c 100644 --- a/applications/utilities/mesh/generation/blockMesh/genBlockMesh.C +++ b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C @@ -22,14 +22,35 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +Application + blockMesh + Description A multi-block mesh generator. + The @a constant/blockMeshDict (or @a constant/\/blockMeshDict) + is used. + + For backwards compatibility, @a constant/polyMesh/blockMeshDict + (or @a constant/\/polyMesh/blockMeshDict) can also be used + if the previous search failed. + +Usage + + - blockMesh [OPTION] + + @param -blockTopology \n + Write the topology as a set of edges in OBJ format. + + @param -region \\n + Specify an alternative mesh region + \*---------------------------------------------------------------------------*/ #include "Time.H" #include "IOdictionary.H" #include "IOPtrList.H" +#include "autoPtr.H" #include "blockMesh.H" #include "attachPolyTopoChanger.H" @@ -60,47 +81,89 @@ int main(int argc, char *argv[]) word regionName; fileName polyMeshDir; + fileName constantDir; + autoPtr meshDictPtr; if (args.options().found("region")) { regionName = args.options()["region"]; polyMeshDir = regionName/polyMesh::meshSubDir; + constantDir = runTime.constant()/regionName; Info<< nl << "Generating mesh for region " << regionName << endl; + + // try constant//blockMeshDict + meshDictPtr.reset + ( + new IOobject + ( + "blockMeshDict", + runTime.constant(), + regionName, + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); } else { regionName = polyMesh::defaultRegion; polyMeshDir = polyMesh::meshSubDir; + constantDir = runTime.constant(); + + // try constant/blockMeshDict + meshDictPtr.reset + ( + new IOobject + ( + "blockMeshDict", + runTime.constant(), + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); } + // not found, fallback to polyMesh directory + if (!meshDictPtr->headerOk()) + { + meshDictPtr.reset + ( + new IOobject + ( + "blockMeshDict", + runTime.constant(), + polyMeshDir, + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + } - Info<< nl << "Reading block mesh description dictionary" << endl; - - IOobject meshDescriptionIOobject - ( - "blockMeshDict", - runTime.constant(), - polyMeshDir, - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ); - - if (!meshDescriptionIOobject.headerOk()) + if (!meshDictPtr->headerOk()) { FatalErrorIn(args.executable()) << "Cannot open mesh description file " << nl - << runTime.constant()/polyMeshDir/"blockMeshDict" << nl + << constantDir/"blockMeshDict" << nl + << "or "<< nl + << constantDir/polyMeshDir/polyMesh::meshSubDir/"blockMeshDict" + << nl << exit(FatalError); } - IOdictionary meshDescription(meshDescriptionIOobject); + Info<< nl << "Reading mesh description file" << endl; + + IOdictionary blockMeshDict(meshDictPtr()); Info<< nl << "Creating block mesh" << endl; - blockMesh blocks(meshDescription); + blockMesh blocks(blockMeshDict); if (writeTopo) @@ -145,7 +208,6 @@ int main(int argc, char *argv[]) } - Info<< nl << "Creating mesh from block mesh" << endl; wordList patchNames = blocks.patchNames(); @@ -186,11 +248,11 @@ int main(int argc, char *argv[]) // Read in a list of dictionaries for the merge patch pairs - if (meshDescription.found("mergePatchPairs")) + if (blockMeshDict.found("mergePatchPairs")) { List > mergePatchPairs ( - meshDescription.lookup("mergePatchPairs") + blockMeshDict.lookup("mergePatchPairs") ); if (mergePatchPairs.size()) @@ -296,7 +358,7 @@ int main(int argc, char *argv[]) // Set the precision of the points data to 10 IOstream::defaultPrecision(10); - Info << nl << "Writing polyMesh" << endl; + Info<< nl << "Writing polyMesh" << endl; mesh.removeFiles(mesh.instance()); if (!mesh.write()) { From d61fd187c10c2d4688193a53bdbf9dba418c9e01 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 18 Jul 2008 11:41:12 +0200 Subject: [PATCH 06/30] argList.C - don't emit banner with -help, -doc usage etc. This makes it easier to find the usage on the screen. Provide hint about -help if the docs cannot be found. --- src/OpenFOAM/global/argList/argList.C | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 59ee6e57b5..d8b90d013b 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -168,7 +168,6 @@ Foam::argList::argList { // Check if this run is a parallel run by searching for any parallel option // If found call runPar (might filter argv) - for (int argi=0; argi args_ and capture ( ... ) lists // for normal arguments and for options regroupArgv(argc, argv); @@ -291,8 +284,10 @@ Foam::argList::argList string dateString = clock::date(); string timeString = clock::clockTime(); + // Print the banner once only for parallel runs if (Pstream::master()) { + IOobject::writeBanner(Info, true); Info<< "Exec : " << argListString.c_str() << nl << "Date : " << dateString.c_str() << nl << "Time : " << timeString.c_str() << nl @@ -609,9 +604,9 @@ void Foam::argList::printUsage() const Info<< ']'; } - // place help/doc options of the way at the end, + // place help/doc/srcDoc options of the way at the end, // but with an extra space to separate it a little - Info<< " [-help] [-doc] [-srcDoc]" << endl; + Info<< " [-help] [-doc] [-srcDoc]\n" << endl; } @@ -663,7 +658,9 @@ void Foam::argList::displayDoc(bool source) const } else { - Info<< "No documentation found" << endl; + Info<< nl + << "No documentation found for " << executable_ + << ", but you can use -help to display the usage\n" << endl; } } From b6c6953ba3f6465300238db2b34600c08f20577b Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 18 Jul 2008 12:23:48 +0200 Subject: [PATCH 07/30] foamClearPolyMesh gets -region option too --- bin/foamClearPolyMesh | 49 +++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/bin/foamClearPolyMesh b/bin/foamClearPolyMesh index 535be942b8..c354ca0dd3 100755 --- a/bin/foamClearPolyMesh +++ b/bin/foamClearPolyMesh @@ -35,7 +35,7 @@ usage() { while [ "$#" -ge 1 ]; do echo "$1" 1>&2; shift; done cat <&2 -usage: ${0##*/} [-case dir] +usage: ${0##*/} [-case dir] [-region name] Remove the contents of the constant/polyMesh directory as per the Foam::polyMesh::removeFiles() method. @@ -44,47 +44,60 @@ USAGE exit 1 } -unset caseDir +unset caseDir regionName # parse a single option -if [ "$#" -gt 0 ]; then +while [ "$#" -gt 0 ] +do case "$1" in -h | -help) usage ;; -case) - shift - caseDir=$1 - [ "$#" -ge 1 ] || usage "'-case' option requires an argument" + [ "$#" -ge 2 ] || usage "'-case' option requires an argument" + caseDir=$2 + shift 2 cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'" ;; + -region) + [ "$#" -ge 2 ] || usage "'-region' option requires an argument" + regionName=$2 + shift 2 + ;; *) usage "unknown option/argument: '$*'" ;; esac +done + +if [ -n "$regionName" ] +then + meshDir=$regionName/polyMesh +else + meshDir=polyMesh fi -# meshDir is only set if -case was specified: insist upon 'constant/polyMesh' +# if -case was specified: insist upon 'constant/polyMesh' if [ -n "$caseDir" ] then - # require constant/polyMesh - meshDir=constant/polyMesh - - if [ ! -d "$meshDir" ] + if [ -d constant/$meshDir ] then - echo "Error: no '$meshDir' in $caseDir" 1>&2 + # use constant/polyMesh + meshDir=constant/$meshDir + else + echo "Error: no 'constant/$meshDir' in $caseDir" 1>&2 exit 1 fi else - if [ -d constant/polyMesh ] + if [ -d constant/$meshDir ] then # use constant/polyMesh - meshDir=constant/polyMesh - elif [ -d polyMesh ] + meshDir=constant/$meshDir + elif [ -d $meshDir ] then - # likely already in constant/ - meshDir=polyMesh - elif [ "${PWD##*/}" = polyMesh ] + # likely already in constant/ - do not adjust anything + : + elif [ "${PWD##*/}" = polyMesh -a -z "$regionName" ] then # apparently already within polyMesh/ meshDir=. From fbf250af6580579fd9e85c602d4df914dd835eba Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 18 Jul 2008 13:53:42 +0200 Subject: [PATCH 08/30] foamCopySettings ignore log files as well --- bin/foamCopySettings | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/foamCopySettings b/bin/foamCopySettings index 22c7a6b32a..bad2904aea 100755 --- a/bin/foamCopySettings +++ b/bin/foamCopySettings @@ -84,9 +84,9 @@ for i in $fileList do name="${i##*/}" # skip numerical (results) directories (except 0) - # and things that look like queuing system output + # and things that look like queuing system output or log files case "$name" in - [1-9] | [0-9]?* | foam.[eo][1-9]*) + [1-9] | [0-9]?* | foam.[eo][1-9]* | log | *.log ) echo "$i [skipped]" continue ;; From 7f9631634d338a20e5887003c47d34e2ff7167d6 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 18 Jul 2008 15:32:10 +0200 Subject: [PATCH 09/30] cleanup wmake scripts - match comments to names of scripts - remove comments about using C-shell (not true anymore) - use 'assert' style syntax in places instead of if/then/fi - wcleanMachine supports multiple arguments --- wmake/MakefileOptions | 2 +- wmake/makeWmake | 5 ++- wmake/scripts/addCompile | 6 ++-- wmake/scripts/makeFiles | 36 +++++++++------------- wmake/scripts/makeOptions | 16 +++------- wmake/scripts/mkObjectDir | 6 ++-- wmake/wclean | 5 +-- wmake/wcleanAll | 15 +++------ wmake/wcleanAlmostAll | 12 +++----- wmake/wcleanMachine | 47 +++++++++++++---------------- wmake/wmakeDerivedFiles | 10 +++--- wmake/wmakeFilesAndOptions | 62 +++++++++++++++----------------------- 12 files changed, 90 insertions(+), 132 deletions(-) diff --git a/wmake/MakefileOptions b/wmake/MakefileOptions index f4da8edd9a..9cb0287116 100644 --- a/wmake/MakefileOptions +++ b/wmake/MakefileOptions @@ -23,7 +23,7 @@ # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # Script -# MakefileFiles +# MakefileOptions # # Description # General, easy to use make system for multi-platform development. diff --git a/wmake/makeWmake b/wmake/makeWmake index 5b2c477257..a18f72f009 100755 --- a/wmake/makeWmake +++ b/wmake/makeWmake @@ -27,10 +27,13 @@ # makeWmake # # Description -# Script to build all the system specific parts of wmake +# Script to build all the system-specific parts of wmake # #------------------------------------------------------------------------------ +# run from this directory only +cd ${0%/*} || exit 1 + ( cd src && make ) #------------------------------------------------------------------------------ diff --git a/wmake/scripts/addCompile b/wmake/scripts/addCompile index c56f4043b9..f5d70d2c80 100755 --- a/wmake/scripts/addCompile +++ b/wmake/scripts/addCompile @@ -28,8 +28,6 @@ # # Description # Cleans up the dependency list and add the compilation statement. -# It has to be written in the C-shell rather than the Bourne shell -# because it uses file name manipulators. # # Usage: wmkdep | addCompile # @@ -52,11 +50,11 @@ if [ "$WM_PROJECT_DIR" ] then sed -e s%$WM_PROJECT_DIR%'$(WM_PROJECT_DIR)'% > $depName else - cat > $depName + cat > $depName fi -if [ "$sub" = "java" ] +if [ "$sub" = java ] then sed -e s%"\(.*\).class.*:"%'$(CLASSES_DIR)/'"\1.class\:"% \ diff --git a/wmake/scripts/makeFiles b/wmake/scripts/makeFiles index f0423240c3..acda08ccaf 100755 --- a/wmake/scripts/makeFiles +++ b/wmake/scripts/makeFiles @@ -28,43 +28,36 @@ # # Description # Scan the current directory for source files and construct Make/files -# It has to be written in the C-shell rather than the Bourne shell -# because it uses file name manipulators. # # Usage : makeFiles # #------------------------------------------------------------------------------ -if [ -r "Make/files" ] +if [ -r Make/files ] then - echo "makeFiles: Make/files already exists, exiting" - exit 1 -fi - - -if [ ! -d "Make" ] -then - mkdir Make + echo "makeFiles: Make/files already exists, exiting" + exit 1 fi rulesPath=$WM_DIR/rules/$WM_ARCH$WM_COMPILER +[ -d Make ] || mkdir Make rm -f Make/files dirs=`find . -name "*" -type d -print` for dir in $dirs do - if [ $dir != "." ] - then - baseDirName=`echo $dir | sed 's%^\./%%' | $rulesPath/dirToString` - baseDir=`echo $dir | sed 's%^\./%%'` + if [ $dir != . ] + then + baseDirName=`echo $dir | sed 's%^\./%%' | $rulesPath/dirToString` + baseDir=`echo $dir | sed 's%^\./%%'` - if [ $baseDirName != "Make" ] - then - echo $baseDirName " = " $baseDir >> Make/files - fi - fi + if [ $baseDirName != Make ] + then + echo $baseDirName " = " $baseDir >> Make/files + fi + fi done echo >> Make/files @@ -86,7 +79,6 @@ done echo >> Make/files -pwd=`pwd` -echo 'EXE = $(FOAM_APPBIN)/'${pwd##*/} >> Make/files +echo 'EXE = $(FOAM_APPBIN)/'${PWD##*/} >> Make/files #------------------------------------------------------------------------------ diff --git a/wmake/scripts/makeOptions b/wmake/scripts/makeOptions index 6847125ab9..774df99117 100755 --- a/wmake/scripts/makeOptions +++ b/wmake/scripts/makeOptions @@ -28,26 +28,18 @@ # # Description # Scan the current directory for options and construct Make/options -# It has to be written in the C-shell rather than the Bourne shell -# because it uses file name manipulators. # # Usage : makeOptions # #------------------------------------------------------------------------------ -if [ -r "Make/options" ] +if [ -r Make/options ] then - echo "makeOptions: Make/options already exists, exiting" - exit 1 + echo "makeOptions: Make/options already exists, exiting" + exit 1 fi - -if [ ! -d "Make" ] -then - mkdir Make -fi - -rulesPath=$WM_DIR/rules/$WM_ARCH +[ -d Make ] || mkdir Make rm -f Make/options diff --git a/wmake/scripts/mkObjectDir b/wmake/scripts/mkObjectDir index f4a281c6f3..c367a5322f 100755 --- a/wmake/scripts/mkObjectDir +++ b/wmake/scripts/mkObjectDir @@ -27,15 +27,13 @@ # mkObjectDir # # Description -# Makes a directory hierachy for the given object file -# It has to be written in the C-shell rather than the Bourne shell -# because it uses file name manipulators. +# Makes a directory hierarchy for the given object file # # Usage: mkObjectDir # #------------------------------------------------------------------------------ -if [ $# = 1 ] +if [ $# -eq 1 ] then if [ ! -d ${1%/*} -a $1 != ${1%/*} ] then diff --git a/wmake/wclean b/wmake/wclean index d9b932bebb..1ea917eec5 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -54,7 +54,8 @@ USAGE } # provide immediate help -if [ "$1" = "-h" -o "$1" = "-help" ]; then +if [ "$1" = "-h" -o "$1" = "-help" ] +then usage fi @@ -93,7 +94,7 @@ then echo "$Script error" echo " could not change to directory '$dir'" exit 1 - } + } fi # provide some feedback diff --git a/wmake/wcleanAll b/wmake/wcleanAll index 4b8fc3cbb0..e7d3477cb7 100755 --- a/wmake/wcleanAll +++ b/wmake/wcleanAll @@ -24,7 +24,7 @@ # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # Script -# wmakeAll +# wcleanAll # # Description # script that searches all the directories below the current for the @@ -32,19 +32,14 @@ # #------------------------------------------------------------------------------ -if [ ! -d bin -o ! -d src ] -then - echo $0: not in the project top level directory ! +[ -d bin -a -d src ] || { + echo "${0##*/}: not in the project top level directory" exit 1 -fi - +} for dir in lib applications/bin do - if [ -d $dir ] - then - rm -rf $dir/* - fi + [ -d $dir ] && rm -rf $dir/* done ( cd tutorials && ./Allclean ) diff --git a/wmake/wcleanAlmostAll b/wmake/wcleanAlmostAll index 8ceaaf7865..515c3110d8 100755 --- a/wmake/wcleanAlmostAll +++ b/wmake/wcleanAlmostAll @@ -32,18 +32,14 @@ # #------------------------------------------------------------------------------ -if [ ! -d bin -o ! -d src ] -then - echo $0: not in the project top level directory ! +[ -d bin -a -d src ] || { + echo "${0##*/}: not in the project top level directory" exit 1 -fi - +} for dir in lib applications/bin do - if [ -d $dir ] - rm -rf $dir/* - fi + [ -d $dir ] && rm -rf $dir/* done ( cd tutorials && ./Allclean ) diff --git a/wmake/wcleanMachine b/wmake/wcleanMachine index d3fcfc0c16..a3deba2322 100755 --- a/wmake/wcleanMachine +++ b/wmake/wcleanMachine @@ -27,44 +27,39 @@ # wcleanMachine # # Description -# Searches all the directories below the current for the -# object file directories of the specified machine and then deletes them. +# Searches the directories below the current directory for the object +# file directories of the specified machine type(s) and deletes them # -# Usage: wcleanMachine +# Usage: wcleanMachine [ .. ] # #------------------------------------------------------------------------------ -if [ $# = 0 ] +if [ $# -eq 0 ] then - echo $0: wcleanMachine : Machine type expected, exiting ! + echo "${0##*/}: Machine type(s) expected, exiting !" exit 1 fi - -if [ ! -d lib -o ! -d src ] -then - echo $0: not in the project top level directory ! +[ -d lib -a -d src ] || { + echo "${0##*/}: not in the project top level directory !" exit 1 -fi - -find `find . -depth \( -name "Make.[A-Za-z]*" -o -name "Make" \) -type d -print` \ - -depth \( -type d -name "*$1" -o -name "*$1$WM_MPLIB" \) -exec rm -r {} \; - -#find . -depth -type d \( -name ii_files -o -name Templates.DB \) -exec rm -rf {} \; +} -if [ -d lib/$1 ] -then - rm -r lib/$1 -fi +for machType +do + echo "Cleaning machine type: $machType" -if [ applications/bin ] -then - if [ -d applications/bin/$1 ] - then - rm -r applications/bin/$1 - fi -fi + find `find . -depth \( -name "Make.[A-Za-z]*" -o -name "Make" \) -type d -print` \ + -depth \( -type d -name "*$machType" -o -name "*$machType$WM_MPLIB" \) -exec rm -r {} \; + # find . -depth -type d \( -name ii_files -o -name Templates.DB \) -exec rm -rf {} \; + + for dir in lib/$machType applications/bin/$machType + do + [ -d $dir ] && rm -r $dir + done + +done #------------------------------------------------------------------------------ diff --git a/wmake/wmakeDerivedFiles b/wmake/wmakeDerivedFiles index a88c85900e..e4fd037a25 100755 --- a/wmake/wmakeDerivedFiles +++ b/wmake/wmakeDerivedFiles @@ -32,14 +32,17 @@ # #------------------------------------------------------------------------------ -if [ ! -d $WM_OPTIONS ] +if [ ! -d "$WM_OPTIONS" ] then - echo The $WM_OPTIONS directory does not exist, exiting \! + echo "The $WM_OPTIONS directory does not exist, exiting" exit 1 fi # change to the $WM_OPTIONS directory -cd $WM_OPTIONS +cd $WM_OPTIONS 2>/dev/null || { + echo "Could not change to directory '$WM_OPTIONS'" + exit 1 +} # Find and keep macro definitions in files list grep "=" files > filesMacros @@ -141,5 +144,4 @@ rm files.$$ cd .. - #------------------------------------------------------------------------------ diff --git a/wmake/wmakeFilesAndOptions b/wmake/wmakeFilesAndOptions index 54ced8b28d..f65b7c435e 100755 --- a/wmake/wmakeFilesAndOptions +++ b/wmake/wmakeFilesAndOptions @@ -35,48 +35,34 @@ #------------------------------------------------------------------------------ Script=${0##*/} -if [ ! "$WM_OPTIONS" ] +# +# check environment variables +# +for check in WM_OPTIONS WM_LINK_LANGUAGE WM_DIR +do + eval test "\$$check" || { + echo "$Script error" + echo " environment variable \$$check not set" + exit 1 + } +done + +if [ -d Make ] then - echo "$Script: environment variable $WM_OPTIONS not set, exiting!" - exit 1 -fi - - -if [ ! "$WM_DIR" ] -then - echo "$Script: environment variable $WM_DIR not set" - exit 1 -fi - - -if [ ! "$WM_LINK_LANGUAGE" ] -then - echo "$Script: environment variable $WM_LINK_LANGUAGE not set" - exit 1 -fi - - -if [ -d "Make" ] -then - echo "$Script: Make directory already exists" - exit 1 + echo "$Script: Make directory already exists" + exit 1 else - mkdir Make + mkdir Make fi +[ -e Make/files ] || { + echo "$Script: Creating files" + $WM_DIR/scripts/makeFiles +} -if [ ! -e "Make/files" ] -then - echo "$Script: Creating files" - $WM_DIR/scripts/makeFiles -fi - - -if [ ! -e "Make/options" ] -then - echo "$Script: Creating options" - $WM_DIR/scripts/makeOptions -fi - +[ -e Make/options ] || { + echo "$Script: Creating options" + $WM_DIR/scripts/makeOptions +} #------------------------------------------------------------------------------ From a48bc8746a326e67be1368994ca369e9635f0e1c Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sun, 20 Jul 2008 14:07:49 +0200 Subject: [PATCH 10/30] use dictionary::readIfPresent wherever reasonable --- src/OpenFOAM/db/IOobject/IOobjectReadHeader.C | 5 +- .../db/IOobject/IOobjectWriteHeader.C | 1 - src/OpenFOAM/db/Time/Time.C | 35 +++------- src/OpenFOAM/db/Time/TimeIO.C | 26 ++----- .../matrices/lduMatrix/lduMatrix/lduMatrix.H | 21 ++---- .../lduMatrix/lduMatrix/lduMatrixSolver.C | 6 +- .../lduMatrix/lduMatrix/lduMatrixTemplates.C | 15 ---- .../GAMGPreconditioner/GAMGPreconditioner.C | 2 +- .../lduMatrix/solvers/GAMG/GAMGSolver.C | 13 ++-- .../solvers/smoothSolver/smoothSolver.C | 2 +- src/OpenFOAM/matrices/solution/solution.H | 2 +- .../meshes/patchIdentifier/patchIdentifier.C | 5 +- .../constraint/cyclic/cyclicPolyPatch.C | 6 +- .../polyPatches/polyPatch/newPolyPatch.C | 18 +---- .../preservePatchTypes/preservePatchTypes.C | 24 +++---- .../layerParameters/layerParameters.C | 8 +-- src/conversion/ensight/part/ensightPart.C | 12 ++-- .../meshReader/starcd/STARCDMeshReader.C | 20 +++--- .../metisDecomp/metisDecomp.C | 46 ++++-------- .../parMetisDecomp/parMetisDecomp.C | 70 ++++++------------- .../layerAdditionRemoval.C | 15 ++-- src/engine/engineTime/engineTime.C | 22 ++---- .../fvMatrices/fvMatrix/fvMatrix.H | 4 +- .../coordinateRotation/coordinateRotation.C | 5 +- .../searchableSurface/searchableSurfaces.C | 7 +- .../OutputFilterFunctionObject.C | 23 ++---- .../sampledSet/sampledSets/sampledSets.C | 10 +-- .../sampledSurface/plane/sampledPlane.C | 3 +- .../sampledSurface/sampledSurface.C | 5 +- .../sampledSurfaces/sampledSurfaces.C | 10 +-- .../chemistryReader/chemistryReader.C | 5 +- .../LES/compressible/LESModel/LESModel.C | 10 +-- .../LES/incompressible/LESModel/LESModel.C | 10 +-- 33 files changed, 129 insertions(+), 337 deletions(-) diff --git a/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C b/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C index 3564ae9ab1..966ef84136 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C +++ b/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C @@ -83,10 +83,7 @@ bool Foam::IOobject::readHeader(Istream& is) } // The note entry is optional - if (headerDict.found("note")) - { - note_ = string(headerDict.lookup("note")); - } + headerDict.readIfPresent("note", note_); } else { diff --git a/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C b/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C index cbf7800606..20030c2ea5 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C +++ b/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C @@ -49,7 +49,6 @@ bool Foam::IOobject::writeHeader(Ostream& os) const << " format " << os.format() << ";\n" << " class " << type() << ";\n"; - // outdent for visibility and more space if (note().size()) { os << " note " << note() << ";\n"; diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index f0948b77de..dd1e944067 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -101,14 +101,12 @@ void Foam::Time::setControls() { // default is to resume calculation from "latestTime" word startFrom("latestTime"); - if (controlDict_.found("startFrom")) - { - controlDict_.lookup("startFrom") >> startFrom; - } + + controlDict_.readIfPresent("startFrom", startFrom); if (startFrom == "startTime") { - startTime_ = readScalar(controlDict_.lookup("startTime")); + controlDict_.lookup("startTime") >> startTime_; } else { @@ -158,7 +156,7 @@ void Foam::Time::setControls() FatalErrorIn("Time::setControls()") << "Start time is not the same for all processors" << nl << "processor " << Pstream::myProcNo() << " has startTime " - << startTime_ << exit(FatalError); + << startTime_ << exit(FatalError); } } @@ -176,15 +174,13 @@ void Foam::Time::setControls() ) ); - if (timeDict.found("deltaT")) + if (timeDict.readIfPresent("deltaT", deltaTSave_)) { - deltaTSave_ = readScalar(timeDict.lookup("deltaT")); deltaT0_ = deltaTSave_; } - if (timeDict.found("index")) + if (timeDict.readIfPresent("index", startTimeIndex_)) { - timeDict.lookup("index") >> startTimeIndex_; timeIndex_ = startTimeIndex_; } } @@ -503,20 +499,9 @@ void Foam::Time::setTime(const instant& inst, const label newIndex) ) ); - if (timeDict.found("deltaT")) - { - deltaT_ = readScalar(timeDict.lookup("deltaT")); - } - - if (timeDict.found("deltaT0")) - { - deltaT0_ = readScalar(timeDict.lookup("deltaT0")); - } - - if (timeDict.found("index")) - { - timeIndex_ = readLabel(timeDict.lookup("index")); - } + timeDict.readIfPresent("deltaT", deltaT_); + timeDict.readIfPresent("deltaT0", deltaT0_); + timeDict.readIfPresent("index", timeIndex_); } @@ -647,7 +632,7 @@ Foam::Time& Foam::Time::operator++() case wcRunTime: case wcAdjustableRunTime: { - label outputTimeIndex = + label outputTimeIndex = label(((value() - startTime_) + 0.5*deltaT_)/writeInterval_); if (outputTimeIndex > outputTimeIndex_) diff --git a/src/OpenFOAM/db/Time/TimeIO.C b/src/OpenFOAM/db/Time/TimeIO.C index 45eaefed64..fc3ad8857c 100644 --- a/src/OpenFOAM/db/Time/TimeIO.C +++ b/src/OpenFOAM/db/Time/TimeIO.C @@ -44,10 +44,8 @@ void Foam::Time::readDict() ); } - if (controlDict_.found("writeInterval")) + if (controlDict_.readIfPresent("writeInterval", writeInterval_)) { - controlDict_.lookup("writeInterval") >> writeInterval_; - if (writeControl_ == wcTimeStep && label(writeInterval_) < 1) { FatalIOErrorIn("Time::readDict()", controlDict_) @@ -60,10 +58,8 @@ void Foam::Time::readDict() controlDict_.lookup("writeFrequency") >> writeInterval_; } - if (controlDict_.found("purgeWrite")) + if (controlDict_.readIfPresent("purgeWrite", purgeWrite_)) { - purgeWrite_ = readInt(controlDict_.lookup("purgeWrite")); - if (purgeWrite_ < 0) { WarningIn("Time::readDict()") @@ -106,10 +102,7 @@ void Foam::Time::readDict() } } - if (controlDict_.found("timePrecision")) - { - precision_ = readLabel(controlDict_.lookup("timePrecision")); - } + controlDict_.readIfPresent("timePrecision", precision_); // stopAt at 'endTime' or a specified value // if nothing is specified, the endTime is zero @@ -119,18 +112,14 @@ void Foam::Time::readDict() if (stopAt_ == saEndTime) { - endTime_ = readScalar(controlDict_.lookup("endTime")); + controlDict_.lookup("endTime") >> endTime_; } else { endTime_ = GREAT; } } - else if (controlDict_.found("endTime")) - { - endTime_ = readScalar(controlDict_.lookup("endTime")); - } - else + else if (!controlDict_.readIfPresent("endTime", endTime_)) { endTime_ = 0; } @@ -175,10 +164,7 @@ void Foam::Time::readDict() ); } - if (controlDict_.found("graphFormat")) - { - graphFormat_ = word(controlDict_.lookup("graphFormat")); - } + controlDict_.readIfPresent("graphFormat", graphFormat_); if (controlDict_.found("runTimeModifiable")) { diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H index 2d89ac4e79..33fcda639d 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H @@ -87,8 +87,7 @@ class lduMatrix public: - //- Class returned by the solver - // containing performance statistics + //- Class returned by the solver, containing performance statistics class solverPerformance { word solverName_; @@ -237,16 +236,6 @@ public: // Protected Member Functions - //- Read a control parameter from controlDict - template - inline void readControl - ( - const dictionary& controlDict, - T& control, - const word& controlName - ); - - //- Read the control parameters from the controlDict_ virtual void readControls(); @@ -318,7 +307,6 @@ public: Istream& solverData ); - // Selectors //- Return a new solver @@ -333,6 +321,7 @@ public: ); + // Destructor virtual ~solver() @@ -749,7 +738,7 @@ public: const lduInterfaceFieldPtrsList&, const direction cmpt ) const; - + //- Matrix transpose multiplication with updated interfaces. void Tmul ( @@ -800,7 +789,7 @@ public: scalarField& result, const direction cmpt ) const; - + //- Update interfaced interfaces for matrix operations void updateMatrixInterfaces ( @@ -810,7 +799,7 @@ public: scalarField& result, const direction cmpt ) const; - + template tmp > H(const Field&) const; diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C index 4db27fde04..19fd2435a0 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C @@ -171,9 +171,9 @@ Foam::lduMatrix::solver::solver void Foam::lduMatrix::solver::readControls() { - readControl(controlDict_, maxIter_, "maxIter"); - readControl(controlDict_, tolerance_, "tolerance"); - readControl(controlDict_, relTol_, "relTol"); + controlDict_.readIfPresent("maxIter", maxIter_); + controlDict_.readIfPresent("tolerance", tolerance_); + controlDict_.readIfPresent("relTol", relTol_); } diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C index 50767e741e..6209d81c86 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C @@ -31,21 +31,6 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -template -inline void Foam::lduMatrix::solver::readControl -( - const dictionary& controlDict, - T& control, - const word& controlName -) -{ - if (controlDict.found(controlName)) - { - controlDict.lookup(controlName) >> control; - } -} - - template Foam::tmp > Foam::lduMatrix::H(const Field& psi) const { diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C index 2042ac6ac3..cfd2f4513e 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C @@ -75,7 +75,7 @@ Foam::GAMGPreconditioner::~GAMGPreconditioner() void Foam::GAMGPreconditioner::readControls() { GAMGSolver::readControls(); - readControl(controlDict_, nVcycles_, "nVcycles"); + controlDict_.readIfPresent("nVcycles", nVcycles_); } diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C index fa13572601..f8a29ba241 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C @@ -154,13 +154,12 @@ void Foam::GAMGSolver::readControls() { lduMatrix::solver::readControls(); - readControl(controlDict_, cacheAgglomeration_, "cacheAgglomeration"); - - readControl(controlDict_, nPreSweeps_, "nPreSweeps"); - readControl(controlDict_, nPostSweeps_, "nPostSweeps"); - readControl(controlDict_, nFinestSweeps_, "nFinestSweeps"); - readControl(controlDict_, scaleCorrection_, "scaleCorrection"); - readControl(controlDict_, directSolveCoarsest_, "directSolveCoarsest"); + controlDict_.readIfPresent("cacheAgglomeration", cacheAgglomeration_); + controlDict_.readIfPresent("nPreSweeps", nPreSweeps_); + controlDict_.readIfPresent("nPostSweeps", nPostSweeps_); + controlDict_.readIfPresent("nFinestSweeps", nFinestSweeps_); + controlDict_.readIfPresent("scaleCorrection", scaleCorrection_); + controlDict_.readIfPresent("directSolveCoarsest", directSolveCoarsest_); } diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C index c07a626ec3..6b7c1cbcc3 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C @@ -72,7 +72,7 @@ Foam::smoothSolver::smoothSolver void Foam::smoothSolver::readControls() { lduMatrix::solver::readControls(); - readControl(controlDict_, nSweeps_, "nSweeps"); + controlDict_.readIfPresent("nSweeps", nSweeps_); } diff --git a/src/OpenFOAM/matrices/solution/solution.H b/src/OpenFOAM/matrices/solution/solution.H index 7b295cc18a..3d455fdecc 100644 --- a/src/OpenFOAM/matrices/solution/solution.H +++ b/src/OpenFOAM/matrices/solution/solution.H @@ -97,7 +97,7 @@ public: const dictionary& solverDict(const word& name) const; //- Return the stream of solver parameters for the given field - // (Provided for backward compatibility only) + // @deprecated Backward compatibility only - should use solverDict ITstream& solver(const word& name) const; diff --git a/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.C b/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.C index bdbde0c06f..c0d90270df 100644 --- a/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.C +++ b/src/OpenFOAM/meshes/patchIdentifier/patchIdentifier.C @@ -52,10 +52,7 @@ Foam::patchIdentifier::patchIdentifier name_(name), boundaryIndex_(index) { - if (dict.found("physicalType")) - { - dict.lookup("physicalType") >> physicalType_; - } + dict.readIfPresent("physicalType", physicalType_); } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C index e753d53d8a..96928eab87 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C @@ -622,10 +622,8 @@ Foam::cyclicPolyPatch::cyclicPolyPatch rotationAxis_(vector::zero), rotationCentre_(point::zero) { - if (dict.found("featureCos")) - { - dict.lookup("featureCos") >> featureCos_; - } + dict.readIfPresent("featureCos", featureCos_); + if (dict.found("transform")) { transform_ = transformTypeNames.read(dict.lookup("transform")); diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/newPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/newPolyPatch.C index 67a3e2886b..fde52b3e75 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/newPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/newPolyPatch.C @@ -27,14 +27,9 @@ License #include "polyPatch.H" #include "dictionary.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -autoPtr polyPatch::New +Foam::autoPtr Foam::polyPatch::New ( const word& patchType, const word& name, @@ -72,7 +67,7 @@ autoPtr polyPatch::New } -autoPtr polyPatch::New +Foam::autoPtr Foam::polyPatch::New ( const word& name, const dictionary& dict, @@ -89,10 +84,7 @@ autoPtr polyPatch::New word patchType(dict.lookup("type")); - if (dict.found("geometricType")) - { - dict.lookup("geometricType") >> patchType; - } + dict.readIfPresent("geometricType", patchType); dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTablePtr_->find(patchType); @@ -124,8 +116,4 @@ autoPtr polyPatch::New } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/preservePatchTypes/preservePatchTypes.C b/src/OpenFOAM/meshes/preservePatchTypes/preservePatchTypes.C index 2f46854f6f..7c6aecf8f4 100644 --- a/src/OpenFOAM/meshes/preservePatchTypes/preservePatchTypes.C +++ b/src/OpenFOAM/meshes/preservePatchTypes/preservePatchTypes.C @@ -77,19 +77,14 @@ void Foam::preservePatchTypes const dictionary& patchDict = patchDictionary.subDict(patchNames[patchi]); - patchTypes[patchi] = word(patchDict.lookup("type")); + patchDict.lookup("type") >> patchTypes[patchi]; - if (patchDict.found("geometricType")) - { - patchTypes[patchi] = - word(patchDict.lookup("geometricType")); - } - - if (patchDict.found("physicalType")) - { - patchPhysicalTypes[patchi] = - word(patchDict.lookup("physicalType")); - } + patchDict.readIfPresent("geometricType", patchTypes[patchi]); + patchDict.readIfPresent + ( + "physicalType", + patchPhysicalTypes[patchi] + ); } } @@ -98,10 +93,7 @@ void Foam::preservePatchTypes const dictionary& patchDict = patchDictionary.subDict(defaultFacesName); - if (patchDict.found("geometricType")) - { - defaultFacesType = word(patchDict.lookup("geometricType")); - } + patchDict.readIfPresent("geometricType", defaultFacesType); } } diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C index a2fd5ca976..17ad2db042 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C @@ -175,9 +175,7 @@ Foam::layerParameters::layerParameters featureAngle_(readScalar(dict.lookup("featureAngle"))), concaveAngle_ ( - dict.found("concaveAngle") - ? readScalar(dict.lookup("concaveAngle")) - : defaultConcaveAngle + dict.lookupOrDefault("concaveAngle", defaultConcaveAngle) ), nGrow_(readLabel(dict.lookup("nGrow"))), nSmoothSurfaceNormals_ @@ -242,9 +240,7 @@ Foam::layerParameters::layerParameters featureAngle_(readScalar(dict.lookup("featureAngle"))), concaveAngle_ ( - dict.found("concaveAngle") - ? readScalar(dict.lookup("concaveAngle")) - : defaultConcaveAngle + dict.lookupOrDefault("concaveAngle", defaultConcaveAngle) ), nGrow_(readLabel(dict.lookup("nGrow"))), nSmoothSurfaceNormals_ diff --git a/src/conversion/ensight/part/ensightPart.C b/src/conversion/ensight/part/ensightPart.C index 5ccb17e820..ff870658f6 100644 --- a/src/conversion/ensight/part/ensightPart.C +++ b/src/conversion/ensight/part/ensightPart.C @@ -171,14 +171,10 @@ void Foam::ensightPart::reconstruct(Istream& is) forAll(elementTypes(), elemI) { word key(elementTypes()[elemI]); - if (dict.found(key)) - { - dict.lookup(key) >> elemLists_[elemI]; - } - else - { - elemLists_[elemI].clear(); - } + + elemLists_[elemI].clear(); + dict.readIfPresent(key, elemLists_[elemI]); + size_ += elemLists_[elemI].size(); } diff --git a/src/conversion/meshReader/starcd/STARCDMeshReader.C b/src/conversion/meshReader/starcd/STARCDMeshReader.C index 751be41c57..084a792704 100644 --- a/src/conversion/meshReader/starcd/STARCDMeshReader.C +++ b/src/conversion/meshReader/starcd/STARCDMeshReader.C @@ -745,17 +745,17 @@ void Foam::meshReaders::STARCD::readBoundary(const fileName& inputName) iter != boundaryRegion_.end() ) { - if (iter().found("BoundaryType")) - { - iter().lookup("BoundaryType") >> patchTypes_[patchI]; - foundType = true; - } + foundType = iter().readIfPresent + ( + "BoundaryType", + patchTypes_[patchI] + ); - if (iter().found("Label")) - { - iter().lookup("Label") >> patchNames_[patchI]; - foundName = true; - } + foundName = iter().readIfPresent + ( + "Label", + patchNames_[patchI] + ); } // consistent names, in long form and in lowercase diff --git a/src/decompositionAgglomeration/decompositionMethods/metisDecomp/metisDecomp.C b/src/decompositionAgglomeration/decompositionMethods/metisDecomp/metisDecomp.C index 964556f074..74804f4e75 100644 --- a/src/decompositionAgglomeration/decompositionMethods/metisDecomp/metisDecomp.C +++ b/src/decompositionAgglomeration/decompositionMethods/metisDecomp/metisDecomp.C @@ -69,7 +69,7 @@ Foam::label Foam::metisDecomp::decompose // Method of decomposition // recursive: multi-level recursive bisection (default) - // k-way: multi-level k-way + // k-way: multi-level k-way word method("k-way"); // decomposition options. 0 = use defaults @@ -88,15 +88,12 @@ Foam::label Foam::metisDecomp::decompose // Check for user supplied weights and decomp options if (decompositionDict_.found("metisCoeffs")) { - dictionary metisDecompCoeffs - ( - decompositionDict_.subDict("metisCoeffs") - ); + const dictionary& metisCoeffs = + decompositionDict_.subDict("metisCoeffs"); + word weightsFile; - if (metisDecompCoeffs.found("method")) + if (metisCoeffs.readIfPresent("method", method)) { - metisDecompCoeffs.lookup("method") >> method; - if (method != "recursive" && method != "k-way") { FatalErrorIn("metisDecomp::decompose()") @@ -106,14 +103,12 @@ Foam::label Foam::metisDecomp::decompose << exit(FatalError); } - Info<< "metisDecomp : Using Metis options " << options - << endl << endl; + Info<< "metisDecomp : Using Metis method " << method + << nl << endl; } - if (metisDecompCoeffs.found("options")) + if (metisCoeffs.readIfPresent("options", options)) { - metisDecompCoeffs.lookup("options") >> options; - if (options.size() != 5) { FatalErrorIn("metisDecomp::decompose()") @@ -124,12 +119,11 @@ Foam::label Foam::metisDecomp::decompose } Info<< "metisDecomp : Using Metis options " << options - << endl << endl; + << nl << endl; } - if (metisDecompCoeffs.found("processorWeights")) + if (metisCoeffs.readIfPresent("processorWeights", processorWeights)) { - metisDecompCoeffs.lookup("processorWeights") >> processorWeights; processorWeights /= sum(processorWeights); if (processorWeights.size() != nProcessors_) @@ -142,20 +136,15 @@ Foam::label Foam::metisDecomp::decompose } } - if (metisDecompCoeffs.found("cellWeightsFile")) + if (metisCoeffs.readIfPresent("cellWeightsFile", weightsFile)) { Info<< "metisDecomp : Using cell-based weights." << endl; - word cellWeightsFile - ( - metisDecompCoeffs.lookup("cellWeightsFile") - ); - IOList cellIOWeights ( IOobject ( - cellWeightsFile, + weightsFile, mesh_.time().timeName(), mesh_, IOobject::MUST_READ, @@ -174,20 +163,15 @@ Foam::label Foam::metisDecomp::decompose } //- faceWeights disabled. Only makes sense for cellCells from mesh. - //if (metisDecompCoeffs.found("faceWeightsFile")) + //if (metisCoeffs.readIfPresent("faceWeightsFile", weightsFile)) //{ // Info<< "metisDecomp : Using face-based weights." << endl; // - // word faceWeightsFile - // ( - // metisDecompCoeffs.lookup("faceWeightsFile") - // ); - // // IOList weights // ( // IOobject // ( - // faceWeightsFile, + // weightsFile, // mesh_.time().timeName(), // mesh_, // IOobject::MUST_READ, @@ -366,7 +350,7 @@ Foam::labelList Foam::metisDecomp::decompose(const pointField& points) // number of internal faces label nInternalFaces = 2*mesh_.nInternalFaces(); - // Check the boundary for coupled patches and add to the number of + // Check the boundary for coupled patches and add to the number of // internal faces const polyBoundaryMesh& pbm = mesh_.boundaryMesh(); diff --git a/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C b/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C index 38a03e392a..a5778bcdf0 100644 --- a/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C +++ b/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C @@ -516,26 +516,20 @@ Foam::labelList Foam::parMetisDecomp::decompose(const pointField& points) // Check for user supplied weights and decomp options if (decompositionDict_.found("metisCoeffs")) { - dictionary parMetisDecompCoeffs - ( - decompositionDict_.subDict("metisCoeffs") - ); + const dictionary& metisCoeffs = + decompositionDict_.subDict("metisCoeffs"); + word weightsFile; - if (parMetisDecompCoeffs.found("cellWeightsFile")) + if (metisCoeffs.readIfPresent("cellWeightsFile", weightsFile)) { - word cellWeightsFile - ( - parMetisDecompCoeffs.lookup("cellWeightsFile") - ); - Info<< "parMetisDecomp : Using cell-based weights read from " - << cellWeightsFile << endl; + << weightsFile << endl; labelIOField cellIOWeights ( IOobject ( - cellWeightsFile, + weightsFile, mesh_.time().timeName(), mesh_, IOobject::MUST_READ, @@ -554,21 +548,16 @@ Foam::labelList Foam::parMetisDecomp::decompose(const pointField& points) } } - if (parMetisDecompCoeffs.found("faceWeightsFile")) + if (metisCoeffs.readIfPresent("faceWeightsFile", weightsFile)) { - word faceWeightsFile - ( - parMetisDecompCoeffs.lookup("faceWeightsFile") - ); - Info<< "parMetisDecomp : Using face-based weights read from " - << faceWeightsFile << endl; + << weightsFile << endl; labelIOField weights ( IOobject ( - faceWeightsFile, + weightsFile, mesh_.time().timeName(), mesh_, IOobject::MUST_READ, @@ -621,12 +610,10 @@ Foam::labelList Foam::parMetisDecomp::decompose(const pointField& points) } } - if (parMetisDecompCoeffs.found("options")) + if (metisCoeffs.readIfPresent("options", options)) { - parMetisDecompCoeffs.lookup("options") >> options; - Info<< "Using Metis options " << options - << endl << endl; + << nl << endl; if (options.size() != 3) { @@ -835,26 +822,20 @@ Foam::labelList Foam::parMetisDecomp::decompose // Check for user supplied weights and decomp options if (decompositionDict_.found("metisCoeffs")) { - dictionary parMetisDecompCoeffs - ( - decompositionDict_.subDict("metisCoeffs") - ); + const dictionary& metisCoeffs = + decompositionDict_.subDict("metisCoeffs"); + word weightsFile; - if (parMetisDecompCoeffs.found("cellWeightsFile")) + if (metisCoeffs.readIfPresent("cellWeightsFile", weightsFile)) { - word cellWeightsFile - ( - parMetisDecompCoeffs.lookup("cellWeightsFile") - ); - Info<< "parMetisDecomp : Using cell-based weights read from " - << cellWeightsFile << endl; + << weightsFile << endl; labelIOField cellIOWeights ( IOobject ( - cellWeightsFile, + weightsFile, mesh_.time().timeName(), mesh_, IOobject::MUST_READ, @@ -877,21 +858,16 @@ Foam::labelList Foam::parMetisDecomp::decompose } //- faceWeights disabled. Only makes sense for cellCells from mesh. - //if (parMetisDecompCoeffs.found("faceWeightsFile")) + //if (metisCoeffs.readIfPresent("faceWeightsFile", weightsFile)) //{ - // word faceWeightsFile - // ( - // parMetisDecompCoeffs.lookup("faceWeightsFile") - // ); - // // Info<< "parMetisDecomp : Using face-based weights read from " - // << faceWeightsFile << endl; + // << weightsFile << endl; // // labelIOField weights // ( // IOobject // ( - // faceWeightsFile, + // weightsFile, // mesh_.time().timeName(), // mesh_, // IOobject::MUST_READ, @@ -944,12 +920,10 @@ Foam::labelList Foam::parMetisDecomp::decompose // } //} - if (parMetisDecompCoeffs.found("options")) + if (metisCoeffs.readIfPresent("options", options)) { - parMetisDecompCoeffs.lookup("options") >> options; - Info<< "Using Metis options " << options - << endl << endl; + << nl << endl; if (options.size() != 3) { diff --git a/src/dynamicMesh/layerAdditionRemoval/layerAdditionRemoval.C b/src/dynamicMesh/layerAdditionRemoval/layerAdditionRemoval.C index 2835bee5cd..c90ad7e878 100644 --- a/src/dynamicMesh/layerAdditionRemoval/layerAdditionRemoval.C +++ b/src/dynamicMesh/layerAdditionRemoval/layerAdditionRemoval.C @@ -102,14 +102,7 @@ Foam::scalar Foam::layerAdditionRemoval::readOldThickness const dictionary& dict ) { - if (dict.found("oldLayerThickness")) - { - return readScalar(dict.lookup("oldLayerThickness")); - } - else - { - return -1.0; - } + dict.lookupOrDefault("oldLayerThickness", -1.0); } @@ -279,7 +272,7 @@ bool Foam::layerAdditionRemoval::changeTopology() const << "Layer thickness: min: " << minDelta << " max: " << maxDelta << " avg: " << avgDelta << " old thickness: " << oldLayerThickness_ << nl - << "Removal threshold: " << minLayerThickness_ + << "Removal threshold: " << minLayerThickness_ << " addition threshold: " << maxLayerThickness_ << endl; } @@ -295,7 +288,7 @@ bool Foam::layerAdditionRemoval::changeTopology() const } // No topological changes allowed before first mesh motion - // + // oldLayerThickness_ = avgDelta; topologicalChange = false; @@ -314,7 +307,7 @@ bool Foam::layerAdditionRemoval::changeTopology() const // At this point, info about moving the old mesh // in a way to collapse the cells in the removed // layer is available. Not sure what to do with - // it. + // it. if (debug) { diff --git a/src/engine/engineTime/engineTime.C b/src/engine/engineTime/engineTime.C index 7be803d320..edbd350388 100644 --- a/src/engine/engineTime/engineTime.C +++ b/src/engine/engineTime/engineTime.C @@ -84,23 +84,11 @@ Foam::engineTime::engineTime stroke_(dimensionedScalar("stroke", dimLength, 0)), clearance_(dimensionedScalar("clearance", dimLength, 0)) { - // the geometric parameters are not strictly required for Time - if (dict_.found("conRodLength")) - { - dict_.lookup("conRodLength") >> conRodLength_; - } - if (dict_.found("bore")) - { - dict_.lookup("bore") >> bore_; - } - if (dict_.found("stroke")) - { - dict_.lookup("stroke") >> stroke_; - } - if (dict_.found("clearance")) - { - dict_.lookup("clearance") >> clearance_; - } + // geometric parameters are not strictly required for Time + dict_.readIfPresent("conRodLength", conRodLength_); + dict_.readIfPresent("bore", bore_); + dict_.readIfPresent("stroke", stroke_); + dict_.readIfPresent("clearance", clearance_); timeAdjustment(); diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H index 44e66e3cb7..f9c82a2d58 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H @@ -342,11 +342,11 @@ public: //- Relax matrix (for steady-state solution). // alpha = 1 : diagonally equal - // alpha < 1 : ,, dominant + // alpha < 1 : diagonally dominant // alpha = 0 : do nothing void relax(const scalar alpha); - //- Relax matrix (for steadty-state solution). + //- Relax matrix (for steady-state solution). // alpha is read from controlDict void relax(); diff --git a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C index e01f39c97d..649013fdf1 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C @@ -162,10 +162,7 @@ Foam::autoPtr Foam::coordinateRotation::New // default type is self (alias: "axes") word rotType(typeName_()); - if (dict.found("type")) - { - dict.lookup("type") >> rotType; - } + dict.readIfPresent("type", rotType); // can (must) construct base class directly if (rotType == typeName_() || rotType == "axes") diff --git a/src/meshTools/searchableSurface/searchableSurfaces.C b/src/meshTools/searchableSurface/searchableSurfaces.C index 9689744fca..cd7171ed5e 100644 --- a/src/meshTools/searchableSurface/searchableSurfaces.C +++ b/src/meshTools/searchableSurface/searchableSurfaces.C @@ -176,12 +176,7 @@ Foam::searchableSurfaces::searchableSurfaces const dictionary& dict = topDict.subDict(key); names_[surfI] = key; - - if (dict.found("name")) - { - dict.lookup("name") >> names_[surfI]; - } - + dict.readIfPresent("name", names_[surfI]); // Make IOobject with correct name autoPtr namedIO(io.clone()); diff --git a/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.C b/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.C index df3598e953..ee7c3c6ef1 100644 --- a/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.C +++ b/src/sampling/outputFilters/OutputFilterFunctionObject/OutputFilterFunctionObject.C @@ -34,25 +34,10 @@ License template void Foam::OutputFilterFunctionObject::readDict() { - if (dict_.found("region")) - { - dict_.lookup("region") >> regionName_; - } - - if (dict_.found("dictionary")) - { - dict_.lookup("dictionary") >> dictName_; - } - - if (dict_.found("interval")) - { - dict_.lookup("interval") >> interval_; - } - - if (dict_.found("enabled")) - { - dict_.lookup("enabled") >> execution_; - } + dict_.readIfPresent("region", regionName_); + dict_.readIfPresent("dictionary", dictName_); + dict_.readIfPresent("interval", interval_); + dict_.readIfPresent("enabled", execution_); } diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.C b/src/sampling/sampledSet/sampledSets/sampledSets.C index 1877e39df5..7c1e86fd01 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.C +++ b/src/sampling/sampledSet/sampledSets/sampledSets.C @@ -289,16 +289,10 @@ void Foam::sampledSets::read(const dictionary& dict) fieldNames_ = wordList(dict_.lookup("fields")); interpolationScheme_ = "cell"; - if (dict_.found("interpolationScheme")) - { - dict_.lookup("interpolationScheme") >> interpolationScheme_; - } + dict_.readIfPresent("interpolationScheme", interpolationScheme_); writeFormat_ = "null"; - if (dict_.found("setFormat")) - { - dict_.lookup("setFormat") >> writeFormat_; - } + dict_.readIfPresent("setFormat", writeFormat_); scalarFields_.clear(); vectorFields_.clear(); diff --git a/src/sampling/sampledSurface/plane/sampledPlane.C b/src/sampling/sampledSurface/plane/sampledPlane.C index 7a9dfdd641..d3a7f799f8 100644 --- a/src/sampling/sampledSurface/plane/sampledPlane.C +++ b/src/sampling/sampledSurface/plane/sampledPlane.C @@ -156,9 +156,8 @@ Foam::sampledPlane::sampledPlane label zoneId = -1; - if (dict.found("zone")) + if (dict.readIfPresent("zone", zoneName_)) { - dict.lookup("zone") >> zoneName_; zoneId = mesh.cellZones().findZoneID(zoneName_); if (debug && zoneId < 0) { diff --git a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C index a9418c8046..8d5c60df91 100644 --- a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C +++ b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C @@ -188,10 +188,7 @@ Foam::sampledSurface::sampledSurface CfPtr_(NULL), area_(-1) { - if (dict.found("name")) - { - dict.lookup("name") >> name_; - } + dict.readIfPresent("name", name_); } diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index b3aff7e235..4fb6b6c43b 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -327,16 +327,10 @@ void Foam::sampledSurfaces::read(const dictionary& dict) fieldNames_ = wordList(dict.lookup("fields")); interpolationScheme_ = "cell"; - if (dict.found("interpolationScheme")) - { - dict.lookup("interpolationScheme") >> interpolationScheme_; - } + dict.readIfPresent("interpolationScheme", interpolationScheme_); writeFormat_ = "null"; - if (dict.found("surfaceFormat")) - { - dict.lookup("surfaceFormat") >> writeFormat_; - } + dict.readIfPresent("surfaceFormat", writeFormat_); PtrList newList diff --git a/src/thermophysicalModels/combustion/chemistryReaders/chemistryReader/chemistryReader.C b/src/thermophysicalModels/combustion/chemistryReaders/chemistryReader/chemistryReader.C index 6f278a7f71..be4c7b6eae 100644 --- a/src/thermophysicalModels/combustion/chemistryReaders/chemistryReader/chemistryReader.C +++ b/src/thermophysicalModels/combustion/chemistryReaders/chemistryReader/chemistryReader.C @@ -46,10 +46,7 @@ Foam::autoPtr Foam::chemistryReader::New word chemistryReaderTypeName("chemkinReader"); // otherwise use the specified reader - if (thermoDict.found("chemistryReader")) - { - thermoDict.lookup("chemistryReader") >> chemistryReaderTypeName; - } + thermoDict.readIfPresent("chemistryReader", chemistryReaderTypeName); Info<< "Selecting chemistryReader " << chemistryReaderTypeName << endl; diff --git a/src/turbulenceModels/LES/compressible/LESModel/LESModel.C b/src/turbulenceModels/LES/compressible/LESModel/LESModel.C index 841d116e62..8591c4c7b4 100644 --- a/src/turbulenceModels/LES/compressible/LESModel/LESModel.C +++ b/src/turbulenceModels/LES/compressible/LESModel/LESModel.C @@ -88,10 +88,7 @@ LESModel::LESModel delta_(LESdelta::New("delta", U.mesh(), *this)) { - if (found("k0")) - { - lookup("k0") >> k0_; - } + readIfPresent("k0", k0_); } @@ -117,10 +114,7 @@ bool LESModel::read() delta_().read(*this); - if (found("k0")) - { - lookup("k0") >> k0_; - } + readIfPresent("k0", k0_); return true; } diff --git a/src/turbulenceModels/LES/incompressible/LESModel/LESModel.C b/src/turbulenceModels/LES/incompressible/LESModel/LESModel.C index 7be12ff448..4eefbe2d60 100644 --- a/src/turbulenceModels/LES/incompressible/LESModel/LESModel.C +++ b/src/turbulenceModels/LES/incompressible/LESModel/LESModel.C @@ -87,10 +87,7 @@ LESModel::LESModel delta_(LESdelta::New("delta", U.mesh(), *this)) { - if (found("k0")) - { - lookup("k0") >> k0_; - } + readIfPresent("k0", k0_); } @@ -117,10 +114,7 @@ bool LESModel::read() delta_().read(*this); - if (found("k0")) - { - lookup("k0") >> k0_; - } + readIfPresent("k0", k0_); return true; } From f75ffd7f156e9f54766cce5ec291c9f9249de305 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sun, 20 Jul 2008 14:17:08 +0200 Subject: [PATCH 11/30] cosmetics --- src/OpenFOAM/include/addRegionOption.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenFOAM/include/addRegionOption.H b/src/OpenFOAM/include/addRegionOption.H index a67d1e0fbd..382836d329 100644 --- a/src/OpenFOAM/include/addRegionOption.H +++ b/src/OpenFOAM/include/addRegionOption.H @@ -1 +1 @@ - argList::validOptions.insert("region", "region name"); + argList::validOptions.insert("region", "name"); From 0473f177ad73bab0087bd068d4e8cb4be731bcc9 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sun, 20 Jul 2008 15:19:07 +0200 Subject: [PATCH 12/30] Create unique member name for addNamed...SelectionTable We can now add the same member function with different lookups e.g. 'stl' and 'stlb' By using leading/trailing underscores around the lookup name, we get a unique name and avoid possible collision with other classes. --- .../addToMemberFunctionSelectionTable.H | 7 +++---- .../db/runTimeSelection/addToRunTimeSelectionTable.H | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/OpenFOAM/db/memberFunctionSelection/addToMemberFunctionSelectionTable.H b/src/OpenFOAM/db/memberFunctionSelection/addToMemberFunctionSelectionTable.H index 5d6b78db47..7bfd089dc3 100644 --- a/src/OpenFOAM/db/memberFunctionSelection/addToMemberFunctionSelectionTable.H +++ b/src/OpenFOAM/db/memberFunctionSelection/addToMemberFunctionSelectionTable.H @@ -26,7 +26,7 @@ InClass Foam::memberFunctionSelectionTables Description - Macros to enable the easy insertion into member function selection tables. + Macros for easy insertion into member function selection tables \*---------------------------------------------------------------------------*/ @@ -47,14 +47,13 @@ Description \ /* Add the thisType constructor function to the table */ \ baseType::add##memberFunction##argNames##MemberFunctionToTable \ - add##thisType##memberFunction##argNames##MemberFunctionTo##baseType##Table_(#lookup) + add_##lookup##_##thisType##memberFunction##argNames##MemberFunctionTo##baseType##Table_(#lookup) #define addTemplateToMemberFunctionSelectionTable\ (baseType,thisType,Targ,memberFunction,argNames) \ \ /* Add the thisType constructor function to the table */ \ - baseType::add##memberFunction##argNames##MemberFunctionToTable \ - > \ + baseType::add##memberFunction##argNames##MemberFunctionToTable > \ add##thisType##Targ##memberFunction##argNames##MemberFunctionTo##baseType##Table_ diff --git a/src/OpenFOAM/db/runTimeSelection/addToRunTimeSelectionTable.H b/src/OpenFOAM/db/runTimeSelection/addToRunTimeSelectionTable.H index b3bbf50cb7..3a1d74e28a 100644 --- a/src/OpenFOAM/db/runTimeSelection/addToRunTimeSelectionTable.H +++ b/src/OpenFOAM/db/runTimeSelection/addToRunTimeSelectionTable.H @@ -26,7 +26,7 @@ InClass Foam::runTimeSelectionTables Description - Macros to enable the easy insertion into run-time selection tables. + Macros for easy insertion into run-time selection tables \*---------------------------------------------------------------------------*/ @@ -45,7 +45,7 @@ Description \ /* Add the thisType constructor function to the table */ \ baseType::add##argNames##ConstructorToTable \ - add##thisType##argNames##ConstructorTo##baseType##Table_(#lookup) + add_##lookup##_##thisType##argNames##ConstructorTo##baseType##Table_(#lookup) #define addTemplateToRunTimeSelectionTable(baseType,thisType,Targ,argNames) \ \ From 4d96b876e4f55bf41ef8303cdbc3c9de2208147e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sun, 20 Jul 2008 15:53:43 +0200 Subject: [PATCH 13/30] cleanup of foam-pack scripts - removed legacy foamDiffSourceList, foamPackChanged - added foamPackDoxygen for separate distribution of docs handles -prefix option - misc. cosmetic changes --- bin/foamDiffSourceList | 135 -------------------------------------- bin/foamExec | 4 +- bin/foamJob | 10 ++- bin/foamNew | 4 +- bin/foamPack | 3 +- bin/foamPackBin | 2 +- bin/foamPackBinAll | 3 +- bin/foamPackChanged | 105 ----------------------------- bin/foamPackDoxygen | 121 ++++++++++++++++++++++++++++++++++ bin/foamPackSource | 9 ++- bin/foamPackThirdPartyBin | 4 +- bin/paraFoam | 18 +++-- bin/rmcore | 2 +- bin/rmdepall | 19 +++--- bin/rm~all | 2 +- 15 files changed, 161 insertions(+), 280 deletions(-) delete mode 100755 bin/foamDiffSourceList delete mode 100755 bin/foamPackChanged create mode 100755 bin/foamPackDoxygen diff --git a/bin/foamDiffSourceList b/bin/foamDiffSourceList deleted file mode 100755 index 560d965032..0000000000 --- a/bin/foamDiffSourceList +++ /dev/null @@ -1,135 +0,0 @@ -#!/bin/sh -#------------------------------------------------------------------------------ -# ========= | -# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox -# \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. -# \\/ M anipulation | -#------------------------------------------------------------------------------- -# License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# Script -# foamDiffSourceList -# -# Description -# Packs and compresses files that have changed (diff -uw) between -# oldDir newDir -# -#------------------------------------------------------------------------------ -tmpFile=${TMPDIR:-/tmp}/foamDiffList.$$ - -if [ $# -ne 3 ]; then - echo "Usage : ${0##*/} oldDir newDir tarFile" - echo "" - echo "Find the files that changed (diff -uw) between and " - echo "and pack them into " - echo "" - exit 1 -fi - -# canonical form (no double and no trailing dashes) -oldDir=$(echo "$1" | sed -e 's@//*@/@g' -e 's@/$@@') -newDir=$(echo "$2" | sed -e 's@//*@/@g' -e 's@/$@@') -packFile=$3 - -if [ ! -d $oldDir ]; then - echo "Error: directory $oldDir does not exist" - exit 1 -fi - -if [ ! -d $newDir ]; then - echo "Error: directory $newDir does not exist" - exit 1 -fi - -if [ -f $packFile ]; then - echo "Error: $packFile already exists" - exit 1 -fi - -# Clean up on termination and on Ctrl-C -trap 'rm -f $tmpFile 2>/dev/null; exit 0' EXIT TERM INT - -fileCount=0 -cat /dev/null > $tmpFile - -find -H $newDir \ - ! -type d -type f \ - ! -name "*~" \ - -a ! -name ".*~" \ - -a ! -name ".#*" \ - -a ! -name "*.orig" \ - -a ! -name "*.dep" \ - -a ! -name "*.o" \ - -a ! -name "*.so" \ - -a ! -name "*.a" \ - -a ! -name "*.tgz" \ - -a ! -name "core" \ - -a ! -name "core.[1-9]*" \ - -a ! -name "log[0-9]*" \ -| sed \ - -e "\@$newDir/.git/@d" \ - -e "\@$newDir/lib/@d" \ - -e '\@applications/bin/@d' \ - -e '\@/t/@d' \ - -e '\@Make[.A-Za-z]*/[^/]*/@d' \ - -e '\@[Dd]oxygen/html@d' \ - -e '\@[Dd]oxygen/latex@d' \ - -e '\@[Dd]oxygen/man@d' \ - -e "s@$newDir/*@@" \ - | \ - ( - while read file - do - (( fileCount=$fileCount + 1)) - - if [ -f "$oldDir/$file" ] - then - diff -uw $oldDir/$file $newDir/$file >/dev/null 2>&1 - if [ $? = 1 ] - then - echo "[DIFF]" $file - echo $newDir/$file >> $tmpFile - continue - fi - else - echo "[NEW]" $file - echo $newDir/$file >> $tmpFile - continue - fi - echo $fileCount $file - done - ) - -# file fileCount -fileCount=$(cat $tmpFile | wc -l) -echo "----------------------------------------------------------------------" -echo "pack $fileCount changed/new files" - -tar -czpf $packFile --files-from $tmpFile - -if [ $? = 0 ] -then - echo "Finished packing changed files from $newDir into $packFile" -else - echo "Error: failure packing changed files from $newDir into $packFile" - rm -f $packFile 2>/dev/null -fi -echo "----------------------------------------------------------------------" - -# ---------------------------------------------------------------------------- diff --git a/bin/foamExec b/bin/foamExec index b4ec646637..dea3c664f8 100755 --- a/bin/foamExec +++ b/bin/foamExec @@ -37,13 +37,11 @@ # foamExec -v ... -parallel # #------------------------------------------------------------------------------ -Script=${0##*/} - usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat< ... +usage: ${0##*/} [OPTION] ... options: -v ver specify OpenFOAM version diff --git a/bin/foamJob b/bin/foamJob index 39d32db801..1aad5fca99 100755 --- a/bin/foamJob +++ b/bin/foamJob @@ -29,13 +29,11 @@ # Description # #------------------------------------------------------------------------------ -Script=${0##*/} - usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat< ... +usage: ${0##*/} [OPTION] ... options: -case dir specify case directory @@ -108,9 +106,9 @@ do usage ;; -case) - shift - caseDir=$1 - [ "$#" -ge 1 ] || usage "'-case' option requires an argument" + [ "$#" -ge 2 ] || usage "'-case' option requires an argument" + caseDir=$2 + shift 2 cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'" ;; -s) diff --git a/bin/foamNew b/bin/foamNew index 3900c3c74c..15005c5c83 100755 --- a/bin/foamNew +++ b/bin/foamNew @@ -30,13 +30,11 @@ # Create a new standard OpenFOAM source file # #------------------------------------------------------------------------------ -Script=${0##*/} - usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat< {args} +usage: ${0##*/} {args} * create a new standard OpenFOAM source file diff --git a/bin/foamPack b/bin/foamPack index 6541e10c4a..8166714c6b 100755 --- a/bin/foamPack +++ b/bin/foamPack @@ -43,7 +43,8 @@ then fi # add optional output directory -if [ -d "$1" ]; then +if [ -d "$1" ] +then packFile="$1/$packFile" fi diff --git a/bin/foamPackBin b/bin/foamPackBin index 99ceabb402..4c0d673e27 100755 --- a/bin/foamPackBin +++ b/bin/foamPackBin @@ -31,7 +31,7 @@ # #------------------------------------------------------------------------------ -if [ $# = 0 ] +if [ $# -eq 0 ] then echo "Error: architecture type expected, exiting" echo diff --git a/bin/foamPackBinAll b/bin/foamPackBinAll index 76ad4ffb81..45708b17c3 100755 --- a/bin/foamPackBinAll +++ b/bin/foamPackBinAll @@ -27,7 +27,7 @@ # foamPackBinAll [outputDir] # # Description -# Packs and compresses all binary version of foam for release +# Packs and compresses all binary versions of foam for release # #------------------------------------------------------------------------------ packDir=$WM_PROJECT-$WM_PROJECT_VERSION @@ -38,6 +38,7 @@ then exit 1 fi +# obtain arch types from lib/ for bin in $packDir/lib/* do foamPackBin ${bin##*/} $@ diff --git a/bin/foamPackChanged b/bin/foamPackChanged deleted file mode 100755 index 93fac19060..0000000000 --- a/bin/foamPackChanged +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/sh -#------------------------------------------------------------------------------ -# ========= | -# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox -# \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. -# \\/ M anipulation | -#------------------------------------------------------------------------------- -# License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# Script -# foamPackChanged -# -# Description -# Packs and compresses files that have a corresponding .orig file -# -#------------------------------------------------------------------------------ -tmpFile=${TMPDIR:-/tmp}/foamPackChanged.$$ - -if [ $# -ne 2 ]; then - echo "Usage : ${0##*/} directory tarFile" - echo "" - echo "Packs and compresses files that have a corresponding .orig file" - echo "" - exit 1 -fi - -# canonical form (no double and no trailing dashes) -packDir=$(echo "$1" | sed -e 's@//*@/@g' -e 's@/$@@') -packFile=$2 - -if [ ! -d $packDir ]; then - echo "Error: directory $packDir does not exist" - exit 1 -fi - -# Clean up on termination and on Ctrl-C -trap 'rm -f $tmpFile 2>/dev/null; exit 0' EXIT TERM INT - -fileCount=0 -cat /dev/null > $tmpFile - -find -H $packDir \ - ! -type d \ - -type f \ - -name "*.orig" \ -| sed \ - -e "\@$packDir/lib/@d" \ - -e '\@applications/bin/@d' \ - -e '\@/t/@d' \ - -e '\@Make[.A-Za-z]*/[^/]*/@d' \ - -e '\@[Dd]oxygen/html@d' \ - -e '\@[Dd]oxygen/latex@d' \ - -e '\@[Dd]oxygen/man@d' \ - -e "s@$packDir/*@@" \ - | \ - ( - while read file - do - (( fileCount=$fileCount + 1 )) - - file=${file%%.orig} - - if [ -f "$packDir/$file" ] - then - echo $fileCount $file - echo $packDir/$file >> $tmpFile - else - echo "[MISSING]" $file - fi - done - ) - -# file fileCount -fileCount=$(cat $tmpFile | wc -l) -echo "----------------------------------------------------------------------" -echo "pack $fileCount updated (non-.orig) files" - -tar -czpf $packFile --files-from $tmpFile - -if [ $? = 0 ] -then - echo "Finished packing changed files from $packDir into $packFile" -else - echo "Error: failure packing changed files from $packDir into $packFile" - rm -f $packFile 2>/dev/null -fi -echo "----------------------------------------------------------------------" - -# ---------------------------------------------------------------------------- diff --git a/bin/foamPackDoxygen b/bin/foamPackDoxygen new file mode 100755 index 0000000000..239c87c740 --- /dev/null +++ b/bin/foamPackDoxygen @@ -0,0 +1,121 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------- +# License +# This file is part of OpenFOAM. +# +# OpenFOAM is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with OpenFOAM; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# Script +# foamPackDoxygen [-prefix DIR] [-o outputDir] +# +# Description +# Packs and compresses the OpenFOAM doxygen html for release +# +#------------------------------------------------------------------------------ +packDir=$WM_PROJECT-$WM_PROJECT_VERSION +packTag=_Doxygen.gtgz + +usage() { +cat <&2 +Usage: ${0##*/} [-prefix DIR] [-o outputDir] + + Packs and compresses the OpenFOAM doxygen html for release + +USAGE + exit 1 +} + +unset prefix outputDir + +while [ "$#" -gt 0 ] +do + case $1 in + -prefix | --prefix ) + prefix=${2%%/} + shift 2 + ;; + -o | -output ) + outputDir=${2%%/} + shift 2 + ;; + -h | -help ) + usage + ;; + -*) + usage "unknown option: '$*'" + ;; + esac +done + +# if packing from within the directory, use -prefix form +if [ "${PWD##*/}" = "$packDir" ] +then + : ${prefix:=$packDir} +fi + +# pack the directories directly and add prefix afterwards +if [ -n "$prefix" ] +then + packDir="$prefix" +elif [ ! -d $packDir ] +then + echo "Error: directory $packDir does not exist" + exit 1 +fi + +# +# add optional output directory +# +if [ -d "$outputDir" ] +then + packFile="$outputDir/$packDir$packTag" +else + packFile="$packDir$packTag" +fi + + +if [ -f $packFile ] +then + echo "Error: $packFile already exists" + exit 1 +fi + +# Pack and compress the packFile using GNU tar +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +echo +echo "Packing doxygen html into $packFile" +echo + +if [ -n "$prefix" ] +then + tar czpf $packFile --transform="s@^@$prefix/@" doc/Doxygen/html +else + tar czpf $packFile $packDir/doc/Doxygen/html +fi + +if [ $? = 0 ] +then + echo "Finished packing doxygen html into file $packFile" +else + echo "Error: failure packing doxygen html file $packFile" +fi + +#------------------------------------------------------------------------------ diff --git a/bin/foamPackSource b/bin/foamPackSource index 7db55ed86b..2bdee4916d 100755 --- a/bin/foamPackSource +++ b/bin/foamPackSource @@ -33,7 +33,8 @@ #------------------------------------------------------------------------------ tmpFile=${TMPDIR:-/tmp}/foamPackFiles.$$ -if [ $# -ne 2 ]; then +if [ $# -ne 2 ] +then echo "Usage : ${0##*/} directory tarFile" echo "" echo "Packs all .C and .H files and Make/options and Make/files into" @@ -46,12 +47,14 @@ fi packDir=$(echo "$1" | sed -e 's@//*@/@g' -e 's@/$@@') packFile=$2 -if [ ! -d $packDir ]; then +if [ ! -d $packDir ] +then echo "Error: directory $packDir does not exist" exit 1 fi -if [ -f $packFile ]; then +if [ -f $packFile ] +then echo "Error: $packFile already exists" exit 1 fi diff --git a/bin/foamPackThirdPartyBin b/bin/foamPackThirdPartyBin index 484c0c1e4b..cc99b95d27 100755 --- a/bin/foamPackThirdPartyBin +++ b/bin/foamPackThirdPartyBin @@ -33,14 +33,14 @@ if [ $# = 0 ] then - echo "Error: archOptionsitecture type expected, exiting" + echo "Error: archOptions type expected, exiting" echo echo "Usage : ${0##*/} [outputDir]" echo exit 1 fi archOptions=$1 -arch=${archOptions%%G*} +arch=${archOptions%%G*} # TODO: works for Gcc only arch3264=$(echo "$arch" | sed 's@64@-64@') timeStamp=$(date +%Y-%m-%d) diff --git a/bin/paraFoam b/bin/paraFoam index 93fb4cf03b..217596343a 100755 --- a/bin/paraFoam +++ b/bin/paraFoam @@ -30,13 +30,11 @@ # start paraview with the OpenFOAM libraries # #------------------------------------------------------------------------------ -Script=${0##*/} - usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat</dev/null || usage "directory does not exist: '$caseDir'" ;; *) usage "unknown option/argument: '$*'" ;; esac -fi +done # get a sensible caseName caseName=${PWD##*/} +caseFile="$caseName.OpenFOAM" # parent directory for normal or parallel results case "$caseName" in @@ -77,8 +77,6 @@ do [ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'" done -#caseFile="$caseName.foam" -caseFile="$caseName.OpenFOAM" case "$ParaView_VERSION" in 2*) diff --git a/bin/rmcore b/bin/rmcore index 6014adc414..1245878ff3 100755 --- a/bin/rmcore +++ b/bin/rmcore @@ -1,3 +1,3 @@ #!/bin/sh -#find . \( -name 'core' \) -exec ls -l {} \; -exec rm {} \; +# find . \( -name 'core' \) -exec ls -l {} \; -exec rm {} \; find . \( -type f -name 'core' -o -name 'core.[1-9]*' -o -name 'vgcore.*' \) -print | xargs -t rm diff --git a/bin/rmdepall b/bin/rmdepall index 89e6e4c566..84e6526741 100755 --- a/bin/rmdepall +++ b/bin/rmdepall @@ -1,12 +1,15 @@ #!/bin/sh -if [ $# -eq 0 ]; then - find . \( -name '*.dep' \) -print | xargs -t rm -elif [ $# -eq 1 ]; then - echo "Removing all dep files containing $1..." - find . -name '*.dep' -exec grep "$1" '{}' \; -exec rm '{}' \; +if [ $# -eq 0 ] +then + find . \( -name '*.dep' \) -print | xargs -t rm +elif [ $# -eq 1 ] +then + echo "Removing all dep files containing $1..." + find . -name '*.dep' -exec grep "$1" '{}' \; -exec rm '{}' \; else - echo "Usage: `basename $0` to remove all .dep files" - echo " `basename $0` to remove all .dep files referring to " - exit 1 + echo "Usage: ${0##/} to remove all .dep files" + echo " ${0##/} to remove all .dep files referring to " + exit 1 fi + diff --git a/bin/rm~all b/bin/rm~all index 73ea1d5569..6ee2bad370 100755 --- a/bin/rm~all +++ b/bin/rm~all @@ -1,3 +1,3 @@ #!/bin/sh -#find . \( -name '*~' -o -name '.*~' \) -exec ls -l {} \; -exec rm {} \; +# find . \( -name '*~' -o -name '.*~' \) -exec ls -l {} \; -exec rm {} \; find . \( -name '*~' -o -name '.*~' \) -print | xargs -t rm From 85c164340e7b458dadb01a728df73e18f740a74b Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 21 Jul 2008 16:40:05 +0200 Subject: [PATCH 14/30] Added IOobject::readOption to IOOutputFilter - allows post-processing functions with an optional dictionary (eg, the developer can hard-wire some defaults) --- .../sampling/probeLocations/probeLocations.C | 2 +- .../postProcessing/sampling/sample/sample.C | 71 ++++++++++--------- .../IOOutputFilter/IOOutputFilter.C | 3 +- .../IOOutputFilter/IOOutputFilter.H | 4 +- 4 files changed, 42 insertions(+), 38 deletions(-) diff --git a/applications/utilities/postProcessing/sampling/probeLocations/probeLocations.C b/applications/utilities/postProcessing/sampling/probeLocations/probeLocations.C index 920f251656..4e960a7415 100644 --- a/applications/utilities/postProcessing/sampling/probeLocations/probeLocations.C +++ b/applications/utilities/postProcessing/sampling/probeLocations/probeLocations.C @@ -44,7 +44,7 @@ int main(int argc, char *argv[]) instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - IOprobes sniff(mesh, "probesDict", true); + IOprobes sniff(mesh, "probesDict", IOobject::MUST_READ, true); forAll(timeDirs, timeI) { diff --git a/applications/utilities/postProcessing/sampling/sample/sample.C b/applications/utilities/postProcessing/sampling/sample/sample.C index 1cc9115dba..f2b27de8ea 100644 --- a/applications/utilities/postProcessing/sampling/sample/sample.C +++ b/applications/utilities/postProcessing/sampling/sample/sample.C @@ -28,39 +28,39 @@ Description Keywords: - setFormat: set output format, choice of - xmgr - jplot - gnuplot - raw + @param setFormat : set output format, choice of \n + - xmgr + - jplot + - gnuplot + - raw - surfaceFormat: surface output format, choice of - null : suppress output - foamFile : separate points, faces and values file - dx : DX scalar or vector format - vtk : VTK ascii format - raw : x y z value format for use with e.g. gnuplot 'splot'. - stl : ascii stl. Does not contain values! + @param surfaceFormat : surface output format, choice of \n + - null : suppress output + - foamFile : separate points, faces and values file + - dx : DX scalar or vector format + - vtk : VTK ascii format + - raw : x y z value format for use with e.g. gnuplot 'splot'. + - stl : ascii stl. Does not contain values! - interpolationScheme: interpolation scheme, choice of - cell : use cell-centre value; constant over cells (default) - cellPoint : use cell-centre and vertex values - cellPointFace : use cell-centre, vertex and face values. - 1] vertex values determined from neighbouring cell-centre values - 2] face values determined using the current face interpolation scheme - for the field (linear, limitedLinear, etc.) + @param interpolationScheme : interpolation scheme, choice of \n + - cell : use cell-centre value; constant over cells (default) + - cellPoint : use cell-centre and vertex values + - cellPointFace : use cell-centre, vertex and face values. \n + -# vertex values determined from neighbouring cell-centre values + -# face values determined using the current face interpolation scheme + for the field (linear, limitedLinear, etc.) - fields: list of fields to sample + @param fields : list of fields to sample - sets: list of sets to sample, choice of - uniform evenly distributed points on line - face one point per face intersection - midPoint one point per cell, inbetween two face intersections - midPointAndFace combination of face and midPoint + @param sets : list of sets to sample, choice of \n + - uniform evenly distributed points on line + - face one point per face intersection + - midPoint one point per cell, inbetween two face intersections + - midPointAndFace combination of face and midPoint - curve specified points, not nessecary on line, uses + - curve specified points, not nessecary on line, uses tracking - cloud specified points, uses findCell + - cloud specified points, uses findCell Option axis: how to write point coordinate. Choice of - x/y/z: x/y/z coordinate only @@ -74,11 +74,12 @@ Description uniform: extra number of sampling points curve, cloud: list of coordinates - surfaces: list of surfaces to sample, choice of - plane : values on plane defined by point, normal. - patch : values on patch. + @param surfaces : list of surfaces to sample, choice of \n + - plane : values on plane defined by point, normal. + - patch : values on patch. - Runs in parallel. +Notes + Runs in parallel \*---------------------------------------------------------------------------*/ @@ -100,8 +101,8 @@ int main(int argc, char *argv[]) instantList timeDirs = timeSelector::select0(runTime, args); # include "createMesh.H" - IOsampledSets sSets(mesh, "sampleDict", true); - IOsampledSurfaces sSurfaces(mesh, "sampleDict", true); + IOsampledSets sSets(mesh, "sampleDict", IOobject::MUST_READ, true); + IOsampledSurfaces sSurfs(mesh, "sampleDict", IOobject::MUST_READ, true); forAll(timeDirs, timeI) { @@ -112,10 +113,10 @@ int main(int argc, char *argv[]) polyMesh::readUpdateState state = mesh.readUpdate(); sSets.readUpdate(state); - sSurfaces.readUpdate(state); + sSurfs.readUpdate(state); sSets.write(); - sSurfaces.write(); + sSurfs.write(); Info<< endl; } diff --git a/src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.C b/src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.C index b2ee559eaa..e76c2252d4 100644 --- a/src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.C +++ b/src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.C @@ -34,6 +34,7 @@ Foam::IOOutputFilter::IOOutputFilter ( const objectRegistry& obr, const fileName& dictName, + const IOobject::readOption rOpt, const bool readFromFiles ) : @@ -44,7 +45,7 @@ Foam::IOOutputFilter::IOOutputFilter dictName, obr.time().system(), obr, - IOobject::MUST_READ, + rOpt, IOobject::NO_WRITE ) ), diff --git a/src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.H b/src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.H index 77d3087737..bd69a5f3d3 100644 --- a/src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.H +++ b/src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.H @@ -70,11 +70,13 @@ public: // Constructors //- Construct for given objectRegistry and dictionary - // allow the possibility to load fields from files + // Allow dictionary to be optional + // Allow the possibility to load fields from files IOOutputFilter ( const objectRegistry&, const fileName& dictName = OutputFilter::typeName() + "Dict", + const IOobject::readOption rOpt = IOobject::MUST_READ, const bool loadFromFile = false ); From b42e13583a2e76c05fef7152e46515a0787062c7 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 22 Jul 2008 11:12:40 +0200 Subject: [PATCH 15/30] More cleanup on headers/source for doxygen - it also found things like size_t instead of size_type in fileName class --- .../conversion/plot3dToFoam/plot3dToFoam.C | 3 +- .../db/functionObject/functionObject.H | 3 ++ .../functionObjectList/functionObjectList.H | 3 ++ .../FieldFields/FieldField/FieldField.H | 4 +- .../basic/generic/genericPolyPatch.H | 7 ++-- src/OpenFOAM/primitives/Scalar/doubleFloat.H | 3 -- .../primitives/strings/fileName/fileName.H | 2 +- .../autoHexMesh/shellSurfaces/shellSurfaces.H | 2 +- src/conversion/ensight/part/ensightPart.H | 2 +- .../boundaryMesh/octreeDataFaceList.C | 2 +- .../motionSmoother/motionSmoother.H | 35 ++++++++-------- .../displacementInterpolationFvMotionSolver.H | 2 +- .../ManualInjection/ManualInjection.H | 8 ++-- .../molecule/molecule/molecule.H | 26 ++++++------ .../moleculeCloudBuildCellOccupancy.C | 5 --- .../basic/energyScalingFunction.C | 3 -- .../basic/newEnergyScalingFunction.C | 3 -- .../pairPotential/basic/newPairPotential.C | 3 -- .../pairPotential/basic/pairPotential.C | 3 -- .../pairPotential/derived/azizChen/azizChen.H | 30 +++++++------- .../derived/maitlandSmith/maitlandSmith.H | 40 ++++++++++--------- .../basic/newTetherPotential.C | 3 -- .../directMappedPolyPatch.H | 7 ++-- .../fieldAverage/fieldAverage/fieldAverage.H | 2 +- src/postProcessing/forces/forces/forces.H | 2 +- .../OutputFilterFunctionObject.H | 10 ++++- .../chemkinReader/chemkinLexer.L | 5 +++ .../triSurface/interfaces/STL/readSTLASCII.L | 4 ++ .../dynOneEqEddy/dynOneEqEddy.H | 2 +- .../LienCubicKELowRe/LienCubicKELowRe.H | 2 +- 30 files changed, 118 insertions(+), 108 deletions(-) diff --git a/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C b/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C index f686180195..6e81ff9f0b 100644 --- a/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C +++ b/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C @@ -28,7 +28,8 @@ Description Work in progress! Handles ascii multiblock (and optionally singleBlock) format. By default expects blanking. Use -noBlank if none. - Use -2D if 2D. + Use -2D @a thickness if 2D. + Niklas Nordin has experienced a problem with lefthandedness of the blocks. The code should detect this automatically - see hexBlock::readPoints but if this goes wrong just set the blockHandedness_ variable to 'right' diff --git a/src/OpenFOAM/db/functionObject/functionObject.H b/src/OpenFOAM/db/functionObject/functionObject.H index d729c1c8cb..4761636613 100644 --- a/src/OpenFOAM/db/functionObject/functionObject.H +++ b/src/OpenFOAM/db/functionObject/functionObject.H @@ -28,6 +28,9 @@ Class Description Abstract base-class for Time/database function objects. +See Also + Foam::OutputFilterFunctionObject + SourceFiles functionObject.C diff --git a/src/OpenFOAM/db/functionObjectList/functionObjectList.H b/src/OpenFOAM/db/functionObjectList/functionObjectList.H index 752c6d8a0d..bd71c1578c 100644 --- a/src/OpenFOAM/db/functionObjectList/functionObjectList.H +++ b/src/OpenFOAM/db/functionObjectList/functionObjectList.H @@ -29,6 +29,9 @@ Description List of function objects with execute function which is called for each object. +See Also + Foam::functionObject and Foam::OutputFilterFunctionObject + SourceFiles functionObjectList.C diff --git a/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.H b/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.H index 20b41f17b8..958e2f259b 100644 --- a/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.H +++ b/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::FieldField\ + Foam::FieldField Description Generic field type. @@ -134,7 +134,7 @@ public: ); forAll(*nffPtr, i) - { + { nffPtr->set(i, Field::NewCalculatedType(ff[i]).ptr()); } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/generic/genericPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/generic/genericPolyPatch.H index a5a0614b99..6ab6354a08 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/generic/genericPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/generic/genericPolyPatch.H @@ -23,14 +23,15 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::genericPolyPatch.C + Foam::genericPolyPatch Description Determines a mapping between patch face centres and mesh cell centres and processors they're on. - Note: storage is not optimal. It stores all face centres and cells on - all processors to keep the addressing calculation simple. +Note + Storage is not optimal. It stores all face centres and cells on all + processors to keep the addressing calculation simple. SourceFiles genericPolyPatch.C diff --git a/src/OpenFOAM/primitives/Scalar/doubleFloat.H b/src/OpenFOAM/primitives/Scalar/doubleFloat.H index 58e8f65002..40ccb27279 100644 --- a/src/OpenFOAM/primitives/Scalar/doubleFloat.H +++ b/src/OpenFOAM/primitives/Scalar/doubleFloat.H @@ -22,9 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Typedef - Foam::double and float - \*---------------------------------------------------------------------------*/ #ifndef doubleFloat_H diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.H b/src/OpenFOAM/primitives/strings/fileName/fileName.H index 71cdfbdb46..1ef3839ea5 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.H +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.H @@ -147,7 +147,7 @@ public: wordList components(const char delimiter='/') const; //- Return a component of the path - word component(const size_t, const char delimiter='/') const; + word component(const size_type, const char delimiter='/') const; // Interogation diff --git a/src/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.H b/src/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.H index b996e98e89..0ec93cbeb1 100644 --- a/src/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.H +++ b/src/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - shellSurfaces + Foam::shellSurfaces Description Encapsulates queries for volume refinement ('refine all cells within diff --git a/src/conversion/ensight/part/ensightPart.H b/src/conversion/ensight/part/ensightPart.H index b511c6d095..5df840ea01 100644 --- a/src/conversion/ensight/part/ensightPart.H +++ b/src/conversion/ensight/part/ensightPart.H @@ -137,7 +137,7 @@ protected: ( ensightFile& os, const List& field, - const labelList& idList + const List