From 52c2bfc5198fd4417354e95baf68bebf4c8b77d8 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 11 Jun 2008 15:08:13 +0200 Subject: [PATCH 01/15] fix minor typos --- README | 63 +++++++++---------- src/OpenFOAM/db/dictionary/dictionary.C | 26 ++++---- src/OpenFOAM/db/dictionary/dictionary.H | 28 ++++----- .../db/dictionary/dictionaryTemplates.C | 4 +- 4 files changed, 58 insertions(+), 63 deletions(-) diff --git a/README b/README index e698d955a2..57b80f5d14 100644 --- a/README +++ b/README @@ -29,8 +29,8 @@ 2. System requirements ~~~~~~~~~~~~~~~~~~~~~~ OpenFOAM is developed and tested on Linux, but should work with other - Unix style system. To check your system setup, execute the foamSystemCheck - script in the bin directory of the OpenFOAM installation. If no problems + Unix style systems. To check your system setup, execute the foamSystemCheck + script in the bin/ directory of the OpenFOAM installation. If no problems are reported, proceed to "3. Installation"; otherwise contact your system administrator. @@ -40,7 +40,6 @@ 3. Installation ~~~~~~~~~~~~~~~ - Download and unpack the files in the $HOME/OpenFOAM directory as described in: http://www.OpenFOAM.org/download.html @@ -77,10 +76,9 @@ 3.1. Installation in alternative locations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - OpenFOAM may also be installed in an alternative location. - However, the installation directory must be network available - (eg, NFS) if parallel calculations are planned. + OpenFOAM may also be installed in alternative locations. However, the + installation directory should be network available (e.g., NFS) if + parallel calculations are planned. The environment variable 'FOAM_INST_DIR' can be used to find and source the appropriate resource file. Here is a bash/ksh/sh example: @@ -89,7 +87,7 @@ foamDotFile=$FOAM_INST_DIR/OpenFOAM-/etc/bashrc [ -f $foamDotFile ] && . $foamDotFile - and a csh example: + and a csh/tcsh example: setenv FOAM_INST_DIR /data/app/OpenFOAM foamDotFile=$FOAM_INST_DIR/OpenFOAM-/etc/bashrc @@ -102,9 +100,8 @@ 4. Building from Sources (Optional) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - If you cannot find an appropriate binary pack for your platform, you can - build the complete OpenFOAM from the source-pack. First you will need to + build the complete OpenFOAM from the source-pack. You will first need to compile or obtain a recent version of gcc (we recomend gcc-4.2.?) for your platform, which may be obtained from http://gcc.gnu.org/. @@ -114,29 +111,27 @@ $WM_PROJECT_DIR/etc/settings.csh appropriately and finally update the environment variables as in section 3. - Now go to the top-level source directory $WM_PROJECT_DIR and type - ./Allwmake, which is the name of the top-level build script for building - the whole of OpenFOAM. In principle this will build everything, but - sometimes problems occur with the build order and it is necessary to - update the environment variables and re-execute Allwmake. If you - experience difficulties with building the source-pack or your platform is - not currently supported please contact to - negotiate a support contract and we will do the port and maintain it in + Now go to the top-level source directory $WM_PROJECT_DIR and execute the + top-level build script './Allwmake'. In principle this will build + everything, but if problems occur with the build order it may be necessary + to update the environment variables and re-execute 'Allwmake'. If you + experience difficulties with building the source-pack, or your platform is + not currently supported, please contact to + negotiate a support contract and we will do the port and maintain it for future releases. 5. Testing the installation ~~~~~~~~~~~~~~~~~~~~~~~~~~~ To check your installation setup, execute the 'foamInstallationTest' - script (in the bin directory of the OpenFOAM installation). If no problems - are reported, proceed to getting started with OpenFOAM; otherwise, go back - and check you have installed the software correctly and/or contact your - system administrator. + script (in the bin/ directory of the OpenFOAM installation). If no + problems are reported, proceed to getting started with OpenFOAM; + otherwise, go back and check you have installed the software correctly + and/or contact your system administrator. 6. Getting Started ~~~~~~~~~~~~~~~~~~ - Create a project directory within the $HOME/OpenFOAM directory named - (e.g. 'chris-1.5' for user chris and OpenFOAM version 1.5) and create a directory named 'run' within it, e.g. by typing: @@ -144,7 +139,7 @@ mkdir -p $HOME/OpenFOAM/${USER}-${WM_PROJECT_VERSION}/run Copy the 'tutorial' examples directory in the OpenFOAM distribution to the - 'run' directory. If OpenFOAM environment variables are set correctly, + 'run' directory. If the OpenFOAM environment variables are set correctly, then the following command will be correct: cp -r $WM_PROJECT_DIR/tutorials $HOME/OpenFOAM/${USER}-${WM_PROJECT_VERSION}/run @@ -158,27 +153,27 @@ 7. Documentation ~~~~~~~~~~~~~~~~ - http://www.OpenFOAM.org/doc + http://www.OpenFOAM.org/doc 8. Help ~~~~~~~ - http://www.OpenFOAM.org - http://www.OpenFOAM.org/discussion.html + http://www.OpenFOAM.org + http://www.OpenFOAM.org/discussion.html 9. Reporting Bugs in OpenFOAM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - http://www.OpenFOAM.org/bugs.html + http://www.OpenFOAM.org/bugs.html A. Running OpenFOAM in 32-bit mode on 64-bit machines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Those users with an installation of Linux on a 64-bit machine may install - either or both of the 32-bit version of OpenFOAM (linux) or the 64-bit - version of FOAM (linux64) with 64-bit being the default mode. In order to - set up the user to run in 32-bit mode, the user must set the environment - variable $WM_32 (to anything, e.g. "on") before sourcing the etc/bashrc - (or etc/cshrc) file. Unsetting $WM_32 and sourcing the bashrc file will + Linux users with a 64-bit machine may install either the OpenFOAM 32-bit + version (linux) or the OpenFOAM 64-bit version (linux64), or both. + The 64-bit is the default mode on a 64-bit machine. To use an installed + 32-bit version, the user must set the environment variable $WM_32 (to + anything, e.g. "on") before sourcing the etc/bashrc (or etc/cshrc) file. + Unsetting WM_32 and re-sourcing the etc/bashrc (or etc/cshrc) file will set up the user to run in 64-bit mode. diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index 8dd2263574..f72c1b532d 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -195,15 +195,15 @@ Foam::label Foam::dictionary::endLineNumber() const } -bool Foam::dictionary::found(const word& keyword, bool recusive) const +bool Foam::dictionary::found(const word& keyword, bool recursive) const { if (hashedEntries_.found(keyword)) { return true; } - else if (recusive && &parent_ != &dictionary::null) + else if (recursive && &parent_ != &dictionary::null) { - return parent_.found(keyword, recusive); + return parent_.found(keyword, recursive); } else { @@ -215,16 +215,16 @@ bool Foam::dictionary::found(const word& keyword, bool recusive) const const Foam::entry* Foam::dictionary::lookupEntryPtr ( const word& keyword, - bool recusive + bool recursive ) const { HashTable::const_iterator iter = hashedEntries_.find(keyword); if (iter == hashedEntries_.end()) { - if (recusive && &parent_ != &dictionary::null) + if (recursive && &parent_ != &dictionary::null) { - return parent_.lookupEntryPtr(keyword, recusive); + return parent_.lookupEntryPtr(keyword, recursive); } else { @@ -239,19 +239,19 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr Foam::entry* Foam::dictionary::lookupEntryPtr ( const word& keyword, - bool recusive + bool recursive ) { HashTable::iterator iter = hashedEntries_.find(keyword); if (iter == hashedEntries_.end()) { - if (recusive && &parent_ != &dictionary::null) + if (recursive && &parent_ != &dictionary::null) { return const_cast(parent_).lookupEntryPtr ( keyword, - recusive + recursive ); } else @@ -267,10 +267,10 @@ Foam::entry* Foam::dictionary::lookupEntryPtr const Foam::entry& Foam::dictionary::lookupEntry ( const word& keyword, - bool recusive + bool recursive ) const { - const entry* ePtr = lookupEntryPtr(keyword, recusive); + const entry* ePtr = lookupEntryPtr(keyword, recursive); if (ePtr == NULL) { @@ -291,10 +291,10 @@ const Foam::entry& Foam::dictionary::lookupEntry Foam::ITstream& Foam::dictionary::lookup ( const word& keyword, - bool recusive + bool recursive ) const { - return lookupEntry(keyword, recusive).stream(); + return lookupEntry(keyword, recursive).stream(); } diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index 93fc495d59..a3a21841cb 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -31,8 +31,8 @@ Description The dictionary class is the base class for IOdictionary. It serves the purpose of a bootstrap dictionary for the objectRegistry - data dictionaries, since unlike the IOdictionary class, it does not use a - objectRegistry itself to work. + data dictionaries, since unlike the IOdictionary class, it does not use + a objectRegistry itself to work. SourceFiles dictionary.C @@ -171,31 +171,31 @@ public: // Search and lookup //- Search dictionary for given keyword - // If recusive search parent dictionaries - bool found(const word& keyword, bool recusive=false) const; + // If recursive search parent dictionaries + bool found(const word& keyword, bool recursive=false) const; //- Find and return an entry data stream pointer if present // otherwise return NULL. - // If recusive search parent dictionaries - const entry* lookupEntryPtr(const word&, bool recusive=false) const; + // If recursive search parent dictionaries + const entry* lookupEntryPtr(const word&, bool recursive=false) const; //- Find and return an entry data stream pointer for manipulation // if present otherwise return NULL. - // If recusive search parent dictionaries - entry* lookupEntryPtr(const word&, bool recusive=false); + // If recursive search parent dictionaries + entry* lookupEntryPtr(const word&, bool recursive=false); //- Find and return an entry data stream if present otherwise error. - // If recusive search parent dictionaries - const entry& lookupEntry(const word&, bool recusive=false) const; + // If recursive search parent dictionaries + const entry& lookupEntry(const word&, bool recursive=false) const; //- Find and return an entry data stream - // If recusive search parent dictionaries - ITstream& lookup(const word&, bool recusive=false) const; + // If recursive search parent dictionaries + ITstream& lookup(const word&, bool recursive=false) const; //- Find and return a T, if not found return the given default value - // If recusive search parent dictionaries + // If recursive search parent dictionaries template - T lookupOrDefault(const word&, const T&, bool recusive=false) const; + T lookupOrDefault(const word&, const T&, bool recursive=false) const; //- Check if entry is a sub-dictionary bool isDict(const word&) const; diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C index 73b97fa664..4a0f54d762 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C +++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C @@ -34,10 +34,10 @@ T Foam::dictionary::lookupOrDefault ( const word& keyword, const T& deft, - bool recusive + bool recursive ) const { - const entry* ePtr = lookupEntryPtr(keyword, recusive); + const entry* ePtr = lookupEntryPtr(keyword, recursive); if (ePtr == NULL) { From 64d00dc22bf1aa6de86c422e3c274c932579956e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 13 Jun 2008 13:16:02 +0200 Subject: [PATCH 02/15] Doxygen filter changes * allow doxygen to process applications/**.H * use @cond/@endcond to suppress documenting classes/variables in applications/ - allows some access from applications to libraries - connection between application and local includes is still a bit weak, but is possible via the dirs.html navigation. --- bin/doxyFilt | 18 ++-- bin/{doxyAwkTop => tools/doxyFilt-ignore.awk} | 42 +++------- bin/tools/doxyFilt-top.awk | 82 +++++++++++++++++++ bin/{doxyAwk => tools/doxyFilt.awk} | 34 ++++---- bin/{doxyScr => tools/doxyFilt.sed} | 11 +++ doc/Doxygen/Doxyfile | 4 +- 6 files changed, 135 insertions(+), 56 deletions(-) rename bin/{doxyAwkTop => tools/doxyFilt-ignore.awk} (70%) create mode 100644 bin/tools/doxyFilt-top.awk rename bin/{doxyAwk => tools/doxyFilt.awk} (77%) rename bin/{doxyScr => tools/doxyFilt.sed} (81%) diff --git a/bin/doxyFilt b/bin/doxyFilt index c8b97232fd..8b56c6cf89 100755 --- a/bin/doxyFilt +++ b/bin/doxyFilt @@ -29,9 +29,12 @@ # Description # pass-through filter for doxygen # -# Filter has special treatment for applications/{solvers,utilities}/*.C -# - only keep the first comment block of the C source file -# - the corresponding H files are ignored in Doxyfile EXCLUDE_PATTERNS +# Special treatment for applications/{solvers,utilities}/*.C +# - only keep the first comment block of the C source file +# use @cond / @endcond to suppress documenting all classes/variables +# +# Special treatment for applications/{solvers,utilities}/*.H +# - use @cond / @endcond to suppress documenting all classes/variables #------------------------------------------------------------------------------ if [ "$#" -gt 0 ] @@ -41,16 +44,19 @@ then dirName=${filePath%/[^/]*} fileName=${filePath##*/} - awkScript=$WM_PROJECT_DIR/bin/doxyAwk + awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilt.awk case "$1" in */applications/solvers/*.C | */applications/utilities/*.C ) - awkScript=$WM_PROJECT_DIR/bin/doxyAwkTop + awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilt-top.awk + ;; + */applications/solvers/*.H | */applications/utilities/*.H ) + awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilt-ignore.awk ;; esac awk -f $awkScript $1 | \ - sed -f $WM_PROJECT_DIR/bin/doxyScr \ + sed -f $WM_PROJECT_DIR/bin/tools/doxyFilt.sed \ -e s@%filePath%@$filePath@g \ -e s@%fileName%@$fileName@g \ -e s@%dirName%@$dirName@g diff --git a/bin/doxyAwkTop b/bin/tools/doxyFilt-ignore.awk similarity index 70% rename from bin/doxyAwkTop rename to bin/tools/doxyFilt-ignore.awk index da1c4cc164..55d5800d19 100644 --- a/bin/doxyAwkTop +++ b/bin/tools/doxyFilt-ignore.awk @@ -4,7 +4,7 @@ # \\ / O peration | # \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. # \\/ M anipulation | -# ------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- # License # This file is part of OpenFOAM. # @@ -23,41 +23,23 @@ # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # Script -# doxyAwkTop +# doxyFilt-ignore.awk # # Description -# Output only the first /* ... */ comment section found in the file -# - This is useful for application files in which only the first -# block documents the application itself and all other files simply -# pollute our documentation +# - Prefix file contents with doxygen @file tag and %filePath% tag +# that will be changed in a subsequent sed script +# - Surround the contents of an entire file with @cond / @endcond +# to skip documenting all classes/variables # # ----------------------------------------------------------------------------- BEGIN { - state = 0 + print "//! @file %filePath%" + print "//! @cond OpenFOAMIgnoreAppDoxygen" } -# a '/*' at the beginning of a line starts a block -/^ *\/\*/ { - state++ +{ print } + +END { + print "//! @endcond OpenFOAMIgnoreAppDoxygen" } - -# a '*/' ends the block -/\*\// { - if (state == 1) - { - print - } - state = 2 - next -} - -# end block -{ - if (state == 1) - { - print - } - next -} - # ----------------------------------------------------------------------------- diff --git a/bin/tools/doxyFilt-top.awk b/bin/tools/doxyFilt-top.awk new file mode 100644 index 0000000000..b37630b0d3 --- /dev/null +++ b/bin/tools/doxyFilt-top.awk @@ -0,0 +1,82 @@ +# ----------------------------------------------------------------------------- +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 1991-2007 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 +# doxyFilt-top.awk +# +# Description +# Only output the first /* ... */ comment section found in the file +# Use @cond / @endcond to suppress documenting all classes/variables +# - This is useful for application files in which only the first +# block documents the application itself. +# +# ----------------------------------------------------------------------------- +BEGIN { + state = 0 +} + +# a '/*' at the beginning of a line starts a comment block +/^ *\/\*/ { + state++ +} + +# check first line +# either started with a comment or skip documentation for the whole file +FNR == 1 { + if (!state) + { + print "//! @cond OpenFOAMIgnoreAppDoxygen" + state = 2 + } +} + +# a '*/' ends the comment block +# skip documentation for rest of the file +/\*\// { + if (state == 1) + { + print + print "//! @cond OpenFOAMIgnoreAppDoxygen" + } + state = 2 + next +} + +# print everything within the first comment block +{ + if (state) + { + print + } + next +} + +END { + if (state == 2) + { + print "//! @endcond OpenFOAMIgnoreAppDoxygen" + } +} + +# ----------------------------------------------------------------------------- diff --git a/bin/doxyAwk b/bin/tools/doxyFilt.awk similarity index 77% rename from bin/doxyAwk rename to bin/tools/doxyFilt.awk index c09b058db6..25c323c6eb 100644 --- a/bin/doxyAwk +++ b/bin/tools/doxyFilt.awk @@ -4,7 +4,7 @@ # \\ / O peration | # \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. # \\/ M anipulation | -# ------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- # License # This file is part of OpenFOAM. # @@ -23,23 +23,23 @@ # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # Script -# doxyAwk +# doxyFilt.awk # # Description # Converts cocoon style sentinel strings into doxygen style strings # -# - assume the comment strings are formatted as follows -# //- general description -# // more information -# // and even more information -# This should be re-formatted as the following -# //! general description -# /*! -# more information -# and even more information -# */ -# The intermediate "/*! ... */" block is left-justified to handle -# possible verbatim text +# Assumes comment strings are formatted as follows +# //- general description +# // more information +# // and even more information +# This should be re-formatted as the following +# //! general description +# /*! +# more information +# and even more information +# */ +# The intermediate "/*! ... */" block is left-justified to handle +# possible verbatim text # ----------------------------------------------------------------------------- BEGIN { @@ -55,14 +55,14 @@ BEGIN { /^ *\/\// { - # start block + # start comment block if (state == 1) { printf "/*!\n" state = 2 } - # inside block + # inside comment block if (state == 2) { if (!sub(/^ *\/\/ /, "")) @@ -77,7 +77,7 @@ BEGIN { { - # end block + # end comment block if (state == 2) { printf "*/\n" diff --git a/bin/doxyScr b/bin/tools/doxyFilt.sed similarity index 81% rename from bin/doxyScr rename to bin/tools/doxyFilt.sed index da9dc8c8d9..5b92b42455 100644 --- a/bin/doxyScr +++ b/bin/tools/doxyFilt.sed @@ -1,3 +1,12 @@ +# ----------------------------------------------------------------------------- +# Script +# doxyFilt.sed +# +# Description +# Transform human-readable tags such as 'Description' into the Doxygen +# equivalent +# ----------------------------------------------------------------------------- + /^License/,/\*\//{ /^License/,/MA 0211.-130. USA/{ s?^License.*?\*\/\ @@ -141,3 +150,5 @@ s? *\([a-zA-Z0-9]*\.[a-zA-Z]*\)?
  • \1
  • ? s/.*\*\//\*\// } + +# ----------------------------------------------------------------------------- diff --git a/doc/Doxygen/Doxyfile b/doc/Doxygen/Doxyfile index cce0feda75..13c36d9d30 100644 --- a/doc/Doxygen/Doxyfile +++ b/doc/Doxygen/Doxyfile @@ -522,9 +522,7 @@ EXCLUDE_SYMLINKS = NO # for example use the pattern */test/* EXCLUDE_PATTERNS = */lnInclude/* \ - */t/* \ - */applications/utilities/*.H \ - */applications/solvers/*.H + */t/* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names From 1e8d4b2a82ae664963ca738c84bf4237f84943cf Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 13 Jun 2008 10:43:31 +0200 Subject: [PATCH 03/15] dictionary functionEntries cleanup * added '#remove' function * changed insert() method name to more general execute() * using #inputMode or #remove within a primitiveEntry now provokes an error * adjusted the dictionaryTest accordingly --- .../test/dictionary/calcEntry/calcEntry.C | 21 +--- .../test/dictionary/calcEntry/calcEntry.H | 7 +- applications/test/dictionary/testDict | 59 +++++++-- applications/test/dictionary/testDict2 | 30 +++++ applications/test/dictionary/value | 3 +- src/OpenFOAM/Make/files | 1 + src/OpenFOAM/db/dictionary/entry/entryIO.C | 16 ++- .../functionEntry/functionEntry.C | 119 +++++++++--------- .../functionEntry/functionEntry.H | 52 ++++---- .../includeEntry/includeEntry.C | 68 +++++----- .../includeEntry/includeEntry.H | 19 +-- .../inputModeEntry/inputModeEntry.C | 38 ++---- .../inputModeEntry/inputModeEntry.H | 16 ++- .../functionEntries/removeEntry/removeEntry.C | 88 +++++++++++++ .../functionEntries/removeEntry/removeEntry.H | 100 +++++++++++++++ .../primitiveEntry/primitiveEntryIO.C | 2 +- 16 files changed, 432 insertions(+), 207 deletions(-) create mode 100644 applications/test/dictionary/testDict2 create mode 100644 src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C create mode 100644 src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H diff --git a/applications/test/dictionary/calcEntry/calcEntry.C b/applications/test/dictionary/calcEntry/calcEntry.C index 6fb009456b..d148f5d829 100644 --- a/applications/test/dictionary/calcEntry/calcEntry.C +++ b/applications/test/dictionary/calcEntry/calcEntry.C @@ -42,24 +42,17 @@ namespace functionEntries ( functionEntry, calcEntry, - insert, + execute, primitiveEntryIstream ); - addToMemberFunctionSelectionTable - ( - functionEntry, - calcEntry, - insert, - dictionaryIstream - ); } } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -bool Foam::functionEntries::calcEntry::insert +bool Foam::functionEntries::calcEntry::execute ( const dictionary& parentDict, primitiveEntry& entry, @@ -75,14 +68,4 @@ bool Foam::functionEntries::calcEntry::insert } -bool Foam::functionEntries::calcEntry::insert -( - dictionary& parentDict, - Istream& is -) -{ - return true; -} - - // ************************************************************************* // diff --git a/applications/test/dictionary/calcEntry/calcEntry.H b/applications/test/dictionary/calcEntry/calcEntry.H index c4c725dfb0..157bdc6d02 100644 --- a/applications/test/dictionary/calcEntry/calcEntry.H +++ b/applications/test/dictionary/calcEntry/calcEntry.H @@ -69,18 +69,13 @@ public: // Member Functions - static bool insert + static bool execute ( const dictionary& parentDict, primitiveEntry& entry, Istream& is ); - static bool insert - ( - dictionary& parentDict, - Istream& is - ); }; diff --git a/applications/test/dictionary/testDict b/applications/test/dictionary/testDict index 70f6885e7e..9bd58c58ae 100644 --- a/applications/test/dictionary/testDict +++ b/applications/test/dictionary/testDict @@ -1,17 +1,19 @@ +/*-------------------------------*- C++ -*---------------------------------*\ +| ========= | +| \\ / OpenFOAM | +| \\ / | +| \\ / The Open Source CFD Toolbox | +| \\/ http://www.OpenFOAM.org | +\*-------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; - - root ""; - case ""; - instance ""; - local ""; - class dictionary; object testDict; } - +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#inputMode merge dimensions [ 0 2 -2 0 0 0 0 ]; internalField uniform 1; @@ -29,7 +31,6 @@ inactive type zeroGradient; } - boundaryField { Default_Boundary_Region @@ -40,6 +41,12 @@ boundaryField inlet_1 { $active } inlet_2 { $inactive } inlet_3 { $inactive } + inlet_4 { $inactive } + inlet_5 "a primitiveEntry is squashed by a directory entry"; + inlet_5 { $inactive } + inlet_6 { $inactive } + inlet_7 { $inactive } + inlet_8 { $inactive } #include "testDictInc" @@ -48,8 +55,44 @@ boundaryField type inletOutlet; inletValue $internalField; value #include "value"; + // error #remove self; x 5; y 6; another #calc{x $x; y $y;}; } + + // this should have no effect + #remove inactive + + inlet_7 { $active } + #inputMode overwrite + inlet_8 { $active } } + +// NB: the inputMode has a global scope +#inputMode merge +#include "testDict2" + +foo +{ + $active +} + +bar +{ + $active +} + +baz +{ + $active +} + + +// this should work +#remove active + +// this should work too +#remove ( bar baz ) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/test/dictionary/testDict2 b/applications/test/dictionary/testDict2 new file mode 100644 index 0000000000..6c55ab384c --- /dev/null +++ b/applications/test/dictionary/testDict2 @@ -0,0 +1,30 @@ +/*-------------------------------*- C++ -*---------------------------------*\ +| ========= | +| \\ / OpenFOAM | +| \\ / | +| \\ / The Open Source CFD Toolbox | +| \\/ http://www.OpenFOAM.org | +\*-------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object testDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +boundaryField +{ + Default_Boundary_Region + { + value $internalField; + note "actually a noslip wall"; + } + + inlet_3 "a primitiveEntry squashes directory entry"; +} + +#inputMode overwrite +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/test/dictionary/value b/applications/test/dictionary/value index 196f9d3d0a..6a860dc353 100644 --- a/applications/test/dictionary/value +++ b/applications/test/dictionary/value @@ -1 +1,2 @@ -uniform 2 +// the trailing ';' shouldn't actually be there, but shouldn't cause problems +uniform 2; diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index c9be7642ba..7b137dedc0 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -122,6 +122,7 @@ functionEntries = $(dictionary)/functionEntries $(functionEntries)/functionEntry/functionEntry.C $(functionEntries)/includeEntry/includeEntry.C $(functionEntries)/inputModeEntry/inputModeEntry.C +$(functionEntries)/removeEntry/removeEntry.C IOdictionary = db/IOobjects/IOdictionary $(IOdictionary)/IOdictionary.C diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C index 1b2b2016c9..84efb2bfc2 100644 --- a/src/OpenFOAM/db/dictionary/entry/entryIO.C +++ b/src/OpenFOAM/db/dictionary/entry/entryIO.C @@ -96,7 +96,7 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is) if (keyword[0] == '#') // ... Function entry { word functionName = keyword(1, keyword.size()-1); - return functionEntry::insert(functionName, parentDict, is); + return functionEntry::execute(functionName, parentDict, is); } else if (keyword[0] == '$') // ... Substitution entry { @@ -105,7 +105,7 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is) } else if (keyword == "include") // ... For backward compatibility { - return functionEntries::includeEntry::insert(parentDict, is); + return functionEntries::includeEntry::execute(parentDict, is); } else // ... Data entries { @@ -114,12 +114,18 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is) // Deal with duplicate entries bool mergeEntry = false; - if (parentDict.found(keyword)) + + entry* existingPtr = parentDict.lookupEntryPtr(keyword); + if (existingPtr) { if (functionEntries::inputModeEntry::overwrite()) { - // silently drop previous entries - parentDict.remove(keyword); + // clear dictionary so merge acts like overwrite + if (existingPtr->isDict()) + { + existingPtr->dict().clear(); + } + mergeEntry = true; } else if (functionEntries::inputModeEntry::merge()) { diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C index 7e53591c64..3d4b037dfc 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C @@ -33,22 +33,66 @@ namespace Foam defineMemberFunctionSelectionTable ( functionEntry, - insert, - primitiveEntryIstream + execute, + dictionaryIstream ); defineMemberFunctionSelectionTable ( functionEntry, - insert, - dictionaryIstream + execute, + primitiveEntryIstream ); } // * * * * * * * * * * * * Member Function Selectors * * * * * * * * * * * * // -bool Foam::functionEntry::insert +bool Foam::functionEntry::execute +( + const word& functionName, + dictionary& parentDict, + Istream& is +) +{ + is.fatalCheck + ( + "functionEntry::execute" + "(const word& functionName, dictionary& parentDict, Istream& is)" + ); + + if (!executedictionaryIstreamMemberFunctionTablePtr_) + { + cerr<<"functionEntry::execute" + << "(const word&, dictionary&, Istream&)" + << " not yet initialized, function = " + << functionName.c_str() << std::endl; + + // Return true to keep reading + return true; + } + + executedictionaryIstreamMemberFunctionTable::iterator mfIter = + executedictionaryIstreamMemberFunctionTablePtr_->find(functionName); + + if (mfIter == executedictionaryIstreamMemberFunctionTablePtr_->end()) + { + FatalErrorIn + ( + "functionEntry::execute" + "(const word& functionName, dictionary& parentDict, Istream&)" + ) << "Unknown functionEntry " << functionName + << endl << endl + << "Valid functionEntries are :" << endl + << executedictionaryIstreamMemberFunctionTablePtr_->toc() + << exit(FatalError); + } + + return mfIter()(parentDict, is); +} + + +bool Foam::functionEntry::execute ( const word& functionName, const dictionary& parentDict, @@ -58,14 +102,14 @@ bool Foam::functionEntry::insert { is.fatalCheck ( - "functionEntry::insert" + "functionEntry::execute" "(const word& functionName, const dictionary& parentDict, " - "primitiveEntry& entry, Istream& is)" + "primitiveEntry&, Istream&)" ); - if (!insertprimitiveEntryIstreamMemberFunctionTablePtr_) + if (!executeprimitiveEntryIstreamMemberFunctionTablePtr_) { - cerr<<"functionEntry::insert" + cerr<<"functionEntry::execute" << "(const word&, dictionary&, primitiveEntry&, Istream&)" << " not yet initialized, function = " << functionName.c_str() << std::endl; @@ -74,69 +118,24 @@ bool Foam::functionEntry::insert return true; } - insertprimitiveEntryIstreamMemberFunctionTable::iterator mfIter = - insertprimitiveEntryIstreamMemberFunctionTablePtr_->find(functionName); + executeprimitiveEntryIstreamMemberFunctionTable::iterator mfIter = + executeprimitiveEntryIstreamMemberFunctionTablePtr_->find(functionName); - if (mfIter == insertprimitiveEntryIstreamMemberFunctionTablePtr_->end()) + if (mfIter == executeprimitiveEntryIstreamMemberFunctionTablePtr_->end()) { FatalErrorIn ( - "functionEntry::insert" + "functionEntry::execute" "(const word& functionName, const dictionary& parentDict, " - "primitiveEntry& entry, Istream& is)" + "primitiveEntry&, Istream&)" ) << "Unknown functionEntry " << functionName << endl << endl << "Valid functionEntries are :" << endl - << insertprimitiveEntryIstreamMemberFunctionTablePtr_->toc() + << executeprimitiveEntryIstreamMemberFunctionTablePtr_->toc() << exit(FatalError); } return mfIter()(parentDict, entry, is); } - -bool Foam::functionEntry::insert -( - const word& functionName, - dictionary& parentDict, - Istream& is -) -{ - is.fatalCheck - ( - "functionEntry::insert" - "(const word& functionName, dictionary& parentDict, Istream& is)" - ); - - if (!insertdictionaryIstreamMemberFunctionTablePtr_) - { - cerr<<"functionEntry::insert" - << "(const word&, dictionary&, Istream&)" - << " not yet initialized, function = " - << functionName.c_str() << std::endl; - - // Return true to keep reading - return true; - } - - insertdictionaryIstreamMemberFunctionTable::iterator mfIter = - insertdictionaryIstreamMemberFunctionTablePtr_->find(functionName); - - if (mfIter == insertdictionaryIstreamMemberFunctionTablePtr_->end()) - { - FatalErrorIn - ( - "functionEntry::insert" - "(const word& functionName, dictionary& parentDict, Istream& is)" - ) << "Unknown functionEntry " << functionName - << endl << endl - << "Valid functionEntries are :" << endl - << insertdictionaryIstreamMemberFunctionTablePtr_->toc() - << exit(FatalError); - } - - return mfIter()(parentDict, is); -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H index aa579420d2..20f1d9b247 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H @@ -33,13 +33,10 @@ Class Foam::functionEntry Description - A function entry causes entries to be added/manipulated on the specified + A functionEntry causes entries to be added/manipulated on the specified dictionary given an input stream. - In dictionaries, a @c \# sigil is typically used for a functionEntry. - -See Also - functionEntries::includeEntry and functionEntries::inputModeEntry + In dictionaries, a @c '\#' sigil is typically used for a functionEntry. SourceFiles functionEntry.C @@ -84,7 +81,28 @@ public: ( bool, functionEntry, - insert, + execute, + dictionaryIstream, + ( + dictionary& parentDict, + Istream& is + ), + (parentDict, is) + ); + + //- Execute the functionEntry in a sub-dict context + static bool execute + ( + const word& functionName, + dictionary& parentDict, + Istream& is + ); + + declareMemberFunctionSelectionTable + ( + bool, + functionEntry, + execute, primitiveEntryIstream, ( const dictionary& parentDict, @@ -94,7 +112,8 @@ public: (parentDict, entry, is) ); - static bool insert + //- Execute the functionEntry in a primitiveEntry context + static bool execute ( const word& functionName, const dictionary& parentDict, @@ -103,25 +122,6 @@ public: ); - declareMemberFunctionSelectionTable - ( - bool, - functionEntry, - insert, - dictionaryIstream, - ( - dictionary& parentDict, - Istream& is - ), - (parentDict, is) - ); - - static bool insert - ( - const word& functionName, - dictionary& parentDict, - Istream& is - ); }; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C index 81a8c0b23f..60af24c589 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C @@ -48,16 +48,16 @@ namespace functionEntries ( functionEntry, includeEntry, - insert, - primitiveEntryIstream + execute, + dictionaryIstream ); addToMemberFunctionSelectionTable ( functionEntry, includeEntry, - insert, - dictionaryIstream + execute, + primitiveEntryIstream ); } } @@ -82,7 +82,35 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName } -bool Foam::functionEntries::includeEntry::insert +bool Foam::functionEntries::includeEntry::execute +( + dictionary& parentDict, + Istream& is +) +{ + IFstream fileStream(includeFileName(is)); + + if (fileStream) + { + parentDict.read(fileStream); + return true; + } + else + { + FatalIOErrorIn + ( + "functionEntries::includeEntry::includeEntry" + "(dictionary& parentDict,Istream& is)", + is + ) << "Cannot open include file " << fileStream.name() + << " while reading dictionary " << parentDict.name() + << exit(FatalIOError); + + return false; + } +} + +bool Foam::functionEntries::includeEntry::execute ( const dictionary& parentDict, primitiveEntry& entry, @@ -111,34 +139,4 @@ bool Foam::functionEntries::includeEntry::insert } } - -bool Foam::functionEntries::includeEntry::insert -( - dictionary& parentDict, - Istream& is -) -{ - IFstream fileStream(includeFileName(is)); - - if (fileStream) - { - parentDict.read(fileStream); - return true; - } - else - { - FatalIOErrorIn - ( - "functionEntries::includeEntry::includeEntry" - "(dictionary& parentDict,Istream& is)", - is - ) << "Cannot open include file " << fileStream.name() - << " while reading dictionary " << parentDict.name() - << exit(FatalIOError); - - return false; - } -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H index dfd6de82d7..00e04d60ca 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H @@ -29,9 +29,9 @@ Description Specify an include file when reading dictionaries, expects a single string to follow. - An example of @c \#include directive: + An example of the @c \#include directive: @verbatim - \#include "includefile" + #include "includeFile" @endverbatim The usual expansion of environment variables and other constructs (eg, @@ -85,18 +85,21 @@ public: // Member Functions - static bool insert + //- Execute the functionEntry in a sub-dict context + static bool execute + ( + dictionary& parentDict, + Istream& is + ); + + //- Execute the functionEntry in a primitiveEntry context + static bool execute ( const dictionary& parentDict, primitiveEntry& entry, Istream& is ); - static bool insert - ( - dictionary& parentDict, - Istream& is - ); }; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C index 27b1e78f5e..4360ee9ec2 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C @@ -47,15 +47,7 @@ namespace functionEntries ( functionEntry, inputModeEntry, - insert, - primitiveEntryIstream - ); - - addToMemberFunctionSelectionTable - ( - functionEntry, - inputModeEntry, - insert, + execute, dictionaryIstream ); } @@ -63,7 +55,7 @@ namespace functionEntries // * * * * * * * * * * * * * * * * Private Data * * * * * * * * * * * * * * // -Foam::label Foam::functionEntries::inputModeEntry::inputMode_ = imError; +Foam::label Foam::functionEntries::inputModeEntry::mode_ = imError; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -74,15 +66,15 @@ void Foam::functionEntries::inputModeEntry::setMode(Istream& is) word mode(is); if (mode == "merge") { - inputMode_ = imMerge; + mode_ = imMerge; } else if (mode == "overwrite") { - inputMode_ = imOverwrite; + mode_ = imOverwrite; } else if (mode == "error" || mode == "default") { - inputMode_ = imError; + mode_ = imError; } else { @@ -95,19 +87,7 @@ void Foam::functionEntries::inputModeEntry::setMode(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -bool Foam::functionEntries::inputModeEntry::insert -( - const dictionary& parentDict, - primitiveEntry& entry, - Istream& is -) -{ - setMode(is); - return true; -} - - -bool Foam::functionEntries::inputModeEntry::insert +bool Foam::functionEntries::inputModeEntry::execute ( dictionary& parentDict, Istream& is @@ -120,13 +100,13 @@ bool Foam::functionEntries::inputModeEntry::insert void Foam::functionEntries::inputModeEntry::clear() { - inputMode_ = imError; + mode_ = imError; } bool Foam::functionEntries::inputModeEntry::merge() { - if (inputMode_ & imMerge) + if (mode_ & imMerge) { return true; } @@ -139,7 +119,7 @@ bool Foam::functionEntries::inputModeEntry::merge() bool Foam::functionEntries::inputModeEntry::overwrite() { - if (inputMode_ & imOverwrite) + if (mode_ & imOverwrite) { return true; } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H index 10a3761655..072465341d 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H @@ -74,11 +74,12 @@ class inputModeEntry }; //- current input mode - static label inputMode_; + static label mode_; // Private Member Functions + //- Read the mode as a word and set enum appropriately static void setMode(Istream&); //- Disallow default bitwise copy construct @@ -96,23 +97,20 @@ public: // Member Functions - static bool insert - ( - const dictionary& parentDict, - primitiveEntry&, - Istream& - ); - - static bool insert + //- Execute the functionEntry in a sub-dict context + static bool execute ( dictionary& parentDict, Istream& ); + //- Reset the inputMode to 'default' static void clear(); + //- Return true if the inputMode is 'merge' static bool merge(); + //- Return true if the inputMode is 'overwrite' static bool overwrite(); }; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C new file mode 100644 index 0000000000..f6b1becdca --- /dev/null +++ b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C @@ -0,0 +1,88 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 + +\*---------------------------------------------------------------------------*/ + +#include "removeEntry.H" +#include "dictionary.H" +#include "IStringStream.H" +#include "OStringStream.H" +#include "addToMemberFunctionSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +const Foam::word Foam::functionEntries::removeEntry::typeName +( + Foam::functionEntries::removeEntry::typeName_() +); + +// Don't lookup the debug switch here as the debug switch dictionary +// might include removeEntry +int Foam::functionEntries::removeEntry::debug(0); + +namespace Foam +{ +namespace functionEntries +{ + addToMemberFunctionSelectionTable + ( + functionEntry, + removeEntry, + execute, + dictionaryIstream + ); +} +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionEntries::removeEntry::execute +( + dictionary& parentDict, + Istream& is +) +{ + token currToken(is); + is.putBack(currToken); + + if (currToken == token::BEGIN_LIST) + { + wordList keys(is); + + forAll(keys, keyI) + { + parentDict.remove(keys[keyI]); + } + } + else + { + word key(is); + parentDict.remove(key); + } + + return true; +} + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H new file mode 100644 index 0000000000..06c409d299 --- /dev/null +++ b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H @@ -0,0 +1,100 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 + +Class + Foam::functionEntries::removeEntry + +Description + Remove a dictionary entry. + + The @c \#remove directive takes a word or a list of words. For example, + @verbatim + #remove entry0 + #remove ( entry1 entry2 entry3 ) + @endverbatim + + The removable only occurs in the current context. + Removing sub-entries or parent entries is not supported. + +SourceFiles + removeEntry.C + +\*---------------------------------------------------------------------------*/ + +#ifndef removeEntry_H +#define removeEntry_H + +#include "functionEntry.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionEntries +{ + +/*---------------------------------------------------------------------------*\ + Class removeEntry Declaration +\*---------------------------------------------------------------------------*/ + +class removeEntry +: + public functionEntry +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + removeEntry(const removeEntry&); + + //- Disallow default bitwise assignment + void operator=(const removeEntry&); + + +public: + + //- Runtime type information + TypeName("remove"); + + + // Member Functions + + //- Execute the functionEntry in a sub-dict context + static bool execute + ( + dictionary& parentDict, + Istream& is + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionEntries +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C index 8c5d0dd9c7..511b53117b 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C @@ -115,7 +115,7 @@ bool Foam::primitiveEntry::expandFunction ) { word functionName = keyword(1, keyword.size()-1); - return functionEntry::insert(functionName, parentDict, *this, is); + return functionEntry::execute(functionName, parentDict, *this, is); } From 92cd94ac669b0de75b8f8b6c041c24b9069950a2 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 13 Jun 2008 14:40:46 +0200 Subject: [PATCH 04/15] Reworked dictionary code : * finally removed #ifdef's with old merge method * use autoPtr::ptr() instead of autoPtr::() to reduce cloning * eliminated a few add() methods that are covered by the templated form * added a 'set()' method that forces overwrite - symmetric with HashTable --- src/OpenFOAM/db/dictionary/dictionary.C | 253 ++++++++---------- src/OpenFOAM/db/dictionary/dictionary.H | 73 +++-- .../db/dictionary/dictionaryTemplates.C | 22 +- .../inputModeEntry/inputModeEntry.C | 1 + 4 files changed, 178 insertions(+), 171 deletions(-) diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index f72c1b532d..4990cfb8dc 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -34,74 +34,6 @@ defineTypeNameAndDebug(Foam::dictionary, 0); const Foam::dictionary Foam::dictionary::null; -#define DICTIONARY_INPLACE_MERGE - -// * * * * * * * * * * * * * Private member functions * * * * * * * * * * * // - -bool Foam::dictionary::add(entry* ePtr, bool mergeEntry) -{ - HashTable::iterator iter = hashedEntries_.find(ePtr->keyword()); - - if (mergeEntry && iter != hashedEntries_.end()) - { - // merge dictionary with dictionary - if (iter()->isDict() && ePtr->isDict()) - { - iter()->dict().merge(ePtr->dict()); - delete ePtr; - - return true; - } - else - { - // replace existing dictionary with entry or vice versa -#ifdef DICTIONARY_INPLACE_MERGE - IDLList::replace(iter(), ePtr); - delete iter(); - hashedEntries_.erase(iter); - - if (hashedEntries_.insert(ePtr->keyword(), ePtr)) - { - ePtr->name() = name_ + "::" + ePtr->keyword(); - return true; - } - else - { - IOWarningIn("dictionary::add(entry* ePtr)", (*this)) - << "problem replacing entry "<< ePtr->keyword() - << " in dictionary " << name() - << endl; - - IDLList::remove(ePtr); - delete ePtr; - return false; - } -#else - remove(ePtr->keyword()); -#endif - } - } - - if (hashedEntries_.insert(ePtr->keyword(), ePtr)) - { - ePtr->name() = name_ + "::" + ePtr->keyword(); - IDLList::append(ePtr); - - return true; - } - else - { - IOWarningIn("dictionary::add(entry* ePtr)", (*this)) - << "attempt to add entry "<< ePtr->keyword() - << " which already exists in dictionary " << name() - << endl; - - delete ePtr; - return false; - } -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::dictionary::dictionary() @@ -270,11 +202,10 @@ const Foam::entry& Foam::dictionary::lookupEntry bool recursive ) const { - const entry* ePtr = lookupEntryPtr(keyword, recursive); + const entry* entryPtr = lookupEntryPtr(keyword, recursive); - if (ePtr == NULL) + if (entryPtr == NULL) { - // If keyword not found print error message ... FatalIOErrorIn ( "dictionary::lookupEntry(const word& keyword) const", @@ -284,7 +215,7 @@ const Foam::entry& Foam::dictionary::lookupEntry << exit(FatalIOError); } - return *ePtr; + return *entryPtr; } @@ -300,7 +231,9 @@ Foam::ITstream& Foam::dictionary::lookup bool Foam::dictionary::isDict(const word& keyword) const { - if (const entry* entryPtr = lookupEntryPtr(keyword)) + const entry* entryPtr = lookupEntryPtr(keyword); + + if (entryPtr) { return entryPtr->isDict(); } @@ -313,7 +246,9 @@ bool Foam::dictionary::isDict(const word& keyword) const const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const { - if (const entry* entryPtr = lookupEntryPtr(keyword)) + const entry* entryPtr = lookupEntryPtr(keyword); + + if (entryPtr) { return &entryPtr->dict(); } @@ -326,13 +261,9 @@ const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const { - if (const entry* entryPtr = lookupEntryPtr(keyword)) + const entry* entryPtr = lookupEntryPtr(keyword); + if (entryPtr == NULL) { - return entryPtr->dict(); - } - else - { - // If keyword not found print error message ... FatalIOErrorIn ( "dictionary::subDict(const word& keyword) const", @@ -340,37 +271,31 @@ const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const ) << " keyword " << keyword << " is undefined in dictionary " << name() << exit(FatalIOError); - - return entryPtr->dict(); } + return entryPtr->dict(); } Foam::dictionary& Foam::dictionary::subDict(const word& keyword) { - if (entry* entryPtr = lookupEntryPtr(keyword)) + entry* entryPtr = lookupEntryPtr(keyword); + if (entryPtr == NULL) { - return entryPtr->dict(); - } - else - { - // If keyword not found print error message ... FatalIOErrorIn ( - "dictionary::subDict(const word& keyword) const", + "dictionary::subDict(const word& keyword)", *this ) << " keyword " << keyword << " is undefined in dictionary " << name() << exit(FatalIOError); - - return entryPtr->dict(); } + return entryPtr->dict(); } Foam::wordList Foam::dictionary::toc() const { - wordList keywords(size()); + wordList keys(size()); label i = 0; for @@ -380,56 +305,124 @@ Foam::wordList Foam::dictionary::toc() const ++iter ) { - keywords[i++] = iter().keyword(); + keys[i++] = iter().keyword(); } - return keywords; + return keys; } -void Foam::dictionary::add(const entry& e) +bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) { - add(e.clone(*this).ptr()); + HashTable::iterator iter = hashedEntries_.find(entryPtr->keyword()); + + if (mergeEntry && iter != hashedEntries_.end()) + { + // merge dictionary with dictionary + if (iter()->isDict() && entryPtr->isDict()) + { + iter()->dict().merge(entryPtr->dict()); + delete entryPtr; + + return true; + } + else + { + // replace existing dictionary with entry or vice versa + IDLList::replace(iter(), entryPtr); + delete iter(); + hashedEntries_.erase(iter); + + if (hashedEntries_.insert(entryPtr->keyword(), entryPtr)) + { + entryPtr->name() = name_ + "::" + entryPtr->keyword(); + return true; + } + else + { + IOWarningIn("dictionary::add(entry*)", (*this)) + << "problem replacing entry "<< entryPtr->keyword() + << " in dictionary " << name() << endl; + + IDLList::remove(entryPtr); + delete entryPtr; + return false; + } + } + } + + if (hashedEntries_.insert(entryPtr->keyword(), entryPtr)) + { + entryPtr->name() = name_ + "::" + entryPtr->keyword(); + IDLList::append(entryPtr); + + return true; + } + else + { + IOWarningIn("dictionary::add(entry* entryPtr)", (*this)) + << "attempt to add entry "<< entryPtr->keyword() + << " which already exists in dictionary " << name() + << endl; + + delete entryPtr; + return false; + } } -void Foam::dictionary::add(const word& keyword, const token& t) + +void Foam::dictionary::add(const entry& e, bool mergeEntry) { - add(new primitiveEntry(keyword, t)); + add(e.clone(*this).ptr(), mergeEntry); } -void Foam::dictionary::add(const word& keyword, const word& w) +void Foam::dictionary::add(const word& k, const word& w, bool overwrite) { - add(new primitiveEntry(keyword, token(w))); + add(new primitiveEntry(k, token(w)), overwrite); } -void Foam::dictionary::add(const word& keyword, const Foam::string& s) +void Foam::dictionary::add(const word& k, const Foam::string& s, bool overwrite) { - add(new primitiveEntry(keyword, token(s))); + add(new primitiveEntry(k, token(s)), overwrite); } -void Foam::dictionary::add(const word& keyword, const label l) +void Foam::dictionary::add(const word& k, const label l, bool overwrite) { - add(new primitiveEntry(keyword, token(l))); + add(new primitiveEntry(k, token(l)), overwrite); } -void Foam::dictionary::add(const word& keyword, const scalar s) +void Foam::dictionary::add(const word& k, const scalar s, bool overwrite) { - add(new primitiveEntry(keyword, token(s))); + add(new primitiveEntry(k, token(s)), overwrite); } -void Foam::dictionary::add(const word& keyword, const ITstream& tokens) +void Foam::dictionary::add(const word& k, const dictionary& d, bool mergeEntry) { - add(new primitiveEntry(keyword, tokens)); + add(new dictionaryEntry(k, *this, d), mergeEntry); } -void Foam::dictionary::add(const word& keyword, const tokenList& tokens) + +void Foam::dictionary::set(entry* entryPtr) { - add(new primitiveEntry(keyword, tokens)); + entry* existingPtr = lookupEntryPtr(entryPtr->keyword()); + + // clear dictionary so merge acts like overwrite + if (existingPtr && existingPtr->isDict()) + { + existingPtr->dict().clear(); + } + add(entryPtr, true); } -void Foam::dictionary::add(const word& keyword, const dictionary& dict) + +void Foam::dictionary::set(const entry& e) { - add(new dictionaryEntry(keyword, *this, dict)); + set(e.clone(*this).ptr()); +} + +void Foam::dictionary::set(const word& k, const dictionary& d) +{ + set(new dictionaryEntry(k, *this, d)); } @@ -486,7 +479,10 @@ bool Foam::dictionary::changeKeyword } else { - // could issue warning if desired + WarningIn("dictionary::changeKeyword(const word& old, const word& new)") + << "cannot rename keyword "<< oldKeyword + << " to existing keyword " << newKeyword + << " in dictionary " << name() << endl; return false; } } @@ -527,34 +523,24 @@ bool Foam::dictionary::merge(const dictionary& dict) if (iter2 != hashedEntries_.end()) { // Recursively merge sub-dictionaries + // TODO: merge without copying if (iter2()->isDict() && iter().isDict()) { - // without copying and without remove/add? - // this certainly looks ugly and doesn't necessarily - // retain the original sort order (perhaps nice to have) - if - ( - iter2()->dict().merge(iter().dict()) - ) + if (iter2()->dict().merge(iter().dict())) { changed = true; } } else { -#ifdef DICTIONARY_INPLACE_MERGE add(iter().clone(*this).ptr(), true); -#else - remove(keyword); - add(iter().clone(*this)()); -#endif changed = true; } } else { // not found - just add - add(iter().clone(*this)()); + add(iter().clone(*this).ptr()); changed = true; } } @@ -588,8 +574,8 @@ void Foam::dictionary::operator=(const dictionary& dict) << abort(FatalError); } - // Clear the current entries - IDLList::clear(); + name_ = dict.name(); + clear(); // Create clones of the entries in the given dictionary // resetting the parentDict to this dictionary @@ -603,10 +589,6 @@ void Foam::dictionary::operator=(const dictionary& dict) IDLList::append(iter().clone(*this).ptr()); } - name_ = dict.name(); - - hashedEntries_.clear(); - for ( IDLList::iterator iter = begin(); @@ -636,7 +618,7 @@ void Foam::dictionary::operator+=(const dictionary& dict) ++iter ) { - add(iter().clone(*this)()); + add(iter().clone(*this).ptr()); } } @@ -660,7 +642,7 @@ void Foam::dictionary::operator|=(const dictionary& dict) { if (!found(iter().keyword())) { - add(iter().clone(*this)()); + add(iter().clone(*this).ptr()); } } } @@ -683,8 +665,7 @@ void Foam::dictionary::operator<<=(const dictionary& dict) ++iter ) { - remove(iter().keyword()); - add(iter().clone(*this)()); + set(iter().clone(*this).ptr()); } } diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index a3a21841cb..9a6021ae53 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -34,6 +34,10 @@ Description data dictionaries, since unlike the IOdictionary class, it does not use a objectRegistry itself to work. +ToDo + A merge() member function with a non-const dictionary parameter. + This would avoid unnecessary cloning in the add(entry*,bool) method + SourceFiles dictionary.C dictionaryIO.C @@ -217,38 +221,57 @@ public: // Editing //- Add a new entry - bool add(entry*, bool mergeEntry = false); + // With the merge option, dictionaries are interwoven and + // primitive entries are overwritten + bool add(entry*, bool mergeEntry=false); //- Add an entry - void add(const entry&); - - //- Add a token entry - void add(const word& keyword, const token&); + // With the merge option, dictionaries are interwoven and + // primitive entries are overwritten + void add(const entry&, bool mergeEntry=false); //- Add a word entry - void add(const word& keyword, const word&); + // optionally overwrite an existing entry + void add(const word& keyword, const word&, bool overwrite=false); //- Add a string entry - void add(const word& keyword, const string&); + // optionally overwrite an existing entry + void add(const word& keyword, const string&, bool overwrite=false); //- Add a label entry - void add(const word& keyword, const label); + // optionally overwrite an existing entry + void add(const word& keyword, const label, bool overwrite=false); //- Add a scalar entry - void add(const word& keyword, const scalar); - - //- Add an entry constructed from a ITstream - void add(const word& keyword, const ITstream&); - - //- Add an entry constructed from a tokenList - void add(const word& keyword, const tokenList& tokens); - - //- Add a T entry - template - void add(const word& keyword, const T&); + // optionally overwrite an existing entry + void add (const word& keyword, const scalar, bool overwrite=false); //- Add a dictionary entry - void add(const word& keyword, const dictionary&); + // optionally merge with an existing sub-dictionary + void add + ( + const word& keyword, + const dictionary&, + bool mergeEntry=false + ); + + //- Add a T entry + // optionally overwrite an existing entry + template + void add(const word& keyword, const T&, bool overwrite=false); + + //- Assign a new entry, overwrite any existing entry + void set(entry*); + + //- Assign a new entry, overwrite any existing entry + void set(const entry&); + + //- Assign a dictionary entry, overwrite any existing entry + void set(const word& keyword, const dictionary&); + + //- Assign a T entry, overwrite any existing entry + template + void set(const word& keyword, const T&); //- Remove an entry specified by keyword bool remove(const word& keyword); @@ -307,14 +330,12 @@ public: // Global Operators -// Combine dictionaries starting from the entries in dict one and then including -// those from dict2. -// Warn, but do not overwrite the entries from dict1. +//- Combine dictionaries starting from the entries in dict1 and then including those from dict2. +// Warn, but do not overwrite the entries from dict1. dictionary operator+(const dictionary& dict1, const dictionary& dict2); -// Combine dictionaries starting from the entries in dict one and then including -// those from dict2. -// Do not overwrite the entries from dict1. +//- Combine dictionaries starting from the entries in dict1 and then including those from dict2. +// Do not overwrite the entries from dict1. dictionary operator|(const dictionary& dict1, const dictionary& dict2); diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C index 4a0f54d762..03f245f910 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C +++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C @@ -33,30 +33,34 @@ template T Foam::dictionary::lookupOrDefault ( const word& keyword, - const T& deft, + const T& deflt, bool recursive ) const { - const entry* ePtr = lookupEntryPtr(keyword, recursive); + const entry* entryPtr = lookupEntryPtr(keyword, recursive); - if (ePtr == NULL) + if (entryPtr == NULL) { - return deft; + return deflt; } else { - return pTraits(ePtr->stream()); + return pTraits(entryPtr->stream()); } } template -void Foam::dictionary::add(const word& keyword, const T& t) +void Foam::dictionary::add(const word& k, const T& t, bool overwrite) { - entry* ePtr = new primitiveEntry(keyword, t); - append(ePtr); - hashedEntries_.insert(ePtr->keyword(), ePtr); + add(new primitiveEntry(k, t), overwrite); } +template +void Foam::dictionary::set(const word& k, const T& t) +{ + set(new primitiveEntry(k, t)); +} + // ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C index 4360ee9ec2..cdfa9410fd 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C @@ -59,6 +59,7 @@ Foam::label Foam::functionEntries::inputModeEntry::mode_ = imError; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// we could combine this into execute() directly, but leave it here for now void Foam::functionEntries::inputModeEntry::setMode(Istream& is) { clear(); From f48cbb88a94771294fcc14c6aecc7d7506d50898 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 13 Jun 2008 15:51:31 +0200 Subject: [PATCH 05/15] use dictionary lookupOrDefault() method instead of found() + lookup() --- .../sampledSurface/patch/sampledPatch.C | 2 +- .../sampledSurface/sampledSurface.C | 23 ++----------------- .../sampledSurface/sampledSurface.H | 5 ---- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/src/sampling/sampledSurface/patch/sampledPatch.C b/src/sampling/sampledSurface/patch/sampledPatch.C index 2b4f636ee7..8ca36d42f5 100644 --- a/src/sampling/sampledSurface/patch/sampledPatch.C +++ b/src/sampling/sampledSurface/patch/sampledPatch.C @@ -140,7 +140,7 @@ Foam::sampledPatch::sampledPatch patchFaceLabels_(0) { // default: non-triangulated - triangulate() = getBool(dict, "triangulate", false); + triangulate() = dict.lookupOrDefault("triangulate", false); createGeometry(); } diff --git a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C index 24ceb62aa6..ef805c8642 100644 --- a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C +++ b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C @@ -151,25 +151,6 @@ Foam::sampledSurface::New ); } - -bool Foam::sampledSurface::getBool -( - const dictionary& dict, - const word& key, - const bool defaultVal -) -{ - if (dict.found(key)) - { - return readBool(dict.lookup(key)); - } - else - { - return defaultVal; - } -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::sampledSurface::sampledSurface @@ -200,8 +181,8 @@ Foam::sampledSurface::sampledSurface : name_(name), mesh_(mesh), - triangulate_(getBool(dict, "triangulate", true)), - interpolate_(getBool(dict, "interpolate", false)), + triangulate_(dict.lookupOrDefault("triangulate", true)), + interpolate_(dict.lookupOrDefault("interpolate", false)), SfPtr_(NULL), magSfPtr_(NULL), CfPtr_(NULL), diff --git a/src/sampling/sampledSurface/sampledSurface/sampledSurface.H b/src/sampling/sampledSurface/sampledSurface/sampledSurface.H index d91ff075e2..d143ee95aa 100644 --- a/src/sampling/sampledSurface/sampledSurface/sampledSurface.H +++ b/src/sampling/sampledSurface/sampledSurface/sampledSurface.H @@ -128,11 +128,6 @@ class sampledSurface protected: - // Protected static functions - - //- Read bool from dictionary. Return provided value if not found - static bool getBool(const dictionary&, const word&, const bool); - // Protected Member functions virtual void clearGeom() const; From 763cc5e4ab08c1488b51302b10d606a8c61bf9eb Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 13 Jun 2008 19:47:04 +0200 Subject: [PATCH 06/15] Pstream : avoid compiler warnings, doxygen ignore file-scope variables --- src/Pstream/Allwmake | 4 +++ src/Pstream/dummy/IPread.C | 43 +++++++++++++----------------- src/Pstream/dummy/OPwrite.C | 13 +++------ src/Pstream/dummy/Pstream.C | 16 ++++------- src/Pstream/gamma/OPwrite.C | 6 +++-- src/Pstream/gamma/PstreamGlobals.H | 3 ++- src/Pstream/mpi/IPread.C | 18 +++++-------- src/Pstream/mpi/OPwrite.C | 26 +++++++----------- src/Pstream/mpi/Pstream.C | 18 ++++++------- 9 files changed, 64 insertions(+), 83 deletions(-) diff --git a/src/Pstream/Allwmake b/src/Pstream/Allwmake index 0b81eda108..eb51ef379e 100755 --- a/src/Pstream/Allwmake +++ b/src/Pstream/Allwmake @@ -6,6 +6,10 @@ wmake libso dummy case "$WM_MPLIB" in LAM | OPENMPI | MPI | MPICH | MPICH-GM | MPIGAMMA ) export WM_OPTIONS=${WM_OPTIONS}$WM_MPLIB + set +x + echo + echo "Note: ignore spurious warnings about missing mpicxx.h headers" + set -x wmake libso mpi ;; diff --git a/src/Pstream/dummy/IPread.C b/src/Pstream/dummy/IPread.C index dd28fd7fef..fd4ed46e0f 100644 --- a/src/Pstream/dummy/IPread.C +++ b/src/Pstream/dummy/IPread.C @@ -32,12 +32,9 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // -IPstream::IPstream +Foam::IPstream::IPstream ( const commsTypes commsType, const int fromProcNo, @@ -53,13 +50,12 @@ IPstream::IPstream { notImplemented ( - "IPstream::IPstream" + "IPsream::IPstream" "(" - "const commsTypes commsType," - "const int fromProcNo," + "const commsTypes," + "const int fromProcNo," "const label bufSize," - "streamFormat format," - "versionNumber version" + "streamFormat, versionNumber" ")" ); } @@ -67,7 +63,7 @@ IPstream::IPstream // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -int IPstream::read +int Foam::IPstream::read ( const commsTypes commsType, const int fromProcNo, @@ -75,33 +71,32 @@ int IPstream::read const std::streamsize bufSize ) { - notImplemented - ( - "IPstream::read" - "(" - "const commsTypes commsType," - "const int fromProcNo," - "char* buf," - "const label bufSize" - ")" + notImplemented + ( + "IPstream::read" + "(" + "const commsTypes," + "const int fromProcNo," + "char* buf," + "const label bufSize" + ")" ); return 0; } -void IPstream::waitRequests() +void Foam::IPstream::waitRequests() {} -bool IPstream::finishedRequest(const label) +bool Foam::IPstream::finishedRequest(const label) { - notImplemented("IPstream::finishedRequest()"); + notImplemented("IPstream::finishedRequest()"); + return false; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/Pstream/dummy/OPwrite.C b/src/Pstream/dummy/OPwrite.C index 7166a1ad45..d87f22d769 100644 --- a/src/Pstream/dummy/OPwrite.C +++ b/src/Pstream/dummy/OPwrite.C @@ -32,12 +32,9 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -OPstream::~OPstream() +Foam::OPstream::~OPstream() { notImplemented("OPstream::~OPstream()"); } @@ -45,7 +42,7 @@ OPstream::~OPstream() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -bool OPstream::write +bool Foam::OPstream::write ( const commsTypes commsType, const int toProcNo, @@ -68,11 +65,11 @@ bool OPstream::write } -void OPstream::waitRequests() +void Foam::OPstream::waitRequests() {} -bool OPstream::finishedRequest(const label) +bool Foam::OPstream::finishedRequest(const label) { notImplemented("OPstream::finishedRequest()"); return false; @@ -81,6 +78,4 @@ bool OPstream::finishedRequest(const label) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/Pstream/dummy/Pstream.C b/src/Pstream/dummy/Pstream.C index 22adbe6cf2..3b1e9752f5 100644 --- a/src/Pstream/dummy/Pstream.C +++ b/src/Pstream/dummy/Pstream.C @@ -29,16 +29,13 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -void Pstream::addValidParOptions(HashTable& validParOptions) +void Foam::Pstream::addValidParOptions(HashTable& validParOptions) {} -bool Pstream::init(int& argc, char**& argv) +bool Foam::Pstream::init(int& argc, char**& argv) { FatalErrorIn("Pstream::init(int& argc, char**& argv)") << "Trying to use the dummy Pstream library." << nl @@ -49,24 +46,21 @@ bool Pstream::init(int& argc, char**& argv) } -void Pstream::exit(int errnum) +void Foam::Pstream::exit(int errnum) { notImplemented("Pstream::exit(int errnum)"); } -void Pstream::abort() +void Foam::Pstream::abort() { notImplemented("Pstream::abort()"); } -void reduce(scalar&, const sumOp&) +void Foam::reduce(scalar&, const sumOp&) {} - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/Pstream/gamma/OPwrite.C b/src/Pstream/gamma/OPwrite.C index ca96d1a172..3d1529e4bf 100644 --- a/src/Pstream/gamma/OPwrite.C +++ b/src/Pstream/gamma/OPwrite.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description - Write primitive and binary block from OPstream + Write primitive and binary block from OPstream gamma-mpi \*---------------------------------------------------------------------------*/ @@ -46,8 +46,10 @@ namespace Foam // Largest message sent so far. This tracks the size of the receive // buffer on the receiving end. Done so we only send out resize messages -// if nessecary +// if necessary +//! @cond fileScope labelList maxSendSize; +//! @endcond fileScope // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/src/Pstream/gamma/PstreamGlobals.H b/src/Pstream/gamma/PstreamGlobals.H index 9d0807a9b1..58941c80be 100644 --- a/src/Pstream/gamma/PstreamGlobals.H +++ b/src/Pstream/gamma/PstreamGlobals.H @@ -26,7 +26,8 @@ Namespace Foam::PstreamGlobals Description - Global functions and variables for working with parallel streams. + Global functions and variables for working with parallel streams, + but principally for gamma/mpi SourceFiles PstreamGlobals.C diff --git a/src/Pstream/mpi/IPread.C b/src/Pstream/mpi/IPread.C index 7423dd6b43..f00f322bab 100644 --- a/src/Pstream/mpi/IPread.C +++ b/src/Pstream/mpi/IPread.C @@ -33,18 +33,16 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // Outstanding non-blocking operations. -DynamicList IPstream_outstandingRequests_; - +//! @cond fileScope +Foam::DynamicList IPstream_outstandingRequests_; +//! @endcond fileScope // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // -IPstream::IPstream +Foam::IPstream::IPstream ( const commsTypes commsType, const int fromProcNo, @@ -89,7 +87,7 @@ IPstream::IPstream // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -label IPstream::read +Foam::label Foam::IPstream::read ( const commsTypes commsType, const int fromProcNo, @@ -192,7 +190,7 @@ label IPstream::read } -void IPstream::waitRequests() +void Foam::IPstream::waitRequests() { if (IPstream_outstandingRequests_.size() > 0) { @@ -219,7 +217,7 @@ void IPstream::waitRequests() } -bool IPstream::finishedRequest(const label i) +bool Foam::IPstream::finishedRequest(const label i) { if (i >= IPstream_outstandingRequests_.size()) { @@ -244,6 +242,4 @@ bool IPstream::finishedRequest(const label i) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/Pstream/mpi/OPwrite.C b/src/Pstream/mpi/OPwrite.C index 2a09427b7c..4f69ef3f75 100644 --- a/src/Pstream/mpi/OPwrite.C +++ b/src/Pstream/mpi/OPwrite.C @@ -31,20 +31,16 @@ Description #include "OPstream.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // Outstanding non-blocking operations. -DynamicList OPstream_outstandingRequests_; - +//! @cond fileScope +Foam::DynamicList OPstream_outstandingRequests_; +//! @endcond fileScope // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -OPstream::~OPstream() +Foam::OPstream::~OPstream() { if ( @@ -66,7 +62,7 @@ OPstream::~OPstream() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -bool OPstream::write +bool Foam::OPstream::write ( const commsTypes commsType, const int toProcNo, @@ -80,7 +76,7 @@ bool OPstream::write { transferFailed = MPI_Bsend ( - (char*)buf, + const_cast(buf), bufSize, MPI_PACKED, procID(toProcNo), @@ -92,7 +88,7 @@ bool OPstream::write { transferFailed = MPI_Send ( - (char*)buf, + const_cast(buf), bufSize, MPI_PACKED, procID(toProcNo), @@ -106,7 +102,7 @@ bool OPstream::write transferFailed = MPI_Isend ( - (char*)buf, + const_cast(buf), bufSize, MPI_PACKED, procID(toProcNo), @@ -132,7 +128,7 @@ bool OPstream::write } -void OPstream::waitRequests() +void Foam::OPstream::waitRequests() { if (OPstream_outstandingRequests_.size() > 0) { @@ -159,7 +155,7 @@ void OPstream::waitRequests() } -bool OPstream::finishedRequest(const label i) +bool Foam::OPstream::finishedRequest(const label i) { if (i >= OPstream_outstandingRequests_.size()) { @@ -184,6 +180,4 @@ bool OPstream::finishedRequest(const label i) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/Pstream/mpi/Pstream.C b/src/Pstream/mpi/Pstream.C index a456341317..ce42db4ea6 100644 --- a/src/Pstream/mpi/Pstream.C +++ b/src/Pstream/mpi/Pstream.C @@ -42,12 +42,14 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -void Pstream::addValidParOptions(HashTable& validParOptions) +// NOTE: +// valid parallel options vary between implementations, but flag common ones. +// if they are not removed by MPI_Init(), the subsequent argument processing +// will notice that they are wrong +void Foam::Pstream::addValidParOptions(HashTable& validParOptions) { validParOptions.insert("np", ""); validParOptions.insert("p4pg", "PI file"); @@ -59,7 +61,7 @@ void Pstream::addValidParOptions(HashTable& validParOptions) } -bool Pstream::init(int& argc, char**& argv) +bool Foam::Pstream::init(int& argc, char**& argv) { MPI_Init(&argc, &argv); @@ -119,7 +121,7 @@ bool Pstream::init(int& argc, char**& argv) } -void Pstream::exit(int errnum) +void Foam::Pstream::exit(int errnum) { # ifndef SGIMPI int size; @@ -140,13 +142,13 @@ void Pstream::exit(int errnum) } -void Pstream::abort() +void Foam::Pstream::abort() { MPI_Abort(MPI_COMM_WORLD, 1); } -void reduce(scalar& Value, const sumOp& bop) +void Foam::reduce(scalar& Value, const sumOp& bop) { if (!Pstream::parRun()) { @@ -426,6 +428,4 @@ void reduce(scalar& Value, const sumOp& bop) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // From 099117dd2a545ac4f6e2b22da614cfa6201834d9 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 13 Jun 2008 18:21:36 +0200 Subject: [PATCH 07/15] argList + IOobject write-headers modifications * new -srcDoc option to display doxygen-processed source code * display standard options -help/-doc/-srcDoc at end of usage * consolidate code when writing IOobject headers * drop writeLogbanner and add optional bool to writeBanner * minor formatting changes --- src/OpenFOAM/db/IOobject/IOobject.H | 7 +-- src/OpenFOAM/db/IOobject/IOobjectI.H | 38 +++++---------- .../db/IOobject/IOobjectWriteHeader.C | 14 +++--- src/OpenFOAM/global/argList/argList.C | 47 +++++++++++++------ src/OpenFOAM/global/argList/argList.H | 22 +++++---- 5 files changed, 65 insertions(+), 63 deletions(-) diff --git a/src/OpenFOAM/db/IOobject/IOobject.H b/src/OpenFOAM/db/IOobject/IOobject.H index 0c35bd7f1a..e08a56a1a8 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.H +++ b/src/OpenFOAM/db/IOobject/IOobject.H @@ -329,12 +329,9 @@ public: // Writing //- Write the standard OpenFOAM file/dictionary banner + // Optionally without -*- C++ -*- editor hint (eg, for logs) template - static inline void writeBanner(Stream& os); - - //- Write the standard OpenFOAM log banner - template - static inline void writeLogBanner(Stream& os); + static inline void writeBanner(Stream& os, bool noHint=false); //- Write the standard file section divider template diff --git a/src/OpenFOAM/db/IOobject/IOobjectI.H b/src/OpenFOAM/db/IOobject/IOobjectI.H index 09a64ff896..7ffff5ede5 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectI.H +++ b/src/OpenFOAM/db/IOobject/IOobjectI.H @@ -29,48 +29,34 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -inline void Foam::IOobject::writeBanner(Stream& os) +inline void Foam::IOobject::writeBanner(Stream& os, bool noHint) { static bool spacesSet = false; - static char spaces[80]; + static char spaces[40]; if (!spacesSet) { - memset(spaces, ' ', 80); + memset(spaces, ' ', 40); spaces[38 - strlen(Foam::FOAMversion)] = '\0'; spacesSet = true; } - os << - "/*--------------------------------*- C++ -*----------------------------------*\\\n" - "| ========= | |\n" - "| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |\n" - "| \\\\ / O peration | Version: " << FOAMversion << spaces << "|\n" - "| \\\\ / A nd | Web: http://www.openfoam.org |\n" - "| \\\\/ M anipulation | |\n" - "\\*---------------------------------------------------------------------------*/\n"; -} - - -template -inline void Foam::IOobject::writeLogBanner(Stream& os) -{ - static bool spacesSet = false; - static char spaces[80]; - - if (!spacesSet) + if (noHint) { - memset(spaces, ' ', 80); - spaces[38 - strlen(Foam::FOAMversion)] = '\0'; - spacesSet = true; + os << + "/*---------------------------------------------------------------------------*\\\n"; + } + else + { + os << + "/*--------------------------------*- C++ -*----------------------------------*\\\n"; } os << - "/*---------------------------------------------------------------------------*\\\n" "| ========= | |\n" "| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |\n" "| \\\\ / O peration | Version: " << FOAMversion << spaces << "|\n" - "| \\\\ / A nd | Web: http://www.openfoam.org |\n" + "| \\\\ / A nd | Web: http://www.OpenFOAM.org |\n" "| \\\\/ M anipulation | |\n" "\\*---------------------------------------------------------------------------*/\n"; } diff --git a/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C b/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C index 8846dd1d44..6e647c9ca5 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C +++ b/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C @@ -37,8 +37,8 @@ bool Foam::IOobject::writeHeader(Ostream& os) const if (!os.good()) { Info<< "IOobject::writeHeader(Ostream&) : " - << "no stream open for write" - << endl << os.info() << endl; + << "no stream open for write" << nl + << os.info() << endl; return false; } @@ -49,16 +49,14 @@ 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"; + os << " note " << note() << ";\n"; } - // writing without quotes would look nicer - os << " object " << name() << ";\n" - //<< " instance " << instance()/local() << ";\n" - //<< " local " << local() << ";\n" - << " location " << instance()/local() << ";\n" + os << " location " << instance()/local() << ";\n" + << " object " << name() << ";\n" << "}" << nl; writeDivider(os); diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 8e1738a734..59ee6e57b5 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -186,7 +186,7 @@ Foam::argList::argList // Print the banner once only for parallel runs if (Pstream::master()) { - IOobject::writeLogBanner(Info); + IOobject::writeBanner(Info, true); } // convert argv -> args_ and capture ( ... ) lists @@ -252,19 +252,30 @@ Foam::argList::argList args_.setSize(nArgs); - // Help options: - // -doc display the documentation in browser - // -help print the usage - if (options_.found("doc") || options_.found("help")) + // Help/documentation options: + // -help print the usage + // -doc display application documentation in browser + // -srcDoc display source code in browser + if + ( + options_.found("help") + || options_.found("doc") + || options_.found("srcDoc") + ) { if (options_.found("help")) { printUsage(); } - if (options_.found("doc")) + // only display one or the other + if (options_.found("srcDoc")) { - displayDoc(); + displayDoc(true); + } + else if (options_.found("doc")) + { + displayDoc(false); } ::exit(0); @@ -578,12 +589,9 @@ void Foam::argList::printUsage() const ++iter ) { - Info<< ' ' << '<' << iter().c_str() << '>'; + Info<< " <" << iter().c_str() << '>'; } - // place -doc and -help up front - Info<< " [-doc] [-help]"; - for ( HashTable::iterator iter = validOptions.begin(); @@ -601,16 +609,27 @@ void Foam::argList::printUsage() const Info<< ']'; } - Info<< endl; + // place help/doc options of the way at the end, + // but with an extra space to separate it a little + Info<< " [-help] [-doc] [-srcDoc]" << endl; } -void Foam::argList::displayDoc() const +void Foam::argList::displayDoc(bool source) const { const dictionary& docDict = debug::controlDict().subDict("Documentation"); List docDirs(docDict.lookup("doxyDocDirs")); List docExts(docDict.lookup("doxySourceFileExts")); + // for source code: change foo_8C.html to foo_8C-source.html + if (source) + { + forAll(docExts, extI) + { + docExts[extI].replace(".", "-source."); + } + } + fileName docFile; bool found = false; @@ -618,7 +637,7 @@ void Foam::argList::displayDoc() const { forAll(docExts, extI) { - docFile = docDirs[dirI]/executable() + docExts[extI]; + docFile = docDirs[dirI]/executable_ + docExts[extI]; docFile.expand(); if (exists(docFile)) diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index 3068e042c9..f79d6d5d17 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -27,18 +27,18 @@ Class Description Extract command arguments and options from the supplied - @a argc and @a argv. + @a argc and @a argv parameters. Sequences with "(" ... ")" are transformed into a stringList. For example, @verbatim program -listFiles \( *.txt \) @endverbatim - in which the backslash-escaping has been used to avoid shell expansions, would create a stringList: @verbatim ( "file1.txt" "file2.txt" ... "fileN.txt" ) @endverbatim + The backslash-escaping has been used to avoid shell expansions. @par Default command-line options @param -case \ \n @@ -47,6 +47,8 @@ Description specify case as a parallel job @param -doc \n display the documentation in browser + @param -srcDoc \n + display the source documentation in browser @param -help \n print the usage @@ -130,14 +132,14 @@ public: //- A list of valid parallel options static HashTable validParOptions; - //! @cond ignore documentation for this class + //! @cond ignoreDocumentation class initValidTables { public: initValidTables(); }; - //! @endcond + //! @endcond ignoreDocumentation // Constructors @@ -148,8 +150,8 @@ public: ( int& argc, char**& argv, - bool checkArgs = true, - bool checkOpts = true + bool checkArgs=true, + bool checkOpts=true ); @@ -196,8 +198,7 @@ public: return globalCase_; } - //- Return case name for parallel run - // or the global case for a serial run + //- Return case name for parallel run or the global case for a serial run const fileName& caseName() const { return case_; @@ -222,13 +223,14 @@ public: void printUsage() const; //- Display documentation in browser - void displayDoc() const; + // Optionally display the application source code + void displayDoc(bool source=false) const; // Check //- Check argument list - bool check(bool checkArgs = true, bool checkOpts = true) const; + bool check(bool checkArgs=true, bool checkOpts=true) const; //- Check root path and case path bool checkRootCase() const; From 3bbd01ebfb4e798c0dbafa6af25dd8e72e0a64ea Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sun, 15 Jun 2008 17:57:55 +0200 Subject: [PATCH 08/15] minor changes to Allwmake script(s) * use $WM_THIRD_PARTY_DIR variable in top-level Allwmake * test new shell idiom for Allwmake files: # run from this directory only cd ${0%/*} || exit 1 this might be especially useful when building optional components --- Allwmake | 5 ++++- applications/utilities/mesh/conversion/Optional/Allwmake | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Allwmake b/Allwmake index 515d1cdf9a..749c60fc89 100755 --- a/Allwmake +++ b/Allwmake @@ -1,10 +1,13 @@ #!/bin/sh set -x +# run from this directory only +cd ${0%/*} || exit 1 + # wmake is required for subsequent targets (cd wmake/src && make) -(cd $WM_PROJECT_INST_DIR/ThirdParty && ./Allwmake) +(cd $WM_THIRD_PARTY_DIR && ./Allwmake) (cd src && ./Allwmake) diff --git a/applications/utilities/mesh/conversion/Optional/Allwmake b/applications/utilities/mesh/conversion/Optional/Allwmake index 95f041dd61..31617e3b12 100755 --- a/applications/utilities/mesh/conversion/Optional/Allwmake +++ b/applications/utilities/mesh/conversion/Optional/Allwmake @@ -2,6 +2,9 @@ # Build optional components (eg, may depend on third-party libraries) set -x +# run from this directory only +cd ${0%/*} || exit 1 + # build libccmio if required if [ ! -e $FOAM_LIBBIN/libccmio.so ] then From 1025c3c4d348e1a67825f962efbde2d853da5cce Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 16 Jun 2008 10:39:22 +0200 Subject: [PATCH 09/15] eliminate .OpenFOAM-VERSION references in dotFoam and other files --- bin/mpirunDebug | 23 +++++++------- src/OSspecific/Unix/Unix.C | 20 +++---------- src/OpenFOAM/include/OSspecific.H | 2 -- wmake/wmakeLockScheduler | 50 +++++++++++++++++-------------- wmake/wmakeScheduler | 13 +++----- 5 files changed, 49 insertions(+), 59 deletions(-) diff --git a/bin/mpirunDebug b/bin/mpirunDebug index b0a53cdc63..eec1513439 100755 --- a/bin/mpirunDebug +++ b/bin/mpirunDebug @@ -80,27 +80,25 @@ $ECHO "Choose running method: 1)gdb+xterm 2)gdb 3)log 4)xterm+valgrind: \c" read method if [ "$method" -ne 1 -a "$method" -ne 2 -a "$method" -ne 3 -a "$method" -ne 4 ]; then printUsage - exit 1 + exit 1 fi $ECHO "Run all processes local or distributed? 1)local 2)remote: \c" read spawn if [ "$spawn" -ne 1 -a "$spawn" -ne 2 ]; then printUsage - exit 1 + exit 1 fi -# check ~/.OpenFOAM-VERSION -# check /etc -# check /.OpenFOAM-VERSION +# check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/ +# check ~/.$WM_PROJECT/ +# check /etc/ if [ "$WM_PROJECT" ]; then - : ${FOAM_DOT_DIR:=.$WM_PROJECT-$WM_PROJECT_VERSION} - for i in \ - $HOME/$FOAM_DOT_DIR \ + $HOME/.WM_PROJECT/$WM_PROJECT_VERSION \ + $HOME/.WM_PROJECT \ $WM_PROJECT_DIR/etc \ - $WM_PROJECT_DIR/$FOAM_DOT_DIR \ ; do if [ -f "$i/bashrc" ]; then @@ -112,7 +110,12 @@ fi # Construct test string for remote execution. # Source OpenFOAM settings if OpenFOAM environment not set. -sourceFoam='[ "$WM_PROJECT" ] || . '"$sourceFoam" +# attempt to preserve the installation directory 'FOAM_INST_DIR' +if [ "$FOAM_INST_DIR" ]; then + sourceFoam='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam" +else + sourceFoam='[ "$WM_PROJECT" ] || '". $sourceFoam" +fi echo "**sourceFoam:$sourceFoam" diff --git a/src/OSspecific/Unix/Unix.C b/src/OSspecific/Unix/Unix.C index e50444a236..b2c89395e5 100644 --- a/src/OSspecific/Unix/Unix.C +++ b/src/OSspecific/Unix/Unix.C @@ -213,25 +213,13 @@ bool Foam::chDir(const fileName& dir) Foam::fileName Foam::dotFoam(const fileName& name) { - // Search for file 'name' in: - // 1) ~/.OpenFOAM-VERSION/, ~/.OpenFOAM/VERSION/ or ~/.OpenFOAM/ - // 2) $WM_PROJECT_INST_DIR/site/VERSION or $WM_PROJECT_INST_DIR/site/ - // 3) $WM_PROJECT_DIR/etc/ - // Search user files: // ~~~~~~~~~~~~~~~~~~ - // Check for user file in ~/.OpenFOAM-VERSION/ - fileName fullName = home()/(word(".OpenFOAM-") + FOAMversion)/name; - if (exists(fullName)) - { - return fullName; - } - fileName searchDir = home()/".OpenFOAM"; if (dir(searchDir)) { // Check for user file in ~/.OpenFOAM/VERSION - fullName = searchDir/FOAMversion/name; + fileName fullName = searchDir/FOAMversion/name; if (exists(fullName)) { return fullName; @@ -252,7 +240,7 @@ Foam::fileName Foam::dotFoam(const fileName& name) if (dir(searchDir)) { // Check for site file in $WM_PROJECT_INST_DIR/site/VERSION - fullName = searchDir/"site"/FOAMversion/name; + fileName fullName = searchDir/"site"/FOAMversion/name; if (exists(fullName)) { return fullName; @@ -272,14 +260,14 @@ Foam::fileName Foam::dotFoam(const fileName& name) if (dir(searchDir)) { // Check for shipped OpenFOAM file in $WM_PROJECT_DIR/etc - fullName = searchDir/"etc"/name; + fileName fullName = searchDir/"etc"/name; if (exists(fullName)) { return fullName; } } - // Nothing found + // Not found return fileName::null; } diff --git a/src/OpenFOAM/include/OSspecific.H b/src/OpenFOAM/include/OSspecific.H index d071cf6cd0..33e474cdf3 100644 --- a/src/OpenFOAM/include/OSspecific.H +++ b/src/OpenFOAM/include/OSspecific.H @@ -89,8 +89,6 @@ bool chDir(const fileName& dir); //- Search for @em name in the following hierarchy: // -# personal settings: -// - ~/.OpenFOAM-\ -// (old style) // - ~/.OpenFOAM/\/ // for version-specific files // - ~/.OpenFOAM/ diff --git a/wmake/wmakeLockScheduler b/wmake/wmakeLockScheduler index b8db7492f7..8182ad4b76 100755 --- a/wmake/wmakeLockScheduler +++ b/wmake/wmakeLockScheduler @@ -37,7 +37,8 @@ # Sources the relevant cshrc/bashrc if not set. # # WM_PROJECT_DIR, WM_PROJECT and WM_PROJECT_VERSION will have been set -# before calling this routine +# before calling this routine. +# FOAM_INST_DIR may possibly have been set (to find installation) # # Usage # wmakeScheduler COMMAND @@ -45,7 +46,7 @@ # # wmakeScheduler -count # count the total number of slots available in WM_HOSTS -# eg, WM_NCOMPPROCS=$(wmakeScheduler -count) +# eg, export WM_NCOMPPROCS=$(wmakeScheduler -count) # #------------------------------------------------------------------------------- lockDir=$HOME/.wmakeScheduler @@ -81,35 +82,40 @@ case $SHELL in ;; esac -# check ~/.$WM_PROJECT-$WM_PROJECT_VERSION/ # check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/ # check ~/.$WM_PROJECT/ # check /etc/ -# check /dev/null; then # Set colour colour=${colours[$colourIndex]} - #echo "** host=$host colourIndex=$colourIndex colour=$colour" + ## echo "** host=$host colourIndex=$colourIndex colour=$colour" if [ "$host" = "$HOST" ]; then if [ "$colour" ]; then diff --git a/wmake/wmakeScheduler b/wmake/wmakeScheduler index 1be15abd87..14f4d90402 100755 --- a/wmake/wmakeScheduler +++ b/wmake/wmakeScheduler @@ -37,7 +37,8 @@ # Sources the relevant cshrc/bashrc if not set. # # WM_PROJECT_DIR, WM_PROJECT and WM_PROJECT_VERSION will have been set -# before calling this routine +# before calling this routine. +# FOAM_INST_DIR may possibly have been set (to find installation) # # Usage # wmakeScheduler COMMAND @@ -45,7 +46,7 @@ # # wmakeScheduler -count # count the total number of slots available in WM_HOSTS -# eg, WM_NCOMPPROCS=$(wmakeScheduler -count) +# eg, export WM_NCOMPPROCS=$(wmakeScheduler -count) # #------------------------------------------------------------------------------- lockDir=$HOME/.wmakeScheduler @@ -81,21 +82,15 @@ case $SHELL in ;; esac -# check ~/.$WM_PROJECT-$WM_PROJECT_VERSION/ # check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/ # check ~/.$WM_PROJECT/ # check /etc/ -# check Date: Sun, 15 Jun 2008 17:56:54 +0200 Subject: [PATCH 10/15] build paraview without requiring Tk --- bin/tools/buildParaViewFunctions | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/tools/buildParaViewFunctions b/bin/tools/buildParaViewFunctions index f279a503b0..0ff51f99ed 100644 --- a/bin/tools/buildParaViewFunctions +++ b/bin/tools/buildParaViewFunctions @@ -48,6 +48,7 @@ initialiseVariables () if [ "$VERBOSE" = ON ]; then addCMakeVariable "CMAKE_VERBOSE_MAKEFILE=TRUE" fi + addCMakeVariable "VTK_USE_TK=FALSE" } @@ -90,8 +91,8 @@ addPythonSupport () else # Try to obtain $PYTHON_LIBRARY if not set # - assumes dynamically linked - PYTHON_LIBRARY=`ldd $WHICH_PYTHON | grep libpython | \ - sed 's/.* => \(.*\) (.*/\1/'` + PYTHON_LIBRARY=`ldd $WHICH_PYTHON | \ + sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p'` fi if [ ! -n "$PYTHON_LIBRARY" ]; then @@ -102,7 +103,7 @@ addPythonSupport () exit 1 fi PYTHON_MAJOR_VERSION=`echo $PYTHON_LIBRARY | \ - sed 's/.*libpython\(.*\).so.*/\1/'` + sed 's/.*libpython\(.*\)\.so.*/\1/'` PYTHON_INCLUDE_DIR=/usr/include/python$PYTHON_MAJOR_VERSION addCMakeVariable "PARAVIEW_ENABLE_PYTHON=ON" @@ -143,7 +144,7 @@ buildParaView () # set paraview environment unset PARAVIEW_SRC_DIR - for i in $PWD $WM_PROJECT_INST_DIR + for i in $PWD $WM_THIRD_PARTY_DIR do if [ -d $i/$PARAVIEW_SRC ] then @@ -155,7 +156,7 @@ buildParaView () [ -d "$PARAVIEW_SRC_DIR" ] || { echo "did not find $PARAVIEW_SRC in these directories:" echo " PWD=$PWD" - echo " WM_PROJECT_INST_DIR=$WM_PROJECT_INST_DIR" + echo " WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR" echo "abort build" exit 1 } From a382bdacea2a22ede53a128041fcd221777ae5da Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 16 Jun 2008 11:09:59 +0200 Subject: [PATCH 11/15] OpenFOAM Make/options: use $WM_THIRD_PARTY_DIR zlib headers, not system headers --- src/OpenFOAM/Make/options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenFOAM/Make/options b/src/OpenFOAM/Make/options index 420d3469ec..c5c5809076 100644 --- a/src/OpenFOAM/Make/options +++ b/src/OpenFOAM/Make/options @@ -1,5 +1,5 @@ EXE_INC = \ - -I$(LIB_SRC)/zlib-1.2.3 + -I$(WM_THIRD_PARTY_DIR)/zlib-1.2.3 LIB_LIBS = \ $(FOAM_LIBBIN)/libOSspecific.o \ From dcb487fd0fb8d1a5995e826cb6375587dcf20d3c Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 16 Jun 2008 11:46:11 +0200 Subject: [PATCH 12/15] wmake : set WM_NCOMPPROCS automatically when both WM_HOSTS and WM_SCHEDULER are set This substantially eases enabling/disabling distributed compiling For example, - export WM_HOSTS="host1:N ... hostN:N" as usual - simply set/unset WM_SCHEDULER etc/aliases.{sh,csh} added aliases for enabling/disabling wmakeScheduler - alias wmSchedON='export WM_SCHEDULER=$WM_PROJECT_DIR/wmake/wmakeScheduler' - alias wmSchedOFF='unset WM_SCHEDULER' Removed wmakeLockScheduler, identical to wmakeScheduler except a 'sleep' --- etc/aliases.csh | 6 ++ etc/aliases.sh | 6 ++ wmake/wmake | 9 +- wmake/wmakeLockScheduler | 207 --------------------------------------- 4 files changed, 20 insertions(+), 208 deletions(-) delete mode 100755 wmake/wmakeLockScheduler diff --git a/etc/aliases.csh b/etc/aliases.csh index 0239cc8f3b..6042fc6bd3 100644 --- a/etc/aliases.csh +++ b/etc/aliases.csh @@ -38,6 +38,12 @@ alias wm32 'setenv WM_ARCH_OPTION 32; source $WM_PROJECT_DIR/etc/cshrc' alias wmSP 'setenv WM_PRECISION_OPTION SP; source $WM_PROJECT_DIR/etc/cshrc' alias wmDP 'setenv WM_PRECISION_OPTION DP; source $WM_PROJECT_DIR/etc/cshrc' +# Toggle wmakeScheduler on/off +# - also need to set WM_HOSTS +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +alias wmSchedON 'setenv WM_SCHEDULER $WM_PROJECT_DIR/wmake/wmakeScheduler' +alias wmSchedOFF 'unsetenv WM_SCHEDULER' + # Change directory aliases # ~~~~~~~~~~~~~~~~~~~~~~~~ alias src 'cd $FOAM_SRC' diff --git a/etc/aliases.sh b/etc/aliases.sh index 885568a734..1d3367589e 100644 --- a/etc/aliases.sh +++ b/etc/aliases.sh @@ -38,6 +38,12 @@ alias wm32='export WM_ARCH_OPTION=32; . $WM_PROJECT_DIR/etc/bashrc' alias wmSP='export WM_PRECISION_OPTION=SP; . $WM_PROJECT_DIR/etc/bashrc' alias wmDP='export WM_PRECISION_OPTION=DP; . $WM_PROJECT_DIR/etc/bashrc' +# Toggle wmakeScheduler on/off +# - also need to set WM_HOSTS +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +alias wmSchedON='export WM_SCHEDULER=$WM_PROJECT_DIR/wmake/wmakeScheduler' +alias wmSchedOFF='unset WM_SCHEDULER' + # Change directory aliases # ~~~~~~~~~~~~~~~~~~~~~~~~ alias src='cd $FOAM_SRC' diff --git a/wmake/wmake b/wmake/wmake index 61def5bc66..1290fd556d 100755 --- a/wmake/wmake +++ b/wmake/wmake @@ -89,9 +89,16 @@ done make="make" +# set WM_NCOMPPROCS automatically when both WM_HOSTS and WM_SCHEDULER are set +if [ -z "$WM_NCOMPPROCS" -a -n "$WM_HOSTS" -a -n "$WM_SCHEDULER" ] +then + WM_NCOMPPROCS=$(wmakeScheduler -count) + [ $? -eq 0 ] || unset WM_NCOMPPROCS +fi + if [ "$WM_NCOMPPROCS" ] then - if [ "$WM_NCOMPPROCS" -ne 1 -a ! "$MAKEFLAGS" ] + if [ "$WM_NCOMPPROCS" -gt 1 -a ! "$MAKEFLAGS" ] then lockDir=$HOME/.wmakeScheduler diff --git a/wmake/wmakeLockScheduler b/wmake/wmakeLockScheduler deleted file mode 100755 index 8182ad4b76..0000000000 --- a/wmake/wmakeLockScheduler +++ /dev/null @@ -1,207 +0,0 @@ -#!/bin/bash -#------------------------------------------------------------------------------ -# ========= | -# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox -# \\ / O peration | -# \\ / A nd | Copyright (C) 1991-2007 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 -# wmakeScheduler -# -# Description -# Scheduler for network distributed compilations using wmake. -# - WM_HOSTS contains a list of hosts and number of concurrent processes -# eg, -# export WM_HOSTS="hostA:1 hostB:2 hostC:1" -# - WM_COLOURS contains a list of colours to cycle through -# export WM_COLOURS="black blue green cyan red magenta yellow" -# -# Sources the relevant cshrc/bashrc if not set. -# -# WM_PROJECT_DIR, WM_PROJECT and WM_PROJECT_VERSION will have been set -# before calling this routine. -# FOAM_INST_DIR may possibly have been set (to find installation) -# -# Usage -# wmakeScheduler COMMAND -# run 'COMMAND' on one of the slots listed in WM_HOSTS -# -# wmakeScheduler -count -# count the total number of slots available in WM_HOSTS -# eg, export WM_NCOMPPROCS=$(wmakeScheduler -count) -# -#------------------------------------------------------------------------------- -lockDir=$HOME/.wmakeScheduler - -# fallback - 1 core on current host -: ${WM_HOSTS:=$HOST:1} - -# count the total number of slots available and exit -if [ "$1" = "-count" ] -then - expr $( - for slotGroup in $WM_HOSTS - do - n=${slotGroup##*:} - if [ "$n" = "${slotGroup%%:*}" ]; then n=1; fi # missing ':' - echo "+ ${n:-1}" - done) - exit 0 -fi - -# where to source WM_PROJECT settings in a remote shell -# This code tries to figure out which cshrc or bashrc to execute. -# !! Assumes remote computer running same shell and startup files -# in same location - -sourceFoam=false # fallback command -case $SHELL in -*/csh | */tcsh ) # [t]csh vs bash|ksh|sh - shellRc=cshrc - ;; -*) - shellRc=bashrc - ;; -esac - -# check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/ -# check ~/.$WM_PROJECT/ -# check /etc/ -if [ "$WM_PROJECT" ]; then - - for i in \ - $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \ - $HOME/.$WM_PROJECT \ - $WM_PROJECT_DIR/etc \ - ; - do - if [ -f "$i/$shellRc" ]; then - sourceFoam="$i/$shellRc" - break - fi - done -fi - -# Construct test string for remote execution. -# Source WM_PROJECT settings if WM_PROJECT environment not set. -# attempt to preserve the installation directory 'FOAM_INST_DIR' -case $sourceFoam in -*/bashrc) - if [ "$FOAM_INST_DIR" ]; then - sourceFoam='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam" - else - sourceFoam='[ "$WM_PROJECT" ] || '". $sourceFoam" - fi - ;; - -*/cshrc) - # TODO: csh equivalent to bash code (preserving FOAM_INST_DIR) - sourceFoam='if ( ! $?WM_PROJECT ) source '"$sourceFoam" - ;; -esac - -# quote double-quotes for remote command line -rcmd=$(echo $* | sed -e s/\"/\'\"\'/g) -## the same, without forking (not ksh, maybe not /bin/sh either) -# rcmd=$(while [ "$#" -gt 0 ]; do echo "${1//\"/'\"'}"; shift; done) - - -# Convert WM_COLOURS into an array -declare colours -nColours=0 -for col in $WM_COLOURS -do - colours[$nColours]=$col - ((nColours = $nColours + 1)) -done - -# Bashism: make pipe fail early. This make sure return value of compilation -# is returned and not of colouring pipe. -set -o pipefail - -# Define function to colour output by argument 1 -colourPipe(){ - if [ "$1" ]; then - (while read line; do setterm -foreground $1; echo "$line" ; done; setterm -foreground default) - else - cat - fi -} - - -colourIndex=0 - -while : -do - for slotGroup in $WM_HOSTS - do - # split 'host:N', but catch 'host:' and 'host' too - host=${slotGroup%%:*} - n=${slotGroup##*:} - if [ "$n" = "$host" ]; then n=1; fi # missing ':' - : ${n:=1} - - i=0 - while [ "$i" -lt "$n" ] - do - lockFile="$lockDir/$host:$i" - if lockfile -r0 "$lockFile" 2>/dev/null; then - # Set colour - colour=${colours[$colourIndex]} - ## echo "** host=$host colourIndex=$colourIndex colour=$colour" - - if [ "$host" = "$HOST" ]; then - if [ "$colour" ]; then - eval $* 2>&1 | colourPipe $colour - else - eval $* - fi - elif [ -n "$JOB_ID" ]; then - qrsh -inherit -v PWD $host "$rcmd" - else - if [ "$colour" ]; then - ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 | colourPipe $colour - else - ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" - fi - fi - retval=$? - - # Release lock - rm -f "$lockFile" 2>/dev/null - exit $retval - fi - i=$(expr $i + 1) - - # Cycle through colours - colourIndex=$(expr $colourIndex + 1) - if (( $colourIndex >= $nColours )); then - colourIndex=0 - fi - done - done -done - -if [ "$WM_COLOURS" ]; then - setterm -foreground default -fi - -#------------------------------------------------------------------------------ From 0067393011fc8982ca781d94c6d4c41aaf354702 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 16 Jun 2008 17:10:19 +0200 Subject: [PATCH 13/15] bin/tools/*Functions are not executable - use editor hint instead of #!/bin/sh --- bin/tools/CleanFunctions | 3 +-- bin/tools/RunFunctions | 3 +-- bin/tools/buildParaViewFunctions | 3 +-- bin/tools/thirdPartyGetFunctions | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/bin/tools/CleanFunctions b/bin/tools/CleanFunctions index de10e46fc7..c9d52c9134 100644 --- a/bin/tools/CleanFunctions +++ b/bin/tools/CleanFunctions @@ -1,5 +1,4 @@ -#!/bin/sh -#------------------------------------------------------------------------------ +#---------------------------------*- sh -*------------------------------------- # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions index 64cc1ae4e5..8b0208e64e 100644 --- a/bin/tools/RunFunctions +++ b/bin/tools/RunFunctions @@ -1,5 +1,4 @@ -#!/bin/sh -#------------------------------------------------------------------------------ +#---------------------------------*- sh -*------------------------------------- # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | diff --git a/bin/tools/buildParaViewFunctions b/bin/tools/buildParaViewFunctions index 0ff51f99ed..d5fb1771ec 100644 --- a/bin/tools/buildParaViewFunctions +++ b/bin/tools/buildParaViewFunctions @@ -1,5 +1,4 @@ -#!/bin/sh -#------------------------------------------------------------------------------ +#---------------------------------*- sh -*------------------------------------- # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | diff --git a/bin/tools/thirdPartyGetFunctions b/bin/tools/thirdPartyGetFunctions index a6c92f8a2d..0a79b6f68f 100644 --- a/bin/tools/thirdPartyGetFunctions +++ b/bin/tools/thirdPartyGetFunctions @@ -1,5 +1,4 @@ -#!/bin/sh -#------------------------------------------------------------------------------ +#---------------------------------*- sh -*------------------------------------- # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | From 5d377a21092481e34e40af2680f1f69c42850977 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 17 Jun 2008 10:01:10 +0200 Subject: [PATCH 14/15] fixed NamedEnum array bounds warning * some warnings were spurious with gcc-4.3.0, but gcc-4.3.1 correctly flagged these problems: - processorLduInterfaceTemplates.C --- .../lduInterface/processorLduInterfaceTemplates.C | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C index 2944cb8d84..59f152e236 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C @@ -73,8 +73,7 @@ void Foam::processorLduInterface::send else { FatalErrorIn("processorLduInterface::send") - << "Unsuported communications type " - << Pstream::commsTypeNames[commsType] + << "Unsupported communications type " << commsType << exit(FatalError); } } @@ -104,8 +103,7 @@ void Foam::processorLduInterface::receive else { FatalErrorIn("processorLduInterface::receive") - << "Unsuported communications type " - << Pstream::commsTypeNames[commsType] + << "Unsupported communications type " << commsType << exit(FatalError); } } @@ -184,8 +182,7 @@ void Foam::processorLduInterface::compressedSend else { FatalErrorIn("processorLduInterface::compressedSend") - << "Unsuported communications type " - << Pstream::commsTypeNames[commsType] + << "Unsupported communications type " << commsType << exit(FatalError); } } @@ -225,8 +222,7 @@ void Foam::processorLduInterface::compressedReceive else if (commsType != Pstream::nonBlocking) { FatalErrorIn("processorLduInterface::compressedReceive") - << "Unsuported communications type " - << Pstream::commsTypeNames[commsType] + << "Unsupported communications type " << commsType << exit(FatalError); } From 817b64987e6fe902f78b0ea30725c5d570d2470d Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 17 Jun 2008 11:44:33 +0200 Subject: [PATCH 15/15] Avoid gcc-4.3.1 warning: parentheses around comparison in operand of & --- .../meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C | 2 +- src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C b/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C index bc36491fa7..0920b53640 100644 --- a/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C +++ b/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C @@ -653,7 +653,7 @@ void Foam::meshCutAndRemove::setRefinement const edge& e = mesh().edges()[edgeI]; // Check if there is any cell using this edge. - if (debug & findCutCell(cuts, mesh().edgeCells()[edgeI]) == -1) + if (debug && findCutCell(cuts, mesh().edgeCells()[edgeI]) == -1) { FatalErrorIn ( diff --git a/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C b/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C index a86578e185..28e72d224a 100644 --- a/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C +++ b/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C @@ -601,7 +601,7 @@ void Foam::meshCutter::setRefinement const edge& e = mesh().edges()[edgeI]; // Check if there is any cell using this edge. - if (debug & findCutCell(cuts, mesh().edgeCells()[edgeI]) == -1) + if (debug && findCutCell(cuts, mesh().edgeCells()[edgeI]) == -1) { FatalErrorIn (